Пример #1
0
    def setupGraphics(s):
        i1  = Inv(s, "I1", s.scale1((200, 50)))
        xor = Xor(s, "X1", (0, 0))
        s1  = Swt(s, "S1", (0, 0))
        s2  = Swt(s, "S2", (0, 0))

        xor.align(xor.C, i1.A, -20, 0)  # make xnor to test align
        s1.align(s1.B,  xor.A, -30, 0)
        s2.align(s2.B,  xor.B, -30, 0)

        s1.B.addWire(xor.A)
        s2.B.addWire(xor.B)
        xor.C.addWire(i1.A)
        s.gates = (s1, s2, xor, i1)
        s1.B.labelQuad = 1
        s2.B.labelQuad = 1
        s.banner = "XOR (4 Nands) plus Inverter for XNOR"
        xor.n2.A.labelQuad = 2
        xor.n2.B.labelQuad = 2
        xor.n2.C.labelQuad = 1
        xor.A.labelQuad = 2
        xor.B.labelQuad = 2
        xor.C.labelQuad = 1
        i1.A.labelQuad = 2
        i1.B.labelQuad = 1

        # wire works fine as LED
        s.led   = Connector(s, "LED", (i1.B.x(20), i1.B.y()))
        i1.B.addWire(s.led)  # works as LED
Пример #2
0
    def setupGraphics(self):
        self.banner = "Encapsulated OR circuit"
        or2 = Or(self, "O2", self.scale1((50, 30)))
        s1 = Swt(self, "S1")   # Switch feeding input A
        s2 = Swt(self, "S2")   # Switch feeding input B

        s1.align(s1.B, or2.A, -30, 0)  # line up the gates
        s2.align(s2.B, or2.B, -30, 0)
        s1.B.addWire(or2.A)
        s2.B.addWire(or2.B)
        s1.B.labelQuad = 1
        s2.B.labelQuad = 1
        self.gates = (s1, s2, or2)

        or2.n1.A.labelQuad = 3            # Label all the connectors
        or2.n1.B.labelQuad = 2
        or2.n1.C.labelQuad = 1
        or2.i1.A.labelQuad = 2            # Inverter
        or2.i1.B.labelQuad = 1
        or2.i2.A.labelQuad = 3            # Inverter
        or2.i2.B.labelQuad = 4
        or2.A.labelQuad = 1
        or2.B.labelQuad = 1
        or2.C.labelQuad = 1
        or2.C.addWire( (or2.C.x(30), or2.C.y()))  # tail to see
Пример #3
0
 def setupGraphics(s):
     s.banner = "Edge Triggered Latch. Click S1 and P1"
     el1 = ELatch(s, "EL1", s.scale1((20, 20)))
     p1 = Puls(s, "P1")
     p1.align(p1.B, el1.C, -20, 0)
     s1 = Swt(s, "S1")
     s1.align(s1.B, el1.D, -20, 0)
     p1.B.addWire(el1.C)
     s1.B.addWire(el1.D)
     el1.output.addWire((el1.output.x(20), el1.output.y()))
     s.gates = (p1, s1, el1)
Пример #4
0
 def setupGraphics(s):
     s.banner = "Testing the Data Latch"
     dl1 = DLatch(s, "DL1", s.scale1((50, 30)))
     d1 = Swt(s,  "D1")  # data switch
     c1 = Puls(s, "C1")  # pulse generator
     d1.align(d1.B, dl1.D, -30, 0)  # align each with dlatch D & C
     c1.align(c1.B, dl1.C, -30, 0)
     c1.B.addWire(dl1.C)       # wire them to the dlatch
     d1.B.addWire(dl1.D)
     # add a piece of wire to monitor output
     dl1.output.addWire((dl1.output.x(20), dl1.output.y()))
     s.gates = (c1, d1, dl1)
Пример #5
0
    def setupGraphics(s):
        s.banner = "Building an OR gate from basic components"
        n1 = Nand2(s, "N1", s.scale1((150, 30))) # Nand Gate
        i1 = Inv(s,   "I1")  # Inverter for n1.A
        i2 = Inv(s,   "I2")  # Inverter for n1.B
        s1 = Swt(s,   "S1")  # Switch feeding input A
        s2 = Swt(s,   "S2")  # Switch feeding input B

        s2.align(s2.B, n1.B, -30,   0)
        i1.align(i1.B, n1.A, -40, -20)  # inverter precedes Nand
        s1.align(s1.B, i1.A, -50,   0)  # line up the gates
        i2.align(i2.B, n1.B, -40,  20)  # inverter precedes Nand
        s2.align(s2.B, i2.A, -50,   0)  # line up the gates

        n1.A.labelQuad = 3              # Label all the connectors
        n1.B.labelQuad = 2
        n1.C.labelQuad = 1
        i1.A.labelQuad = 2              # Inverter
        i1.B.labelQuad = 1
        i2.A.labelQuad = 3              # Inverter
        i2.B.labelQuad = 4
        s1.B.labelQuad = 1              # Switches
        s2.B.labelQuad = 1

        s.gates = (s1, s2, i1, i2, n1)
        s1.B.addWire(i1.A)
        s2.B.addWire(i2.A)
        i1.B.addWire(n1.A)
        i2.B.addWire(n1.B)
        n1.C.addWire( (n1.C.x(30), n1.C.y()))  # tail to see
Пример #6
0
    def setupGraphics(self):
        self.banner = "Basic components. Switch, Multipulsar, Nand, Inverter"

        n1 = Nand2(self, "N1", self.scale1((50, 30))) # Nand Gate
        i1 = Inv(self, "I1")           # Inverter
        s1 = Swt(self, "S1")           # Switch feeding input A
        m1 = MultPuls(self, "MP1")     # Pulsar feeding input B

        s1.align(s1.B, n1.A, -50, 0)   # line up the gates
        m1.align(m1.B, n1.B, -30, 0)
        i1.align(i1.B, n1.C,  80, 0)   # inverter follows Nand

        n1.A.labelQuad = 2             # Label all connectors
        n1.B.labelQuad = 2
        n1.C.labelQuad = 1
        i1.A.labelQuad = 2
        i1.B.labelQuad = 1

        self.gates = (m1, s1, n1, i1)
        s1.B.addWire(n1.A)
        m1.B.addWire(n1.B)
        n1.C.addWire(i1.A)
        i1.B.addWire( (i1.B.x(30), i1.B.y()))  # tail to see