Flip-Flops & Counters
SR latch, D, JK, and T flip-flops, timing diagrams, synchronous and asynchronous counters, binary, ring, and Johnson counters
1. SR Latch — The Basic Memory Cell
The SR (Set-Reset) latch is the simplest bistable circuit. Built from two cross-coupled NOR or NAND gates, it has two stable states and forms the foundation of all flip-flop circuits.
The forbidden state (S=R=1) can lead to metastability — a circuit that takes an indeterminate time to settle. The D flip-flop eliminates this by ensuring S and R are always complementary.
2. Flip-Flop Types
3. Counters
Counters are registers whose state advances through a defined sequence. An N-bit binary counter cycles through \( 2^N \) states. The key distinction is synchronous vs asynchronous:
All flip-flops clocked simultaneously. No ripple delay. Faster and easier to analyze. Used in most modern designs.
Each flip-flop clocked by the output of the previous. Simpler to build but introduces cumulative propagation delay (ripple).
Specialty counters include the ring counter (single 1 bit circulating — N states from N FFs) and the Johnson counter (complemented output fed back — 2N states from N FFs, no glitches).
4. Python: 4-Bit Counter & D Flip-Flop Timing Diagram
Simulate a 4-bit synchronous binary counter over 16 clock cycles, plot Q0–Q3 timing waveforms, and show D flip-flop capture behavior with a random data input.
Click Run to execute the Python code
Code will be executed with Python 3 on the server