back.pysim: extract simulator commands to sim._cmds. NFC.
authorwhitequark <whitequark@whitequark.org>
Wed, 8 Jul 2020 05:42:33 +0000 (05:42 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 31 Dec 2021 14:48:07 +0000 (14:48 +0000)
nmigen/back/pysim.py
nmigen/sim/__init__.py [new file with mode: 0644]
nmigen/sim/_cmds.py [new file with mode: 0644]

index a9c6c162ac09cc5e9953a6f10e609c3cd69e961f..f3c1feccc1aafabacb55328ae67706b256646795 100644 (file)
@@ -12,48 +12,10 @@ from ..hdl.ast import *
 from ..hdl.cd import *
 from ..hdl.ir import *
 from ..hdl.xfrm import ValueVisitor, StatementVisitor, LHSGroupFilter
+from ..sim._cmds import *
 
 
-class Command:
-    pass
-
-
-class Settle(Command):
-    def __repr__(self):
-        return "(settle)"
-
-
-class Delay(Command):
-    def __init__(self, interval=None):
-        self.interval = None if interval is None else float(interval)
-
-    def __repr__(self):
-        if self.interval is None:
-            return "(delay ε)"
-        else:
-            return "(delay {:.3}us)".format(self.interval * 1e6)
-
-
-class Tick(Command):
-    def __init__(self, domain="sync"):
-        if not isinstance(domain, (str, ClockDomain)):
-            raise TypeError("Domain must be a string or a ClockDomain instance, not {!r}"
-                            .format(domain))
-        assert domain != "comb"
-        self.domain = domain
-
-    def __repr__(self):
-        return "(tick {})".format(self.domain)
-
-
-class Passive(Command):
-    def __repr__(self):
-        return "(passive)"
-
-
-class Active(Command):
-    def __repr__(self):
-        return "(active)"
+__all__ = ["Settle", "Delay", "Tick", "Passive", "Active", "Simulator"]
 
 
 class _WaveformWriter:
diff --git a/nmigen/sim/__init__.py b/nmigen/sim/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/nmigen/sim/_cmds.py b/nmigen/sim/_cmds.py
new file mode 100644 (file)
index 0000000..a1cea3e
--- /dev/null
@@ -0,0 +1,46 @@
+from ..hdl.cd import *
+
+
+__all__ = ["Settle", "Delay", "Tick", "Passive", "Active"]
+
+
+class Command:
+    pass
+
+
+class Settle(Command):
+    def __repr__(self):
+        return "(settle)"
+
+
+class Delay(Command):
+    def __init__(self, interval=None):
+        self.interval = None if interval is None else float(interval)
+
+    def __repr__(self):
+        if self.interval is None:
+            return "(delay ε)"
+        else:
+            return "(delay {:.3}us)".format(self.interval * 1e6)
+
+
+class Tick(Command):
+    def __init__(self, domain="sync"):
+        if not isinstance(domain, (str, ClockDomain)):
+            raise TypeError("Domain must be a string or a ClockDomain instance, not {!r}"
+                            .format(domain))
+        assert domain != "comb"
+        self.domain = domain
+
+    def __repr__(self):
+        return "(tick {})".format(self.domain)
+
+
+class Passive(Command):
+    def __repr__(self):
+        return "(passive)"
+
+
+class Active(Command):
+    def __repr__(self):
+        return "(active)"