diff options
author | David Shah <davey1576@gmail.com> | 2018-06-14 20:46:05 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-06-14 20:46:05 +0200 |
commit | 0f0d9bfb005ebac1659efae73eb4bae9c8d76cdb (patch) | |
tree | c8f8b1b7e10d48b3c27fe8af5b9aafe25591f8b1 /ice40/transform_arachne_loc.py | |
parent | ff074e4b4c86c6edc7ed4d78886080318526d3ae (diff) | |
download | nextpnr-0f0d9bfb005ebac1659efae73eb4bae9c8d76cdb.tar.gz nextpnr-0f0d9bfb005ebac1659efae73eb4bae9c8d76cdb.tar.bz2 nextpnr-0f0d9bfb005ebac1659efae73eb4bae9c8d76cdb.zip |
ice40: Importer for placed ice40 designs from arachne
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'ice40/transform_arachne_loc.py')
-rwxr-xr-x | ice40/transform_arachne_loc.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ice40/transform_arachne_loc.py b/ice40/transform_arachne_loc.py new file mode 100755 index 00000000..14792845 --- /dev/null +++ b/ice40/transform_arachne_loc.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +import json +import sys +import re + +with open(sys.argv[1]) as f: + data = json.load(f) + +for mod, moddata in data["modules"].items(): + if "cells" in moddata: + for cell, celldata in moddata["cells"].items(): + pos = re.split('[,/]', celldata["attributes"]["loc"]) + pos = [int(_) for _ in pos] + if celldata["type"] == "ICESTORM_LC": + celldata["attributes"]["BEL"] = "X%d/Y%d/lc%d" % (pos[0], pos[1], pos[2]) + elif celldata["type"] == "SB_IO": + celldata["attributes"]["BEL"] = "X%d/Y%d/io%d" % (pos[0], pos[1], pos[2]) + elif "RAM" in celldata["type"]: + celldata["attributes"]["BEL"] = "X%d/Y%d/ram" % (pos[0], pos[1]) + elif celldata["type"] == "SB_GB": + celldata["attributes"]["BEL"] = "X%d/Y%d/gb" % (pos[0], pos[1]) + else: + assert False +print(json.dumps(data, sort_keys=True, indent=4))
\ No newline at end of file |