Control signals are generated based on the instruction to be executed. Thus, a combinational circuit to generate signals based on opcode and function codes.

![](../../../schoolwork/cs2100/MIPS/media/Pasted image 20240915004453.png)

Control Signals

SignalStagePurposeValue
RegDstDecodeSelect destination register number0: $rt (Inst[20:16])
1: $rd (Inst[15:11])
RegWriteDecode/WritebackEnable write of register0: no write
1: write
ALUSrcALUSelect 2nd operand for ALU0: Operand2 = Register RD 2
1: Operand2 = SignExt(Inst[15:0)
ALUcontrolALUSelect operation to be performed0000: AND
0001: OR
0010: ADD
0110: SUB
0111: SLT
1100: NOR
MemReadMemoryEnable reading of data memory0: no read
1: write
MemWriteDecode/WritebackEnable write of register0: no write
1: write
MemToRegWritebackSelect result to be written back0: ALU result
1: Memory data
PCSrcMemory/WritebackSelect next $PC value0: $PC + 4
1: $(PC + 4) + IMM
ControlSignalR-formatlwswbeq
0RegDst1000
1ALUSrc0110
2MemToReg0100
3RegWrite1100
4MemRead0100
5MemWrite0010
6Branch0001
7ALUop11000
8ALUop00001

Control Bits

![](../../../schoolwork/cs2100/MIPS/media/Pasted image 20240915004512.png) 4 control bits are needed: Ainvert: 1 to invert A, 0 otherwise Binvert: 1 to invert B, 0 otherwise Operation: To select one of the 3 results

AinvertBinvertOperationFunction
0000AND
0001OR
0010ADD
0110SUB
0111SLT
1100NOR

Two-Level Implementation

![](../../../schoolwork/cs2100/MIPS/media/Pasted image 20240915004545.png)

OpcodeALUopInstruction OperationfunctALU actionALU control
lw00load wordxxxxxxadd0010
sw00store wordxxxxxxadd0010
beq01branch equalxxxxxxsub0110
R-type10add100000add0010
R-type10sub100010sub0110
R-type10and100100and0000
R-type10or100101or0001
R-type10set on less than101010set on less than0111
![](../../../schoolwork/cs2100/MIPS/media/Pasted image 20240918221115.png)

X

The X bits mean that the bits are not used to determine the ALU control signal.

ALUcontrol3 = 0 
ALUcontrol2 = (F1 AND ALUop1) OR (ALUop0) 
ALUcontrol1 = !ALUop1 OR !F2 
ALUcontrol0 = (F0 OR F3) AND ALUop1

ALUcontrol0ALUcontrol1ALUcontrol2ALUcontrol3ALUOp1ALUOp0F4F5F2F3F0F1(always 0)ORANDNOT

Deriving ALUcontrol

ALUcontrol3 = 0

For all the operations, ALUcontrol3 = 0;

ALUcontrol2 = (ALUop1 AND F1) OR ALUop0)

ALUcontrol2 is 1 for sub, slt, beq.

For sub and slt, the differentiating factor is ALUop1 = 1 and F1 = 1 For beq, it is when ALUop0 = 1.

ALUcontrol1 = !ALUop1 AND !F2

ALUcontrol1 is 1 for add, sub, slt, and all non Rformat.

When it is R format, so ALUop1 = 1. The differentiating factor is that F2 = 0 for these instructions and 1 otherwise.

ALUcontrol0 = ALUop1 AND (F3 OR F0)

ALUcontrol1 is 1 for or, slt.

All the instructions are R format, so ALUop1 = 1. slt and or do not share any common bits.

Thus, for slt, it is the only instruction with F3 = 1, so that can indicate the slt. For or, it is the only instruction with F0 = 1, so that can indicate or.

Combinational Circuit Implementation

R-formatRegDstALUSrcMemToRegRegWriteMemReadMemWriteBranchALUOp1ALUOp0lwRegDstALUSrcMemToRegRegWriteMemReadMemWriteBranchALUOp1ALUOp0swRegDstALUSrcMemToRegRegWriteMemReadMemWriteBranchALUOp1ALUOp0beqRegDstALUSrcMemToRegRegWriteMemReadMemWriteBranchALUOp1ALUOp0

![](../../../schoolwork/cs2100/MIPS/media/Pasted image 20240915011020.png) ![](../../../schoolwork/cs2100/MIPS/media/Pasted image 20240915011210.png)

The circuit connections indicate that the instructions set the particular control signal.

The O above the OR gates at the input refer to a collapsed NOT gate.

R-format

000000 has collapsed NOT gates everywhere.

Instruction Execution

Instruction execution refers to the process of:

  1. Reading contents of register/memory
  2. Perform computation through computational logic
  3. Write results to one or more storage elements

All of this should be performed within a clock period.

A storage element should not be read as it is being written.

Speed of single cycle implementation

Using a single cycle implementation, all instructions will take as much time as the slowest one, resulting in a long cycle time for each implementation. This is as the instructions cannot overlap in execution.

Multicycle implementation

Break instructions into execution steps -

  1. fetch
  2. decode + read
  3. ALU
  4. memory read/write
  5. register/write

By allocating this execution steps one clock cycle instead, one cycle is shorter, and the frequency is much higher.

Variable number of clock cycles are needed to complete different instructions.

Pipelining

Breaks instructions into execution steps one per clock cycle. Allows different instructions to be in different execution steps simultaneously.