def _trace_drivees(bit: m.Bit) -> Iterable[m.Bit]: drivees = bit.driving() if not drivees: return _empty() for drivee in drivees: if drivee.is_input() or drivee.is_inout(): yield drivee continue yield from _trace_drivees(drivee)
def test_wire3(): b0 = Bit(name='b0') b1 = Bit(name='b1') print('wire(b0,b1)') wire(b0, b1) assert b0.port.wires is b1.port.wires #wires = b0.port.wires #print 'inputs:', [str(p) for p in wires.inputs] #print 'outputs:', [str(p) for p in wires.outputs] assert len(b0.port.wires.inputs) == 1 assert len(b0.port.wires.outputs) == 1 assert b0.wired() assert b1.wired() assert b0.trace() is b1 assert b1.trace() is b0 assert b0.value() is None assert b1.value() is b0
def test_bit_val(): b = BitIn(name="a") assert isinstance(b, BitType) assert isinstance(b, BitIn) assert b.isinput() assert str(b) == "a" assert isinstance(b, BitIn) assert b.isinput() b = BitOut(name="a") assert b.isoutput() assert str(b) == "a" assert isinstance(b, BitOut) assert b.isoutput() b = Bit(name="a") assert str(b) == "a" assert isinstance(b, Bit) assert not b.isinput() assert not b.isoutput() assert not b.isinout()
def test_const(): zero = Bit(0) one = Bit(1) assert zero.name.name == "GND" assert one.name.name == "VCC"