aboutsummaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorJannis Harder <me@jix.one>2022-08-05 15:24:28 +0200
committerJannis Harder <me@jix.one>2022-08-16 13:37:30 +0200
commitb156fe903f75b589cb270c062a5cbd65f55e5cf6 (patch)
treeb34a466a2e6010b54cbe66fc85ae36c1a7880b6d /backends
parent475267ac254f6f5ec2202b58c26d8ea82c9d2e4a (diff)
downloadyosys-b156fe903f75b589cb270c062a5cbd65f55e5cf6.tar.gz
yosys-b156fe903f75b589cb270c062a5cbd65f55e5cf6.tar.bz2
yosys-b156fe903f75b589cb270c062a5cbd65f55e5cf6.zip
yosys-witness: Add stats command
Diffstat (limited to 'backends')
-rw-r--r--backends/smt2/witness.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/backends/smt2/witness.py b/backends/smt2/witness.py
index 03d72a17b..a1e65569d 100644
--- a/backends/smt2/witness.py
+++ b/backends/smt2/witness.py
@@ -62,6 +62,24 @@ def display(input):
yield f" {step_prefix} {sig.pretty()} = {display_bits}"
click.echo_via_pager([line + "\n" for line in output()])
+
+@cli.command(help="""
+Display statistics of a Yosys witness trace.
+""")
+@click.argument("input", type=click.File("r"))
+def stats(input):
+ click.echo(f"Reading Yosys witness trace {input.name!r}...")
+ inyw = ReadWitness(input)
+
+ total = 0
+
+ for t, values in inyw.steps():
+ click.echo(f"{t:5}: {len(values.values):8} bits")
+ total += len(values.values)
+
+ click.echo(f"total: {total:8} bits")
+
+
@cli.command(help="""
Transform a Yosys witness trace.