def __init__(self): n1 = Not() n2 = Not() a1 = And() a2 = And() a3 = And() a4 = And() inputs = {} a_split = Split(n1.input, a2.input_a, a4.input_b) inputs["input_a"] = a_split.input b_split = Split(n2.input, a3.input_a, a4.input_a) inputs["input_b"] = b_split.input n1_split = Split(a1.input_a, a3.input_b) n1.output.connect(n1_split.input) n2_split = Split(a1.input_b, a2.input_b) n2.output.connect(n2_split.input) outputs = {} outputs["output_a"] = a1.output outputs["output_b"] = a2.output outputs["output_c"] = a3.output outputs["output_d"] = a4.output super(TwoToFourDecoder, self).__init__(inputs, outputs)
def __init__(self): inputs = {} outputs = {} n = Not() a1 = And() a2 = And() sr = SRFlipFlop() clk_split = Split() d_split = Split() #connect up the inputs inputs["input_d"] = d_split.input d_split.connect(n.input) d_split.connect(a2.input_b) n.output.connect(a1.input_a) inputs["clock"] = clk_split.input clk_split.connect(a1.input_b) clk_split.connect(a2.input_a) a1.output.connect(sr.set) a2.output.connect(sr.reset) outputs["output_q_"] = sr.output_q_ outputs["output_q"] = sr.output_q super(DFlipFlop, self).__init__(inputs, outputs)
def __init__(self): data_split = Split() write_split = Split() inputs = {} inputs["data"] = data_split.input inputs["write"] = write_split.input outputs = {} output = Cathode() outputs["output"] = output n1 = Not() n2 = Not() a1 = And() a2 = And() a3 = And() o = Or() data_split.connect(a1.input_a) data_split.connect(n1.input) n1.output.connect(a2.input_a) write_split.connect(a1.input_b) write_split.connect(a2.input_b) a1.output.connect(o.input_b) a2.output.connect(n2.input) o.output.connect(a3.input_a) n2.output.connect(a3.input_b) a_output_split = Split() a3.output.connect(a_output_split.input) a_output_split.connect(o.input_a) a_output_split.connect(output) super(GatedLatch, self).__init__(inputs, outputs)
def __init__(self): a1 = And() a2 = And() n = Not() inputs = {} inputs["input_a"] = a1.input_a inputs["input_b"] = a1.input_b inputs["input_c"] = a2.input_a a1.output.connect(a2.input_b) a2.output.connect(n.input) outputs = {} outputs["output"] = n.output super(ThreeInputNand, self).__init__(inputs, outputs)
def __init__(self): o = Or() a = And() n = Not() inputs = {} inputs["set"] = o.input_b inputs["reset"] = n.input outputs = {} output = Cathode() outputs["output"] = output o.output.connect(a.input_a) n.output.connect(a.input_b) a_output_split = Split() a.output.connect(a_output_split.input) a_output_split.connect(o.input_a) a_output_split.connect(output) super(AndOrLatch, self).__init__(inputs, outputs)
def __init__(self): n = Not() a1 = And() a2 = And() o = Or() #create inputs inputs = {} inputs["input_a"] = a1.input_a inputs["input_b"] = a2.input_a signal_split = Split(n.input, a2.input_b) inputs["signal"] = signal_split.input #connect up gates n.output.connect(a1.input_b) a1.output.connect(o.input_a) a2.output.connect(o.input_b) #create output outputs = {} outputs["output"] = o.output super(TwoToOneMultiplexer, self).__init__(inputs, outputs)
def test_not(): logic_gate_test(Not(), operator.__not__)
def __init__(self): inputs = {} outputs = {} n1 = ThreeInputNand() n2 = ThreeInputNand() n3 = Nand() n4 = Nand() n5 = Nand() n6 = Nand() n7 = Nand() n8 = Nand() n = Not() clk_split = Split() n3_split = Split() n4_split = Split() n_split = Split() n7_split = Split() n8_split = Split() output_q_ = Cathode() output_q = Cathode() self.components = {} self.components["clk_split"] = clk_split self.components["n3_split"] = n3_split self.components["n4_split"] = n4_split self.components["n_split"] = n_split # inputs inputs["input_j"] = n1.input_b inputs["clock"] = clk_split.input inputs["input_k"] = n2.input_b # clock split clk_split.connect(n1.input_c) clk_split.connect(n2.input_a) clk_split.connect(n.input) # nand 1 n1.output.connect(n3.input_a) # nand 2 n2.output.connect(n4.input_b) # nand 3 n3.output.connect(n3_split.input) # nand 4 n4.output.connect(n4_split.input) # not n.output.connect(n_split.input) # nand 3 split n3_split.connect(n4.input_a) n3_split.connect(n5.input_a) # nand 4 split n4_split.connect(n3.input_b) n4_split.connect(n6.input_b) # not split n_split.connect(n5.input_b) n_split.connect(n6.input_a) # nand 5 n5.output.connect(n7.input_a) # nand 6 n6.output.connect(n8.input_b) # nand 7 n7.output.connect(n7_split.input) # nand 8 n8.output.connect(n8_split.input) # nand 7 split n7_split.connect(n8.input_a) n7_split.connect(output_q) n7_split.connect(n2.input_c) # nand 8 split n8_split.connect(n7.input_b) n8_split.connect(output_q_) n8_split.connect(n1.input_a) outputs["output_q_"] = output_q_ outputs["output_q"] = output_q super(MasterSlaveJKFlipFlop, self).__init__(inputs, outputs)