Overriding Parameters via Hash Parentheses
Hardware designs frequently reuse generic IP blocks like counters, FIFOs, and adders to maintain a clean and modular codebase. To adapt these generic blocks to specific data paths, engineers override their default parameters during instantiation instead of rewriting the logic from scratch.
A generic counter module named generic_counter is provided in the environment. It has a default parameter WIDTH set to 8. The top-level solution module must instantiate this generic counter, override its WIDTH parameter to 16 using hash-parentheses syntax, and connect the top-level ports to the counter instance. The counter increments by one on every positive clock edge where the enable signal is asserted.
- Clock edge:
posedge clk - Reset type: Asynchronous
- Reset polarity: Active-low
rst_n - Reset behavior: Output
outclears to 16'b0 - Priority: Reset takes priority over enable
Cycle 1: rst_n=0 → out=0 Cycle 2: rst_n=1, en=1 → out=1 Cycle 3: en=1 → out=2 Cycle 4: en=0 → out=2 (hold)
| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | clk | input | 1 | Positive-edge triggered clock | | rst_n| input | 1 | Asynchronous active-low reset; clears out to 0 | | en | input | 1 | Enable signal; increments counter when 1 | | out | output | 16 | Current count value; resets to 16'b0 |
Constraints
- Instantiate
generic_counterexactly once. - Use the
#(.PARAMETER_NAME(value))syntax to override the width to 16. - The output must be exactly 16 bits wide.
- Do not write the counter logic from scratch; rely entirely on the instantiated module.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real testbench — you get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.