Skip to content

Commit

Permalink
ecp5: Fix TQFP144 package import
Browse files Browse the repository at this point in the history
Signed-off-by: gatecat <gatecat@ds0.me>
  • Loading branch information
gatecat committed Aug 17, 2023
1 parent 053d895 commit 88714c5
Showing 1 changed file with 35 additions and 27 deletions.
62 changes: 35 additions & 27 deletions ecp5/trellis_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ def get_bel_index(ddrg, loc, name):
packages = {}
pindata = []

def process_pio_db(ddrg, device):
piofile = path.join(database.get_db_root(), "ECP5", dev_names[device], "iodb.json")
def process_pio_db(ddrg, device, package_filter=None):
piofile = path.join(database.get_db_root(), "ECP5", device, "iodb.json")
with open(piofile, 'r') as f:
piodb = json.load(f)
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 = []
for name, pinloc in sorted(pkgdata.items()):
x = pinloc["col"]
Expand All @@ -257,30 +261,31 @@ def process_pio_db(ddrg, device):
if bel_idx is not None:
pins.append((name, loc, bel_idx))
packages[pkgname] = pins
for metaitem in piodb["pio_metadata"]:
x = metaitem["col"]
y = metaitem["row"]
loc = pytrellis.Location(x, y)
pio = "PIO" + metaitem["pio"]
bank = metaitem["bank"]
if "function" in metaitem:
pinfunc = metaitem["function"]
else:
pinfunc = None
dqs = -1
if "dqs" in metaitem:
tdqs = metaitem["dqs"]
if tdqs[0] == "L":
dqs = 0
elif tdqs[0] == "R":
dqs = 2048
suffix_size = 0
while tdqs[-(suffix_size+1)].isdigit():
suffix_size += 1
dqs |= int(tdqs[-suffix_size:])
bel_idx = get_bel_index(ddrg, loc, pio)
if bel_idx is not None:
pindata.append((loc, bel_idx, bank, pinfunc, dqs))
if package_filter is None:
for metaitem in piodb["pio_metadata"]:
x = metaitem["col"]
y = metaitem["row"]
loc = pytrellis.Location(x, y)
pio = "PIO" + metaitem["pio"]
bank = metaitem["bank"]
if "function" in metaitem:
pinfunc = metaitem["function"]
else:
pinfunc = None
dqs = -1
if "dqs" in metaitem:
tdqs = metaitem["dqs"]
if tdqs[0] == "L":
dqs = 0
elif tdqs[0] == "R":
dqs = 2048
suffix_size = 0
while tdqs[-(suffix_size+1)].isdigit():
suffix_size += 1
dqs |= int(tdqs[-suffix_size:])
bel_idx = get_bel_index(ddrg, loc, pio)
if bel_idx is not None:
pindata.append((loc, bel_idx, bank, pinfunc, dqs))

global_data = {}
quadrants = ["UL", "UR", "LL", "LR"]
Expand Down Expand Up @@ -690,7 +695,10 @@ def main():
max_row = chip.get_max_row()
max_col = chip.get_max_col()
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)
# print("{} unique location types".format(len(ddrg.locationTypes)))
bba = write_database(args.device, chip, ddrg, "le")
Expand Down

0 comments on commit 88714c5

Please sign in to comment.