Download Multicycle Implementation: A Comprehensive Approach to Instruction Execution - Prof. Kirk and more Study notes Computer Architecture and Organization in PDF only on Docsity!
Multicycle Implementation
- • Each step in instruction execution takes 1 clock cycleAdvantages:
- Functional units like ALU can be used more than once per instructionminimizing hardware
- Instructions may take varying numbers of clock cycles to complete(efficiency)
- Major differences from single-cycle design: – Single memory for instructions and data
- – Single ALUAdditional registers (state elements) for output between steps
Multicycle Datapath
Combined memory^ Additional registers
unit
Shared ALU
Complete Multicycle Implementation (First look)
MUX for updating PC MUX for ALU inp
MUX for ALU inp
Modified MUXfor PCSrc
Steps of an instruction
- Assumptions – No step can contain more than one ALU operation
- No step can contain more than one register file access– No step can contain more than one memory access
- Conclusions– Temp registers allow very fast access within cycle
- A cycle must be of sufficient length to perform longest of ALU op,reg/mem access
- Required that any data needed in subsequent cycle stored in tempregister or register/memory prior to end of step
- Cycle must be long enough for step to fully complete– Must allow multiple steps to complete independent of one another
Complete Multicycle implementation
ResultfromALU
RegAPC/ RegB/irbyte/irword4/ branch targ/jump targPC+4/
65 functaddr
43 rs2rd
21 op coders
(^12) (^354)
6
1-bit Control Signals
PCWriteCondPCWrite No effectNo effect Enable PC^ Enable PC Ánew PC on zeroÁnew PC
IRWrite No effect Enable IRÁMemData
RegDst(0/1mux) Rs2 is WriteReg Rd is WriteReg ALUSrcA(0/1mux)MemRead Operand1 of ALUNo effect ÁPC Operand1 of ALU Enable read from memÁRegA Addr to memLocal RegÁÁALU resultMDR
Enable write to mem
Enable write to reg file
Asserted (1)
MemtoReg(0/1mux)IorD(0/1mux) Local Reg Addr to memÁALU resultÁPC MemWrite No effect
RegWrite No effect
Signal Deasserted (0)
Complete Multicycle implementation
Detailed Step 1
• Instruction Fetch Step – Fetch instructions from memory IR=memory[PC]
- Compute address of next instruction (PC+4)
PCSourceALUSrcB 0001 PC^ ALU Operand2 is 4ÁPC+4 on PCWrite
ALUOp 001 ALU add
Value
PCWriteIRWrite^ Enable IR Enable PCÁÁMemDatanew PC
ALUSrcA(0/1mux)MemRead Operand1 of ALU Enable read from memÁPC IorD(0/1mux) Addr to memÁPC
Signal Action
If signal not listed, assume disabled
Detailed Step 3
• Memory Reference Instruction – ALUOut = A + sign extended(IR[15-0])
• Arithmetic/Logical Instruction – ALUOut = A op B
ALUSrcBALUOp 1000 ALU Operand2 is sign extended lower16 bits of IR^ ALU add
ALUSrcA(0/1mux)Signal Value 1 Operand1 of ALU Action ÁRegA
ALUSrcBALUOp 0010^ ALU op determined by func ALU Operand2 from RegB
ALUSrcA(0/1mux)Signal Value 1 Operand1 of ALU Action ÁRegA
Detailed Step 3
• Branch Instruction – If (A == B) PC = ALUOut
• Jump Instruction – PC = PC[31-28] || (IR[25-0]<<2)
PCWriteCondPCSource 011 Enable PC PCÁALU result on PCWrite Ánew PC on zero ALUSrcBALUOp 0001 ALU Operand2 from RegB^ ALU sub
ALUSrcA(0/1mux)Signal Value 1 Operand1 of ALU Action ÁRegA
PCSourcePCWriteSignal Value 011 PCÁ Enable PCALU result on PCWrite Action Ánew PC
Detailed Step 4
• Arithmetic/logical instruction (R-type) – Reg[IR[15-11]]=ALUOut
RegDst(0/1mux) Value 1 Rd is WriteReg Local RegEnable write to reg fileÁALU result
Action MemtoReg(0/1mux)RegWrite
Signal
Detailed Step 5
• Memory Read completion step (loads) – Reg[IR[20-16]]=MDR
RegDst(0/1mux) Value 0 Rs2 is WriteReg Enable write to reg file Local RegÁMDR
Action MemtoReg(0/1mux)RegWrite
Signal
Implementing the Control
• Sequential logic – Stores data in memory elements (current “state” of
– Behavior determined by input + current statemachine
– Truth table does not provide enough info to describe asequential system concisely
- Describe using FSM – Set of states + two functions (nextstate and output)
- • Set of statesNextstateË Ëcombination logic given inputs, determines next stateall possible values of internal storage
- OutputËproduces a set of outputs from current states and the inputs
- Synchronous state machines: state change with clock edge, new statecomputed every clock cycle
Finite State Machines
Current state^ Next-statefunction Clock functionOutput
stateNext Outputs
Inputs