Skip to content

Commit

Permalink
Merge pull request f4pga#1180 from litghost/add_clock_regions
Browse files Browse the repository at this point in the history
Add clock_region to tilegrid.json for constructing clock networks.
  • Loading branch information
acomodi committed Dec 16, 2019
2 parents b29742b + c38859c commit 143ea98
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
16 changes: 13 additions & 3 deletions fuzzers/005-tilegrid/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@ def load_tiles(tiles_fn):
tile_type, tile_name, grid_x, grid_y = record[0:4]
grid_x, grid_y = int(grid_x), int(grid_y)
sites = {}
for i in range(4, len(record), 2):
site_type, site_name = record[i:i + 2]
sites[site_name] = site_type
clock_region = None
if len(record) >= 5:
clock_region = record[4]
if clock_region == "NA":
clock_region = None
for i in range(5, len(record), 2):
site_type, site_name = record[i:i + 2]
sites[site_name] = site_type

tile = {
'type': tile_type,
'name': tile_name,
'grid_x': grid_x,
'grid_y': grid_y,
'sites': sites,
'clock_region': clock_region,
}
tiles.append(tile)

Expand Down Expand Up @@ -59,6 +66,9 @@ def make_database(tiles, pin_func):
"pin_functions": {},
}

if tile["clock_region"]:
database[tile["name"]]["clock_region"] = tile["clock_region"]

for site in database[tile["name"]]["sites"]:
if site in pin_func:
database[tile["name"]]["pin_functions"][site] = pin_func[site]
Expand Down
9 changes: 8 additions & 1 deletion fuzzers/005-tilegrid/generate_tiles.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ proc write_tiles_txt {} {
set sites [get_sites -quiet -of_objects $tile]
set typed_sites {}

set clock_region "NA"

if [llength $sites] {
set site_types [get_property SITE_TYPE $sites]
foreach t $site_types s $sites {
Expand All @@ -23,10 +25,15 @@ proc write_tiles_txt {} {
if [llength $package_pin] {
puts $fp_pin "$s [get_property PIN_FUNC $package_pin]"
}
set clock_region [get_property CLOCK_REGION $s]
}
}
if {[llength $clock_region] == 0} {
set clock_region "NA"
}


puts $fp "$type $tile $grid_x $grid_y $typed_sites"
puts $fp "$type $tile $grid_x $grid_y $clock_region $typed_sites"
}
close $fp_pin
close $fp
Expand Down
22 changes: 21 additions & 1 deletion prjxray/grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from prjxray import segment_map
from prjxray.grid_types import BlockType, GridLoc, GridInfo, BitAlias, Bits, BitsInfo
from prjxray.grid_types import BlockType, GridLoc, GridInfo, BitAlias, Bits, BitsInfo, ClockRegion
from prjxray.tile_segbits_alias import TileSegbitsAlias
import re

CLOCK_REGION_RE = re.compile('X([0-9])Y([0-9])')


class Grid(object):
Expand All @@ -16,6 +19,8 @@ def __init__(self, db, tilegrid):
self.loc = {}
self.tileinfo = {}

clock_regions = {}

for tile in self.tilegrid:
tileinfo = self.tilegrid[tile]
grid_loc = GridLoc(tileinfo['grid_x'], tileinfo['grid_y'])
Expand Down Expand Up @@ -46,11 +51,26 @@ def __init__(self, db, tilegrid):
alias=alias,
)

clock_region = None
if 'clock_region' in tileinfo:
if tileinfo['clock_region'] is not None:
if tileinfo['clock_region'] not in clock_regions:
m = CLOCK_REGION_RE.fullmatch(tileinfo['clock_region'])
assert m is not None, tileinfo['clock_region']

clock_regions[tileinfo['clock_region']] = ClockRegion(
name=tileinfo['clock_region'],
x=int(m.group(1)),
y=int(m.group(2)))

clock_region = clock_regions[tileinfo['clock_region']]

self.tileinfo[tile] = GridInfo(
bits=bits,
sites=tileinfo['sites'],
tile_type=tileinfo['type'],
pin_functions=tileinfo.get('pin_functions', {}),
clock_region=clock_region,
)

x, y = zip(*self.loc.keys())
Expand Down
4 changes: 3 additions & 1 deletion prjxray/grid_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class BlockType(enum.Enum):


GridLoc = namedtuple('GridLoc', 'grid_x grid_y')
GridInfo = namedtuple('GridInfo', 'bits sites tile_type pin_functions')
ClockRegion = namedtuple('ClockRegion', 'name x y')
GridInfo = namedtuple(
'GridInfo', 'bits sites tile_type pin_functions clock_region')
BitAlias = namedtuple('BitAlias', 'tile_type start_offset sites')
Bits = namedtuple('Bits', 'base_address frames offset words alias')
BitsInfo = namedtuple('BitsInfo', 'block_type tile bits')

0 comments on commit 143ea98

Please sign in to comment.