SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
yosys_gate_chains.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
"""Measure maximal-chain folding, including input parsing and process startup.
3
4
Usage: python3 benchmarks/yosys_gate_chains.py build/yosys/silicon_bmux_case.so
5
Requires yosys on PATH. Each size is tested in both cell insertion orders.
6
"""
7
import
json
8
from
pathlib
import
Path
9
import
statistics
10
import
subprocess
11
import
sys
12
import
tempfile
13
import
time
14
15
plugin = Path(sys.argv[1]).resolve()
16
with
tempfile.TemporaryDirectory(prefix=
"silicon_gate_scaling_"
)
as
directory:
17
source = Path(directory) /
"chain.il"
18
for
count
in
(1000, 2000, 4000, 8000, 16000):
19
for
reverse
in
(
False
,
True
):
20
cells = []
21
for
i
in
range(count):
22
cells.append(f
""" cell $and \\g{i:06}
23
parameter \\A_WIDTH 1
24
parameter \\B_WIDTH 1
25
parameter \\Y_WIDTH 1
26
parameter \\A_SIGNED 0
27
parameter \\B_SIGNED 0
28
connect \\A \\a [0]
29
connect \\B \\{'a' if i == 0 else 'n'} [{i + 1 if i == 0 else i - 1}]
30
connect \\Y \\n [{i}]
31
end
32
"""
)
33
if
reverse:
34
cells.reverse()
35
source.write_text(f
"module \\top\n wire width {count + 1} input 1 \\a\n"
36
f
" wire width {count} \\n\n wire output 2 \\y\n"
37
+
""
.join(cells) + f
" connect \\y \\n [{count - 1}]\nend\n"
)
38
samples = []
39
for
_
in
range(3):
40
started = time.perf_counter()
41
subprocess.run([
"yosys"
,
"-Q"
,
"-T"
,
"-q"
,
"-m"
, str(plugin),
"-p"
,
42
f
'read_rtlil "{source}"; silicon_gates'
], check=
True
)
43
samples.append(time.perf_counter() - started)
44
print(json.dumps({
"gates"
: count,
"reverse"
: reverse,
45
"seconds"
: round(statistics.median(samples), 6)}), flush=
True
)
benchmarks
yosys_gate_chains.py
Generated by
1.17.0