aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-07-25 11:32:45 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-07-25 11:32:45 +0100
commit14a501969af0023c7396d41a0116e706c68cf5ed (patch)
treee16a50bf122faed323bce936255e7e09b6201242 /ice40
parentc554ab1ef01c8cb5f4a35040bc3fce106be03559 (diff)
parente39290b71299843eff858fb51543b99a06178a1d (diff)
downloadnextpnr-14a501969af0023c7396d41a0116e706c68cf5ed.tar.gz
nextpnr-14a501969af0023c7396d41a0116e706c68cf5ed.tar.bz2
nextpnr-14a501969af0023c7396d41a0116e706c68cf5ed.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr into q3k/pll-pads
Diffstat (limited to 'ice40')
-rwxr-xr-xice40/picorv32_benchmark.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/ice40/picorv32_benchmark.py b/ice40/picorv32_benchmark.py
new file mode 100755
index 00000000..9544db50
--- /dev/null
+++ b/ice40/picorv32_benchmark.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+import os, sys, threading
+from os import path
+import subprocess
+import re
+
+num_runs = 8
+
+if not path.exists("picorv32.json"):
+ os.remove("picorv32.json")
+ subprocess.run(["wget", "https://raw.githubusercontent.com/cliffordwolf/picorv32/master/picorv32.v"], check=True)
+ subprocess.run(["yosys", "-q", "-p", "synth_ice40 -json picorv32.json -top top", "picorv32.v", "picorv32_top.v"], check=True)
+
+fmax = {}
+
+if not path.exists("picorv32_work"):
+ os.mkdir("picorv32_work")
+
+threads = []
+
+for i in range(num_runs):
+ def runner(run):
+ ascfile = "picorv32_work/picorv32_s{}.asc".format(run)
+ if path.exists(ascfile):
+ os.remove(ascfile)
+ result = subprocess.run(["../nextpnr-ice40", "--hx8k", "--seed", str(run), "--json", "picorv32.json", "--asc", ascfile], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
+ if result.returncode != 0:
+ print("Run {} failed!".format(run))
+ else:
+ icetime_res = subprocess.check_output(["icetime", "-d", "hx8k", ascfile])
+ fmax_m = re.search(r'\(([0-9.]+) MHz\)', icetime_res.decode('utf-8'))
+ fmax[run] = float(fmax_m.group(1))
+ threads.append(threading.Thread(target=runner, args=[i+1]))
+
+for t in threads: t.start()
+for t in threads: t.join()
+
+fmax_min = min(fmax.values())
+fmax_max = max(fmax.values())
+fmax_avg = sum(fmax.values()) / len(fmax)
+
+print("{}/{} runs passed".format(len(fmax), num_runs))
+print("icetime: min = {} MHz, avg = {} MHz, max = {} MHz".format(fmax_min, fmax_avg, fmax_max))