Skip to main content

6.4 Registers, Shift Registers & Synchronous Counters

πŸ“šModule 06: Sequential Logic Circuits: Latches & Flip-FlopsTopic 6.4⏱️21 min read
🎯High-Yield For:University Semester Exams β€’ Hardware Engineering Rounds β€’ Foundational Computing

πŸ’‘ Core Intuition: The Conveyor Belt vs. The Clockwork Odometer​

In Topics 6.1 through 6.3, we engineered individual single-bit memory cells: the Latch and the Flip-Flop. However, real microprocessors do not process single isolated bitsβ€”they operate on words (88-bit bytes, 3232-bit integers, 6464-bit memory addresses, 512512-bit SIMD vectors).

🍳 The Everyday Analogy: The Conveyor Belt Assembly vs. The Automobile Odometer​

  • The Shift Register (The Bucket Brigade): Imagine five firefighters lined up to put out a fire. The first scoops water from a reservoir, hands the bucket to the second, who hands it to the third, until the fifth pours it onto the flames. On each command whistle (clock edge), every bucket shifts right by one position. Serial data enters at one end and exits at the other.
  • The Synchronous Counter (The Mechanical Odometer): In an automobile dashboard, rolling wheels track mileage. When transitioning from 009 to 010, the units wheel flips from 9 to 0 while simultaneously kicking the tens wheel from 0 to 1 on the exact same mechanical shaft rotation. All wheels transition in lockstep.

πŸ’» Bridging to Computer Science​

In computer systems engineering and VLSI hardware:

  1. Serialization / Deserialization (SerDes): High-speed computer buses (PCIe 5.0, USB4, SATA, Gigabit Ethernet) cannot route 64 parallel copper traces across motherboards without timing skew. Instead, a PISO register converts internal 64-bit CPU words into an ultra-fast serial stream, which a SIPO register at the receiver reconstructs.
  2. CPU Program Counter (PC): The Program Counter register in an instruction execution pipeline is a synchronous up-counter. On each fetched instruction, it increments by 4 (in 32-bit RISC architectures) or loads a jump target address.
  3. Circular Ring Buffers: High-speed memory controllers and hardware DMA engines use ring and Johnson counter topologies to generate multiphase non-overlapping clock pulses for dynamic RAM refreshing.


πŸ’Ύ Data Storage Registers & Parallel Load Architecture​

An nn-bit Register is a bank of nn edge-triggered D Flip-Flops sharing a common clock line. It can store an nn-bit binary word simultaneously.

The Problem with Clock Gating:​

Beginners often attempt to control whether a register updates by placing an AND gate on the clock line (CLKgated=CLKβ‹…LoadCLK_{gated} = CLK \cdot \text{Load}). This is strictly prohibited in ASIC design:

  • Clock Skew: The AND gate introduces an asymmetric propagation delay (Ξ”t\Delta t), meaning the gated register sees the clock edge later than the rest of the chip.
  • Glitch Hazards: If the Load enable line glitches while the clock is high, the register sees a spurious clock edge and corrupts its data.

The Production Solution: Multiplexer-Controlled Feedback​

Instead of gating the clock, we keep the clock ticking continuously to all flip-flops and place a 2:1 Multiplexer on the DD input of each stage:

Architecture Flow

MUX-Steered Register Parallel Load Architecture

Replacing hazardous clock gating with continuous clocking and 2:1 MUX recirculating feedback

Control

Control: Load Signal

Select Line (Sel)

Steers whether stage latches external input (Load = 1) or retains stored data (Load = 0).

β†’
Selects MUX input
Steering

2:1 Multiplexer

D = Load Β· Din + Load' Β· Q

Directs Din to D when Load = 1. Recirculates Q feedback into D when Load = 0 without disturbing clock distribution.

β†’
Feeds D terminal
Storage

Edge-Triggered D-FF

Continuous CLK Grid

Clock lines tick uniformly across entire chip with zero clock skew. Data updates deterministically on active edge.

β†’
Drives output Q
Output & Hold

Feedback Loop & Output Q

Q holds state

