Static Hazards and the Consensus Fix
Find the input change that makes a correct circuit glitch, and add the consensus term that holds its output steady.
You Will Be Able To
- Explain how unequal path delays make a static hazard.
- Find static-1 hazards on a K-map as touching groups that do not overlap.
- Remove a hazard with the consensus term.
- Tell a static-1 hazard from a static-0 hazard.
- Lesson
- G5.2
- Time
- 25 min
- Runs on
- Your browser
- Check
- 5 questions
A gate-level mux had both data inputs at 1, so its output should have stayed 1 whatever the select did. When the select fell, the output dropped to 0 for one gate delay. The function was right; the timing was not.
- Cycle 1
sfalls at t = 10. - Cycle 2
One gate delay later,
t1has fallen.nshas risen, butt0has not seen it yet. - Cycle 3
Both product terms are 0 at t = 11, so the OR gate drops
yat t = 12. - Cycle 4
t0rose at t = 12, soyis back to 1 at t = 13.
Measured on the hazard-mux circuit model, the same netlist as the lab.
A Glitch from Two Paths
A static hazard is a glitch on an output that should not change. A static-1 hazard drops a steady 1 to 0 for a moment. A static-0 hazard lifts a steady 0 to 1.
It needs two paths of different delay from one input. Here s reaches t1 through one gate, but reaches t0 through two: the inverter, then the AND gate.
s travels. Each box is one gate delay.- I/O
- Datapath
- Data
- Short path
One gate delay after
sfalls,t1is already 0. - Long path
The other term needs two gate delays, so for one gate delay both OR inputs are 0.
Read the diagram as text
- s falls: t = 10
- NOT: ns rises at 11
- AND sb: t1 falls at 11
- AND s'a: t0 rises at 12
- OR: sees 0, 0 at 11
- s falls → NOT: long path
- s falls → AND sb: short path
- NOT → AND s'a
- AND s'a → OR
- AND sb → OR
The glitch is as wide as the difference between the two paths: here one gate delay.
The direction matters. When s rises, t1 turns on one gate delay before t0 turns off. The two terms overlap, and y stays 1.
Finding Hazards on a K-Map
Each product term is a group on the K-map. A static-1 hazard can occur where two groups touch across one variable but share no cell.
So the rule is: look for every pair of adjacent 1 cells that no single group covers. Each such pair is a possible static-1 hazard.
The Consensus Term
The consensus of two terms that hold one variable in opposite forms is their AND with that variable dropped. The consensus of s'a and sb is ab.
The consensus theorem says the extra term changes nothing: s'a + sb + ab = s'a + sb. It adds no 1 to the map, yet it holds the output across the change.
Minimum cover
assign y = (~s & a) | (s & b);
Synthesized on this site: 1 cell, a mux. As gates with delays, it glitches when s falls.
With the consensus term
assign y = (~s & a) | (s & b)
| (a & b);
Synthesized on this site: the same 1 mux cell. The redundant term is gone.
Static-0 Hazards
A product of sums has the dual problem. Its sum terms are groups of 0s. Where two of them touch without overlapping, a steady 0 can rise to 1 for a moment.
The fix is the dual: add the consensus sum, here (a + b). With a = b = 0 it stays 0 and holds the output at 0.
Asked in interviews
What is a static hazard?
A glitch on an output that should stay constant. Two paths from one input have different delays, so for a moment neither term holds the output. Static-1 drops a 1; static-0 raises a 0.
How do you remove a static-1 hazard from a sum of products?
Find two groups on the K-map that touch across one variable but do not overlap. Add their consensus term, which covers both cells and does not depend on that variable.
Why does a minimizer not keep hazard covers?
The consensus term is logically redundant, so a minimizer or a synthesis tool removes it. Glitches that matter are handled by design style: register the signal, or never use combinational logic as a clock or reset.
Try It
Both muxes get a = b = 1, so both should show 1 all the time.
When s falls, the plain mux drops to 0 at t = 12 and recovers at t = 13. The mux with the consensus term never moves. When s rises, neither moves.
Delete the gate g5 from mux_fixed, and the OR input that it drives, and run again. Then give the inverter #2 in place of #1: how long is the glitch now?
t=10 s falls t=12 y=0 y_fixed=1 t=13 y=1 y_fixed=1 t=20 s rises t=30 doneRead included file: tb.sv
// tb.sv: a = b = 1, so both muxes must give y = 1 whatever s does (read-only).
`timescale 1ns/1ns
module tb;
logic a = 1, b = 1, s = 1;
wire y, y_fixed;
mux_gates u1 (.a(a), .b(b), .s(s), .y(y));
mux_fixed u2 (.a(a), .b(b), .s(s), .y(y_fixed));
always @(y or y_fixed) if ($time > 5) $display("t=%0d y=%b y_fixed=%b", $time, y, y_fixed);
initial begin
#10 s = 0; $display("t=10 s falls");
#10 s = 1; $display("t=20 s rises");
#10 $display("t=30 done");
end
endmodule
Check Yourself
Common Mistakes
Wrong Assume the minimum cover is always the best circuit.
The minimum cover of the mux glitches. The term that removes the glitch is the one a minimizer throws away.
Fix Where a glitch matters, keep the consensus terms that bridge touching groups.
Wrong Expect an RTL simulation to show the glitch.
With no gate delays every path takes zero time, so assign y = s ? b : a; never glitches in simulation.
Fix Study hazards on a gate netlist with delays, as in the lab.
Wrong Add any extra term that covers the two cells.
A term that also covers a 0 of the map changes the function.
Fix Use the consensus term: drop the changing variable and keep the other literals of both groups.
Wrong Trust synthesis to keep a hand-added consensus term.
The term is logically redundant. The site's synthesis turned the mux with and without it into the same single mux cell.
Fix Make glitch-sensitive signals glitch-free by design, for example from a flip-flop.
Remember
- A static hazard is a glitch on an output that should stay constant, caused by two paths with different delays.
- On a K-map, a static-1 hazard can sit between two touching groups that share no cell.
- The consensus term (drop the changing variable, AND the rest) bridges them and adds no new 1.
- Products of sums have static-0 hazards; the dual consensus sum removes them.
- Minimizers and synthesis remove consensus terms, so glitch-sensitive signals need a registered or hazard-free design.