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.
This commit is contained in:
David Anderson 2024-09-09 12:47:19 -07:00
parent d10a548bc1
commit b527a62ab8
2 changed files with 3 additions and 8 deletions

View File

@ -1,11 +1,5 @@
package PinSync; 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. // mkPinSync builds a synchronizer for use with asynchronous inputs.
// //
// You should only use this to capture asynchronous inputs coming from // 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 // source domain. Conceptually, we assume that register exists outside
// our design and is driving the input of mkPinSync, so we just need // our design and is driving the input of mkPinSync, so we just need
// the metastability mitigation within our own domain. // 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, _)); provisos(Bits#(val, _));
Reg#(val) r1 <- mkReg(init_value); Reg#(val) r1 <- mkReg(init_value);

View File

@ -10,7 +10,7 @@ module mkTB();
let testflags <- mkTestFlags(); let testflags <- mkTestFlags();
let cycles <- mkCycleCounter(); let cycles <- mkCycleCounter();
PinSync#(UInt#(2)) dut <- mkPinSync(0); Reg#(UInt#(2)) dut <- mkPinSync(0);
function Action check_dut_val(UInt#(2) want_val); function Action check_dut_val(UInt#(2) want_val);
return action return action