ProgramCounter

Inputs

PinTypeDescription
ClockbitOn rising edge (0→1), the PC updates its value
ResetbitReset counter to 0 — highest priority
LoadbitLoad Addr into counter — medium priority
Addrbus8Jump target address (used when Load = 1)
Incbus8Increment amount (defaults to 1 if unconnected)

Outputs

PinTypeDescription
Qbus8Current program counter value (0–255)

How It Works

The ProgramCounter (PC) tracks the address of the next instruction to execute. On each clock rising edge, it evaluates its inputs in the following priority order:

  1. Reset = 1 → Q = 0 (highest priority — aborts jump and increment)
  2. Load = 1 and Reset = 0 → Q = Addr (jump to target address)
  3. Neither Reset nor Load → Q = Q + Inc (normal sequential execution)

Important: the Inc pin has a special default behavior. If nothing is connected to Inc, the PC checks this with isInputConnected and defaults Inc to 1. This means:

The Q output always reflects the current address and connects to the ROM's address input.

Usage

The ProgramCounter is the heart of program flow control:

Typical connections:

Go to the simulator →