Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Reject Input Glitches Shorter than Four Samples

Hardware interview practice

Reject Input Glitches Shorter than Four Samples

MediumRTL DesignSystemVerilog

An asynchronous control input may glitch. A 100 MHz destination must first synchronize it and then change its filtered output only after seeing the opposite level on four consecutive destination samples. Implement the synchronizer and four-sample stability filter.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

module stable4_filter(
 input logic clk,rst_n,async_in,
 output logic filtered_out
);
Reviewed example

Work through one case

Input
Case 1: From filtered_out=0, synchronized samples 1,1,1,0
Case 2: Scenario: From filtered_out=0, synchronized samples 1,1,1,1 change the output to 1 on the fourth sample.
Case 3: Scenario: From filtered_out=1, four consecutive synchronized zeros change the output to 0 by the same rule.
Expected output
Case 1: Leave the output at 0 and clear progress.
Case 2: Expected behavior: From filtered_out=0, synchronized samples 1,1,1,1 change the output to 1 on the fourth sample.
Case 3: Expected behavior: From filtered_out=1, four consecutive synchronized zeros change the output to 0 by the same rule.

The shown result follows by applying this rule: The CDC synchronizer is separate from the four-sample qualification state. The cases also demonstrate this requirement: A return to the current output before four differing samples restarts qualification; use a saturating or explicitly cleared counter so it cannot wrap into a false transition.

What to cover

Requirements

  1. Use a two-flop destination-clock synchronizer for async_in, mark or preserve it as a synchronizer, and feed the filter only from its second stage.
  2. Active-low synchronous reset clears both synchronizer stages, filtered_out, and the differing-sample counter.
  3. When the synchronized sample equals filtered_out, clear the counter; otherwise count consecutive differing samples, update filtered_out on the fourth such sample, and clear the counter.
  4. A return to the current output before four differing samples restarts qualification; use a saturating or explicitly cleared counter so it cannot wrap into a false transition.
asic.fyi · Learn silicon end to end.info@asic.fyi