Control Path Design
Control Path Design
Computer Architecture
Lecture 9: Designing Single Cycle Control
361 control.1
31 26 21 16 11 6 0
° ADD and subtract op rs rt rd shamt funct
• add rd, rs, rt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
• sub rd, rs, rt
31 26 21 16 0
° OR Imm: op rs rt immediate
• ori rt, rs, imm16 6 bits 5 bits 5 bits 16 bits
° BRANCH:
• beq rs, rt, imm16
° JUMP: 31 26 0
• j target op target address
6 bits 26 bits
361 control.2
1
Recap: A Single Cycle Datapath
° We have everything except control signals (underline)
• Today’s lecture will show you how to generate the control signals
Branch Instruction<31:0>
Instruction
<21:25>
<16:20>
<11:15>
<0:15>
Jump Fetch Unit
Rd Rt
RegDst Clk
1 Mux 0
Rs Rt Rt Rs Rd Imm16
RegWr 5 5 5 ALUctr
busA Zero MemWr MemtoReg
Rw Ra Rb
busW 32
32 32-bit
ALU
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc
ExtOp
361 control.3
Processor
Input
Control
Memory
Datapath Output
° Today’s Topic: Designing the Control for the Single Cycle Datapath
361 control.4
2
Outline of Today’s Lecture
° Summary
361 control.5
361 control.6
3
Instruction Fetch Unit at the Beginning of Add / Subtract
30
Addr<31:2>
PC<31:28> 30
Addr<1:0>
“00”
Target 4 1 Instruction
Instruction<25:0> 30
Mux
26 Memory
PC
0
30 0 32
Adder
30
Mux
“1”
Adder
1 Jump = previous Instruction<31:0>
Clk 30
SignExt
imm16 30
Instruction<15:0> 16
361 control.7
<16:20>
<11:15>
<0:15>
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = 0
ExtOp = x
361 control.8
4
Instruction Fetch Unit at the End of Add and Subtract
° PC <- PC + 4
• This is the same for all instructions except: Branch and Jump
30
Addr<31:2>
PC<31:28> 30
Addr<1:0>
“00”
Target 4 1 Instruction
Instruction<25:0> 30
Mux
26 Memory
PC
0
30 0 32
Adder
30
Mux
“1”
Adder
1 Jump = 0 Instruction<31:0>
Clk 30
SignExt
imm16 30
Instruction<15:0> 16
Branch = 0 Zero = x
361 control.9
<16:20>
<11:15>
<0:15>
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = 1
ExtOp = 0
361 control.10
5
The Single Cycle Datapath during Or Immediate
31 26 21 16 0
op rs rt immediate
<21:25>
<16:20>
<11:15>
<0:15>
Rd Rt Fetch Unit
RegDst = 0 Clk
1 Mux 0
Rs Rt ALUctr = Or Rt Rs Rd Imm16
RegWr = 1 5 5 5 MemtoReg = 0
busA Zero MemWr = 0
Rw Ra Rb
busW 32
32 32-bit
ALU
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = 1
ExtOp = 0
361 control.11
<16:20>
<11:15>
<0:15>
32 0
Registers busB 0 32
Clk
Mux
32
Mux
WrEn Adr 1
Extender
1 Data In 32
imm16 Data 32
32
16 Memory
Clk
ALUSrc = 1
ExtOp = 1
361 control.12
6
The Single Cycle Datapath during Load
31 26 21 16 0
op rs rt immediate
<21:25>
<16:20>
<11:15>
<0:15>
Rd Rt Fetch Unit
RegDst = 0 Clk
1 Mux 0
Rs Rt ALUctr Rt Rs Rd Imm16
RegWr = 1 5 5 5 = Add MemtoReg = 1
busA Zero MemWr = 0
Rw Ra Rb
busW 32
32 32-bit
ALU
32 0
Registers busB 0 32
Clk
Mux
32
1 Data In 32
imm16 Data 32
32
16 Memory
Clk
ALUSrc = 1
ExtOp = 1
361 control.13
<16:20>
<11:15>
<0:15>
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = 1
ExtOp = 1
361 control.14
7
The Single Cycle Datapath during Store
31 26 21 16 0
op rs rt immediate
<21:25>
<16:20>
<11:15>
<0:15>
Rd Rt Fetch Unit
RegDst = x Clk
1 Mux 0
Rs Rt ALUctr Rt Rs Rd Imm16
RegWr = 0 5 5 5 = Add
MemtoReg = x
busA Zero MemWr = 1
Rw Ra Rb
busW 32
32 32-bit
ALU
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = 1
ExtOp = 1
361 control.15
<16:20>
<11:15>
<0:15>
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = 0
ExtOp = x
361 control.16
8
Instruction Fetch Unit at the End of Branch
31 26 21 16 0
op rs rt immediate
30
Addr<31:2>
PC<31:28> 30
Addr<1:0>
“00”
Target 4 1 Instruction
Instruction<25:0> 30
Mux
26 Memory
PC
0
30 0 32
Adder
30
Mux
“1”
Adder
1 Jump = 0 Instruction<31:0>
Clk 30
SignExt
imm16 30
Instruction<15:0> 16 Assume Zero = 1 to see
the interesting case.
Branch = 1 Zero = 1
361 control.17
nPC_sel
4
Adder
00
Mux
PC
Adder
Clk
imm16
361 control.18
9
The Single Cycle Datapath during Jump
31 26 0
op target address
<21:25>
<16:20>
<11:15>
<0:15>
Jump = 1 Fetch Unit
Rd Rt
RegDst = x Clk
1 Mux 0
Rs Rt ALUctr = x Rt Rs Rd Imm16
RegWr = 0 5 5 5 MemtoReg = x
busA Zero MemWr = 0
Rw Ra Rb
busW 32
32 32-bit
ALU
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
16 Memory
Clk
ALUSrc = x
ExtOp = x
361 control.19
30
Addr<31:2>
PC<31:28> 30
Addr<1:0>
“00”
Target 4 1 Instruction
Instruction<25:0> 30
Mux
26 Memory
PC
0
30 0 32
Adder
30
Mux
“1”
Adder
1 Jump = 1 Instruction<31:0>
Clk 30
SignExt
imm16 30
Instruction<15:0> 16
Branch = 0 Zero = x
361 control.20
10
Step 4: Given Datapath: RTL -> Control
Instruction<31:0>
Inst
<21:25>
<21:25>
<16:20>
<11:15>
<0:15>
Memory
Adr
Op Fun Rt Rs Rd Imm16
Control
DATA PATH
361 control.21
361 control.22
11
A Summary of the Control Signals
31 26 21 16 11 6 0
R-type op rs rt rd shamt funct add, sub
func
ALU ALUctr
op Main 6
ALUop Control 3
6 Control
(Local)
N
ALU
361 control.24
12
The Encoding of ALUop
func
op 6 ALU ALUctr
Main
ALUop Control
6 Control 3
(Local)
N
31 26 21 16 11 6 0
R-type op rs rt rd shamt funct
( P. 286 text)
funct<5:0> Instruction Operation ALUctr ALUctr<2:0> ALU Operation
10 0000 add 000 Add
10 0010 subtract 001 Subtract
ALU
13
The Truth Table for ALUctr funct<3:0> Instruction Op.
0000 add
ALUop R-type ori lw sw beq 0010 subtract
(Symbolic) “R-type” Or Add Add Subtract 0100 and
ALUop<2:0> 1 00 0 10 0 00 0 00 0 01 0101 or
1010 set-on-less-than
361 control.27
361 control.28
14
The Logic Equation for ALUctr<1>
ALUop func
bit<2> bit<1> bit<0> bit<3> bit<2> bit<1> bit<0> ALUctr<1>
0 0 0 x x x x 1
0 x 1 x x x x 1
1 x x 0 0 0 0 1
1 x x 0 0 1 0 1
1 x x 1 0 1 0 1
361 control.29
ALUop func
bit<2> bit<1> bit<0> bit<3> bit<2> bit<1> bit<0> ALUctr<0>
0 1 x x x x x 1
1 x x 0 1 0 1 1
1 x x 1 0 1 0 1
361 control.30
15
The ALU Control Block
func
6 ALU ALUctr
ALUop Control
3
(Local)
3
361 control.31
° RegWr: <=_____________
361 control.32
16
Step 5: Logic for each control signal
361 control.33
17
The “Truth Table” for RegWrite
361 control.35
ALUSrc
RegDst
MemtoReg
MemWrite
Branch
Jump
ExtOp
ALUop<2>
ALUop<1>
ALUop<0>
361 control.36
18
Putting it All Together: A Single Cycle Processor
ALUop
ALU ALUctr
RegDst 3 func Control
op Main 3
ALUSrc Instr<5:0> 6
6 Control
Instr<31:26> : Branch Instruction<31:0>
Instruction
<21:25>
<16:20>
<11:15>
<0:15>
Jump Fetch Unit
Rd Rt
RegDst Clk
1 Mux 0
Rs Rt Rt Rs Rd Imm16
RegWr 5 5 5 ALUctr
busA Zero MemWr MemtoReg
Rw Ra Rb
busW 32
32 32-bit
ALU
32 0
Registers busB 0 32
Clk
Mux
32
Mux
32
WrEn Adr 1
Extender
1 Data In 32
imm16 Data
32
Instr<15:0> 16 Memory
Clk
ALUSrc
ExtOp
361 control.37
Clocking Methodology
Clk
Setup Hold Setup Hold
Don’t Care
. . . .
. . . .
. . . .
361 control.38
19
Worst Case Timing (Load)
Clk
Clk-to-Q
PC Old Value New Value
Instruction Memoey Access Time
Rs, Rt, Rd, Old Value New Value
Op, Func
Delay through Control Logic
ALUctr Old Value New Value
° Cycle time is much longer than needed for all other instructions
361 control.40
20
Summary
° Single cycle datapath => CPI=1, CCT => long
21