diff --git a/lib/PinSync.bsv b/lib/PinSync.bsv index a7db442..9b50f84 100644 --- a/lib/PinSync.bsv +++ b/lib/PinSync.bsv @@ -1,5 +1,11 @@ package PinSync; +(* always_ready, always_enabled *) +interface PinSync#(type val); + method Action _write(val a); + method val _read(); +endinterface + // mkPinSync builds a synchronizer for use with asynchronous inputs. // // You should only use this to capture asynchronous inputs coming from @@ -18,7 +24,7 @@ package PinSync; // source domain. Conceptually, we assume that register exists outside // our design and is driving the input of mkPinSync, so we just need // the metastability mitigation within our own domain. -module mkPinSync(val init_value, Reg#(val) ifc) +module mkPinSync(val init_value, PinSync#(val) ifc) provisos(Bits#(val, _)); Reg#(val) r1 <- mkReg(init_value); diff --git a/lib/PinSync_Test.bsv b/lib/PinSync_Test.bsv index 37fec83..6052e88 100644 --- a/lib/PinSync_Test.bsv +++ b/lib/PinSync_Test.bsv @@ -10,7 +10,7 @@ module mkTB(); let testflags <- mkTestFlags(); let cycles <- mkCycleCounter(); - Reg#(UInt#(2)) dut <- mkPinSync(0); + PinSync#(UInt#(2)) dut <- mkPinSync(0); function Action check_dut_val(UInt#(2) want_val); return action