Program Counter
Build a program counter that tracks the current instruction address—the CPU component that steps through program memory.
Overview
The Program Counter (PC) holds the address of the next instruction to execute. Normally it increments by 1 each cycle to step through sequential code. For jumps and branches, it can be loaded with a new address. The 74HC161 is a synchronous 4-bit counter with parallel load capability—perfect for a PC.
Components Needed
- 2x SN74HC161 IC (4-bit Counter)
- 8x LED
- 8x Switch
- 3x Push button
- severalx Wires
Instructions
Study the 74HC161
The 74HC161 has parallel data inputs (A-D), synchronous load (LD), enable inputs (ENP, ENT), clear (CLR), clock, and outputs (QA-QD, RCO for ripple carry).
Build an 8-bit Counter
Cascade two 74HC161s by connecting RCO of the first to ENT of the second. This creates an 8-bit counter for 256 addresses.
Add Parallel Load
Wire 8 switches to the parallel inputs. Connect a button to the LD signal. This allows loading a specific address (for jumps).
Test Count and Jump
Clock the counter and watch it increment through addresses. Load a value (simulating a jump) and verify the count continues from the new address.
Challenges
- Add a reset button that clears PC to 0
- Implement conditional load for branch instructions
- Add increment-by-2 mode for 16-bit instruction words
- Connect to a ROM to actually fetch instructions