aboutsummaryrefslogtreecommitdiffstats
path: root/python/dump_design.py
blob: 419c7304662ac1613db694f74a0f0df30b2f1bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Run ./nextpnr-ice40 --json ice40/blinky.json --run python/dump_design.py
for cell, cinfo in sorted(ctx.cells, key=lambda x: x.first):
    print("Cell {} : {}".format(cell, cinfo.type))
    print("\tPorts:")
    for port, pinfo in sorted(cinfo.ports, key=lambda x: x.first):
        dir = (" <-- ", " --> ", " <-> ")[int(pinfo.type)]
        if pinfo.net is not None:
            print("\t\t{} {} {}".format(port, dir, pinfo.net.name))

    if len(cinfo.attrs) > 0:
        print("\tAttrs:")
        for attr, val in cinfo.attrs:
            print("\t\t{}: {}".format(attr, val))

    if len(cinfo.params) > 0:
        print("\tParams:")
        for param, val in cinfo.params:
            if val.isdigit():
                val = bin(int(val))[2:]
                val = "{}'b{}".format(len(val), val)
            print("\t\t{}: {}".format(param, val))

    if cinfo.bel is not None:
        print("\tBel: {}".format(cinfo.bel))
    print()