mirror of https://github.com/openXC7/prjxray.git
Additional library behaviors after integration.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
parent
cd129ba84e
commit
9284744028
|
|
@ -69,13 +69,18 @@ class Database(object):
|
|||
|
||||
self.site_types[site_type_name] = os.path.join(self.db_root, f)
|
||||
|
||||
self.tile_types_obj = {}
|
||||
|
||||
def get_tile_types(self):
|
||||
""" Return list of tile types """
|
||||
return self.tile_types.keys()
|
||||
|
||||
def get_tile_type(self, tile_type):
|
||||
""" Return Tile object for given tilename. """
|
||||
return tile.Tile(tile_type, self.tile_types[tile_type])
|
||||
if tile_type not in self.tile_types_obj:
|
||||
self.tile_types_obj[tile_type] = tile.Tile(tile_type, self.tile_types[tile_type])
|
||||
|
||||
return self.tile_types_obj[tile_type]
|
||||
|
||||
def _read_tilegrid(self):
|
||||
""" Read tilegrid database if not already read. """
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ class Grid(object):
|
|||
x, y = zip(*self.loc.keys())
|
||||
self._dims = (min(x), max(x), min(y), max(y))
|
||||
|
||||
def tiles(self):
|
||||
""" Return list of tiles. """
|
||||
return self.tileinfo.keys()
|
||||
|
||||
def tile_locations(self):
|
||||
""" Return list of tile locations. """
|
||||
return self.loc.keys()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import os.path
|
||||
import csv
|
||||
import pickle
|
||||
import pyjson5 as json5
|
||||
import progressbar
|
||||
import re
|
||||
from collections import namedtuple
|
||||
|
||||
|
|
@ -112,6 +110,8 @@ class NodeLookup(object):
|
|||
self.nodes = nodes
|
||||
|
||||
def load_from_root_csv(self, nodes):
|
||||
import pyjson5 as json5
|
||||
import progressbar
|
||||
for node in progressbar.progressbar(nodes):
|
||||
with open(node) as f:
|
||||
node_wires = json5.load(f)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ from prjxray import lib
|
|||
""" Database files available for a tile """
|
||||
TileDbs = namedtuple('TileDbs', 'segbits mask tile_type')
|
||||
|
||||
Pip = namedtuple('Pip', 'net_to net_from can_invert is_directional is_pseudo')
|
||||
Pip = namedtuple('Pip', 'name net_to net_from can_invert is_directional is_pseudo')
|
||||
|
||||
""" Site - Represents an instance of a site within a tile.
|
||||
|
||||
name - Name of site within tile, instance specific.
|
||||
|
|
@ -16,6 +17,7 @@ pins - Instaces of site pins within this site and tile. This is an tuple of
|
|||
|
||||
"""
|
||||
Site = namedtuple('Site', 'name prefix x y type site_pins')
|
||||
|
||||
""" SitePin - Tuple representing a site pin within a tile.
|
||||
|
||||
Sites are generic based on type, however sites are instanced
|
||||
|
|
@ -24,13 +26,13 @@ information and tile type specific information.
|
|||
|
||||
name - Site type specific name. This name is expected to be the same for all
|
||||
sites of the same type.
|
||||
direction - Direction of this site pin. This direction is expected to be the
|
||||
same for all sites of the same type.
|
||||
wire - Wire name within the tile. This name is site instance specific.
|
||||
|
||||
"""
|
||||
SitePin = namedtuple('SitePin', 'name wire')
|
||||
|
||||
WireInfo = namedtuple('WireInfo', 'pips sites')
|
||||
|
||||
|
||||
class Tile(object):
|
||||
""" Provides abstration of a tile in the database. """
|
||||
|
|
@ -43,6 +45,7 @@ class Tile(object):
|
|||
self.wires = None
|
||||
self.sites = None
|
||||
self.pips = None
|
||||
self.pips_by_name = {}
|
||||
|
||||
def yield_sites(sites):
|
||||
for site in sites:
|
||||
|
|
@ -59,8 +62,9 @@ class Tile(object):
|
|||
) for name, wire in site['site_pins'].items()))
|
||||
|
||||
def yield_pips(pips):
|
||||
for pip in pips.values():
|
||||
for name, pip in pips.items():
|
||||
yield Pip(
|
||||
name = name,
|
||||
net_to=pip['dst_wire'],
|
||||
net_from=pip['src_wire'],
|
||||
can_invert=bool(int(pip['can_invert'])),
|
||||
|
|
@ -75,6 +79,8 @@ class Tile(object):
|
|||
self.sites = tuple(yield_sites(tile_type['sites']))
|
||||
self.pips = tuple(yield_pips(tile_type['pips']))
|
||||
|
||||
self.wire_info = {}
|
||||
|
||||
def get_wires(self):
|
||||
"""Returns a set of wire names present in this tile."""
|
||||
return self.wires
|
||||
|
|
@ -88,6 +94,34 @@ class Tile(object):
|
|||
"""
|
||||
return self.pips
|
||||
|
||||
def get_pip_by_name(self, name):
|
||||
if len(self.pips_by_name) == 0:
|
||||
for pip in self.pips:
|
||||
self.pips_by_name[pip.name] = pip
|
||||
|
||||
return self.pips_by_name[name]
|
||||
|
||||
def get_wire_info(self, target_wire, allow_pseudo=False):
|
||||
if len(self.wire_info) == 0:
|
||||
for wire in self.wires:
|
||||
pips = list()
|
||||
sites = list()
|
||||
|
||||
for site in self.sites:
|
||||
for site_pin in site.site_pins:
|
||||
if site_pin.wire == wire:
|
||||
sites.append((site.name, site_pin.name))
|
||||
|
||||
for pip in self.pips:
|
||||
pseudo_filter = (not pip.is_pseudo) or allow_pseudo
|
||||
if (wire == pip.net_to or wire == pip.net_from) and pseudo_filter:
|
||||
pips.append(pip.name)
|
||||
|
||||
assert wire not in self.wire_info
|
||||
self.wire_info[wire] = WireInfo(pips=pips, sites=sites)
|
||||
|
||||
return self.wire_info[target_wire]
|
||||
|
||||
def get_instance_sites(self, grid_info):
|
||||
""" get_sites returns abstract sites for all tiles of type.
|
||||
get_instance_sites converts site info from generic to specific
|
||||
|
|
@ -125,3 +159,11 @@ class Tile(object):
|
|||
)
|
||||
|
||||
assert site_names == set(grid_info.sites.keys())
|
||||
|
||||
def get_other_wire_from_pip(pip, wire):
|
||||
if wire == pip.net_to:
|
||||
return pip.net_from
|
||||
elif wire == pip.net_from:
|
||||
return pip.net_to
|
||||
else:
|
||||
assert False, (pip, wire)
|
||||
|
|
|
|||
Loading…
Reference in New Issue