From f26fb51509fefecdce79e0565e8090862ac8a361 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 1 Mar 2019 20:14:48 -0500 Subject: [PATCH] Commentary, bug1339. --- examples/tracing_c/sim_main.cpp | 8 ++++++-- examples/tracing_sc/sc_main.cpp | 8 ++++++-- include/verilated.h | 12 +++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/examples/tracing_c/sim_main.cpp b/examples/tracing_c/sim_main.cpp index 36ba2e958..5c4acbe1c 100644 --- a/examples/tracing_c/sim_main.cpp +++ b/examples/tracing_c/sim_main.cpp @@ -27,15 +27,19 @@ int main(int argc, char** argv, char** env) { // Prevent unused variable warnings if (0 && argc && argv && env) {} - // Pass arguments so Verilated code can see them, e.g. $value$plusargs - Verilated::commandArgs(argc, argv); // Set debug level, 0 is off, 9 is highest presently used + // May be overridden by commandArgs Verilated::debug(0); // Randomization reset policy + // May be overridden by commandArgs Verilated::randReset(2); + // Pass arguments so Verilated code can see them, e.g. $value$plusargs + // This needs to be called before you create any model + Verilated::commandArgs(argc, argv); + // Construct the Verilated model, from Vtop.h generated from Verilating "top.v" Vtop* top = new Vtop; // Or use a const unique_ptr, or the VL_UNIQUE_PTR wrapper diff --git a/examples/tracing_sc/sc_main.cpp b/examples/tracing_sc/sc_main.cpp index 078025909..1b33bbd8e 100644 --- a/examples/tracing_sc/sc_main.cpp +++ b/examples/tracing_sc/sc_main.cpp @@ -24,15 +24,19 @@ int sc_main(int argc, char* argv[]) { // Prevent unused variable warnings if (0 && argc && argv) {} - // Pass arguments so Verilated code can see them, e.g. $value$plusargs - Verilated::commandArgs(argc, argv); // Set debug level, 0 is off, 9 is highest presently used + // May be overridden by commandArgs Verilated::debug(0); // Randomization reset policy + // May be overridden by commandArgs Verilated::randReset(2); + // Pass arguments so Verilated code can see them, e.g. $value$plusargs + // This needs to be called before you create any model + Verilated::commandArgs(argc, argv); + // General logfile ios::sync_with_stdio(); diff --git a/include/verilated.h b/include/verilated.h index a02fc5c37..fc19cdb1c 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -438,7 +438,9 @@ public: static void flushCb(VerilatedVoidCb cb) VL_MT_SAFE; static void flushCall() VL_MT_SAFE; - /// Record command line arguments, for retrieval by $test$plusargs/$value$plusargs + /// Record command line arguments, for retrieval by $test$plusargs/$value$plusargs, + /// and for parsing +verilator+ run-time arguments. + /// This should be called before the first model is created. static void commandArgs(int argc, const char** argv) VL_MT_SAFE; static void commandArgs(int argc, char** argv) VL_MT_SAFE { commandArgs(argc, const_cast(argv)); } @@ -563,13 +565,13 @@ extern void VL_PRINTF_MT(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; /// Print a debug message from internals with standard prefix, with printf style format extern void VL_DBG_MSGF(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; -extern IData VL_RANDOM_I(int obits); ///< Randomize a signal -extern QData VL_RANDOM_Q(int obits); ///< Randomize a signal +extern IData VL_RANDOM_I(int obits); ///< Randomize a signal +extern QData VL_RANDOM_Q(int obits); ///< Randomize a signal extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); ///< Randomize a signal /// Init time only, so slow is fine -extern IData VL_RAND_RESET_I(int obits); ///< Random reset a signal -extern QData VL_RAND_RESET_Q(int obits); ///< Random reset a signal +extern IData VL_RAND_RESET_I(int obits); ///< Random reset a signal +extern QData VL_RAND_RESET_Q(int obits); ///< Random reset a signal extern WDataOutP VL_RAND_RESET_W(int obits, WDataOutP outwp); ///< Random reset a signal extern WDataOutP VL_ZERO_RESET_W(int obits, WDataOutP outwp); ///< Zero reset a signal (slow - else use VL_ZERO_W)