Add assertion on reusing VerilatedContext (#5167).

This commit is contained in:
Wilson Snyder
2024-06-11 19:38:58 -04:00
parent 920ed5ca3d
commit fd1e4d9e45
10 changed files with 79 additions and 58 deletions
+9 -1
View File
@@ -2664,8 +2664,16 @@ void VerilatedContext::addModel(VerilatedModel* modelp) {
m_ns.m_cpuTimeStart.start();
m_ns.m_wallTimeStart.start();
}
threadPoolp(); // Ensure thread pool is created, so m_threads cannot change any more
// We look for time passing, as opposed to post-eval(), as embedded
// models might get added inside initial blocks.
if (VL_UNLIKELY(time()))
VL_FATAL_MT(
__FILE__, __LINE__, "",
"Adding model when time is non-zero. ... Suggest check time(), or for restarting"
" model use a new VerilatedContext");
threadPoolp(); // Ensure thread pool is created, so m_threads cannot change any more
m_threadsInModels += modelp->threads();
if (VL_UNLIKELY(modelp->threads() > m_threads)) {
std::ostringstream msg;