Пример #1
0
    def build(_):
        types.struct({"foo": types.i12})({"foo": 7})
        dim(types.i8, 2)([42, 45])
        types.i8(5)

        BarType({"foo": 7})

        Taps()
        StupidLegacy(ignore=no_connect)
Пример #2
0
def ExternWithParams(a, b):

    typedef1 = types.struct({"a": types.i1}, "exTypedef")

    class M:
        pass

    return M
Пример #3
0
class ComplexPorts:
    clk = Input(types.i1)
    sel = Input(types.i2)
    data_in = Input(dim(32, 3))
    struct_data_in = Input(types.struct({"foo": types.i36}))

    a = Output(types.i32)
    b = Output(types.i32)
    c = Output(types.i32)

    @generator
    def build(ports):
        assert len(ports.data_in) == 3
        ports.set_all_ports({
            'a': ports.data_in[0].reg(ports.clk).reg(ports.clk),
            'b': ports.data_in[ports.sel],
            'c': ports.struct_data_in.foo[:-4]
        })
Пример #4
0
@module
class Taps:
    taps = Output(dim(8, 3))

    @generator
    def build(ports):
        ports.taps = [203, 100, 23]


@externmodule
class StupidLegacy:
    ignore = Input(dim(1, 4))


BarType = types.struct({"foo": types.i12}, "bar")


@module
class Top:
    @generator
    def build(_):
        types.struct({"foo": types.i12})({"foo": 7})
        dim(types.i8, 2)([42, 45])
        types.i8(5)

        BarType({"foo": 7})

        Taps()
        StupidLegacy(ignore=no_connect)
Пример #5
0
# RUN: %PYTHON% %s 2>err.txt | FileCheck %s
# RUN: cat err.txt | FileCheck --check-prefix=ERR %s

from pycde import dim, types

# CHECK: [('foo', Type(i1)), ('bar', Type(i13))]
# ERR: i1
st1 = types.struct({"foo": types.i1, "bar": types.i13})
print(st1.fields)
st1.foo.dump()
print()

from mlir.ir import Module

# ERR: i6
array1 = dim(types.i6)
array1.dump()
print()
# CHECK: i6
print(array1)

# ERR: !hw.array<12xarray<10xi6>>
array2 = dim(6, 10, 12)
array2.dump()
print()
# CHECK: [12][10]i6
print(array2)

# ERR: !hw.typealias<@pycde::@myname1, i8>
int_alias = types.int(8, "myname1")
int_alias.dump()