sim.pysim: avoid redundant VCD updates.
This commit properly addresses a bug introduced in2efeb05c
and then temporarily fixed in58f1d4bc
. Fixes #429.
This commit is contained in:
parent
6e7dbe004e
commit
c9fd000103
|
@ -262,11 +262,13 @@ class _PySimulation(BaseSimulation):
|
||||||
def wait_interval(self, process, interval):
|
def wait_interval(self, process, interval):
|
||||||
self.timeline.delay(interval, process)
|
self.timeline.delay(interval, process)
|
||||||
|
|
||||||
def commit(self):
|
def commit(self, changed=None):
|
||||||
converged = True
|
converged = True
|
||||||
for signal_state in self.pending:
|
for signal_state in self.pending:
|
||||||
if signal_state.commit():
|
if signal_state.commit():
|
||||||
converged = False
|
converged = False
|
||||||
|
if changed is not None:
|
||||||
|
changed.update(self.pending)
|
||||||
self.pending.clear()
|
self.pending.clear()
|
||||||
return converged
|
return converged
|
||||||
|
|
||||||
|
@ -294,6 +296,8 @@ class PySimEngine(BaseEngine):
|
||||||
process.reset()
|
process.reset()
|
||||||
|
|
||||||
def _step(self):
|
def _step(self):
|
||||||
|
changed = set() if self._vcd_writers else None
|
||||||
|
|
||||||
# Performs the two phases of a delta cycle in a loop:
|
# Performs the two phases of a delta cycle in a loop:
|
||||||
converged = False
|
converged = False
|
||||||
while not converged:
|
while not converged:
|
||||||
|
@ -303,13 +307,13 @@ class PySimEngine(BaseEngine):
|
||||||
process.runnable = False
|
process.runnable = False
|
||||||
process.run()
|
process.run()
|
||||||
|
|
||||||
for vcd_writer in self._vcd_writers:
|
|
||||||
for signal_state in self._state.pending:
|
|
||||||
vcd_writer.update(self._timeline.now,
|
|
||||||
signal_state.signal, signal_state.next)
|
|
||||||
|
|
||||||
# 2. commit: apply every queued signal change, waking up any waiting processes
|
# 2. commit: apply every queued signal change, waking up any waiting processes
|
||||||
converged = self._state.commit()
|
converged = self._state.commit(changed)
|
||||||
|
|
||||||
|
for vcd_writer in self._vcd_writers:
|
||||||
|
for signal_state in changed:
|
||||||
|
vcd_writer.update(self._timeline.now,
|
||||||
|
signal_state.signal, signal_state.curr)
|
||||||
|
|
||||||
def advance(self):
|
def advance(self):
|
||||||
self._step()
|
self._step()
|
||||||
|
|
Loading…
Reference in a new issue