aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-01 14:00:51 -0800
committerKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-02 07:53:11 -0800
commita4369afae529297fd684eafbb75654f2bd27b780 (patch)
tree9657e80835fddd2047a61ddee0b8100ad3e91af3 /python
parentefc98c517eb1d2eb4a8ecc2ae82e770aaa1a0edd (diff)
downloadnextpnr-a4369afae529297fd684eafbb75654f2bd27b780.tar.gz
nextpnr-a4369afae529297fd684eafbb75654f2bd27b780.tar.bz2
nextpnr-a4369afae529297fd684eafbb75654f2bd27b780.zip
Add simple python file for doing Arch API sanity checks.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
Diffstat (limited to 'python')
-rw-r--r--python/check_arch_api.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/python/check_arch_api.py b/python/check_arch_api.py
new file mode 100644
index 00000000..647faefc
--- /dev/null
+++ b/python/check_arch_api.py
@@ -0,0 +1,57 @@
+""" Script to do Arch API sanity checking.
+
+This python script can be used to do some sanity checking of either wire to
+wire connectivity or bel pin wire connectivity.
+
+Wire to wire connectivity is tested by supplying a source and destination wire
+and verifing that a pip exists that connects those wires.
+
+Bel pin wire connectivity is tested by supplying a bel and pin name and the
+connected wire.
+
+Invoke in a working directory that contains a file name "test_data.yaml":
+ ${NEXTPNR} --run ${NEXTPNR_SRC}/check_arch_api.py
+
+"test_data.yaml" should contain the test vectors for the wire to wire or bel
+pin connectivity tests. Example test_data.yaml:
+
+pip_test:
+ - src_wire: CLBLM_R_X11Y93/CLBLM_L_D3
+ dst_wire: SLICE_X15Y93.SLICEL/D3
+bel_pin_test:
+ - bel: SLICE_X15Y93.SLICEL/D6LUT
+ pin: A3
+ wire: SLICE_X15Y93.SLICEL/D3
+
+"""
+import yaml
+
+
+def check_arch_api(ctx):
+ pips_tested = 0
+ bel_pins_tested = 0
+ with open('test_data.yaml', 'r') as f:
+ test_data = yaml.safe_load(f.read())
+ if 'pip_test' in test_data:
+ for pip_test in test_data['pip_test']:
+ pip = None
+ for pip_name in ctx.getPipsDownhill(pip_test['src_wire']):
+ if ctx.getPipDstWire(pip_name) == pip_test['dst_wire']:
+ pip = pip_name
+ src_wire = ctx.getPipSrcWire(pip_name)
+ assert src_wire == pip_test['src_wire'], (
+ src_wire, pip_test['src_wire'])
+
+ assert pip is not None
+ pips_tested += 1
+
+ if 'bel_pin_test' in test_data:
+ for bel_pin_test in test_data['bel_pin_test']:
+ wire_name = ctx.getBelPinWire(bel_pin_test['bel'], bel_pin_test['pin'])
+ assert bel_pin_test['wire'] == wire_name, (bel_pin_test['wire'], wire_name)
+
+ bel_pins_tested += 1
+
+ print('Tested {} pips and {} bel pins'.format(pips_tested, bel_pins_tested))
+
+check_arch_api(ctx)