Skip to content
GATEiit

GATE EC · Digital Circuits

Shift-registers

Shift registers built from D flip-flops: serial and parallel modes (SISO, SIPO, PISO, PIPO), bidirectional and universal registers, shifting as multiply or divide, ring and Johnson counters, and linear feedback shift registers.

Before you start

  • D flip-flops →

    Each stage of a shift register is an edge-triggered D flip-flop that copies its input at the clock edge.

  • Multiplexers →

    A universal shift register uses a 4:1 multiplexer at each stage to choose hold, shift left, shift right or load.

  • Binary and 2's complement numbers →

    Left and right shifts multiply and divide by 2; arithmetic shifts keep the sign.

Concept notes

1. Shift register basics and the four modes

A shift register is a chain of D flip-flops sharing one clock, with the output of each stage feeding the D input of the next. At every active clock edge each flip-flop takes the value its neighbour held just before the edge, so the stored word moves one place. Because all flip-flops sample together, a D input never sees the new value of its neighbour in the same edge (edge-triggered flip-flops are essential; level-sensitive latches would let data race through).

An n-bit register uses n flip-flops and stores n bits.

Mode Data in Data out Typical use
SISO (serial in, serial out) one bit per clock one bit per clock delay line
SIPO (serial in, parallel out) one bit per clock all n bits at once serial-to-parallel conversion (receiver)
PISO (parallel in, serial out) all n bits in one load one bit per clock parallel-to-serial conversion (transmitter)
PIPO (parallel in, parallel out) all bits at once all bits at once storage register

Timing facts:

  • Loading n bits serially takes n clock pulses. After loading, the first bit entered is in the last stage.
  • In a SISO register a bit entered at the input reaches the serial output after n clock pulses, so the register delays a bit stream by n clock periods: td=n/fclk.
  • Sending an n-bit word over one wire at a clock rate f takes n/f seconds.
DQFF0Q0 DQFF1Q1 DQFF2Q2 DQFF3Q3 Serial inSerial outCLKParallel outputs
4-bit shift register: serial data enters FF0 and moves one stage right at each clock edge. Taking Q0 to Q3 together gives SIPO; taking only Q3 gives SISO.

2. Bidirectional and universal shift registers

A bidirectional register can shift left or right. A universal shift register (such as the 4-bit 74194 type) can also hold its data and load in parallel. Each stage has a 4:1 multiplexer in front of its D input, selected by two mode lines:

S1S0 Operation D input of stage i
00 hold its own output Qi
01 shift right Qi−1 (stage 0 takes the serial-right input)
10 shift left Qi+1 (the last stage takes the serial-left input)
11 parallel load external input Ii

Which direction counts as "right" depends on how the stages are drawn; always follow the question's definition, then trace one clock at a time.

Shifting as arithmetic. Writing the word with the MSB on the left:

  • A logical left shift by one (0 entering at the LSB) multiplies an unsigned number by 2, as long as no 1 is shifted out of the MSB. Shifting k places multiplies by 2k.
  • A logical right shift (0 entering at the MSB) divides an unsigned number by 2, dropping the remainder.
  • An arithmetic right shift copies the sign bit into the MSB, so it divides a 2's complement number by 2, rounding towards −∞. Example: 11101000 (−24) shifted right twice gives 11111010 (−6).
  • Rotate (circular shift) feeds the bit that leaves one end back into the other end; no bit is lost.

Example: 00010110 (22) shifted left twice is 01011000 (88) =22×4.

3. Ring and Johnson counters

Feeding the output of a shift register back to its input turns it into a counter whose states are decoded easily.

Ring counter. D0=Qn−1 (the last output goes straight back). It is preset to a single 1, for example 1000, which then circulates: 1000→0100→0010→0001→1000.

  • n flip-flops give only n states (mod-n), out of 2n possible.
  • Each state has exactly one 1, so no decoding gates are needed.
  • Each output is a pulse of width one clock period, repeating at fclk/n.
  • It is not self-starting: if it powers up in 0000 it stays there, and other wrong patterns also circulate forever, so it needs a preset or correcting logic.

Johnson (twisted-ring, switch-tail) counter. D0=Qn−1‾. From 0000 (written Q0Q1Q2Q3) a 4-bit Johnson counter goes 0000→1000→1100→1110→1111→0111→0011→0001→0000

  • n flip-flops give 2n states (mod-2n); 2n−2n states are unused.
  • Each state is decoded by one 2-input AND gate (on two adjacent outputs).
  • Each output is a square wave with 50% duty cycle at fclk/(2n).
  • The basic circuit is not self-starting: the unused states form a separate cycle (for 4 bits, a second cycle of 8 states such as 0100→1010→1101→…).
