Datapath For The MIPS Architecture (A Single-Cycle Implementation)
Datapath For The MIPS Architecture (A Single-Cycle Implementation)
Datapath For The MIPS Architecture (A Single-Cycle Implementation)
Data Register # PC Address Instruction memory Instruction Registers Register # Register # Data Data memory
ALU
Address
Clock Methodology
State element Combinational logic
What can we do so that we can read the state and write back to it in the same clock cycle?
Add
4 Read address Instruction Instruction memory
PC
Instruction
Read data 1 Read register 2 Registers Write register Read data 2 Write data RegWrite
Read register 1
ALU operation
Read data 2
Address
MemRead
Branch target
Instruction
Read data 1 Read register 2 Registers Write register Read data 2 Write data RegWrite 16 Sign extend 32
ALU Zero
Add
4
PC
Registers Read register 1 Read Read register 2 data 1 Read Write data 2 register Write data RegWrite 16
3 ALUSrc
M u x
ALU operation
MemWrite MemtoReg
Address
Read data
M u x
Sign 32 extend
PC
M u x
Sign extend
32
M u x
ALU operation Op
funct
00 00 01 10 10 10 10 10
XXXXXX add XXXXXX add XXXXXX subtract 100000 100010 100100 100101 101010 add subtract and or set on less than
10
Funct field X X X X X X X X X X X X X X X X X X 0 0 0 0 0 1 X X 0 0 1 1 1 0 X X 0 1 0 0 0 1 X X 0 0 0 1 1 0
0 X 1 1 1 1 1 1
0 1 X X X X X X
Figure 5.15: Truth table for the three ALU control bits
11
R-format:
OP
6 bits
rs
5 bits
rt
5 bits
rd
shamt
16 bits
funct
I-format:
OP
6 bits
rs
rt
26 bits
address/immediate
J-format:
OP
target address
Looking at the datapath, youll see many control lines that have been left dangling up to now. We need to figure out how to set these values; the information for this will come from instructions.
12
Read data 1
ALU control
13
PCSrc
PC
Read data 1 Read register 2 Registers Read Write data 2 register Write data
0 M u x 1
Address
Write data
1 M u x 0
Instruction [15 0]
16
Sign extend
32 ALU control
Instruction [5 0]
14
Figure 5.21: Executing an R-type instruction fetch from instruction memory and increment the PC.
0 M u x
Instruction
Instruction memory
PC
Read address
0 M u x 1
Read data 1 Read register 2 Registers Read Write data 2 register Write data
0 M u x 1
Address
Write data
1 M u x 0
16
Sign extend
32 ALU control
15
0 M u x
Instruction memory
PC
0 M u x 1
Read data 1 Read register 2 Registers Read Write data 2 register Write data
Read register 1
0 M u x 1
Address
Write data
1 M u x 0
16
Sign extend
32 ALU control
16
0 M u x
PC
Read data 1 Read register 2 Registers Read Write data 2 register Write data
0 M u x 1
Address
Write data
1 M u x 0
Instruction [15 0]
16
Sign extend
32 ALU control
Instruction [5 0]
17
Figure 5.24: Finally, write result to destination register and increment the PC.
0 M u x
PC
Read data 1 Read register 2 Registers Read Write data 2 register Write data
0 M u x 1
Address
Write data
1 M u x 0
Instruction [15 0]
16
Sign extend
32 ALU control
Instruction [5 0]
18
lw sw beq
0 1 0
0 0 0
0 0 0
0 0 1
0 1 0
0 1 0
Using an opcode as input, you can define a function that produces control signals as outputs (RegDst, ALUSrc, MemtoReg, etc). The control unit in this case is simply a combinational circuit.
19
Performance of Single-Cycle Machines The goal: have every instruction executed in a single clock cycle. The drawback: the clock period is chosen to allow for the execution of the longest instruction. Variable clocks: is this a solution?
20
A Multicycle Machine
Goal: break up the execution of an instruction into steps, where each step takes one clock cycle to complete.
Memory
ALU
ALUOut
Data
Main differences: one memory unit for data and code, a single ALU, extra registers to hold data thats passed from one clock cycle to the next.
21
PC
Address
Memory MemData Write data
! # "
0 M u x 1
Instruction [31-26] Instruction Read register 1 Read Read register 2 data 1 Registers Write Read register data 2 Write data A
0 M Instruction u x 1 0 M u x 1
IRWrite
Op
RegDst 0
26
Shift left 2
28
1 u
x 2
! $ # " $
0 M u x 1 0 4 1 M u 2 x 3 B
16
PC [31-28]
ALUOut
Sign extend
32
Shift left 2
ALU control
22