Simple Latch Based Clock Gating Cell
Modern SoCs rely heavily on clock gating to reduce dynamic power consumption. Naively gating a clock with a simple AND gate introduces hazardous glitches if the enable signal transitions while the clock is high.
A standard glitch-free clock gating cell solves this by synchronizing the enable signal. The circuit uses a negative-level sensitive latch to hold the enable signal steady during the high phase of the clock. The latched enable is then ANDed with the source clock to produce the gated clock. This ensures the output clock transitions cleanly and safely.
Timing and Reset Rules:
- Latch transparency: The internal latch is transparent when
clkis 0; it directly passes theensignal. - Latch hold: The internal latch holds its current value when
clkis 1, ignoring any changes onen. - Output logic: The
gated_clkoutput is a combinational AND ofclkand the internal latched enable. - Reset: There is no explicit reset pin; the latch assumes the value of
enwhenclkis 0.
Worked Trace:
Step 1: clk=0, en=1 → latched_en=1, gated_clk=0 Step 2: clk=1, en=1 → latched_en=1 (hold), gated_clk=1 Step 3: clk=1, en=0 → latched_en=1 (hold), gated_clk=1 (glitch prevented) Step 4: clk=0, en=0 → latched_en=0, gated_clk=0 Step 5: clk=0, en=1 → latched_en=1, gated_clk=0 Step 6: clk=1, en=1 → latched_en=1 (hold), gated_clk=1
{ "signal": [
{ "name": "clk", "wave": "01.0.1" },
{ "name": "en", "wave": "1.0..1" },
{},
{ "name": "latched_en","wave": "1..0.1" },
{ "name": "gated_clk", "wave": "01.0.1" }
], "head": { "text": "Enable falls while clk is high; latch holds value to prevent output glitch." } }Port Table:
| Signal | Direction | Width | Description | |-------------|-----------|-------|-------------| | clk | input | 1 | Source clock | | en | input | 1 | Clock enable signal | | gated_clk | output | 1 | Gated output clock |
Constraints
- Must infer a negative-level sensitive latch for the internal enable signal.
- Do not use edge-triggered flip-flops (
posedgeornegedge). - The output
gated_clkmust be the continuous logical AND ofclkand the latched enable. - All ports are 1-bit wide.
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.