Académique Documents
Professionnel Documents
Culture Documents
University of Waterloo
ECE 222
Digital Computers
Hiren Patel
NOTE:
HVZM6
Chapter 5
Instruction Execution
Datapath design
Hardwired Control-path
RISC processor
Datapath
Functional units, registers, memory interfaces
Must be able to implement every instruction in the ISA
Control
Implements the decode stage of the instruction execution
Sets the appropriate inputs for the mux selectors, write enables, and so
on to regulate flow of data in the processor
1: The maximum
number of registers
written to by the ISA is 3
one.
1
2: The maximum 2
number of registers
read by any instruction
in the ISA is two.
Memory
Data Memory
Data
Memory Address
Clock
Read/Write
3: or one of the
operands could be of
immediate-type and the
other register-type. 3
2
4: The third destination
register is written back
to the register file.
2: The instruction is 2
decoded and the source Decode
registers are read
3: The computation 3
specific for the Execute
instruction is performed.
4: If instruction is a 4
memory instruction then Memory
perform it in this stage.
1: Inter-stage registers.
MuxB selects RB or
immediate field based on the
instruction in IR 1
R-type then 0
I-type then 1
1: Inter-stage registers.
1
If non-memory operation
RZ holds computation result
1
MuxY puts RZ into RY
If Load
RZ holds effective address
MuxY selects memory data,
reads into RY
If Store
RZ holds effective address
1
RM holds data
1: Inter-stage registers.
Fetch
1. Memory address [PC]
2. IR [[PC]] (Memory data)
3. PC [PC] 4
Execute
1. RZ [RA] [RB]
Memory
1. RY [RZ]
Write-back
1. R3 [RY] (IR21-17)
Fetch
1. Memory address [PC]
2. IR [[PC]] (Memory data)
3. PC [PC] 4
Execute
1. RZ [RA] Immediate value
X
Memory
1. Memory address [RZ]
2. RY [[RZ]] (Memory data)
Write-back
1. R5 [RY] (IR26-22)
Fetch Memory
1. Memory address [PC] 1. No action
2. IR [[PC]] (Memory data)
Write-back
3. PC [PC] 4
1. No action
Decode (decode IR)
1. RA [R5] (IR31-27),
RB [R6] (IR26-21)
Execute
1. Compare [RA] to [RB]
2. If [RA]=[RB] then
1. PC [PC] Branch offset
2. Branch offset is immediate operand
3. Separate adder needed
1. Both operations done in one cycle
2. Adder used from instruction
address generator
Fetch
1. Memory address [PC]
2. IR [[PC]] (Memory data)
3. PC [PC] 4
Execute
1. PC-Temp [PC], PC [RA]
Memory
1. RY [PC-Temp]
Write-back
1. Link_Reg [RY]
ECE 222 (Patel, H.): Basic Processing Unit 26
Waiting for Memory
On a memory access
Hit in cache then MFC is set in the same clock cycle as request
Miss in cache then MFC stalls the execution of the instruction until
completion of request
Memory stage
MuxMA selects RZ when Load or Store
memory operations (effective address)
Adder
Increment PC by 4 for straight-
line execution
Compute new target address
for branch and subroutine calls
MuxINC
Selects between 4 and branch
offset
Branch offset extracted from IR
and sign-extended to 32-bits
MuxPC
Select next PC (result of adder)
Or address for subroutine
linkage
INC_select
0: +4
1: Branch offset
PC_select
0: RA (Subroutine)
1: Incremented PC
Needs PC_enable to be on
Recall
Requested data in cache (hit) results in one clock cycle
Requested data NOT in cache (miss) requires multiple clock cycles
Control signal MFC is used to wait for response from memory
Fetch stage
Memory address [PC], Read memory, Wait for MFC,
IR Memory data, PC [PC] 4
Memory stage
Memory address [RZ], Read/write memory, Wait for MFC,
RY Memory data (if read)
MEM_read
To read from memory
MEM_write
To write to memory
IR_enable
Loads new insn into IR
Activated in Fetch, after
MFC is asserted
MA_select
RZ: Load and Store
address
PC: Fetch address
RF_write C_select
When reading A and B, set to 0 R-type, dest is IR21-17
When writing C, set to 1
I-type, dest is IR26-22
B_select
0: RB
1: Immediate
ALU_op
k-bit control code
(AND, OR, ) encoded in k bits
Condition signals
Monitored by control circuitry
to ensure branching
Hardwired control
Implement circuitry (FSM) to govern the setting of control signals
Microprogrammed control
Set the control signals through software (microprogram)
ALU/Load/Call insn
RF_write = T5.
(ALUOp+LOADOp+CallOp)
Fetch/Branch
PC_enable = T1.MFC + T3.BROp
ECE 222 (Patel, H.): Basic Processing Unit 37
Summary
Instruction Execution
Datapath design
Hardwired Control-path