Building a Simple 8-Bit CPU in Logisim-evolution: Step-by-Step Architecture Guide

⚡ Quick Summary: The Minimal Working CPU Architecture

An 8-bit central processing unit in Logisim-evolution consists of exactly two synchronized subsystems: a datapath (Program Counter, Instruction Register, Accumulator, ALU, and RAM) that transforms data across shared 8-bit buses, and a control unit (FSM state machine) that pulses enable and write lines across 4 discrete micro-operation phases (Fetch, Decode, Execute, Writeback). To achieve a functional computer that executes loops and conditional branching, a minimal instruction set requires only 8 operations (NOP, LDA, ADD, SUB, STA, JMP, JZ, and HLT). This design can be simulated purely in software or compiled directly to physical FPGA hardware such as the Digilent Basys 3.

Essential Lab Textbooks and Physical FPGA Silicon for CPU Design

Building a CPU from raw logic gates is the definitive capstone project of computer engineering. The following authoritative textbooks and development boards bridge schematic simulation with physical silicon:

Gold Standard Course

The Elements of Computing Systems (Nand2Tetris)

By Noam Nisan & Shimon Schocken. The legendary MIT Press textbook that guides you from single NAND gates to building the 16-bit Hack CPU, assembler, virtual machine, and compiler.

Format: Paperback & Kindle • Used in 400+ Universities Worldwide
View Textbook on Amazon →
Physical Hardware Target

Digilent Basys 3 FPGA Development Board

The physical silicon target for your CPU. Synthesize the 8-bit CPU designed in this tutorial and display accumulator values on real 7-segment displays while stepping clock cycles with physical pushbuttons.

Price: ~$165 USD • Built-in Logisim FPGA Commander Support
Check Basys 3 on Amazon →

Complete 8-Bit Instruction Set Architecture Table

Our minimal processor utilizes an 8-bit fixed-width instruction format. The upper 4 bits represent the Opcode (Operation Code), and the lower 4 bits represent the Operand Address (referencing 16 bytes of internal data RAM):

Opcode (Binary) Mnemonic Format RTL Micro-Operation Description Active Control Signals
0000 NOP 0000 0000 No operation. Program counter increments smoothly. PC_Inc
0001 LDA addr 0001 [AAAA] Load RAM contents at address [AAAA] into Accumulator (AC). RAM_Out, AC_Load
0010 ADD addr 0010 [AAAA] AC ← AC + RAM[AAAA]. Updates Zero and Carry flags. ALU_Add, AC_Load, Flag_Update
0011 SUB addr 0011 [AAAA] AC ← AC – RAM[AAAA]. Updates Zero and Borrow flags. ALU_Sub, AC_Load, Flag_Update
0100 STA addr 0100 [AAAA] Store Accumulator value into RAM at address [AAAA]. AC_Out, RAM_Write
0101 JMP addr 0101 [AAAA] Unconditional branch: Program counter latches target address [AAAA]. PC_Load, Operand_Bus
0110 JZ addr 0110 [AAAA] Conditional jump: PC ← [AAAA] only if Zero Flag = 1. PC_Load_Cond (AND gate with Zero Flag)
1111 HLT 1111 0000 Halt processor: stops the master clock oscillator until hard reset. Clock_Halt

Four Phase Micro-Operation Cycle of the Control Unit

A single instruction cannot execute in a single instant because data buses would suffer contention. The control unit employs a 2-bit counter (sequencing states 0 through 3) to execute instructions across four clean phases:

Phase 0: Instruction Fetch

The Program Counter (PC) outputs its current 4-bit memory address to the Instruction ROM. The ROM looks up the 8-bit instruction byte. At the rising edge of the fetch clock, this byte is latched into the Instruction Register (IR), and the PC increments by 1 in preparation for the next cycle.

Phase 1: Instruction Decode and Operand Split

A bus splitter divides the 8-bit Instruction Register into two 4-bit nibbles: bits 7–4 (Opcode) and bits 3–0 (Operand Address). The Opcode feeds a 4-to-16 line Decoder or control ROM, which asserts exactly one active instruction wire (e.g., IS_ADD or IS_STA).

Phase 2: Execution and Memory Access

The control logic activates the physical buses. If executing LDA, the data RAM places its byte onto the shared data bus. If executing ADD, the ALU sums the Accumulator and RAM output. If executing JMP, the lower 4-bit operand is routed directly to the PC’s load input.

