yosys-witness: Add stats command

This commit is contained in:
Jannis Harder 2022-08-05 15:24:28 +02:00
parent 475267ac25
commit b156fe903f
1 changed files with 18 additions and 0 deletions

View File

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