Chapter 21 of 32

Hazards in Combinational Circuits

Up to now we have treated logic gates as perfect: change an input and the output instantly becomes the value the truth table says. Real gates are not like that. Every gate takes a few nanoseconds (or picoseconds) to respond, and different paths through a circuit have different delays. Because of this, a circuit whose output should stay at 1 can briefly drop to 0 for a few nanoseconds when an input changes. That short, unwanted pulse is called a glitch, and the circuit condition that allows it is called a hazard.

Glitches look harmless, but if the glitching signal drives a clock input, an asynchronous clear, a chip-select line or a latch enable, the circuit can lose data or count an extra pulse. In this chapter we learn why hazards happen, how to spot them on a Karnaugh map in seconds, and how to remove them by adding a deliberately "redundant" term. This builds directly on Karnaugh Maps and the consensus theorem from Boolean Algebra Laws.

A hazard is a condition in a combinational circuit where, because of unequal propagation delays along different paths, the output can momentarily take a wrong value (a glitch) while the inputs change, even though the steady-state output is correct.

Every hazard, K-map and fix in this chapter was checked with a Python script that searches all adjacent minterm pairs, and the glitches were reproduced in a Verilog gate-level simulation with Icarus Verilog. The outputs shown are real.


Why Glitches Happen: Propagation Delay

Every gate has a propagation delay tpd: the time between an input change and the resulting output change. When one input signal reaches the output through two paths, and one path contains an extra inverter, the two copies of that signal arrive at different times. For a short window the circuit "sees" a combination of old and new values that never exists in the truth table.

The simplest possible example is F = A + A′. Logically it is always 1. But build it with a NOT gate and an OR gate:

A ---------------------+
                       |    +------+
                       +--->|      |
                            |  OR  |----> F
A ---->[ NOT ]--- A′ ------>|      |
                            +------+

A falls 1 → 0 at time t:
  direct input of OR becomes 0 at time t
  A′ becomes 1 only at time t + t_pd(NOT)
  → between t and t + t_pd(NOT), both OR inputs are 0, so F dips to 0

So F goes 1 → 0 → 1 even though it should stay at 1. The width of the glitch is roughly the delay difference between the two paths.


Types of Hazards

Type

Correct behaviour

Possible wrong behaviour

Typical cause

Static-1 hazard

Output should stay 1

1 → 0 → 1

SOP (AND-OR) circuit; two adjacent 1s covered by different product terms

Static-0 hazard

Output should stay 0

0 → 1 → 0

POS (OR-AND) circuit; two adjacent 0s covered by different sum terms

Dynamic hazard

Output should change once (0 → 1 or 1 → 0)

0 → 1 → 0 → 1 or 1 → 0 → 1 → 0

Multi-level circuits where one input reaches the output through three or more paths with different delays

Two more terms you will see in books:

  • Logic hazard: a hazard caused by the particular way the function is implemented. It can be removed by changing the circuit (adding terms). Static and dynamic hazards for a single input change are logic hazards.

  • Function hazard: occurs when two or more inputs change at the same time and the function itself has a different value at some intermediate input combination. No choice of gates can remove it; it must be avoided by design (for example, by making sure only one input changes at a time, or by sampling the output with a clock).

A word about "hazard" versus "glitch": a hazard means a glitch is possible. Whether it actually appears depends on the exact gate delays, wire lengths and temperature. A circuit with a hazard may work on the bench and fail on another board, which is exactly why designers remove hazards on paper instead of relying on luck.


Static-1 Hazards in SOP Circuits

Consider the function used inside a 2-to-1 multiplexer (see Multiplexers): F = AB + A′C. When A = 1 the output follows B, and when A = 0 it follows C.

A

B

C

F = AB + A′C

0

0

0

0

0

0

1

1

0

1

0

0

0

1

1

1

1

0

0

0

1

0

1

0

1

1

0

1

1

1

1

1

