Always Latch Intentional Design
Clock distribution networks consume significant power in modern hardware. To save power, entire functional blocks are disabled by turning off their clocks. However, simply ANDing an enable signal with the clock creates dangerous glitches if the enable transitions while the clock is high. Integrated Clock Gating (ICG) cells solve this by safely synchronizing the enable signal using a latch.
The module receives a master clock clk, a functional enable en, and a test enable te. It outputs a gated_clk. To prevent glitches, the combined enable (en OR te) must be latched while clk is low. The latched enable is then ANDed with clk to produce gated_clk. Because latches are typically considered design errors, synthesis tools warn when they are inferred. SystemVerilog provides the always_latch block to explicitly declare intentional latch inference.
- Clock edge: The latch is transparent when
clkis low (level-sensitive, not edge-triggered). - Reset: There is no dedicated reset pin. The latch initializes its state during the low phase of
clk. - Combinational logic: The enable condition is
enORte. - Output:
gated_clkis the logical AND ofclkand the latched enable.
Cycle 1 (clk=0): en=1, te=0 → latched enable=1, gated_clk=0 Cycle 2 (clk=1): en=0, te=0 → latched enable=1 (hold), gated_clk=1 Cycle 3 (clk=0): en=0, te=0 → latched enable=0, gated_clk=0 Cycle 4 (clk=1): en=1, te=0 → latched enable=0 (hold), gated_clk=0
{ "signal": [
{ "name": "clk", "wave": "0101" },
{ "name": "en", "wave": "1001" },
{ "name": "te", "wave": "0..." },
{},
{ "name": "latched_en","wave": "1.0." },
{ "name": "gated_clk", "wave": "010." }
], "head": { "text": "Glitch-free clock gating cell preventing glitches on the output." } }| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | clk | input | 1 | Master clock and active-low latch enable | | en | input | 1 | Functional clock enable | | te | input | 1 | Test enable; forces clock on for DFT | | gated_clk | output | 1 | Gated clock output |
Constraints
- Must use the SystemVerilog
always_latchkeyword. - The latch must be transparent when
clkis 0. - Output
gated_clkmust be driven by an AND gate. - Do not use edge-triggered flip-flops.
- Do not use a reset pin.
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.