Add gate watcher API to observe gate state changes during simulation

This commit is contained in:
Stone_Red
2026-03-25 13:14:06 +01:00
parent 3928524c32
commit b1b71a2392
3 changed files with 89 additions and 3 deletions
+10
View File
@@ -35,6 +35,16 @@ internal static class Program
sim.ConnectGates(a, inv2.Inputs[0], toInputBit: 0);
sim.ConnectGates(inv2.Outputs[0], lamp, toInputBit: 0);
int httpSink = sim.AddGate(GateKind.Sink);
sim.ConnectGates(inv2.Outputs[0], httpSink, toInputBit: 0);
using var httpWatcher = sim.WatchGate(httpSink, (gateId, mask) =>
{
if ((mask & 1) != 0)
{
Console.WriteLine($"HTTP gate {gateId} fired at mask={mask:X}");
}
});
sim.SetSource(a, value: false);
sim.RunUntilStable();
Console.WriteLine($"A=0 => Lamp={sim.GetOutput(lamp)} (expected False)");