CPU Design
CPU Design
CPU Design
Requirements
Datapath Design:
EECC550 - Shaaban
#1 Lec # 4 Winter 2012 12-11-2012
Using independent RTN, write the micro-operations required for target ISA
instructions.
1
This provides the the required datapath components and how they are connected.
EECC550 - Shaaban
#2 Lec # 4 Winter 2012 12-11-2012
Top-down Design:
Specify component behavior from high-level requirements (ISA).
Bottom-up Design:
Assemble components in target technology to establish critical timing
(hardware delays, critical path timing).
Iterative refinement:
Establish a partial solution, expand and improve.
Instruction Set
Architecture (ISA):
Provides
Requirements
Reg. File
Mux
Processor
Datapath
ALU
Reg
Cells
ISA Requirements
CPU Design
Control
Mem
Decoder
Sequencer
Gates
EECC550 - Shaaban
#3 Lec # 4 Winter 2012 12-11-2012
EECC550 - Shaaban
#4 Lec # 4 Winter 2012 12-11-2012
R-Type
26
op
6 bits
[31:26]
I-Type: ALU
31
[31:26]
31
J-Type: Jumps
[25:21]
16
rt
5 bits
[20:16]
21
rs
5 bits
[25:21]
11
rd
5 bits
shamt
5 bits
[15:11]
[10:6]
op
6 bits
0
funct
6 bits
[5:0]
16
0
Immediate (imm16)
rt
5 bits
16 bits
[20:16]
[15:0]
26
[31:26]
rs
5 bits
26
op
6 bits
Load/Store, Branch
21
Or address offset
0
target address
26 bits
[25:0]
EECC550 - Shaaban
#5 Lec # 4 Winter 2012 12-11-2012
OP
rs
6 bits
5 bits
[31:26]
2nd operand
[25:21]
Destination
rt
rd
5 bits
5 bits
[20:16]
[15:11]
shamt
funct
5 bits
6 bits
[10:6]
Function
Field
[5:0]
Rs, rt , rd
op: Opcode, basic operation of the instruction.
are register specifier fields
For R-Type op = 0
Independent RTN:
rs: The first register source operand.
Instruction Word Mem[PC]
rt: The second register source operand.
R[rd] R[rs] funct R[rt]
rd: The register destination operand.
PC PC + 4
shamt: Shift amount used in constant shift operations.
funct: Function, selects the specific variant of operation in the op field.
Operand register in rs
Destination register in rd
Examples:
add $1,$2,$3
sub $1,$2,$3
Operand register in rt
and $1,$2,$3
or $1,$2,$3
EECC550 - Shaaban
#6 Lec # 4 Winter 2012 12-11-2012
Destination
OP
rs
rt
6 bits
5 bits
5 bits
[31:26]
[25:21]
[20:16]
2nd operand
Immediate (imm16)
16 bits imm16
[15:0]
OP = 8
Examples:
OP = 12
Result register in rt
add immediate:
addi $1,$2,100
and immediate
andi $1,$2,10
Constant operand
in immediate
EECC550 - Shaaban
#7 Lec # 4 Winter 2012 12-11-2012
Src./Dest.
OP
rs
rt
6 bits
5 bits
5 bits
[31:26]
[25:21]
[20:16]
16 bits imm16
[15:0]
Signed address
offset in bytes
Sign
Extended
base register in rs
Examples:
source register in rt
Store word:
Load word:
Destination register in rt
Base or Displacement Addressing used (Mode 3)
Offset
sw $3, 500($4)
lw $1, 32($2)
Offset
base register in rs
EECC550 - Shaaban
#8 Lec # 4 Winter 2012 12-11-2012
rs
rt
6 bits
5 bits
5 bits
16 bits imm16
[31:26]
[25:21]
[20:16]
[15:0]
Signed address
offset in words
OP = 4
Examples:
OP = 5
Branch on equal
beq $1,$2,100
bne $1,$2,100
Added
to PC+4 to form
branch target
Sign extended
EECC550 - Shaaban
#9 Lec # 4 Winter 2012 12-11-2012
jump target
6 bits
26 bits
[31:26]
Word = 4 bytes
Examples:
Jump
j 10000
jal 10000
Jump target
in words
[25:0]
PC(31-28),jump_target,00
0 0
2 bits
EECC550 - Shaaban
#10 Lec # 4 Winter 2012 12-11-2012
31
I OR Immediate:
31
26
I BRANCH:
beq rs, rt, imm16
4
11
rs
5 bits
rt
5 bits
rd
5 bits
shamt
5 bits
funct
6 bits
[31:26]
[25:21]
[20:16]
[15:11]
[10:6]
[5:0]
26
21
16
op
6 bits
rs
5 bits
rt
5 bits
[31:26]
[25:21]
[20:16]
6 bits
[31:26]
31
16
op
6 bits
21
32 = add
34 = sub
26
op
6 bits
[31:26]
21
rs
5 bits
[25:21]
21
rs
5 bits
[25:21]
0
Immediate (imm16)
16 bits
[15:0]
16
rt
5 bits
[20:16]
0
Immediate (imm16)
16 bits Offset in bytes
[15:0]
16
rt
5 bits
[20:16]
0
Immediate (imm16)
16 bits Offset in words
[15:0]
EECC550 - Shaaban
#11 Lec # 4 Winter 2012 12-11-2012
Instruction
Fetch
Instruction Mem[PC]
Update program counter to address
Next
Instruction
of next instruction
Instruction
PC
PC + 4
Decode
Execute
Done by
Control Unit
(Based on Opcode)
Result
Store
T = I x CPI x C
Common
steps
for all
instructions
EECC550 - Shaaban
#12 Lec # 4 Winter 2012 12-11-2012
Common
Steps
EECC550 - Shaaban
#13 Lec # 4 Winter 2012 12-11-2012
T = I x CPI x C
CPI = 1
Add
Add
32
32
32
32
Data
Register #
PC
A ddress
Instruction
ISA
Registers
ALU
A ddress
Register #
Instruction
memory
Data
memory
Register #
32
4th Edition Figure 4.1 page 302 - 3rd Edition Figure 5.1 page 287
Data
EECC550 - Shaaban
#14 Lec # 4 Winter 2012 12-11-2012
R-Type Example:
Micro-Operation Sequence For ADD
add rd, rs, rt
32 = add
34 = sub
OP
6 bits
[31:26]
rs
5 bits
[25:21]
rt
rd
5 bits
5 bits
[20:16]
[15:11]
shamt
funct
5 bits
6 bits
[10:6]
[5:0]
PC PC + 4
Increment PC
Independent RTN ?
Program
Memory
Common
Steps
EECC550 - Shaaban
#15 Lec # 4 Winter 2012 12-11-2012
Instruction
address
32
Instruction
32
Instruction
memory
a. Instruction memory
Add Sum
PC
Instruction
Word
32
32
32
b. Program counter
32
32-bit
c. Adder
EECC550 - Shaaban
#16 Lec # 4 Winter 2012 12-11-2012
Instruction Mem[PC]
PC PC + 4
32
Add
32
4
32
PC PC + 4
PC
32
Read
address
Instruction
32
Instruction
memory
Instruction
Mem[PC]
EECC550 - Shaaban
#17 Lec # 4 Winter 2012 12-11-2012
5
5
Data
Read
register 1
Read
data 1
R[rs]
32
Read
register 2
Registers
Write
R[rt]
register
Read
data 2 32
Write
ALU operation
(Function)
32
Zero
Data
ALU ALU
result
32
32
Data
RegWrite
a. Registers
Register File:
b. ALU
Zero = Zero flag = 1
When ALU result equals zero
EECC550 - Shaaban
#18 Lec # 4 Winter 2012 12-11-2012
RW RA RB
Write Enable 5
EECC550 - Shaaban
#19 Lec # 4 Winter 2012 12-11-2012
Write Port
Write
Register 0
Data In
Write
Register
RW
5
rd?
rt?
0
1
5-to-32
Decoder
..
.
30
31
.
.
Register 1
Data In
Write
.
32
Write
..
.
..
.
Register 30
Data In
Write
Data In
Register 31
Data
Out
Data
Out
32
32
..
2 Read Ports
0
1
..
.
.
.
R[rs]
32
32-to-1
MUX
Register
Read Data 1
(Bus A)
30
31
5
Read Register 1
(RA)
Data
Out
Data
Out
rs
32
0
1
32
RW RA RB
Write Enable 5 5 5
busA
busW
32
32 32-bit
32
Registers
busB
Clk
32
Also see Appendix C in Book CD (3rd Edition Appendix B) - The Basics of Logic Design
..
.
32-to-1
MUX
30
31
32
R[rt]
Register
Read Data 2
(Bus B)
Read Register 2
(RB)
rt
EECC550 - Shaaban
#20 Lec # 4 Winter 2012 12-11-2012
Idealized Memory
Write Enable
Address
Data In
DataOut
Memory (idealized)
32
32
One input bus: Data In.
Clk
One output bus: Data Out.
Memory word is selected by:
Read Enable
Address selects the word to put on Data Out bus.
Write Enable = 1: address selects the memory
word to be written via the Data In bus.
Clock input (CLK):
The CLK input is a factor ONLY during write operation,
During read operation, this memory behaves as
a combinational logic block:
Address valid => Data Out valid after access time.
Ideal Memory = Short access time.
EECC550 - Shaaban
Compared to other components in CPU datapath
#21 Lec # 4 Winter 2012 12-11-2012
Hold
Setup
Hold
Dont Care
CLK-to-Q
.
.
.
CLK-to-Q
.
.
.
.
.
.
.
.
.
Clock
All storage element (e.g Flip-Flops, Registers, Data Memory) writes are triggered by
the same clock edge.
Cycle Time = CLK-to-Q + Longest Delay Path + Setup + Clock Skew
EECC550 - Shaaban
#22 Lec # 4 Winter 2012 12-11-2012
[25:21]
rs
[20:16]
rt
R[rs]
(Function)
e.g add = 0010
32
[15:11]
rd
R[rt]
32
32
32
EECC550 - Shaaban
#23 Lec # 4 Winter 2012 12-11-2012
Rw
32
Clk
Ra Rb
32 32-bit
Registers
5
busA
R[rs]
32
busB
R[rt]
ALU
busW
Rt
Result
32
32
EECC550 - Shaaban
#24 Lec # 4 Winter 2012 12-11-2012
PC+4
Clk
Old
Value
Rs, Rt, Rd,
Op, Func
PC
Clk-to-Q
New Value
Old
Value
ALUctr
Old
Value
RegWr
Old
Value
busA,
B
Old
Value
busW
Old
Value
Rd Rs Rt
RegWr 5 5
5
busA
R[rs]
32
busB
32
R[rt]
ALU
busW
32
Clk
Rw Ra Rb
32 32-bit
Registers
Register Write
Occurs Here
ALUct
r
Result
32
All register
writes occur on
falling edge of clock
(clocking methodology)
EECC550 - Shaaban
#25 Lec # 4 Winter 2012 12-11-2012
26
21
16
op
6 bits
rs
5 bits
rt
5 bits
[31:26]
[25:21]
[20:16]
0
Immediate (imm16)
16 bits
[15:0]
PC PC + 4
Increment PC
000 ..
Not in book version
000
Common
Steps
Imm16
EECC550 - Shaaban
#26 Lec # 4 Winter 2012 12-11-2012
Rt
Mux
RegWr
Rs Rt
5
5
5
Rw
busW
ALUctr
R[rt]
busB
ZeroExt
16
Result
32
Mux
32
imm16
ALU
32
32 32-bit
Registers
32
Clk
R[rs]
busA
Ra Rb
Function = OR
2x1 MUX
(width 32 bits)
32
ALUSrc
000
Imm16
EECC550 - Shaaban
#27 Lec # 4 Winter 2012 12-11-2012
31
35
26
op
6 bits
[31:26]
21
rs
5 bits
[25:21]
16
[20:16]
rt
5 bits
0
Immediate (imm16)
16 bits
[15:0]
Increment
PC
Instruction
Memory
Signed
Address offset
in bytes
Common
Steps
EECC550 - Shaaban
#28 Lec # 4 Winter 2012 12-11-2012
MemWrite
Address
32
32
Write
data
Read
data
32
Data
memory
MemRead
a. Data memory unit
Inputs:
for address and write (store) data
Output
for read (load) data
Data memory write or update is edge triggered at the
end of the cycle (clocking methodology)
16
Sign
ex t en d
32
For SignExt[imm16]
b. Sign-extension unit
EECC550 - Shaaban
#29 Lec # 4 Winter 2012 12-11-2012
32
Clk
Rs
5
5
Rw Ra Rb
32 32-bit
Registers
32
busB R[rt] 0
32
ALUSrc
Data In
32
Clk
ExtOp
32
MemWr
WrEn Adr
Data
Memory
32 bit
2X1 Mux
Mu
x
Extender
16
Offset
Effective
Address
Mux
32
imm16
MemtoReg
R[rs]
busA
ALU
busW
Rt
Mux 0
RegWr 5
LW
32
MemRd
Effective Address
EECC550 - Shaaban
#30 Lec # 4 Winter 2012 12-11-2012
31
26
op
6 bits
43
[31:26]
21
rs
5 bits
[25:21]
16
rt
5 bits
[20:16]
0
Immediate (imm16)
16 bits
[15:0]
Signed
Address offset
in bytes
PC PC + 4
Increment PC
Effective Address
To store at
Data Memory
Common
Steps
EECC550 - Shaaban
#31 Lec # 4 Winter 2012 12-11-2012
Rt
Mux
RegWr 5
32
Clk
Rs
Rt
Base Address register
Rw Ra Rb
32 32-bit
Registers
32
Offset
R[rt]
Clk
ALUSrc
32
Data In 32
32
ExtOp
Effective
Address
WrEn Adr
Data
Memory
Mux
busB R[rt]
32
Mux
16
R[rs]
busA
Extender
imm16
MemtoReg
MemWr
ALU
busW
ALUctr
Add =
SW
32
MemRd
Effective Address
EECC550 - Shaaban
#32 Lec # 4 Winter 2012 12-11-2012
31
26
op
6 bits
[31:26]
21
rs
5 bits
[25:21]
rt
5 bits
[20:16]
0
immediate
16 bits
[15:0]
PC Offset
in words
Common
Steps
Increment PC
16
Action
Zero : PC PC + ( SignExt(imm16) x 4 )
Branch Target
Then Zero = 1
EECC550 - Shaaban
#33 Lec # 4 Winter 2012 12-11-2012
Datapath For
Branch Instructions
Shift
left 2
[25:21] rs Read
Instruction
[20:16] rt
register 1
Read
data 1
Read
register 2
Regist ers
Write
register
Read
ISA
PC + 4 + ( SignExt(imm16) x 4
4
R[rs]
To branch
control logic
ALU Zero
R[rt]
data 2
Write
data
(Main ALU)
RegWrite
[15:0] imm16
Branch
target
Add Sum
SignExt(imm16) x 4
16
Zero flag =1
if R[rs] - R[rt] = 0
(i.e R[rs] = R[rt])
4th Edition Figure 4.9, page 312 - 3rd Edition Figure 5.9, page 297
EECC550 - Shaaban
#34 Lec # 4 Winter 2012 12-11-2012
Instruction Address
32
RegWr 5
4
0
busW
Clk
PC
Mux
Adder
Sign extend
shift left 2
PC Ext
imm16
00
Adder
32
PC+4
Rt
Rw Ra Rb
32 32-bit
Registers
PC
Branch
Target
Rs
R[rs]
busA
32
R[rt]
busB
32
Equal?
Branch
Zero
Main ALU
(subtract)
Clk
EECC550 - Shaaban
#35 Lec # 4 Winter 2012 12-11-2012
[25:21] rs
R[rs]
32
[20:16] rt
R[rt]
32
32
R[rt]
32
rt/rd
MUX
not shown
[15:0] imm16
SignExt(imm16)
32
EECC550 - Shaaban
#36 Lec # 4 Winter 2012 12-11-2012
32
32
Combination of Figure 4.10 (p. 314) and Figure 4.6 (p. 309)
[3rd Edition Figure 5.10 (p. 299) and Figure 5.6 (p. 293)]
PC
Add
4
PC
Read
address
rs
rt
Instruction
Instruction
memory
Read
register 1
Read
register 2
Write
data
Registers
16
0
M
u
x
1
A LU ALU
result
Address
Read
data
1
M
u
x
0
Data
memory
R[rt]
Sign
extend
MemtoReg
Zero
32
RegWrite
rt/rd
MUX
not shown
MemWrite
ALUSrc
Read R[rt]
data 2
Write
register
4 ALU operation
Read R[rs]
data 1
32
Write
data
32
MemRead
32
This is book version ORI not supported, no zero extend of immediate needed
EECC550 - Shaaban
#37 Lec # 4 Winter 2012 12-11-2012
Zero
32
32
PC +4
Branch
32
32
32
Branch Target
4
rs
R[rs]
rt
R[rt]
rt/rd
MUX
not shown
32
32
32
This is book version ORI not supported, no zero extend of immediate needed
4th Edition Figure 4.11 page 315 - 3rd Edition Figure 5.11 page 300
EECC550 - Shaaban
#38 Lec # 4 Winter 2012 12-11-2012
3rd Edition
The main ALU has four control lines (detailed design in Appendix B)
with the following functions:
th
ALU Control Lines
0000
0001
0010
0110
0111
1100
ALU Function
AND
OR
add
subtract
Set-on-less-than
NOR
4 Edition
Appendix C
Not Used
For our current subset of MIPS instructions only the top five functions
will be used (thus only three control lines will be used)
For R-type instruction the ALU function depends on both the opcode
and the 6-bit funct function field
For other instructions the ALU function depends on the opcode only.
A local ALU control unit can be designed to accept 2-bit ALUop control
lines (from main control unit) and the 6-bit function field and generate
the correct 4-bit ALU control lines.
Or 3 bits depending on number
functions actually used
EECC550 - Shaaban
#39 Lec # 4 Winter 2012 12-11-2012
Main
Control
func
6
ALUop
Or
3 bits
Opcode
Subtract = 01
Add = 00
Instruction
Opcode
Instruction
Operation
LW
SW
Branch Equal
R-Type
R-Type
R-Type
R-Type
R-Type
Load word
Store word
branch equal
add
subtract
AND
OR
set on less than
ALUctr
4
ALU
ALU
Control
(Local)
Desired
ALUOp Funct Field ALU Action
00
00
01
10
10
10
10
10
R-Type = 10
XXXXXX
XXXXXX
XXXXXX
100000
100010
100100
100101
101010
add
add
subtract
add
subtract
and
or
set on less than
ALU Control
Lines
0010
0010
0110
0010
0110
0000
0001
0111
EECC550 - Shaaban
#40 Lec # 4 Winter 2012 12-11-2012
Add
Subtract
Add
Subtract
AND
OR
Set-On-less-Than
Page 302
2
Function
Field
3 ALU Control Lines
4th line = 0
More details found in Appendix D in Book CD (3 rd Edition Appendix C)
EECC550 - Shaaban
#41 Lec # 4 Winter 2012 12-11-2012
32
PCSrc
32
PC +4
32
Add
4
Shift
left 2
RegWrite
PC
Read
address
Instruction
[31:0]
Instruction
memory
Instruction [25:21]
Read
register 1
rs
Instruction [20:16]
rt
Instruction [15:11]
rd
Read
register 2
M
u
x
RegDst
Instruction [15:0]
imm16
Write
register
Write
data
16
ALUSrc
R[rt]
0
1
Registers
Sign
extend
M
u
x
ALU ALU
result
ALU
control
Function Field
Instruction [5:0]
MemtoReg
Zero
ALUOp
Address
Read
data
32
R[rt]
32
MemWrite
R[rs]
Read
data 1
M
u
x
Branch
Target
32
Read
data 2
32
ALU
result
Branch
PC +4
32
Add
Zero
1
M
u
x
0
Data
Write memory
data
ALUOp (2-bits)
00 = add
01 = subtract
10 = R-Type
MemRead
32
This is book version ORI not supported, no zero extend of immediate needed
4th Edition Figure 4.15 page 320 - 3rd Edition Figure 5.15 page 305
EECC550 - Shaaban
#42 Lec # 4 Winter 2012 12-11-2012
PCSrc
Branch
Zero
PC+4
Zero
Function
Field
32
imm16
16
(Includes ORI
not in book version)
32
Data In
32
ExtOp ALUSrc
MemWr
MemtoReg
Clk
32
WrEn Adr
Mux
Clk
Extender
Clk
00 = add
01 = subtract
10 = R-Type
Main
ALU
ALU
busW
Mux
PC
Mux
Adder
Rs Rt
5
5
R[rs]
busA
Rw Ra Rb
32
32 32-bit
R[rt]
Registers
busB
0
32
ALU
Control
RegWr 5
Branch
Target
ALUop
(2-bits)
Imm16
Rd Rt
0
1
Adder
PC Ext
imm16
Rd
RegDst
00
Rt
Instruction<31:0>
<0:15>
Rs
<11:15>
Adr
<16:20>
<21:25>
Inst
Memory
Data
Memory
MemRd
EECC550 - Shaaban
#43 Lec # 4 Winter 2012 12-11-2012
Instruction<31:0>
Rd
<0:25>
Rs
<0:15>
Rt
<11:15>
Op Fun
<16:20>
Adr
<21:25>
<21:25>
Instruction
Memory
Imm16 Jump_target
Control Unit
Control Lines
RegDst
ALUSrc
MemtoReg
RegWrite
Mem
Read
Mem
Write
Branch
ALOp
(2-bits)
DATA PATH
EECC550 - Shaaban
#44 Lec # 4 Winter 2012 12-11-2012
RegDst
RegWrite
None
ALUSrc
Branch
MemRead
None
MemWrite
None
MemtoReg
EECC550 - Shaaban
#45 Lec # 4 Winter 2012 12-11-2012
R-Format
Control
Lines
lw
sw
beq
ALUOp (2-bits)
00 = add
01 = subtract
10 = R-Type
EECC550 - Shaaban
#46 Lec # 4 Winter 2012 12-11-2012
Similar to Figure 4.22 Page 327 (3rd Edition Figure 5.22 Page 312)
EECC550 - Shaaban
#47 Lec # 4 Winter 2012 12-11-2012
Control
Lines
To Datapath
EECC550 - Shaaban
#48 Lec # 4 Winter 2012 12-11-2012
32
PC +4
Add
32
PC +4
M
u
x
ALU Branch 1
Add
Target
result
PC +4
32
4
Instruction [3126]
Opcode
PC
Read
address
Instruction [2521] rs
Read
register 1
Instruction [2016] rt
Read
register 2
Instruction
[310]
Instruction
memory
0
Instruction [1511]
rd
Instruction [150]
imm16
M
u
x
Shift
left 2
RegDst
Branch
MemRead
MemtoReg
ALUOp
MemWrite
ALUSrc
RegWrite
Control
Write
register
Write
data
16
Read
data 1
R[rs]
Zero
R[rt]
Read
data 2
Registers
Sign
extend
32
M
u
x
ALU ALU
result
Address
Read
data
M
u
0x
Data
Write memory
data
ALU
control
Function Field
Instruction [50]
In this book version, ORI is not supportedno zero extend of immediate needed.
ALUOp (2-bits)
00 = add
01 = subtract
10 = R-Type
32
EECC550 - Shaaban
#49 Lec # 4 Winter 2012 12-11-2012
OP
2
Jump_target
6 bits
26 bits
[31:26]
Jump address
in words
[25:0]
PC PC + 4
Increment PC
PC PC(31-28),jump_target,00
Common
Steps
PC(31-28)
Jump
Address
4 bits
4 highest bits from PC + 4
jump target
0 0
26 bits
2 bits
EECC550 - Shaaban
#50 Lec # 4 Winter 2012 12-11-2012
PCSrc
PC+4
32
00
Adder
PC+4(31-28)
PC(31-28)
4 bits
26
Shift left 2
jump target
26 bits
28
32
PC
Branch
Target
Instruction(25-0)
jump_target
PC
32
Mux
Mux
Adder
imm16
PC Ext
Instruction(15-0)
JUMP
Jump
Address
Clk
PC(31-28),jump_target,00
Jump Address
0 0
EECC550 - Shaaban
2 bits
#51 Lec # 4 Winter 2012 12-11-2012
32
Shift
left 2
26
28
PC + 4 [3128]
Add
PC +4
32
PC +4
32
0
M
u
x
PC +4
Add
ALU
result
Branch
Target
M
u
x
32
Shift
left 2
RegDst
Jump
Branch
Opcode
MemRead
Instruction [3126]
MemtoReg
Control
ALUOp
MemWrite
ALUSrc
RegWrite
Instruction [2521]
PC
Read
address
Instruction [2016]
Instruction
[310]
Instruction
memory
rs
rt
0
Instruction [1511]
rd
Instruction [150]
imm16
M
u
x
Read
register 1
Read
data 1
Read
register 2
Zero
Read
data 2
Write
register
Write
data
16
R[rs]
ALU
R[rt]
0
M
u
x
Registers
Sign
extend
ALU
result
Address
Data
memory
R[rt]
Write
data
Read
data
M
u
x
32
32
ALU
control
Function Field
Instruction [50]
In this book version, ORI is not supportedno zero extend of immediate needed.
ALUOp (2-bits)
00 = add
01 = subtract
10 = R-Type
EECC550 - Shaaban
#52 Lec # 4 Winter 2012 12-11-2012
Mem
Write
lw
sw
beq
R-Format
Figure 4.18 page 323 (3rd Edition Figure 5.18 page 308) modified to include j
EECC550 - Shaaban
#53 Lec # 4 Winter 2012 12-11-2012
Clk
PC Old Value
Old Value
ALUctr
Old Value
ExtOp
Old Value
New Value
ALUSrc
Old Value
New Value
MemtoReg
Old Value
New Value
RegWr
Old Value
New Value
busA
busB
Register
Write Occurs
Old Value
Delay through Extender & Mux
Old Value
New Value
ALU Delay
Address
Old Value
New Value
Data Memory Access Time
busW
Old Value
New
EECC550 - Shaaban
#54 Lec # 4 Winter 2012 12-11-2012
Reg File
mux
ALU
mux
setup
Load
PC
Inst Memory
ALU
Data Mem
Store
PC
mux
Reg File
Critical Path
Inst Memory
Reg File
ALU
Data Mem
Branch
PC
Inst Memory
Reg File
Jump
PC
Inst Memory
mux
cmp
mux setup
mux
mux
EECC550 - Shaaban
#55 Lec # 4 Winter 2012 12-11-2012
Memory Units: 2 ns
ALU and adders: 2 ns
Register File: 1 ns
Control Unit < 1 ns
Control
Unit
2 ns
Instruction
Memory
2 ns
Main
ALU
Register
Read
Critical Path
PC + 4
ALU
2 ns
1 ns
Data
Memory
Register
Write
Critical
Path = 8 ns (LW)
(Load)
Branch Target
ALU
Time
2 ns
2ns
3ns
4ns
5ns
7ns
8ns
EECC550 - Shaaban
ns = nanosecond = 10-9 second
The clock cycle is determined by the instruction with longest delay: The load in this case which is 8 ns. Clock rate = 1 / 8 ns = 125 MHz
A program with I = 1,000,000 instructions executed takes:
Execution Time = T = I x CPI x C = 10 6 x 1 x 8x10 -9 = 0.008 s = 8 msec
Instruction
Class
Instruction
Memory
Register
Read
ALU
Operation
Data
Memory
ALU
2 ns
1 ns
2 ns
Load
2 ns
1 ns
2 ns
2 ns
Store
2 ns
1 ns
2 ns
2 ns
Branch
2 ns
1 ns
2 ns
Jump
2 ns
T = I x CPI x C
Register
Write
Total
Delay
1 ns
6 ns
1 ns
8 ns
7 ns
5 ns
2 ns
C = 8 ns
EECC550 - Shaaban
#57 Lec # 4 Winter 2012 12-11-2012
PC + 4
rs
R[rs]
rt
31
R[rt]
rd
imm16
1. Expand the multiplexor controlled by RegDst to include the value 31 as a new input 2.
2. Expand the multiplexor controlled by MemtoReg to have PC+4 as new input 2.
EECC550 - Shaaban
#59 Lec # 4 Winter 2012 12-11-2012
RegDst
MemtoReg
Is now 2 bits
ALUSrc
MemtoReg
Reg
Write
Mem Mem
Read Write Branch ALUOp1 ALUOp0
Jump
R-format
01
00
lw
00
01
sw
xx
xx
beq
xx
xx
xx
xx
JAL
10
10
R[31]
PC+ 4
Instruction Word Mem[PC]
R[31] PC + 4
PC Jump Address
PC Jump Address
EECC550 - Shaaban
#60 Lec # 4 Winter 2012 12-11-2012
EECC550 - Shaaban
#61 Lec # 4 Winter 2012 12-11-2012
Reg
Write
Mem Mem
Read Write Branch ALUOp1 ALUOp0
RegDst
ALUSrc
R-format
lw
sw
beq
LWR
rd
R[rt]
Jump
Add
EECC550 - Shaaban
#62 Lec # 4 Winter 2012 12-11-2012
Jump Memory
rs
rt
6 bits
5 bits
5 bits
address (imm16)
Not Used
16 bits
Add any necessary datapaths and control signals to the single cycle
datapath and justify the need for the modifications, if any.
Specify control line values for this instruction.
EECC550 - Shaaban
#63 Lec # 4 Winter 2012 12-11-2012
2
Jump
PC + 4
2
Branch Target
rs
R[rs]
rt
R[rt]
rd
imm16
EECC550 - Shaaban
#64 Lec # 4 Winter 2012 12-11-2012
RegDst
ALUSrc
MemtoReg
Reg
Write
Mem Mem
Read Write Branch ALUOp1 ALUOp0
R-format
00
lw
00
sw
00
beq
00
01
Jm
10
Jump
add
PC Mem[R[rs] + SignExt[imm16]]
EECC550 - Shaaban
#65 Lec # 4 Winter 2012 12-11-2012
Here, cycle time for load is longer than needed for all other instructions.
EECC550 - Shaaban
#66 Lec # 4 Winter 2012 12-11-2012