Edge detector

A one-tick pulse every time the input changes — the trick behind every rising-edge trigger. A ready-made memory circuit you can open in the TorchAnvil simulator.

Fire a pulse when the input changes

Start the simulation, then flip the lever. The lamp blinks once — briefly — and goes dark again, even though the lever is still in its new position. Flip the lever back: another brief flash.

This is an edge detector, and it's one of the most useful little circuits in the book.

How it works

Two copies of the input arrive at the XOR gate:

XOR is "are these two different?". While the input is stable, the delayed copy matches the live one — XOR is false, lamp off. The instant the input flips, the live side changes immediately but the delayed side is still showing the old value. For exactly one tick they disagree — XOR is true, lamp on. Next tick, the delayed side catches up and they match again.

live delayed (prev tick) XOR
0 0 0
1 0 1 (rising edge)
1 1 0
0 1 1 (falling edge)

Why it matters

"Something just happened" is a question digital circuits ask constantly. Button-press latches, rising-edge clock triggers, transition counters, change-of-state interrupts — they all boil down to some variant of this. Even the flip-flops in this library are built around edge detection: the JK, D, and T all compare clk to prevClk to decide whether to act. This sample is that comparison made visible.

Try this