So F = Σm(1, 3, 6, 7). Now set B = C = 1 and let A fall from 1 to 0. Before the change F = AB = 1; after it F = A′C = 1. The output should stay 1. But:

  1. A falls. After one AND delay, the term AB falls to 0.

  2. A′ must first pass through the NOT gate, so the term A′C rises one NOT delay later.

  3. For that short interval both product terms are 0, so the OR output drops to 0. That is a static-1 hazard.

Spotting It on the K-Map

            BC
          00   01   11   10
        +----+----+----+----+
 A = 0  |  0 |  1 |  1 |  0 |      group A′C = m1, m3
        +----+----+----+----+
 A = 1  |  0 |  0 |  1 |  1 |      group AB  = m7, m6
        +----+----+----+----+
                    ↑
         m3 (011) and m7 (111) are adjacent 1s,
         but no single group contains both  → static-1 hazard

Rule for SOP circuits: a static-1 hazard exists wherever two adjacent 1-cells on the K-map are not covered by a common product term. The changing variable is the one that differs between the two cells.

Here m3 = 011 and m7 = 111 differ only in A, so the hazard appears when A changes while B = C = 1, exactly as we reasoned.

The Fix: Add the Consensus Term

Add a group that bridges the two cells: m3 and m7 together form BC.

F = AB + A′C + BC

BC is the consensus of AB and A′C, and the consensus theorem (XY + X′Z + YZ = XY + X′Z) tells us that adding it does not change the function. Logically it is redundant; electrically it is essential. While B = C = 1, the term BC stays at 1 no matter what A is doing, so the OR output is held at 1 throughout the transition.

Notice the trade-off: the hazard-free circuit uses one more AND gate and a 3-input OR gate. A minimal SOP is not always hazard-free.

Seeing the Glitch in Simulation

Here is the circuit in SystemVerilog, built from gate primitives where every gate has a 2 ns delay, next to the fixed version:

