Professional Documents
Culture Documents
ECE4680 Datapath.1
2003-3-19
Output
ECE4680 Datapath.2
2003-3-19
ECE4680 Datapath.3
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.4 2003-3-19
OR Immediate: 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 Datapath.5
Clk
use PC to supply instruction address get the instruction from memory read registers use the instruction to decide exactly what to do All instructions use the ALU after reading the registers
Imm Why? memory-reference? arithmetic? control flow? 16 Data Address Data In Clk
32 Clk
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.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
ECE4680 Datapath.9
2003-3-19
_ Q D
D C
D latch
Q D latch _ C Q
Q _ Q
D
C
Q
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
ECE4680 Datapath.11 2003-3-19
32 Clk
Rw Ra Rb 32 32-bit Registers
32 32 ALU 32
DataOut
ECE4680 Datapath.12
nent
ECE4680 Datapath.13
2003-3-19
add
rd, rs, rt Fetch the instruction from memory The ADD operation Calculate the next instructions address
ECE4680 Datapath.14
2003-3-19
rt, rs, imm16 mem[PC] Addr Fetch the instruction from memory
R[rs] + SignExt(imm16) Calculate the memory address Mem[Addr] PC + 4 Load the data into the register Calculate the next instructions address
R[rt] PC
ECE4680 Datapath.15
2003-3-19
32
Sum Carry
32 Select
MUX (p.B-9,B-19)
Decoder
A B out0 out1 out2 out7
Decoder
32 32
MUX
32
ALU
OP A 32 In which cases do we need an adder, ALU, MUX or Decoder? ALU
32
Result Zero
B
ECE4680 Datapath.16
32
2003-3-19
Clk
The content is
ECE4680 Datapath.17
2003-3-19
32 32-bit Registers
ECE4680 Datapath.18
2003-3-19
32 32-bit Registers
Write Enable
C D C D
RA RB
0 1
Register 0 Register 1
RW
32-to-1 Decoder
30 31
M U X
busA
C D C
Register 30 Register 31
busW
Clk
M U X
busB
ECE4680 Datapath.19
2003-3-19
Memory (idealized) One input bus: Data In One output bus: Data Out
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.
Data In 32 Clk
DataOut 32
ECE4680 Datapath.20
2003-3-19
Clk
Instruction Word 32
ECE4680 Datapath.21
2003-3-19
add
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
ECE4680 Datapath.22
2003-3-19
sub
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
ECE4680 Datapath.23
2003-3-19
ALUctr
ALU
Result 32
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
ALUctr
ALU
ECE4680 Datapath.25
2003-3-19
ori
mem[PC] R[rt]
PC
ECE4680 Datapath.26
2003-3-19
Example: ori
ALUctr
Rw Ra Rb 32 32-bit Registers
Result 32
ALU
Mux
imm16
16
32 ALUSrc
ECE4680 Datapath.27
2003-3-19
lw
26 op 6 bits
21 rs 5 bits
16 rt 5 bits
0 immediate 16 bits
Load the data into the register Calculate the next instructions address
0 immediate 16 bits 0 immediate 16 bits
2003-3-19
31
ECE4680 Datapath.28
Example: lw
immediate 16 bits
21 rs 5 bits
16 rt 5 bits
Rw Ra Rb 32 32-bit Registers
Mux
32
imm16
16
Data Memory
ExtOp
2003-3-19
sw
mem[PC] Addr
R[rs] + SignExt(imm16) Calculate the memory address R[rt] Store the register into memory Calculate the next instructions address
Mem[Addr] PC PC + 4
ECE4680 Datapath.30
2003-3-19
Example: sw
immediate 16 bits
Rw Ra Rb 32 32-bit Registers
Data In 32
imm16
16
ECE4680 Datapath.31
ExtOp
2003-3-19
beq
rs, rt, imm16 Fetch the instruction from memory Calculate the branch condition
ECE4680 Datapath.32
2003-3-19
PC
ALUctr
imm16 16
Rw Ra Rb 32 32-bit Registers
ALU
Zero
To Instruction Memory
Mux
imm16
16
ExtOp
2003-3-19
1 30
2003-3-19
1 Carry In Adder
00
1 30 30
30
SignExt
target mem[PC] PC<31:2> Fetch the instruction from memory PC<31:28> concat target<25:0> Calculate the next instructions address
ECE4680 Datapath.37
2003-3-19
30 00 30 1 Mux 0
30 1
30
0 Mux 1
Jump
Instruction<31:0>
30
Branch
Zero
This is the whole design of Instruction Fetch Unit: 3 inputs: jump, Branch and Zero; 1 output: instruction word.
2003-3-19
Rt Zero ALU
Rs
Rd
busW 32 Clk
MemWr
32 32 WrEn Adr
imm16
16
Data Memory
ALUSrc ExtOp
ECE4680 Datapath.39 2003-3-19
ECE4680 Datapath.40
2003-3-19