Module 10: Capstone Projects · Project 1 — 8-bit RISC Processor Core

Project 1, Part 1: The Instruction Set

Processor design begins with an instruction set architecture (ISA) specification. The ISA defines the formal behavioral contract between software programs and hardware execution units. This article defines a minimal 8-bit RISC instruction set that balances decoding simplicity with computational capability.

Architectural Design Goals

The target processor implements a compact, self-contained architecture:

  • 8-bit word width: Data registers, arithmetic units, and memory words share an 8-bit width.
  • Turing completeness: The instruction set includes arithmetic operations, data movement, memory access, and conditional branching.
  • Fixed-width encoding: Every instruction occupies exactly one 8-bit word to simplify fetch and decode logic.

Instruction Set Table

The architecture allocates eight instructions using a 3-bit primary opcode field:

Mnemonic Opcode (3 bits) Format Functional Operation
ADD Rd, Rs 000 R-type Rd <= Rd + Rs
SUB Rd, Rs 001 R-type Rd <= Rd - Rs
AND Rd, Rs 010 R-type Rd <= Rd & Rs
OR Rd, Rs 011 R-type Rd <= Rd | Rs
LDI Rd, Imm 100 I-type Rd <= Imm (Load Immediate)
LD Rd, [Addr] 101 I-type Rd <= Mem[Addr] (Memory Read)
ST [Addr], Rd 110 I-type Mem[Addr] <= Rd (Memory Write)
BEQ Rd, Addr 111 I-type if (Rd == 0) PC <= Addr

The eight opcodes exhaust the 3-bit binary encoding space completely. Branch instruction BEQ tests whether destination register Rd contains zero. This avoids the hardware overhead of an explicit status flag register.

Binary Instruction Formats

The architecture defines two distinct instruction layouts:

R-type and I-type encodings as bit fields
Figure 1: Instruction encoding

R-type (Register-to-Register Operations):
  Bits [7:5]: Opcode (3 bits)
  Bits [4:3]: Destination register Rd (2 bits, 4 general-purpose registers)
  Bits [2:1]: Source register Rs (2 bits)
  Bit  [0]:   Unused padding bit

I-type (Immediate and Memory Operations):
  Bits [7:5]: Opcode (3 bits)
  Bits [4:3]: Target register Rd (2 bits)
  Bits [2:0]: Immediate data or Memory address (3 bits)

The 8-bit word limit creates an architectural tradeoff between register count and immediate bit width. The register file provides four registers (R0 to R3), addressed by 2-bit fields. Immediate values and direct memory addresses are limited to 3 bits (values 0 to 7).

The Fetch-Decode-Execute Flow

The processor executes instructions across four defined stages:

  1. Fetch: Read the instruction byte from memory at the current Program Counter (PC) address.
  2. Decode: Extract opcode bits, register specifiers, and immediate fields from the instruction register.
  3. Execute: Perform ALU operations, register file updates, memory transfers, or branch evaluations.
  4. Advance: Increment the Program Counter by one, unless a taken branch overwrites the target address.

Practice Exercise

Assemble the following assembly code sequence into binary machine code:

  1. Load immediate value 5 into register R0.
  2. Load immediate value 3 into register R1.
  3. Add register R1 into register R0.
  4. Store register R0 to memory address 0.
Solution

Apply the bitfield formats defined in Figure 1:

LDI R0, 5   ->  100 00 101     (Opcode=100, Rd=00, Imm=101)
LDI R1, 3   ->  100 01 011     (Opcode=100, Rd=01, Imm=011)
ADD R0, R1  ->  000 00 01 0    (Opcode=000, Rd=00, Rs=01, Unused bit=0)
ST  [0], R0 ->  110 00 000     (Opcode=110, Rd=00 as source, Addr=000)

This four-byte program computes 5 + 3 = 8 and stores the result in memory location 0.

The instruction set architecture defines opcodes, bitfield mappings, and register structures. This 8-bit RISC specification establishes the technical baseline for processor implementation. The next article constructs the datapath registers, multiplexers, and arithmetic logic units.

Project 1, Part 2: The Datapath →