Simple 4-Bit CPU
Build a complete 4-bit CPU from the components you've created—program counter, registers, ALU, and control logic working together.
Overview
This is the capstone project—combining all the digital building blocks into a working computer. Your CPU will fetch instructions from ROM, decode them, execute operations in the ALU, store results in registers, and use the program counter to sequence through your program. It's a real, functioning computer built from basic logic.
Components Needed
- 1x SN74LS181 IC (ALU)
- 2x SN74HC161 IC (Counter)
- 2x SN74HC374 IC (Register)
- 2x SN74HC138 IC (Decoder)
- 4x SN74HC153 IC (MUX)
- severalx Various logic gate ICs
- 1x 28C16 EEPROM
- 16x LED
- manyx Wires
Instructions
Define the Architecture
Plan your CPU: 4-bit data width, 8-bit instructions (4-bit opcode + 4-bit operand), 2 general-purpose registers (A and B), accumulator-based ALU, 256-byte program memory.
Design the Instruction Set
Create 8-16 instructions: LOAD, STORE, ADD, SUB, AND, OR, JUMP, JUMP_IF_ZERO, HALT, etc. Document the binary encoding for each.
Build the Datapath
Connect PC → ROM → Instruction Register → Decoder. Wire registers to ALU through MUXes. Connect ALU output back to register file and memory interface.
Implement Control Logic
Build the instruction decoder to generate control signals. Wire control signals to register load enables, MUX selects, ALU function, and memory read/write.
Write a Test Program
Create a simple program in machine code: load values, add them, store result. Program the EEPROM with your machine code.
Test and Debug
Use single-step clocking to watch each instruction execute. Monitor data buses, register contents, and control signals. Debug issues one instruction at a time.
Challenges
- Add more instructions (shift, compare, call/return)
- Implement conditional branches based on ALU flags
- Add interrupt capability
- Expand to 8-bit data path
- Build an assembler to convert assembly to machine code