From 19ca140165cd789c12c5203a53cb81993b8879fe Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 20 Sep 2025 11:02:42 -0400 Subject: [PATCH] Improve adding model error message --- include/verilated.cpp | 12 +++++++----- test_regress/t/t_wrapper_reuse_context_bad.out | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 18ab07f15..39ff67b1b 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -2849,11 +2849,13 @@ void VerilatedContext::addModel(const VerilatedModel* modelp) { // 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( - "", 0, "", - "Adding model when time is non-zero. ... Suggest check time(), or for restarting" - " model use a new VerilatedContext"); + if (VL_UNLIKELY(time())) { + const std::string msg + = "Adding model '"s + modelp->hierName() + + "' when time is non-zero. ... Suggest check time(), or for restarting" + " model use a new VerilatedContext"; + VL_FATAL_MT("", 0, "", msg.c_str()); + } threadPoolp(); // Ensure thread pool is created, so m_threads cannot change any more m_threadsInModels += modelp->threads(); diff --git a/test_regress/t/t_wrapper_reuse_context_bad.out b/test_regress/t/t_wrapper_reuse_context_bad.out index 66e87adb9..260527d29 100644 --- a/test_regress/t/t_wrapper_reuse_context_bad.out +++ b/test_regress/t/t_wrapper_reuse_context_bad.out @@ -1,2 +1,2 @@ -%Error: Adding model when time is non-zero. ... Suggest check time(), or for restarting model use a new VerilatedContext +%Error: Adding model 'TOP' when time is non-zero. ... Suggest check time(), or for restarting model use a new VerilatedContext Aborting...