° Today:
• Single cycle processor:
- Advantage: One clock cycle per instruction
- Disadvantage: long cycle time CS152
Lec8.1
How to Design a Processor: step-by-
step
° 1. Analyze instruction set => datapath requirements
• the meaning of each instruction is given by the register transfers
• datapath must include storage element for ISA registers
- possibly more
• datapath must support each register transfer
CS152
Lec8.2
The MIPS Instruction
Formats
° All MIPS instructions are 32 bits long. The three instruction formats:
31 26 21 16 11 6 0
• R-type op rs rt rd shamt funct
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
31 26 21 16 0
• I-type op rs rt immediate
6 bits 5 bits 5 bits 16 bits
31 26 0
• J-type
op target address
6 bits 26 bits
CS152
Lec8.4
Logical Register Transfers
° RTL gives the meaning of the instructions
° All start by fetching the instruction
op | rs | rt | rd | shamt | funct = MEM[ PC ]
op | rs | rt | Imm16 = MEM[ PC ]
° Combinational Elements
° Storage Elements
• Clocking methodology
CS152
Lec8.7
Combinational Logic Elements (Basic Building
Blocks) CarryIn
° Adder A
32
Adder
Sum
32
B Carry
32
Select
° MUX
A
32
MUX
Y
32
B
32
OP
° ALU A
32
ALU
Result
32
B
32 CS152
Lec8.8
Storage Element: Register (Basic Building
Block)
° Register Write Enable
• Similar to the D Flip Flop except
Data In Data Out
- N-bit input and output
N N
- Write Enable input
• Write Enable:
Clk
- negated (0): Data Out will not
change
- asserted (1): Data Out will
become Data In
CS152
Lec8.9
Storage Element: Register
File
° Register File consists of 32 registers: RWRA RB
• Two 32-bit output busses: Write Enable 5 5 5
busA and busB busA
• One 32-bit input bus: busW busW 32 32-bit 32
32 Registers busB
° Register is selected by: Clk
32
• RA (number) selects the register to put on busA (data)
• RB (number) selects the register to put on busB (data)
• RW (number) selects the register to be written
via busW (data) when Write Enable is 1
CS152
Lec8.11
Clocking
Methodology
Clk
Setup Hold Setup Hold
Don’t Care
. . . .
. . . .
. . . .
CS152
Lec8.12
Step 3: Assemble DataPath meeting our
requirements
° Register Transfer Requirements
Datapath Assembly
° Instruction Fetch
CS152
Lec8.13
3a: Overview of the Instruction Fetch
Unit
° The common RTL operations
• Fetch the Instruction: mem[PC]
• Update the program counter:
- Sequential Code: PC <- PC + 4
- Branch and Jump: PC <- “something else”
Clk PC
Next Address
Logic
Address
Instruction Word
Instruction
Memory 32
CS152
Lec8.14
3b: Add &
Subtract
° R[rd] <- R[rs] op R[rt] Example: addU rd, rs, rt
• Ra, Rb, and Rw come from instruction’s rs, rt, and rd fields
• ALUctr and RegWr: control logic after decoding the
instruction
31 26 21 16 11 6 0
op rs rt rd shamt funct
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
Rd Rs Rt
RegWr ALUctr
5 5 5
busA
Rw Ra Rb
busW 32 Result
ALU
32 32-bit
32 32
Registers
Clk busB
32
CS152
Lec8.15
Register-Register Timing: One complete
Clk
cycle
Clk-to-Q
PC Old Value New Value
Instruction Memory Access Time
Rs, Rt, Rd, Old Value New Value
Op, Func
Delay through Control Logic
ALUctr Old Value New Value
Rd Rs Rt
RegWr 5 5 ALUctr Register Write
5
Occurs Here
busA
Rw Ra Rb
busW 32 Result
ALU
32 32-bit
32 Registers 32
Clk busB
32
CS152
Lec8.16
3c: Logical Operations with
°
Immediate
R[rt] <- R[rs] op ZeroExt[imm16] ]
31 26 21 16 11 0
op rs rt immediate
6 bits 5 bits 5 bits rd? 16 bits
31 16 15 0
0000000000000000 immediate
16 bits 16 bits
Rd Rt
RegDst
Mux
Rs Rt? ALUctr
RegWr 5 5 5
busA
Rw Ra Rb
busW 32 Result
32 32-bit
ALU
32 Registers 32
Clk busB
32
Mux
ZeroExt
imm16
16 32
ALUSrc
CS152
Lec8.17
3d: Load
°
Operations
R[rt] <- Mem[R[rs] + SignExt[imm16]] Example: lw rt, rs, imm16
31 26 21 16 11 0
op rs rt immediate
6 bits 5 bits 5 bits rd 16 bits
Rd Rt
RegDst
Mux
Rs Rt?
RegWr 5 ALUctr
5 5
busA W_Src
Rw Ra Rb
busW 32
32 32-bit
ALU
32 Registers 32
Clk busB MemWr
Mux
32
Mux
WrEn Adr
Extender
Data In 32
32 ?? Data
imm16 32
16 Memory
Clk
ALUSrc
CS152
ExtOp Lec8.18
3e: Store
Operations
° Mem[ R[rs] + SignExt[imm16] <- R[rt] ] Example: sw rt, rs, imm16
31 26 21 16 0
op rs rt immediate
6 bits 5 bits 5 bits 16 bits
Rd Rt ALUctr MemWr W_Src
RegDst
Mux
Rs Rt
RegWr 5 5 5
busA
Rw Ra Rb
busW 32
32 32-bit
ALU
32 Registers 32
Clk busB
Mux
Mux
32
WrEn Adr
Extender
Data In 32 32
imm16 Data
32
16 Memory
Clk
ExtOp ALUSrc
CS152
Lec8.19
3f: The Branch
Instruction
31 26 21 16 0
op rs rt immediate
6 bits 5 bits 5 bits 16 bits
CS152
Lec8.20
Datapath for Branch
Operations
° beq rs, rt, imm16 Datapath generates condition (equal)
31 26 21 16 0
op rs rt immediate
6 bits 5 bits 5 bits 16 bits
Inst Address Cond
nPC_sel Rs Rt
4 RegWr 5 5 5
Adder
32 busA
Rw Ra Rb
00
busW
Equal?
32 32-bit 32
Mux
Registers
PC
Clk busB
32
Adder
PC Ext
imm16
Clk
CS152
Lec8.21
Putting it All Together: A Single Cycle
Datapath
Instruction<31:0>
<21:25>
<16:20>
<11:15>
Inst
<0:15>
Memory
Adr
Rs Rt Rd Imm16
busA
busW Rw Ra Rb =
00
32 32-bit 32
ALU
Mux
32 Registers busB 32 0
PC
Mux
32
Mux
Adder
1 Data In
PC Ext
imm16 32 Data
Clk
imm16
16 Memory
Clk
32 Address
32 Ideal
32 32-bit
ALU
Data
PC
Registers Data In
B Memory
Clk Clk
32
Clk
CS152
Lec8.23
An Abstract View of the
Implementation
Ideal Control
Instruction Control Signals Conditions
Instruction
Memory
Rd Rs Rt
5 5 5
Instruction
Address
A Data
Rw Ra Rb 32 Data
Next Address
32 Address
32 Ideal Out
32 32-bit
ALU
Data
PC
Clk Clk
32
Clk
Datapath
CS152
Lec8.24
Steps 4 & 5: Implement the
control
Next time
CS152
Lec8.25
Summary
° 5 steps to design a processor
• 1. Analyze instruction set => datapath requirements
• 2. Select set of datapath components & establish clock methodology
• 3. Assemble datapath meeting the requirements
• 4. Analyze implementation of each instruction to determine setting of
control points that effects the register transfer.
• 5. Assemble the control logic