datapath and control: multicycle implementation
DESCRIPTION
Datapath and Control: MultiCycle Implementation. Performance of Single Cycle Machines. Assume following operation times: Memory units : 200 ps ALU and adders : 100 ps Register File (read or write): 50 ps Mux, control unit, PC access, sign extension unit, wires : 0 ps. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/1.jpg)
Datapath and Control:MultiCycle Implementation
![Page 2: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/2.jpg)
Performance of Single Cycle Machines
° Assume following operation times:• Memory units : 200 ps
• ALU and adders : 100 ps
• Register File (read or write): 50 ps
• Mux, control unit, PC access, sign extension unit, wires : 0 ps
Instr. Class Functional units used Total time
R-type Instr. Fetch (200 ps)
Reg access (50 ps)
ALU (100 ps)
Reg access (50 ps)
400ps
Load word Instr. Fetch (200 ps)
Reg access(50 ps)
ALU (100 ps)
Mem. Access (200 ps)
Register access (50 ps)
600 ps
Store Word Instr. Fetch (200 ps)
Reg access (50 ps)
ALU (100 ps)
Mem. Access (200 ps)
550 ps
Branch Instr. Fetch (200 ps)
Reg access(50 ps)
ALU (100 ps)
350 ps
Jump Instr. Fetch (200 ps)
200 ps
Clock cycle must cover longest instruction cycle period = 600ps (inefficient!)
![Page 3: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/3.jpg)
Clocking: single-cycle vs. multicycle
Single-cycle Implementation
add $t0,$t1,$t2 beq $t0,$t1,Lwaste waste
clock
![Page 4: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/4.jpg)
Multicycle Implementation
° Instruction execution divided into steps
°Each step will take one clock cycle (not each instruction) [CPI > 1]
shorter clock cycle: cycle time constrained by longest step, not longest instruction
°simpler instructions take fewer cycles
higher overall performance
![Page 5: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/5.jpg)
Clocking: single-cycle vs. multicycle
add $t0,$t1,$t2 beq $t0,$t1,L
Single-cycle Implementation
Multicycle Implementation
add $t0,$t1,$t2 beq $t0,$t1,L
• Multicycle Implementation: less waste=higher performance
waste waste
clock
clock
![Page 6: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/6.jpg)
How fast can we run the clock?
° Depends on how much we want done per clock cycle
• Can do: several “inexpensive” datapath operations per clock
- simple gates (AND, OR, …)
- single datapath registers (PC)
- sign extender, left shifter, multiplexor
• PLUS: exactly one “expensive” datapath operation per clock
- ALU operation
- Register File access (2 reads, or 1 write)
- Memory access (read or write)
![Page 7: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/7.jpg)
Multicycle Instruction Execution1: fetch instruction, PC=PC+4
2: decode, fetch registers, branch target
3: execute/compute data address/branch
4: access memory/complete R-type
5: store memory content to register
![Page 8: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/8.jpg)
Recall: Single Cycle Datapath and Control
![Page 9: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/9.jpg)
StepsCycle R-format Load Word
(lw)Store Word (sw)
beq
1 Fetch instr,
PC = PC+4
Fetch instr.
PC = PC+4
Fetch instr,
PC = PC+4
Fetch instr,
PC = PC+42 Read registers,
calculate branch target address
Read registers, calc branch target address
Read registers, calc branch target address
Read registers, calc branch target address
3 Do computation Calc data address
Calc data address
Compare reg values, set PC
4 Write result to register
Read data memory
Write to data memory
5 Write data to register
![Page 10: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/10.jpg)
Multicycle Datapath (overview)
Registers
ReadReg1
ALU
ReadReg2
WriteReg
Data
PC
Address
Instructionor Data
Memory
MIPS-liteMulticycle Version
A
B
ALU-Out
InstructionRegister
Data MemoryData
Register
Readdata 1
Readdata 2
• One ALU (no extra adders)• One Memory (no separate Imem, Dmem)• New Temporary Registers
![Page 11: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/11.jpg)
Multicycle Implementation
°Datapath changes• one memory: both instructions and data (because can access on separate steps)
• one ALU (eliminate extra adders)
• extra “invisible” registers to capture intermediate (per-step) datapath results
![Page 12: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/12.jpg)
Multicycle Datapath: Add Multiplexors
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
zero
15:11
Note inputs to multiplexors
![Page 13: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/13.jpg)
Multicycle Datapath: Add Multiplexors
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
zero
15:11
Note inputs to multiplexors
![Page 14: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/14.jpg)
Datapath + Control Points
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
IorDMemRead
MemWriteIRWrite
RegDstRegWrite
ALUSrcA
ALUSrcB
MemtoReg
ALUControl
ALUOp
22
4
(funct) 5:0
Mux
PCSrcPCWrite
PCWrite-Cond
![Page 15: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/15.jpg)
Cycle 1 Datapath: IR=Mem[PC]; PC=PC+4
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
ALUControl
2
4
(funct) 5:0
Mux
IR=Mem[PC];PC=PC+4
IorD=0MemRead
MemWriteIRWrite
RegDst=xRegWrite
ALUSrcA=0
ALUSrcB=01
MemtoReg=x ALUOp=00
2
PCSrc=0PCWrite
PCWrite-Cond
![Page 16: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/16.jpg)
Cycle 2: A=Reg[IR25:21]; B=Reg[IR20:16]; ALUOut= PC + sgn-ext(IR15:0) << 2
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
ALUControl
22
4
(funct) 5:0
Mux
A=Reg[IR25:21];B=Reg[IR20:16];ALUOut= PC +
sgn-ext(IR15:0) << 2
IorD=xMemRead
MemWriteIRWrite
RegDst=xRegWrite
ALUSrcA=0
ALUSrcB=11
MemtoReg=x ALUOp=00
2
PCSrc=xPCWrite
PCWrite-Cond
![Page 17: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/17.jpg)
Cycle 3: R-format: ALUOut = A op B
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
ALUControl
2
4
(funct) 5:0
Mux
ALUOut=A op B
IorD=xMemRead
MemWriteIRWrite
RegDst=xRegWrite
ALUSrcA=1
ALUSrcB=00
MemtoReg=x ALUOp=10
2
PCSrc=xPCWrite
PCWrite-Cond
![Page 18: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/18.jpg)
Cycle 4 R-format: Reg[IR15:11] = ALUOut
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
ALUControl
2
4
(funct) 5:0
Mux
Reg[IR15:11] = ALUOut
IorD=xMemRead
MemWriteIRWrite
RegDst=1RegWrite
ALUSrcA=x
ALUSrcB=x
MemtoReg=0 ALUOp=x
2
PCSrc=xPCWrite
PCWrite-Cond
![Page 19: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/19.jpg)
Cycle 3 beq: if (A==B) PC =ALUOut
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
ALUControl
2
4
(funct) 5:0
Mux
if (A==B) PC =ALUOut
IorD=xMemRead
MemWriteIRWrite
RegDst=xRegWrite
ALUSrcA=1
ALUSrcB=00
MemtoReg=x ALUOp=01
2
PCSrc=01PCWrite
PCWrite-Cond
![Page 20: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/20.jpg)
Cycle 3 lw/sw: ALUOut = A + sgn-ext(IR15:0)
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
IorD=xMemRead
MemWriteIRWrite
RegDst=xRegWrite
ALUSrcA=1
ALUSrcB=10
MemtoReg=x
ALUControl
ALUOp=00
22
4
(funct) 5:0
Mux
PCSrc=xPCWrite
PCWrite-Cond
ALUOut = A + sgn-ext(IR15:0)
![Page 21: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/21.jpg)
Cycle 4 lw:MDR = Mem[ALUout]
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
IorD=1MemRead
MemWriteIRWrite
RegDst=xRegWrite
ALUSrcA=x
ALUSrcB=x
MemtoReg=x
ALUControl
ALUOp=x
22
4
(funct) 5:0
Mux
PCSrc=xPCWrite
PCWrite-Cond
MDR = Mem[ALUout]
![Page 22: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/22.jpg)
Cycle 5 lw: Reg[IR15:11] = MDR
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
IorD=xMemRead
MemWriteIRWrite
RegDst=0RegWrite
ALUSrcA=x
ALUSrcB=x
MemtoReg=1
ALUControl
ALUOp=x
22
4
(funct) 5:0
Mux
PCSrc=xPCWrite
PCWrite-Cond
Reg[IR15:11] = MDR
![Page 23: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/23.jpg)
Cycle 4 (sw): Mem[ALUOut] = B
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
IorD=1MemRead
MemWriteIRWrite
RegDstRegWrite
ALUSrcA
ALUSrc
MemtoReg
ALUControl
ALUOp
22
4
(funct) 5:0
Mux
PCSrcPCWrite
PCWrite-Cond
Mem[ALUOut] = B
![Page 24: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/24.jpg)
Datapath + Control Points
ALU
Regs
ReadReg1
Readdata1
Readdata2
ReadReg2
WriteReg
WriteData
Sgn Ext- end
PC
<<2
A
B
ALU-Out
Address
ReadData
Mem
WriteData
MDR
Mux
25:21
20:16
15:0 0 1M2 u3 x
Mux
Mux
Mux
IR4
z
15:11
IorDMemRead
MemWriteIRWrite
RegDstRegWrite
ALUSrcA
ALUSrcB
MemtoReg
ALUControl
ALUOp
22
4
(funct) 5:0
Mux
PCSrcPCWrite
PCWrite-Cond
![Page 25: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/25.jpg)
Complete datapath
![Page 26: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/26.jpg)
Fig. 5.30 Summary of steps taken
![Page 27: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/27.jpg)
•All write control signals not asserted explicitly are deasserted
•All Multiplexer controls not specified explicitly are don’t care •asserted if name only
•otherwise exact value
1
FSM for Main Control Unit
0
![Page 28: Datapath and Control: MultiCycle Implementation](https://reader035.vdocument.in/reader035/viewer/2022062520/56815a81550346895dc7eb3c/html5/thumbnails/28.jpg)
Main Control Unit