**Parameterizable Mod-N Counter:** Explain the design of a modulus counte…
**Parameterizable Mod-N Counter:** Explain the design of a modulus counter (Mod-N Counter) that counts from $0$ up to $N-1$ and wraps around to $0$. Write parameterized synthesizable Verilog RTL code and its testbench.
Model answer
### 1. Working Principle A **Mod-N Counter** cycles through exactly $N$ distinct states ($0, 1, 2, \dots, N-1$). The required number of flip-flops is: k = \lceil \log_2 N \rceil When the counter reaches terminal count $(N-1)$, the next clock pulse resets it back to $0$. ### 2. Parameterized Verilog RTL Implementation ### 3. Verilog Testbench