Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ECE4680
30
Addr<31:2> PC<31:28> Target 4 Instruction<25:0> 26 30 1 Adder Adder SignExt 30 30 00 30 1 Mux 0 Addr<1:0> Instruction Memory 32
0 30 Mux 1 30
Jump
Instruction<31:0>
Branch
ECE4680 Multipath.1 2002-3-31 ECE4680 Multipath.4
Zero
2002-3-31
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<0>
:
Rt Rs Rt
Rd RegDst
RegWrite ALUSrc RegDst MemtoReg MemWrite Branch Jump ExtOp ALUop<2> ALUop<1> ALUop<0>
Rt Zero ALU
Rs
Rd
MemWr
busW 32 Clk
32 32 WrEn Adr
imm16 Instr<15:0>
16
Data Memory
ALUSrc ExtOp
ECE4680 Multipath.2 2002-3-31 ECE4680 Multipath.5
2002-3-31
Concepts
Cycle time must be long enough for the load instruction: PCs Clock -to-Q + Instruction Memory Access Time + Register File Access Time + ALU Delay (address calculation) + Data Memory Access Time + Register File Setup Time + Clock Skew
instruction
Control
signals
Cycle time is much longer than needed for all other instructions. Examples: R-type instructions do not require data memory access Jump does not require ALU operation nor data memory access
ECE4680 Multipath.3
2002-3-31
ECE4680 Multipath.6
2002-3-31
This real (no clock input) register file may not work reliably in the single cycle processor because: We cannot guarantee Rw will be stable BEFORE RegWr = 1 There is a race between Rw (address) and RegWr (write enable)
5 5 5 32
Ra RegWr Rb
Reg File 32
busB 32
busA
Rw busW
This is the essence of the multiple cycle processor The advantages of the multiple cycle processor: Cycle time is much shorter Different instructions take different number of cycles to complete Load takes five cycles - Jump only takes three cycles Allows a functional unit to be used more than once per instruction Adder + ALU Instruction mem + Data mem
The real (no clock input) memory may not work reliably in the single cycle processor because: We cannot guarantee Address will be stable BEFORE WrEn = 1 There is a race between Adr and WrEn
32
WrEn Adr
Ideal Memory
Din Dout 32
32
ECE4680 Multipath.7
2002-3-31
ECE4680 Multipath.10
2002-3-31
Address
Solution for the multiple cycle implementation: Make sure Address is stable by the end of Cycle N Assert Write Enable signal ONE cycle later at Cycle (N + 1) Address cannot change until Write Enable is disasserted
Rs, Rt, Rd, Op, Func ALUctr ExtOp ALUSrc RegWr busA busB Address busW
ECE4680 Multipath.8
Delay through Control Logic New Value New Value New Value Register File Write Time New Value
2
Old Value Delay through Extender & Mux Old Value Old Value
3
New Value ALU Delay New Value
32
WrEn Adr
Independent Read (RAdr, Dout) and Write (WAdr, Din) ports Read and write (to different location) can occur at the same instruction cycle
32
Ideal Memory
Din Dout
32
Read Port is a combinational path: Read Address Valid --> Memory Read Access Delay --> Data Out Valid Write Port is also a combinational path:
00 30 32 32
MemWr
In real life for m-cycle machines: Neither register file nor ideal memory has the clock input The write path is a combinational logic delay path: - Write enable goes to 1 and Din settles down - Memory write access delay - Din is written into mem[address] Important: Address and Data must be stable BEFORE Write Enable goes to 1
ECE4680 Multipath.9
Clk
RAdr<1:0> <31:2>
32
WrEn Adr
Ideal Memory
Din Dout 32
MemWrite = 1 --> Memory Write Access Delay --> Data In is written into location[WrAdr]
Ideal Memory
WrAdr Din Dout 32
32
2002-3-31
ECE4680 Multipath.12
2002-3-31
Mux
32
PC
32 0
0 32 0 1 2 3 32
Zero ALU
Mux
Instruction Reg
32
MemWr=?
RAdr
RAdr
Mux
32 32
1 32
Ideal Memory
WrAdr 32 Din Dout 32
ALU
Reg File
Mux
Clk
32
32
Ideal Memory
32 32 WrAdr Din Dout 32
ALU Control
Op 6 6 Imm 16
ALUSelB=xx ALUOp=xx
2002-3-31
Clk
ECE4680 Multipath.13 2002-3-31 ECE4680 Multipath.16
Reg[rs] ; busB
Reg[rt] ;
Rfetch/Decode
ALUOp=Add 1: BrWr, ExtOp ALUSelB=10 x: RegDst, PCSrc IorD, MemtoReg Others: 0s
Why can we not further send target address to PC?
PC + SignExt(Imm16)*4
PCWrCond=0 Zero MemWr=0 IRWr=0
32 32 Rs 32 Rt Rt 0 Rd 1 5 5
(speculative calculation)
PCSrc=x
1
BrWr=1
32
IorD=x
RegDst=x
RegWr=0
ALUSelA=0
Target
Mux
0 32
Zero ALU
Mux
Instruction Reg
PC
32
32
MemWr=0
RAdr
32 32 32
RAdr
Mux
ALU
1 32
Clk
Ideal Memory
WrAdr 32 Din Dout 32
Reg File
0 1 2 3 32
Mux
32
32
32
Ideal Memory
WrAdr Din Dout
32
32
Clk
ECE4680 Multipath.14 2002-3-31
<< 2 Control
Op Func 6 6 Imm 16
ALU Control
Extend
ALUSelB=10
32
ALUOp=Add
2002-3-31
ExtOp=1
Branch Completion
BrComplete
PCWr=1
BrWr=0 Target PC
IorD=x Mux
32
PCSrc=1 ALUSelA=1
1
BrWr=0
32
RegDst=x
RegWr=0
Target
Mux
0 32
PC
32 32 32 0 0
0 32 0 1 2 3 32
32
Zero ALU
32 32
Rs 32 Rt Rt 0 Rd 1 5 5
Zero ALU
Mux
Instruction Reg
RAdr
Mux
Instruction Reg
Mux
RAdr
1 32 32
Ideal Memory
WrAdr 32 Din Dout
busA 32 busB 32
1 32 32 32
Ideal Memory
WrAdr 32 Din Dout
ECE4680 Multipath.15
Mux
Reg File
0 1 2 3 32
Mux
32
<< 2
Imm 16
ALU Control
ALUSelB=00
Extend
ALUSelB=01
32
ALUOp=Sub
2002-3-31
ExtOp=x
RegDst=x
RegWr=0
ALUSelA=0
Target
R-type Execution: ALU output busA op busB R-type Completion: Reg[rd] ALU output
Mux
PC
0 32 0 1 2 3 32
Zero ALU
Mux
RAdr
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Instruction Reg
ALUselA Zero
32
ECE4680 Multipath.19
R-type Execution
ALU Output busA op busB
Mux
Reg File
32
Rs 32 Rt Rt 0 Rd 1 5 5
Ra Rb Rw
Mux
Mux
Instruction Reg
busA 32
ALU
<< 2 Control
Op Func 6 6 Imm 16
ALU Control
Reg File
0 1 2 3 32
Mux
32
Extend
ALUSelB=10
32
busW busB 32
ALUOp=Add
1 Mux 0
ExtOp=1
ALUselB
2002-3-31
ECE4680 Multipath.22
RExec
PCWr=0
BrWr=0 Target
Register is NOT needed to save the outputs of R-type Execution: busA and busB will not change after Register Fetch Control signals ALUSelA, ALUSelB, and ALUOp will not change after R-type Execution Consequently ALU output will not change after R-type Execution In theory, you need a register to hold a signal value if:
32
RegDst=1
RegWr=0
Mux
32
PC
0
Rs 32 Rt Rt 0 Rd 1 1 Mux 0 5 5
0 32 0 1 2 3 32
Zero ALU
Mux
Instruction Reg
32 32
RAdr
32 32
ECE4680 Multipath.20
R-type Completion
R[rd] <- ALU Output
PCWr=0
Mux
1 32 0
Ideal Memory
WrAdr 32 Din Dout
Reg File
(1) The signal is computed in one clock cycle and used in another. (2) AND the inputs to the functional block that computes this signal can change before the signal is written into a state element. You can save a register if Cond 1 is true BUT Cond 2 is false: But in practice, this will introduce a multiple cycle delay path: A logic delay path that takes multiple cycles to propagate from one storage element to the next storage element
Mux
<< 2
ALU Control
Imm 16
Extend
32
ExtOp=x
MemtoReg=x
ALUOp=Rtype ALUSelB=01
2002-3-31 ECE4680 Multipath.23
2002-3-31
Rfinish
PCSrc=x ALUSelA=1
1
BrWr=0 Target
ALU
RegDst=1
RegWr=1
Mux
32
PC
Rs 32 Rt Rt 0 Rd 1 1 Mux 0 5 5
0 32 0 1 2 3 32
Zero ALU
Mux
Instruction Reg
32 32
RAdr
32 32
ECE4680 Multipath.21
Mux
1
Ideal Memory
WrAdr 32 Din Dout
Reg File
Mux
Mux
32
Rs 32 Rt Rt 0 Rd 1 1 Mux 0 5 5
Zero
32
Instruction Reg
Ra Rb Rw
busA 32
ALU
<< 2
ALU Control
Reg File
0 1 2 3 32
Mux
32
busW busB 32
Imm 16
Extend
32
ExtOp=x
MemtoReg=0
ALUOp=Rtype ALUSelB=01
2002-3-31 ECE4680 Multipath.24
ALU Control
ALUselB
2002-3-31
Ori Completion
ALUOp=Or
OriFinish
Reg[rt]
PCWr=0
ALU output
PCWrCond=0 Zero
PCSrc=x ALUSelA=1
1
BrWr=0 Target
IorD=x PC
32 32 0
MemWr=0 IRWr=0
32
RegDst=0
RegWr=1
Mux
32
Rs 32 Rt Rt 0 Rd 1 5 5
0 32 0 1 2 3 32
Zero ALU
Mux
Instruction Reg
RAdr
Mux
Rs 32 Rt Rt 0 Rd 1 1 Mux 0 5 5
Zero
32
32
Ra Rb Rw
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Mux
Reg File
Instruction Reg
ECE4680 Multipath.25
Mux
busA 32
32
ALU
Reg File
0 1 2 3 32
32
1 Mux 0
<< 2
ALU Control
Mux
busW busB 32
ALU Control
Imm 16
ALUselB
Extend
32
ExtOp=0
2002-3-31 ECE4680 Multipath.28
MemtoReg=0
ALUOp=Or ALUSelB=11
2002-3-31
PCWr=0
BrWr=1
32
PCWr=0
BrWr=1
32
Target PC Zero
32 32 32
Target
Mux
Mux
PC
32 32 0
0 32 0 1 2 3 32
RAdr
0 32 0
Mux
Zero ALU
Intruction Reg
Mux
Instruction Reg
32 32
ECE4680 Multipath.26
Ori Execution
ALU output busA or ZeroExt[Imm16]
PCWr=0
Mux
1
Ideal Memory
WrAdr 32 Din Dout
ALU
RAdr
Mux
Reg File
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Reg File
Mux
Mux
32 1 2 3 32
<< 2 Control Op
Func 6 6 Imm 16
ALU Control
ALUOp=Add
ExtOp=1
2002-3-31
ALU Control
Control
Op Func
6 6
Imm 16
Extend
ALUSelB=10
32
:
ECE4680 Multipath.29
ALUOp=Add
2002-3-31
ExtOp=1
busA + SignExt[Imm16]
AdrCal
PCWr=0
BrWr=0 Target
32
Target PC Zero
32 32 32
Mux
Mux
32
PC
32 32 0
0 32 0 1 2 3 32
0 32 0 1 2 3 32
Zero ALU
Mux
Mux
Instruction Reg
Instruction Reg
RAdr
RAdr
32 32
ECE4680 Multipath.27
Mux
1
Mux
ALU
Ideal Memory
WrAdr 32 Din Dout
Reg File
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Reg File
1 Mux 0
Mux
Mux
32
<< 2
ALU Control
<< 2
ALU Control
Imm 16
Extend
32
ExtOp=0
MemtoReg=x
ALUOp=Or ALUSelB=11
2002-3-31 ECE4680 Multipath.30
Imm 16
Extend
32
ExtOp=1
MemtoReg=x
ALUOp=Add ALUSelB=11
2002-3-31
busB
BrWr=0
1
PCWr
RegDst=x
RegWr=0
ALUSelA=1
32
Target PC Zero
32 32 32
BrWr Target
Mux
Mux
32
PC
32 32 0
Rs 32 Rt Rt 0 Rd 1 1 Mux 0 5 5
0 32 0 1 2 3 32
RAdr
Rs 32 Rt Rt 0 Rd 1 1 Mux 0 5 5
0 32 0 1 2 3 32
Zero ALU
Mux
Mux
Instruction Reg
Instruction Reg
RAdr
32 32
Mux
1
Mux
ALU
Ideal Memory
WrAdr 32 Din Dout
Reg File
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Reg File
Mux
Mux
32
<< 2
ALU Control
<< 2
ALU Control
Imm 16
Extend
32
ExtOp=1
MemtoReg=x
ALUOp=Add ALUSelB=11
2002-3-31 ECE4680 Multipath.34
Imm 16
Extend
32
ALUOp ALUSelB
2002-3-31
ExtOp
MemtoReg
mem[ALU output]
Summary
Disadvantages of the Single Cycle Processor Long cycle time
BrWr=0
1
Cycle time is too long for all instructions except the Load Multiple Cycle Processor: Divide the instructions into smaller steps Execute each step (instead of the entire instruction) in one cycle
32
Target
Mux
PC
0
0 32 0 1 2 3 32
Zero ALU
Mux
Instruction Reg
32 32
RAdr
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Do NOT confuse Multiple Cycle Processor with Multiple Cycle Delay Path Multiple Cycle Processor executes each instruction in multiple clock cycles Multiple Cycle Delay Path: a combinational logic path between two storage elements that takes more than one clock cycle to complete It is possible (desirable) to build a MC Processor without MCDP: Use a register to save a signals value whenever a signal is generated in one clock cycle and used in another cycle later
ECE4680 Multipath.32
Mux IorD=x
32 0
Reg File
Mux
32
<< 2
ALU Control
Imm 16
Extend
32
ExtOp=1
MemtoReg=x
ALUOp=Add ALUSelB=11
2002-3-31 ECE4680 Multipath.35 2002-3-31
Mem Dout
PCWrCond=0 Zero MemWr=0 IRWr=0
32 Rs 32 Rt Rt 0 Rd 1 5 5
LWwr
Rfetch/Decode
ALUOp=Add 1: BrWr, ExtOp ALUSelB=10 x: RegDst, PCSrc IorD, MemtoReg Others: 0s
BrComplete
beq
PCSrc=x ALUSelA=1
1
BrWr=0 Target
RegDst=0
RegWr=1
32
lw or sw Rtype
1: ExtOp LWmem ALUSelA, IorD ALUSelB=11 ALUOp=Add lw x: MemtoReg PCSrc
Mux
Ori OriExec
ALUOp=Or 1: ALUSelA ALUSelB=11 x: MemtoReg IorD, PCSrc
PC
0 32 0 1 2 3 32
Zero ALU
32 32
RAdr
1 32 32
Ideal Memory
WrAdr 32 Din Dout
Reg File
32
AdrCal
Mux
Instruction Reg
ECE4680 Multipath.33
Mux
1 Mux 0
Mux
sw LWwr
1: ALUSelA RegWr, ExtOp MemtoReg ALUSelB=11 ALUOp=Add x: PCSrc IorD 1: ExtOp SWMem ALUOp=Rtype MemWr ALUSelA 1: RegDst, RegWr ALUSelB=11 ALUselA ALUOp=Add ALUSelB=01 x: PCSrc,RegDst x: IorD, PCSrc MemtoReg ExtOp
<< 2
ALU Control
Rfinish
OriFinish
ALUOp=Or x: IorD, PCSrc ALUSelB=11 1: ALUSelA RegWr
Imm 16
Extend
32
ExtOp=1
MemtoReg=1
ALUOp=Add ALUSelB=11
2002-3-31
ECE4680 Multipath.36
2002-3-31
ECE4680 Multipath.37
2002-3-31