Professional Documents
Culture Documents
ECE4680 Control.1
2003-3-17
The different fields are: op: operation of the instruction rs, rt, rd: the source and destination registers specifier shamt: shift amount funct: selects the variant of the operation in the op field address / immediate: address offset or immediate value target address: target address of the jump instruction
ECE4680 Control.2 2003-3-17
OR Imm: ori rt, rs, imm16 LOAD and STORE lw rt, rs, imm16 sw rt, rs, imm16 BRANCH: beq rs, rt, imm16 JUMP: j target
31
26 op 6 bits
ECE4680 Control.3
Rs Zero ALU
Rt
Rd
busW 32 Clk
MemWr
Mux
Data In 32 Clk
imm16
16
ALUSrc ExtOp
ECE4680 Control.4 2003-3-17
Output
Todays Topic: Designing the Control for the Single Cycle Datapath
ECE4680 Control.5
2003-3-17
add
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
ECE4680 Control.6
2003-3-17
mem[PC]
30 00 30 1 Mux 0
Adder
30 1
0 30 Adder Mux 1 30
SignExt
30
Branch = previous
Zero = previous
2003-3-17
1 Mux 0
Rs Zero
Rt
Rd
Imm16 MemtoReg = 0
MemWr = 0 0 Mux 32
ALU
32 WrEn Adr
imm16
16
Data Memory
ALUSrc = 0 ExtOp = x
ECE4680 Control.8 2003-3-17
30 00 30 1 Mux 0
Adder
30 1
0 30 Adder Mux 1 30
Jump = 0
Instruction<31:0>
SignExt
30
Branch = 0
Zero = x
2003-3-17
1 Mux 0 ALUctr = Or
Rs Zero ALU
Rt
Rd
Imm16 MemtoReg = 0
MemWr = 0 0 Mux 32
32 WrEn Adr
imm16
16
Data Memory
ALUSrc = 1 ExtOp = 0
ECE4680 Control.10 2003-3-17
1 Mux 0
Rs Zero ALU
Rt
Rd
Imm16 MemtoReg = 1
MemWr = 0 0 Mux
32 WrEn Adr
1 32
imm16
16
Data Memory
ALUSrc = 1 ExtOp = 1
ECE4680 Control.11 2003-3-17
1 Mux 0
Rs Zero ALU
Rt
Rd
Imm16 MemtoReg = x
MemWr = 1 0 Mux 32
32 WrEn Adr
imm16
16
Data Memory
ALUSrc = 1 ExtOp = 1
ECE4680 Control.12 2003-3-17
1 Mux 0
RegWr = 0
Rs Zero
Rt
Rd
Imm16 MemtoReg = x
busW 32 Clk
MemWr = 0 0 Mux 32
ALU
32 WrEn Adr
imm16
16
Data Memory
ALUSrc = 0 ExtOp = x
ECE4680 Control.13 2003-3-17
30 00 30 1 Mux 0
Adder
30 1
0 30 Adder Mux 1 30
Jump = 0
Instruction<31:0>
SignExt
Jump = 1 Clk Rt
1 Mux 0
Rs
Rt
Rd
Imm16 MemtoReg = x
32
1 32
imm16
16
Data Memory
30 00 30 1 Mux 0
Adder
30 1
0 30 Adder Mux 1 30
Jump = 1
Instruction<31:0>
SignExt
30
Branch = 0
Zero = x
2003-3-17
26 op op op rs rs
21 rt rt
16 rd
11 shamt
6 funct
op 6
Main Control
func 6 ALUop N
ALUctr 3 ALU
ECE4680 Control.18
2003-3-17
In this exercise, ALUop has to be 2 bits wide to represent: (1) R-type instructions I-type instructions that require the ALU to perform: - (2) Or, (3) Add, and (4) Subtract
Why not consider J-type?
To implement the full MIPS ISA, ALUop hat to be 3 bits to represent: (1) R-type instructions I-type instructions that require the ALU to perform: (2) Or, (3) Add, (4) Subtract, and (5) And (Example: andi)
R-type R-type 1 00 ori Or 0 10 lw Add 0 00 sw Add 0 00 beq Subtract 0 01 jump xxx xxx
2003-3-17
R-type R-type 1 00 21 rs
lw Add 0 00 11
sw Add 0 00 6 shamt
beq Subtract 0 01
funct
Recall ALU Homework (also P. 286 text): funct<5:0> 10 0000 10 0010 10 0100 10 0101 10 1010
ECE4680 Control.20
ALUctr
ALU
ECE4680 Control.21
2003-3-17
ALUctr<0> = !ALUop<2> & ALUop<0> + ALUop<2> & !func<2> & func<1> & !func<0>
ECE4680 Control.22
2003-3-17
ALUctr<1> = !ALUop<2> & ALUop<1> + ALUop<2> & !func<3> & func<2> & !func<1> ALUop<2> & func<3> & !func<2> & func<1> & !func<1>
ECE4680 Control.23
2003-3-17
ALUctr<2> = !ALUop<2> & ALUop<1> + ALUop<2> & !func<3> & func<2> & !func<1> & func<0> + ALUop<2> & func<3> & !func<2> & func<1> & !func<0>
ECE4680 Control.24
2003-3-17
ALUctr<0> = !ALUop<2> & ALUop<0> + ALUop<2> & !func<2> & func<1> & !func<0> ALUctr<1> = !ALUop<2> & ALUop<1> + ALUop<2> & !func<3> & func<2> & !func<1> + ALUop<2> & func<3> & !func<2> & func<1> & !func<1> ALUctr<2> = !ALUop<2> & ALUop<1> + ALUop<2> & !func<3> & func<2> & !func<1> & func<0> + ALUop<2> & func<3> & !func<2> & func<1> & !func<0>
ECE4680 Control.25
2003-3-17
:
ALUop 3 00 0000 R-type 1 0 0 1 0 0 0 x R-type 1 0 0
func 6
ALUctr 3
op RegDst ALUSrc MemtoReg RegWrite MemWrite Branch Jump ExtOp ALUop (Symbolic) ALUop <2> ALUop <1> ALUop <0>
ECE4680 Control.26
00 1101 10 0011 10 1011 00 0100 00 0010 ori lw sw beq jump x x x 0 0 x 0 1 1 1 x x x 1 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 x x 1 1 0 Add Subtract xxx Add Or 0 0 0 x 0 1 0 0 x 0 0 0 0 x 1
2003-3-17
RegWrite = R-type + ori + lw = !op<5> & !op<4> & !op<3> & !op<2> & !op<1> & !op<0> + !op<5> & !op<4> & op<3> & op<2> & !op<1> & op<0> + op<5> & !op<4> & !op<3> & !op<2> & op<1> & op<0>
op<5>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<0>
R-type
ori
lw
sw
beq
jump RegWrite
ECE4680 Control.27
2003-3-17
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<5>
<0>
..
op<0>
R-type
ori
lw
sw
beq
jump
RegWrite ALUSrc RegDst MemtoReg MemWrite Branch Jump ExtOp ALUop<2> ALUop<1> ALUop<0>
ECE4680 Control.28
2003-3-17
:
Rt Rs 5 5 Rt
Rd RegDst
Rt Zero ALU
Rs
Rd
busW 32 Clk
MemWr
32 32 WrEn Adr
imm16 Instr<15:0>
16
Data Memory
ALUSrc ExtOp
ECE4680 Control.29 2003-3-17
The effect of load in our single cycle processor is NOT delayed - lw $1, 100 ($2) // Load Register R1 add $3, $1, $0 // Move new R1 into R3
The effect of branch and jump in a real MIPS Processor is delayed: - Instruction Address: 0x00 j 1000 Instruction Address: 0x04 Instruction Address: 0x1000 add $1, $2, $3 sub $1, $2, $3
Branch and jump in our single cycle processor is NOT delayed - Instruction Address: 0x00 j 1000 Instruction Address: 0x1000 sub $1, $2, $3
ECE4680 Control.30
2003-3-17
Rs, Rt, Rd, Op, Func ALUctr ExtOp ALUSrc MemtoReg RegWr busA busB Address
Instruction Memory Access Time New Value Delay through Control Logic New Value New Value New Value New Value New Value
Register File Access Time New Value New Value ALU Delay New Value New
2003-3-17
Old Value
ECE4680 Control.32
2003-3-17
ECE4680 Control.33
2003-3-17