Skip to content

Single-Cycle Control

Instruction Timing

Example: add Timing

critical path=tclk-q+max{tAdd+tmux,tIMEM+tReg+tALU+tmux}+tsetup=tclk-q+(tIMEM+tReg+tALU+tmux)+tsetup

Example: lw Timing

lw involves all 5 stages

critical path=tclk-q+max{tAdd+tmux,tIMEM+tReg+tmux+tALU+tDMEM+tmux,tIMEM+tImm+tmux+tALU+tDMEM+tmux}+tsetup

Timing for 5 Stages

  • tWB involves WB selector delay and setup time

Example timing of stages for different instruction types:

InstructionIF = 200psID = 100psEX = 200psME=200psWB = 100psTotal
RXXX600ps
IXXX600ps
BXXXX500ps
JXXXX500ps
lwXXXXX800ps
SXXXX700ps
  • lw is the longest involving all stages
  • Maximum clock frequency
    • fmax=1/800 ps=1.25 GHz
  • Most blocks are idle most of the time
    • Pipelining, adding registers in the middle

Control Logic

Control Logic can be implemented in two ways:

  • Truth Table
  • ROM

Control Logic Truth Table

InstBrEqBrLTPCSelImmSelBrUnASelBSelALUSelMemRWRegWEnWBSel
add**+4R*RegRegAddRead1ALU
sub**+4R*RegRegSubRead1ALU
R-R Op**+4R*RegRegOpRead1ALU
addi**+4I*RegImmAddRead1ALU
lw**+4I*RegImmAddRead1Mem
sw**+4S*RegImmAddWrite0*
beq0*+4B*PCImmAddRead0*
beq1*ALUB*PCImmAddRead0*
bne0*ALUB*PCImmAddRead0*
bne1*+4B*PCImmAddRead0*
blt*1ALUB0PCImmAddRead0*
bltu*1ALUB1PCImmAddRead0*
jalr**ALUI*RegImmAddRead1PC+4
jal**ALUJ*PCImmAddRead1PC+4
auipc**+4U*PCImmAddRead1ALU

Control Realization Options

  • ROM
    • Read-Only Memory
    • Regular structure
    • Can be easily reprogrammed
      • fix errors
      • add instructions
    • Popular when designing control logic manually
  • Combinational Logic
    • Today, chip designers use logic synthesis tools to convert turth tables to network of gates

Instruction type encoded using only 9 bits:

  • inst[30]
  • inst[14:12]
  • inst[6:2]

ROM-based Control

11-bit address (inputs)
Inst[30,14:12,6:2]
        | 
        / 9   BrEq BrLT
        |       |   |
+-------V-------V---V-+
|                     |-----> PCSel
|                     |-/-3-> ImmSel[2:0]
|                     |-----> BrUn
|                     |-----> ASel
|         ROM         |-----> BSel
|                     |-/-4-> ALUSel[3:0]
|                     |-----> MemRW
|                     |-----> RegWEn
|                     |-/-2-> WBSel[1:0]
+---------------------+          15 data bits (output)

Implementation

Decoding Example: add

add=i[30]i[14]i[13]i[12]R-typeR-type=i[6]i[5]i[4]i[3]i[2]RV32IRV32I=i[1]i[0]