Example #1
0
        def definition(def_):
            def buf(y):
                return Buf(loc=(0, y // 8, y % 8))

            buffer = join(col(buf, width))
            wire(def_.I, buffer.I0)
            wire(buffer.O, def_.O)
Example #2
0
def test_str_repr_anon():
    And2 = m.DeclareCircuit('And2', "I0", m.In(m.Bit), "I1", m.In(m.Bit), "O",
                            m.Out(m.Bit))
    circ = m.DefineCircuit("Test", "I0", m.In(m.Bits[3]), "I1",
                           m.In(m.Bits[3]), "O", m.Out(m.Bits[3]))
    anon = m.join(m.map_(And2, 3))
    m.wire(circ.I0, anon.I0)
    m.wire(circ.I1, anon.I1)
    m.wire(circ.O, anon.O)
    m.EndCircuit()

    string = str(anon)
    assert string[:len("AnonymousCircuitInst")] == "AnonymousCircuitInst"
    assert string[-len(
        "<I0: Array[3, In(Bit)], I1: Array[3, In(Bit)], O: Array[3, Out(Bit)]>"
    ):] == "<I0: Array[3, In(Bit)], I1: Array[3, In(Bit)], O: Array[3, Out(Bit)]>"
    assert repr(
        anon
    ) == 'AnonymousCircuitType("I0", array([And2_inst0.I0, And2_inst1.I0, And2_inst2.I0]), "I1", array([And2_inst0.I1, And2_inst1.I1, And2_inst2.I1]), "O", array([And2_inst0.O, And2_inst1.O, And2_inst2.O]))'
Example #3
0
 def definition(io):
     s = flat(join(map_(Swap, n // 2 - 1)), flatargs=['I', 'O'])
     wire(io.I[0], io.O[0])
     wire(s(io.I[1:-1]), io.O[1:-1])
     wire(io.I[-1], io.O[-1])
Example #4
0
 def definition(io):
     s = flat(join(map_(Swap, n // 2)), flatargs=['I', 'O'])
     wire(s(io.I), io.O)
Example #5
0
 def logic(a: m.Bits[10]) -> m.Bits[10]:
     return m.join(m.map_(Not, 10))(a)