4-Bit Register with Clock
Basic 4-bit register with parallel load and clock. Foundation for data storage in digital systems with timing analysis.
Lo que aprenderás
- 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.
Cómo funciona
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.
Pruébalo paso a paso
Configura las entradas en la simulación de arriba, lee qué debería suceder y verifícalo.
- 1D = 1010 Clock = risingEsperado:
Q = 1010Lo que verás: Set inputs to 1010, raise the clock — register captures all 4 bits simultaneously. Output reflects 1010 (= 10). - 2D = 0101 Clock = rising againEsperado:
Q = 0101Lo que verás: Change inputs to 0101 and clock — new value captured. The previous value is overwritten. - 3Clock = stoppedEsperado:
Q frozenLo que verás: Stop the clock — Q holds whatever it was. D's changes have no effect until the next clock edge. - 4D = all 0 Clock = risingEsperado:
Q = 0000Lo que verás: Clock with D = 0000 → register loads zeros. Effectively a clear-to-zero on every cycle if D is held at 0.
Componentes utilizados
Aplicaciones en el mundo real
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.