Back to EECS 31L Index

8. EECS 31L / 08 Microarchitecture

EECS 31L • Study Notes • Microarchitecture
Mahmoud Elfar • Spring 2026 • v0.1

v0.1: Initial version

Table of Contents


8.1. Microarchitecture

A microarchitecture is the specific design of a processor’s datapath and control unit that implements a given instruction set architecture (ISA). Okay let’s take a step back.

Designing a general-purpose processor involves two parts:

Part 1: An instruction set architecture (ISA), which defines the programmer-visible interface: the instructions, registers, and memory model. An ISA serves two main purposes:

Part 2: A microarchitecture, which defines the actual hardware design that implements the ISA. A microarchitecture specifies how the processor’s datapath and control unit are organized to execute the instructions defined by the ISA. Multiple microarchitectures can implement the same ISA, each with different performance, power, and area characteristics.

Case Study: The Emotion Engine

Sony Emotion Engine CPU

Sony Emotion Engine CPU

Image: Wikimedia Commons, CC BY-SA 3.0.

The Emotion Engine (EE) is a central processing unit (CPU, or microprocessor) developed through collaboration between Sony Computer Entertainment and Toshiba for the PlayStation 2 (PS2) video game console, circa late 1990s. The EE implemented the MIPS R5000 ISA – a 64-bit RISC architecture – as well as some custom extensions developed by Sony.

Sony also developed the microarchitecture of the EE. Game developers who wanted to write games for the PS2 did not need to know anything about the microarchitecture of the EE. Their devkit provided them with the ISA specification, which was all they needed to write software that could run on the PS2. The microarchitecture was Sony’s internal design choice that determined how the EE executed instructions, but it was abstracted away from game developers.

↑ Back to top

8.2. The Data, The Path, and the Controller

The datapath is the collection of hardware components that perform the actual data processing in a processor. Food processors process food; data processors process data. Okay everyone is tired of those clever analogies:

RISC-V Microarchitecture

A RISC-V Microarchitecture

↑ Back to top

8.3. Microarchitecture Components

Recall the components from study notes 06 – we just added one more component: the Control Unit.

Component Type Description
Program Counter
(PC)
Sequential A register that holds the address of the current instruction.
Gets updated every clock cycle to point to the next instruction.
PC + 4 for the next instruction (since instructions are 4 bytes).
Instruction Memory
(IMEM)
Combinational A read-only memory that stores the program instructions.
Takes the PC as input and outputs the instruction at that address.
Register File Sequential A collection of registers that can be read and written.
Has two read ports (for source registers) and one write port (for the destination register).
Reads are combinational (outputs change immediately with address changes); writes occur on clock edges.
ALU Combinational Performs arithmetic and logic operations.
Takes two operands and a control signal to determine the operation.
Outputs the result and status flags (Zero, Overflow, Carry_Out).
Data Memory
(DMEM)
Sequential A read/write memory for data storage.
Takes an address and control signals to read or write data.
Reads are combinational; writes occur on clock edges.
Immediate Generator
(IMMGEN)
Combinational Generates immediate values from instruction fields.
Takes instruction bits as input and outputs a sign-extended 32-bit immediate value.
ALU-Source MUX Combinational Selects the second operand for the ALU.
Controlled by ALUSrc signal: selects between register data and immediate value.
Register-Write-Source MUX Combinational Selects the value to write back to the register file.
Controlled by MemToReg signal: selects between ALU result and DMEM output.
PC Adder Combinational Computes the next PC value (PC + 4).
Used to advance to the next instruction.
Control Unit Combinational Generates control signals based on the instruction opcode and function fields.
Controls the operation of the datapath components for each instruction type.

↑ Back to top

8.4. RISC-V Microarchitecture

Microarchitectures come in many shapes and forms. In this course, we will focus on a specific microarchitecture for the RISC-V ISA called the “single-cycle datapath”. Understanding this datapath is crucial for grasping more complex designs that you will definitely encounter in the future, whether in your studies or future career.

You should be able to:

↑ Back to top

8.5. The Execution Cycle (FeDEX Store)

FeDEX Store™ is a mnemonic for the four-ish stages of instruction execution: Fetch, Decode, Execute, Store/Writeback.

8.5.1. Fetch

Fetching an instruction means reading it from the instruction memory.

