From 310d197b8eb33ad4ba41662454aa228cae6b67cf Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Wed, 6 Feb 2019 16:41:04 -0800 Subject: [PATCH 1/4] Add support for non-canonical sorted output. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- prjxray/grid.py | 7 +++++++ utils/bit2fasm.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/prjxray/grid.py b/prjxray/grid.py index 7cbd6f3e..78e08e16 100644 --- a/prjxray/grid.py +++ b/prjxray/grid.py @@ -96,3 +96,10 @@ class Grid(object): def get_segment_map(self): return segment_map.SegmentMap(self) + + def tile_key(self, tilename): + gridinfo = self.gridinfo_at_tilename(tilename) + loc = self.loc_of_tilename(tilename) + tile_type = gridinfo.tile_type + + return (tile_type, loc.grid_x, -loc.grid_y) diff --git a/utils/bit2fasm.py b/utils/bit2fasm.py index 05a87c38..9cac3733 100755 --- a/utils/bit2fasm.py +++ b/utils/bit2fasm.py @@ -5,7 +5,8 @@ Take bitstream .bit files and decode them to FASM. import os import fasm -from prjxray import db +import fasm.output +from prjxray.db import Database from prjxray import fasm_disassembler from prjxray import bitstream import subprocess @@ -26,15 +27,39 @@ def bit_to_bits(bitread, part_yaml, bit_file, bits_file, frame_range=None): def bits_to_fasm(db_root, bits_file, verbose, canonical): - disassembler = fasm_disassembler.FasmDisassembler(db.Database(db_root)) + db = Database(db_root) + grid = db.grid() + disassembler = fasm_disassembler.FasmDisassembler(db) with open(bits_file) as f: bitdata = bitstream.load_bitdata(f) + def is_zero_feature(feature): + parts = feature.split('.') + tile = parts[0] + gridinfo = grid.gridinfo_at_tilename(tile) + feature = '.'.join(parts[1:]) + + db_k = '%s.%s' % (gridinfo.tile_type, feature) + segbits = db.get_tile_segbits(gridinfo.tile_type) + any_bits = False + for bit in segbits.feature_to_bits(db_k): + if bit.isset: + any_bits = True + + return not any_bits + + model = fasm.output.merge_and_sort( + disassembler.find_features_in_bitstream(bitdata, verbose=verbose), + zero_function=is_zero_feature, + sort_key=grid.tile_key, + ) + print( fasm.fasm_tuple_to_string( - disassembler.find_features_in_bitstream(bitdata, verbose=verbose), - canonical=canonical)) + model, + canonical=canonical), + end='') def main(): From f372849bc00646e8f5dcab0b223e792156c7d694 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Wed, 6 Feb 2019 17:12:01 -0800 Subject: [PATCH 2/4] Update FASM to version that includes output sorting. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- third_party/fasm | 2 +- utils/bit2fasm.py | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/third_party/fasm b/third_party/fasm index b7a57855..ece57149 160000 --- a/third_party/fasm +++ b/third_party/fasm @@ -1 +1 @@ -Subproject commit b7a578552669954050f3700ced243b9d9e12d649 +Subproject commit ece57149c96cea82ab155af3bba04e76eee4ab6a diff --git a/utils/bit2fasm.py b/utils/bit2fasm.py index 9cac3733..74caeb69 100755 --- a/utils/bit2fasm.py +++ b/utils/bit2fasm.py @@ -50,16 +50,12 @@ def bits_to_fasm(db_root, bits_file, verbose, canonical): return not any_bits model = fasm.output.merge_and_sort( - disassembler.find_features_in_bitstream(bitdata, verbose=verbose), - zero_function=is_zero_feature, - sort_key=grid.tile_key, - ) + disassembler.find_features_in_bitstream(bitdata, verbose=verbose), + zero_function=is_zero_feature, + sort_key=grid.tile_key, + ) - print( - fasm.fasm_tuple_to_string( - model, - canonical=canonical), - end='') + print(fasm.fasm_tuple_to_string(model, canonical=canonical), end='') def main(): From 94217d105cf35f76c7a853dcd1e162c5860f5516 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Wed, 6 Feb 2019 17:25:11 -0800 Subject: [PATCH 3/4] Update package symlinks. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cac6d9fc..1f10aa71 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ env: $(IN_ENV) pip install -r requirements.txt $(IN_ENV) pip install -r docs/requirements.txt ln -sf $(PWD)/prjxray env/lib/python3.*/site-packages/ - ln -sf $(PWD)/third_party/fasm/fasm.py env/lib/python3.*/site-packages/ + ln -sf $(PWD)/third_party/fasm/ env/lib/python3.*/site-packages/ $(IN_ENV) python -c "import yaml" || (echo "Unable to find python-yaml" && exit 1) build: From 273c240e6cefba97b4c74b10da34402e6a173673 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Wed, 6 Feb 2019 17:34:26 -0800 Subject: [PATCH 4/4] Attempt #2 to make travis happy. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1f10aa71..f489e492 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,6 @@ env: virtualenv --python=python3 --system-site-packages env $(IN_ENV) pip install -r requirements.txt $(IN_ENV) pip install -r docs/requirements.txt - ln -sf $(PWD)/prjxray env/lib/python3.*/site-packages/ - ln -sf $(PWD)/third_party/fasm/ env/lib/python3.*/site-packages/ $(IN_ENV) python -c "import yaml" || (echo "Unable to find python-yaml" && exit 1) build: @@ -25,7 +23,7 @@ test: test-py test-cpp @true test-py: - $(IN_ENV) py.test $(TEST_EXCLUDE) --doctest-modules --junitxml=build/py_test_results.xml + $(IN_ENV) PYTHONPATH="$(PWD):$(PWD)/third_party/fasm:$PYTHONPATH" py.test $(TEST_EXCLUDE) --doctest-modules --junitxml=build/py_test_results.xml test-cpp: mkdir -p build