Hardware interview practice
Generate and synchronize a Gray-code counter
Design a parameterized counter whose exported Gray code changes by one bit per source increment, then synchronize that Gray value into a destination clock domain.

Reviewed example
Work through one case
Input
WIDTH=3; enabled source binary counts=[0,1,2,3]Expected output
registered Gray values=[000,001,011,010]; each appears in destination after two destination edgesEach source increment changes one Gray bit, while the marked two-flop chain still handles metastability before destination use.
What to cover
Requirements
- Increment the binary source count by at most one on each enabled source edge.
- Register Gray code derived from the next binary value.
- Use a two-flop destination synchronizer for every Gray bit and mark the chain for CDC tools.
- Explain that Gray coding limits transition ambiguity but does not remove metastability or replace synchronization.