Counter Flip-flops States Decoding Output frequency
Ring n n none fclk/n
Johnson n 2n 2-input AND fclk/(2n)
Binary n 2n n-input AND MSB at fclk/2n

4. Linear feedback shift registers and state tracing

A linear feedback shift register (LFSR) feeds the XOR of some outputs (the taps) back to the input. It generates a repeating bit pattern and is used for pseudo-random sequences, scramblers and CRC computation.

  • The all-zero state maps to itself (XOR of zeros is 0), so an XOR-feedback LFSR must not start at all zeros.
  • With n flip-flops the longest possible cycle is 2n−1 states (every non-zero state once). Taps that achieve this give a maximal-length sequence; other taps give shorter cycles.
  • In a maximal-length sequence each output contains 2n−1 ones and 2n−1−1 zeros per period.

How to trace any feedback shift register (the common GATE question):

  1. Write the next-state equations. For shifting right: Q1+=Q0, Q2+=Q1, and so on, plus the feedback equation for Q0+.
  2. Evaluate the feedback using the present state only.
  3. Tabulate state after state until a state repeats; the number of distinct states is the cycle length.

Example: 3 stages with D0=Q1⊕Q2, starting at Q0Q1Q2=100:

Clock Q0Q1Q2
0 100
1 010
2 101
3 110
4 111
5 011
6 001
7 100

All seven non-zero states appear, so this is maximal length (23−1=7). The output Q2 reads 0,0,1,0,1,1,1 and repeats.

DQFF0DQFF1DQFF2Q0 Q1 Q2 XORCLKD0  = Q1  ⊕ Q2 
3-bit linear feedback shift register: the XOR of Q1 and Q2 is fed back to D0, giving a repeating sequence of 7 states.

Formulas to remember

Serial loading or delayn clock periods for n bits
t=nfclk
Ring counter
states=n,fout=fclkn
Johnson counter
states=2n,fout=fclk2n,unused=2n−2n
Maximal-length LFSR period
N=2n−1
Shift as arithmetic
left shift by k:×2k,right shift by k:÷2k

Common mistakes

  • Using the new value of a neighbouring flip-flop in the same clock edge; every stage takes the value its neighbour held just before the edge.
  • Forgetting that after serial loading the first bit entered sits in the last stage, so the stored word appears reversed if read from the first stage.
  • Confusing ring and Johnson counters: a ring counter feeds back Q, has n states and needs no decoding; a Johnson counter feeds back Q-bar, has 2n states and needs 2-input AND gates.
  • Starting an XOR-feedback LFSR at all zeros; it never leaves that state.
  • Using a logical right shift to halve a negative 2's complement number; an arithmetic shift must copy the sign bit.
  • Assuming shift left always means towards Q0; follow the direction defined in the question.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Loading a 4-bit SIPO register

numerical

A 4-bit register shifts right (Q0→Q1→Q2→Q3) with serial input into Q0. It starts at 0000, and the serial input bits are 1, 0, 1, 1 (first bit first), one per clock. Find Q0Q1Q2Q3 after each clock.

  1. Step 1: Apply the first clock.

    Try it on paper first.

Example 2: Johnson counter as a frequency divider

numerical

A 4-bit Johnson counter (D0=Q3‾) starts at 0000 and runs from a 1 MHz clock. List its states, and find the frequency and duty cycle of Q3.

  1. Step 1: Trace the states (written Q0 Q1 Q2 Q3).

    Try it on paper first.

Example 3: Tracing a 4-bit LFSR

numerical

A 4-bit register shifts Q0→Q1→Q2→Q3 with D0=Q2⊕Q3. Starting at Q0Q1Q2Q3=1000, find the state after 5 clocks and the length of the cycle.

  1. Step 1: Write the next-state rule.

    Try it on paper first.

Example 4: Shifts as multiplication and division

conceptual

An 8-bit register holds 00010110. (a) Find the value after two logical left shifts. (b) The register instead holds the 2's complement number 11101000; find the value after two arithmetic right shifts.

  1. Step 1: Do the left shifts and read the value.

    Try it on paper first.

Previous year questions

1 official GATE EC question on this topic, newest first.

Topic test

9 questions: up to 1 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-29. Spotted a mistake? Use Report an issue on any question, or contact us.