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.

s Falls at t = 10 with a = b = 1One column per gate delay, from t = 9 to t = 13.
01234st1 = sbns = s't0 = s'ayglitch
Scroll horizontally ↔
  1. Cycle 1

    s falls at t = 10.

  2. Cycle 2

    One gate delay later, t1 has fallen. ns has risen, but t0 has not seen it yet.

  3. Cycle 3

    Both product terms are 0 at t = 11, so the OR gate drops y at t = 12.

  4. Cycle 4

    t0 rose at t = 12, so y is 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.

A Mux That Glitches
A Mux That Glitchesg0 · NOTns=1g1 · ANDt0=1g2 · ANDt1=0g3 · ORy=1a=1b=1s=0
a=1 b=1 s=0
g0 · NOTs=0 → ns=1
g1 · ANDa=1, ns=1 → t0=1
g2 · ANDb=1, s=0 → t1=0
g3 · ORt0=1, t1=0 → y=1
Read the connections
GateKindInputsOutput
g0NOTsns
g1ANDa, nst0
g2ANDb, st1
g3ORt0, t1y

Outputs: y. MUX inputs: d0, d1, select. Latch/flip-flop inputs: data, enable/clock. Unknown values are marked x; high impedance is folded into x in this model.

Gate delay 13. Settled after 13 gate delays from t = 0.

Output values at each gate delay012345678910111213yxx111111111101
Scroll horizontally ↔
Every computed frame
Timey
0x
1x
21
31
41
51
61
71
81
91
101
111
120
131

  1. Step 10 · s falls at 10. The AND gate t1 sees `s` at once. The other AND gate waits for the inverter.
  2. Step 11 · A gap. `t1` has fallen, but `ns` has only just risen. For one gate delay both AND gates give 0.
  3. Step 12 · The glitch. The OR gate passes the gap on: `y` drops to 0 at 12.
  4. Step 13 · Back to 1. `t0` is now 1, so `y` returns to 1 at 13. The output should never have moved.

Unit delays. a = b = 1, so y = 1 whichever input s selects. Click s and step again: s rising does not glitch.

Two Paths from s to yArrows show where a change of s travels. Each box is one gate delay.
  • I/O
  • Datapath
  • Data
Two paths from s to yArrows show where a change of `s` travels. Each box is one gate delay. io s falls t = 10 datapath NOT ns rises at 11 datapath AND sb t1 falls at 11 datapath AND s'a t0 rises at 12 datapath OR sees 0, 0 at 11 long pathshort path
  1. io s fallst = 10
    • long path → NOT
    • short path → AND sb
  2. datapath AND sbt1 falls at 11
    • OR
  3. datapath ORsees 0, 0 at 11
  4. datapath NOTns rises at 11
    • AND s'a
  5. datapath AND s'at0 rises at 12
    • OR
  1. Short path

    One gate delay after s falls, t1 is already 0.

  2. 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.

y = s'a + sb
sa / b01
00
01
11
10

~s & a | s & b

Minimum SOP: 2 terms · 4 literals.

  1. The minimum cover. Two groups: s'a and sb. Cell 011 is in s'a only; cell 111 is in sb only.
  2. The jump. When `s` changes with a = b = 1, the function moves between 011 and 111. No single group holds both cells, so the output depends on which term moves first.
  3. The bridge. The group ab covers both cells. It does not depend on `s`, so it stays 1 during the change.

Cells are numbered sab. The third group adds no new 1 to the map.

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.

The Consensus Gate Holds y
The Consensus Gate Holds yg0 · NOTns=1g1 · ANDt0=1g2 · ANDt1=0g3 · ANDconsensus=1g4 · ORy=1a=1b=1s=0
a=1 b=1 s=0
g0 · NOTs=0 → ns=1
g1 · ANDa=1, ns=1 → t0=1
g2 · ANDb=1, s=0 → t1=0
g3 · ANDa=1, b=1 → consensus=1
g4 · ORt0=1, t1=0, consensus=1 → y=1
Read the connections
GateKindInputsOutput
g0NOTsns
g1ANDa, nst0
g2ANDb, st1
g3ANDa, bconsensus
g4ORt0, t1, consensusy

Outputs: y. MUX inputs: d0, d1, select. Latch/flip-flop inputs: data, enable/clock. Unknown values are marked x; high impedance is folded into x in this model.

Gate delay 12. Settled after 12 gate delays from t = 0.

Output values at each gate delay0123456789101112yxx11111111111
Scroll horizontally ↔
Every computed frame
Timey
0x
1x
21
31
41
51
61
71
81
91
101
111
121

  1. Step 11 · The same gap. `t0` and `t1` are both 0 at 11, as before.
  2. Step 12 · No glitch. The third AND gate, ab, is 1 the whole time, so `y` stays 1.

The hazard-mux-consensus preset: the same mux with ab added.

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
  1. 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.

  2. 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.

  3. 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?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: t=10 s falls t=12 y=0 y_fixed=1 t=13 y=1 y_fixed=1 t=20 s rises t=30 done
Read 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

ConceptA function is 1 on both sides of a single input change. On which K-map pattern can a static-1 hazard occur?
ConceptWhat is the consensus of the terms xy' and yz?
ConceptWhy does the consensus term not change the function?
Read the waveformThis trace comes from a product-of-sums circuit whose function is 0 before and after the change of x. What happened?
One input change
01234xy
Scroll horizontally ↔

One column per gate delay.

Predict the outputIn the hazard mux, the inverter now has #2. With a = b = 1, s falls at t = 10. Predict the exact line.
`timescale 1ns/1ns
module tb;
  logic a = 1, b = 1, s = 1;
  wire  ns, t0, t1, y;
  not #2 g1 (ns, s);
  and #1 g2 (t0, a, ns);
  and #1 g3 (t1, b, s);
  or  #1 g4 (y, t0, t1);
  time fell, rose;
  always @(negedge y) if ($time > 5) fell = $time;
  always @(posedge y) if ($time > 5) rose = $time;
  initial begin
    #10 s = 0;
    #10 $display("y low from t=%0d to t=%0d", fell, rose);
  end
endmodule

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.

Practice

Report a problem with this page