Codiode

Bypassable Register with Generate If

MediumVerilog / SystemVerilogBuild

A configurable delay element either registers its input or passes it straight through. A generate block picks one of the two structures when the design is elaborated, so only the chosen one is built.

The solution module is parameterized with bypass. When bypass is 0 the module registers d through a flip-flop and drives q one cycle later. When bypass is 1 the module drives q directly from d combinationally.

The compiler halts with an elaboration error: "Identifier is not a constant." The test suite fails to build. Inspect the code and correct the fault. The testbench instantiates the module with bypass = 0.

Signal Direction Width Description
clk input 1 Positive-edge triggered clock; used only when bypass=0
d input 1 Data input
q output 1 Data output; registered when bypass=0, combinational when bypass=1

Constraints

  • The configuration must be a compile-time parameter, not a runtime input port.
  • When bypass = 0, the flip-flop is positive-edge triggered and has no reset.
  • When bypass = 1, output q equals input d combinationally with no clock dependency.
  • Do not change the internal logic; only change how bypass is declared.

Topics

DebugParametersSystemVerilogGenerate

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's 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.

Part of SystemVerilog RTL

Problem 13 of 15 in the SystemVerilog RTL track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.