Menu

Theme

Projects · Project · CHECKED ON 5.0.0

Build an 8-bit CPU in Logisim-evolution

A CPU is a loop: the program counter picks an instruction from memory, a control unit turns its opcode into control signals, and the ALU and registers carry it out on the next clock edge. Here you build LDV-8, an 8-bit accumulator CPU with 16 instructions, a 256-word program ROM, 256 bytes of RAM and a halt signal, then load and run programs with a memory image. Every part has a .circ file that passed a test in Logisim-evolution 5.0.0.
FOR
Computer-organisation students and hobbyists who have built an ALU
CHECKED
12 Nov 2026
FIX TIME
about 8 to 12 hours
Checked against Logisim-evolution 5.0.0 on 1 machines
On this page

What you will build

LDV-8 has 8-bit data, 8-bit addresses, 12-bit instructions and 16 instructions. It is single-cycle: every instruction finishes in one clock cycle. It is a Harvard design: the program lives in one ROM and the data in a separate RAM. Time: about 8 to 12 hours over several sessions. You should have built the adders and the ALU and know registers, the RAM and the ROM.

circ-8-bit-cpu-ldv8 · mainscroll to see all
888clkclkresetresetRegisterpc regpc_nextclkresetrunpcAdderpconezeropc_inc1one0zeropc_incoperandjumppc_nextROMprogpcinstrinstroperandopROMctrlopcwcwacc_weflags_wemem_webselalu_fjmpjzjcout_wehalthaltrunacc_werunacc_we_eflags_werunflags_we_emem_werunmem_we_eout_werunout_we_ejzzjz_hitjccjc_hitjmpjz_hitjc_hitjumpRegisteracc regalu_rclkresetacc_we_eaccRegisterflags regflags_inclkresetflags_we_eflagsRegisterout regaccclkresetout_we_eoutRAMdataoperandaccmem_we_eclkram_q1ram_qoperandbselbAdderaccbzeror_addc_add0zerobnbAdderaccnbone1r_subc_sub1one1accbr_andaccbr_oraccbr_xorShifteraccs1r_shlShifteraccs1r_shr1s1r_addr_subr_andr_orr_xorr_shlr_shrbalu_falu_raccacc0acc7bb7r_addradd7r_subrsub7alu_rr7acc7b7same_aacc7radd7chg_asame_achg_av_addacc7b7diffacc7rsub7chg_sdiffchg_sv_subc_addc_sub000acc7acc00alu_fc_newv_addv_sub000000alu_fv_newCompalu_rzero8z_new0zero8flags_inz_newr7c_newv_newflagszncvoutlohiHexDhiHexDloLEDhaltout8bouthalthaltpc8bpcacc8bacc
The complete LDV-8 circuit drawn from the tested file. Everything is wired with tunnels, so the signals have names. CC BY 4.0 · SHA-256 a8cdb0f8b228
Describe this circuit

