**4-bit Gray Code Counter:** Explain how an internal binary counter can b…
**4-bit Gray Code Counter:** Explain how an internal binary counter can be combined with combinatorial Gray logic to implement a glitch-free **4-bit Gray Code Counter**. Write the synthesizable Verilog RTL code and its testbench.
Model answer
### 1. Working Principle A Gray code counter cycles through 16 states with exactly 1 bit changing on each step. The standard RTL architecture registers an internal binary count and derives the registered Gray output directly: gray\_count = bin\_count \oplus (bin\_count \gg 1) ### 2. Verilog RTL Implementation ### 3. Verilog Testbench