Chapter 4 Part 1
Chapter 4 Part 1
Edition
The Hardware/Software Interface
Chapter 4
The Processor
§4.1 Introduction
Introduction
n CPU performance factors
n Instruction count
n Determined by ISA and compiler
n CPI and Cycle time
n Determined by CPU hardware
n We will examine two RISC-V implementations
n A simplified version
n A more realistic pipelined version
n Simple subset, shows most aspects
n Memory reference: ld, sd
n Arithmetic/logical: add, sub, and, or
n Control transfer: beq
PC
offset
PC
read
read
write
Instruction
Address Immediate Value
From instruction
Multiplexers
n Can’t just join
wires together
n Use multiplexers
Branch control
From ALU
ALU or Memory
Reg. or Immediate
A
Y
B
n Arithmetic/Logic Unit
n Multiplexer n Y = F(A, B)
n Y = S ? I1 : I0
A
I0 M
u Y ALU Y
I1 x
B
S F
Clk
D Q
D
Clk
Q
Clk
D Q Write
Write D
Clk
Q
Increment by
4 for next
64-bit instruction
register
Register File
X5 X1 Data from X5
…
X6 Data from X6
X31
Load/Store Instructions
n Read register operands [lw x6, 32(x7)]
n Calculate address using 12-bit offset [x7+32]
n Use ALU, but sign-extend offset
32-bit
instruction Extracts 12 bits
Extend to 64 bits
val(x6)
val(x7)
Extracts 12 bits
Extend to 64 bits
32-bit instruction Sign-bit wire
replicated
(x6)
0/x
0 0
(x5) (x7)
0/x
(x6) + (x7)
R-Type/Load/Store Datapath
lw x6, 8(x7)
(x7)
0
1 1
(x6) (x7)+8
8
00..0008 1
MEM[x7+8]
R-Type/Load/Store Datapath
sw x6, 16(x7)
(x7)
(x6) 1
1 x
(x7)+16
16
(x6)
00..0016 0
Full Datapath
ALU
opcode ALUOp Operation Opcode field ALU function control
ld 00 load register XXXXXXXXXXX add 0010
sd 00 store register XXXXXXXXXXX add 0010
beq 01 branch on equal XXXXXXXXXXX subtract 0110
Add
Sub
Add
Sub
And
Or
I[30] I[14-12]
Datapath With Control
R-Type Instruction
X
X
X
X
X
X
add
X
X X
sub
X