6 MultiCycle
6 MultiCycle
RegWrite
MemRead
MemWrite
ALUSrcA
IRWrite
RegDst
PC
ALUOp
0
M Instruction rs Read
u Read [25-21] Register 1 Read 0
Address M
x data 1 A
Register File
1 Instruction u
rt Read
Instruction
[20-16]
Instruction 0
Register 2 x
1 A ALU
[15-0]
rd u
M
Write L out
Instruction Register
U
Write 1x
Data Memory
Register Write Read
0
Data data 2 B 0
M 4 1M
Memory u u
x
2
1x
Data 3
extender
Register
Left 2
Shift
ALUSrcB
MemToReg
Sign
CI-0114 Fundamentos de Arquitectura 11
Multi-cycle datapath
New added
datapath
elements.
RegWrite
MemRead
MemWrite
ALUSrcA
IRWrite
RegDst
PC
ALUOp
0
M Instruction rs Read
u Read [25-21] Register 1 Read 0
Address M
x data 1 A
Register File
1 Instruction u
rt Read
Instruction
[20-16]
Instruction 0
Register 2 x
1 A ALU
[15-0]
rd u
M
Write L out
Instruction Register
U
Write 1x
Data Memory
Register Write Read
0
Data data 2 B 0
M 4 1M
Memory u u
x
2
1x
Data 3
extender
Register
Left 2
Shift
ALUSrcB
MemToReg
Sign
CI-0114 Fundamentos de Arquitectura 15
Multi-cycle control
The IorD control signal.
●
Deasserted (0): the contents of PC is used as the address for the
memory unit
●
Asserted (1): The contents of ALUOut is used as the address for
the memory unit
RegWrite
MemRead
MemWrite
ALUSrcA
IRWrite
RegDst
PC
ALUOp
0
M Instruction rs Read
u Read [25-21] Register 1 Read 0
Address M
x data 1 A
Register File
1 Instruction u
rt Read
Instruction
[20-16]
Instruction 0
Register 2 x
1 A ALU
[15-0]
rd u
M
Write L out
Instruction Register
U
Write 1x
Data Memory
Register Write Read
0
Data data 2 B 0
M 4 1M
Memory u u
x
2
1x
Data 3
extender
Register
Left 2
Shift
ALUSrcB
MemToReg
Sign
CI-0114 Fundamentos de Arquitectura 17
Multi-cycle control
The RegDst control signal:
●
Deasserted (0): the register file destination number for the Write
register comes from the rt field
●
Asserted (1): the register file destination number for the Write
register comes from the rd field
RegWrite
MemRead
MemWrite
ALUSrcA
IRWrite
RegDst
PC
ALUOp
0
M Instruction rs Read
u Read [25-21] Register 1 Read 0
Address M
x data 1 A
Register File
1 Instruction u
rt Read
Instruction
[20-16]
Instruction 0
Register 2 x
1 A ALU
[15-0]
rd u
M
Write L out
Instruction Register
U
Write 1x
Data Memory
Register Write Read
0
Data data 2 B 0
M 4 1M
Memory u u
x
2
1x
Data 3
extender
Register
Left 2
Shift
ALUSrcB
MemToReg
Sign
CI-0114 Fundamentos de Arquitectura 19
Multi-cycle control
The MemToReg control signal:
●
Deasserted (0): the value fed to the register file input comes from
ALUout
●
Asserted (1): the value fed to the register file input comes from
MDR
RegWrite
MemRead
MemWrite
ALUSrcA
IRWrite
RegDst
PC
ALUOp
0
M Instruction rs Read
u Read [25-21] Register 1 Read 0
Address M
x data 1 A
Register File
1 Instruction u
rt Read
Instruction
[20-16]
Instruction 0
Register 2 x
1 A ALU
[15-0]
rd u
M
Write L out
Instruction Register
U
Write 1x
Data Memory
Register Write Read
0
Data data 2 B 0
M 4 1M
Memory u u
x
2
1x
Data 3
extender
Register
Left 2
Shift
ALUSrcB
MemToReg
Sign
CI-0114 Fundamentos de Arquitectura 21
Multi-cycle control
One of the changes we’ve made is that we’re using only a single ALU. We have
no dedicated adders on the side. To implement this change, we need to add
some multiplexors.
●
ALUSrcA multiplexor chooses between the contents of PC or the contents of
temporary register A as the first operand
●
ALUSrcB multiplexor chooses between the contents of temporary register B,
the constant 4, the immediate field, or the left-shifted immediate field as the
second operand
PCSrc
ALUSrcA
ALUOp
Control
IorD
MemRead
MemWrite
RegWrite
IRWrite
PC
RegDst
0
[31-28]
Left 2
[25-0]
Shift
1M
PC 0 u
M [25-21] rs Read
Read x
2
u Register 1 Read 0
Address M 3
x data 1 A
Instruction
Register File
1 [20-16] u
rt Read
A
Register
Register 2 x Zero
Instruction
ALU
0 1
MemToReg
M
L
ALUSrcB
rd u
Write Out
Register
U
Write 1x
Data Memory
Write Read
0
Data data 2 B 0
M 4 1M
Memory u
2
u
x
1x
Data 3
extender
Register [15-0]
Left 2
Shift
Sign
CI-0114 Fundamentos de Arquitectura 23
Multi-cycle 1-bit control signal
1-Bit signal name Effect when deasserted Effect when asserted
RegDst The register file destination number The register file destination number for the
for the Write register comes from the Write register comes from the rd field
rt field
RegWrite None Write register is written with the value of the
Write data input
ALUSrcA The first ALU operand is PC The first ALU operand is A register
MemToReg The value fed to the register file input The value fed to the register file input
is ALUout comes from Memory data register
10 The second input to the ALU is the sign-extended, lower 16 bits of the Instruction Register (IR).
11 The second input to the ALU is the sign-extended, lower 16 bits of the IR shifted left by 2 bits
01 The contents of ALUOut (the branch target address) are sent to the PC for writing
10 The jump target address (IR[25-0] shifted left 2 bits and concatenated with PC + 4[31-28]) is sent
to the PC for writing
0001
0010 Substrac operation
0101 Or operation
IR = Memory[PC];
PC = PC + 4;
Operations:
●
Send contents of PC to the memory element as the address
●
Read instruction from memory
●
Write instruction into IR for use in next cycle
●
Increment PC by 4
MemRead None
MemWrite None
IRWrite
PCSource None
ALUOp
ALUSrcA
ALUSrcB
RegWrite
MemRead 1
MemWrite 0
IRWrite 1
PCSource 00
ALUOp xxxx
ALUSrcA 0
ALUSrcB 01
RegWrite 0
A = Reg[IR[25-21]];
B = Reg[IR[20-16]];
ALUOut = PC + (sign-extend(IR[15-0]) << 2);
Operations:
●
Decode instruction
●
Optimistically read registers
●
Optimistically compute branch target
Signal Value
ALUOp
ALUSrcA
ALUSrcB
Signal Value
ALUOp 0000
ALUSrcA 0
ALUSrcB 11
Signal Value
ALUOp 0000
ALUSrcA 1
ALUSrcB 10
Signal Value
ALUOp xxxx
ALUSrcA 1
ALUSrcB 10
Signal Value
ALUOp 0010
ALUSrcA 1
ALUSrcB 00
PCSource 01
PCWriteCond 1
Signal Value
PCSource 10
PCWrite 1
Signal Value
MemRead 1
IorD 1
IRWrite 0
Signal Value
MemWrite 1
IorD 1
Signal Value
MemToReg 0
RegWrite 1
RegDst 1
Signal Value
MemToReg 1
RegWrite 1
RegDst 0
MemRead 1
MemWrite 0
IRWrite 1
PCSource 00
ALUOp 0000
ALUSrcA 0
ALUSrcB 01
RegWrite 0
Signal Value
ALUOp 0000
ALUSrcA 0
ALUSrcB 11
Signal Value
ALUOp 0000
ALUSrcA 1
ALUSrcB 10
Signal Value
MemToReg 0
RegWrite 1
RegDst 1
●
which has the following fields:
Op code rs rt Immediate
000100 10001 10010 XXXXXXXXXXXXXXXX
MemRead 1
MemWrite 0
IRWrite 1
PCSource 00
ALUOp 0000
ALUSrcA 0
ALUSrcB 01
RegWrite 0
Signal Value
ALUOp 0000
ALUSrcA 0
ALUSrcB 11
Signal Value
ALUOp 0010
ALUSrcA 1
ALUSrcB 00
PCSource 01
PCWriteCond 1
sw $rt, immed($rs)
●
which has the following fields:
Op code rs rt Immediate
101011 10111 10010 XXXXXXXXXXXXXXXX
MemRead 1
MemWrite 0
IRWrite 1
PCSource 00
ALUOp 0000
ALUSrcA 0
ALUSrcB 01
RegWrite 0
Signal Value
ALUOp 0000
ALUSrcA 0
ALUSrcB 11
Signal Value
ALUOp 0000
ALUSrcA 1
ALUSrcB 10
Signal Value
MemWrite 1
IorD 1
lw $rt, immed($rs)
●
which has the following fields:
Op code rs rt Immediate
100011 10111 10010 XXXXXXXXXXXXXXXX
MemRead 1
MemWrite 0
IRWrite 1
PCSource 00
ALUOp 0000
ALUSrcA 0
ALUSrcB 01
RegWrite 0
Signal Value
ALUOp 0000
ALUSrcA 0
ALUSrcB 11
Signal Value
ALUOp 0000
ALUSrcA 1
ALUSrcB 10
Signal Value
MemRead 1
IorD 1
IRWrite 0
Signal Value
MemToReg 1
RegWrite 1
RegDst 0