Register with Enable

Easy · Sequential Logic

Build an 8-bit register: eight D flip-flops that share a clock, a reset and a load enable. A register remembers a value between clock edges, and it is the building block of every counter, pipeline and state machine.

Ports

PortDirWidthMeaning
clkinput1Clock. The register changes only at the rising edge of clk.
rstinput1Synchronous, active-high reset (it takes effect only at a rising edge).
eninput1Load enable.
dinput8Value to store.
qoutput8The stored value (the flip-flops' outputs).

Behavior

At every rising edge of clk, in priority order:

  1. If rst = 1: q <= 0. Reset wins over the enable.
  2. Else if en = 1: q <= d.
  3. Else: q keeps its value.

Between rising edges q never changes, whatever d, en or rst do. In particular, raising rst does not clear q until the next rising edge.

Example

edge0123456
rst1000010
en0101110
d8'h558'h3C8'hFF8'h818'h078'hAA8'h11
q after the edge8'h008'h3C8'h3C8'h818'h078'h008'h00

Sign up free to solve Register with Enable in your browser.

More Sequential Logic problems