Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change number of bits after gate initialization #2

Open
ialokim opened this issue Jan 24, 2020 · 1 comment
Open

Change number of bits after gate initialization #2

ialokim opened this issue Jan 24, 2020 · 1 comment

Comments

@ialokim
Copy link
Contributor

ialokim commented Jan 24, 2020

As the GateView and the gate's functionality currently seems to be defined once during initialization, I assume there is no way to change the number of (input or output) bits of some gate afterwards. Is that correct?

If so, do you have some idea where and how this functionality could be added? I would like to look into it, as we would like to use your library with this possibility.

@tilk
Copy link
Owner

tilk commented Jan 25, 2020

Changing the gate's input/output characteristics is currently not possible, as it risks leaving the circuit in some weird, inconsistent state, and breaking the simulation.
Backbone.js, the library used by JointJS and DigitalJS for representing graphs, allows to listen to changes of model attributes. If I was adding a feature like this, I would add listeners to relevant attributes, which would respond by fixing up the graph so that it is still consistent after the change. If changing the number of bits, this would probably require disconnecting every connection to the changed input/output. (Another possibility would be to allow the invalid connection, but have the simulation detect it and display the problem in the UI in some way.) One would also need to ensure that the view gets re-rendered.
As this is a functionality which seems bug-prone, tests would need to be added to verify correctness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants