FAILURE MAP
← Case archive

FA-89211 / Digital logic simulation / Open access

Functional toggle taken from the first value of a cycle · case 01

Glitchy cycles report functional activity based on a transient value rather than the settled value.

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

ROOT CAUSE

Functional activity compares the first sub-cycle value instead of the settled last value.

THE FAILURE

Functional activity compares the first sub-cycle value instead of the settled last value.

Unsuccessful approach: Picking the middle event is still a transient value.

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]:
            for v in cyc:
                tot += ht(ref, v) * c
                ref = v
            if cyc:
                func += ht(fref, cyc[0]) * 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[8, 20][4, 20]Failed
cross-cycle glitch reference[4, 6][2, 6]Failed
unloaded net[20, 20][20, 20]Passed
empty cycles keep reference[24, 32][16, 32]Failed
from unknown initial value[3, 5][3, 5]Passed

SHA-256 / adb6fcfb948c7765b1eac88f59fc9ca8d8c90b33746c7749db5c20bb7f250c96

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]:
            for v in cyc:
                tot += ht(ref, v) * c
                ref = v
            if cyc:
                func += ht(fref, cyc[len(cyc) // 2]) * 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[0, 20][4, 20]Failed
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[2, 5][3, 5]Failed

SHA-256 / 89b397889a6f79cb127aa6339bb1b30a842026af8f6f7c486147b796946057fa

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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.397870+00:00.

Case digest / f8bd5e0412b8514740974081f0ec78a7f337ad669f27a38f597bb9eb1a0e60b8