From 510be53521f58575d0b414ba69c8c23d4249cf85 Mon Sep 17 00:00:00 2001 From: Matthew Ballance Date: Sat, 28 Mar 2020 13:47:21 -0400 Subject: [PATCH] Expose VPI cbNextDeadline via the public API (#2212) Signed-off-by: Matthew Ballance --- include/verilated_vpi.cpp | 4 ++++ include/verilated_vpi.h | 3 +++ test_regress/t/t_vpi_time_cb.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 101d23f79..f76e75894 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -566,6 +566,10 @@ bool VerilatedVpi::callCbs(vluint32_t reason) VL_MT_UNSAFE_ONE { return VerilatedVpiImp::callCbs(reason); } +QData VerilatedVpi::cbNextDeadline() VL_MT_UNSAFE_ONE { + return VerilatedVpiImp::cbNextDeadline(); +} + //====================================================================== // VerilatedVpiImp implementation diff --git a/include/verilated_vpi.h b/include/verilated_vpi.h index 65756cf3a..dea1bb9e0 100644 --- a/include/verilated_vpi.h +++ b/include/verilated_vpi.h @@ -44,6 +44,9 @@ public: /// Call callbacks of arbitrary types /// Users can call this from their application code static bool callCbs(vluint32_t reason) VL_MT_UNSAFE_ONE; + /// Returns time of the next registered VPI callback, or + /// ~(0) if none are registered + static QData cbNextDeadline() VL_MT_UNSAFE_ONE; /// Self test, for internal use only static void selfTest() VL_MT_UNSAFE_ONE; }; diff --git a/test_regress/t/t_vpi_time_cb.cpp b/test_regress/t/t_vpi_time_cb.cpp index 596a38035..12a5e774b 100644 --- a/test_regress/t/t_vpi_time_cb.cpp +++ b/test_regress/t/t_vpi_time_cb.cpp @@ -235,6 +235,7 @@ int main(int argc, char** argv, char** env) { topp->eval(); VerilatedVpi::callValueCbs(); VerilatedVpi::callTimedCbs(); + CHECK_RESULT(VerilatedVpi::cbNextDeadline(), main_time+1); topp->clk = !topp->clk; // mon_do(); #if VM_TRACE