Control signals

SignalWidthDescriptionUsed By
1RegWrite1 bitWrite enable for register fileRegFile
2MemRead1 bitEnable memory readData Memory
3MemWrite1 bitEnable memory writeData Memory
4MemtoReg1 bitSelect memory data or ALU result to RegFileWrite-back Mux
5ALUSrc1 bitSelect immediate or register as ALU inputALU input Mux
6PCSrc1 bitSelect next PC (sequential or branch)PC input Mux
7Branch1 bitIndicates branch instructionBranch Comparator, PC logic
8Jump1 bitIndicates jump instructionPC logic
9ALUOp2-3 bitsEncodes ALU operation typeALU Control
10(Optional) ImmSrc2-3 bitsSelect immediate extractionImmediate Generator
11(Optional) LoadType2 bitsSelect load sizeData Memory or extension logic
12(Optional) StoreType2 bitsSelect store sizeData Memory

Before diving into the tables, note that some control signals are not simple single bits but multi‑bit buses that let your datapath select among multiple options:

  • ImmSrc [2:0]: selects which immediate format your imm_gen.v uses:

    • 3'b000 = I‑type

    • 3'b001 = S‑type

    • 3'b010 = B‑type

    • 3'b011 = U‑type

    • 3'b100 = J‑type

  • LoadType [2:0]: tells data_mem.v the width and signedness of a load:

    • 3'b000 = Byte, Signed

    • 3'b001 = Half, Signed

    • 3'b010 = Word (no sign extension)

    • 3'b011 = Byte, Unsigned

    • 3'b100 = Half, Unsigned

  • StoreType [1:0]: tells data_mem.v the width of a store:

    • 2'b00 = Byte

    • 2'b01 = Half

    • 2'b10 = Word

PCSrc is high whenever the next‐PC comes from a target adder (branches or jumps):
$PCSrc=Branch \lor Jump$

ImmSrc selects which immediate‐generation format to use:

> I : I‐type (loads, ALU‐imm, JALR)
> S : S‐type (stores)
> B : B‐type (branches)
> U : U‐type (LUI/AUIPC)
> J : J‐type (JAL)

LoadType / StoreType encode access width & signedness.


R-Type ALU Ops (opcode = 0110011; ALUSrc=0; ALUOp=10; ImmSrc=–)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
ADD011001100000000001000000010–––
SUB011001100001000001000000010–––
SLL011001100100000001000000010–––
SLT011001101000000001000000010–––
SLTU011001101100000001000000010–––
XOR011001110000000001000000010–––
SRL011001110100000001000000010–––
SRA011001110101000001000000010–––
OR011001111000000001000000010–––
AND011001111100000001000000010–––

I-Type ALU Ops (opcode = 0010011; ALUSrc=1; ALUOp=10; ImmSrc=I)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
ADDI0010011000–1100000010I––
SLLI001001100100000001100000010I––
SLTI0010011010–1100000010I––
SLTIU0010011011–1100000010I––
XORI0010011100–1100000010I––
SRLI001001110100000001100000010I––
SRAI001001110101000001100000010I––
ORI0010011110–1100000010I––
ANDI0010011111–1100000010I––

Loads (opcode = 0000011; ALUSrc=1; ALUOp=00; MemRead=1; MemtoReg=1; ImmSrc=I)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
LB0000011000–1110100000IByte_Signed–
LH0000011001–1110100000IHalf_Signed–
LW0000011010–1110100000IWord–
LBU0000011100–1110100000IByte_Unsigned–
LHU0000011101–1110100000IHalf_Unsigned–

Stores (opcode = 0100011; ALUSrc=1; ALUOp=00; MemWrite=1; ImmSrc=S)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
SB0100011000–0101–00000S–Byte
SH0100011001–0101–00000S–Half
SW0100011010–0101–00000S–Word

Branches (opcode = 1100011; ALUSrc=0; ALUOp=01; Branch=1; ImmSrc=B)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
BEQ1100011000–0000–11001B––
BNE1100011001–0000–11001B––
BLT1100011100–0000–11001B––
BGE1100011101–0000–11001B––
BLTU1100011110–0000–11001B––
BGEU1100011111–0000–11001B––

Jumps (opcode = 1101111 & 1100111; ImmSrc=J for JAL, I for JALR)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
JAL1101111––1100010100J––
JALR1100111000–1100010100I––

U-Type (opcode = 0110111 & 0010111; ALUSrc=1; ImmSrc=U)

Instropcodefunct3funct7RegWriteALUSrcMemReadMemWriteMemtoRegPCSrcBranchJumpALUOpImmSrcLoadTypeStoreType
LUI0110111––1100000011U––
AUIPC0010111––1100000000U––

See more: ALU Control