From e8f93d0d1ad5cb83c735e10000e07f3a00858786 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 18 Dec 2018 04:37:39 +0000 Subject: [PATCH] back.pysim: trigger processes waiting on Tick() exactly at clock edge. --- nmigen/back/pysim.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 5cb7ebf..65357bf 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -539,6 +539,13 @@ class Simulator: del self._wait_tick[process] self._suspended.remove(process) + # Immediately run the process. It is important that this happens here, + # and not on the next step, when all the processes will run anyway, + # because Tick() simulates an edge triggered process. Like DFFs that latch + # a value from the previous clock cycle, simulator processes observe signal + # values from the previous clock cycle on a tick, too. + self._run_process(process) + # Unless handling synchronous logic above has triggered more synchronous logic (which # can happen e.g. if a domain is clocked off a clock divisor in fabric), we're done. # Otherwise, do one more round of updates. -- 2.30.2