aboutsummaryrefslogtreecommitdiffstats
path: root/icefuzz/pinloc/pinlocdb.py
blob: f32c3f6210bcec80e3b5db443e114e442e22c5b4 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3

import re
from sys import argv

ieren_db = [ ]
pinloc_db = [ ]

for arg in argv[1:]:
    pin = re.search(r"_([^.]*)", arg).group(1)
    with open(arg, "r") as f:
        tile = [0, 0]
        iob = [0, 0, 0]
        ioctrl = [0, 0, 0]

        for line in f:
            match = re.match(r"^\.io_tile (\d+) (\d+)", line)
            if match:
                tile = [int(match.group(1)), int(match.group(2))]

            match = re.match(r"^IOB_(\d+)", line)
            if match:
                iob = tile + [int(match.group(1))]

            match = re.match(r"^IoCtrl REN_(\d+)", line)
            if match:
                ioctrl = tile + [int(match.group(1))]

        ieren_db.append(tuple(iob + ioctrl))
        pinloc_db.append(tuple(['"' + pin + '"'] + iob))

print()
print("# ieren_db")
for entry in sorted(ieren_db):
    print("        (%2d, %2d, %d, %2d, %2d, %d)," % entry)

print()
print("# pinloc_db")
for entry in sorted(pinloc_db, key=lambda n: re.sub(r"[0-9]+", lambda d: "%03d" % int(d.group(0)), n[0])):
    print("        (%5s, %2d, %2d, %d)," % entry)

print()