Components: Clock 1; Input pin reset; Register pc reg; Adder 1; Constant 1; Constant 2; Multiplexer 1; ROM prog; Splitter 1; ROM ctrl; Splitter 2; NOT Gate 1; AND Gate 1; AND Gate 2; AND Gate 3; AND Gate 4; AND Gate 5; AND Gate 6; OR Gate 1; Register acc reg; Register flags reg; Register out reg; RAM data; Constant 3; Multiplexer 2; Adder 2; Constant 4; NOT Gate 2; Adder 3; Constant 5; AND Gate 7; OR Gate 2; XOR Gate 1; Shifter 1; Shifter 2; Constant 6; Multiplexer 3; Splitter 3; Splitter 4; Splitter 5; Splitter 6; Splitter 7; XNOR Gate 1; XOR Gate 2; AND Gate 8; XOR Gate 3; XOR Gate 4; AND Gate 9; Multiplexer 4; Constant 7; Constant 8; Constant 9; Constant 10; Multiplexer 5; Constant 11; Constant 12; Constant 13; Constant 14; Constant 15; Constant 16; Comparator 1; Constant 17; Splitter 8; Splitter 9; Splitter 10; Hex Digit Display 1; Hex Digit Display 2; LED 1; Output pin out; Output pin halt; Output pin pc; Output pin acc.

  • Clock 1 connects to Register pc reg, Register acc reg, Register flags reg, Register out reg, RAM data (net clk).
  • Input pin reset connects to Register pc reg, Register acc reg, Register flags reg, Register out reg (net reset).
  • Register pc reg connects to Adder 1, ROM prog, Output pin pc (net pc), 8 bits wide.
  • Register pc reg connects to Multiplexer 1 (net pc_next), 8 bits wide.
  • Register pc reg connects to NOT Gate 1, AND Gate 1, AND Gate 2, AND Gate 3, AND Gate 4 (net run).
  • Adder 1 connects to Constant 1 (net one), 8 bits wide.
  • Adder 1 connects to Multiplexer 1 (net pc_inc), 8 bits wide.
  • Adder 1 connects to Constant 2, Adder 2, Constant 4 (net zero).
  • Multiplexer 1 connects to Splitter 1, RAM data, Multiplexer 2 (net operand), 8 bits wide.
  • Multiplexer 1 connects to OR Gate 1 (net jump).
  • ROM prog connects to Splitter 1 (net instr), 12 bits wide.
  • Splitter 1 connects to ROM ctrl (net op), 8 bits wide.
  • ROM ctrl connects to Splitter 2 (net cw), 12 bits wide.
  • Splitter 2 connects to AND Gate 1 (net acc_we).
  • Splitter 2 connects to AND Gate 2 (net flags_we).
  • Splitter 2 connects to AND Gate 3 (net mem_we).
  • Splitter 2 connects to Multiplexer 2 (net bsel).
  • Splitter 2 connects to Multiplexer 3, Multiplexer 4, Multiplexer 5 (net alu_f), 3 bits wide.
  • Splitter 2 connects to OR Gate 1 (net jmp).
  • Splitter 2 connects to AND Gate 5 (net jz).
  • Splitter 2 connects to AND Gate 6 (net jc).
  • Splitter 2 connects to AND Gate 4 (net out_we).
  • Splitter 2 connects to NOT Gate 1, LED 1, Output pin halt (net halt).
  • AND Gate 1 connects to Register acc reg (net acc_we_e).
  • AND Gate 2 connects to Register flags reg (net flags_we_e).
  • AND Gate 3 connects to RAM data (net mem_we_e).
  • AND Gate 4 connects to Register out reg (net out_we_e).
  • AND Gate 5 connects to OR Gate 1 (net jz_hit).
  • AND Gate 5 connects to Splitter 9 (net z).
  • AND Gate 6 connects to OR Gate 1 (net jc_hit).
  • AND Gate 6 connects to Splitter 9 (net c).
  • Register acc reg connects to Register out reg, RAM data, Adder 2, Adder 3, AND Gate 7, OR Gate 2, XOR Gate 1, Shifter 1, Shifter 2, Splitter 3, Output pin acc (net acc), 8 bits wide.
  • Register acc reg connects to Multiplexer 3, Splitter 7, Comparator 1 (net alu_r), 8 bits wide.
  • Register flags reg connects to Splitter 9 (net flags), 4 bits wide.
  • Register flags reg connects to Splitter 8 (net flags_in), 4 bits wide.
  • Register out reg connects to Splitter 10, Output pin out (net out), 8 bits wide.
  • RAM data connects to Multiplexer 2 (net ram_q), 8 bits wide.
  • RAM data connects to Constant 3.
  • Multiplexer 2 connects to Adder 2, NOT Gate 2, AND Gate 7, OR Gate 2, XOR Gate 1, Multiplexer 3, Splitter 4 (net b), 8 bits wide.
  • Adder 2 connects to Multiplexer 3, Splitter 5 (net r_add), 8 bits wide.
  • Adder 2 connects to Multiplexer 4 (net c_add).
  • NOT Gate 2 connects to Adder 3 (net nb), 8 bits wide.
  • Adder 3 connects to Multiplexer 3, Splitter 6 (net r_sub), 8 bits wide.
  • Adder 3 connects to Constant 5 (net one1).
  • Adder 3 connects to Multiplexer 4 (net c_sub).
  • AND Gate 7 connects to Multiplexer 3 (net r_and), 8 bits wide.
  • OR Gate 2 connects to Multiplexer 3 (net r_or), 8 bits wide.
  • XOR Gate 1 connects to Multiplexer 3 (net r_xor), 8 bits wide.
  • Shifter 1 connects to Shifter 2, Constant 6 (net s1), 3 bits wide.
  • Shifter 1 connects to Multiplexer 3 (net r_shl), 8 bits wide.
  • Shifter 2 connects to Multiplexer 3 (net r_shr), 8 bits wide.
  • Splitter 3 connects to Multiplexer 4 (net acc0).
  • Splitter 3 connects to XNOR Gate 1, XOR Gate 2, XOR Gate 3, XOR Gate 4, Multiplexer 4 (net acc7).
  • Splitter 4 connects to XNOR Gate 1, XOR Gate 3 (net b7).
  • Splitter 5 connects to XOR Gate 2 (net radd7).
  • Splitter 6 connects to XOR Gate 4 (net rsub7).
  • Splitter 7 connects to Splitter 8 (net r7).
  • XNOR Gate 1 connects to AND Gate 8 (net same_a).
  • XOR Gate 2 connects to AND Gate 8 (net chg_a).
  • AND Gate 8 connects to Multiplexer 5 (net v_add).
  • XOR Gate 3 connects to AND Gate 9 (net diff).
  • XOR Gate 4 connects to AND Gate 9 (net chg_s).
  • AND Gate 9 connects to Multiplexer 5 (net v_sub).
  • Multiplexer 4 connects to Constant 7.
  • Multiplexer 4 connects to Constant 8.
  • Multiplexer 4 connects to Constant 9.
  • Multiplexer 4 connects to Constant 10.
  • Multiplexer 4 connects to Splitter 8 (net c_new).
  • Multiplexer 5 connects to Constant 11.
  • Multiplexer 5 connects to Constant 12.
  • Multiplexer 5 connects to Constant 13.
  • Multiplexer 5 connects to Constant 14.
  • Multiplexer 5 connects to Constant 15.
  • Multiplexer 5 connects to Constant 16.
  • Multiplexer 5 connects to Splitter 8 (net v_new).
  • Comparator 1 connects to Constant 17 (net zero8), 8 bits wide.
  • Comparator 1 connects to Splitter 8 (net z_new).
  • Splitter 10 connects to Hex Digit Display 2 (net lo), 4 bits wide.
  • Splitter 10 connects to Hex Digit Display 1 (net hi), 4 bits wide.

