1#!/usr/bin/env python3 2 3import re 4from sys import argv 5 6ieren_db = [ ] 7pinloc_db = [ ] 8 9for arg in argv[1:]: 10 pin = re.search(r"_([^.]*)", arg).group(1) 11 with open(arg, "r") as f: 12 tile = [0, 0] 13 iob = [0, 0, 0] 14 ioctrl = [0, 0, 0] 15 16 for line in f: 17 match = re.match(r"^\.io_tile (\d+) (\d+)", line) 18 if match: 19 tile = [int(match.group(1)), int(match.group(2))] 20 21 match = re.match(r"^IOB_(\d+)", line) 22 if match: 23 iob = tile + [int(match.group(1))] 24 25 match = re.match(r"^IoCtrl REN_(\d+)", line) 26 if match: 27 ioctrl = tile + [int(match.group(1))] 28 29 ieren_db.append(tuple(iob + ioctrl)) 30 pinloc_db.append(tuple(['"' + pin + '"'] + iob)) 31 32print() 33print("# ieren_db") 34for entry in sorted(ieren_db): 35 print(" (%2d, %2d, %d, %2d, %2d, %d)," % entry) 36 37print() 38print("# pinloc_db") 39for entry in sorted(pinloc_db, key=lambda n: re.sub(r"[0-9]+", lambda d: "%03d" % int(d.group(0)), n[0])): 40 print(" (%5s, %2d, %2d, %d)," % entry) 41 42print() 43 44