
If a wire is left open (like w4) it’s only used to show the output of its gate by its color. Wires form a path defined by a tuple of (x,y) points starting from an output and ending at an input of one or more gates. Wires connect a single output from a switch or gate to zero or more inputs of other gates. The Nand and Inv gates are similar but they are not given initial output values. The two switches s1 and s2 each carry their name, a center position, a scale factor (more later), and an initial setting at startup.

#NAND X WIRE NAMES SIMULATOR#
# circ1.pyįrom simulator import Text, Swt, Nand, Inv, Wire, gameLoop A single font (courier) is used in a single point size. Here once again is the starting configuration for circ1.Īt the top of circ1.py the 8 text blocks are defined with a center position and a string for the text.

This project uses a 300x300 pixel window. The origin of the window (0,0) is at the upper-left corner. The center position of each object in given in pixels. The common attributes for each are position in window, a scaling for size, and a name.
#NAND X WIRE NAMES CODE#
code for circ1.pyĪll of the objects in the animation are built from classes defined in simulator.py and consist of text blocks, switches, nand gates, inverters, and wires. Looking at the simplest circuit (circ1.py) pretty much shows how things work for the other 4 circuits as well. A import zg.py simplfies access to the Zelle graphics for the simulator. You can access the code for the simulator here. When complete the circuit is passed to the simulator program also written in python. $ python circ5.py delay=.1Įach of the circuits above are built as python programs that descibe the circuit as a set of linked objects (components, switches and wires). 01 seconds but you might find 1/10 second better with a bit of slow motion.

Play with this using different wait times between activations. Clicking it off turns off the oscillation. But the next thing to happen is for the output of N1 to go low as well as w2 and the input to I1. In the figure notice that the short wire feeding I2 is low (blue). Positive feedback can hold a signal but negative feedback can introduce instability. Run circ2.py and click each high and low (and back) and see how the output on w4 changes. The output at w4 is high (red) if either or both switches S1 and S2 are high. The inputs are inverted before processing by the Nand gate (N1). It also has 2 levels of negation that cancel each other out. This circuit (circ2.py) is similar to circ1.py. You can close the image by clicking the x in the upper right corner. w4 should be red (1) only if both S1 and S2 are red.Īnd click the switches to change what the wires show. Wire w4 simply is there to show the output of I1 and therefore the output of the circuit. Together N1 and I1 create an AND circuit. In the image this is not the case so wire w3 (not labeled) receives 1 and passes it to the input of inverter I1. The output of N1 is 0 if and only if both of its inputs are 1. In turn these wires feed the inputs of the NAND gate N1. Switch S1 outputs to wire w1 and S2 to wire w2. Click it again and it returns to red (1). Click the mouse on a switch thats red and it changes to blue and also sets its output wire to blue (0). The switches are toggled to change their state.
#NAND X WIRE NAMES PLUS#
The wires can be at either zero volts (false or 0) or plus five volts (true or 1).

It is organized so that signals flow from left to right. In image 1 we have switches (S1 and S2) along with NAND gate N1, and inverter I1, connected together with four wires.
