ecp5: Fix TQFP144 package import

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2023-08-17 11:42:29 +02:00 committed by myrtle
parent 053d89570f
commit 88714c54ec

View File

@ -242,11 +242,15 @@ def get_bel_index(ddrg, loc, name):
packages = {} packages = {}
pindata = [] pindata = []
def process_pio_db(ddrg, device): def process_pio_db(ddrg, device, package_filter=None):
piofile = path.join(database.get_db_root(), "ECP5", dev_names[device], "iodb.json") piofile = path.join(database.get_db_root(), "ECP5", device, "iodb.json")
with open(piofile, 'r') as f: with open(piofile, 'r') as f:
piodb = json.load(f) piodb = json.load(f)
for pkgname, pkgdata in sorted(piodb["packages"].items()): for pkgname, pkgdata in sorted(piodb["packages"].items()):
if package_filter is not None and pkgname not in package_filter:
# we need to get the TQ144 package only out of the non-SERDES device
# everything else comes from the SERDES device
continue
pins = [] pins = []
for name, pinloc in sorted(pkgdata.items()): for name, pinloc in sorted(pkgdata.items()):
x = pinloc["col"] x = pinloc["col"]
@ -257,30 +261,31 @@ def process_pio_db(ddrg, device):
if bel_idx is not None: if bel_idx is not None:
pins.append((name, loc, bel_idx)) pins.append((name, loc, bel_idx))
packages[pkgname] = pins packages[pkgname] = pins
for metaitem in piodb["pio_metadata"]: if package_filter is None:
x = metaitem["col"] for metaitem in piodb["pio_metadata"]:
y = metaitem["row"] x = metaitem["col"]
loc = pytrellis.Location(x, y) y = metaitem["row"]
pio = "PIO" + metaitem["pio"] loc = pytrellis.Location(x, y)
bank = metaitem["bank"] pio = "PIO" + metaitem["pio"]
if "function" in metaitem: bank = metaitem["bank"]
pinfunc = metaitem["function"] if "function" in metaitem:
else: pinfunc = metaitem["function"]
pinfunc = None else:
dqs = -1 pinfunc = None
if "dqs" in metaitem: dqs = -1
tdqs = metaitem["dqs"] if "dqs" in metaitem:
if tdqs[0] == "L": tdqs = metaitem["dqs"]
dqs = 0 if tdqs[0] == "L":
elif tdqs[0] == "R": dqs = 0
dqs = 2048 elif tdqs[0] == "R":
suffix_size = 0 dqs = 2048
while tdqs[-(suffix_size+1)].isdigit(): suffix_size = 0
suffix_size += 1 while tdqs[-(suffix_size+1)].isdigit():
dqs |= int(tdqs[-suffix_size:]) suffix_size += 1
bel_idx = get_bel_index(ddrg, loc, pio) dqs |= int(tdqs[-suffix_size:])
if bel_idx is not None: bel_idx = get_bel_index(ddrg, loc, pio)
pindata.append((loc, bel_idx, bank, pinfunc, dqs)) if bel_idx is not None:
pindata.append((loc, bel_idx, bank, pinfunc, dqs))
global_data = {} global_data = {}
quadrants = ["UL", "UR", "LL", "LR"] quadrants = ["UL", "UR", "LL", "LR"]
@ -690,7 +695,10 @@ def main():
max_row = chip.get_max_row() max_row = chip.get_max_row()
max_col = chip.get_max_col() max_col = chip.get_max_col()
process_timing_data() process_timing_data()
process_pio_db(ddrg, args.device) process_pio_db(ddrg, dev_names[args.device])
# add TQFP144 package from non-SERDES device if appropriate
if args.device == "25k": process_pio_db(ddrg, "LFE5U-25F", {"TQFP144", })
if args.device == "45k": process_pio_db(ddrg, "LFE5U-45F", {"TQFP144", })
process_loc_globals(chip) process_loc_globals(chip)
# print("{} unique location types".format(len(ddrg.locationTypes))) # print("{} unique location types".format(len(ddrg.locationTypes)))
bba = write_database(args.device, chip, ddrg, "le") bba = write_database(args.device, chip, ddrg, "le")