1
Outline
- Combinational & sequential logic
- Single-cycle CPU
- Multi-cycle CPU
Outline Combinational & sequential logic Single-cycle CPU - - PowerPoint PPT Presentation
Outline Combinational & sequential logic Single-cycle CPU Multi-cycle CPU 1 Combinational Element combinational n n input output logic Output determined entirely by input Contains no storage element 2 Examples of
ALU
State element 1 State element 2 Combinational logic
State element 1 Combinational logic
Read reg 1 Read reg 2 Write reg Write data
Registers
5 5 5 Read data 1 Read data 2 64 64
Register numbers Data
64
RegWrite
PC
Address Instruction
Instruction Memory Data Register # Register # Register #
Registers
Address
Data
Data Memory ALU ALU
What is this for?
Read address
Instruction
Instruction Memory PC ALU
Adder
32
– a register that points to the next instruction to be fetched – it is incremented each clock cycle
Memory
supplied to upstream datapath elements
preparation for the next instruction (why 4?)
hardwired to perform add instruction
later, we assume separate memory units for instructions & data
Read reg 1 Read reg 2 Write reg Write data
Register File
Read data 1 Read data 2 ALU ALU
RegWrite ALUop
5 5 5
– rs=R2, rt=R3, rd=R1
– RegWrite is asserted to enable write at clock edge – ALUop to control operation
sign extend 64 16
Read reg 1 Read reg 2 Write reg Write data
Registers
Read data 1 Read data 2 ALU ALU
RegWrite ALUop
5 5
sign extend 5
16
Address
Write data
Data Memory
Read data
64
MemWrite MemRead
– PC = PC + Imm<< 2 (note that at this point PC is already
PCcurrent=(PCprevious+4) + Imm<< 2
– PC remains unchanged: PCcurrent=(PCprevious+4) – the next sequential instruction is taken
– RegFile, sign extender, adder, shifter
64 shift left 2 64
64 shift left 2 64 1 6 sign extend ALU
Adder
0xb123 0xffffb123 0xfffec48c
Read reg 1 Read reg 2 Write reg Write data
Registers
Read data 1 Read data 2 ALU ALU
RegWrite ALUop = subtract
5
sign extend
16
64 5
ALU
Adder
shift left 2
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Data In Address Program Memory Control Logic Rdest Rs Rt Instruction Register Data Memory (Register File) Program Counter (PC) ALU 4
Clock period Rising edge Falling edge
cycle time
Q C D _ Q
D C Q
D C Q
D C D latch D C Q D latch D C Q Q Q Q
State element 1 State element 2 Combinational logic Clock cycle
Read register number 1 Read data 1 Read register number 2 Read data 2 Write register Write Write data Register file
Read register number 1 Register 0 Register 1 . . . Register n – 2 Register n – 1 M u x Read register number 2 M u x Read data 1 Read data 2
M u x C Select 32 32 32 B A M u x Select B31 A31 C31 M u x B30 A30 C30 M u x B0 A0 C0 . . . . . .
Write 1 n-to-2n decoder n – 1 n Register 0 C D Register 1 C D Register n – 2 C D Register n – 1 C D . . . Register number . . . Register data
PC Instruction address Instruction Instruction memory Add Sum
Read register 1 Read register 2 Write register Write Data Registers ALU Data Data Zero ALU result RegWrite
5 5 5 Register numbers Read data 1 Read data 2 ALU operation 4
Address Read data Data memory
Write data MemRead MemWrite
Sign extend 16 32
Read register 1 Read register 2 Write register Write data Write data Registers ALU Add Zero RegWrite MemRead MemWrite PCSrc MemtoReg Read data 1 Read data 2 ALU operation 4 Sign extend 16 32 Instruction ALU result Add ALU result M u x M u x M u x ALUSrc Address Data memory Read data Shift left 2 4 Read address Instruction memory PC
Instruction RegDst ALUSrc Memto- Reg Reg Write Mem Read Mem Write Branch ALUOp1 ALUp0 R-format 1 1 1 lw 1 1 1 1 sw X 1 X 1 beq X X 1 1
Read register 1 Read register 2 Write register Write data Write data Registers ALU Add Zero Read data 1 Read data 2 Sign extend 16 32 Instruction [31–0] ALU result Add ALU result M u x M u x M u x Address Data memory Read data Shift left 2 4 Read address Instruction memory PC 1 1 1 M u x 1 ALU control Instruction [5–0] Instruction [25–21] Instruction [31–26] Instruction [15–11] Instruction [20–16] Instruction [15–0] RegDst Branch MemRead MemtoReg ALUOp MemWrite ALUSrc RegWrite Control
Operation2 Operation1 Operation0 Operation ALUOp1 F3 F2 F1 F0 F (5– 0) ALUOp0 ALUOp ALU control block R-format Iw sw beq Op0 Op1 Op2 Op3 Op4 Op5 Inputs Outputs RegDst ALUSrc MemtoReg RegWrite MemRead MemWrite Branch ALUOp1 ALUOpO
State element 1 State element 2 Combinational logic Clock cycle
Read register 1 Read register 2 Write register Write data Write data Registers ALU Add Zero RegWrite MemRead MemWrite PCSrc MemtoReg Read data 1 Read data 2 ALU operation 4 Sign extend 16 32 Instruction ALU result Add ALU result M u x M u x M u x ALUSrc Address Data memory Read data Shift left 2 4 Read address Instruction memory PC
Data Register # Register # Register # PC Address Instruction
Memory Registers ALU Instruction register Memory data register ALUOut A B Data
Read register 1 Read register 2 Write register Write data Registers ALU Zero Read data 1 Read data 2 Sign extend 16 32 Instruction [25–21] Instruction [20–16] Instruction [15–0] ALU result M u x M u x Shift left 2 Instruction register PC 1 M u x 1 M u x 1 M u x 1 A B 1 2 3 ALUOut Instruction [15–0] Memory data register Address Write data Memory MemData 4 Instruction [15–11]
Read register 1 Read register 2 Write register Write data Registers ALU Zero Read data 1 Read data 2 Sign extend 16 32 Instruction [31–26] Instruction [25–21] Instruction [20–16] Instruction [15–0] ALU result M u x M u x Shift left 2 Shift left 2 Instruction register PC 1 M u x 1 M u x 1 M u x 1 A B 1 2 3 M u x 1 2 ALUOut Instruction [15–0] Memory data register Address Write data Memory MemData 4 Instruction [15–11] PCWriteCond PCWrite IorD MemRead MemWrite MemtoReg IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst 26 28 Outputs Control Op [5–0] ALU control PC [31–28] Instruction [25-0] Instruction [5–0] Jump address [31–0]
Inputs Current state Outputs Clock Next-state function Output function Next state
MemRead ALUSrcA = 0 IorD = 0 IRWrite ALUSrcB = 01 ALUOp = 00 PCWrite PCSource = 00 ALUSrcA = 0 ALUSrcB = 11 ALUOp = 00 ALUSrcA = 1 ALUSrcB = 00 ALUOp = 10 ALUSrcA = 1 ALUSrcB = 10 ALUOp = 00 MemRead IorD = 1 MemWrite IorD = 1 RegDst = 1 RegWrite MemtoReg = 0 RegDst = 1 RegWrite MemtoReg = 0 PCWrite PCSource = 10 ALUSrcA = 1 ALUSrcB = 00 ALUOp = 01 PCWriteCond PCSource = 01 Instruction decode/ register fetch Instruction fetch 1 Start Jump completion 9 8 6 2 3 4 5 7 Memory read completon step R-type completion Memory access Memory access Execution Branch completion Memory address computation
PCWrite PCWriteCond IorD MemtoReg PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst NS3 NS2 NS1 NS0 Op5 Op4 Op3 Op2 Op1 Op0 S3 S2 S1 S0 State register IRWrite MemRead MemWrite Instruction register
Outputs Control logic Inputs
Op5 Op4 Op3 Op2 Op1 Op0 S3 S2 S1 S0 IorD IRWrite MemRead MemWrite PCWrite PCWriteCond MemtoReg PCSource1 ALUOp1 ALUSrcB0 ALUSrcA RegWrite RegDst NS3 NS2 NS1 NS0 ALUSrcB1 ALUOp0 PCSource0
m n
0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 0 1 1 1
AddrCtl Outputs PLA or ROM State Address select logic Op[5– 0] Adder Instruction register
1 Control unit Input PCWrite PCWriteCond IorD MemtoReg PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst IRWrite MemRead MemWrite BWrite
Dispatch ROM 1 Dispatch ROM 2 Op Opcode name Value Op Opcode name Value 000000 R-format 0110 100011 lw 0011 000010 jmp 1001 101011 sw 0101 000100 beq 1000 100011 lw 0010 101011 sw 0010
State number Address-control action Value of AddrCtl Use incremented state 3 1 Use dispatch ROM 1 1 2 Use dispatch ROM 2 2 3 Use incremented state 3 4 Replace state number by 0 5 Replace state number by 0 6 Use incremented state 3 7 Replace state number by 0 8 Replace state number by 0 9 Replace state number by 0
State Adder 1 PLA or ROM Mux 3 2 1 Dispatch ROM 1 Dispatch ROM 2 AddrCtl Address select logic Instruction register
PCWrite PCWriteCond IorD MemtoReg PCSource ALUOp ALUSrcB ALUSrcA RegWrite AddrCtl Outputs Microcode memory IRWrite MemRead MemWrite RegDst Control unit Input Microprogram counter Address select logic Adder 1 Instruction register
BWrite Datapath
Label ALU control SRC1 SRC2 Register control Memory PCWrite control Sequencing Fetch Add PC 4 Read PC ALU Seq Add PC Extshft Read Dispatch 1 Mem1 Add A Extend Dispatch 2 LW2 Read ALU Seq Write MDR Fetch SW2 Write ALU Fetch Rformat1 Func code A B Seq Write ALU Fetch BEQ1 Subt A B ALUOut-cond Fetch JUMP1 Jump address Fetch
Field name Value Signals active Comment Add ALUOp = 00 Cause the ALU to add. ALU control Subt ALUOp = 01 Cause the ALU to subtract; this implements the compare for branches. Func code ALUOp = 10 Use the instruction's function code to determine ALU control. SRC1 PC ALUSrcA = 0 Use the PC as the first ALU input. A ALUSrcA = 1 Register A is the first ALU input. B ALUSrcB = 00 Register B is the second ALU input. SRC2 4 ALUSrcB = 01 Use 4 as the second ALU input. Extend ALUSrcB = 10 Use output of the sign extension unit as the second ALU input. Extshft ALUSrcB = 11 Use the output of the shift-by-two unit as the second ALU input. Read Read two registers using the rs and rt fields of the IR as the register numbers and putting the data into registers A and B. Write ALU RegWrite, Write a register using the rd field of the IR as the register number and Register RegDst = 1, the contents of the ALUOut as the data. control MemtoReg = 0 Write MDR RegWrite, Write a register using the rt field of the IR as the register number and RegDst = 0, the contents of the MDR as the data. MemtoReg = 1 Read PC MemRead, Read memory using the PC as address; write result into IR (and lorD = 0 the MDR). Memory Read ALU MemRead, Read memory using the ALUOut as address; write result into MDR. lorD = 1 Write ALU MemWrite, Write memory using the ALUOut as address, contents of B as the lorD = 1 data. ALU PCSource = 00 Write the output of the ALU into the PC. PCWrite PC write control ALUOut-cond PCSource = 01, If the Zero output of the ALU is active, write the PC with the contents PCWriteCond
jump address PCSource = 10, Write the PC with the jump address from the instruction. PCWrite Seq AddrCtl = 11 Choose the next microinstruction sequentially. Sequencing Fetch AddrCtl = 00 Go to the first microinstruction to begin a new instruction. Dispatch 1 AddrCtl = 01 Dispatch using the ROM 1. Dispatch 2 AddrCtl = 10 Dispatch using the ROM 2.
Control Control Control Enhanced floating point and multimedia Control I/O interface Instruction cache Integer datapath Data cache Secondary cache and memory interface Advanced pipelining hyperthreading support
Control Control Control Enhanced floating point and multimedia Control I/O interface Instruction cache Integer datapath Data cache Secondary cache and memory interface Advanced pipelining hyperthreading support