mirror of https://github.com/openXC7/prjxray.git
prjxray: Update scripts to access fabric data
Parts data are now divided from the part. Update all scripts to access the fabric data from the fabric files. Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
This commit is contained in:
parent
ec15a221d6
commit
082e982911
|
|
@ -9,6 +9,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: ISC
|
||||
import os.path
|
||||
import pathlib
|
||||
import simplejson as json
|
||||
from prjxray import grid
|
||||
from prjxray import tile
|
||||
|
|
@ -16,6 +17,7 @@ from prjxray import tile_segbits
|
|||
from prjxray import site_type
|
||||
from prjxray import connections
|
||||
from prjxray.node_model import NodeModel
|
||||
from prjxray.util import get_fabric_for_part
|
||||
|
||||
|
||||
def get_available_databases(prjxray_root):
|
||||
|
|
@ -45,6 +47,8 @@ class Database(object):
|
|||
"""
|
||||
self.db_root = db_root
|
||||
self.part = part
|
||||
self.fabric = get_fabric_for_part(db_root, part)
|
||||
|
||||
# tilegrid.json JSON object
|
||||
self.tilegrid = None
|
||||
self.tileconn = None
|
||||
|
|
@ -129,21 +133,21 @@ class Database(object):
|
|||
def _read_tilegrid(self):
|
||||
""" Read tilegrid database if not already read. """
|
||||
if not self.tilegrid:
|
||||
with open(os.path.join(self.db_root, self.part,
|
||||
with open(os.path.join(self.db_root, self.fabric,
|
||||
'tilegrid.json')) as f:
|
||||
self.tilegrid = json.load(f)
|
||||
|
||||
def _read_tileconn(self):
|
||||
""" Read tileconn database if not already read. """
|
||||
if not self.tileconn:
|
||||
with open(os.path.join(self.db_root, self.part,
|
||||
with open(os.path.join(self.db_root, self.fabric,
|
||||
'tileconn.json')) as f:
|
||||
self.tileconn = json.load(f)
|
||||
|
||||
def _read_node_wires(self):
|
||||
""" Read node wires if not already read. """
|
||||
if self.node_wires is None:
|
||||
with open(os.path.join(self.db_root, self.part,
|
||||
with open(os.path.join(self.db_root, self.fabric,
|
||||
'node_wires.json')) as f:
|
||||
self.node_wires = json.load(f)
|
||||
|
||||
|
|
|
|||
|
|
@ -834,7 +834,7 @@ def main():
|
|||
# Build (baseaddr, offset) -> tile name map
|
||||
database_dir = os.path.join(
|
||||
os.getenv("XRAY_DATABASE_DIR"), os.getenv("XRAY_DATABASE"),
|
||||
os.getenv("XRAY_PART"))
|
||||
os.getenv("XRAY_FABRIC"))
|
||||
tilegrid_file = os.path.join(database_dir, "tilegrid.json")
|
||||
address_map = build_address_map(tilegrid_file)
|
||||
|
||||
|
|
|
|||
|
|
@ -82,15 +82,16 @@ def add_site_group_zero(segmk, site, prefix, vals, zero_val, val):
|
|||
|
||||
|
||||
class Segmaker:
|
||||
def __init__(self, bitsfile, verbose=None, db_root=None, part=None):
|
||||
def __init__(self, bitsfile, verbose=None, db_root=None, fabric=None):
|
||||
self.db_root = db_root
|
||||
if self.db_root is None:
|
||||
self.db_root = util.get_db_root()
|
||||
assert self.db_root, "No db root specified."
|
||||
|
||||
self.part = part
|
||||
if self.part is None:
|
||||
self.part = util.get_part()
|
||||
assert self.part, "No part specified."
|
||||
self.fabric = fabric
|
||||
if self.fabric is None:
|
||||
self.fabric = util.get_fabric()
|
||||
assert self.fabric, "No fabric specified."
|
||||
|
||||
self.verbose = verbose if verbose is not None else os.getenv(
|
||||
'VERBOSE', 'N') == 'Y'
|
||||
|
|
@ -128,7 +129,7 @@ class Segmaker:
|
|||
|
||||
def load_grid(self):
|
||||
'''Load self.grid holding tile addresses'''
|
||||
with open(os.path.join(self.db_root, self.part, "tilegrid.json"),
|
||||
with open(os.path.join(self.db_root, self.fabric, "tilegrid.json"),
|
||||
"r") as f:
|
||||
self.grid = json.load(f)
|
||||
assert "segments" not in self.grid, "Old format tilegrid.json"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import math
|
|||
import os
|
||||
import random
|
||||
import re
|
||||
import yaml
|
||||
from .roi import Roi
|
||||
|
||||
|
||||
|
|
@ -31,6 +32,47 @@ def get_part():
|
|||
return ret
|
||||
|
||||
|
||||
def get_fabric():
|
||||
ret = os.getenv("XRAY_FABRIC", None)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def get_part_information(db_root, part):
|
||||
filename = os.path.join(db_root, "mapping", "parts.yaml")
|
||||
assert os.path.isfile(filename), \
|
||||
"Mapping file {} does not exists".format(filename)
|
||||
with open(filename, 'r') as stream:
|
||||
part_mapping = yaml.load(stream, Loader=yaml.FullLoader)
|
||||
part = part_mapping.get(part, None)
|
||||
assert part, "Part {} not found in {}".format(part, part_mapping)
|
||||
return part
|
||||
|
||||
|
||||
def get_part_resources(file_path, part):
|
||||
filename = os.path.join(file_path, "resources.yaml")
|
||||
assert os.path.isfile(filename), \
|
||||
"Mapping file {} does not exists".format(filename)
|
||||
with open(filename, 'r') as stream:
|
||||
res_mapping = yaml.load(stream, Loader=yaml.FullLoader)
|
||||
res = res_mapping.get(part, None)
|
||||
assert res, "Part {} not found in {}".format(part, part_mapping)
|
||||
return res
|
||||
|
||||
|
||||
def get_fabric_for_part(db_root, part):
|
||||
filename = os.path.join(db_root, "mapping", "devices.yaml")
|
||||
assert os.path.isfile(filename), \
|
||||
"Mapping file {} does not exists".format(filename)
|
||||
part = get_part_information(db_root, part)
|
||||
with open(filename, 'r') as stream:
|
||||
device_mapping = yaml.load(stream, Loader=yaml.FullLoader)
|
||||
device = device_mapping.get(part['device'], None)
|
||||
assert device, "Device {} not found in {}".format(
|
||||
part['device'], device_mapping)
|
||||
return device['fabric']
|
||||
|
||||
|
||||
def roi_xy():
|
||||
x1 = int(os.getenv('XRAY_ROI_GRID_X1', 0))
|
||||
x2 = int(os.getenv('XRAY_ROI_GRID_X2', 58))
|
||||
|
|
|
|||
Loading…
Reference in New Issue