4-Bit Register with Clock
Basic 4-bit register with parallel load and clock. Foundation for data storage in digital systems with timing analysis.
您将学到什么
- 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.
工作原理
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.
逐步尝试
在上方嵌入式电路中设置输入,然后阅读预期结果并验证。
- 1D = 1010 Clock = rising预期:
Q = 1010您将看到: Set inputs to 1010, raise the clock — register captures all 4 bits simultaneously. Output reflects 1010 (= 10). - 2D = 0101 Clock = rising again预期:
Q = 0101您将看到: Change inputs to 0101 and clock — new value captured. The previous value is overwritten. - 3Clock = stopped预期:
Q frozen您将看到: Stop the clock — Q holds whatever it was. D's changes have no effect until the next clock edge. - 4D = all 0 Clock = rising预期:
Q = 0000您将看到: Clock with D = 0000 → register loads zeros. Effectively a clear-to-zero on every cycle if D is held at 0.
使用的组件
实际应用
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.