notesonly.in

One notebook for every subject — open it anywhere.

Log in

Counters and Shift Registers: Complete Beginner's Guide

A counter counts clock pulses in binary; a shift register moves bits sideways each clock. Both are flip-flops plus a clock, wired differently: counters feed outputs back to toggle inputs, shift registers feed each output into the next input. Together they do counting, timing, serial data and pattern generation.

Digital clocks divide crystals to seconds, UARTs shift serial bits in and out, LED chasers are shift registers with lights. If sequential logic is memory with a clock, counters and shift registers are what that memory does for a living.

Key Concepts

  • Ripple counter: Each output clocks the next. Simple, but delay ripples down, causing glitches and limiting speed. 4 bits count 0000-1111 (0-15).
  • Synchronous counter: One shared clock with steering logic; no ripple, much faster.
  • MOD-n: Cycles through n states. MOD-16 is a plain 4-bit counter; MOD-10 decade (7490) counts 0-9 for clocks.
  • Up/down: Direction input selects 0,1,2… or 15,14,13…
  • Shift modes: SISO (delay line), SIPO (UART receiver), PISO (UART transmitter), PIPO (register).
  • Ring counter: A single 1 circulates through n flip-flops: n one-hot states.
  • Johnson counter: Inverted last output feeds back: 2n states from n flip-flops, decoded with 2-input gates.
  • Clear/preset: Force zero or a value instantly; used for MOD-n truncation (MOD-10 resets at 1010).

How It Works

  1. 3-bit ripple: Three JK flip-flops with J=K=1; Q0 clocked by system clock, Q1 by Q0, Q2 by Q1.
  2. Sequence: 000, 001, 010, 011, 100, 101, 110, 111, back to 000: eight states, MOD-8.
  3. The ripple: On 011→100, Q0 flips first, then Q1, then Q2: brief intermediate codes appear. Synchronous counters avoid this.
  4. Shift right: Each clock copies every bit one position right, loading serial input into the leftmost bit.
  5. Serial to parallel: Clock 8 bits into SIPO and all 8 appear at once: how a UART receives a byte.

Worked Example

4-bit ripple up-counter from 0000, 11 pulses. Each pulse adds one: count = 11 = 8+2+1 = 1011. Five more pulses (16 total) wrap past 1111 to 0000: modulo-16 behavior. Now load 1011 into a shift-right register, 2 clocks, serial input 0. Clock 1: 0101. Clock 2: 0010. The pattern shifted exactly as a SISO delay line should.

Common Misconceptions

  • "All bits change together." Only synchronous counters. Ripple stages flip in sequence with real transient glitches.
  • "MOD-16 counts to 16." It has 16 states, 0-15, then wraps; displaying 16 needs a fifth bit.
  • "Shift registers multiply." Left-shifting a value does double it arithmetically, but the device's real jobs are serializing, delaying and pattern generation.

Real-World Applications

  • Timekeeping: Crystal dividers to 1 Hz; decade counters build clock displays.
  • Serial comms: UART, SPI and I2S shift bits with SIPO/PISO registers.
  • Frequency synthesis: PLL dividers count references against VCOs.
  • Expansion: Microcontrollers drive dozens of outputs via chains like the 74HC595.

Counters count pulses, shift registers move bits, both from clocked flip-flops. Ripple is simple but glitchy; synchronous costs gates for clean speed; MOD-n sets cycle length with decade counters at the heart of clocks. SISO/SIPO/PISO/PIPO serialize the world's data; ring and Johnson generate sequences. The example nails it: 11 pulses give 1011, 16 wrap to 0000, two shifts turn 1011 into 0010.