All files are saved in the 5.0.0 format and verified there. There is no classic 2.7.1 version: sequential test vectors need Evolution, and the command-line behaviour we rely on differs in 2.7.1 (F04, F05).

Part 1: The instruction set

Registers and memory: ACC (8 bits), PC (8 bits), four flags Z, N, C and V, an output register OUT (8 bits), a program ROM of 256 words of 12 bits and a data RAM of 256 bytes. An instruction is 12 bits: the opcode is bits 11 to 8 and the operand is bits 7 to 0. In hex the first digit is the opcode and the last two digits are the operand, so D05 is JZ to address 05.

The 16 instructions of LDV-8
0HLTnoneStop: nothing changes any more and halt is 1none
1LDA aaddressACC gets RAM[a]Z N (C V cleared)
2LDI n8-bit valueACC gets nZ N (C V cleared)
3STA aaddressRAM[a] gets ACCnone
4ADD aaddressACC gets ACC + RAM[a]Z N C V
5SUB aaddressACC gets ACC - RAM[a]Z N C V
6ADI n8-bit valueACC gets ACC + n (ADI FF subtracts 1)Z N C V
7AND aaddressACC gets ACC AND RAM[a]Z N (C V cleared)
8OR aaddressACC gets ACC OR RAM[a]Z N (C V cleared)
9XOR aaddressACC gets ACC XOR RAM[a]Z N (C V cleared)
ASHLnoneACC shifted left by 1Z N C (old bit 7)
BSHRnoneACC shifted right by 1Z N C (old bit 0)
CJMP aaddressPC gets anone
DJZ aaddressif Z = 1 then PC gets anone
EJC aaddressif C = 1 then PC gets anone
FOUTnoneOUT gets ACCnone

