add ifc_sync module
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 29 Jul 2018 08:54:00 +0000 (09:54 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 29 Jul 2018 08:54:00 +0000 (09:54 +0100)
src/lib/ifc_sync.bsv [new file with mode: 0644]

diff --git a/src/lib/ifc_sync.bsv b/src/lib/ifc_sync.bsv
new file mode 100644 (file)
index 0000000..b6878d7
--- /dev/null
@@ -0,0 +1,32 @@
+package ifc_sync;
+
+  import Clocks::*;
+  import GetPut::*;
+
+  interface Ifc_sync#(type a);
+    interface Put#(a) put;
+    interface Get#(a) get;
+  endinterface
+  module mksyncconnection#(Clock putclock, Reset putreset,
+                           Clock getclock, Reset getreset)(Ifc_sync#(a))
+    provisos(Bits#(a, a__));
+    CrossingReg#(a) null_wire<- mkNullCrossingReg(getclock,?,
+                                        clocked_by putclock,
+                                        reset_by putreset);
+ //   ReadOnly#(Bit#(a)) null_wire <- mkNullCrossingWire(getclock, 
+//                                  from_put, clocked_by getclock,
+//                                  reset_by getreset);
+    interface put = interface Put
+      method Action put(a in);
+        null_wire<= in;
+      endmethod
+    endinterface;
+    interface get = interface Get
+      method ActionValue#(a) get();
+        return null_wire.crossed;
+      endmethod
+    endinterface;
+  endmodule
+
+endpackage;
+