`timescale 1ns/1ns
// F = AB + A'C  built from gates, every gate has a 2 ns delay
module mux_hazard(input logic A, B, C, output logic F);
  logic An, t1, t2;
  not #2 g0(An, A);
  and #2 g1(t1, A, B);
  and #2 g2(t2, An, C);
  or  #2 g3(F, t1, t2);
endmodule

// Same function with the consensus term BC added
module mux_fixed(input logic A, B, C, output logic F);
  logic An, t1, t2, t3;
  not #2 g0(An, A);
  and #2 g1(t1, A, B);
  and #2 g2(t2, An, C);
  and #2 g4(t3, B, C);
  or  #2 g3(F, t1, t2, t3);
endmodule

module tb;
  logic A, B, C;
  logic F_hazard, F_fixed;
  mux_hazard u1(A, B, C, F_hazard);
  mux_fixed  u2(A, B, C, F_fixed);
  initial begin
    $monitor("t=%0d ns  A=%b B=%b C=%b  F_hazard=%b  F_fixed=%b", $time, A, B, C, F_hazard, F_fixed);
    A = 1; B = 1; C = 1;
    #20 A = 0;      // A falls: 1 -> 0
    #20 A = 1;      // A rises: 0 -> 1
    #20 $finish;
  end
endmodule

Output (Icarus Verilog, iverilog -g2012):

t=0 ns  A=1 B=1 C=1  F_hazard=x  F_fixed=x
t=4 ns  A=1 B=1 C=1  F_hazard=1  F_fixed=1
t=20 ns  A=0 B=1 C=1  F_hazard=1  F_fixed=1
t=24 ns  A=0 B=1 C=1  F_hazard=0  F_fixed=1
t=26 ns  A=0 B=1 C=1  F_hazard=1  F_fixed=1
t=40 ns  A=1 B=1 C=1  F_hazard=1  F_fixed=1

Read the timeline for the falling edge of A at t = 20 ns:

t = 20   A falls
t = 22   AB falls to 0 (one AND delay)    A′ rises (one NOT delay)
t = 24   OR sees AB = 0 → F falls         A′C rises (NOT + AND delay)
t = 26   OR sees A′C = 1 → F rises again
         → a 2 ns glitch on F_hazard; F_fixed never moves

Two lessons from this run. First, the fixed circuit is perfectly steady. Second, when A rises at t = 40 ns there is no glitch, because with these particular delays the new term AB turns on at t = 42 ns, before the old term A′C turns off at t = 44 ns (A′ must first fall through the inverter). One OR input is always at 1, so there is no gap. A hazard is a possibility; whether you see a glitch depends on the delays and on the direction of the change.


A 4-Variable Example with Two Hazards

Problem: F(A, B, C, D) = Σm(2, 3, 5, 7, 8, 9, 12, 13). Find the minimal SOP, find all static-1 hazards and give a hazard-free SOP.

Step 1: K-map and minimal cover.

               CD
             00   01   11   10
          +----+----+----+----+
  AB = 00 |  0 |  0 |  1 |  1 |     m0  m1  m3  m2
          +----+----+----+----+
  AB = 01 |  0 |  1 |  1 |  0 |     m4  m5  m7  m6
          +----+----+----+----+
  AB = 11 |  1 |  1 |  0 |  0 |     m12 m13 m15 m14
          +----+----+----+----+
  AB = 10 |  1 |  1 |  0 |  0 |     m8  m9  m11 m10
          +----+----+----+----+

Groups:  AC′   = m8, m9, m12, m13
         A′BD  = m5, m7
         A′B′C = m2, m3

Minimal SOP:  F = AC′ + A′BD + A′B′C

This minimal cover is unique (m2 can only be covered by A′B′C, m8 and m12 only by AC′, and covering m7 with A′CD instead of A′BD would need a fourth term for m5).

Step 2: check every pair of adjacent 1s. Go through each 1-cell and look at its neighbours that are also 1:

Adjacent pair

Changing variable

Common group?

m2, m3

D

Yes, A′B′C

m3, m7

B

No (m3 in A′B′C, m7 in A′BD)

m5, m7

C

Yes, A′BD

m5, m13

A

No (m5 in A′BD, m13 in AC′)

m8, m9 / m8, m12 / m9, m13 / m12, m13

D / B / B / D

Yes, AC′

So there are two static-1 hazards: when B changes with A = 0, C = 1, D = 1, and when A changes with B = 1, C = 0, D = 1.

Step 3: add one bridging group per hazard.

  • m3 + m7 = 0011, 0111 → A′CD

  • m5 + m13 = 0101, 1101 → BC′D

Hazard-free SOP:  F = AC′ + A′BD + A′B′C + A′CD + BC′D

Our script confirmed that this 5-term expression has exactly the same truth table as the minimal one and that every pair of adjacent 1s now shares a product term.

A simple, always-correct (but sometimes wasteful) method is to use the sum of all prime implicants: in a complete sum of primes every pair of adjacent 1s is covered by some prime implicant, so it is free of static-1 hazards for single-input changes. In practice we add only the primes needed to bridge the uncovered pairs, as we did above.


Static-0 Hazards in POS Circuits

Everything works the same way for POS circuits, using the 0s of the map. A static-0 hazard exists wherever two adjacent 0-cells are not covered by a common sum term.

Example: F = (A + B)(A′ + C). Its 0s are at m0, m1 (A = 0, B = 0) and m4, m6 (A = 1, C = 0).

            BC
          00   01   11   10
        +----+----+----+----+
 A = 0  |  0 |  0 |  1 |  1 |      (A + B)   covers m0, m1
        +----+----+----+----+
 A = 1  |  0 |  1 |  1 |  0 |      (A′ + C)  covers m4, m6
        +----+----+----+----+
          ↑
   m0 (000) and m4 (100) are adjacent 0s in different sum terms

With B = C = 0, as A changes the output should stay 0, but during the transition both sum terms can briefly be 1 together (one is turning off while the other is turning on), so the AND output can spike to 1. Fix: add the sum term covering m0 and m4, which is (B + C):

F = (A + B)(A′ + C)(B + C)

(B + C) is the dual form of the consensus term, so the function is unchanged (verified by computation).

A useful fact for exams: a two-level SOP circuit (with no product term containing both a variable and its complement) cannot have a static-0 or a dynamic hazard for a single input change; only static-1 hazards need checking. Likewise a two-level POS circuit needs only a static-0 check.


Dynamic Hazards

A dynamic hazard happens when the output is supposed to change once but changes three times (or more). For that, the changing input must reach the output by at least three paths with different delays, which normally needs a multi-level circuit (three or more levels of gates).

Here is a deliberately small circuit that shows one. It computes F = A · (A′ + Aslow), where Aslow is the same signal A arriving late through a slow path (in a real chip, a long wire or extra logic). Logically F = A, so when A rises F should go 0 → 1 exactly once.

`timescale 1ns/1ns
module dyn(input logic A, output logic F);
  logic An, As, G;
  not #1 g0(An, A);
  buf #3 g1(As, A);      // a slow path, e.g. a long wire or extra logic
  or  #1 g2(G, An, As);
  and #1 g3(F, A, G);