Output Q drives external datapath while simultaneously feeding back into MUX input 0 for glitch-free hold state.

  • When Load=0\text{Load} = 0: The MUX selects the feedback line (D=QD = Q). On every clock edge, the flip-flop simply reloads its own current value (rock-solid hold).
  • When Load=1\text{Load} = 1: The MUX selects the external input pin (D=DinD = D_{in}). On the clock edge, the new word is latched.

πŸ”„ The Four Shift Register Topologies (SISO, SIPO, PISO, PIPO)​

A Shift Register cascades flip-flops such that the output of stage ii connects directly to the data input of stage iβˆ’1i-1. On every active clock pulse, the stored binary pattern shifts by one bit position.

4-Bit Serial-In Shift Register (SISO / SIPO)Click Clock to Shift Bits Right
Din=1CLKFF 3DQ=0FF 2DQ=0FF 1DQ=0FF 0DQ=0Dout=0
Stored Nibble:0000β‚‚ (0₁₀)
Q₃(MSB):0
Qβ‚‚:0
Q₁:0
Qβ‚€(LSB / Dout):0

Depending on how data enters and leaves the register, there are four fundamental operational topologies:

TopologyData Input MethodData Output MethodClock Cycles to LoadClock Cycles to RetrievePrimary Hardware Application
SISO (Serial-In Serial-Out)1 bit per clock edge1 bit per clock edgeNNNβˆ’1N - 1Digital delay lines, temporary serial buffering.
SIPO (Serial-In Parallel-Out)1 bit per clock edgeAll NN bits simultaneouslyNN11UART Receiver, SPI, I2C, Serial-to-Parallel decoders.
PISO (Parallel-In Serial-Out)All NN bits simultaneously1 bit per clock edge11Nβˆ’1N - 1UART Transmitter, High-speed serial links (PCIe, SATA).
PIPO (Parallel-In Parallel-Out)All NN bits simultaneouslyAll NN bits simultaneously1111CPU Pipeline Registers, ALU Input/Output Latches.

πŸŽ›οΈ The 74194 Universal Bidirectional Shift Register​

A Universal Shift Register integrates all possible register behaviors into a single IC. Each flip-flop is preceded by a 4:1 Multiplexer governed by two mode select lines (S1,S0S_1, S_0):

S1S_1S0S_0Operating ModeInput Selected by 4:1 MUXCircuit Action
00Hold / No ChangeI0=QiI_0 = Q_iRe-circulates own output; state holds indefinitely.
01Shift RightI1=Qi+1I_1 = Q_{i+1} (or Serial In Right)Bits shift towards LSB (Q3β†’Q2β†’Q1β†’Q0Q_3 \to Q_2 \to Q_1 \to Q_0).
10Shift LeftI2=Qiβˆ’1I_2 = Q_{i-1} (or Serial In Left)Bits shift towards MSB (Q0β†’Q1β†’Q2β†’Q3Q_0 \to Q_1 \to Q_2 \to Q_3).
11Parallel LoadI3=DiI_3 = D_iLoads all external bus lines simultaneously in 1 cycle.

πŸ’ Circulating Shift Counters: Ring vs. Johnson​

By looping the serial output of a shift register back into its serial input, we create circulating state counters:

1. The Ring Counter (One-Hot Circulating Counter)​

In a 4-bit Ring Counter, the serial output Q0Q_0 is tied directly back to D3D_3: D3=Q0D_3 = Q_0

Starting from an initial seed of 100021000_2, the single logic 1 circulates continuously: 1000⟢0100⟢0010⟢0001⟢10001000 \longrightarrow 0100 \longrightarrow 0010 \longrightarrow 0001 \longrightarrow 1000

  • Total Valid States: NN states for an NN-bit register (44 states for 44 bits).
  • Decoding Hardware: Zero logic gates required! Each flip-flop output directly indicates the active state (One-Hot encoding).
  • Silicon Efficiency: Very low (44 states out of 24=162^4 = 16 possible states; 1212 states are wasted).

2. The Johnson (Twisted Ring / Moebius) Counter​

In a Johnson counter, the inverted output Qˉ0\bar{Q}_0 is fed back to D3D_3: D3=Qˉ0D_3 = \bar{Q}_0

