Repository navigation
Simulate a flattened netlist of the component - #67
Merged
Merged
Conversation
Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with
|
| Latest commit: |
76cd1d0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3ed9e62a.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev |
| Branch Preview URL: | https://netlist-simulation.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev |
Rn86222
force-pushed
the
netlist-simulation
branch
2 times, most recently
from
November 14, 2026 01:49
b4ee612 to
83b396a
Compare
Add a revision counter to CCStore that increases on every change to the circuit (components, component pins, node registration and config, node pins, connections). Moving a node does not change the circuit, so it does not count. Anything derived from the circuit can be cached against this number. Extracted from 788b5c9 (WIP: netlist-based simulation). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the recursive per-component evaluation with a netlist built from the store: the component hierarchy is flattened into intrinsic node instances, pins carrying the same value are grouped into nets, and the instances are sorted so that each one is evaluated after its drivers. Intrinsic components can now be marked as sequential. A sequential instance (the FlipFlop) derives its outputs from the previous time step, so it does not wait for its inputs, which lets a circuit contain a feedback loop through it, including one that runs through a user-defined component. A loop without one is reported as a SimulationCombinationalLoopError instead of hanging, and an unconnected input pin as a SimulationUnconnectedPinError. The netlist is cached against the store revision, and the editor keys its frame cache on the revision and the input values only. Extracted from 788b5c9 (WIP: netlist-based simulation). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the circuit cannot be simulated, for example because a loop has no flip-flop to break it or an input pin is unconnected, keep the error message in the editor store, switch back to edit mode and show the message in a snackbar. A failed circuit is not simulated again until it or its input values change, or the editor mode is switched. Extracted from 788b5c9 (WIP: netlist-based simulation). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The evaluation functions of the intrinsic components were still written against the per-component frames of the old simulation, so the netlist simulation wrapped every instance in a frame holding that one node, let the function write its outputs into it and read them back. Replace `evaluate` and `isSequential` with a `behavior` that is either combinational, computing the outputs from the current inputs, or sequential, computing them from the inputs of the previous time step. A sequential behavior cannot see the current inputs at all, since it is evaluated before they are known. Input and Output have no behavior, as they are resolved away while flattening. The simulation now hands the input values grouped by pin key to the function and writes the returned values to the nets. Errors thrown while evaluating are rethrown with the instance they come from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now that the evaluation functions are pure, cover each intrinsic on its own: the bitwise operators, the constants, Aggregate/Decompose/Broadcast, the AndN/OrN reductions, the initial value of the FlipFlop, and which intrinsics are sequential or have no behavior at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow #63 in the netlist module, which was added after the rest of the codebase had been migrated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rn86222
force-pushed
the
netlist-simulation
branch
from
November 14, 2026 01:51
83b396a to
76cd1d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rework the simulation so that a circuit can contain a feedback loop through a flip-flop, including one that runs through a user-defined component.
The first three commits are taken from the WIP commit 788b5c9 on
wip-simulation-netlistby @chelproc, split by concern. The change that disables pin property editing outside edit mode is left there.src/store/netlist.ts). The netlist is cached against a new store revision counter.SimulationCombinationalLoopError) and an unconnected input pin (SimulationUnconnectedPinError) instead of hanging, and show the error in the editor, falling back to edit mode.evaluateandisSequentialare replaced with abehaviorthat is eithercombinational(from the current inputs) orsequential(from the inputs of the previous time step, without access to the current ones). Input and Output have no behavior, as they are resolved away while flattening.Testing
src/store/simulation.test.ts) and the evaluation of each intrinsic (src/store/intrinsics/definitions.test.ts);tscand the tests pass on every commit.🤖 Generated with Claude Code