461 Assignment
461 Assignment
Output
nput A Input B (A ⊕ B)
0 0 0
0 1 1
1 0 1
1 1 0
Design of ALU
Design of ALU
Recall: The Instruction Processing “Cycle”
q FETCH
q DECODE
q EVALUATE ADDRESS
q FETCH OPERANDS
q EXECUTE
q STORE RESULT
20
Instruction Processing Viewed Another Way
n Instructions transform Data (AS) to Data’ (AS’)
n This transformation is done by functional units
q Units that “operate” on data
n These units need to be told what to do to the data
n Multi-cycle machine:
q Control signals needed in the next cycle can be generated in
the current cycle
q Latency of control processing can be overlapped with latency
of datapath operation (more parallelism)
22
Review: Performance Analysis
n Execution time of a single instruction
q {CPI} x {clock cycle time} CPI: Cycles Per Instruction
Machine Encoding
n Semantics
if MEM[PC] == add rd rs rt
GPR[rd] ¬ GPR[rs] + GPR[rt]
PC ¬ PC + 4
31
(R-Type) ALU Datapath
Add
4
ALU operation
25:21 Read 3
Read register 1
PC address Read
20:16 Read data 1
register 2 Zero
Instruction
Instruction Registers ALU ALU
15:11 Write result
Instruction register
Read
memory data 2
Write
data
RegWrite
1
IF ID EX MEM WB
if MEM[PC] == ADD rd rs rt
GPR[rd] ¬ GPR[rs] + GPR[rt]
Combinational
PC ¬ PC + 4
**Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]
state update logic
**Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.] 32
I-Type ALU Instructions
n I-type: 2 register operands and 1 immediate
Machine Encoding
n Semantics
if MEM[PC] == addi rs rt immediate
PC ¬ PC + 4
GPR[rt] ¬ GPR[rs] + sign-extend(immediate)
33
Datapath for R- and I-Type ALU Insts.
Add
4
3 n
ALU operation
Read
Read 25:21
PC register 1 Mem
address Read
data 1
20:16
Read
Instruction register 2 Zero
Instruction Registers ALU ALU
15:11
Write result Address
Instruction register
Read
memory data 2
Write Data
RegDest data
memo
isItype RegWrite
ALUSrc
Write
data
116
Sign
32
isItype Mem
extend
IF ID EX MEM WB
if MEM[PC] == ADDI rt rs immediate
GPR[rt] ¬ GPR[rs] + sign-extend (immediate)
Combinational
PC ¬ PC + 4 state update logic
**Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]
Single-Cycle MIPS Processor
PCSrc1=Jump
Instruction [25– 0] Shift Jump address [31– 0]
left 2
26 28 0 1
Instruction [5– 0]
u Instruction register
u Op-code for current instruction
u Determines which micro-instructions are performed
u Flags
u State of CPU
u Results of previous operations
• Instruction execution is performed in steps. So, for each step there is a control
word/ microinstruction in the microprogram. A sequence of microinstructions
required to execute a particular instruction is called micro-routine
Microprogrammed Control Unit
OPeration
Operation
1. In the first step (instruction fetch) the Microinstruction address
generator would fetch the instruction from ‘instruction register’ (IR).
2. In the second step, the microinstruction address generator decodes the
instruction obtained from IR and retrieves the starting address of the micro-
routine required to perform the corresponding operation mentioned in the
instruction. It loads that starting address to microprogram counter.
3. In the third step, the ‘control word’ corresponding to the ‘starting address’ of
‘microprogram counter’ is read and as the execution proceeds, microprogram
address generator will increment the value of microprogram counter to read
the successive control words of the microroutine.
4. In the last microinstruction of a microroutine, there is a bit which we call end
bit. When end bit is set to 1 it denotes successful execution of that
microroutine.
5. After this, the microprogram address generator would return back to Step
1 again to fetch a new instruction. And the cycle goes on.
Comparison
Pararmeters Hardwired Control Unit Microprogrammed Control Unit
Implementation It is a circuitry approach. This control unit is implemented by
programming
Instructions It works well for simple instructions. It works well for complex
instructions also.
Costing Implementing hardwired structure Implementing microprograms is not
requires a cost. costly.