Fetching Stage

Fetching Stage

Components:

Signals:

At the end of every cycle the PC must advance. Since every instruction is exactly 4 bytes wide, the next address is always pc_out + 4. A dedicated adder computes this, and the result feeds back into the PC’s write port at the rising clock edge.

8.5.2. Decode

Decoding an instruction means splitting the 32-bit word into its named fields, reading the required register values, and generating the control signals that configure the rest of the datapath.

Decode Stage

Decode Stage

Components:

Signals:

Decode is entirely combinational. The register file read and control signal generation both complete within the same clock cycle as fetch. All control signals are stable before the Execute stage begins.

8.5.3. Execute

Executing an instruction means performing the required arithmetic or logical computation in the ALU.

Execute Stage

Execute Stage

Components:

Signals:

The Control Unit drives ALUOp directly; no separate ALU controller is shown in this diagram. The same ALU hardware computes the result for R-type operations and the effective address for lw/sw, because both reduce to addition or a specified arithmetic operation at the ALU level.

8.5.4. Memory

The memory stage either reads a word from data memory (lw) or writes a word to it (sw). For all other instruction types this stage is idle and passes Result through unchanged.

Memory Stage

Memory Stage

Components:

Signals:

For R-type and I-type arithmetic instructions, the Control Unit deasserts both MemRead and MemWrite, leaving DMEM idle. Result flows directly to the writeback MUX.

8.5.5. Write Back

Write back selects the result to commit and writes it into the destination register.

Write Back Stage

Write Back Stage

Components:

Signals:

Write-back completes at the rising clock edge — the same edge that advances the PC. Every state update in the single-cycle design (PC increment, register write, data memory write) is simultaneous. The next instruction begins fetching with all written values already stable.

↑ Back to top

8.6. The Control Unit

8.6.1. What the Control Unit Does

Every stage of FeDEX Store is shaped by control signals. The Control Unit is the combinational circuit that generates all of them. It takes the instruction’s opcode, funct3, and funct7 as inputs and asserts the correct combination of control signals as outputs — within the same clock cycle, before the Execute stage begins.

The Control Unit does not process data. It does not add, compare, or store anything. Its only job is to look at what kind of instruction is being executed and configure every mux, every enable line, and every memory port accordingly. It is the part of the microarchitecture that makes the datapath do different things for different instructions.

Inputs to the Control Unit:

Outputs from the Control Unit:

Signal Width Controls
RegWrite 1 Whether to write to the register file at the end of the cycle
ALUSrc 1 Whether the ALU’s B input comes from the register file (0) or the immediate (1)
ALUOp 3 Which operation the ALU performs
MemRead 1 Whether to read from data memory
MemWrite 1 Whether to write to data memory
MemToReg 1 Whether the writeback value comes from the ALU (0) or data memory (1)

A note on ALUOp: in some textbook designs, the Control Unit outputs a 2-bit ALUOp that feeds a separate ALU Control circuit, which then produces the final 3-bit (or 4-bit) ALU control signal. In the version of the datapath used in this course, ALUOp drives the ALU directly. Either approach is valid; what matters is the final operation the ALU performs.

8.6.2. Control Signal Truth Table

For the four instruction types we study — R-type, I-type arithmetic (addi, ori, etc.), I-type load (lw), and S-type store (sw) — the Control Unit outputs the following:

Instruction RegWrite ALUSrc ALUOp MemRead MemWrite MemToReg
R-type (add, sub, and, or, …) 1 0 (from funct3/funct7) 0 0 0
I-type arithmetic (addi, ori, …) 1 1 (from funct3) 0 0 0
I-type load (lw) 1 1 ADD 1 0 1
S-type store (sw) 0 1 ADD 0 1 X

Notes on reading this table:

8.6.3. How to Use the Truth Table

Given an instruction, you should be able to state the value of every control signal. The process is:

  1. Identify the instruction type from the opcode (and funct3/funct7 if needed). Refer to the RISC-V ISA document (Harris Appendix B) if you need the opcode values.
  2. Look up the row in the table above.
  3. Read off each signal value.

Example: add x5, x1, x2

This is R-type. From the table:

Example: lw x7, 36(x2)

This is I-type load. From the table:

Example: sw x5, 12(x11)

This is S-type. From the table:

↑ Back to top


To be continued…