diff --git a/test_regress/t/t_cover_per_instance.dat.out b/test_regress/t/t_cover_per_instance.dat.out new file mode 100644 index 000000000..a38d3d58d --- /dev/null +++ b/test_regress/t/t_cover_per_instance.dat.out @@ -0,0 +1,20 @@ +# SystemC::Coverage-3 +C 'ft/t_cover_per_instance.vl16n27tlinepagev_line/childoblockS16htb.dut.u_a' 1 +C 'ft/t_cover_per_instance.vl16n27tlinepagev_line/childoblockS16htb.dut.u_b' 1 +C 'ft/t_cover_per_instance.vl16n27tlinepagev_line/child__W3oblockS16htb.dut.u_wide' 1 +C 'ft/t_cover_per_instance.vl18n3tlinepagev_line/childoblockS18htb.dut.u_a' 9 +C 'ft/t_cover_per_instance.vl18n3tlinepagev_line/childoblockS18htb.dut.u_b' 9 +C 'ft/t_cover_per_instance.vl18n3tlinepagev_line/child__W3oblockS18htb.dut.u_wide' 9 +C 'ft/t_cover_per_instance.vl19n5tbranchpagev_branch/childoifS19-20htb.dut.u_a' 4 +C 'ft/t_cover_per_instance.vl19n5tbranchpagev_branch/childoifS19-20htb.dut.u_b' 1 +C 'ft/t_cover_per_instance.vl19n5tbranchpagev_branch/child__W3oifS19-20htb.dut.u_wide' 2 +C 'ft/t_cover_per_instance.vl19n6tbranchpagev_branch/childoelseS21-22htb.dut.u_a' 5 +C 'ft/t_cover_per_instance.vl19n6tbranchpagev_branch/childoelseS21-22htb.dut.u_b' 8 +C 'ft/t_cover_per_instance.vl19n6tbranchpagev_branch/child__W3oelseS21-22htb.dut.u_wide' 7 +C 'ft/t_cover_per_instance.vl30n19tlinepagev_line/toblockS30htb.dut' 1 +C 'ft/t_cover_per_instance.vl55n3tlinepagev_line/toblockS55-56htb.dut' 9 +C 'ft/t_cover_per_instance.vl61n13tlinepagev_line/tboblockS61htb' 1 +C 'ft/t_cover_per_instance.vl67n3tlinepagev_line/tboblockS67htb' 17 +C 'ft/t_cover_per_instance.vl69n3tlinepagev_line/tboblockS69htb' 9 +C 'ft/t_cover_per_instance.vl70n5tbranchpagev_branch/tboifS70-72htb' 1 +C 'ft/t_cover_per_instance.vl70n6tbranchpagev_branch/tboelsehtb' 8 diff --git a/test_regress/t/t_cover_per_instance.out b/test_regress/t/t_cover_per_instance.out index 9240a8578..09136e720 100644 --- a/test_regress/t/t_cover_per_instance.out +++ b/test_regress/t/t_cover_per_instance.out @@ -5,34 +5,43 @@ // SPDX-FileCopyrightText: 2026 Wilson Snyder // SPDX-License-Identifier: CC0-1.0 - module child ( + module child #( + parameter int WIDTH = 1 + ) ( input clk, input en ); `ifdef INLINE_CHILD //verilator inline_module `else //verilator no_inline_module `endif -%000001 reg [3:0] count = 0; +%000001 reg [WIDTH-1:0] count = '0; -000001 point: type=line comment=block hier=tb.dut.u_a -000001 point: type=line comment=block hier=tb.dut.u_b +-000001 point: type=line comment=block hier=tb.dut.u_wide %000009 always @(posedge clk) begin -000009 point: type=line comment=block hier=tb.dut.u_a -000009 point: type=line comment=block hier=tb.dut.u_b +-000009 point: type=line comment=block hier=tb.dut.u_wide %000008 if (en) begin -000004 point: type=branch comment=if hier=tb.dut.u_a -000001 point: type=branch comment=if hier=tb.dut.u_b +-000002 point: type=branch comment=if hier=tb.dut.u_wide -000005 point: type=branch comment=else hier=tb.dut.u_a -000008 point: type=branch comment=else hier=tb.dut.u_b +-000007 point: type=branch comment=else hier=tb.dut.u_wide %000004 count <= count + 1'b1; -000004 point: type=branch comment=if hier=tb.dut.u_a -000001 point: type=branch comment=if hier=tb.dut.u_b +-000002 point: type=branch comment=if hier=tb.dut.u_wide %000008 end else begin -000005 point: type=branch comment=else hier=tb.dut.u_a -000008 point: type=branch comment=else hier=tb.dut.u_b +-000007 point: type=branch comment=else hier=tb.dut.u_wide %000008 count <= count; -000005 point: type=branch comment=else hier=tb.dut.u_a -000008 point: type=branch comment=else hier=tb.dut.u_b +-000007 point: type=branch comment=else hier=tb.dut.u_wide end end endmodule @@ -57,6 +66,15 @@ .en(cyc == 0) ); + // Parameterized u_wide should preserve a useful per-instance hierarchy and + // parameter-specialized coverage bucket for downstream coverage tools. + child #( + .WIDTH(3) + ) u_wide ( + .clk(clk), + .en(cyc < 2) + ); + %000009 always @(posedge clk) begin -000009 point: type=line comment=block hier=tb.dut %000009 cyc <= cyc + 1'b1; diff --git a/test_regress/t/t_cover_per_instance.v b/test_regress/t/t_cover_per_instance.v index 211f6e34b..512563b38 100644 --- a/test_regress/t/t_cover_per_instance.v +++ b/test_regress/t/t_cover_per_instance.v @@ -4,14 +4,16 @@ // SPDX-FileCopyrightText: 2026 Wilson Snyder // SPDX-License-Identifier: CC0-1.0 -module child ( +module child #( + parameter int WIDTH = 1 +) ( input clk, input en ); `ifdef INLINE_CHILD //verilator inline_module `else //verilator no_inline_module `endif - reg [3:0] count = 0; + reg [WIDTH-1:0] count = '0; always @(posedge clk) begin if (en) begin @@ -41,6 +43,15 @@ module t ( .en(cyc == 0) ); + // Parameterized u_wide should preserve a useful per-instance hierarchy and + // parameter-specialized coverage bucket for downstream coverage tools. + child #( + .WIDTH(3) + ) u_wide ( + .clk(clk), + .en(cyc < 2) + ); + always @(posedge clk) begin cyc <= cyc + 1'b1; end diff --git a/test_regress/t/t_cover_per_instance_inline.py b/test_regress/t/t_cover_per_instance_inline.py index 3f83020a4..33176a521 100755 --- a/test_regress/t/t_cover_per_instance_inline.py +++ b/test_regress/t/t_cover_per_instance_inline.py @@ -28,6 +28,8 @@ test.execute(all_run_flags=[" +verilator+coverage+file+" + test.obj_dir + "/cove cov = test.obj_dir + "/coverage.dat" +test.files_identical(cov, "t/t_cover_per_instance.dat.out") + test.run(cmd=[ os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage", "--annotate-points", diff --git a/test_regress/t/t_cover_per_instance_noinline.py b/test_regress/t/t_cover_per_instance_noinline.py index a2b70d816..4193ac5e8 100755 --- a/test_regress/t/t_cover_per_instance_noinline.py +++ b/test_regress/t/t_cover_per_instance_noinline.py @@ -27,6 +27,8 @@ test.execute(all_run_flags=[" +verilator+coverage+file+" + test.obj_dir + "/cove cov = test.obj_dir + "/coverage.dat" +test.files_identical(cov, "t/t_cover_per_instance.dat.out") + test.run(cmd=[ os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage", "--annotate-points",