Problems

16. Counter-based debouncer

MediumWrite the moduleAbout 20 min
sequentialcountersdebounce

A push button bounces: for a short while after a press its signal flips between 0 and 1. Clean it up.

clean is a registered output. It changes only after noisy has been different from clean at 4 consecutive rising clock edges; on the fourth such edge clean takes the value of noisy. Any edge at which noisy equals clean restarts the count. The rule is the same for presses (0 to 1) and releases (1 to 0).

Assume noisy has already been synchronized to clk. rst (synchronous, active high) sets clean to 0 and restarts the count.

Ports

Module debounce

PortDirBitsWhat it is
clkin1Clock.
rstin1Synchronous reset, active high.
noisyin1Bouncy input, already synchronized.
cleanout1Debounced output.

Example

clean = 0 and noisy goes 1 for three edges, 0 for one edge, then 1 for four edges: clean becomes 1 on the last of those four edges, not earlier.

Stuck? . Sign in to save your progress. You can solve the free problems without an account.

Verilogdebounce.v
14px
Loading the editor…

Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.

Counter-based debouncer: Verilog interview question | breadboardhub