Starting from an all-zero state 000020000_2: 0000β†’1000β†’1100β†’1110β†’1111β†’0111β†’0011β†’0001β†’00000000 \to 1000 \to 1100 \to 1110 \to 1111 \to 0111 \to 0011 \to 0001 \to 0000

  • Total Valid States: 2N2N states (88 states for a 44-bit register; exactly double the Ring counter!).
  • Decoding Hardware: Minimalβ€”any state can be decoded using a single 2-input AND gate.
  • Self-Starting Requirement: If noise drops the counter into an unused state (e.g., 10101010), it may circulate indefinitely in an illegal loop. Production designs add corrective feedback logic: D3=QΛ‰0β‹…QΛ‰1D_3 = \bar{Q}_0 \cdot \bar{Q}_1.

⏱️ Asynchronous (Ripple) vs. Synchronous Counters​

Binary counters fall into two fundamentally different timing categories:

Engineering ParameterAsynchronous (Ripple) CounterSynchronous Counter
Clock DistributionOnly stage 0 receives the master clock. Stage i+1i+1 is clocked by output QiQ_i of stage ii.All flip-flops share the exact same master clock simultaneously.
Propagation DelayCumulative: ttotal=NΓ—tpd(FF)t_{total} = N \times t_{pd(FF)}. Each stage must wait for the previous stage to finish settling.Constant: ttotal=tpd(FF)t_{total} = t_{pd(FF)} (plus gate steering delay). All bits update concurrently!
Maximum Frequency (fmaxf_{max})Low: fmax=1Nβ‹…tpdf_{max} = \frac{1}{N \cdot t_{pd}}. Speed degrades linearly with bit-width.High: fmax=1tpd+tcombf_{max} = \frac{1}{t_{pd} + t_{comb}}. Speed is independent of bit-width!
Decoding Glitches (Spikes)Severe: Transient intermediate states (e.g., 011β†’010β†’000β†’100011 \to 010 \to 000 \to 100) generate false spikes on combinational decoders.Zero: State transitions are strictly atomic and glitch-free.
Hardware ComplexityExtremely simple (no external steering logic required).Requires external AND gates to determine toggle conditions.

βš™οΈ Systematic Synchronous Counter Design Procedure​

3-Bit Synchronous Binary Up Counter (Modulo-8)Simultaneous Clocking: 0 Ripple Delay
CLKFFβ‚€ (Tβ‚€=1)Q0 = 0FF₁ (T₁=Qβ‚€)Q1 = 0FFβ‚‚ (Tβ‚‚=Q₁Qβ‚€)Q2 = 0
Decimal State:0₁₀
Binary State Vector:000β‚‚ (Qβ‚‚Q₁Qβ‚€)
Next State (on ↑CLK):1₁₀

The 5-Step Universal Design Algorithm:​

  1. State Diagram & Count Sequence: Define states (0β†’1β‹―β†’Mβˆ’1β†’00 \to 1 \dots \to M-1 \to 0).
  2. Determine Flip-Flop Count: 2Nβ‰₯M2^N \ge M.
  3. Construct State Transition & Excitation Table: Map Qn→Qn+1Q_n \to Q_{n+1} and look up required inputs for each flip-flop.
  4. K-Map Simplification: Solve for flip-flop inputs in terms of current state variables.
  5. Logic Realization: Connect gates to flip-flop clock and data pins.

Worked Example: Design a 3-Bit Synchronous Up Counter using T Flip-Flops​

We need N=3N = 3 flip-flops (Q2,Q1,Q0Q_2, Q_1, Q_0) counting from 0002β†’1112000_2 \to 111_2.

Excitation Table for T Flip-Flop:​

Recall that T=QnβŠ•Qn+1T = Q_n \oplus Q_{n+1} (if state changes, T=1T=1; if state holds, T=0T=0).

Present State (Q2Q1Q0Q_2 Q_1 Q_0)Next State (Q2+Q1+Q0+Q_2^+ Q_1^+ Q_0^+)Required T2T_2Required T1T_1Required T0T_0
000001000011
001010001111
010011000011
011100111111
100101000011
101110001111
110111000011
111000111111

