Make callCbs() public.

VerilatedVpi::callCbs() can be used by the user to signal
simulation-related callbacks, e.g.
VerilatedVpi::callCbs(cbStartOfSimulation).

The information if any callbacks have been called may be important to
drive an evaluation until no further changes are observed.

Signed-off-by: Lukasz Dalek <ldalek@antmicro.com>
Signed-off-by: Philipp Wagner <mail@philipp-wagner.com>
Signed-off-by: Stefan Wallentowitz <stefan@wallentowitz.de>
Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
Philipp Wagner 2019-09-21 07:43:20 -04:00 committed by Wilson Snyder
parent 96725b3431
commit d7b6b53c4d
2 changed files with 11 additions and 1 deletions

View File

@ -390,8 +390,9 @@ public:
}
return ~VL_ULL(0); // maxquad
}
static void callCbs(vluint32_t reason) {
static bool callCbs(vluint32_t reason) VL_MT_UNSAFE_ONE {
VpioCbList& cbObjList = s_s.m_cbObjLists[reason];
bool called = false;
for (VpioCbList::iterator it=cbObjList.begin(); it!=cbObjList.end();) {
if (VL_UNLIKELY(!*it)) { // Deleted earlier, cleanup
it = cbObjList.erase(it);
@ -400,7 +401,9 @@ public:
VerilatedVpioCb* vop = *it++;
VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: reason_callback %d %p\n", reason, vop););
(vop->cb_rtnp()) (vop->cb_datap());
called = true;
}
return called;
}
static void callValueCbs() VL_MT_UNSAFE_ONE {
assertOneCheck();
@ -521,6 +524,10 @@ void VerilatedVpi::callValueCbs() VL_MT_UNSAFE_ONE {
VerilatedVpiImp::callValueCbs();
}
bool VerilatedVpi::callCbs(vluint32_t reason) VL_MT_UNSAFE_ONE {
return VerilatedVpiImp::callCbs(reason);
}
//======================================================================
// VerilatedVpiImp implementation

View File

@ -45,6 +45,9 @@ public:
/// Call value based callbacks
/// Users should call this from their main loops
static void callValueCbs() VL_MT_UNSAFE_ONE;
/// Call callbacks of arbitrary types
/// Users can call this from their application code
static bool callCbs(vluint32_t reason) VL_MT_UNSAFE_ONE;
/// Self test, for internal use only
static void selfTest() VL_MT_UNSAFE_ONE;
};