endmodule

module tb;
  logic A, F;
  dyn u(A, F);
  initial begin
    $monitor("t=%0d ns  A=%b  F=%b", $time, A, F);
    A = 0;
    #10 A = 1;
    #10 $finish;
  end
endmodule

Output:

t=0 ns  A=0  F=x
t=1 ns  A=0  F=0
t=10 ns  A=1  F=0
t=11 ns  A=1  F=1
t=13 ns  A=1  F=0
t=15 ns  A=1  F=1

F goes 0 → 1 → 0 → 1: a dynamic hazard. The three paths are: A directly into the AND gate (fast, turns F on at 11 ns), A through the inverter into the OR gate (medium, makes G fall and turns F off at 13 ns), and A through the slow buffer (slowest, makes G rise again and turns F back on at 15 ns). Notice that G = A′ + Aslow itself contains a static-1 hazard; dynamic hazards usually come from static hazards buried inside a multi-level circuit. The cure is the same idea: remove the static hazards in the inner levels, or rewrite the circuit as a hazard-free two-level form.


Function Hazards: When Two Inputs Change

Go back to F = AB + A′C and move from ABC = 011 (F = 1) to ABC = 110 (F = 1). Two inputs change: A rises and C falls. In real hardware they never change at exactly the same instant:

011 → 111 → 110    (A changes first)   F: 1 → 1 → 1   no glitch
011 → 010 → 110    (C changes first)   F: 1 → 0 → 1   glitch!

The glitch happens because the function itself is 0 at the intermediate point 010. No added term can fix this, not even the consensus term BC (which is 0 at 010). This is a function hazard. Designers avoid it by changing one input at a time (Gray-code sequencing, see Code Converters) or, much more commonly, by using synchronous design.


Do Hazards Matter in Real Designs?

In a synchronous system (everything clocked by flip-flops, which we meet in Flip-Flops: SR, JK, D & T), glitches on ordinary data paths are harmless: the flip-flops sample the signal only at the clock edge, after the logic has settled. The clock period is chosen to be longer than the slowest settling time, so a 2 ns glitch in the middle of a 10 ns cycle is never seen.

Hazards do matter when a combinational signal is used where every edge counts:

  • as a clock for a flip-flop or counter (gated clocks): a glitch is an extra clock edge;

  • as an asynchronous preset/clear or reset input: a glitch can clear a register;

  • as the enable of a latch (a level-sensitive memory element, introduced in the next chapter), or as a chip-select or write-enable for memory;

  • inside asynchronous sequential circuits, where the outputs feed back as inputs and a glitch can push the circuit into a wrong state. These circuits also have a third kind, the essential hazard, which comes from the feedback structure itself and is studied in advanced courses.

Remedy

How it works

Limitation

Add consensus / redundant terms

Cover every pair of adjacent 1s (SOP) or 0s (POS) with a common term

Extra gates; fixes only single-input-change logic hazards

Synchronous design

Sample outputs with a clock after they settle

