ice40: Importer for placed ice40 designs from arachne

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-06-14 20:46:05 +02:00
parent ff074e4b4c
commit 0f0d9bfb00
3 changed files with 35 additions and 0 deletions

2
ice40/.gitignore vendored
View File

@ -3,3 +3,5 @@
/blinky_tb.vcd /blinky_tb.vcd
/picorv32.v /picorv32.v
/chipdbs/ /chipdbs/
*.blif

9
ice40/picorv32_arachne.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -ex
rm -f picorv32.v
wget https://raw.githubusercontent.com/cliffordwolf/picorv32/master/picorv32.v
yosys -p 'synth_ice40 -nocarry -blif picorv32.blif -top top' picorv32.v picorv32_top.v
arachne-pnr -d 8k --post-place-blif picorv32_place.blif picorv32.blif
yosys picorv32_place.blif -o picorv32_place.json
./transform_arachne_loc.py picorv32_place.json > picorv32_place_nx.json
../nextpnr-ice40 --hx8k --asc picorv32.asc --json picorv32_place_nx.json

24
ice40/transform_arachne_loc.py Executable file
View File

@ -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))