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

Always FF Edge Strictness

EasyVerilog / SystemVerilogBuild

A standard D flip-flop with asynchronous reset forms the foundational state-holding element in synchronous digital designs. This particular instance sits at the output of a reset tree where the reset is distributed asynchronously across multiple clock domains. The block uses SystemVerilog's always_ff construct, which enforces stricter simulation semantics than the Verilog always block.

The solution module captures d on each rising clock edge and drives q. The reset rst_n is active-low and asynchronous. Asserting rst_n low must drive q to 0 immediately regardless of the clock.

Compilation fails with a semantic error during elaboration. The compiler flags the sequential block for violating always_ff strictness rules. Inspect the module and correct the fault.

| Signal | Direction | Width | Description | |---------|-----------|-------|-------------| | clk | input | 1 | Positive-edge triggered clock | | rst_n | input | 1 | Asynchronous active-low reset; q goes to 0 immediately when asserted | | d | input | 1 | Data input captured on rising clock edge | | q | output | 1 | Registered output; resets to 0 |

Constraints

  • Clock is positive-edge triggered.
  • Reset is asynchronous and active-low; q must go to 0 immediately when rst_n is low.
  • The module must use the always_ff keyword.
  • Output q is registered.

Topics

DebugSequential LogicSystemVerilog

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