Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Circ_SR_Latch(Circuit):
- def __init__(self, inputs, x, y, flip=False):
- super().__init__(inputs, x, y, flip)
- n_o1 = Node(DummyNode(), x + 21, y)
- n_o2 = Node(DummyNode(), x + 121, y)
- n_i1 = Node(n_o2, x + 25, y + 150)
- n_i2 = Node(n_o1, x + 100, y + 150)
- g1 = Gate_NOR([inputs[0], n_i1], x, y + 25)
- g1.state = True
- g2 = Gate_NOR([n_i2, inputs[1]], x + 100, y + 25)
- g2.state = False
- n_o1.inp = g1
- n_o2.inp = g2
- Wire(g1.output, [], n_o1)
- Wire(g2.output, [], n_o2)
- Wire(g1.output, [(x + 50, y + 25), (x + 90, y + 150)], n_i2)
- Wire(g2.output, [(x + 100, y + 25), (x + 45, y + 150)], n_i1)
- self.outputs = [n_o1, n_o2]
- class Circ_Gated_SR_Latch(Circuit):
- def __init__(self, inputs, x, y, flip=False):
- super().__init__(inputs, x, y, flip)
- ne = Node(inputs[1], x + 75, y + 285)
- Wire(inputs[1], [], ne)
- and_1 = Gate_AND([inputs[0], ne], x, y + 160)
- and_2 = Gate_AND([ne, inputs[2]], x + 130, y + 160)
- latch = Circ_SR_Latch([and_1.output, and_2.output], x + 15, y)
- self.outputs = latch.outputs
- class Circ_D_Latch(Circuit):
- def __init__(self, inputs, x, y, flip=False):
- super().__init__(inputs, x, y, flip)
- g_n = Gate_NOT([inputs[0]], x - 10, y + 275)
- node = Node(inputs[0], x + 155, y + 365)
- Wire(g_n.nodes[0], [], node)
- latch = Circ_Gated_SR_Latch([g_n.output, inputs[1], node], x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement