mirror of https://github.com/openXC7/prjxray.git
Update FASM tools to use new required_features.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
parent
f0f29956d7
commit
8387eb8c32
|
|
@ -53,7 +53,6 @@ def main():
|
|||
y2=j['info']['GRID_Y_MAX'],
|
||||
)
|
||||
|
||||
|
||||
with open(args.pad_wires) as f:
|
||||
for l in f:
|
||||
parts = l.strip().split(' ')
|
||||
|
|
@ -89,7 +88,8 @@ def main():
|
|||
|
||||
unknown_base_address = int(annotation.value, 0)
|
||||
|
||||
assert unknown_base_address not in frames_in_use, "Found unknown bit in base address 0x{:08x}".format(unknown_base_address)
|
||||
assert unknown_base_address not in frames_in_use, "Found unknown bit in base address 0x{:08x}".format(
|
||||
unknown_base_address)
|
||||
|
||||
if not fasm_line.set_feature:
|
||||
continue
|
||||
|
|
@ -109,7 +109,8 @@ def main():
|
|||
if not_in_roi and base_address_in_roi:
|
||||
required_features.append(fasm_line)
|
||||
|
||||
j['required_features'] = fasm.fasm_tuple_to_string(required_features, canonical=True)
|
||||
j['required_features'] = fasm.fasm_tuple_to_string(
|
||||
required_features, canonical=True)
|
||||
|
||||
json.dump(j, sys.stdout, indent=2, sort_keys=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import fasm
|
||||
from prjxray import bitstream
|
||||
from prjxray import grid
|
||||
|
||||
|
||||
class FasmLookupError(Exception):
|
||||
|
|
@ -142,34 +141,50 @@ class FasmAssembler(object):
|
|||
bits.base_address + bits.frames):
|
||||
self.frames_in_use.add(frame)
|
||||
|
||||
def parse_fasm_filename(self, filename):
|
||||
def add_fasm_line(self, line, missing_features):
|
||||
if not line.set_feature:
|
||||
return
|
||||
|
||||
line_strs = tuple(fasm.fasm_line_to_string(line))
|
||||
assert len(line_strs) == 1
|
||||
line_str = line_strs[0]
|
||||
|
||||
parts = line.set_feature.feature.split('.')
|
||||
tile = parts[0]
|
||||
feature = '.'.join(parts[1:])
|
||||
|
||||
# canonical_features flattens multibit feature enables to only
|
||||
# single bit features, which is what enable_feature expects.
|
||||
#
|
||||
# canonical_features also filters out features that are not enabled,
|
||||
# which are no-ops.
|
||||
for flat_set_feature in fasm.canonical_features(line.set_feature):
|
||||
address = 0
|
||||
if flat_set_feature.start is not None:
|
||||
address = flat_set_feature.start
|
||||
|
||||
try:
|
||||
self.enable_feature(tile, feature, address, line_str)
|
||||
except FasmLookupError as e:
|
||||
missing_features.append(str(e))
|
||||
|
||||
def parse_fasm_filename(self, filename, extra_features=[]):
|
||||
missing_features = []
|
||||
for line in fasm.parse_fasm_filename(filename):
|
||||
if not line.set_feature:
|
||||
continue
|
||||
self.add_fasm_line(line, missing_features)
|
||||
|
||||
line_strs = tuple(fasm.fasm_line_to_string(line))
|
||||
assert len(line_strs) == 1
|
||||
line_str = line_strs[0]
|
||||
|
||||
parts = line.set_feature.feature.split('.')
|
||||
tile = parts[0]
|
||||
feature = '.'.join(parts[1:])
|
||||
|
||||
# canonical_features flattens multibit feature enables to only
|
||||
# single bit features, which is what enable_feature expects.
|
||||
#
|
||||
# canonical_features also filters out features that are not enabled,
|
||||
# which are no-ops.
|
||||
for flat_set_feature in fasm.canonical_features(line.set_feature):
|
||||
address = 0
|
||||
if flat_set_feature.start is not None:
|
||||
address = flat_set_feature.start
|
||||
|
||||
try:
|
||||
self.enable_feature(tile, feature, address, line_str)
|
||||
except FasmLookupError as e:
|
||||
missing_features.append(str(e))
|
||||
for line in extra_features:
|
||||
self.add_fasm_line(line, missing_features)
|
||||
|
||||
if missing_features:
|
||||
raise FasmLookupError('\n'.join(missing_features))
|
||||
|
||||
def mark_roi_frames(self, roi):
|
||||
for tile in roi.gen_tiles():
|
||||
gridinfo = self.grid.gridinfo_at_tilename(tile)
|
||||
|
||||
for block_type in gridinfo.bits:
|
||||
bits = gridinfo.bits[block_type]
|
||||
for frame in range(bits.base_address,
|
||||
bits.base_address + bits.frames):
|
||||
self.frames_in_use.add(frame)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
import fasm
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from prjxray import fasm_assembler
|
||||
from prjxray import db
|
||||
from prjxray.db import Database
|
||||
from prjxray.roi import Roi
|
||||
|
||||
|
||||
class FASMSyntaxError(SyntaxError):
|
||||
|
|
@ -51,9 +54,26 @@ def dump_frm(f, frames):
|
|||
'0x%08X ' % addr + ','.join(['0x%08X' % w for w in words]) + '\n')
|
||||
|
||||
|
||||
def run(db_root, filename_in, f_out, sparse=False, debug=False):
|
||||
assembler = fasm_assembler.FasmAssembler(db.Database(db_root))
|
||||
assembler.parse_fasm_filename(filename_in)
|
||||
def run(db_root, filename_in, f_out, sparse=False, roi=None, debug=False):
|
||||
db = Database(db_root)
|
||||
assembler = fasm_assembler.FasmAssembler(db)
|
||||
|
||||
if roi:
|
||||
with open(roi) as f:
|
||||
roi_j = json.load(f)
|
||||
x1 = roi_j['info']['GRID_X_MIN']
|
||||
x2 = roi_j['info']['GRID_X_MAX']
|
||||
y1 = roi_j['info']['GRID_Y_MIN']
|
||||
y2 = roi_j['info']['GRID_Y_MAX']
|
||||
|
||||
assembler.mark_roi_frames(Roi(db=db, x1=x1, x2=x2, y1=y1, y2=y2))
|
||||
|
||||
if 'required_features' in roi_j:
|
||||
extra_features = fasm.parse_fasm_string(roi_j['required_features'])
|
||||
else:
|
||||
extra_features = []
|
||||
|
||||
assembler.parse_fasm_filename(filename_in, extra_features=extra_features)
|
||||
frames = assembler.get_frames(sparse=sparse)
|
||||
|
||||
if debug:
|
||||
|
|
@ -80,6 +100,9 @@ def main():
|
|||
parser.add_argument('--db-root', help="Database root.", **db_root_kwargs)
|
||||
parser.add_argument(
|
||||
'--sparse', action='store_true', help="Don't zero fill all frames")
|
||||
parser.add_argument(
|
||||
'--roi',
|
||||
help="ROI design.json file defining which tiles are within the ROI.")
|
||||
parser.add_argument(
|
||||
'--debug', action='store_true', help="Print debug dump")
|
||||
parser.add_argument('fn_in', help='Input FPGA assembly (.fasm) file')
|
||||
|
|
@ -95,6 +118,7 @@ def main():
|
|||
filename_in=args.fn_in,
|
||||
f_out=open(args.fn_out, 'w'),
|
||||
sparse=args.sparse,
|
||||
roi=args.roi,
|
||||
debug=args.debug)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue