CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

Overriding Parameters via Hash Parentheses

MediumVerilog / SystemVerilogBuild

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 out clears 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_counter exactly 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

CountersParametersVerilog SyntaxInstantiation

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.

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Basic D Flip FlopEasy
  • Debug: Missing Edge in Sensitivity ListMedium
  • Read After Write Hazard DetectionEasy
  • Parameterized Interface with ModportsHard
  • Struct Array PipelineHard
  • T Flip Flop from D Flip Flop TemplateEasy
  • Recursive Generate Reduction TreeHard
  • Four Stage Shift RegisterEasy

Browse all problems · Learning tracks