lib.cdc: use a local clock domain in ResetSynchronizer.
authorwhitequark <whitequark@whitequark.org>
Mon, 19 Aug 2019 20:47:40 +0000 (20:47 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 19 Aug 2019 21:45:08 +0000 (21:45 +0000)
This reverts commit 779f3ee906190b92e5a07e5adcd62b20213bb936.
This reverts commit 300d47ca2ebbabb31d2f191acf80c9b89659c4f0.
This reverts commit 9c54d0c061884317d1558de9f9be52d1ec8dea68.

nmigen/back/pysim.py
nmigen/lib/cdc.py

index 445acf0babf1d993a33977bf607a7c26d0ea22b3..a89556fc9a8e21e6ddd3c49d5bd0401037216066 100644 (file)
@@ -10,9 +10,6 @@ from ..tools import flatten
 from ..hdl.ast import *
 from ..hdl.ir import *
 from ..hdl.xfrm import ValueVisitor, StatementVisitor
-from ..hdl.ast import DUID
-from ..hdl.dsl import Module
-from ..hdl.cd import ClockDomain
 
 
 __all__ = ["Simulator", "Delay", "Tick", "Passive", "DeadlineError"]
@@ -359,24 +356,9 @@ class _StatementCompiler(StatementVisitor):
         return run
 
 
-class _SimulatorPlatform:
-    def get_reset_sync(self, reset_sync):
-        m = Module()
-        cd = ClockDomain("_reset_sync_{}".format(DUID().duid), async_reset=True)
-        m.domains += cd
-        for i, o in zip((0, *reset_sync._regs), reset_sync._regs):
-            m.d[cd.name] += o.eq(i)
-        m.d.comb += [
-            ClockSignal(cd.name).eq(ClockSignal(reset_sync.domain)),
-            ResetSignal(cd.name).eq(reset_sync.arst),
-            ResetSignal(reset_sync.domain).eq(reset_sync._regs[-1])
-        ]
-        return m
-
-
 class Simulator:
     def __init__(self, fragment, vcd_file=None, gtkw_file=None, traces=()):
-        self._fragment        = Fragment.get(fragment, platform=_SimulatorPlatform())
+        self._fragment        = Fragment.get(fragment, platform=None)
 
         self._signal_slots    = SignalDict()  # Signal -> int/slot
         self._slot_signals    = list()        # int/slot -> Signal
index 802a865d0020adbe64cddc95c78d6d4be4b927a6..9b0cc073bbaa4597310d29a8cfba29f3843808a2 100644 (file)
@@ -82,16 +82,12 @@ class ResetSynchronizer(Elaboratable):
             return platform.get_reset_sync(self)
 
         m = Module()
-        for i, o in zip((Const(0, 1), *self._regs), self._regs):
-            m.submodules += Instance("$adff",
-                p_CLK_POLARITY=1,
-                p_ARST_POLARITY=1,
-                p_ARST_VALUE=Const(1, 1),
-                p_WIDTH=1,
-                i_CLK=ClockSignal(self.domain),
-                i_ARST=self.arst,
-                i_D=i,
-                o_Q=o
-            )
-        m.d.comb += ResetSignal(self.domain).eq(self._regs[-1])
+        m.domains += ClockDomain("reset_sync", async_reset=True, local=True)
+        for i, o in zip((0, *self._regs), self._regs):
+            m.d.reset_sync += o.eq(i)
+        m.d.comb += [
+            ClockSignal("reset_sync").eq(ClockSignal(self.domain)),
+            ResetSignal("reset_sync").eq(self.arst),
+            ResetSignal(self.domain).eq(self._regs[-1])
+        ]
         return m