How SubCircuits are implemented?
Contributing author: @shubhankarsharma00
Subcircuits are self-contained circuits that appear as "black boxes" in other circuits. A given subcircuit may be used any number of times at multiple levels just as long as it does not become a subcircuit of itself i.e. no circular dependency.
When a user tries to add a subcircuit to a circuit a prompt is presented to him and after he selects the circuit he wants to include in as a subcircuit, a call to SubCircuit
constructor is made with the id
= scope of the circuit that is being included and scope
= circuit in which we are drawing the subcircuit. SubCircuit class extends from CircuitElement
which means undefined x and y will make the element follow the mouse movement before it is dropped into position.
Once the SubCircuit is drawn onto the canvas we check for 3 errors:
- Cyclic dependency.
- If there are no Input/Output nodes.
- If the subCircuitScope(the actual circuit which we are trying to add into the current circuit) exists.
If all the above conditions do not cause any error the we proceed further and in the constructor, we call scheduleBackup
function on the subCircuitScope to generate data for the subCircuit's scope in JSON. This data is then used in next 2 function calls : buildCircuit()
and makeConnections()
buildCircuit
loads all the data of the subCircuitScope and draws all its nodes and makeConnections
connects all these nodes wirelessly. This makes a whole connected circuit onto the current circuit but without actually drawing wires.
Loading Subcircuits:
While loading circuits with Subcircuits we can pass in savedData
argument during the SubCircuit
constructor call in loadScope()
made in the main load()
function which will draw the subcircuit according to the given data.
CircuitVerse is a web-based simulation software for creating and testing digital circuits. The easy drag and drop feature makes it easier and a fun way to learn about logic circuits and also compatible to be used by teachers as well as students. From simple gates to complex sequential circuits, plot timing diagrams, automatic circuit generation, explore standard ICs, and much more, CircuitVerse has got you covered. It also lets the user store and access the previously built circuits to build yet more complex circuits and generate truth tables for the constructed circuits.
- Home
- Running the server
- Simulator
- Development
- Internationalization (I18n)
- GSoC '19
- GSoC '20
- GSoC '21
- GSoC '22
- GSoC '23
- GSoC '24
- GCI 2019
- Google Season of Docs 2020