K-Map Derivation of Inputs:​

  1. For T0T_0: Notice that T0=1T_0 = 1 in EVERY row! T0=1\mathbf{T_0 = 1} (FF0 toggles on every single clock edge).
  2. For T1T_1: T1=1T_1 = 1 whenever Q0=1Q_0 = 1 (rows 001, 011, 101, 111): T1=Q0\mathbf{T_1 = Q_0} (FF1 toggles whenever FF0 is currently high).
  3. For T2T_2: T2=1T_2 = 1 only when both Q1=1Q_1 = 1 and Q0=1Q_0 = 1 (rows 011 and 111): T2=Q1Q0\mathbf{T_2 = Q_1 Q_0} (FF2 toggles only when both lower bits are high, preparing for rollover).
πŸ“Synchronous Binary Counter Governing Steering Equationsformula
T0=1,T1=Q0,T2=Q1Q0,…Tk=∏i=0kβˆ’1QiT_0 = 1, \quad T_1 = Q_0, \quad T_2 = Q_1 Q_0, \quad \dots \quad T_k = \prod_{i=0}^{k-1} Q_i

Each successive stage toggles if and only if all previous lower-order stages are currently at logic 1!


🏭 Real-World Production Context: SerDes Transceivers & Program Counter Microarchitecture​

In enterprise compute hardware and high-speed networking:

  • Serializer/Deserializer (SerDes): When sending data across high-speed optical links or PCIe interconnects at 32 GT/s, parallel transmission is physically impossible due to trace length mismatches and cross-talk. Shift registers serialize parallel words into a single differential pair with embedded clocking.
  • Instruction Sequencing: Synchronous counters drive micro-operation sequencers within processor control units, stepping through microcode ROM cycles deterministically without intermediate decoding hazards.
  • FIFO Memory Pointers: High-throughput circular ring buffers in network interface cards (NICs) use Gray-code synchronous counters to prevent multi-bit transition glitches when passing head and tail pointers across asynchronous clock domains.

πŸ“ Numerical Applications & Worked Examples​

Example 1: Latency & Clock Cycle Analysis Across Shift Register Topologies​

Problem Statement:
An nn-bit binary data word (n=8n = 8 bits) is to be transferred from a transmitter to a receiver across a synchronous digital interface. The interface can be implemented using one of four shift register configurations:

  1. Serial-In, Serial-Out (SISO)
  2. Serial-In, Parallel-Out (SIPO)
  3. Parallel-In, Serial-Out (PISO)
  4. Parallel-In, Parallel-Out (PIPO)

For each topology:

  • Determine the number of clock pulses required to write (load) the nn-bit word into the register.
  • Determine the number of clock pulses required to read (retrieve) the nn-bit word from the register.
  • Calculate total latency for n=8n = 8 bits.

Step-by-Step Solution:

  1. SISO Configuration:
    • Write: Loading nn serial bits requires nn clock pulses (88 pulses).
    • Read: Unloading the stored bits serially requires (nβˆ’1)(n - 1) additional clock pulses (77 pulses), because the first bit is already available at the output after the nn-th write pulse.
    • Total Latency: n+(nβˆ’1)=2nβˆ’1=15Β clockΒ cyclesn + (n - 1) = 2n - 1 = \mathbf{15\text{ clock cycles}}.
  2. SIPO Configuration:
    • Write: Loading nn bits serially requires nn clock pulses (88 pulses).
    • Read: All nn parallel outputs are available immediately (0 additional clock pulses).
    • Total Latency: n=8Β clockΒ cyclesn = \mathbf{8\text{ clock cycles}}.
  3. PISO Configuration:
    • Write: Loading all nn bits in parallel requires 11 clock pulse (with Load=1\text{Load} = 1).
    • Read: Shifting out the remaining (nβˆ’1)(n - 1) bits serially requires (nβˆ’1)(n - 1) pulses (77 pulses).
    • Total Latency: 1+(nβˆ’1)=n=8Β clockΒ cycles1 + (n - 1) = n = \mathbf{8\text{ clock cycles}}.
  4. PIPO Configuration:
    • Write: Loading all bits in parallel requires 11 clock pulse.
    • Read: All outputs are available immediately (00 pulses).
    • Total Latency: 1Β clockΒ cycle\mathbf{1\text{ clock cycle}} (Fastest, but requires nn input and nn output routing wires).

