






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







This figure illustrates the flow-of-control for the ADD instruction. All three ports of the registerfile are used, and the write-enable bit (WE) is set for the register file. The ALU control signal is asimple ADD function.
Program Counter INSTRUCTION
REGISTER FILE
ADD: 000 rA rB 0000 rC
SRC2 SRC
NAND
This figure illustrates the flow-of-control for the BITWISE NAND instruction. All three ports ofthe register file are used, and the write-enable bit is set for the register file. The ALU control sig-nal is a BITWISE NAND function.
Program Counter INSTRUCTION
REGISTER FILE
NAND: 010 rA rB 0000 rC
SRC2 SRC
LUI
This figure illustrates the flow-of-control for the LOAD UPPER IMMEDIATE instruction. Thisinstruction replaces the top ten bits of an instruction with ten bits found in the instruction wordand zeroes out the bottom six bits. Only two ports of the register file are used; the second source operand is an immediate value. The write-enable bit is set for the register file.Compared to ADDI, the immediate-manipulation logic for LUI is slightly different; the logic for Left-Shift-6 looks like this:
The second argument to the ALU (SRC2) is ignored; this is accomplished by setting the ALUcontrol to be PASS1, which sends through the first argument unchanged. This same ALU controlwill be used for the JALR instruction as well. One could alternatively zero-extend the immediate value and use a SHIFT input to the ALU while inputting the value ‘6’ at the other ALU-input.However, the illustrated mechanism seems slightly less complicated.
Program Counter INSTRUCTION
REGISTER FILE
LLI: 011 rA TGT Left-Shift-
imm-
SRC2 SRC
LUI:Bit:^15 01114 13 12 reg A^11 109 87 imm-10 (0 to 1023)^65 43 SRC1 OPERAND:Bit: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SW
This figure illustrates the flow-of-control for the STORE DATA WORD instruction. Only twoports of the register file are used; the register file’s write port (TGT) is not used. The SRC2 outputport does not feed the ALU (as it normally does), but rather the DATA input of data memory. This is the value to be written to memory. The second ALU input is an immediate value that comesdirectly from the instruction word. The write-enable bit is set for data memory but not for the register file. The ALU control signal isa simple ADD function. The result of the ALU ADD goes to the ADDR port of data memory,which responds by latching the data word at the specified address. Note that the rA field of the instruction, which is normally tied to the register file’s TGT specifier,is instead tied to the SRC2 specifier. As in LW, the Sign-Extend-7 logic extends the sign of the immediate value (as opposed to simplyadding zeroes at the top) and in so doing produces a two’s complement number.
Program Counter INSTRUCTION
REGISTER FILE
Sign-Extend-
SW: 101 rA rB simm-7 DATA MEMORY WE SRC2^ SRC1 DATA ADDR
SW:Bit:^15 10114 13 12 reg A^11 109 reg B^8 7 65 simm-7 (-64 to 63)^43 SRC2 OPERAND:Bit: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BEQ
This figure illustrates the flow-of-control for the BRANCH-IF-EQUAL instruction. Like STOREDATA WORD instruction, it does not write a result to the register file. Two values are read fromthe register file and compared. The ALU control signal is a request for a test of equality (labeled EQ? in the diagram). If the ALU does not support an equality test, a SUBTRACT signal can beused, as most ALUs do have a 1-bit output signal that indicates a zero-value result: the two com-bined produce the same results as an EQ signal. The result of the comparison determines which of two values are to be placed into the programcounter. If the two values in the register file are equal, the value to be latched in the programcounter is the sum (note that the sign extension is just like in LW and SW). If the two values read from the register^ PC + 1 + (sign-extended immediate value) file are NOT equal, the value to be latched in the program counter is the sum PC + 1 (which is the normal program counter update value). We have shown a small portion of the CON-TROL module: that portion controlling the PC mux. The choice between PC+1 and PC+1+IMMis represented by an AND of the EQ! output of the ALU and a signal that represents CONDI- TIONAL BRANCH (i.e. the 3-bit opcode is BEQ:110). Thus, if the opcode is a conditionalbranch and the two values are equal, choose PC+1+IMM, otherwise choose PC+1. Note that the rA field of the instruction, which is normally tied to the register file’s TGT specifier,is instead tied to the SRC2 specifier.
Program Counter INSTRUCTION
REGISTER FILE
BEQ: 110 rA rB simm-
Sign-Ext-
Putting it All Together
This diagram combines all of the previous data and control paths into one complete framework.To accommodate all control and data paths, there are a number of muxes that choose the directionof data flow. These muxes are operated by the CONTROL module, which depends on only two inputs:1. the 3-bit OPCODE of the instruction; and
MUXalu
Sign-Extend-
Left-Shift-
FUNC (^) alu
Program Counter INSTRUCTION
REGISTER FILE
WE (^) rf
OP rA rC TGT
WE (^) dmem
rB MEMORY DATA SRC2 DATA IN ADDR
Sign-Ext-
MUXtgt TGT MUXrf
MUX (^) pc CONTROL MUXalu
CONTROL module. The CONTROL module simply sets the control lines as appropriate for theinstruction, and all of the control and data paths are set up: after delays through the register file,the ALU, the data memory, and the corresponding muxes, all of the signals stabilize. At this point, the newly produced values are latched (in the register file, the data memory and/or the programcounter), and the new program counter causes a new instruction to be read from the instructionmemory. These are the signals that the CONTROL module exports: FUNC (^) alu This signal instructs the ALU to perform a given function. MUXalu1 This 1-bit signal controls the mux connected to the SRC1 input of the ALU. Themux chooses between the SRC1 output of the register file and the left-shifted imme-diate value (to be used for LUI instructions). MUXalu2 This 1-bit signal controls the mux connected to the SRC2 input of the ALU. Themux chooses between the SRC2 output of the register file and sign-extended imme-diate value (to be used for ADDI, LW, and SW instructions). MUXpc This 2-bit signal controls the mux connected the program counter. The mux choosesbetween the output of the ALU, the output of the +1 adder that produces the sumPC+1 on every cycle MUXrf This 1-bit signal controls the mux connected to the register file’s SRC2 operandspecifier, a 3-bit signal that determines which of the registers will be read out ontothe 16-bit SRC2 data output port. The mux chooses between the rA and rC fields of MUXtgt the instruction word.This 2-bit signal controls the mux connected to the register file’s 16-bit TGT data input port, which carries the data to be written to the register file (provided the write-enable bit of the register file is set). The mux chooses between the output of theALU, the output of the data memory, and the output of the +1 adder tied to the pro- WErf gram counter.This 1-bit signal enables or disables the write port of the register file. If the signal is WEdmem high, the register file can write a result. If it is low, writing is blocked.This 1-bit signal enables or disables the write port of the data memory. If the signal is high, the data memory can write a result. If it is low, writing is blocked.