Phase 3: Writeback and Sequence Reset

The destination register latches the final result. For arithmetic operations, the Accumulator latches the ALU output bus, and status flip-flops latch Zero and Carry flags. The 2-bit micro-sequencer counter resets to 0, concluding the instruction and beginning the next fetch cycle.

Sample Machine Code Program for Calculating a Sum in ROM

To verify your CPU datapath in Logisim-evolution, enter the following hex values directly into the ROM component’s built-in hex editor (accessible via right-click → Edit Contents). This program loads the number at RAM address 0xE (value: 5), adds the number at RAM address 0xF (value: 3), stores the resulting 8 back into RAM address 0xD, and halts:

// Memory Address: Machine Hex Code [Assembly Mnemonic] // Explanation
0x0: 1E    // LDA 0xE   ; Load value at RAM[14] (0x05) into Accumulator
0x1: 2F    // ADD 0xF   ; Add value at RAM[15] (0x03) to Accumulator (AC = 0x08)
0x2: 4D    // STA 0xD   ; Store Accumulator result (0x08) into RAM[13]
0x3: F0    // HLT       ; Stop clock execution (Done)

// Data RAM Initial Values:
RAM[0xD] = 0x00  ; Result placeholder
RAM[0xE] = 0x05  ; Input A (5)
RAM[0xF] = 0x03  ; Input B (3)

Frequent Design Traps When Building Logisim CPUs

Over 80% of student CPUs fail on the first run due to three predictable schematic hazards:

⚠️ Bus Contention (Orange Wire Conflicts)

If two registers or memory outputs drive the main data bus simultaneously, Logisim turns the wire orange (error contention). In a single-bus CPU, never connect outputs directly together without controlled Multiplexers or Tri-State Buffers governed by mutually exclusive control lines.

⚠️ Double PC Increment per Cycle

If the Program Counter’s count enable input is left asserted across multiple micro-phases, the PC will skip every other instruction. Ensure the PC increment line is strictly qualified by an AND gate with Phase == 0 (Fetch).

⚠️ Asynchronous Timing Glitches in Branches

When executing conditional jumps like JZ, do not feed raw ALU zero outputs directly into the PC load trigger. The ALU takes several nanoseconds of propagation delay to settle after addition. Always sample status flags into clocked D flip-flops before testing branch conditions.

Curriculum Progression from 8-Bit CPU to Advanced Architectures

Once your accumulator CPU is executing assembly instructions reliably, scale your architecture through our next-level hardware guides:

Frequently Asked Questions About Building Logisim CPUs

What is the difference between an accumulator CPU and a general-purpose register CPU?

An accumulator CPU (like the 8-bit model built here or the MOS 6502) performs all arithmetic operations implicitly on a single working register called the Accumulator. This keeps instruction formats compact (only 8 bits) because only one memory operand address needs to be specified. In contrast, modern RISC architectures (like MIPS and RISC-V) use 32 general-purpose registers and require 32-bit instructions to encode two source registers and one destination register per operation.

How do I prevent wire spaghetti when connecting multiple CPU subcircuits?

Never route physical multi-bit buses across your entire canvas. Instead, use Logisim-evolution’s Tunnel components (found in the Wiring library). By naming a tunnel DATA_BUS[7..0] or CONTROL_REG_WRITE, any component connected to that tunnel label communicates wirelessly across the schematic, keeping the layout legible and easy to grade.

Can this 8-bit Logisim CPU be synthesized onto a physical FPGA board?

Yes. Logisim-evolution’s FPGA Commander can convert this entire 8-bit schematic into synthesizable VHDL. You can map the 8-bit accumulator output to physical board LEDs or 7-segment displays, map the clock to an onboard button (to step instructions manually), and flash it directly to an Artix-7 FPGA (such as the Digilent Basys 3). Follow our complete guide on FPGA Hardware Deployment.

How do I debug an instruction that outputs incorrect values during simulation?

Use the Chronogram tool (Simulate → Chronogram). By adding the master clock, phase counter outputs, and key register load lines to the waveform timeline, you can visually trace exactly which control wire fired at the wrong clock tick, pinpointing timing discrepancies in seconds.

⚖️ Affiliate Disclosure: In full compliance with FTC guidelines, links pointing to merchant platforms (such as Amazon) are affiliate referral pathways. If you choose to acquire laboratory hardware kits or textbooks through these links, we may receive a commission at zero additional expense to you.

Similar Posts