Example 2: State Capacity & Decoding Complexity: 4-Bit Ring vs Johnson Counters​

Problem Statement:
Compare a 4-bit Ring Counter and a 4-bit Johnson (Twisted-Ring) Counter constructed using identical edge-triggered D flip-flops (n=4n = 4):

  1. Determine the Modulo (number of valid states in the counting sequence).
  2. Calculate the number of unused (lockout candidate) states.
  3. Determine the minimum gate logic required to decode any individual state.

Step-by-Step Solution:

  1. Ring Counter Analysis (n=4n = 4):
    • Valid State Sequence: Circulates a single '1' through nn positions:
      10002β†’01002β†’00102β†’00012β†’100021000_2 \to 0100_2 \to 0010_2 \to 0001_2 \to 1000_2
    • Modulo: Mod=n=4Β states\text{Mod} = n = \mathbf{4\text{ states}}.
    • Unused States: Total possible 2nβˆ’n=24βˆ’4=16βˆ’4=12Β unusedΒ states2^n - n = 2^4 - 4 = 16 - 4 = \mathbf{12\text{ unused states}}.
    • Decoding Logic: Because exactly one bit is active high at any time, each state is decoded with zero combinational gates! Simply tap output pin QiQ_i directly.
  2. Johnson Counter Analysis (n=4n = 4):
    • Valid State Sequence: Feeds inverted output QΛ‰3\bar{Q}_3 back to D0D_0:
      0000β†’1000β†’1100β†’1110β†’1111β†’0111β†’0011β†’0001β†’00000000 \to 1000 \to 1100 \to 1110 \to 1111 \to 0111 \to 0011 \to 0001 \to 0000
    • Modulo: Mod=2n=2(4)=8Β states\text{Mod} = 2n = 2(4) = \mathbf{8\text{ states}} (Double the capacity of the ring counter!).
    • Unused States: 2nβˆ’2n=16βˆ’8=8Β unusedΒ states2^n - 2n = 16 - 8 = \mathbf{8\text{ unused states}}.
    • Decoding Logic: Adjacent states differ by a single bit transition. Any state is uniquely decoded using a single 2-input AND gate (e.g., State 11001100 is decoded by Q1QΛ‰2Q_1 \bar{Q}_2).

Example 3: Systematic Design of a Modulo-6 Synchronous Up-Counter using T Flip-Flops​

Problem Statement:
Design a synchronous counter that counts repeatedly through the sequence 0β†’1β†’2β†’3β†’4β†’5β†’00 \to 1 \to 2 \to 3 \to 4 \to 5 \to 0 using positive edge-triggered T flip-flops.

  1. Determine the required number of flip-flops.
  2. Formulate the state transition table with T flip-flop excitations.
  3. Derive minimized excitation equations for each stage using Karnaugh maps.

