A four-bit shift register, one bit per clock

Four D-FLOPs in a row, every one clocked together, each feeding the next. Whatever is on SIN when a clock edge arrives lands in the first flip-flop, and everything already inside shuffles one place along. 36 NAND gates.

Open fullscreen

Drag the clock knob left to slow the rate down, then tap the SIN switch on and off and watch the pattern march down the four lamps. They are stacked in a column with Q0 — the first flip-flop, the one SIN feeds — at the top and Q3 at the bottom, so a bit enters at the top lamp and works its way down.

Why this matters more than it looks

A shift register is how a wire that carries one bit at a time becomes a number you can act on. Every serial protocol ends in one: bits arrive one per clock, and after eight ticks a byte is sitting there in parallel, ready to read.

Run it the other way and it is the transmitter. Load four bits, then shift them out one per clock onto a single wire.

It is also a delay line. Q3 is simply SIN from four clock ticks ago, which makes the whole thing a small memory of the recent past — the basis of edge detection, debouncing and digital filters.

Things worth trying


Built out of NAND gates and nothing else. The sandbox, the JSON module format and the rest of the library are described in Digital logic — from NAND to a computer.

logic