Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Register a glitch-free decoded enable

Q014·Free·SystemVerilog

Register a glitch-free decoded enable

Difficulty
Easy
Topic
RTL Design
Language
SV
Interview prompt

Question

Generate valid when a two-bit input equals 01 or 10. The signal will control downstream sequential logic, so make the decoded result cycle-aligned and glitch-free rather than using it to gate a clock. Treat a as a known synchronous input that meets setup and hold around the sampling edge.

Candidate starting point

Implementation scaffold

module registered_valid_decode (
  input  logic       clk,
  input  logic       rst_n,
  input  logic [1:0] a,
  output logic       valid
);
  always_ff @(posedge clk or negedge rst_n) begin : register_decoded_enable
    // TODO: Implement register_decoded_enable using the supplied state and interface.
  end
endmodule
Reviewed example

Trace one case

Input
After reset, inputs a immediately before four rising edges are 00, 01, 11, 10.
Expected output
The valid register immediately after those same edges is 0, 1, 0, 1; downstream sequential logic samples those values one edge later.

The decode drives a register’s D input, not its clock. Between-edge changes of a cannot change the valid register; asserting rst_n low still clears it asynchronously.

What to cover

Requirements

  1. Register valid on the functional clock.
  2. Never create a derived clock with combinational decode logic.
  3. Reset valid to a known inactive value.
  4. After a rising edge, valid reflects the input sampled at that edge. A downstream register observes it on the next edge. Only asynchronous reset assertion may change valid between functional clock edges.
Exact question handoffPractice Q014

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

RTL Clock Boundaries and Flow

Review reset, clock boundaries, arbitration, ready-valid flow, FIFOs, and backpressure.

  • RTL Design
  • Decode
  • Clock enable
  • Glitch
RTL Clock Boundaries and Flow →
Continue practicing

Related questions

Q102 · RTL DesignCode an asynchronously reset register with enableEasy→Q814 · RTL DesignGlitch-free gated test clockEasyP→Q690 · RTL DesignHold even decimal counts for an extra enabled cycleMediumP→Q948 · Low-Power DesignDesign glitch-free clock gatingMediumP→Q1142 · Memory SystemsPlace buffering for glitch-free display scanoutMediumP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi