hdl.ast: actually remove simulator commands.
authorwhitequark <whitequark@whitequark.org>
Mon, 2 Dec 2019 02:23:36 +0000 (02:23 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 2 Dec 2019 02:24:24 +0000 (02:24 +0000)
These were supposed to be removed in 7df70059, but I forgot.

examples/basic/uart.py
nmigen/hdl/ast.py

index 1279ae0f1cc4ceb8972029198c836e383f9279dd..afbe48775cd1ad420f16d2e66ca3fa1d3c23f8c1 100644 (file)
@@ -103,44 +103,41 @@ if __name__ == "__main__":
 
     args = parser.parse_args()
     if args.action == "simulate":
-        from nmigen.hdl.ast import Passive
-        from nmigen.back import pysim
-
-        with pysim.Simulator(uart,
-                vcd_file=open("uart.vcd", "w"),
-                gtkw_file=open("uart.gtkw", "w"),
-                traces=ports) as sim:
-            sim.add_clock(1e-6)
-
-            def loopback_proc():
-                yield Passive()
-                while True:
-                    yield uart.rx_i.eq((yield uart.tx_o))
-                    yield
-            sim.add_sync_process(loopback_proc())
-
-            def transmit_proc():
-                assert (yield uart.tx_ack)
-                assert not (yield uart.rx_rdy)
-
-                yield uart.tx_data.eq(0x5A)
-                yield uart.tx_rdy.eq(1)
-                yield
-                yield uart.tx_rdy.eq(0)
+        from nmigen.back.pysim import Simulator, Passive
+
+        sim = Simulator(uart)
+        sim.add_clock(1e-6)
+
+        def loopback_proc():
+            yield Passive()
+            while True:
+                yield uart.rx_i.eq((yield uart.tx_o))
                 yield
-                assert not (yield uart.tx_ack)
+        sim.add_sync_process(loopback_proc)
 
-                for _ in range(uart.divisor * 12): yield
+        def transmit_proc():
+            assert (yield uart.tx_ack)
+            assert not (yield uart.rx_rdy)
 
-                assert (yield uart.tx_ack)
-                assert (yield uart.rx_rdy)
-                assert not (yield uart.rx_err)
-                assert (yield uart.rx_data) == 0x5A
+            yield uart.tx_data.eq(0x5A)
+            yield uart.tx_rdy.eq(1)
+            yield
+            yield uart.tx_rdy.eq(0)
+            yield
+            assert not (yield uart.tx_ack)
 
-                yield uart.rx_ack.eq(1)
-                yield
-            sim.add_sync_process(transmit_proc())
+            for _ in range(uart.divisor * 12): yield
+
+            assert (yield uart.tx_ack)
+            assert (yield uart.rx_rdy)
+            assert not (yield uart.rx_err)
+            assert (yield uart.rx_data) == 0x5A
+
+            yield uart.rx_ack.eq(1)
+            yield
+        sim.add_sync_process(transmit_proc)
 
+        with sim.write_vcd("uart.vcd", "uart.gtkw"):
             sim.run()
 
     if args.action == "generate":
index 3bc9cb05394d0aeaee94f4de402f6de26998d378..15d1d6544fb95327fd5e2f9a224dadaa7ce9d264 100644 (file)
@@ -18,8 +18,8 @@ __all__ = [
     "Signal", "ClockSignal", "ResetSignal",
     "UserValue",
     "Sample", "Past", "Stable", "Rose", "Fell", "Initial",
-    "Statement", "Assign", "Assert", "Assume", "Cover", "Switch", "Delay", "Tick",
-    "Passive", "ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict",
+    "Statement", "Assign", "Assert", "Assume", "Cover", "Switch",
+    "ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict",
     "SignalSet",
 ]
 
@@ -1404,47 +1404,6 @@ class Switch(Statement):
         return "(switch {!r} {})".format(self.test, " ".join(case_reprs))
 
 
-@final
-class Delay(Statement):
-    def __init__(self, interval=None, *, src_loc_at=0):
-        super().__init__(src_loc_at=src_loc_at)
-        self.interval = None if interval is None else float(interval)
-
-    def _rhs_signals(self):
-        return ValueSet()
-
-    def __repr__(self):
-        if self.interval is None:
-            return "(delay ε)"
-        else:
-            return "(delay {:.3}us)".format(self.interval * 1e6)
-
-
-@final
-class Tick(Statement):
-    def __init__(self, domain="sync", *, src_loc_at=0):
-        super().__init__(src_loc_at=src_loc_at)
-        self.domain = str(domain)
-
-    def _rhs_signals(self):
-        return ValueSet()
-
-    def __repr__(self):
-        return "(tick {})".format(self.domain)
-
-
-@final
-class Passive(Statement):
-    def __init__(self, *, src_loc_at=0):
-        super().__init__(src_loc_at=src_loc_at)
-
-    def _rhs_signals(self):
-        return ValueSet()
-
-    def __repr__(self):
-        return "(passive)"
-
-
 class _MappedKeyCollection(metaclass=ABCMeta):
     @abstractmethod
     def _map_key(self, key):