Incrementers, Decrementers, and Program Counters
← All articles

Incrementers, Decrementers, and Program Counters

6 min

Adding 1 is a special case

A full adder chain computes A+B for two arbitrary N-bit numbers, but incrementing (adding exactly 1) only ever adds a constant — and when one operand is fixed at 000...001, most of the gates inside each full adder's carry logic simplify away, leaving a cheaper chain built from XOR and AND gates alone.

The ripple-carry incrementer

Working it out bit by bit:

  • Bit 0 always flips (0⊕1 or 1⊕1), and bit 0's carry-out is simply bit 0's own current value.
  • Each following bit flips only if every less-significant bit was already 1 — i.e. the carry has rippled all the way up from bit 0 — exactly the 'carry into every column' behaviour of adding a single 1, and one gate cheaper per stage than a full adder.

Decrementers work the same way in reverse

A decrementer subtracts 1 using the same shortcut applied to two's-complement subtraction: each bit flips only if every less-significant bit was already 0. Boolflow ships both as ready-made INC4 and DEC4 blocks.

The program counter

A CPU's program counter is an ordinary loadable register with an INC4 wired from its output back into its own input: every clock cycle it either loads a jump target or increments its own current value by one — exactly how instruction fetch advances through memory address by address. Wire an INC4's output into a REG4's input in the circuit editor to build one.

Build an incrementer in the circuit editor →