FAILURE MAP
← Case archive

FA-89216 / Digital logic simulation / Open access

Glitch reference reset at every cycle boundary · case 01

Total energy counts transitions from the initial value at each cycle start instead of from the last event.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The event reference is reinitialized per cycle.

VERIFIED REPAIR

Carry the last event value across cycle boundaries.

Unsuccessful approach: Seeding each cycle with its own first value silently drops the first transition of every cycle.

Case contract

Input [init, waves, cap]: waves[net] is a list of cycles, each a list of sub-cycle values ('0','1','x'). A 0<->1 change costs 2 half-toggles, a change to or from x costs 1, no change 0. Total energy sums half-toggles times cap over every event, comparing each event with the previous event on that net (across cycle boundaries). Functional energy compares only the last value of each non-empty cycle with the previous such value. Nets without a cap entry are unloaded (cap 0). Return [functional, total].

Why this case matters

Power estimation from simulation activity separates functional toggles from glitch toggles; mis-counting either skews dynamic power reports.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(*args):
    init, waves, cap = args
    def ht(a, b):
        if a == b: return 0
        if 'x' in (a, b): return 1
        return 2
    func = tot = 0
    for net in sorted(waves):
        c = cap.get(net, 0)
        ref = fref = init[net]
        for cyc in waves[net]:
            ref = init[net]
            for v in cyc:
                tot += ht(ref, v) * c
                ref = v
            if cyc:
                func += ht(fref, cyc[-1]) * c
                fref = cyc[-1]
    return [func, tot]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0']]}, {'h': 1}], [2, 6]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 1}], [3, 5])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [6, 10]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 2}], [6, 10])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [10, 14]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 3}], [9, 15])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [14, 18]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 4}], [12, 20])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [18, 22]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 5}], [15, 25])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
full toggles and unknown transitions[15, 12][15, 15]Failed
glitch inside a cycle[4, 24][4, 20]Failed
cross-cycle glitch reference[2, 6][2, 6]Passed
unloaded net[20, 10][20, 20]Failed
empty cycles keep reference[16, 16][16, 32]Failed
from unknown initial value[3, 4][3, 5]Failed

SHA-256 / 476e5d663fe3f3746415c1d30ffbbf267f104b8faafcc60ec0bbcdede81d5225

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(*args):
    init, waves, cap = args
    def ht(a, b):
        if a == b: return 0
        if 'x' in (a, b): return 1
        return 2
    func = tot = 0
    for net in sorted(waves):
        c = cap.get(net, 0)
        ref = fref = init[net]
        for cyc in waves[net]:
            ref = cyc[0] if cyc else ref
            for v in cyc:
                tot += ht(ref, v) * c
                ref = v
            if cyc:
                func += ht(fref, cyc[-1]) * c
                fref = cyc[-1]
    return [func, tot]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0']]}, {'h': 1}], [2, 6]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 1}], [3, 5])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [6, 10]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 2}], [6, 10])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [10, 14]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 3}], [9, 15])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [14, 18]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 4}], [12, 20])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [18, 22]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 5}], [15, 25])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
full toggles and unknown transitions[15, 0][15, 15]Failed
glitch inside a cycle[4, 12][4, 20]Failed
cross-cycle glitch reference[2, 2][2, 6]Failed
unloaded net[20, 0][20, 20]Failed
empty cycles keep reference[16, 8][16, 32]Failed
from unknown initial value[3, 2][3, 5]Failed

SHA-256 / b6208461827098205c302cc130f7eb34841a8b7763baaf1f441deb3469d94b48

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(*args):
    init, waves, cap = args
    def ht(a, b):
        if a == b: return 0
        if 'x' in (a, b): return 1
        return 2
    func = tot = 0
    for net in sorted(waves):
        c = cap.get(net, 0)
        ref = fref = init[net]
        for cyc in waves[net]:
            for v in cyc:
                tot += ht(ref, v) * c
                ref = v
            if cyc:
                func += ht(fref, cyc[-1]) * c
                fref = cyc[-1]
    return [func, tot]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0']]}, {'h': 1}], [2, 6]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 1}], [3, 5])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [6, 10]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 2}], [6, 10])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [10, 14]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 3}], [9, 15])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [14, 18]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 4}], [12, 20])], [('full toggles and unknown transitions', [{'a': '0'}, {'a': [['1'], ['x'], ['0'], ['x']]}, {'a': 3}], [15, 15]), ('glitch inside a cycle', [{'g': '0'}, {'g': [['1', '0'], ['1', '0', '1'], ['1'], ['1'], ['1'], ['1'], ['1']]}, {'g': 2}], [4, 20]), ('cross-cycle glitch reference', [{'h': '1'}, {'h': [['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0'], ['0', '1'], ['0']]}, {'h': 1}], [18, 22]), ('unloaded net', [{'a': '0', 'u': '0'}, {'a': [['1'], ['0']], 'u': [['1'], ['0'], ['1']]}, {'a': 5}], [20, 20]), ('empty cycles keep reference', [{'e': '0'}, {'e': [['1'], [], ['0', '1'], [], ['0'], ['0'], ['0'], ['0'], ['0']]}, {'e': 4}], [16, 32]), ('from unknown initial value', [{'k': 'x'}, {'k': [['0'], ['1', 'x', '1']]}, {'k': 5}], [15, 25])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
full toggles and unknown transitions[15, 15][15, 15]Passed
glitch inside a cycle[4, 20][4, 20]Passed
cross-cycle glitch reference[2, 6][2, 6]Passed
unloaded net[20, 20][20, 20]Passed
empty cycles keep reference[16, 32][16, 32]Passed
from unknown initial value[3, 5][3, 5]Passed

SHA-256 / d3411b768528e256438611c5e9f662ba8e5ac35c349ee9564fa8fe35b84f189b

Verification & scope

A deterministic bounded teaching model of one simulator rule set; the contract is stipulated and is not a claim of conformance to any HDL standard or commercial simulator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:15.359519+00:00.

Case digest / d4c69540a7e710fa6c0dbc621efc506671cbffc70f50ec83a89fa0f81ca38915