aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-07 15:04:07 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-07 15:04:07 +0200
commit1d39924c1417295c8c24598d362293f0eff2af89 (patch)
tree57b73c4b044cc5d24de682c58a20c632e1170916 /python
parent547d4fe3ee192ca96280626cefdbe6d180d0ef75 (diff)
downloadnextpnr-1d39924c1417295c8c24598d362293f0eff2af89.tar.gz
nextpnr-1d39924c1417295c8c24598d362293f0eff2af89.tar.bz2
nextpnr-1d39924c1417295c8c24598d362293f0eff2af89.zip
ice40: More Python bindings and examples
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'python')
-rw-r--r--python/functions.py23
-rw-r--r--python/python_test.py4
2 files changed, 21 insertions, 6 deletions
diff --git a/python/functions.py b/python/functions.py
index 4f005456..8d2e2fb8 100644
--- a/python/functions.py
+++ b/python/functions.py
@@ -1,2 +1,21 @@
-def test_function():
- print("Hello World!")
+def get_drivers(wire):
+ wid = chip.getWireByName(wire)
+ assert not wid.nil(), "wire {} not found".format(wire)
+ bp = chip.getBelPinUphill(wid)
+ if not bp.bel.nil():
+ print("Bel pin: {}.{}".format(chip.getBelName(bp.bel), str(bp.pin)))
+ for pip in sorted(chip.getPipsUphill(wid), key=lambda x: x.index):
+ print("Pip: {}".format(chip.getWireName(chip.getPipSrcWire(pip))))
+
+
+def get_loads(wire):
+ wid = chip.getWireByName(wire)
+ assert not wid.nil(), "wire {} not found".format(wire)
+ for bp in sorted(chip.getBelPinsDownhill(wid), key=lambda x: (x.bel.index, x.pin)):
+ print("Bel pin: {}.{}".format(chip.getBelName(bp.bel), str(bp.pin)))
+ for pip in sorted(chip.getPipsDownhill(wid), key=lambda x: x.index):
+ print("Pip: {}".format(chip.getWireName(chip.getPipDstWire(pip))))
+
+
+#get_drivers("12_14_lutff_7/in_3")
+#get_loads("12_14_lutff_global/clk")
diff --git a/python/python_test.py b/python/python_test.py
index 1a6ebfc6..31d066b2 100644
--- a/python/python_test.py
+++ b/python/python_test.py
@@ -1,6 +1,2 @@
-from nextpnrpy_ice40 import Chip, ChipArgs, iCE40Type
-args = ChipArgs()
-args.type = iCE40Type.LP384
-chip = Chip(args)
for wire in chip.getWires():
print(chip.getWireName(wire))