Needs a clock and flip-flops; adds latency

Change one input at a time

Avoids function hazards (e.g. Gray-code counters)

Not always possible

Delay balancing / filtering

Equalise path delays, or filter narrow pulses with an RC network

Fragile; depends on process and temperature


Common Mistakes

  • Thinking a minimal SOP is automatically safe. Minimisation removes exactly the redundant terms that prevent hazards.

  • Checking only cells inside groups. The hazard is in the boundary between two groups: look for adjacent 1s that sit in different groups and share none.

  • Forgetting wrap-around adjacency. On a K-map the left and right edges (and top and bottom edges) are adjacent. Pairs like m0 and m2 or m8 and m10 count.

  • Looking for static-0 hazards in an SOP circuit (or static-1 hazards in a POS circuit). In two-level form, check 1s for SOP and 0s for POS.

  • Trying to remove a function hazard with extra terms. When two inputs change and the function itself passes through the opposite value, no logic fix exists.

  • Simplifying the fixed expression again. If you minimise AB + A′C + BC, the consensus term disappears and so does your fix.


Interview and GATE-Style Questions

What is the difference between a static-1 hazard and a dynamic hazard?

In a static-1 hazard the output should stay at 1 but momentarily goes to 0 (1 → 0 → 1). In a dynamic hazard the output should change once but changes several times (for example 0 → 1 → 0 → 1). Static hazards can occur in two-level circuits; dynamic hazards need a multi-level circuit with three or more paths of different delay.

F = A′B + AC is implemented as a two-level AND-OR circuit. Is there a hazard? If so, fix it.

Yes. With B = C = 1, as A changes, the output moves from A′B to AC, and the two terms are in different groups (m3 = 011 and m7 = 111 are adjacent but not in a common term). A static-1 hazard exists. The consensus term is BC, so the hazard-free form is F = A′B + AC + BC.

How many static-1 hazards does F = AC′ + A′BD + A′B′C have, and for which input changes?

Two. One when B changes with A = 0, C = 1, D = 1 (between m3 and m7), and one when A changes with B = 1, C = 0, D = 1 (between m5 and m13). Adding A′CD and BC′D removes both.

Why does adding a term that is "logically redundant" remove a hazard?

The redundant term covers both input combinations on either side of the transition, so it stays at 1 during the whole change. While one product term is turning off and the other is turning on, the redundant term holds the OR output at 1. It changes nothing in the truth table but changes the timing behaviour.

Can a hazard-free two-level SOP circuit still glitch? Explain.

Yes, if two or more inputs change at the same time and the function has the opposite value at some intermediate input combination. That is a function hazard, and it cannot be removed by adding terms. It is handled by allowing only single-input changes or by sampling the output with a clock.

Why are glitches usually ignored in synchronous digital systems?

Because flip-flops sample the combinational outputs only at the clock edge, and the clock period is chosen so that every path has settled (with setup time to spare) before that edge. Glitches that occur and die out between edges are never captured. Glitches matter only on signals that act immediately, such as clocks, asynchronous resets, latch enables and memory control lines.


Summary

  • A hazard is the possibility of a short wrong output (a glitch) caused by unequal delays along different paths.

  • Static-1 (1 → 0 → 1) hazards appear in SOP circuits where two adjacent 1s on the K-map are not covered by a common term; static-0 (0 → 1 → 0) hazards appear in POS circuits where two adjacent 0s are not covered by a common sum term.

  • The fix is to add the consensus group bridging each such pair: for F = AB + A′C, add BC. The function does not change, but the circuit is no longer minimal.

  • Dynamic hazards (multiple output changes) need three or more paths and appear in multi-level circuits, usually because of static hazards in inner levels.

  • Function hazards come from multiple simultaneous input changes and cannot be fixed by adding logic.

  • Synchronous design hides most glitches; hazards still matter on clocks, asynchronous resets, latch enables and in asynchronous circuits.

Next, in Latches, we take our first step into sequential circuits: we feed a gate's output back to its input and discover how a circuit can remember a bit.