Build REG4 with four D flip-flops and a two-input multiplexer for each bit. Tie the flip-flops to one clock, then feed each flip-flop either its own output or the new data, selected by write enable. The saved value changes on the rising edge when write enable is high.
Connect each bit’s feedback
For each bit, route Q to the multiplexer input selected by write enable zero. Route the new data bit to the input selected by write enable one. Connect the multiplexer output to D. For a single-bit register, the same pattern uses one flip-flop and one multiplexer.
Share the clock and preserve bit order
Wire the same clock to all four flip-flops. Take the register outputs from Q and preserve their original bit order. With write enable low, each multiplexer presents the already stored value to its own flip-flop. With write enable high, each presents the corresponding new data bit.
Test capture, hold, and replacement
Start with write enable high and data 0101, then apply a rising edge and check for Q = 0101. Drop write enable, change data to 1010, and apply another rising edge. Q should hold 0101. Raise write enable and apply the next rising edge with data still at 1010 to check that Q becomes 1010.
Diagnose an output that changes too soon
If Q changes immediately when you change the data, look for a route that bypasses the flip-flop. Also check whether you used a level-sensitive latch where the design requires a rising-edge-triggered flip-flop. Watch clock, data, and output together to compare when each transition occurs. Use the campaign brief for the active palette and scoring rules.