mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-18 17:22:17 +00:00
Merge pull request #3902 from YosysHQ/krys/yw_join
yosys-witness concat yw trace files
This commit is contained in:
commit
c6caadfed4
2 changed files with 87 additions and 15 deletions
|
@ -84,26 +84,65 @@ def stats(input):
|
|||
Transform a Yosys witness trace.
|
||||
|
||||
Currently no transformations are implemented, so it is only useful for testing.
|
||||
If two or more inputs are provided they will be concatenated together into the output.
|
||||
""")
|
||||
@click.argument("input", type=click.File("r"))
|
||||
@click.argument("inputs", type=click.File("r"), nargs=-1)
|
||||
@click.argument("output", type=click.File("w"))
|
||||
def yw2yw(input, output):
|
||||
click.echo(f"Copying yosys witness trace from {input.name!r} to {output.name!r}...")
|
||||
inyw = ReadWitness(input)
|
||||
@click.option("--append", "-p", type=int, multiple=True,
|
||||
help="Number of steps (+ve or -ve) to append to end of input trace. "
|
||||
+"Can be defined multiple times, following the same order as input traces. ")
|
||||
def yw2yw(inputs, output, append):
|
||||
outyw = WriteWitness(output, "yosys-witness yw2yw")
|
||||
join_inputs = len(inputs) > 1
|
||||
inyws = {}
|
||||
|
||||
for clock in inyw.clocks:
|
||||
outyw.add_clock(clock["path"], clock["offset"], clock["edge"])
|
||||
if not append:
|
||||
# default to 0
|
||||
append = [0] * len(inputs)
|
||||
if len(append) != len(inputs):
|
||||
print(f"Mismatch in number of --append values ({len(append)}) and input traces ({len(inputs)}).")
|
||||
sys.exit(1)
|
||||
|
||||
for sig in inyw.signals:
|
||||
outyw.add_sig(sig.path, sig.offset, sig.width, sig.init_only)
|
||||
for (input, p) in zip(inputs, append):
|
||||
if (join_inputs):
|
||||
click.echo(f"Loading signals from yosys witness trace {input.name!r}...")
|
||||
inyw = ReadWitness(input)
|
||||
if p:
|
||||
click.echo(f" appending {p} steps")
|
||||
if (p + len(inyw) <= 0):
|
||||
click.echo(f" skipping {input.name!r} (only {len(inyw)} steps to skip)")
|
||||
continue
|
||||
inyw.append_steps(p)
|
||||
inyws[input] = inyw
|
||||
for clock in inyw.clocks:
|
||||
if clock not in outyw.clocks:
|
||||
outyw.add_clock(clock["path"], clock["offset"], clock["edge"])
|
||||
|
||||
for t, values in inyw.steps():
|
||||
outyw.step(values)
|
||||
for sig in inyw.signals:
|
||||
if sig not in outyw.signals:
|
||||
outyw.add_sig(sig.path, sig.offset, sig.width, sig.init_only)
|
||||
|
||||
init_values = sum([inyw.init_step() for inyw in inyws.values()], start=WitnessValues())
|
||||
|
||||
first_witness = True
|
||||
for (input, inyw) in inyws.items():
|
||||
click.echo(f"Copying yosys witness trace from {input.name!r} to {output.name!r}...")
|
||||
|
||||
if first_witness:
|
||||
outyw.step(init_values)
|
||||
else:
|
||||
outyw.step(inyw.first_step())
|
||||
|
||||
for t, values in inyw.steps(1):
|
||||
outyw.step(values)
|
||||
|
||||
click.echo(f" copied {t + 1} time steps.")
|
||||
first_witness = False
|
||||
|
||||
outyw.end_trace()
|
||||
|
||||
click.echo(f"Copied {outyw.t + 1} time steps.")
|
||||
if join_inputs:
|
||||
click.echo(f"Copied {outyw.t} total time steps.")
|
||||
|
||||
|
||||
class AigerMap:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue