Download ECE 4750 Computer Architecture, Fall 2022 and more Lecture notes Computer Architecture and Organization in PDF only on Docsity!
Topic 2: Fundamental Processor
Microarchitecture
School of Electrical and Computer Engineering
- ECE 4750 Computer Architecture, Fall - revision: 2022-09-29-22- Cornell University
- 1 Processor Microarchitectural Design Patterns
- 1.1. Transactions and Steps
- 1.2. Microarchitecture: Control/Datapath Split
- 2 TinyRV1 Single-Cycle Processor
- 2.1. High-Level Idea for Single-Cycle Processors
- 2.2. Single-Cycle Processor Datapath
- 2.3. Single-Cycle Processor Control Unit
- 2.4. Analyzing Performance
- 3 TinyRV1 FSM Processor
- 3.1. High-Level Idea for FSM Processors
- 3.2. FSM Processor Datapath
- 3.3. FSM Processor Control Unit
- 3.4. Analyzing Performance
- 4 TinyRV1 Pipelined Processor
- 4.1. High-Level Idea for Pipelined Processors
- 4.2. Pipelined Processor Datapath and Control Unit
- 5 Pipeline Hazards: RAW Data Hazards
- 5.1. Expose in Instruction Set Architecture
- 5.2. Hardware Stalling
- 5.3. Hardware Bypassing/Forwarding
- 5.4. RAW Data Hazards Through Memory
- 6 Pipeline Hazards: Control Hazards
- 6.1. Expose in Instruction Set Architecture
- 6.2. Hardware Speculation
- 6.3. Interrupts and Exceptions
- 7 Pipeline Hazards: Structural Hazards
- 7.1. Expose in Instruction Set Architecture
- 7.2. Hardware Stalling
- 7.3. Hardware Duplication
- 8 Pipeline Hazards: WAW and WAR Name Hazards
- 8.1. Software Renaming
- 8.2. Hardware Stalling
- 9 Summary of Processor Performance
- 10 Case Study: Transition from CISC to RISC
- 10.1. Example CISC: IBM 360/M30
- 10.2. Example RISC: MIPS R2K
- Processor Microarchitectural Design Patterns1.2. Microarchitecture: Control/Datapath Split
1.2. Microarchitecture: Control/Datapath Split
Control Signals Status Signals
Control Unit
Datapath
imem
req_val
imem
req
imem
resp
dmem
req_val
dmem
req
dmem
resp
Memory
- TinyRV1 Single-Cycle Processor 2.1. High-Level Idea for Single-Cycle Processors 2. TinyRV1 Single-Cycle Processor
Time
Program =^
Instructions
Program ร^
Avg Cycles
Instruction ร^
Time
Cycle
- Instructions / program depends on source code, compiler, ISA
- Avg cycles / instruction (CPI) depends on ISA, microarchitecture
- Time / cycle depends upon microarchitecture and implementation
Microarchitecture CPI Cycle Time
Single-Cycle Processor 1 long
FSM Processor > 1 short
Pipelined Processor โ 1 short
Technology Constraints
logic is not too expensive, so
we do not need to overly
minimize the number of
registers and combinational
logic
- Assume multi-ported register
file with a reasonable number
of ports is feasible
combinational memory
Control Status
Control Unit
Datapath
<1 cycle combinational
Memory
regfile
imem req
imem resp
dmem req
dmem resp
- TinyRV1 Single-Cycle Processor 2.2. Single-Cycle Processor Datapath
2.2. Single-Cycle Processor Datapath
pc
regfile (read) regfile (write)
0000000 rs2 rs1 000 rd 0110011
ADD 31 2524 2019 15141211 76 0 add rd, rs1, rs R[rd] โ R[rs1] + R[rs2] PC โ PC + 4
pc
regfile (read) regfile (write)
rs1 000 rd 0010011 31 2019 15141211 76 0 imm
ADDI addi rd, rs1, imm R[rd] โ R[rs1] + sext(imm) PC โ PC + 4
- TinyRV1 Single-Cycle Processor 2.2. Single-Cycle Processor Datapath
Implementing ADD and ADDI Instructions
pc
regfile (read) regfile (write)
pc_plus
ir[24:20] alu
ir[19:15]
imemreq. addr
To control unit
imemresp. data
ir[11:7]
op2_sel
ir[31:7] immgen
pc
pc_plus4 regfile(read) (write)regfile
ir[24:20] alu
ir[19:15]
imemreq. addr
To control unit
imemresp. data
ir[11:7]
op2_sel
ir[31:7] immgen
mul wb_sel
0000001 rs2 rs1 000 rd 0110011
MUL 31 2524 2019 15141211 76 0 mul rd, rs1, rs R[rd] โ R[rs1] ร R[rs2] PC โ PC + 4
- TinyRV1 Single-Cycle Processor 2.2. Single-Cycle Processor Datapath
pc
pc_plus4 regfile(read) (write)regfile
ir[24:20] alu
ir[19:15]
imemreq. addr
To control unit
imemresp. data
ir[11:7]
op2_sel
ir[31:7] immgen
mul wb_sel
dmemreq. addr dmemresp. data dmemreq. data
imm_type
rf_wen
pc_sel
jalbr_targ
alu_func
rd 1101111 31 1211 76 0 imm
JAL jal rd, imm R[rd] โ PC + 4 PC โ PC + sext(imm)
imm = {inst[20], inst[31], inst[19:12], inst[30:21], 0 }
pc
pc_plus4 regfile(read) (write)regfile
ir[24:20] alu
ir[19:15]
imemreq. addr
To control unit
imemresp. data
ir[11:7]
op2_sel
ir[31:7] immgen
mul wb_sel
dmemreq. addr dmemresp. data dmemreq. data
imm_type
rf_wen
pc_sel
jalbr_targ
alu_func
jr_targ
rs1 000 1100111
31 2019 15141211 76 0 000000000000 00000
JR jr rs PC โ R[rs1]
- TinyRV1 Single-Cycle Processor 2.2. Single-Cycle Processor Datapath
pc
pc_plus4 regfile(read) (write)regfile
ir[24:20] alu
ir[19:15]
imemreq. addr
To control unit
imemresp. data
ir[11:7]
op2_sel
ir[31:7] immgen
mul wb_sel
dmemreq. addr dmemresp. data dmemreq. data
imm_type
rf_wen
pc_sel
jalbr_targ
alu_func
jr_targ eq
rs1 001 1100011 31 2019 15141211 76 0 rs 2524 imm imm
BNE bne rs1, rs2, imm if ( R[rs1] != R[rs2] ) PC โ PC + sext(imm) else PC โ PC + 4 inst[30:25], inst[11:8], 0 }^ imm^ = { inst[31], inst[7],
- TinyRV1 Single-Cycle Processor 2.3. Single-Cycle Processor Control Unit
2.3. Single-Cycle Processor Control Unit
imem dmem
pc imm op2 alu wb rf req req
inst sel type sel func sel wen val val
add pc+4 โ rf + alu 1 1 0
addi
mul pc+4 โ โ โ mul 1 1 0
lw pc+4 i imm + mem 1 1 1
sw
jal
jr jr โ โ โ โ 0 1 0
bne
Need to factor eq status signal into pc_sel signal for BNE!
2.4. Analyzing Performance
Time
Program =^
Instructions
Program ร^
Cycles
Instruction ร^
Time
Cycles
- Instructions / program depends on source code, compiler, ISA
- Cycles / instruction (CPI) depends on ISA, microarchitecture
- Time / cycle depends upon microarchitecture and implementation
- TinyRV1 Single-Cycle Processor 2.4. Analyzing Performance
Estimating cycle time
There are many paths through the design that start at a state element
and end at a state element. The โcritical pathโ is the longest path across
all of these paths. We can usually use a simple first-order static timing
estimate to estimate the cycle time (i.e., the clock period and thus also
the clock frequency).
pc
regfile (read) regfile (write)
pc_plus
ir[24:20] alu
ir[19:15]
imemreq. addr
To control unit
imemresp. data
ir[11:7]
op2_sel
ir[31:7] immgen
mul wb_sel
dmemreq. addr dmemresp. data dmemreq. data
imm_type
rf_wen
pc_sel
jalbr_targ
alu_func
jr_targ
eq
- register read = 1 ฯ
- register write^ = 1 ฯ
- regfile read = 10 ฯ
- regfile write^ = 10 ฯ
- memory read = 20 ฯ
- memory write = 20 ฯ
- +4 unit = 4 ฯ
- immgen = 2 ฯ
- mux = 3 ฯ
- multiplier = 20 ฯ
- alu = 10 ฯ
- adder = 8 ฯ
- TinyRV1 FSM Processor 3.1. High-Level Idea for FSM Processors 3. TinyRV1 FSM Processor
Time
Program =^
Instructions
Program ร^
Avg Cycles
Instruction ร^
Time
Cycle
- Instructions / program depends on source code, compiler, ISA
- Avg cycles / instruction (CPI) depends on ISA, microarchitecture
- Time / cycle depends upon microarchitecture and implementation
Microarchitecture CPI Cycle Time
Single-Cycle Processor 1 long
FSM Processor > 1 short
Pipelined Processor โ 1 short
Technology Constraints
where logic is expensive, so
we want to minimize the
number of registers and
combinational logic
combinational memory
- Assume multi-ported register
files and memories are too
expensive, these structures
can only have a single
read/write port
Control Status
Control Unit
Datapath
<1 cycle combinational
Memory
regfile
mem req
mem resp
- TinyRV1 FSM Processor 3.1. High-Level Idea for FSM Processors
3.1. High-Level Idea for FSM Processors
add addi mul lw sw jal jr bne Fetch Instruction 3 3 3 3 3 3 3 3 Decode Instruction 3 3 3 3 3 3 3 3 Read Registers 3 3 3 3 3 3 3 Register Arithmetic 3 3 3 3 3 3 Read Memory 3 Write Memory 3 Write Registers 3 3 3 3 3 Update PC 3 3 3 3 3 3 3 3
FetchInst lw
DecodeInst ArithReg ReadMem WriteReg ReadReg UpdatePC
FetchInst add
DecodeInst ArithReg WriteReg ReadReg UpdatePC
FetchInst DecodeInst jal UpdatePC
Single-Cycle
WriteReg
jal
FetchInst lw
DecodeInst ArithReg ReadMem WriteReg ReadReg UpdatePC
FetchInst add
DecodeInst ArithReg WriteReg ReadReg UpdatePC
FetchInst DecodeInst
FSM UpdatePC
(^) WriteReg
3.2. FSM Processor Datapath
Implementing an FSM datapath requires thinking about the required
FSM states, but we will defer discussion of how to implement the
control logic to the next section.
- TinyRV1 FSM Processor 3.2. FSM Processor Datapath
Implementing ADD Instruction
PC IR
pc_en ir_en
Datapath Bus pc_bus_en
A
a_en
alu_bus_en
memresp. data
memreq. addr
RD
rd_bus_en
To control unit
B
b_en
RF rf_wen bus_enrf_
alu_func
alu func
alu rf_addr_sel
rs1rs rd
+4:A + 4 +:A + B
F F F A A A
(pseudo-control-signal syntax)
add rd, rs1, rs
- TinyRV1 FSM Processor 3.2. FSM Processor Datapath
Full Datapath for TinyRV1 FSM Processor
PC IR
pc_en ir_en
Datapath Bus pc_bus_en
A
a_en
alu_bus_en
memresp. data
memreq. addr
RD
rd_bus_en
To control unit
B
b_en
RF rf_wen bus_enrf_
alu_func
alu func
alu rf_addr_sel
rs1rs rd
+4:A + 4 +:A + B
sext imm immgen_bus_en
b_sel C >>
c_sel c_en
x
+?:A +? B memreq. data
WD
wd_en
imm_type
imm gen
imm gen
cmp:A == B
i:sext( IR[31:20] ) s:sext( {IR[31:25],IR[11:7]} ) b:sext( {IR[31],IR[7],IR[30:25],IR[11:8],0} ) j:sext( {IR[31],IR[19:12],IR[20],IR[30:21],0} )
alu_bus_eneq
โ4:A โ 4
F F F A A A
AI AI AI
M M M
M
M
L L L L
S S S S
JA JA JA
JR0 B B B B B B
ADDI Pseudo-Control-Signal
Fragment
addi rd, rs1, imm