diff --git a/src/V3EmitCMain.cpp b/src/V3EmitCMain.cpp index 87fd518ad..cfe83de6b 100644 --- a/src/V3EmitCMain.cpp +++ b/src/V3EmitCMain.cpp @@ -64,8 +64,8 @@ private: puts("int main(int argc, char** argv, char**) {\n"); puts("// Setup context, defaults, and parse command line\n"); puts("Verilated::debug(0);\n"); - if (v3Global.opt.trace()) puts("Verilated::traceEverOn(true);\n"); puts("const std::unique_ptr contextp{new VerilatedContext};\n"); + if (v3Global.opt.trace()) puts("contextp->traceEverOn(true);\n"); puts("contextp->commandArgs(argc, argv);\n"); puts("\n"); diff --git a/test_regress/t/t_trace_binary.out b/test_regress/t/t_trace_binary.out new file mode 100644 index 000000000..32d4f8ec5 --- /dev/null +++ b/test_regress/t/t_trace_binary.out @@ -0,0 +1,16 @@ +$version Generated by VerilatedVcd $end +$date Sun Oct 9 14:08:37 2022 $end +$timescale 1ps $end + + $scope module TOP $end + $scope module t $end + $var wire 32 # sig [31:0] $end + $upscope $end + $upscope $end +$enddefinitions $end + + +#0 +b00000000000000000000000000001010 # +#20 +b00000000000000000000000000010100 # diff --git a/test_regress/t/t_trace_binary.pl b/test_regress/t/t_trace_binary.pl new file mode 100755 index 000000000..03fd8a3c5 --- /dev/null +++ b/test_regress/t/t_trace_binary.pl @@ -0,0 +1,35 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +if (!$Self->have_coroutines) { + skip("No coroutine support"); +} +else { + compile( + verilator_flags => [# Custom as don't want -cc + "-Mdir $Self->{obj_dir}", + "--debug-check", ], + verilator_flags2 => ['--binary --trace'], + verilator_make_cmake => 0, + verilator_make_gmake => 0, + make_main => 0, + ); + + execute( + check_finished => 1, + ); + + vcd_identical("$Self->{obj_dir}/simx.vcd", $Self->{golden_filename}); +} + +ok(1); +1; diff --git a/test_regress/t/t_trace_binary.v b/test_regress/t/t_trace_binary.v new file mode 100644 index 000000000..445c2b375 --- /dev/null +++ b/test_regress/t/t_trace_binary.v @@ -0,0 +1,20 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2020 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +`define STRINGIFY(x) `"x`" + +module t(/*AUTOARG*/); + int sig; + initial begin + sig = 10; + $dumpfile({`STRINGIFY(`TEST_OBJ_DIR),"/simx.vcd"}); + $dumpvars(); + #20; + sig = 20; + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule diff --git a/test_regress/t/t_trace_binary_flag_off.out b/test_regress/t/t_trace_binary_flag_off.out new file mode 100644 index 000000000..8c40ee2bf --- /dev/null +++ b/test_regress/t/t_trace_binary_flag_off.out @@ -0,0 +1,2 @@ +-Info: t/t_trace_binary.v:14: $dumpvar ignored, as Verilated without --trace +*-* All Finished *-* diff --git a/test_regress/t/t_trace_binary_flag_off.pl b/test_regress/t/t_trace_binary_flag_off.pl new file mode 100755 index 000000000..eaa6a3518 --- /dev/null +++ b/test_regress/t/t_trace_binary_flag_off.pl @@ -0,0 +1,35 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +top_filename("t/t_trace_binary.v"); + +if (!$Self->have_coroutines) { + skip("No coroutine support"); +} +else { + compile( + verilator_flags => [# Custom as don't want -cc + "-Mdir $Self->{obj_dir}", + "--debug-check", ], + verilator_flags2 => ['--binary'], + verilator_make_cmake => 0, + verilator_make_gmake => 0, + make_main => 0, + ); + + execute( + expect_filename => $Self->{golden_filename}, + ); +} + +ok(1); +1;