Step-by-Step Solution:

  1. Determine Flip-Flop Count:

    • Number of states N=6N = 6. Minimum flip-flops: 2nβ‰₯6β€…β€ŠβŸΉβ€…β€Šn=32^n \ge 6 \implies n = 3 flip-flops (Q2,Q1,Q0Q_2, Q_1, Q_0).
    • Unused states: 66 (1102110_2) and 77 (1112111_2).
  2. State Transition & T Excitation Table:
    Recall T excitation: T=0T = 0 if Qn=Qn+1Q_n = Q_{n+1} (Hold), T=1T = 1 if Qn≠Qn+1Q_n \neq Q_{n+1} (Toggle).

    Present State (Q2Q1Q0Q_2 Q_1 Q_0)Next State (Q2+Q1+Q0+Q_2^+ Q_1^+ Q_0^+)T2T_2T1T_1T0T_0
    000000 (0)001001 (1)001
    001001 (1)010010 (2)011
    010010 (2)011011 (3)001
    011011 (3)100100 (4)111
    100100 (4)101101 (5)001
    101101 (5)000000 (0)101
    110110 (6)UnusedΓ—\timesΓ—\timesΓ—\times
    111111 (7)UnusedΓ—\timesΓ—\timesΓ—\times
  3. K-Map Minimization (Treating states 6 and 7 as don't-cares Γ—\times):

    • For T0T_0: Every valid transition flips Q0β€…β€ŠβŸΉβ€…β€ŠT0=1Q_0 \implies \mathbf{T_0 = 1} (Tied high permanently).
    • For T1T_1: Min-terms are m1,m3m_1, m_3 with don't-cares at m6,m7m_6, m_7.
      In K-map (Q2Q_2 vs Q1Q0Q_1 Q_0): cells (1,3)(1, 3) combined with don't care:
      T1=Qˉ2Q0\mathbf{T_1 = \bar{Q}_2 Q_0}
    • For T2T_2: Min-terms are m3,m5m_3, m_5 with don't-cares at m6,m7m_6, m_7.
      Grouping m3m_3 with m7β€…β€ŠβŸΉβ€…β€ŠQ1Q0m_7 \implies Q_1 Q_0; grouping m5m_5 with m7β€…β€ŠβŸΉβ€…β€ŠQ2Q0m_7 \implies Q_2 Q_0:
      T2=Q1Q0+Q2Q0=(Q1+Q2)Q0\mathbf{T_2 = Q_1 Q_0 + Q_2 Q_0 = (Q_1 + Q_2) Q_0}
  4. Self-Starting Lockout Verification:

    • If counter starts in unused state 110110 (66): T0=1,T1=1Λ‰(0)=0,T2=(1+1)(0)=0β€…β€ŠβŸΉβ€…β€ŠNextΒ state=111T_0 = 1, T_1 = \bar{1}(0) = 0, T_2 = (1+1)(0) = 0 \implies \text{Next state} = 111 (77).
    • From state 111111 (77): T0=1,T1=0,T2=(1+1)(1)=1β€…β€ŠβŸΉβ€…β€ŠNextΒ state=010T_0 = 1, T_1 = 0, T_2 = (1+1)(1) = 1 \implies \text{Next state} = 010 (22).
    • State 2 is inside the valid loop! The counter is self-starting and completely immune to permanent lockouts.

🎯 Exam & Interview Pitfall Check​

Core Conceptual Questions
  • Why do Ripple Counters generate false decoding spikes, and how do Synchronous Counters eliminate them?
    In a 4-bit ripple counter transitioning from 01112β†’100020111_2 \to 1000_2, stage 0 flips first (01100110), which triggers stage 1 (01000100), which triggers stage 2 (00000000), which triggers stage 3 (10001000). For several nanoseconds, the outputs ripple through intermediate states (6,4,06, 4, 0) before settling at 88. If an AND gate decodes state 00000000, it will output a momentary glitch pulse! Synchronous counters clock all flip-flops concurrently, so all bits transition in lockstep, eliminating intermediate states.
  • How does a Johnson Counter decode any of its 2N2N states using only a 2-input AND gate?
    Because adjacent states in a Johnson counter differ by only a single bit (like Gray code). For instance, state 11001100 is uniquely identified by the boundary condition where Q2=1Q_2 = 1 and Q1=0Q_1 = 0, requiring only Q2Qˉ1Q_2 \bar{Q}_1.
Common Interview Traps
  • Trap: Forgetting that a PISO register requires a Shift/Load control signal.
    Unlike a pure serial register, a PISO register must be able to switch modes: load all parallel inputs simultaneously (S/Lˉ=0S/\bar{L} = 0), then isolate inputs and shift serially (S/Lˉ=1S/\bar{L} = 1).
  • Trap: Overlooking lockout states in non-power-of-two counters.
    When designing Modulo-5 or Modulo-6 counters using 3 flip-flops, 33 states (8βˆ’5=38 - 5 = 3) are unused. Always verify using the state equations that if the counter accidentally powers up in an unused state, it transitions back into the main loop within 1 or 2 clock cycles rather than getting permanently trapped in a lockout loop!

πŸ’¬

Discussion & Doubts