Skip to content
Digital Electronics•Unit 4• ECE1001

Flip-Flops, Registers and Counters

Latches vs flip-flops, characteristic equations, setup and hold timing, registers, and synchronous/ripple counters.

Learning Mode Filter (#29):Personalize View
Skills Built:Flip-Flop Characteristic EquationsTiming Analysis (Setup/Hold)Synchronous Counter DesignMod-N Counter Implementation

1. Intuition First: Latches, Flip-Flops, and Clock Dividers

In combinational logic, output signals respond instantaneously (subject only to propagation delay) to input changes. Memory does not exist. Sequential logic introduces state feedback, allowing a circuit to remember past events.

To understand the difference between memory elements, consider intuitive physical analogies:

  • The Latch (Level-Sensitive Door): A latch is a door held wide open while its enable signal is HIGH. Whatever enters the hallway immediately walks right through into the room. If inputs change or glitch while the door is open, those changes pass directly to the output (transparency).
  • The Flip-Flop (Camera Shutter): A flip-flop is an edge-triggered camera shutter. It remains closed, snaps a high-speed exposure for an instant at the clock transition (LOW-to-HIGH or HIGH-to-LOW), and freezes that picture at output QQ until the next active edge arrives. Input changes occurring between clock edges are completely ignored.
  • The Counter (Train of Reduction Gears): When toggle (TT) flip-flops are chained such that each stage triggers on the state transition of the previous stage, every stage divides the input frequency by 22. Like a mechanical gear reduction box, a high-speed crystal oscillator shaft slows down step-by-step into human-scale seconds, minutes, and hours.
       Level-Sensitive Latch                   Edge-Triggered Flip-Flop
      ┌───────────────────────┐               ┌───────────────────────┐
D ────┤                       ├──── Q    D ────┤                       ├──── Q
      │ Open while EN = 1     │               │ Captures strictly on  │
EN ───┤ Transparent to noise  │          CLK ─┤ active CLK edge (↑)   │
      └───────────────────────┘               └───────────────────────┘

Bistable Memory & Feedback

The elemental core of all semiconductor static memory is a bistable multivibrator formed by two back-to-back cross-coupled inverters. If output Q=1Q = 1, the opposing inverter forces Q‾=0\overline{Q} = 0, which in turn feeds back to sustain Q=1Q = 1. The circuit possesses two stable states (00 and 11). Steering gates (NAND or NOR) surround this core to enable controllable SET and RESET operations.


2. Formula & Unit Quick-Reference Strip

Formula & Unit Quick-Reference Strip
D Flip-FlopNext state
Q^+ = D

Data flip-flop: copies input D onto output Q at the active clock edge.

T Flip-FlopNext state
Q^+ = T \oplus Q

Toggle flip-flop: toggles state when T = 1; holds previous state when T = 0.

JK Flip-FlopNext state
Q^+ = J\overline{Q} + \overline{K}Q

Universal sequential element: sets when J=1, resets when K=1, toggles when J=K=1.

SR LatchNext state
Q^+ = S + \overline{R}Q \quad (SR = 0)

Sets on S=1, resets on R=1; simultaneous assertion S = R = 1 is strictly forbidden.

Setup Time CheckNanoseconds (ns)
T_{\text{clk}} \ge t_{\text{cq}} + t_{\text{logic(max)}} + t_{\text{su}}

Minimum clock period guaranteeing data arrives before destination setup window.

Hold Time CheckNanoseconds (ns)
t_{\text{cq(min)}} + t_{\text{logic(min)}} \ge t_{\text{hold}}

Fastest data arrival must not overwrite previous state during hold window; frequency independent.

Counter State CapacityCount states
N_{\text{states}} = 2^n

An n-bit binary counter traverses 2^n unique states; Mod-N requires ceil(log2 N) flip-flops.

Binary Frequency DivisionHertz (Hz)
f_{\text{out}} = \frac{f_{\text{clk}}}{2^n}

Output frequency obtained after n cascaded binary toggle flip-flop stages.


3. Mathematical Derivation: Unifying Flip-Flops from the Universal JK Cell


4. Typical Bench Values & Laboratory Timing Parameters

In practical breadboard prototyping and high-speed digital design, flip-flops are not instantaneous ideal switches. Understanding dynamic specifications is essential to avoid timing violations:

Typical Laboratory Hardware Ranges
Parameter / PartTypical ValueLab RangePractical Notes
Clock-to-Q Delay (t_cq)2 ns to 8 ns (74HC / 74LVC)0.2 ns (FPGA) - 15 ns (74LS)Propagation time from clock active edge until output Q is stable
Setup Time (t_su)1.5 ns to 4 ns0.1 ns - 10 nsWindow before clock edge where data input D must remain strictly stable
Hold Time (t_hold)0 ns to 2 ns0 ns - 5 nsWindow after clock edge where data input D must remain unchanged
Maximum Clock Frequency (f_max)25 MHz to 125 MHz (Discrete logic IC)10 MHz - 500 MHz+Upper limit set by 1 / (t_cq + t_logic + t_su) in synchronous data paths

5. Worked Engineering Examples

Example 1: JK Flip-Flop Sequential State Tracking (Easy)

Step-by-Step Worked Problem

A positive edge-triggered JK flip-flop starts in the initial cleared state Q = 0. Trace the output state Q over 5 successive active clock edges under the following sequence of input pairs (J, K): Edge 1: (1, 0); Edge 2: (1, 1); Edge 3: (0, 0); Edge 4: (0, 1); Edge 5: (1, 1).

Clock Edge 1: Inputs J = 1, K = 0
Using Q+ = J*Q' + K'*Q: With J=1 and K=0, this is the SET command. Q+ = 1*(0') + 0'*(0) = 1*1 + 1*0 = 1. State changes from Q = 0 to Q = 1.
Clock Edge 2: Inputs J = 1, K = 1
With J=1 and K=1, the flip-flop is in TOGGLE mode. Since present state Q = 1, next state Q+ = Q' = 1' = 0. Output toggles to Q = 0.
Clock Edge 3: Inputs J = 0, K = 0
With J=0 and K=0, the flip-flop is in HOLD (memory) mode. Q+ = Q = 0. Output remains stable at Q = 0.
Clock Edge 4: Inputs J = 0, K = 1
With J=0 and K=1, this is the RESET command. Q+ = 0*(0') + 1'*(0) = 0. Output is forced to Q = 0.
Clock Edge 5: Inputs J = 1, K = 1
With J=1 and K=1, the flip-flop TOGGLES again. Since present state Q = 0, next state Q+ = 0' = 1. Output switches to Q = 1.

Example 2: Synchronous / Truncated Mod-10 BCD Decade Counter (Medium)

Step-by-Step Worked Problem

Design a Mod-10 (decade/BCD) counter that counts cyclically from 0000 (0) to 1001 (9) and resets on the tenth count. (a) Determine the minimum number of flip-flops required. (b) Formulate the reset logic condition. (c) If driven by a 10 kHz input clock, determine the output frequency of the most significant bit (Q3) and its duty cycle.

Step 1: Calculate Minimum Flip-Flop Count (n)
An n-bit binary counter has 2^n unique states. For Mod-N = 10 states: 2^n >= 10. For n = 3, 2^3 = 8 < 10 (insufficient). For n = 4, 2^4 = 16 >= 10. Therefore, n = ceil(log2 10) = 4 flip-flops (Q3, Q2, Q1, Q0) are strictly required.
Step 2: Formulate Truncation / Reset Logic
The valid counting sequence is 0000_2 (0) through 1001_2 (9). The moment the counter reaches state 10 (binary 1010_2, where Q3 = 1, Q2 = 0, Q1 = 1, Q0 = 0), an asynchronous active-low CLEAR signal must be asserted to immediately reset all flip-flops back to 0000_2. The minimal decoding condition is: Reset = Q3 AND Q1. A 2-input NAND gate detecting Q3 and Q1 directly drives the active-low CLR pins.
Step 3: Output Frequency and Waveform Duty Cycle
Because the counter completes one full recycle every 10 input clock pulses, the fundamental output frequency at terminal Q3 is: f_out = f_clk / 10 = 10 kHz / 10 = 1.0 kHz. Examining states where Q3 = 1: Q3 is HIGH only during count 8 (1000_2) and count 9 (1001_2)—a duration of exactly 2 clock periods out of every 10. Thus, Duty Cycle = (2 / 10) * 100% = 20%.

Example 3: High-Speed Setup/Hold Timing Analysis (fmaxf_{\text{max}}) (Exam Level)

Step-by-Step Worked Problem

A synchronous digital register-to-register path has clock-to-Q delay t_cq = 2 ns and setup time t_su = 1 ns. (a) If the longest combinational logic path between registers is t_logic(max) = 7 ns, calculate the minimum clock period T_clk and maximum clock frequency f_max. (b) If pipelining reduces the maximum combinational logic path to 4 ns, what is the new f_max? (c) Compare this with an asynchronous 4-bit ripple counter where each flip-flop has a propagation delay of 10 ns.

Part (a): Baseline Maximum Clock Frequency
The setup timing constraint requires that data launches from register 1, propagates through logic, and stabilizes before register 2's setup window: T_clk >= t_cq + t_logic(max) + t_su. T_clk >= 2 ns + 7 ns + 1 ns = 10 ns. The maximum operational clock frequency is: f_max = 1 / T_clk = 1 / (10 * 10^-9 s) = 100 MHz.
Part (b): Pipelined Critical Path Optimization
When the critical logic path delay is shortened to t_logic(max) = 4 ns: T_clk >= 2 ns + 4 ns + 1 ns = 7 ns. The optimized clock frequency is: f_max = 1 / (7 * 10^-9 s) ≈ 142.86 MHz (a 42.9% frequency improvement).
Part (c): Timing Bottleneck of an Asynchronous Ripple Counter
In an n = 4 bit ripple counter, clock pulses do not arrive simultaneously; each flip-flop is clocked by the preceding stage's output. Total settling time is the cumulative ripple delay: t_settle = n * t_pd = 4 * 10 ns = 40 ns. To prevent reading erroneous intermediate transient counts, the clock period must satisfy T_clk >= t_settle = 40 ns, giving f_max = 1 / 40 ns = 25 MHz—4x slower than the synchronous architecture.

6. Common Exam Traps & Where Marks Are Lost

Common Exam Traps & Where Marks Are Lost

Avoid these classic calculation errors frequently spotted on semester examination answer scripts:

  • Using a Level-Sensitive Latch Instead of an Edge-Triggered Flip-Flop: A latch remains transparent whenever its clock/enable is HIGH. Any input noise or glitches pass straight through to the outputs, causing erratic feedback oscillations in feedback circuits.
  • Forgetting the Race-Around Condition in JK Latches: When a level-triggered JK latch has J = K = 1 and clock width t_w exceeds gate propagation delay t_pd, the output toggles uncontrollably back and forth multiple times during a single clock pulse. Edge triggering or master-slave topology is mandatory.
  • Counting Mod-N Counters up to N: A Mod-N counter counts through exactly N unique states, which means it counts from 0 to N - 1! A Mod-10 counter counts 0 to 9, and must reset upon entering state 10 (1010_2). Never allow state 10 to display as a stable count.
  • Treating Ripple Counter Outputs as Simultaneous: In ripple counters, stage transitions propagate sequentially. During transitions like 0111 -> 1000, outputs momentarily produce false intermediate glitch states (e.g., 0110, 0100, 0000). Combinational decoders attached to these pins will fire false glitch pulses.
  • Believing That Slower Clocks Fix Hold Violations: Setup time violations can always be eliminated by reducing clock frequency (lengthening T_clk). Hold time violations depend strictly on min path delay: t_cq(min) + t_logic(min) >= t_hold. If a hold violation occurs, data arrives too quickly regardless of clock period; slowing the clock does NOT fix it!
  • Asserting S = R = 1 on an SR Latch: In an active-high NOR SR latch, setting S = R = 1 forces both Q and Q' to 0 simultaneously, violating Boolean complementarity. When S and R drop back to 0 simultaneously, internal gate propagation delay differences determine the final state in a non-deterministic race.

7. Interactive Logic Simulation & 'Try Breaking It'

Analyze multi-stage sequential waveforms, clock timing, and propagation delays in the digital logic analyzer below:

[Simulator "logic-analyzer" not found in registry]
Try Breaking It: Predict Before You Test

Clock a 4-bit ripple counter and predict what the outputs show during the step from 0111 to 1000.


8. Parametrised Practice Problem

Practice calculating digital pipeline clock ceilings and setup/hold tolerances with randomized timing constraints:

Parametrised Practice Problem

Thévenin Equivalent of a Loaded Voltage Divider

A 24 V DC voltage source powers a divider with R1 = 60 Ω and R2 = 80 Ω. Calculate the open-circuit Thévenin voltage V_th (in Volts) appearing across terminals of R2.

V
Progressive Hints:

9. Unit Mastery Quiz

5-Question Mastery Check

Unit Quiz: Flip-Flops, Registers and Counters

Q1.What is the characteristic equation of an edge-triggered D flip-flop?

Q2.When both inputs of a JK flip-flop are held HIGH (J = 1, K = 1), what occurs on each active clock edge?

Q3.What is the minimum number of flip-flops required to construct a Mod-12 counter?

Q4.A 3-bit binary asynchronous counter is clocked by an 8 kHz square wave. What is the frequency of the waveform measured at the Most Significant Bit (MSB)?

Q5.Which timing violation CANNOT be resolved by decreasing the operational clock frequency?

0 of 5 answered