CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

D Flip-Flop

EasyVerilog / SystemVerilogBuild

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 a real testbench — you get the waveform back, not a stored answer.

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

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Basic D Flip FlopEasy
  • Debug: Missing Edge in Sensitivity ListMedium
  • Read After Write Hazard DetectionEasy
  • Parameterized Interface with ModportsHard
  • Struct Array PipelineHard
  • T Flip Flop from D Flip Flop TemplateEasy
  • Recursive Generate Reduction TreeHard
  • Four Stage Shift RegisterEasy

Browse all problems · Learning tracks