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

Debounce Logic with Hysteresis

MediumLogic CircuitBuild

Mechanical switches exhibit physical bounce during actuation, causing rapid, spurious voltage transitions. Hardware debounce logic filters these transients to present a clean, stable signal to downstream digital systems.

Implement a debounce circuit that filters the noisy input btn_in. The output btn_out must only update to match btn_in after btn_in has remained stable at a new logical value for 4 consecutive rising edges of clk. If btn_in bounces back to its old value before the 4-cycle threshold is reached, the internal counter must reset and btn_out must remain unchanged.

| btn_in State | Consecutive clk Edges | btn_out (Next State) | |---|---|---| | Same as btn_out | Any | btn_out (Unchanged) | | Different from btn_out | < 4 | btn_out (Unchanged) | | Different from btn_out | 4 | btn_in (Toggles) |

Constraints

  • Use synchronous sequential logic triggered on the rising edge of clk.
  • Implement a 2-bit internal counter to track stability cycles.
  • Reset the counter immediately to 0 if btn_in matches btn_out.
  • Initialize btn_out and the internal counter to 0 when rst is high.

Topics

Sequential LogicCountersDebounce

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

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

  • Binary to HexEasy
  • 1-to-4 Demultiplexer from AND and NOT GatesEasy
  • 2-to-4 Line Decoder with Active-High EnableEasy
  • Hex Nibble to BinaryEasy
  • Odd Parity Bit Generator for 3-bit DataEasy
  • Full Adder from Half AddersEasy
  • Modulo ArithmeticMedium
  • Two's Complement: Encode a Negative DecimalEasy

Browse all problems · Learning tracks