Repository navigation
Fit input values to the current bit width of their pin - #76
Merged
Merged
Conversation
An input value is kept as it was set, so it went stale when the bit width of its pin changed afterwards, e.g. a value set while the width was not fixed (a single bit) and the pin later connected to one of 8 bits. Every time step from then on inherited the stale value, so the simulation failed in every attempt to play, and the value could not be fixed either, since the editor of an input value takes the width from the value itself. Fit the value to the current bit width of the pin when it is read: keep it if it fits, padding or dropping leading zeros, and start over from zero otherwise. `createEditorStore` is exported so that the editor store can be tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with
|
| Latest commit: |
ffec66a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f18f1ac7.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev |
| Branch Preview URL: | https://fix-stale-input-values.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev |
The editor fits the values it feeds to the input pins of the simulated component to the width the simulation assumes for a pin the circuit leaves open. Both hard-coded it as 1, so changing one of them would have brought back the mismatch fixed in the previous commit. Define it once as `DEFAULT_SIMULATION_BIT_WIDTH`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test of simulating a circuit whose input got wider fixed the width with a display, which does not check the width of its input, so the simulation succeeded even with the stale value. Fix the width with an And of the input and a constant instead, which fails on operands of different widths as the reported circuits did. Also restore the stubbed `ResizeObserver` after the tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
An input value is kept as it was set, so it goes stale when the bit width of its pin changes afterwards. For example, a value set while the width of an input was not fixed yet is a single bit, and stays one after the input is connected to a pin of 8 bits. Every later time step inherits the stale value, so every attempt to play fails and falls back to edit mode, and the value cannot be fixed in play mode either, since the editor of an input value takes the width from the value itself.
getInputValue: keep it if it fits, padding or dropping leading zeros withfitSimulationValue, and start over from zero otherwise. The stored values are left as they are, so nothing is written to the store during simulation.DEFAULT_SIMULATION_BIT_WIDTHinstead of being hard-coded as 1 on both sides.Testing
src/pages/edit/Editor/store/slices/core/index.test.ts, which fails without the change: a value set before the width was fixed is fitted (and inherited by later time steps), a value that does not fit starts over from zero, and a circuit ANDing such an input with an 8-bit constant simulates without the "Input lengths must match" error it used to fail with.createEditorStoreis exported for the test, andResizeObserver, which the perspective slice constructs, is stubbed there and restored afterwards.🤖 Generated with Claude Code