From b527a62ab8228c74a174cb5ab94690eb8bf1f711 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 9 Sep 2024 12:47:19 -0700 Subject: [PATCH] lib/PinSync: switch back to Reg type, annotate required timing I was mostly using a separate interface to be able to mark the methods always_enabled and always_ready, but you can attach those annotations to the module constructor instead. --- lib/PinSync.bsv | 9 ++------- lib/PinSync_Test.bsv | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/PinSync.bsv b/lib/PinSync.bsv index 9b50f84..11b5246 100644 --- a/lib/PinSync.bsv +++ b/lib/PinSync.bsv @@ -1,11 +1,5 @@ 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 @@ -24,7 +18,8 @@ endinterface // 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, PinSync#(val) ifc) +(* always_enabled="_write",always_ready="_read" *) +module mkPinSync(val init_value, Reg#(val) ifc) provisos(Bits#(val, _)); Reg#(val) r1 <- mkReg(init_value); diff --git a/lib/PinSync_Test.bsv b/lib/PinSync_Test.bsv index 6052e88..37fec83 100644 --- a/lib/PinSync_Test.bsv +++ b/lib/PinSync_Test.bsv @@ -10,7 +10,7 @@ module mkTB(); let testflags <- mkTestFlags(); let cycles <- mkCycleCounter(); - PinSync#(UInt#(2)) dut <- mkPinSync(0); + Reg#(UInt#(2)) dut <- mkPinSync(0); function Action check_dut_val(UInt#(2) want_val); return action