def testLowLowShouldResultInHigh(self): circuit = Circuit.fromFile("NAND.cir") circuit.setSignal(SignalWithResistance("A", 0.0, 10)) circuit.setSignal(SignalWithResistance("B", 0.0, 10)) circuit.inspectVoltage('NAND') circuit.run(200) self.assertGreater(circuit.getVoltage('NAND'), 4.5)
def testHighHighShouldResultInLow(self): circuit = Circuit.fromFile("NAND.cir") circuit.setSignal(SignalWithResistance("A", 5.0, 10)) circuit.setSignal(SignalWithResistance("B", 5.0, 10)) circuit.inspectVoltage('NAND') circuit.run(200) self.assertLess(circuit.getVoltage('NAND'), 0.5)
def testShouldSwitchOnIn50ns(self): circuit = Circuit.fromFile("NAND.cir") circuit.setSignal(SignalWithResistance("A", 5.0, 10)) circuit.setSignal(DelayedSignal("B", value=0.0, delay=100, resistance=10, startValue=5.0)) circuit.inspectVoltage('NAND') circuit.run(200, 0.05) self.assertLess(circuit.getMaxVoltage('NAND', 0.1, 100), 0.5) self.assertGreater(circuit.getMinVoltage('NAND', 100.05, 200), 4.5)
def setupCircuit(self): circuit = Circuit.fromFile("ALU.cir") circuit.setSignal(SignalWithResistance("A", 0.0, 10)) circuit.setSignal(SignalWithResistance("B", 0.0, 10)) circuit.setSignal(SignalWithResistance("C", 0.0, 10)) circuit.setSignal(SignalWithResistance("INV", 0.0, 10)) circuit.inspectVoltage('XOR') circuit.inspectVoltage('NAND') circuit.inspectVoltage('NOR') circuit.inspectVoltage('CARRY') circuit.inspectVoltage('SUM') circuit.inspectCurrent('Vs') return circuit
def testShouldNotUseTooMuchCurrent(self): circuit = Circuit.fromFile("NAND.cir") circuit.setSignal(SignalWithResistance("A", 5.0, 10)) circuit.setSignal(SignalWithResistance("B", 5.0, 10)) circuit.inspectCurrent('Vs') circuit.run(200) self.assertLess(circuit.getMaxCurrent('Vs'), .001) circuit.setSignal(SignalWithResistance("A", 0.0, 10)) circuit.run(200) self.assertLess(circuit.getMaxCurrent('Vs'), 0.001) circuit.setSignal(SignalWithResistance("B", 0.0, 10)) circuit.run(200) self.assertLess(circuit.getMaxCurrent('Vs'), 0.001) circuit.setSignal(SignalWithResistance("A", 5.0, 10)) circuit.run(200) self.assertLess(circuit.getMaxCurrent('Vs'), 0.001)