Professional Documents
Culture Documents
com
The figure below describes a small processor capable of executing 3 instructions: LOADC, which
loads a constant into one register, ADD, which gathers the values stored in two registers and saves the
result in a third, and SUB, which makes the difference between two registers and saves the result in a third.
To know what to do, a processor needs an instruction, a string of bits that encodes
information about:
• instruction type: field opcode = instruction [7: 6]. This field will be 2'b00 for
LOADC, 2'b10 for ADD and 2'b11 for SUB, regardless of operands.
• the address of the register to which the result will be written: the field dest = instruction [5: 4].
• the address of the register in which the first operand for the arithmetic instructions is stored:
the field addr1 = instruction [3: 2].
• the address of the register in which the second operand for the arithmetic instructions is
stored: the field addr2 = instruction [1: 0].
• date to be uploaded to the registry in case of LOADC: data = instruction [3: 0]
Example: instruction = 8'b10110001 => opcode = 2'b10 (ADD), dest = 2'b11, addr1 = 2'b00, addr2 = 2'b01
=> Reg [3] = Reg [0] + Reg [1]
1
1) Circuit implementation (15p - HDL):
Obs: Use the templates listed with to implement GREEN below, so that you follow
exactly the names of the signals on the interfaces and the names of the modules.
All signals with the reset function are synchronous and active in 0 (hence they are called nreset)
f) Implementation PROCESSOR: how all the sub-modules described above are instantiated and
connected according to the scheme.
Upload all hardware descriptions (Verilog file or files) of the above modules to the assignment
HDL, following the port name indications and the module below (the drawing does not contain
all the names of the ports and modules):
PROCESSOR module (nreset, clock, instruction, result);
INSTR_REG module (nreset, clock, instruction, we, opcode, addr1, addr2, dest, data); MUX
module (in0, in1, sel, out);
REGFILE module (op1, op2, addr1, addr2, dest, data_in, we, clock); ALU
module (op1, op2, opcode, result);
CONTROL module (clock, nreset, op, we_instruction, seldata, we_regfile);
NB: Do not load the testbench here, in HDL, but in SIM. Loading it into HDL can cause errors in the
automatic evaluation.
The scores on the respective modules are divided: as follows: PROCESSOR: 2p / CONTROL:
6p / MUX: 1p / REGFILE: 2p / ALU: 2p / INSTR_REG: 2p.
2
2) PROCESSOR circuit test mode (10p - SIM):
Implement a test module PROCESSOR_TB by which you generate at the input of the tested module
a sequence of instructions so as to perform the following algorithm:
• Load a constant in REGFILE at address 0.
• Load in REGFILE at address 1 a constant different from that at address 0.
• Calculate the sum of the two constants by ADD (REGFILE [0] + REGFILE [1]) and put the
result in REGFILE at address 2.
• Calculate the difference of the two constants by SUB (REGFILE [0] - REGFILE [1]) and put the
result in REGFILE at address 3.
Obs: The instructions need two clock cycles to be fully executed, so they must follow
each other every two clock cycles.
Upload on moodle PROCESSOR_TB.v also a printscreen with the obtained waveform, from which to observe the
variation in time of the state of the automaton and of the registers, in the assignment card
3) Answer in writing on an A4 page and upload a single picture (eg, taken with your mobile phone)
with the answers in the assignment ARG (5p - ARG):
a) What is the connection between the number of selection bits of a multiplexer and the number of inputs?
b) What are the parameters of a ROM memory, what do they mean (eg if you are told that it is a ROM memory of
MxN) and how do we calculate the storage capacity (in bits) according to them?
c) Draw the graph of the CONTROL machine, also highlighting the output values for each state.
d) What type of automaton is CONTROL? Mealy or Moore? Why?
e) If the PROCESSOR should recognize a total of 10 different instructions, what is the minimum number of
bits of the opcode to be able to encode all these instructions?