2018-01-04 17:30:36 +01:00
|
|
|
#!/usr/bin/env python3
|
2020-04-16 09:29:20 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
#
|
|
|
|
|
# Copyright (C) 2017-2020 The Project X-Ray Authors.
|
|
|
|
|
#
|
|
|
|
|
# Use of this source code is governed by a ISC-style
|
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
|
# https://opensource.org/licenses/ISC
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: ISC
|
2018-01-04 17:30:36 +01:00
|
|
|
|
2018-01-08 22:57:06 +01:00
|
|
|
import os, sys, json
|
2018-01-04 17:30:36 +01:00
|
|
|
|
2022-03-15 10:47:58 +01:00
|
|
|
from prjxray.util import OpenSafeFile
|
2019-01-11 04:47:55 +01:00
|
|
|
|
|
|
|
|
def main(argv):
|
|
|
|
|
if len(argv) != 3:
|
|
|
|
|
print("Usage example: python3 %s HCLK_R HCLK_SW6E3" % sys.argv[0])
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
2022-03-15 10:47:58 +01:00
|
|
|
with OpenSafeFile("%s/%s/tileconn.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
2019-01-11 04:47:55 +01:00
|
|
|
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:
|
2018-01-04 17:30:36 +01:00
|
|
|
continue
|
|
|
|
|
|
2019-01-11 04:47:55 +01:00
|
|
|
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]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main(sys.argv)
|