Codiode

D Flip-Flop

EasyVerilog / SystemVerilogBuild2 solved

Design a synchronous D flip-flop with active-high reset in Verilog.

The flip-flop captures the value of input d on every rising edge of clk and holds it on output q until the next rising edge.

Behaviour

reset d q after rising edge
1 x 0
0 0 0
0 1 1

When reset = 1, output is forced to 0 on the next rising edge regardless of d (synchronous reset). When reset = 0, output follows d.

The D flip-flop is the fundamental building block of all sequential digital circuits — registers, counters, and state machines are all built from it.

Constraints

  • Rising-edge triggered — use always @(posedge clk)
  • Reset is synchronous and active-high
  • Reset has priority over d
  • Declare q as reg
  • No combinational latches allowed

Topics

SequentialFlip-Flop

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.

This problem is part of Codiode Pro. The statement above is free to read.

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Part of Sequential RTL

Problem 24 of 26 in the Sequential RTL track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.