Opcode 0 is HLT on purpose: an empty ROM, or a program image that failed to load, reads as all zeros and stops the CPU at once instead of running wild. There is no subtract-immediate because ADI FF adds 255, which subtracts 1 in two’s complement. After SUB, a carry means the first number was at least the second (unsigned), so JC after SUB means “greater or equal”.

Part 2: Program counter

The PC holds the address of the current instruction. Its next value is PC + 1 or a jump target. Build it from an 8-bit Register (clear from reset, enable from en), an Adder that adds the constant 1, and a 2-input Multiplexer with 8 data bits that chooses between PC + 1 and target. The adder’s carry-in is tied to 0.

Download circ-8-bit-cpu-pc.circ and its vector. The 39-row sequential vector with CLK as an input pin counts 0 to 5, jumps to 0x80, counts on, holds with en at 0 and resets (test vectors). It passed.

Part 3: Program memory and fetch

Add a ROM with Address Bit Width 8 and Data Bit Width 12 and give it the label prog: the label is what --load targets later (F16). Its contents are saved inside the .circ (F12). A splitter turns the 12-bit word into op (bits 11 to 8) and operand (bits 7 to 0); set each bit’s end explicitly in the splitter’s attributes (splitter).

Download circ-8-bit-cpu-fetch.circ and its vector (28 rows, passed). It has the countdown program stored and checks op and operand on the first cycles: 2 and 05, F and 00, D and 05, 6 and FF, C and 01.

Part 4: ALU, accumulator and flags

LDV-8’s ALU is built from Logisim’s own Adder, gates and Shifters rather than imported from the 4-bit project. Its operation input alu_f selects through an 8-input multiplexer:

alu_f
0add
1subtract
2and
3or
4xor
5shift left
6shift right
7pass B

Input B is a 2-input multiplexer: RAM data (bsel 0) or the operand (bsel 1). Subtract is ACC + NOT B + 1 on a second adder, so its carry means “no borrow”. Overflow for add is “A and B have the same sign and the result’s sign differs from A”; for subtract it is “A and B differ and the result’s sign differs from A”. Z comes from a comparator against 0, N is the result’s top bit, and C is the adder carry, or the bit shifted out for shifts. The ACC, FLAGS (4 bits) and OUT registers share the clock and write only when their enable is 1.

The data RAM has 8 address bits and 8 data bits, address from operand, data in from ACC, store from mem_we, load tied to 1.

Download circ-8-bit-cpu-datapath.circ and its vector. In it you play the control unit: the control signals are input pins, and the vector runs LDI, ADI, STA, LDA, OUT, SUB, SHL, SHR, AND, OR and XOR instructions and checks ACC, FLAGS and OUT after each clock (55 rows, passed).

Part 5: Control unit

The control word is 12 bits, one bit per signal: bit 0 acc_we, 1 flags_we, 2 mem_we, 3 bsel, bits 4 to 6 alu_f, 7 jmp, 8 jz, 9 jc, 10 out_we, 11 halt. A 16 by 12 ROM labelled ctrl holds one word per opcode, so the table below is the hardware:

Control ROM contents
0HLT0000000001800
1LDA a1100700000073
2LDI n110170000007B
3STA a0010000000004
4ADD a1100000000003
5SUB a1100100000013
6ADI n110100000000B
7AND a1100200000023
8OR a1100300000033
9XOR a1100400000043
ASHL1100500000053
BSHR1100600000063
CJMP a0000010000080
DJZ a0000001000100
EJC a0000000100200
FOUT0000000010400

