lib/PinSync: use an explicit type

To make them more obviously not normal registers, and to add
annotations to make the scheduling more annoying if you try
holding them wrong.
This commit is contained in:
David Anderson 2024-09-09 12:47:19 -07:00
parent 2ff58b51d2
commit 07de394ddb
2 changed files with 8 additions and 2 deletions

View File

@ -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);

View File

@ -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