Ejemplo n.º 1
0
def test_and2():
    And2 = DefineCircuit("And2", "I0", In(Bit), "I1", In(Bit), "O", Out(Bit))
    inst0 = gates.And(2)
    wire(And2.I0, inst0[1])
    wire(And2.I1, inst0[2])
    wire(inst0[0], And2.O)
    EndCircuit()

    assert repr(And2) == '''\
And2 = DefineCircuit("And2", "I0", In(Bit), "I1", In(Bit), "O", Out(Bit))
and_inst0 = and()
wire(And2.I0, and_inst0[1])
wire(And2.I1, and_inst0[2])
wire(and_inst0[0], And2.O)
EndCircuit()'''

    assert compile(And2) == '''\
Ejemplo n.º 2
0
def test_args():
    a = gates.And(2, name='a')
    assert repr(a) == 'a = and(name="a")'
    assert repr(a[0]) == 'a[0]'
    assert repr(a[1]) == 'a[1]'
    assert repr(a[2]) == 'a[2]'
Ejemplo n.º 3
0
 class Main(m.Circuit):
     a = gates.And(2, name='a')
     assert repr(a) == 'a = and(name="a")'
     assert repr(a[0]) == 'a[0]'
     assert repr(a[1]) == 'a[1]'
     assert repr(a[2]) == 'a[2]'
Ejemplo n.º 4
0
def test_wire():
    a = gates.And(2, name='a')
    wire(a[0], a[1])
    wire(a[0], a[2])
Ejemplo n.º 5
0
 class Main(m.Circuit):
     a = gates.And(2, name='a')
     m.wire(a[0], a[1])
     m.wire(a[0], a[2])