Clock Gating Cell Inference
Power consumption in modern ASICs is heavily dominated by the clock tree. To reduce dynamic power, engineers disable the clock to inactive registers using clock gating. However, simply using an AND gate to combine a clock and an enable signal creates dangerous glitches if the enable signal toggles while the clock is high. Standard cell libraries provide Integrated Clock Gating (ICG) cells to solve this, which synthesis tools can automatically infer if the RTL is written correctly.
The module receives a continuous clock signal clk and a control signal en. It must output a glitch-free gated clock gated_clk. To achieve this without glitches, the module must internally latch the en signal while the clock is low, and hold that latched value while the clock is high. The final gated_clk output is the logical AND of the original clock and the latched enable signal.
- Clock edge: The internal latch must be transparent when
clkis low (clk == 0). - Reset type: None. The circuit operates continuously based on clock levels.
- Priority: The latch captures
encontinuously whileclkis low. Whenclktransitions high, the last value ofenis held safely. - Output:
gated_clkis the combinational AND ofclkand the internal latch output.
Phase 1 (clk=0): en=0 → internal latch=0, gated_clk=0 Phase 2 (clk=1): en=1 → internal latch=0 (held), gated_clk=0 (glitch masked) Phase 3 (clk=0): en=1 → internal latch=1, gated_clk=0 Phase 4 (clk=1): en=0 → internal latch=1 (held), gated_clk=1 (keeps clock high for full half-cycle) Phase 5 (clk=0): en=0 → internal latch=0, gated_clk=0
{ "signal": [
{ "name": "clk", "wave": "01010101" },
{ "name": "en", "wave": "01...0.." },
{ "name": "latch_en", "wave": "0.1...0." },
{ "name": "gated_clk", "wave": "0..1010." }
], "head": { "text": "Enable toggling during clock high is safely masked by the latch." } }| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | clk | input | 1 | Continuous clock signal | | en | input | 1 | Clock enable signal | | gated_clk | output | 1 | Glitch-free gated clock |
Constraints
- You must infer a negative-level-sensitive latch (transparent when
clkis 0). - Do not use edge-triggered flip-flops (
posedgeornegedge). - Output
gated_clkmust be the combinational AND ofclkand the latched enable. - No asynchronous resets are used in this 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.