What You'll Learn

  • Store a 4-bit value in a parallel-load register.
  • Recognize a register as parallel D flip-flops sharing a clock.
  • See how every bit captures D on the clock edge synchronously.
  • Connect this to CPU register files and pipeline stages.
  • Understand setup/hold timing across multiple bits.

How It Works

A 4-bit register stores a 4-bit value, updated synchronously on each clock edge. Internally it's four D flip-flops in parallel, all clocked by the same signal. Each clock edge captures the four data inputs (D3..D0) into the four flip-flops; their outputs (Q3..Q0) hold the value until the next clock edge.

A register is the fundamental storage element for multi-bit values in synchronous designs. Every CPU register, every pipeline stage's data, every state machine state register is a parallel D flip-flop bank like this.

With just a clock input, the register loads new data every cycle — equivalent to an unconditional move. To store data only when commanded, add a write-enable input that gates the flip-flop's enable; this is the next template (Register Load Control Demo).

Key timing: setup time (data must be stable before clock edge) and hold time (data must remain stable after clock edge) apply per bit. Worst-case path is the slowest of the four bits, but typically all bits have similar timing.

Try It Step-by-Step

Set the inputs in the embed above, then read what should happen and confirm.

  1. 1
    D = 1010 Clock = rising
    Expected: Q = 1010
    What you'll see: Set inputs to 1010, raise the clock — register captures all 4 bits simultaneously. Output reflects 1010 (= 10).
  2. 2
    D = 0101 Clock = rising again
    Expected: Q = 0101
    What you'll see: Change inputs to 0101 and clock — new value captured. The previous value is overwritten.
  3. 3
    D = varying Clock = stopped
    Expected: Q frozen
    What you'll see: Stop the clock — Q holds whatever it was. D's changes have no effect until the next clock edge.
  4. 4
    D = all 0 Clock = rising
    Expected: Q = 0000
    What you'll see: Clock with D = 0000 → register loads zeros. Effectively a clear-to-zero on every cycle if D is held at 0.

Components Used

Real-World Applications

CPU register file. Each architectural register (e.g., RAX, R0, x0) is implemented as a clocked register cell like this, organized in a register file with read and write ports.

Pipeline-stage registers. Every pipeline stage in a CPU has registers between it and the next stage; data flows synchronously stage-to-stage on each clock edge.

Data bus interface. External bus signals are sampled into a register before being processed in the CPU's clock domain.

Configuration registers. Memory-mapped peripheral registers store control bits; firmware writes set them via a register-load on the bus-clock edge.

FIFO entries. Each FIFO buffer slot is a register cell, with write-enable selectively triggering one entry's load.

Frequently Asked Questions

What's the difference between a register and a counter?
A register stores a value loaded from D inputs; a counter generates a sequence of values via internal next-state logic. Both use flip-flops; the counter adds combinational logic that computes the next count from the current state.
Can I read and write the register in the same cycle?
Read of Q happens any time (combinational output of the flip-flops). Write happens on the next clock edge. So in one cycle you can read the current Q and present a new D for the next cycle's load.
How does this scale to wider registers?
Just add more flip-flops in parallel. An 8-bit register is 8 DFFs sharing a clock; 64-bit is 64 DFFs. CMOS process can pack hundreds of flip-flops into a small area.
What if some bits' D inputs settle later than others?
Worst-case timing is governed by the slowest input. Synthesis tools route signals to balance arrival times. If one input is consistently late, you can pipeline that path with an extra flip-flop.
Why use a register instead of a latch?
Registers (edge-triggered) are glitch-immune — D can wiggle freely between edges. Latches (level-sensitive) are transparent during clock-high, so glitches propagate. Synchronous designs almost always use registers (flip-flops) over latches.

Continue Learning