mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 06:03:23 +00:00
yosys-witness: add append option to yw2yw
Can now append a user defined number of steps to input traces when joining. If the number of steps is +ve, inputs are all set to 0. If -ve then steps are skipped. If all of steps are skipped (including init step) then the input trace will not be copied. If more than one input trace is provided, the append option will need to be provided the same number of times as there are input traces.
This commit is contained in:
parent
8c9a0b51d4
commit
18b44a1e84
2 changed files with 36 additions and 7 deletions
|
@ -393,12 +393,16 @@ class ReadWitness:
|
|||
def init_step(self):
|
||||
return self.step(0)
|
||||
|
||||
def non_init_bits(self):
|
||||
if len(self) > 1:
|
||||
return len(self.bits[1])
|
||||
else:
|
||||
return sum([sig.width for sig in self.signals if not sig.init_only])
|
||||
|
||||
def first_step(self):
|
||||
values = WitnessValues()
|
||||
if len(self.bits) <= 1:
|
||||
raise NotImplementedError("ReadWitness.first_step() not supported for less than 2 steps")
|
||||
non_init_bits = len(self.bits[1])
|
||||
values.unpack(WitnessSigMap([sig for sig in self.signals if not sig.init_only]), self.bits[0][-non_init_bits:])
|
||||
# may have issues when non_init_bits is 0
|
||||
values.unpack(WitnessSigMap([sig for sig in self.signals if not sig.init_only]), self.bits[0][-self.non_init_bits():])
|
||||
return values
|
||||
|
||||
def step(self, t):
|
||||
|
@ -410,5 +414,13 @@ class ReadWitness:
|
|||
for i in range(start, len(self.bits)):
|
||||
yield i, self.step(i)
|
||||
|
||||
def append_steps(self, t):
|
||||
if not t:
|
||||
pass
|
||||
elif t < 0:
|
||||
self.bits = self.bits[:t]
|
||||
else:
|
||||
self.bits.extend(["0"*self.non_init_bits()]*t)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.bits)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue