aboutsummaryrefslogtreecommitdiffstats
path: root/python/dump_design.py
blob: 419c7304662ac1613db694f74a0f0df30b2f1bd1 (plain)
1
2
3
4
5
pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bo
# 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()