3.4.7 · D4Sequential Circuits

Exercises — Registers and shift registers

2,592 words12 min readBack to topic

Throughout, we write an -bit word as where is the least significant bit (LSB, the "ones" place) and is the most significant bit (MSB, the highest power-of-2 place). "Shift right" means every bit moves toward the LSB; "shift left" means toward the MSB.


Level 1 — Recognition

Can you name the part and read the wiring?

L1.1

Recall Solution

Each flip-flop's is external and independent, and no output loops into a neighbour's input. Data does not move sideways — it is loaded in parallel. So this is a plain register. It stores bits = 1 byte. The give-away rule: shift register ⟺ (neighbour feeds neighbour). Here that link is absent.

L1.2

Recall Solution
  • (a) SIPO (Serial-In Parallel-Out) — used by a UART/SPI receiver.
  • (b) PISO (Parallel-In Serial-Out) — the transmitter side.
  • (c) SISO (Serial-In Serial-Out) — bit enters, walks the chain, leaves later.
  • (d) PIPO (Parallel-In Parallel-Out) — just a register. Mnemonic: read In first, Out second.

Level 2 — Application

Turn the crank: trace patterns and count clocks.

L2.1

Recall Solution

Left shift: every bit moves toward the MSB, the top bit falls off, Serial-In () fills .

Clock What happened
start 1101 initial
1 1011 shift left, MSB 1 dropped, new 1 in
2 0111 shift left, MSB 1 dropped, new 1 in
3 1111 shift left, MSB 0 dropped, new 1 in

Answer: .

L2.2

Recall Solution

"Empty" here means every flip-flop was reset to before the first edge — otherwise the early Serial-Out bits would be unknown (), and we could not tabulate them. With a known all-zeros start: A bit must cross all stages, so it emerges after 5 edges. The output stream is the input stream delayed by 5 edges. Watching the far-end bit:

Edge Serial-Out
1 0 (register was all-zeros)
2 0
3 0
4 0
5 1 ← first input bit arrives
6 0 ← second input bit

The first appears on edge 5; a SISO of length is a pure -clock delay. (Had the register started at unknown values, edges 1–4 would read , not .)


Level 3 — Analysis

Explain the number behind the pattern.

L3.1

Recall Solution

.

Shift Bits Decimal Check
0 10110100 180
1 01011010 90
2 00101101 45
3 00010110 22

Notice shift 3: is odd, its LSB () is dropped, so not — that dropped bit is the truncation. This is exactly the "floor" in Binary multiplication and division.

The figure below traces these four rows: green cells are s, and the coral cell marks the LSB that is about to be discarded on the next shift — the visible source of the "floor".

Figure — Registers and shift registers

Read the figure top-to-bottom: each lavender arrow is one right shift; every time a coral (LSB ) cell falls off, that is the odd remainder being truncated.

L3.2

Recall Solution

Two's complement of 8 bits: the MSB carries weight . . Arithmetic right shift copies the sign bit (1) into the vacated MSB: And ✔ — value halved correctly. Logical right shift (fill 0): Completely wrong sign and magnitude. That's why signed division needs arithmetic shift.


Level 4 — Synthesis

Combine pieces into a working sub-system.

L4.1

Recall Solution

We must keep two names apart: is the input pin of flip-flop (what the mux drives), while is the external parallel-load data for stage . Each stage's is chosen by a 4-to-1 mux whose select lines are : Input-by-input:

  • : the stage feeds itself back → it remembers (same idea as the parent's load-enable).
  • : content of the higher stage flows down → shift right.
  • : content of the lower stage flows up → shift left.
  • : the external parallel data is captured → parallel load.

One mux per stage, all sharing and one clock, gives a fully universal register (hold / shift-R / shift-L / load). This is the classic 74194-style part.

L4.2

Recall Solution

Feedback closes the chain: instead of an external Serial-In. Left shift each edge (, ). From the single 1 wraps to the bottom and walks up:

Clock
0 1000
1 0001
2 0010
3 0100
4 1000 (repeats)

The single 1 circulates. Period = 4 (equals the number of stages). That's a ring counter: states from flip-flops, one-hot encoded.


Level 5 — Mastery

Design against a spec; reason about timing and edge cases.

L5.1

Recall Solution

(a) . Decimal: . (b) LSB-first means we send first, up to : bits of from LSB: . (c) The SIPO receives LSB-first and shifts each new bit into the MSB end, pushing older bits toward the LSB (so the first-received LSB ends up in ). After 8 clocks the receiver holds . ✔ Yes, it matches — a correctly-ordered serial channel is loss-free.

L5.2

Recall Solution

(a) Period . (b) Setup (the "not too late" check): the data launched at one edge must be stable at the next flip-flop before the next edge. Required: . Since , there is huge margin (setup slack ) → meets setup. (c) Hold (the "not too early" check): the new data must not arrive so fast that it overruns the current flip-flop's hold window right after the edge. The data can change no sooner than after the edge, so hold is met when : here , hold slack meets hold. (Hold is a per-edge, clock-frequency-independent check — slowing the clock never fixes a hold violation, which is why we check it separately; see Clocking and setup/hold time.) (d) A bit crosses stages = clock edges = . Length worsens latency, never per-edge timing, because each stage only talks to its immediate neighbour.


Active Recall

Recall One-line self-quiz

Q: After how many edges does a bit leave an -stage SISO? ::: edges (one hop per stage). Q: What single wiring change turns a shift register into a ring counter? ::: Feed back into (close the loop). Q: What fills the MSB in a signed (arithmetic) right shift? ::: A copy of the old sign bit. Q: Which select input of the universal-stage mux gives "hold"? ::: (self-feedback), mode . Q: Which timing check is independent of clock frequency? ::: Hold time ().

Connections

  • D flip-flop — every stage here is one such atom
  • Multiplexers — the mode-select in L4.1 is a 4-to-1 mux per stage
  • Counters — L4.2's ring counter is a shift register with feedback
  • Serial communication (UART, SPI) — L1.2 and L5.1 are the PISO/SIPO link
  • Binary multiplication and division — L3's shifts are ×2 and ÷2
  • Clocking and setup/hold time — L5.2's setup and hold budget

Concept Map

add feedback

add mux per stage

D flip-flop one bit

Shift register chain

Right shift divide by 2

Left shift multiply by 2

Ring counter

Universal register