Professional Documents
Culture Documents
Output
ECE4680 Datapath.1
2003-3-19
ECE4680 Datapath.2
2003-3-19
The different fields are: op: operation of the instruction rs, rt, rd: the source and destination register specifiers 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 Datapath.3
2003-3-19
ECE4680 Datapath.4
2003-3-19
31
31
26 op 6 bits
Imm Why? memory-reference? arithmetic? control flow? 16 Data Address Data In Clk
32 Clk 0
Rw Ra Rb 32 32-bit Registers
32 32 ALU 32
DataOut
Next step: to fill in the details: more units, more connections, and control unit
ECE4680 Datapath.5 ECE4680 Datapath.6 2003-3-19
State Elements
Unclocked vs. Clocked Clocks used in synchronous logic when should an element that contains state be updated? falling edge
__
ECE4680 Datapath.7
2003-3-19
ECE4680 Datapath.8
2003-3-19
_ Q D
D C
D latch
D C
Q D latch _ Q
Q _ Q
D
C
Q
ECE4680 Datapath.9
2003-3-19
ECE4680 Datapath.10
2003-3-19
All storage elements are clocked by the same clock edge Edge-trigged: all stored values are updated on a clock edge Cycle Time = Latch Prop + Longest Delay Path + Setup + Clock Skew (Latch Prop + Shortest Delay Path - Clock Skew) > Hold Time
32 Clk
Rw Ra Rb 32 32-bit Registers
32 32 ALU 32
DataOut
ECE4680 Datapath.11
2003-3-19
ECE4680 Datapath.12
add
rd, rs, rt Fetch the instruction from memory The ADD operation Calculate the next instructions address
ECE4680 Datapath.13
2003-3-19
ECE4680 Datapath.14
2003-3-19
rt, rs, imm16 mem[PC] Addr Fetch the instruction from memory MUX (p.B-9,B-19) R[rs] + SignExt(imm16) Calculate the memory address
A B
32
Sum Carry
32 Select 32 32 OP
Decoder
out0 out1 out2 out7
Decoder
MUX
R[rt] PC
Mem[Addr] PC + 4
32
ALU
32
32
Result Zero
ALU
B
ECE4680 Datapath.15 2003-3-19 ECE4680 Datapath.16
32
2003-3-19
Register File consists of 32 registers: Two 32-bit output busses: busA and busB One 32-bit input bus: busW Register is selected by: RA selects the register to put on busA RB selects the register to put on busB RW selects the register to be written via busW when Write Enable is 1 Clock input (CLK)
The CLK input is a factor ONLY during write operation During read operation, behaves as a combinational logic block: - RA or RB valid => busA or busB valid after access time.
ECE4680 Datapath.17
2003-3-19
ECE4680 Datapath.18
2003-3-19
Memory (idealized) One input bus: Data In One output bus: Data Out
Data In 32 Clk
DataOut 32
Write Enable
C D C D
RA RB
0 1
Register 0 Register 1
RW
32-to-1 Decoder
30 31
M U X
Memory word is selected by: Address selects the word to put on Data Out Write Enable = 1: address selects the memory memory word to be written via the Data In bus Clock input (CLK) The CLK input is a factor ONLY during write operation During read operation, behaves as a combinational logic block: Address valid => Data Out valid after access time.
busA
C D C
Register 30 Register 31
busW
Clk
M U X
busB
ECE4680 Datapath.19
2003-3-19
ECE4680 Datapath.20
2003-3-19
add
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
mem[PC] R[rd]
Next Address Logic Address Instruction Memory
Clk
PC
R[rs] + R[rt] PC + 4
PC
Instruction Word 32
ECE4680 Datapath.21
2003-3-19
ECE4680 Datapath.22
2003-3-19
sub
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
ALUctr
ALU
Result 32
ECE4680 Datapath.23
2003-3-19
ECE4680 Datapath.24
2003-3-19
Register-Register Timing
Clk PC Old Value Clk-to-Q New Value Old Value Old Value Old Value Old Value Old Value Instruction Memory Access Time New Value Delay through Control Logic New Value New Value Register File Access Time New Value ALU Delay New Value
ori
mem[PC] R[rt]
PC
ALUctr Register Write Occurs Here
ALU
Result 32
0000000000000000 16 bits
ECE4680 Datapath.25
2003-3-19
ECE4680 Datapath.26
2003-3-19
Example: ori
lw
ALUctr
Calculate the memory address Load the data into the register Calculate the next instructions address
0 immediate 16 bits 0 immediate 16 bits
2003-3-19
Rw Ra Rb 32 32-bit Registers
ALU
imm16
16
32 ALUSrc
ECE4680 Datapath.27
Example: lw
sw
mem[PC]
Dont Care (Rt) busA 32 busB 32 Extender 32 ALUSrc ALU ALUctr MemtoReg
Addr
Rw Ra Rb 32 32-bit Registers
Mux
32
Mem[Addr] PC PC + 4
R[rt]
Store the register into memory Calculate the next instructions address
imm16
16
Data Memory
ECE4680 Datapath.29
ExtOp
2003-3-19
ECE4680 Datapath.30
2003-3-19
Example: sw
beq
rs, rt, imm16 Fetch the instruction from memory Calculate the branch condition Calculate the next instructions address
Rw Ra Rb 32 32-bit Registers
if (COND eq 0)
Mux 32 32 WrEn Adr Data Memory
Data In 32
- PC else - PC
PC + 4 + ( SignExt(imm16) x 4 ) PC + 4
Mux
imm16
16
ECE4680 Datapath.31
ExtOp
2003-3-19
ECE4680 Datapath.32
2003-3-19
26
Rt
The magic number 4 always comes up because: The 32-bit PC is a byte address And all our instructions are 4 bytes (32 bits) long In other words: The 2 LSBs of the 32-bit PC are always zeros There is no reason to have hardware to keep the 2 LSBs In practice, we can simplify the hardware by using a 30-bit PC<31:2>: Sequential operation: PC<31:2> = PC<31:2> + 1 Branch operation: PC<31:2> = PC<31:2> + 1 + SignExt[Imm16] In either case: Instruction Memory Address = PC<31:2> concat 00
ALUctr
imm16 16
Rw Ra Rb 32 32-bit Registers
ALU
Zero
To Instruction Memory
Mux
imm16
16
ExtOp
2003-3-19
ECE4680 Datapath.34
2003-3-19
1 Carry In Adder
00
1 30
1 30 30
30
SignExt
2003-3-19
ECE4680 Datapath.36
2003-3-19
target mem[PC] PC<31:2> Fetch the instruction from memory PC<31:28> concat target<25:0> Calculate the next instructions address
Clk imm16 Instruction<15:0> PC
30 Adder
1 30
Jump
Instruction<31:0>
SignExt
16
30
Branch
Zero
This is the whole design of Instruction Fetch Unit: 3 inputs: jump, Branch and Zero; 1 output: instruction word.
ECE4680 Datapath.37 2003-3-19 ECE4680 Datapath.38 2003-3-19
Branch Rd RegDst Rt Rs 5 5 busA 32 0 Mux ALU Rt Jump Clk Instruction Fetch Unit
Rt Zero
Rs
Rd
busW 32 Clk
MemWr
32 32 WrEn Adr
1 32 ALUSrc
imm16
Data In 32 Clk
16
Data Memory
ExtOp
ECE4680 Datapath.39 2003-3-19 ECE4680 Datapath.40 2003-3-19