FPGA DEVICES · ENGINEERING · SOURCING Source-linked information. Clear project requirements.

Tutorials

FPGA Button Debounce: Separate Synchronization, Stability and the Press Pulse

Published · Updated

Synchronize the input before qualifying a press

A mechanical button can produce several transitions during one action. It is also asynchronous to the FPGA clock. These are separate problems: synchronization reduces the risk associated with sampling an asynchronous signal, while debouncing decides when a new mechanical state has persisted long enough. A long counter alone is not a substitute for the synchronization structure.

A tactile switch on a circuit board. The photograph identifies the mechanical component; it is not a measurement of its bounce duration.
A tactile switch on a circuit board. The photograph identifies the mechanical component; it is not a measurement of its bounce duration. Photo: Raimond Spekking. Original image, CC BY-SA 4.0.

Keep three signals visible in the design: synchronized sample, debounced state and one-cycle press event. This avoids using a held button as a repeated command. Decide whether the application needs release events, long-press behavior or only a single action on the inactive-to-active transition.

Board bring-up sequence: Prepare the board checks before testing this interface.

I/O count and allocation: Reconcile signal count and physical allocation.

Define exactly what N stable samples means

One useful contract accepts a new state after N consecutive samples of that state, resetting the candidate count whenever the sample changes back. Derive N=ceil(clock frequency×qualification time) for a counter evaluated every clock. At 50 MHz and 10 ms, N is 500000; a counter representing zero through N−1 needs 19 bits.

Qualify stability after synchronizationQualify stability after synchronizationRaw buttonStable statePress eventConceptual sequence; threshold and synchronization delay not to scale.
Qualification count example. Explanatory diagram; conditions and limitations are in the adjacent text.

If the design samples only on a slower enable, use that sampling rate instead. Define the N=1 case explicitly. The qualification interval is a design choice informed by the actual switch and required response, not a universal maximum bounce duration. Apply the same reasoning to release unless the application intentionally specifies otherwise.

External input/output timing: Include the external path in the timing budget.

Clock-domain synchronization: Keep asynchronous sampling separate from interface logic.

Test the boundary and the held-button behavior

Construct test sequences with N−1, N and N+1 consecutive samples, an interrupted candidate sequence, a long hold and release bounce. Count emitted press pulses rather than merely looking at the final state. Reset during a candidate transition should have an intentional result.

Boundary tests for one pressBoundary tests for one pressN−1 stable samplesno accepted transitionN stable samplesaccept new stateLong held stateno additional press pulseInterrupted candidaterestart qualification
Boundary tests for one press. Explanatory diagram; conditions and limitations are in the adjacent text.

The timing worksheet below calculates the interval and counter width; it does not claim a hardware measurement. For RTL verification, make the expected event sequence independent of the implementation counter. On a real board, capture both the raw input and the debounced event where possible. This makes it clear whether a failure comes from switch behavior, synchronization, qualification or downstream event handling.

Power-on test record: Retain the power states and test sequence.

Use the equations and review steps above. Interactive checks require JavaScript.
Watch the short qualification count example sequenceQualification count example step sequence

Save the check result with your exact device, board revision and unresolved conditions. Discuss the interface requirements when the remaining issue needs a board or implementation review. Opening this link does not submit the worksheet.

Sources and example scope

Documentation checked 17 November 2026. Worked values are illustrative calculations. No board measurement or Vivado implementation run is claimed. The worksheet checks entered assumptions and does not inspect your schematic or project files.

Back to Tutorials

Related evidence and next tasks

Continue the task with the relevant source scope. These reading paths do not establish interchangeability or current supply.

Source addresses and citation trail

Full source addresses are retained below. Read each citation with its document revision, page, table and applicability conditions above.

  1. https://commons.wikimedia.org/wiki/File:Tactile_switches_on_a_printed_circuit_board-9708.jpg
  2. https://creativecommons.org/licenses/by-sa/4.0
  3. https://digilent.com/blog/debouncing-circuits/