Escolar Documentos
Profissional Documentos
Cultura Documentos
CS420/520 datapath.1
Output
CS420/520 datapath.2
Performance of a machine was determined by: Instruction count Clock cycle time Clock cycles per instruction Inst. Count Processor design (datapath and control) will determine: Clock cycle time Clock cycles per instruction In the next two lectures: Single cycle processor: - Advantage: One clock cycle per instruction - Disadvantage: long cycle time
Cycle Time
CS420/520 datapath.3
Compute result value or status Deposit results in storage (Register/Memory) for later use Determine successor instruction
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
CS420/520 datapath.6 UC. Colorado Springs Adapted from UCB97 & UCB03
ADD and subtract add rd, rs, rt sub rd, rs, rt 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 op
6 bits
CS420/520 datapath.7 UC. Colorado Springs
ALU
S
mode/function
a b
OR gate (c = a | b)
a 0 1 0 1 a 0 1 0 1 a 0 1 d 0 1
b 0 0 1 1 b 0 0 1 1
c=a&b 0 0 0 1 c=a|b 0 1 1 1
a b
Inverter (c = !a )
a
Multiplexor if d==0, c=a; otherwise c= b
c d
c=!A 1 0 c a b
Adapted from UCB97 & UCB03
a b
0 1
CS420/520 datapath.9
Mux
Result
CS420/520 datapath.10
4-bit ALU
Result3
CS420/520 datapath.11
4 4 !B
CarryOut
Adapted from UCB97 & UCB03
CS420/520 datapath.12
Result0 1-bit ALU CarryIn1 CarryOut0 Result1 1-bit ALU CarryIn2 CarryOut1 Result2 1-bit ALU CarryIn3 CarryOut2 1-bit ALU Result3
a 0 1 0 1
b 0 0 1 1
c = a NOR b 1 0 0 0
Zero
CarryOut3
UC. Colorado Springs Adapted from UCB97 & UCB03
CarryIn A
CarryOut
Result3
A[3:0] 4 ALU
CarryIn Result[3:0] 4
B[7:4] 4 CarryOut
CS420/520 datapath.15
B[7:4] 4
32
Sum CarryOut
32 Select
MUX
A B
32 32
MUX
32
ALU
A 32
OP ALU
32
Co
UC. Colorado Springs Adapted from UCB97 & UCB03
CS420/520 datapath.17
Clock input (CLK) The CLK input is a factor ONLY during write operation During read operation, RF behaves as a combinational logic block: - RA or RB valid => busA or busB valid after access time.
CS420/520 datapath.18
Memory (idealized) One input bus: Data In One output bus: Data Out
Data In 32 Clk
DataOut 32
Memory word is selected by: Address selects the word to put on Data Out Write Enable = 1: address selects the 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, IM behaves as a combinational logic block: - Address valid => Data Out valid after access time.
CS420/520 datapath.19
Clk
32
UC. Colorado Springs
CS420/520 datapath.20
Clocking Methodology
Clk Setup Hold Dont Care State . signals . . . . . Combinational logic Clk Clk . . . State . . . Setup Hold
A clocking methodology defines when signals can be read and written. For simplicity, we suppose an edge-triggered clocking methodology. All storage elements are clocked by the same clock edge Edge-triggered: all stored values are updated on a clock edge
CS420/520 datapath.21 UC. Colorado Springs Adapted from UCB97 & UCB03
Clk
Instruction Word 32
CS420/520 datapath.22
add
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
CS420/520 datapath.23
sub
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
CS420/520 datapath.24
RegWr
ALUctr
CS420/520 datapath.25
ori
CS420/520 datapath.26
Rd RegDst Mux
ALUctr
Rw Ra Rb 32 32-bit Registers
16
32 ALUSrc
Adapted from UCB97 & UCB03
CS420/520 datapath.27
lw
Addr <- R[rs] + SignExt(imm16) Calculate the memory address R[rt] <- Mem[Addr] Load the data into the register PC <- PC + 4
31
CS420/520 datapath.28
Example: lw
11 immediate 16 bits
Mux RegWr 5
busW 32 Clk
Rw Ra Rb 32 32-bit Registers
Mux
imm16
16
Data Memory
32
ExtOp
CS420/520 datapath.29 UC. Colorado Springs Adapted from UCB97 & UCB03
sw
mem[PC]
Addr <- R[rs] + SignExt(imm16) Calculate the memory address Mem[Addr] <- R[rt] PC <- PC + 4 Store the register into memory Calculate the next instructions address
CS420/520 datapath.30
Rw Ra Rb 32 32-bit Registers
imm16
16
Data Memory
32
ExtOp
CS420/520 datapath.31
beq
rs, rt, imm16 Fetch the instruction from memory Calculate the branch condition
if (COND eq 0) Calculate the next instructions address - PC <- PC + 4 + ( SignExt(imm16) x 4 ) else - PC <- PC + 4
CS420/520 datapath.32
26
Rt
ALUctr
imm16 16
Rw Ra Rb 32 32-bit Registers
ALU
Mux
imm16
16
1 30
1 30 30
30
SignExt
PC<31:2> <- PC<31:28> concat target<25:0> Calculate the next instructions address
CS420/520 datapath.37
30 00 30 1 Mux 0
30 1
0 30 Mux 1 30
Jump
Instruction<31:0>
Branch
UC. Colorado Springs
Zero
Adapted from UCB97 & UCB03
1 Mux 0 RegWr 5
Rs Zero ALU
Rt
Rd
busW 32 Clk
MemWr
32 32 WrEn Adr
imm16
16
Data Memory
ALUSrc ExtOp
CS420/520 datapath.39 UC. Colorado Springs Adapted from UCB97 & UCB03
Single cycle datapath => CPI=1, CCT => long What is next?: implementing control
CS420/520 datapath.40 UC. Colorado Springs Adapted from UCB97 & UCB03
Output
CS420/520 datapath.41
Control
Instruction Rd Rs 5 5 Rt 5 A Rw Ra Rb 32 32-bit Registers 32 B ALU 32 Data Address Data In Clk Data Out Control Signals Conditions
Clk
Clk
32
Datapath
CS420/520 datapath.42
add
rd, rs, rt Fetch the instruction from memory The actual operation Calculate the next instructions address
CS420/520 datapath.43
30 00 30 1 Mux 0
30 1
0 30 Mux 1 30
Branch = previous
UC. Colorado Springs
Zero = previous
Adapted from UCB97 & UCB03
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
CS420/520 datapath.45 UC. Colorado Springs Adapted from UCB97 & UCB03
30 00 30 1 Mux 0
30 1
0 30 Mux 1 30
Jump = 0
Instruction<31:0>
Branch = 0
UC. Colorado Springs
Zero = x
Adapted from UCB97 & UCB03
1 Mux 0
Rs Zero ALU
Rt
Rd
Imm16 MemtoReg = 0
MemWr = 0 0 Mux 32
32 WrEn Adr
imm16
16
Data Memory
ALUSrc = 1 ExtOp = 0
CS420/520 datapath.47 UC. Colorado Springs Adapted from UCB97 & UCB03
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
CS420/520 datapath.48 UC. Colorado Springs Adapted from UCB97 & UCB03
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
CS420/520 datapath.49 UC. Colorado Springs Adapted from UCB97 & UCB03
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
CS420/520 datapath.50 UC. Colorado Springs Adapted from UCB97 & UCB03
30 00 30 1 Mux 0
30 1
0 30 Mux 1 30
Jump = 0
Instruction<31:0>
Zero = 1
Adapted from UCB97 & UCB03
1 Mux 0
Rs
Rt
Rd
Imm16 MemtoReg = x
32
Mux
imm16
16
Data Memory
30 00 30 1 Mux 0
30 1
Op Func Rs
0 30 Mux 1 30
Jump = 1
Instruction<31:0>
Rd
Imm16
Control
Zero
DATA PATH
CS420/520 datapath.54
:
ALUop 3 00 0000 R-type 1 0 0 1 0 0 0 x R-type 1 0 0
op RegDst ALUSrc MemtoReg RegWrite MemWrite Branch Jump ExtOp ALUop (Symbolic) ALUop <2> ALUop <1> ALUop <0>
CS420/520 datapath.55
00 1101 10 0011 10 1011 00 0100 00 0010 ori 0 1 0 1 0 0 0 0 Or 0 1 0 lw 0 1 1 1 0 0 0 1 Add 0 0 0 sw x 1 x 0 1 0 0 1 Add 0 0 0 beq x 0 x 0 0 1 0 x Subtract 0 0 1 jump x x x 0 0 0 1 x xxx x x x
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>
..
op<5>
..
op<5>
..
op<5>
..
<0>
op<5>
..
op<0>
<0>
<0>
<0>
<0>
R-type
ori
lw
sw
beq
jump RegWrite
CS420/520 datapath.56
..
op<5>
..
op<5>
..
op<5>
..
op<5>
..
<0>
op<5>
..
op<0>
<0>
<0>
<0>
<0>
R-type
ori
lw
sw
beq
jump
RegWrite ALUSrc RegDst MemtoReg MemWrite Branch Jump ExtOp ALUop<2> ALUop<1> ALUop<0>
CS420/520 datapath.57
RegWrite
MemWrite
. . .
CS420/520 datapath.58
:
Rt Rs 5 5 Rt
Rd RegDst
1 Mux 0 RegWr 5
Rs Zero ALU
Rt
Rd
busW 32 Clk
MemWr
32 32 WrEn Adr
imm16 Instr<15:0>
16
Data Memory
ALUSrc ExtOp
CS420/520 datapath.59 UC. Colorado Springs Adapted from UCB97 & UCB03
CS420/520 datapath.60
CS420/520 datapath.61
Decimal 0 1 2 3 4 5 6 7 8
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000
Decimal 0 -1 -2 -3 -4 -5 -6 -7 -8
2s Complement 0000 1111 1110 1101 1100 1011 1010 1001 1000
B 0 0 1 1 0 0 1 1
CarryOut
A Sum B
CS420/520 datapath.64
1 0
1 1 0 0
1 1 1 1 1 1 0 7 3 -6
0 1 1 0 1 0 1 1 0 1 1 -4 -5 7
0 1
1 0
CS420/520 datapath.65
X 0 0 1 1
Y 0 1 0 1
X XOR Y 0 1 1 0