move "wrap" function into nmutil.util
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 28 Jul 2020 10:35:49 +0000 (11:35 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 28 Jul 2020 10:35:49 +0000 (11:35 +0100)
src/nmutil/util.py

index b8f1ce4a02644bfa6ad81eae63de04dcef471b84..3aae6efeb2dc35bb8589f4da4c35f91b0c771076 100644 (file)
@@ -34,3 +34,15 @@ def eq32(is_32bit, dest, src):
             dest[32:64].eq(Mux(is_32bit, 0, src[32:64]))]
 
 
+# a wrapper function formerly in run_simulation that is still useful.
+# Simulation.add_sync_process now only takes functions, it does not
+# take generators.  so passing in arguments is no longer possible.
+# with this wrapper, the following is possible:
+#       sim.add_sync_process(wrap.dut(parallel_sender_number=0))
+#       sim.add_sync_process(wrap.dut(parallel_sender_number=1))
+
+def wrap(process):
+    def wrapper():
+        yield from process
+    return wrapper
+