mirror of https://github.com/openXC7/prjxray.git
Merge pull request #31 from SymbiFlow/tileconn
Add tileconnwire.py utils script
This commit is contained in:
commit
409f4410c3
|
|
@ -24,6 +24,22 @@ with open("nodewires.txt") as f:
|
|||
tilenodes[wire_tile] = dict()
|
||||
tilenodes[wire_tile][node] = wire_name
|
||||
|
||||
def filter_pair(type1, type2, wire1, wire2, delta_x, delta_y):
|
||||
if type1 in ["HCLK_L", "HCLK_R"]:
|
||||
is_vertical_wire = False
|
||||
if wire1.startswith("HCLK_S"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_N"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_W"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_E"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_LV"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_BYP"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_FAN"): is_vertical_wire = True
|
||||
if wire1.startswith("HCLK_LEAF_CLK_"): is_vertical_wire = True
|
||||
if is_vertical_wire and delta_y == 0: return True
|
||||
if not is_vertical_wire and delta_x == 0: return True
|
||||
|
||||
return False
|
||||
|
||||
def handle_pair(tile1, tile2):
|
||||
if tile1 not in tilenodes: return
|
||||
if tile2 not in tilenodes: return
|
||||
|
|
@ -44,6 +60,10 @@ def handle_pair(tile1, tile2):
|
|||
for node, wire1 in tilenodes[tile1].items():
|
||||
if node in tilenodes[tile2]:
|
||||
wire2 = tilenodes[tile2][node]
|
||||
if filter_pair(key[0], key[1], wire1, wire2, key[2], key[3]):
|
||||
continue
|
||||
if filter_pair(key[1], key[0], wire2, wire1, -key[2], -key[3]):
|
||||
continue
|
||||
wire_pairs.add((wire1, wire2))
|
||||
|
||||
if key not in database:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, json
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage example: python3 %s HCLK_R HCLK_SW6E3" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
with open("%s/%s/tileconn.json" % (os.getenv("XRAY_DATABASE_DIR"), os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tileconn = json.load(f)
|
||||
|
||||
outdata = list()
|
||||
max_tiletype_len = 1
|
||||
|
||||
for entry in tileconn:
|
||||
if entry["tile_types"][0] == sys.argv[1]:
|
||||
this_idx, other_idx = 0, 1
|
||||
delta_x, delta_y = entry["grid_deltas"]
|
||||
elif entry["tile_types"][1] == sys.argv[1]:
|
||||
this_idx, other_idx = 1, 0
|
||||
delta_x, delta_y = -entry["grid_deltas"][0], -entry["grid_deltas"][1]
|
||||
else:
|
||||
continue
|
||||
|
||||
for wire_pair in entry["wire_pairs"]:
|
||||
if wire_pair[this_idx] != sys.argv[2]:
|
||||
continue
|
||||
|
||||
outdata.append((delta_x, delta_y, entry["tile_types"][other_idx], wire_pair[other_idx]))
|
||||
max_tiletype_len = max(max_tiletype_len, len(entry["tile_types"][other_idx]))
|
||||
|
||||
for entry in outdata:
|
||||
print("%3d %3d %-*s %s" % (entry[0], entry[1], max_tiletype_len, entry[2], entry[3]))
|
||||
|
||||
Loading…
Reference in New Issue