Mesab / Hardware projectsStructural CPU design
Digital logic · CPU architecture · FPGA integration

M8: a CPU built from logic blocks

An 8-bit accumulator processor with a gate-based ALU, program counter, instruction ROM, data RAM, branches and seven-segment display drivers.

Verified in HDL simulation

Hardware simulation result

8-bitDatapath & accumulator
14Instructions implemented
16 bytesData RAM

The ROM program computes 1 + 2 + 3 + 4 + 5 using a countdown loop. The RTL reaches HALT after 54 instructions and latches decimal 15 to the output register.

Display pins · HDL simulation
Accumulator · hexadecimal
Output register · hexadecimal

This viewer replays signal values recorded by the Verilog testbench. It is not a connection to a physical FPGA.

Gate-level architecture

M8 datapath architecture showing program counter, ROM, control decoder, RAM, gate-based ALU, accumulator and display drivers
Structural arithmetic

Eight full-adder cells form the ripple-carry arithmetic unit. XOR gates select subtraction; gate-based multiplexers select the result.

Hardware control

Single-clock execution with enable signals, conditional branching, a latched output, halt control and invalid-instruction faults.

Board interface

Synchronized controls, a debounced step button and four active-low seven-segment buses. Exact device and pins remain unset.

Recorded execution trace

CycleNext PCAccumulatorRAM[0]RAM[1]OutputHALT

Waveforms from the hardware simulation

Actual HDL simulation showing the program counter, accumulator, running sum in RAM and output register over 54 instruction cycles

The plot uses the testbench’s recorded signals. The downloadable VCD contains the underlying clock, control, register and gate-level transitions.

Inside the arithmetic block

One full-adder cell with two XOR gates, two AND gates and an OR gate

The supplied full_adder module implements these gates directly. Cells are grouped into the ripple-adder block and instantiated in the ALU and program-counter incrementer.

Verification & implementation files

Exhaustive arithmetic

131,072 add/sub input cases and 1,024 bitwise cases passed in the logic simulator.

Instruction behaviour

All 14 instructions, both branch outcomes, RAM bounds, output latching and halt behaviour passed.

Display & controls

The simulated board interface passed stepping and run-control tests. Final output segment codes decode to 0F.

Download CPU & Quartus projectDownload simulation VCDDownload execution trace

Includes structural RTL, assembler, ROM program, testbenches and Quartus QPF/QSF project files. Compilation and simulation used Icarus Verilog 12.0. Quartus synthesis, fitting, timing closure and programming require the exact board model and a local Quartus installation.