mirror of https://github.com/openXC7/prjxray.git
commit
7eb7d844b1
|
|
@ -29,7 +29,7 @@ contrib.append(
|
|||
----
|
||||
|
||||
This file is generated from [README.md](README.md), please edit that file then
|
||||
run the `./.update-contributing.py`.
|
||||
run the `./.github/update-contributing.py`.
|
||||
|
||||
""")
|
||||
|
||||
69
.travis.yml
69
.travis.yml
|
|
@ -1,42 +1,33 @@
|
|||
matrix:
|
||||
os: linux
|
||||
dist: trusty
|
||||
language: python
|
||||
python: 3.6
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
packages:
|
||||
- clang-format-5.0
|
||||
- g++-6
|
||||
|
||||
install:
|
||||
- export CC=gcc-6
|
||||
- export CXX=g++-6
|
||||
- make env
|
||||
|
||||
|
||||
jobs:
|
||||
include:
|
||||
# Job 1) Test C++ w/ GCC
|
||||
- os: linux
|
||||
dist: trusty
|
||||
language: cpp
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-6
|
||||
# State 1 - Tests
|
||||
- stage: "Tests"
|
||||
name: "C++ Tests"
|
||||
script: make test-cpp
|
||||
|
||||
- name: "Python Tests"
|
||||
script: make test-py
|
||||
|
||||
- name: "Format"
|
||||
script:
|
||||
- export CC=gcc-6
|
||||
- export CXX=g++-6
|
||||
- mkdir -p build
|
||||
- pushd build
|
||||
- cmake -DPRJXRAY_BUILD_TESTING=ON ..
|
||||
- make -j 4
|
||||
- ctest
|
||||
# Job 2) Lint checks on Python and C++
|
||||
- os: linux
|
||||
dist: trusty
|
||||
language: python
|
||||
python: 3.6
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
packages:
|
||||
- clang-format-5.0
|
||||
- g++-6
|
||||
install:
|
||||
- export CC=gcc-6
|
||||
- export CXX=g++-6
|
||||
- pip install -r requirements.txt
|
||||
script:
|
||||
- export CC=gcc-6
|
||||
- export CXX=g++-6
|
||||
- make format
|
||||
- test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
|
||||
- test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
|
||||
|
|
|
|||
|
|
@ -92,5 +92,5 @@ In addition to the above contribution guidelines, see the guide to
|
|||
----
|
||||
|
||||
This file is generated from [README.md](README.md), please edit that file then
|
||||
run the `./.update-contributing.py`.
|
||||
run the `./.github/update-contributing.py`.
|
||||
|
||||
|
|
|
|||
64
Makefile
64
Makefile
|
|
@ -1,14 +1,13 @@
|
|||
CLANG_FORMAT ?= clang-format-5.0
|
||||
PYTHON_FORMAT ?= yapf
|
||||
TCL_FORMAT ?= utils//tcl-reformat.sh
|
||||
|
||||
.PHONY: database format clean env
|
||||
ALL_EXCLUDE = third_party .git env build
|
||||
|
||||
# Tools + Environment
|
||||
IN_ENV = if [ -e env/bin/activate ]; then . env/bin/activate; fi;
|
||||
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/fasm.py env/lib/python3.*/site-packages/
|
||||
$(IN_ENV) python -c "import yaml" || (echo "Unable to find python-yaml" && exit 1)
|
||||
|
||||
build:
|
||||
|
|
@ -16,16 +15,53 @@ build:
|
|||
mkdir -p build
|
||||
cd build; cmake ..; $(MAKE)
|
||||
|
||||
database: build
|
||||
$(MAKE) -C $@
|
||||
.PHONY: env build
|
||||
|
||||
FORMAT_EXCLUDE = third_party .git env build
|
||||
FIND_EXCLUDE = $(foreach x,$(FORMAT_EXCLUDE),-and -not -path './$(x)/*')
|
||||
format:
|
||||
find . -name \*.cc $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
|
||||
find . -name \*.h $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
|
||||
$(IN_ENV) find . -name \*.py $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) yapf -p -i
|
||||
find . -name \*.tcl $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) -n 1 $(TCL_FORMAT)
|
||||
# Run tests of code.
|
||||
# ------------------------
|
||||
TEST_EXCLUDE = $(foreach x,$(ALL_EXCLUDE) fuzzers minitests experiments,--ignore $(x))
|
||||
|
||||
test: test-py test-cpp
|
||||
@true
|
||||
|
||||
test-py:
|
||||
$(IN_ENV) py.test $(TEST_EXCLUDE) --doctest-modules --junitxml=build/py_test_results.xml
|
||||
|
||||
test-cpp:
|
||||
mkdir -p build
|
||||
cd build && cmake -DPRJXRAY_BUILD_TESTING=ON ..
|
||||
cd build && $(MAKE) -s
|
||||
cd build && ctest --no-compress-output -T Test -C RelWithDebInfo --output-on-failure
|
||||
|
||||
.PHONY: test test-py test-cpp
|
||||
|
||||
# Auto formatting of code.
|
||||
# ------------------------
|
||||
FORMAT_EXCLUDE = $(foreach x,$(ALL_EXCLUDE),-and -not -path './$(x)/*')
|
||||
|
||||
CLANG_FORMAT ?= clang-format-5.0
|
||||
format-cpp:
|
||||
find . -name \*.cc $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
|
||||
find . -name \*.h $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
|
||||
|
||||
format-docs:
|
||||
./.github/update-contributing.py
|
||||
|
||||
PYTHON_FORMAT ?= yapf
|
||||
format-py:
|
||||
$(IN_ENV) find . -name \*.py $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) yapf -p -i
|
||||
|
||||
TCL_FORMAT ?= utils//tcl-reformat.sh
|
||||
format-tcl:
|
||||
find . -name \*.tcl $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) -n 1 $(TCL_FORMAT)
|
||||
|
||||
format: format-cpp format-docs format-py format-tcl
|
||||
@true
|
||||
|
||||
.PHONY: format format-cpp format-py format-tcl
|
||||
|
||||
# Project X-Ray database
|
||||
# ------------------------
|
||||
|
||||
checkdb:
|
||||
@for DB in database/*; do if [ -d $$DB ]; then \
|
||||
|
|
|
|||
|
|
@ -4,139 +4,142 @@ import sys
|
|||
import json
|
||||
import re
|
||||
|
||||
db_tiles = set()
|
||||
db_tile_prop = dict()
|
||||
db_tile_sites = dict()
|
||||
|
||||
db_sites = set()
|
||||
db_site_prop = dict()
|
||||
db_site_tile = dict()
|
||||
db_site_bit = dict()
|
||||
def main():
|
||||
db_tiles = set()
|
||||
db_tile_prop = dict()
|
||||
db_tile_sites = dict()
|
||||
|
||||
db_sites = set()
|
||||
db_site_prop = dict()
|
||||
db_site_tile = dict()
|
||||
db_site_bit = dict()
|
||||
|
||||
def add_tile(tile):
|
||||
if tile not in db_tiles:
|
||||
db_tiles.add(tile)
|
||||
db_tile_prop[tile] = dict()
|
||||
db_tile_sites[tile] = list()
|
||||
def add_tile(tile):
|
||||
if tile not in db_tiles:
|
||||
db_tiles.add(tile)
|
||||
db_tile_prop[tile] = dict()
|
||||
db_tile_sites[tile] = list()
|
||||
|
||||
def add_site(site):
|
||||
if site not in db_sites:
|
||||
db_sites.add(site)
|
||||
db_site_prop[site] = dict()
|
||||
|
||||
def add_site(site):
|
||||
if site not in db_sites:
|
||||
db_sites.add(site)
|
||||
db_site_prop[site] = dict()
|
||||
with open("%s.txt" % sys.argv[1]) as f:
|
||||
for line in f:
|
||||
line = line.split()
|
||||
|
||||
if line[0] == "TILEPROP":
|
||||
add_tile(line[1])
|
||||
db_tile_prop[line[1]][line[2]] = " ".join(line[3:])
|
||||
continue
|
||||
|
||||
with open("%s.txt" % sys.argv[1]) as f:
|
||||
for line in f:
|
||||
line = line.split()
|
||||
if line[0] == "TILESITE":
|
||||
add_tile(line[1])
|
||||
add_site(line[2])
|
||||
db_tile_sites[line[1]].append(line[2])
|
||||
db_site_tile[line[2]] = line[1]
|
||||
continue
|
||||
|
||||
if line[0] == "TILEPROP":
|
||||
add_tile(line[1])
|
||||
db_tile_prop[line[1]][line[2]] = " ".join(line[3:])
|
||||
continue
|
||||
if line[0] == "SITEPROP":
|
||||
add_site(line[1])
|
||||
db_site_prop[line[1]][line[2]] = " ".join(line[3:])
|
||||
continue
|
||||
|
||||
if line[0] == "TILESITE":
|
||||
add_tile(line[1])
|
||||
add_site(line[2])
|
||||
db_tile_sites[line[1]].append(line[2])
|
||||
db_site_tile[line[2]] = line[1]
|
||||
continue
|
||||
if line[0] == "SLICEBIT":
|
||||
db_site_bit[line[1]] = line[2]
|
||||
continue
|
||||
|
||||
if line[0] == "SITEPROP":
|
||||
add_site(line[1])
|
||||
db_site_prop[line[1]][line[2]] = " ".join(line[3:])
|
||||
continue
|
||||
assert False
|
||||
|
||||
if line[0] == "SLICEBIT":
|
||||
db_site_bit[line[1]] = line[2]
|
||||
continue
|
||||
print("Number of tiles: %d" % len(db_tiles))
|
||||
print("Number of sites: %d" % len(db_sites))
|
||||
print("Number of sites with bit: %d" % len(db_site_bit))
|
||||
|
||||
assert False
|
||||
database = dict()
|
||||
loc_to_tile = dict()
|
||||
|
||||
print("Number of tiles: %d" % len(db_tiles))
|
||||
print("Number of sites: %d" % len(db_sites))
|
||||
print("Number of sites with bit: %d" % len(db_site_bit))
|
||||
|
||||
database = dict()
|
||||
loc_to_tile = dict()
|
||||
|
||||
database["device"] = sys.argv[2]
|
||||
|
||||
database["tiles"] = dict()
|
||||
for tile in db_tiles:
|
||||
entry = dict()
|
||||
entry["props"] = db_tile_prop[tile]
|
||||
entry["sites"] = db_tile_sites[tile]
|
||||
database["tiles"][tile] = entry
|
||||
|
||||
col = int(db_tile_prop[tile]["COLUMN"])
|
||||
row = int(db_tile_prop[tile]["ROW"])
|
||||
loc_to_tile[(col, row)] = tile
|
||||
|
||||
database["sites"] = dict()
|
||||
for site in db_sites:
|
||||
entry = dict()
|
||||
entry["props"] = db_site_prop[site]
|
||||
entry["tile"] = db_site_tile[site]
|
||||
database["sites"][site] = entry
|
||||
|
||||
for site, bit in db_site_bit.items():
|
||||
bit = bit.split("_")
|
||||
bit_type = int(bit[4][1:])
|
||||
bit_half = int(bit[5][1:])
|
||||
bit_row = int(bit[6][1:])
|
||||
bit_col = int(bit[7][1:])
|
||||
bit_word = int(bit[9][1:])
|
||||
assert len(bit) == 11
|
||||
|
||||
for i in range(50):
|
||||
m = re.match("(.*)Y([0-9]+)", site)
|
||||
this_site = "%sY%d" % (m.group(1), int(m.group(2)) + i)
|
||||
|
||||
tile = db_site_tile[this_site]
|
||||
|
||||
word = bit_word + 2 * i
|
||||
if word >= 50: word += 1
|
||||
database["device"] = sys.argv[2]
|
||||
|
||||
database["tiles"] = dict()
|
||||
for tile in db_tiles:
|
||||
entry = dict()
|
||||
entry["BASE_FRAMEID"] = "0x%08x" % (
|
||||
(bit_type << 23) | (bit_half << 22) | (bit_row << 17) |
|
||||
(bit_col << 7))
|
||||
entry["FRAME_TYPE"] = bit_type
|
||||
entry["FRAME_HALF"] = bit_half
|
||||
entry["FRAME_ROW"] = bit_row
|
||||
entry["FRAME_COLUMN"] = bit_col
|
||||
entry["WORDS"] = [word, word + 1]
|
||||
entry["props"] = db_tile_prop[tile]
|
||||
entry["sites"] = db_tile_sites[tile]
|
||||
database["tiles"][tile] = entry
|
||||
|
||||
database["tiles"][tile]["cfgcol"] = entry
|
||||
col = int(db_tile_prop[tile]["COLUMN"])
|
||||
row = int(db_tile_prop[tile]["ROW"])
|
||||
loc_to_tile[(col, row)] = tile
|
||||
|
||||
if database["tiles"][tile]["props"]["TILE_TYPE"] in ("CLBLL_L",
|
||||
"CLBLM_L"):
|
||||
col = int(db_tile_prop[tile]["COLUMN"])
|
||||
row = int(db_tile_prop[tile]["ROW"])
|
||||
right_tile = loc_to_tile[(col + 1, row)]
|
||||
database["sites"] = dict()
|
||||
for site in db_sites:
|
||||
entry = dict()
|
||||
entry["props"] = db_site_prop[site]
|
||||
entry["tile"] = db_site_tile[site]
|
||||
database["sites"][site] = entry
|
||||
|
||||
database["tiles"][right_tile]["cfgcol"] = entry
|
||||
for site, bit in db_site_bit.items():
|
||||
bit = bit.split("_")
|
||||
bit_type = int(bit[4][1:])
|
||||
bit_half = int(bit[5][1:])
|
||||
bit_row = int(bit[6][1:])
|
||||
bit_col = int(bit[7][1:])
|
||||
bit_word = int(bit[9][1:])
|
||||
assert len(bit) == 11
|
||||
|
||||
if database["tiles"][tile]["props"]["TILE_TYPE"] in ("CLBLL_R",
|
||||
"CLBLM_R"):
|
||||
col = int(db_tile_prop[tile]["COLUMN"])
|
||||
row = int(db_tile_prop[tile]["ROW"])
|
||||
left_tile = loc_to_tile[(col - 1, row)]
|
||||
for i in range(50):
|
||||
m = re.match("(.*)Y([0-9]+)", site)
|
||||
this_site = "%sY%d" % (m.group(1), int(m.group(2)) + i)
|
||||
|
||||
database["tiles"][left_tile]["cfgcol"] = entry
|
||||
tile = db_site_tile[this_site]
|
||||
|
||||
tile_cfgcol_count = 0
|
||||
cfgcols = set()
|
||||
word = bit_word + 2 * i
|
||||
if word >= 50: word += 1
|
||||
|
||||
for tile in db_tiles:
|
||||
if "cfgcol" in database["tiles"][tile]:
|
||||
cfgcols.add(database["tiles"][tile]["cfgcol"]["BASE_FRAMEID"])
|
||||
tile_cfgcol_count += 1
|
||||
entry = dict()
|
||||
entry["BASE_FRAMEID"] = "0x%08x" % (
|
||||
(bit_type << 23) | (bit_half << 22) | (bit_row << 17) |
|
||||
(bit_col << 7))
|
||||
entry["FRAME_TYPE"] = bit_type
|
||||
entry["FRAME_HALF"] = bit_half
|
||||
entry["FRAME_ROW"] = bit_row
|
||||
entry["FRAME_COLUMN"] = bit_col
|
||||
entry["WORDS"] = [word, word + 1]
|
||||
|
||||
print("Number of assigned columns: %d" % len(cfgcols))
|
||||
print("Number of tiles with assigned column: %d" % tile_cfgcol_count)
|
||||
database["tiles"][tile]["cfgcol"] = entry
|
||||
|
||||
with open("%s.json" % sys.argv[1], "w") as f:
|
||||
print(json.dumps(database, sort_keys=True, indent="\t"), file=f)
|
||||
if database["tiles"][tile]["props"]["TILE_TYPE"] in ("CLBLL_L",
|
||||
"CLBLM_L"):
|
||||
col = int(db_tile_prop[tile]["COLUMN"])
|
||||
row = int(db_tile_prop[tile]["ROW"])
|
||||
right_tile = loc_to_tile[(col + 1, row)]
|
||||
|
||||
database["tiles"][right_tile]["cfgcol"] = entry
|
||||
|
||||
if database["tiles"][tile]["props"]["TILE_TYPE"] in ("CLBLL_R",
|
||||
"CLBLM_R"):
|
||||
col = int(db_tile_prop[tile]["COLUMN"])
|
||||
row = int(db_tile_prop[tile]["ROW"])
|
||||
left_tile = loc_to_tile[(col - 1, row)]
|
||||
|
||||
database["tiles"][left_tile]["cfgcol"] = entry
|
||||
|
||||
tile_cfgcol_count = 0
|
||||
cfgcols = set()
|
||||
|
||||
for tile in db_tiles:
|
||||
if "cfgcol" in database["tiles"][tile]:
|
||||
cfgcols.add(database["tiles"][tile]["cfgcol"]["BASE_FRAMEID"])
|
||||
tile_cfgcol_count += 1
|
||||
|
||||
print("Number of assigned columns: %d" % len(cfgcols))
|
||||
print("Number of tiles with assigned column: %d" % tile_cfgcol_count)
|
||||
|
||||
with open("%s.json" % sys.argv[1], "w") as f:
|
||||
print(json.dumps(database, sort_keys=True, indent="\t"), file=f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ def get_bit_info(dbstate, frameidx, bitidx, tiletype):
|
|||
label = bit_name[6:9]
|
||||
|
||||
if re.match("^INT_[LR].IMUX", bit_name):
|
||||
m = re.match("^INT_[LR].IMUX(_L)?(\d+)", bit_name)
|
||||
m = re.match("^INT_[LR].IMUX(_L)?(\\d+)", bit_name)
|
||||
bgcolor = "#88aaff"
|
||||
label = "IM" + m.group(2)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ def get_db_root():
|
|||
|
||||
|
||||
def roi_xy():
|
||||
x1 = int(os.getenv('XRAY_ROI_GRID_X1'))
|
||||
x2 = int(os.getenv('XRAY_ROI_GRID_X2'))
|
||||
y1 = int(os.getenv('XRAY_ROI_GRID_Y1'))
|
||||
y2 = int(os.getenv('XRAY_ROI_GRID_Y2'))
|
||||
x1 = int(os.getenv('XRAY_ROI_GRID_X1', 0))
|
||||
x2 = int(os.getenv('XRAY_ROI_GRID_X2', 58))
|
||||
y1 = int(os.getenv('XRAY_ROI_GRID_Y1', 0))
|
||||
y2 = int(os.getenv('XRAY_ROI_GRID_Y2', 52))
|
||||
|
||||
return (x1, x2), (y1, y2)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@ scipy
|
|||
sympy
|
||||
yapf==0.24.0
|
||||
textx
|
||||
pytest
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ class TestUtil(TestCase):
|
|||
}
|
||||
}
|
||||
with setup_database(makedb({})):
|
||||
self.assertEquals(list(get_roi().gen_sites()), [])
|
||||
self.assertListEqual(list(get_roi().gen_sites()), [])
|
||||
with setup_database(makedb({'FOO': 'BAR'})):
|
||||
self.assertEquals(
|
||||
self.assertListEqual(
|
||||
list(get_roi().gen_sites()), [('ATILE', 'FOO', 'BAR')])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import print_function
|
||||
from prjxray import fasm_assembler
|
||||
from prjxray import db
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from prjxray import fasm_assembler
|
||||
from prjxray import db
|
||||
|
||||
|
||||
class FASMSyntaxError(SyntaxError):
|
||||
pass
|
||||
|
||||
|
||||
def dump_frames_verbose(frames):
|
||||
print()
|
||||
|
|
|
|||
|
|
@ -105,11 +105,10 @@ def db_load():
|
|||
return db_res
|
||||
|
||||
|
||||
type_to_tiles, grid_to_tile, nodes, node_node_pip, reverse_node_node = db_load(
|
||||
)
|
||||
|
||||
|
||||
def route(args):
|
||||
type_to_tiles, grid_to_tile, nodes, node_node_pip, reverse_node_node = db_load(
|
||||
)
|
||||
|
||||
active_pips = set()
|
||||
blocked_nodes = set()
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ def bitread2bits(txt):
|
|||
return bits_ref
|
||||
|
||||
|
||||
# FIXME: These functions are currently broken.
|
||||
@unittest.skip
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
def test_lut(self):
|
||||
'''Simple smoke test on just the LUTs'''
|
||||
|
|
|
|||
|
|
@ -5,89 +5,92 @@
|
|||
|
||||
import os, sys, json
|
||||
|
||||
with open("%s/%s/tilegrid.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
||||
os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tilegrid = json.load(f)
|
||||
|
||||
with open("%s/%s/tileconn.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
||||
os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tileconn = json.load(f)
|
||||
def main():
|
||||
with open("%s/%s/tilegrid.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
||||
os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tilegrid = json.load(f)
|
||||
|
||||
grid = dict()
|
||||
wirepairs = dict()
|
||||
remwires = set()
|
||||
with open("%s/%s/tileconn.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
||||
os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tileconn = json.load(f)
|
||||
|
||||
for tilename, tiledata in tilegrid.items():
|
||||
key = (tiledata["grid_x"], tiledata["grid_y"])
|
||||
grid[key] = tilename
|
||||
grid = dict()
|
||||
wirepairs = dict()
|
||||
remwires = set()
|
||||
|
||||
for tilename, tiledata in tilegrid.items():
|
||||
key = (tiledata["grid_x"], tiledata["grid_y"])
|
||||
grid[key] = tilename
|
||||
|
||||
def check_tileconn_entry(tilename, tiledata, entry, idx):
|
||||
if idx == 0:
|
||||
otheridx = 1
|
||||
otherxy = (
|
||||
tiledata["grid_x"] + entry["grid_deltas"][0],
|
||||
tiledata["grid_y"] + entry["grid_deltas"][1])
|
||||
else:
|
||||
otheridx = 0
|
||||
otherxy = (
|
||||
tiledata["grid_x"] - entry["grid_deltas"][0],
|
||||
tiledata["grid_y"] - entry["grid_deltas"][1])
|
||||
|
||||
if otherxy not in grid:
|
||||
return
|
||||
|
||||
othertilename = grid[otherxy]
|
||||
othertiledata = tilegrid[othertilename]
|
||||
|
||||
if othertiledata["type"] != entry["tile_types"][otheridx]:
|
||||
return
|
||||
|
||||
print(
|
||||
" Found relevant entry (%s %s %d %d): %s" % (
|
||||
entry["tile_types"][0], entry["tile_types"][1],
|
||||
entry["grid_deltas"][0], entry["grid_deltas"][1],
|
||||
othertilename))
|
||||
|
||||
for pair in entry["wire_pairs"]:
|
||||
wirename = "%s/%s" % (tilename, pair[idx])
|
||||
otherwirename = "%s/%s" % (othertilename, pair[otheridx])
|
||||
|
||||
remwires.add(wirename)
|
||||
remwires.add(otherwirename)
|
||||
|
||||
if wirename not in wirepairs:
|
||||
wirepairs[wirename] = set()
|
||||
wirepairs[wirename].add(otherwirename)
|
||||
|
||||
if otherwirename not in wirepairs:
|
||||
wirepairs[otherwirename] = set()
|
||||
wirepairs[otherwirename].add(wirename)
|
||||
|
||||
for tilename, tiledata in tilegrid.items():
|
||||
print("Connecting wires in tile %s." % tilename)
|
||||
for entry in tileconn:
|
||||
if entry["tile_types"][0] == tiledata["type"]:
|
||||
check_tileconn_entry(tilename, tiledata, entry, 0)
|
||||
if entry["tile_types"][1] == tiledata["type"]:
|
||||
check_tileconn_entry(tilename, tiledata, entry, 1)
|
||||
|
||||
def check_wire(wire, source):
|
||||
for next_wire in wirepairs[wire]:
|
||||
if next_wire == source:
|
||||
continue
|
||||
print(" %s" % next_wire)
|
||||
if next_wire not in remwires:
|
||||
print(" ** FOUND LOOP IN THIS NODE **")
|
||||
sys.exit(1)
|
||||
remwires.remove(next_wire)
|
||||
check_wire(next_wire, wire)
|
||||
|
||||
while len(remwires):
|
||||
wire = remwires.pop()
|
||||
print("Checking %s:" % wire)
|
||||
check_wire(wire, None)
|
||||
|
||||
print("NO LOOP FOUND: OK")
|
||||
|
||||
|
||||
def check_tileconn_entry(tilename, tiledata, entry, idx):
|
||||
if idx == 0:
|
||||
otheridx = 1
|
||||
otherxy = (
|
||||
tiledata["grid_x"] + entry["grid_deltas"][0],
|
||||
tiledata["grid_y"] + entry["grid_deltas"][1])
|
||||
else:
|
||||
otheridx = 0
|
||||
otherxy = (
|
||||
tiledata["grid_x"] - entry["grid_deltas"][0],
|
||||
tiledata["grid_y"] - entry["grid_deltas"][1])
|
||||
|
||||
if otherxy not in grid:
|
||||
return
|
||||
|
||||
othertilename = grid[otherxy]
|
||||
othertiledata = tilegrid[othertilename]
|
||||
|
||||
if othertiledata["type"] != entry["tile_types"][otheridx]:
|
||||
return
|
||||
|
||||
print(
|
||||
" Found relevant entry (%s %s %d %d): %s" % (
|
||||
entry["tile_types"][0], entry["tile_types"][1],
|
||||
entry["grid_deltas"][0], entry["grid_deltas"][1], othertilename))
|
||||
|
||||
for pair in entry["wire_pairs"]:
|
||||
wirename = "%s/%s" % (tilename, pair[idx])
|
||||
otherwirename = "%s/%s" % (othertilename, pair[otheridx])
|
||||
|
||||
remwires.add(wirename)
|
||||
remwires.add(otherwirename)
|
||||
|
||||
if wirename not in wirepairs:
|
||||
wirepairs[wirename] = set()
|
||||
wirepairs[wirename].add(otherwirename)
|
||||
|
||||
if otherwirename not in wirepairs:
|
||||
wirepairs[otherwirename] = set()
|
||||
wirepairs[otherwirename].add(wirename)
|
||||
|
||||
|
||||
for tilename, tiledata in tilegrid.items():
|
||||
print("Connecting wires in tile %s." % tilename)
|
||||
for entry in tileconn:
|
||||
if entry["tile_types"][0] == tiledata["type"]:
|
||||
check_tileconn_entry(tilename, tiledata, entry, 0)
|
||||
if entry["tile_types"][1] == tiledata["type"]:
|
||||
check_tileconn_entry(tilename, tiledata, entry, 1)
|
||||
|
||||
|
||||
def check_wire(wire, source):
|
||||
for next_wire in wirepairs[wire]:
|
||||
if next_wire == source:
|
||||
continue
|
||||
print(" %s" % next_wire)
|
||||
if next_wire not in remwires:
|
||||
print(" ** FOUND LOOP IN THIS NODE **")
|
||||
sys.exit(1)
|
||||
remwires.remove(next_wire)
|
||||
check_wire(next_wire, wire)
|
||||
|
||||
|
||||
while len(remwires):
|
||||
wire = remwires.pop()
|
||||
print("Checking %s:" % wire)
|
||||
check_wire(wire, None)
|
||||
|
||||
print("NO LOOP FOUND: OK")
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -2,39 +2,46 @@
|
|||
|
||||
import os, sys, json
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage example: python3 %s HCLK_R HCLK_SW6E3" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
with open("%s/%s/tileconn.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
||||
os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tileconn = json.load(f)
|
||||
def main(argv):
|
||||
if len(argv) != 3:
|
||||
print("Usage example: python3 %s HCLK_R HCLK_SW6E3" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
outdata = list()
|
||||
max_tiletype_len = 1
|
||||
with open("%s/%s/tileconn.json" % (os.getenv("XRAY_DATABASE_DIR"),
|
||||
os.getenv("XRAY_DATABASE")), "r") as f:
|
||||
tileconn = json.load(f)
|
||||
|
||||
for entry in tileconn:
|
||||
if entry["tile_types"][0] == sys.argv[1]:
|
||||
this_idx, other_idx = 0, 1
|
||||
delta_x, delta_y = entry["grid_deltas"]
|
||||
elif entry["tile_types"][1] == sys.argv[1]:
|
||||
this_idx, other_idx = 1, 0
|
||||
delta_x, delta_y = -entry["grid_deltas"][0], -entry["grid_deltas"][1]
|
||||
else:
|
||||
continue
|
||||
outdata = list()
|
||||
max_tiletype_len = 1
|
||||
|
||||
for wire_pair in entry["wire_pairs"]:
|
||||
if wire_pair[this_idx] != sys.argv[2]:
|
||||
for entry in tileconn:
|
||||
if entry["tile_types"][0] == sys.argv[1]:
|
||||
this_idx, other_idx = 0, 1
|
||||
delta_x, delta_y = entry["grid_deltas"]
|
||||
elif entry["tile_types"][1] == sys.argv[1]:
|
||||
this_idx, other_idx = 1, 0
|
||||
delta_x, delta_y = -entry["grid_deltas"][0], -entry["grid_deltas"][
|
||||
1]
|
||||
else:
|
||||
continue
|
||||
|
||||
outdata.append(
|
||||
(
|
||||
delta_x, delta_y, entry["tile_types"][other_idx],
|
||||
wire_pair[other_idx]))
|
||||
max_tiletype_len = max(
|
||||
max_tiletype_len, len(entry["tile_types"][other_idx]))
|
||||
for wire_pair in entry["wire_pairs"]:
|
||||
if wire_pair[this_idx] != sys.argv[2]:
|
||||
continue
|
||||
|
||||
for entry in outdata:
|
||||
print(
|
||||
"%3d %3d %-*s %s" %
|
||||
(entry[0], entry[1], max_tiletype_len, entry[2], entry[3]))
|
||||
outdata.append(
|
||||
(
|
||||
delta_x, delta_y, entry["tile_types"][other_idx],
|
||||
wire_pair[other_idx]))
|
||||
max_tiletype_len = max(
|
||||
max_tiletype_len, len(entry["tile_types"][other_idx]))
|
||||
|
||||
for entry in outdata:
|
||||
print(
|
||||
"%3d %3d %-*s %s" %
|
||||
(entry[0], entry[1], max_tiletype_len, entry[2], entry[3]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
|
|
|
|||
Loading…
Reference in New Issue