Digital-Logic-Sim
Digital-Logic-Sim copied to clipboard
0 and 1 fixed constants, and convergence fix
When creating a chip that you require, for instance, a constant 1 input, (e.g. increment by 1, for the program counter) it would be nice to have it inside the chip, and not providing it from the outside. After all, this is a logic sim, we aren't supposed to give the "power and ground" (Metaphorical, don't kill me in comments) Also, trying to create a chip with a not gate inside not connected to anything causes the chip to not work at all, prob. due to some convergence error.
For this last point, the program could simply deny the creation of new CIs without all wires connected, with will be possible if the constants are added.
Chip not working at all: https://gyazo.com/17ac3c4fb3e6000df8f14ac8e24cf794 Wiring: https://gyazo.com/731c19e0b373065dbb2fbd07d15588cd
Possible solution: Wire ANY of the inputs to this blocks* to create constant 1 and constant 0. We just have to agree, it looks ugly and use more computational power then needed. *https://gyazo.com/5304f12c8e20eb99c5e911493152ef53
The issue rises from an optimization, the updating of signals isn't checked every frame for every pin, rather it's only updated when an output signal changes (or an input pin) and by default, all pins are 0. When a chip is added to the current workspace, all the pins are set to 0, and any input pins can ripple inside the chip. As such, a non-native constant needs some input.
Using this knowledge, here is a constant 0
With this, you can invert it to get a constant 1
Both of these work as expected
You need to somehow connect these inputs to a top-level input, otherwise they will never be updated, and cause the same kind of non-fatal input you experienced when sending any input to a NOT gate. This also applies to connecting a constant into a constant. You need it to some chip that does NOT use a constant. In an actual circuit, you can just connect it to some input directly, it doesn't need a dedicated input.
Here is an example of a NOT gate, even though these is one built in (and this circuit does use them a couple times deep down)
This image demonstrates the constants do not break all circuitry, and don't need a dedicated dummy pin