diff --git a/Changes b/Changes index 9a8c2c443..55d08cb3a 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ Verilator 5.025 devel * Add CITATION.cff (#5057) (#5058). [Gijs Burghoorn] * Add VPI eval needed tracking (#5065). [Todd Strader] * Add `--localize-max-size` option and optimization (#5072). +* Add traceCapable indication to model header (#5053). [Vito Gamberini] * Fix missing flex include path variable (#4970) (#4971). [Christopher Taylor] * Fix missing parameters with comma to be errors (#4979) (#5012). [Paul Swirhun] * Fix bound queue printing (#5032). [Aleksander Kiryk, Antmicro Ltd.] diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index f66493580..49dda63c2 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -101,6 +101,12 @@ class EmitCModel final : public EmitCFunc { puts("\n"); ofp()->putsPrivate(false); // public: + + puts("\n// CONSTEXPR CAPABILITIES\n"); + puts("// Verilated with --trace?\n"); + puts("static constexpr bool traceCapable = "s + + (v3Global.opt.trace() ? "true;\n"s : "false;\n"s)); + // User accessible IO puts("\n// PORTS\n" "// The application code writes and reads these signals to\n" diff --git a/test_regress/t/t_trace_cat.cpp b/test_regress/t/t_trace_cat.cpp index 1dc631d14..7b6b9ec26 100644 --- a/test_regress/t/t_trace_cat.cpp +++ b/test_regress/t/t_trace_cat.cpp @@ -13,6 +13,10 @@ #include VM_PREFIX_INCLUDE +#include "TestCheck.h" + +int errors = 0; + unsigned long long main_time = 0; double sc_time_stamp() { return (double)main_time; } @@ -32,6 +36,9 @@ int main(int argc, char** argv) { std::unique_ptr tfp{new VerilatedVcdC}; top->trace(tfp.get(), 99); + // Test for traceCapable - randomly-ish selected this test + TEST_CHECK_EQ(top->traceCapable, true); + tfp->open(trace_name()); top->clk = 0; @@ -63,5 +70,5 @@ int main(int argc, char** argv) { tfp.reset(); top.reset(); printf("*-* All Finished *-*\n"); - return 0; + return errors; }