Glitch Power: Toggles That Do No Work
Count the extra output changes that unequal path delays cause, and cut them by balancing the paths.
You Will Be Able To
- Explain why a net can change several times in one cycle before it settles.
- Measure glitches by comparing every change with the settled changes.
- Predict which structure of the same logic glitches less, and check it in simulation.
- Say why a zero-delay simulation cannot measure glitch power.
- Lesson
- W1.6
- Time
- 25 min
- Runs on
- Your browser
- Check
- 5 questions
A block adds four bytes in every cycle. In 1,000 cycles its sum needs 4,805 output bit changes, yet the chain of adders made 31,433.
- Cycle 1
The new operands arrive. In the zero-delay simulation, bit 7 jumps to its final value at once.
- Cycle 4
In the chain, the first adder answers before its carry has rippled. Bit 7 rises early on a partial sum.
- Cycle 7
The tree is done: one clean rise at 6 ns. Its two halves finish at about the same time.
- Cycle 17
The chain settles at 16 ns, after 9 changes. Only one of them was needed.
Measured on Icarus with 1 ns per gate (data/W1-6.json). Bit 7 changes 9 times in the chain, once in the tree and once in the zero-delay run.
The extra changes, called glitches, do no work. Yet each one charges or discharges a wire, and that costs energy.
Why an Output Changes More Than Once
A gate answers when its inputs change. If its inputs arrive at different times, it answers more than once.
In a ripple-carry adder, sum bit i waits for the carry from bit i - 1. The carry needs about two gate delays per bit. Bit 7 first answers with the carry it has, then answers again when the true carry arrives.
- Datapath
- Data
- The chain
Each adder starts on a partial sum that is still changing. Every early answer travels on and makes the next adder answer again.
- The tree
The two halves work at the same time and finish together. The final adder sees two inputs that arrive at about the same time.
Read the diagram as text
- a + b: Chain, first adder
- + c: Waits for a + b
- + d: Bit 7 settled at 16 ns
- a + b: Tree, left half
- c + d: Tree, right half
- Final adder: Bit 7 settled at 6 ns
- a + b → + c: partial sum
- + c → + d: partial sum
- a + b → Final adder
- c + d → Final adder
The cells are the same. Only the order of the additions differs.
In the trace above, the zero-delay run shows one change. The chain shows several, because its stages finish one after another.
Zero-Delay Simulation Cannot See Them
Most RTL and many gate-level simulations give every gate zero delay. Then all gates answer in the same time step, and each net ends that step with its final value.
A VCD file records one value per net per time step. So the activity file of a zero-delay run holds only the settled changes. A power tool that reads it sees no glitch at all.
To see glitches, a simulation needs delays. This lab gives each gate a delay of 1 ns. A sign-off flow uses each cell's own delays from the library and the wires.
The SAIF format of lesson W1.5 has a field for these extra edges. It calls a change before the net settles a transport glitch. Its count is the toggles of a timing simulation minus the toggles of a zero-delay one.
Where Glitches Grow
The lab runs both versions on the same 1,000 random sets of operands and counts every change of every output bit.
- chain
- tree
- settled
Read the plot as a table
| Output bit | chain | tree | settled |
|---|---|---|---|
| 0 | 1469 | 521 | 521 |
| 1 | 2306 | 988 | 500 |
| 2 | 3036 | 1796 | 526 |
| 3 | 3390 | 1982 | 500 |
| 4 | 3747 | 1935 | 507 |
| 5 | 3907 | 1905 | 517 |
| 6 | 4038 | 1882 | 526 |
| 7 | 4113 | 1849 | 529 |
| 8 | 3083 | 1387 | 391 |
| 9 | 2344 | 912 | 288 |
Measured on Icarus: the lab below prints every number on this plot.
| Structure | Output bit changes | Glitch changes | Changes per useful change |
|---|---|---|---|
| Settled (what the sum needs) | 4,805 | 0 | 1 |
| Chain ((a + b) + c) + d | 31,433 | 26,628 | 6.5 |
| Tree (a + b) + (c + d) | 15,157 | 10,352 | 3.2 |
Measured on Icarus, 1 ns per gate, 1,000 cycles of 40 ns.
The chain changes 6.5 times for every useful change. The tree computes the same sum with 61 % fewer glitch changes.
The middle bits glitch most. Their carries come from long paths, and partial sums reach them many times. In the chain, bit 7 changed 4,113 times for 529 useful changes.
Deep arithmetic with unequal paths glitches most: adder chains, array multipliers and long XOR chains. Narrow logic with short, equal paths glitches little.
Cutting Glitches: Balance the Paths or Add a Register
Two fixes work. Both aim at the same cause: inputs that reach a gate at different times.
Balance the paths
Rearrange the logic so that the inputs of each gate arrive together. The tree did this for the same three adders: 15,157 changes against 31,433.
Add a register stage
A register passes only the settled value, once per cycle. With a register after the chain's second adder, the output changed 8,989 times. The output now glitches only through the last adder.
Both fixes have a price. A register adds a cycle of latency and a bank of flops. Each flop's clock pin burns power in every cycle (lesson W1.2). Balancing changes the structure, and a synthesis tool may rebuild it anyway.
Asked in interviews
What is glitch power?
It is the power of extra transitions before a net settles. They come from inputs that arrive at different times. They change nothing in the final value, but each one charges or discharges the net like a useful toggle.
Why does a zero-delay simulation miss it?
With zero delay, every net takes its final value within one time step. The activity file records one value per time step, so it holds only useful toggles. A timing simulation with real delays shows the glitches.
How do you reduce glitches?
Balance the paths so that each gate's inputs arrive together, for example a tree of adders instead of a chain. Or add a register stage, which passes only settled values. Operand isolation (lesson W2.2) also helps, because quiet inputs cause no glitches.
Try It
Run it. The bench feeds the same random operands to the chain, the tree and a zero-delay copy of the chain. It counts every change of each output bit, read once per nanosecond.
The settled column counts changes from one cycle's final value to the next. That is all the sum needs. The rest of each count is glitch.
Change the chain to ((a + b) + (c + d)) by editing chain4, and run again. Its counts should match the tree.
Then set the delay of the fa instances in tree to 2. Predict first: does the glitch count change when every gate is slower by the same factor?
bit 0: settled 521 chain 1469 tree 521 bit 1: settled 500 chain 2306 tree 988 bit 2: settled 526 chain 3036 tree 1796 bit 3: settled 500 chain 3390 tree 1982 bit 4: settled 507 chain 3747 tree 1935 bit 5: settled 517 chain 3907 tree 1905 bit 6: settled 526 chain 4038 tree 1882 bit 7: settled 529 chain 4113 tree 1849 bit 8: settled 391 chain 3083 tree 1387 bit 9: settled 288 chain 2344 tree 912 settled toggles=4805 chain: toggles=31433 glitch toggles=26628 tree: toggles=15157 glitch toggles=10352 zero-delay chain, bit 0: 1469 events counted by always @Check Yourself
Common Mistakes
Wrong Estimate the power of a deep datapath from a zero-delay gate-level simulation.
Every net gets one final value per time step, so the activity file holds no glitches, and the estimate is too low.
Fix Use a simulation with real cell delays, or a glitch-aware estimate, for arithmetic blocks.
Wrong Count toggles with an always @ block in a zero-delay simulation.
It also counts events inside one time step. The lab counted 1,469 events on bit 0 of the zero-delay chain, which settles only 521 times.
Fix Count changes between settled values, or read them from the VCD file.
always @(y[0]) toggles++;always @(posedge clk) begin
toggles += (y[0] !== last);
last = y[0];
endWrong Treat glitches as harmless because the final value is right.
A glitch charges and discharges the net's capacitance like a useful change, so it costs the same energy.
Fix Count glitches as switching activity when you estimate power.
Remember
- A glitch is an extra change before a net settles. It costs energy like a useful toggle.
- Glitches come from inputs that reach a gate at different times. Deep arithmetic with unequal paths glitches most.
- Measured: a chain of three adders changed its outputs 31,433 times, and a tree of the same adders 15,157 times. The sum needed 4,805.
- A zero-delay simulation records only settled values, so its activity file misses glitch power.
- Balance the paths, or add a register stage at the cost of a cycle and some clock power.