Beruflich Dokumente
Kultur Dokumente
Names on Breadboards?
2) Problem 5.30
Instruction_count x CPI
CPU time = ----------------------------------------
clock_rate
clock
RegWrite
RegDst
ovf
Instr[25-21] Read Addr 1
Instruction Read Address
Memory Register
Instr[20-16] Read Addr 2 Data 1 zero
Read Data
PC Instr[31-0] 0 File
ALU Memory Read Data 1
Address Write Addr
1 Read 0
Instr[15 Data 2 Write Data 0
Write Data
-11] 1
Instr[5-0]
Fetching Instructions
Fetching instructions involves
reading the instruction from the Instruction Memory
updating the PC to hold the address of the next
instruction
Add
Instruction
Memory
Read
PC Instruction
Address
Control
Unit
Read Addr 1
Read
Register
Read Addr 2 Data 1
Instruction
File
Write Addr Read
Data 2
Write Data
Read Addr 1
Register Read
Read Addr 2 Data 1 overflow
Instruction
File zero
ALU
Write Addr Read
Data 2
Write Data
overflow
Read Addr 1 zero
Register Read Address
Read Addr 2 Data 1 Data
Instruction
File Memory Read Data
ALU
Write Addr Read
Data 2 Write Data
Write Data
Sign MemRead
16 Extend 32
Executing Branch Operations
Branch operations involves
compare the operands read from the Register File during decode
for equality (zero ALU output)
compute the branch target address by adding the updated PC to
the 16-bit signed-ext offset field in the instr
Add Branch
Add target
4 Shift address
left 2
ALU control
PC
Sign
16 Extend 32
Executing Jump Operations
Jump operation involves
replace the lower 28 bits of the PC with the lower 26 bits of
the fetched instruction shifted left by 2 bits
Add
4
4
Jump
Instruction Shift address
Memory
left 2 28
Read
PC Instruction
Address 26
Fetch, R, and Memory Access Portions
Add
RegWrite ALUSrc ALU control MemWrite MemtoReg
4
ovf
zero
Instruction Read Addr 1
Register Read Address
Memory
Read Addr 2 Data 1 Data
Read File
PC Instruction Memory Read Data
Address ALU
Write Addr Read
Data 2 Write Data
Write Data
MemRead
Sign
16 Extend 32
Adding the Control
Selecting the operations to perform (ALU, Register
File and Memory read/write)
Controlling the flow of data (multiplexor inputs)
31 25 20 15 10 5 0
R-type: op rs rt rd shamt funct
31 25 20 15 0
Observations
I-Type: op rs rt address offset
op field always
in bits 31-26 31 25 0
J-type: op target address
addr of registers
to be read are
always specified by the
rs field (bits 25-21) and rt field (bits 20-16); for lw and
sw rs is the base register
addr. of register to be written is in one of two places in rt (bits 20-
16) for lw; in rd (bits 15-11) for R-type instructions
offset for beq, lw, and sw always in bits 15-0
Single Cycle Datapath with Control Unit
0
Add
Add 1
4 Shift
left 2 PCSrc
ALUOp Branch
MemRead
Instr[31-26] Control MemtoReg
Unit MemWrite
ALUSrc
RegWrite
RegDst
ovf
Instr[25-21] Read Addr 1
Instruction
Register Read Address
Memory Instr[20-16] Read Addr 2 Data 1 zero
Data
Read
PC Instr[31-0] 0 File
ALU Memory Read Data 1
Address Write Addr
1 Read 0
Instr[15 Data 2 Write Data 0
Write Data
-11] 1
Instr[5-0]
R-type Instruction Data/Control Flow
0
Add
Add 1
4 Shift
left 2 PCSrc
ALUOp Branch
MemRead
Instr[31-26] Control MemtoReg
Unit MemWrite
ALUSrc
RegWrite
RegDst
ovf
Instr[25-21] Read Addr 1
Instruction
Register Read Address
Memory Instr[20-16] Read Addr 2 Data 1 zero
Data
Read
PC Instr[31-0] 0 File
ALU Memory Read Data 1
Address Write Addr
1 Read 0
Instr[15 Data 2 Write Data 0
Write Data
-11] 1
Instr[5-0]
Load Word Instruction Data/Control Flow
0
Add
Add 1
4 Shift
left 2 PCSrc
ALUOp Branch
MemRead
Instr[31-26] Control MemtoReg
Unit MemWrite
ALUSrc
RegWrite
RegDst
ovf
Instr[25-21] Read Addr 1
Instruction
Register Read Address
Memory Instr[20-16] Read Addr 2 Data 1 zero
Data
Read
PC Instr[31-0] 0 File
ALU Memory Read Data 1
Address Write Addr
1 Read 0
Instr[15 Data 2 Write Data 0
Write Data
-11] 1
Instr[5-0]
Branch Instruction Data/Control Flow
0
Add
Add 1
4 Shift
left 2 PCSrc
ALUOp Branch
MemRead
Instr[31-26] Control MemtoReg
Unit MemWrite
ALUSrc
RegWrite
RegDst
ovf
Instr[25-21] Read Addr 1
Instruction
Register Read Address
Memory Instr[20-16] Read Addr 2 Data 1 zero
Data
Read
PC Instr[31-0] 0 File
ALU Memory Read Data 1
Address Write Addr
1 Read 0
Instr[15 Data 2 Write Data 0
Write Data
-11] 1
Instr[5-0]
Adding the Jump Operation
Instr[25-0] 1
Shift 28 32
26 left 2 0
PC+4[31-28]
Add 0
Add 1
4 Shift
Jump left 2 PCSrc
ALUOp
Branch
MemRead
Instr[31-26] Control MemtoReg
Unit MemWrite
ALUSrc
RegWrite
RegDst
ovf
Instr[25-21] Read Addr 1
Instruction Read Address
Memory Register
Instr[20-16] Read Addr 2 Data 1 zero
Read Data
PC Instr[31-0] 0 File
ALU Memory Read Data 1
Address Write Addr
1 Read 0
Instr[15 Data 2 Write Data 0
Write Data
-11] 1
Instr[5-0]
Single Cycle Disadvantages & Advantages
Uses the clock cycle inefficiently the clock cycle
must be timed to accommodate the slowest
instruction
especially problematic for more complex instructions like
floating point multiply
Cycle 1 Cycle 2
Clk
lw sw Waste
IR
Memory Read Addr 1
PC
A
Address Read
Register
ALUout
Read Data Read Addr 2Data 1
(Instr. or Data) File ALU
Write Addr
Read
B
Write Data Write Data Data 2
MDR
Instr[31-26]
PC[31-28]
Shift 28
Instr[25-0]
left 2 2
0
1
Memory 0
PC
0 Read Addr 1
Address
A
Read
IR
1 Register 1 zero
Read Addr 2 Data 1
ALUout
Read Data
0 File
(Instr. or Data) ALU
Write Addr
1 Read
Write Data Data 2
B
1 Write Data 0
4
MDR
1
0 2
Instr[15-0] Sign Shift 3
Extend 32 left 2 ALU
Instr[5-0] control
Complete Multiple Datapath Finite State Machine
Exception Considerations
...
control logic points
...
...
State Reg
Inst Next State
Opcode
FPGA Field programmable gate Array
The Five Steps of the Load Instruction
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5
lw sw R-type
IFetch Dec Exec Mem WB IFetch Dec Exec Mem IFetch
lw sw Waste
multicycle clock
slower than 1/5th of
single cycle clock due
Multiple Cycle Implementation: to state register
overhead
Clk Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9Cycle 10
lw sw R-type
IFetch Dec Exec Mem WB IFetch Dec Exec Mem IFetch