**Parameterized N-bit Up/Down Counter:** Design a parameterized $N$-bit s…
**Parameterized N-bit Up/Down Counter:** Design a parameterized $N$-bit synchronous binary counter in Verilog with an active-high synchronous reset and an UpOrDown control signal. Write the complete RTL code and its testbench.
Model answer
### 1. Working Principle An $N$-bit synchronous counter counts through $2^N$ states on the active edge of clk : - When UpOrDown = 1'b1 : Counter increments ($count \leftarrow count + 1$). - When UpOrDown = 1'b0 : Counter decrements ($count \leftarrow count - 1$). - Overflows/underflows wrap around modulo $2^N$. ### 2. Parameterized Verilog RTL Implementation ### 3. Verilog Testbench