The jump signal is jmp OR (jz AND Z) OR (jc AND C), using the flags stored by the previous instruction. Every write enable (PC, ACC, FLAGS, RAM, OUT) is ANDed with NOT halt; the clock itself keeps running. A decoder with OR gates would also work (decoder); we used a ROM because the table is the design.

Download circ-8-bit-cpu-control.circ, its vector (22 rows, passed) and the control ROM image.

Part 6: Put it together

Wire the blocks: one clock for every register and the RAM; reset to the clear of PC, ACC, FLAGS and OUT; RAM address and jump target from operand; halt as an output pin labelled exactly halt; out as an 8-bit output pin from the OUT register. The main circuit has a Clock component, a reset input, output pins out, halt, pc and acc, two Hex Digit Displays on OUT (displays) and an LED on halt.

Download circ-8-bit-cpu-ldv8.circ (countdown stored in prog). The first cycles of the countdown, before each clock edge:

Countdown trace (reference model; Logisim's out, pc and acc matched on every cycle)
000205000 000
101F00050 000
202D05050 005
3036FF050 005
404C01040 105
501F00040 105
602D05040 104
PC, ACC and OUT over the first seven cycles of the countdown (reference model)
Show values as a table
cyclePCACCOUT
0000000
1010500
2020505
3030505
4040405
5010405
6020404

We did not capture a timing diagram from the window, so this waveform is the model’s, and the test of the circuit itself is the line-by-line match of its output.

Step through a program

The values below were recorded from our reference model, which matched Logisim's own output (out, pc and acc) on every cycle of all three programs. Nothing here simulates a circuit.

Cycle 0 of 23
  1. 00 205 LDI 05
  2. 01 F00 OUT
  3. 02 D05 JZ 05
  4. 03 6FF ADI FF
  5. 04 C01 JMP 01
  6. 05 000 HLT
State before this instruction runs
PC00
Instruction205
ACC00 (0)
Z N C V0 0 0 0
OUT00 (0)
ALUpass B
Signalsacc_we, flags_we, bsel

Part 7: Write your first programs

A listing line is an address, a hex word and a mnemonic. To hand-assemble, write the opcode digit and then the two-digit operand. Three programs, each with a listing and an image in v2.0 raw:

  • countdown 205 F00 D05 6FF C01 000: outputs 5, 4, 3, 2, 1, 0, then halts after 23 instructions. Listing, image.
  • sum (1 + 2 + … + 10 using RAM at 0x80 and 0x81): outputs 55 (0x37); halts after 85 instructions. Listing, image.
  • fibonacci (until the next number would not fit in 8 bits, using JC): outputs 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 and halts after 117 instructions. Listing, image.

Keep your data in RAM from 0x80 up, end with HLT, and remember the RAM is 0 after reset. Exercises with no solutions here: multiply by repeated addition, the larger of two numbers with SUB and JC, count the 1 bits with SHR and JC, output the even numbers, swap two RAM bytes.

Part 8: Load programs with a memory image

Make an image with the memory image generator: Data Bits 12, Address Bits 8, format v2.0 raw. The countdown image is two lines:

File ldv8-countdown.txt
v2.0 raw
205 f00 d05 6ff c01 0

In the window, right-click the prog ROM and choose Load Image, then reset the simulation (Ctrl+R) and turn on ticks (Ctrl+K). After opening any file, click the canvas or press Ctrl+R before judging whether wires are right (F45). Contents loaded into a ROM can be saved in the file (F12). We did not capture the Load Image dialog for LDV-8.

On the command line:

Terminal
java -jar logisim-evolution-5.0.0-all.jar --tty table circ-8-bit-cpu-ldv8.circ --load ldv8-countdown.txt prog
Output: 0000 0000	0000 0000	0000 0000
Output: 0000 0000	0000 0001	0000 0101
Output: 0000 0101	0000 0010	0000 0101
Output: …
Output: 0000 0000	0000 0101	0000 0000
exit: 0

The three programs were run this way and their output matched the reference model on every line (F111). Each line is one clock cycle: the three columns are out, pc and acc, and the run stops by itself when halt is 1. The installers’ launchers take the same options (F28).

Part 9: Run, watch and measure

In the window, enable ticks with Simulate, Auto-Tick Enabled (Ctrl+K) and watch the Hex Digit Displays count down and the halt LED light (clock and simulation). To step, use Manual Tick Half Cycle (Ctrl+T) or Full Cycle (Ctrl+F9). We have no step screenshots of LDV-8 in the window.

On the command line --tty table prints one row per clock cycle until halt, in binary. See the command line reference for halt, speed and the other formats. --tty speed on the countdown printed 5000 Hz (45 ticks in 9 milliseconds); the run is too short to be a speed measure, so we give no performance claim.

Common mistakes

Common mistakes
LDA loads the old valueThe RAM's Asynchronous read is No. Set it to Yes.Tested (F111)
--load seems to do nothingThe circuit must come first, and the circuit needs a halt pin when you use --tty table.Tested (F13, F16, F111)
The CPU halts at once after loadingThe image was rejected (no header line) and the ROM is empty, so address 0 reads as HLT.Tested for the rejection (F15)
The CPU never stops on the command lineThere is no output pin labelled exactly halt in the circuit that runs.Not reproduced here
Nothing happens after loadingTicks are off, or the simulation was not reset; click the canvas or press Ctrl+R.Seen for grey wires (F45)
PC adds 2 per clock, or RAM writes every clockThe clock goes through logic, or the store input is not driven by mem_we.Not reproduced here

Extensions

A shared bus like a breadboard CPU needs tri-state drivers (controlled buffer) and several clock steps per instruction. Input from a keyboard: not published here. A 16-bit CPU needs wider ROM and registers. Running LDV-8 on an FPGA: see the FPGA guide; HDL-only generation stops until every input and output is mapped and saved (F51), and we have not run LDV-8 on a board or checked which of its parts export to HDL.

Downloads

Circuits: pc, fetch, datapath, control, ldv8. Images and listings: countdown, sum, fibonacci, control ROM. Not built: the two broken examples the plan lists. All files are CC BY 4.0 and 5.0.0 only. Back to projects.

To combine the parts into one file for submission, merge them as described in libraries, merging and copying circuits.

Frequently asked questions

How do I make a CPU in Logisim?

Build a program counter, a program ROM, a control unit that decodes the opcode, an ALU with an accumulator and a RAM, and clock them all together. LDV-8 on this page is a complete, tested example.

How do I make a program counter in Logisim?

An 8-bit register, an adder that adds 1, and a multiplexer that picks PC + 1 or a jump target. Stop it with the register's enable, not by gating its clock. Our version passed a 39-row sequential test vector.

How do I load a program into ROM in Logisim?

Right-click the ROM, choose Load Image, or on the command line use --load after the circuit file. The image's first line must be a header such as v2.0 raw (F14, F15, F16).

Why does --load do nothing on the command line?

Two causes: the circuit file must come before --load, and a plain --tty table run ignores --load when the circuit has no halt pin (F13, F16). LDV-8 has a halt pin.

How do I stop the clock when my CPU executes HLT?

You do not stop the clock. HLT sets a halt signal that switches off every write enable, and a pin labelled halt lets the command line stop. See the control unit part.

Does this CPU work in Logisim 2.7.1?

No. It is saved in the 5.0.0 format, uses sequential test vectors that classic does not have, and 2.7.1's -tty table behaves differently (F04, F05).

Sources

  1. LDV-8 runs and vectors, logisim.dev lab data: test-data/FINDINGS.md F111; scripts/qa_cpu.py; test-data/lab20-2026-11-12-cpu/logs/
  2. ROM contents, memory image formats and --load, logisim.dev lab data: test-data/FINDINGS.md F12 to F16
  3. ISA and control words, logisim.dev lab data: src/content/projects/ldv8-isa.json

Try: , , ,