Skip to content

Commit

Permalink
Fix tracing_{on,off} in the presence of non-inlined modules
Browse files Browse the repository at this point in the history
Previously "*.foo.*" failed to match non-inlined instances called 'foo'.
  • Loading branch information
gezalore committed Aug 8, 2024
1 parent 3e5859e commit b147602
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/V3TraceDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class TraceDeclVisitor final : public VNVisitor {
} else if (!nodep->isTrace()) {
return "Verilator instance trace_off";
} else {
const string prettyName = varp->prettyName();
const string prettyName = nodep->prettyName();
if (!v3Global.opt.traceUnderscore()) {
if (!prettyName.empty() && prettyName[0] == '_') return "Leading underscore";
if (prettyName.find("._") != string::npos) return "Inlined leading underscore";
Expand Down
44 changes: 44 additions & 0 deletions test_regress/t/t_trace_scope_no_inline.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
$version Generated by VerilatedVcd $end
$timescale 1ps $end
$scope module top $end
$scope module t $end
$scope module sub_b $end
$var wire 1 # clk $end
$var wire 32 $ cnt [31:0] $end
$upscope $end
$upscope $end
$upscope $end
$enddefinitions $end


#0
0#
b00000000000000000000000000000000 $
#10
1#
b00000000000000000000000000000001 $
#15
0#
#20
1#
b00000000000000000000000000000010 $
#25
0#
#30
1#
b00000000000000000000000000000011 $
#35
0#
#40
1#
b00000000000000000000000000000100 $
#45
0#
#50
1#
b00000000000000000000000000000101 $
#55
0#
#60
1#
b00000000000000000000000000000110 $
24 changes: 24 additions & 0 deletions test_regress/t/t_trace_scope_no_inline.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 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);

compile(
verilator_flags2 => ["--cc --trace -fno-inline t/$Self->{name}.vlt"],
);

execute(
check_finished => 1,
);

vcd_identical($Self->trace_filename, $Self->{golden_filename});

ok(1);
1;
27 changes: 27 additions & 0 deletions test_regress/t/t_trace_scope_no_inline.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2024 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

module t (clk);
input clk;
integer cyc = 0;

always @ (posedge clk) begin
cyc <= cyc + 1;
if (cyc == 5) begin
$write("*-* All Finished *-*\n");
$finish;
end
end

sub sub_a(clk);
sub sub_b(clk);
sub sub_c(clk);
endmodule

module sub(input wire clk);
int cnt = 0;
always @(posedge clk) cnt++;
endmodule
12 changes: 12 additions & 0 deletions test_regress/t/t_trace_scope_no_inline.vlt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2024 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

`verilator_config

// Turn tracing off for all scopes by default
tracing_off -scope "*" -levels 0
// Turn it back on only for *.sub_b.* and below
tracing_on -scope "*.sub_b.*" -levels 0

0 comments on commit b147602

Please sign in to comment.