예제 #1
0
def test_wire1():
    b0 = BitOut(name='b0')
    assert b0.isoutput()

    b1 = BitIn(name='b1')
    assert b1.isinput()

    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
예제 #2
0
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()