Fix expression coverage + VarXRefs (#5797)

This commit is contained in:
Todd Strader 2025-02-22 15:55:23 -05:00 committed by GitHub
parent 812861e7f2
commit 7ec32799b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 67 additions and 1 deletions

View File

@ -726,7 +726,7 @@ class CoverageVisitor final : public VNVisitor {
// not be flagged as redundant or impossible, however the results will // not be flagged as redundant or impossible, however the results will
// still be valid, albeit messier // still be valid, albeit messier
for (CoverTerm& term : l) { for (CoverTerm& term : l) {
if (AstNodeVarRef* const refp = VN_CAST(term.m_exprp, NodeVarRef)) { if (AstVarRef* const refp = VN_CAST(term.m_exprp, VarRef)) {
varps[term.m_objective].insert(refp->varp()); varps[term.m_objective].insert(refp->varp());
} else { } else {
strs[term.m_objective].insert(term.m_emitV); strs[term.m_objective].insert(term.m_emitV);

View File

@ -43,6 +43,13 @@
-000005 point: comment=(b==0) => 0 hier=top.t -000005 point: comment=(b==0) => 0 hier=top.t
endfunction endfunction
localparam int num_intfs = 4;
intf the_intfs [num_intfs-1:0] ();
genvar intf_i;
for (intf_i = 0; intf_i < num_intfs; intf_i++) begin
always_comb the_intfs[intf_i].t = cyc[intf_i];
end
always @ (posedge clk) begin always @ (posedge clk) begin
cyc <= cyc + 1; cyc <= cyc + 1;
%000004 if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write(""); %000004 if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write("");
@ -59,6 +66,13 @@
-000002 point: comment=(cyc2[33]==0 && cyc2[34]==1) => 0 hier=top.t -000002 point: comment=(cyc2[33]==0 && cyc2[34]==1) => 0 hier=top.t
-000003 point: comment=(cyc2[33]==0 && cyc2[35]==0) => 0 hier=top.t -000003 point: comment=(cyc2[33]==0 && cyc2[35]==0) => 0 hier=top.t
-000002 point: comment=(cyc2[34]==0 && cyc2[35]==1) => 1 hier=top.t -000002 point: comment=(cyc2[34]==0 && cyc2[35]==1) => 1 hier=top.t
%000004 if ((~the_intfs[0].t && the_intfs[1].t) || (~the_intfs[2].t && the_intfs[3].t)) $write("");
-000002 point: comment=(the_intfs[0].t==0 && the_intfs[1].t==1) => 1 hier=top.t
-000002 point: comment=(the_intfs[0].t==1 && the_intfs[2].t==1) => 0 hier=top.t
-000004 point: comment=(the_intfs[0].t==1 && the_intfs[3].t==0) => 0 hier=top.t
-000002 point: comment=(the_intfs[1].t==0 && the_intfs[2].t==1) => 0 hier=top.t
-000003 point: comment=(the_intfs[1].t==0 && the_intfs[3].t==0) => 0 hier=top.t
-000002 point: comment=(the_intfs[2].t==0 && the_intfs[3].t==1) => 1 hier=top.t
%000004 if ((~t1 && t2) || (~t3 && t4)) $write(""); %000004 if ((~t1 && t2) || (~t3 && t4)) $write("");
-000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t -000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t
-000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t -000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t
@ -325,3 +339,7 @@
endmodule endmodule
interface intf();
logic t;
endinterface

View File

@ -37,10 +37,18 @@ module t (/*AUTOARG*/
return a & b; return a & b;
endfunction endfunction
localparam int num_intfs = 4;
intf the_intfs [num_intfs-1:0] ();
genvar intf_i;
for (intf_i = 0; intf_i < num_intfs; intf_i++) begin
always_comb the_intfs[intf_i].t = cyc[intf_i];
end
always @ (posedge clk) begin always @ (posedge clk) begin
cyc <= cyc + 1; cyc <= cyc + 1;
if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write(""); if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write("");
if ((~cyc2[32] && cyc2[33]) || (~cyc2[34] && cyc2[35])) $write(""); if ((~cyc2[32] && cyc2[33]) || (~cyc2[34] && cyc2[35])) $write("");
if ((~the_intfs[0].t && the_intfs[1].t) || (~the_intfs[2].t && the_intfs[3].t)) $write("");
if ((~t1 && t2) || (~t3 && t4)) $write(""); if ((~t1 && t2) || (~t3 && t4)) $write("");
if (t3 && (t1 == t2)) $write(""); if (t3 && (t1 == t2)) $write("");
if (123 == (124 - 32'(t1 || t2))) $write(""); if (123 == (124 - 32'(t1 || t2))) $write("");
@ -163,3 +171,7 @@ module sub (
end end
endmodule endmodule
interface intf();
logic t;
endinterface

View File

@ -43,6 +43,13 @@
-000005 point: comment=(b==0) => 0 hier=top.t -000005 point: comment=(b==0) => 0 hier=top.t
endfunction endfunction
localparam int num_intfs = 4;
intf the_intfs [num_intfs-1:0] ();
genvar intf_i;
for (intf_i = 0; intf_i < num_intfs; intf_i++) begin
always_comb the_intfs[intf_i].t = cyc[intf_i];
end
always @ (posedge clk) begin always @ (posedge clk) begin
cyc <= cyc + 1; cyc <= cyc + 1;
%000004 if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write(""); %000004 if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write("");
@ -59,6 +66,13 @@
-000002 point: comment=(cyc2[33]==0 && cyc2[34]==1) => 0 hier=top.t -000002 point: comment=(cyc2[33]==0 && cyc2[34]==1) => 0 hier=top.t
-000003 point: comment=(cyc2[33]==0 && cyc2[35]==0) => 0 hier=top.t -000003 point: comment=(cyc2[33]==0 && cyc2[35]==0) => 0 hier=top.t
-000002 point: comment=(cyc2[34]==0 && cyc2[35]==1) => 1 hier=top.t -000002 point: comment=(cyc2[34]==0 && cyc2[35]==1) => 1 hier=top.t
%000004 if ((~the_intfs[0].t && the_intfs[1].t) || (~the_intfs[2].t && the_intfs[3].t)) $write("");
-000002 point: comment=(the_intfs[0].t==0 && the_intfs[1].t==1) => 1 hier=top.t
-000002 point: comment=(the_intfs[0].t==1 && the_intfs[2].t==1) => 0 hier=top.t
-000004 point: comment=(the_intfs[0].t==1 && the_intfs[3].t==0) => 0 hier=top.t
-000002 point: comment=(the_intfs[1].t==0 && the_intfs[2].t==1) => 0 hier=top.t
-000003 point: comment=(the_intfs[1].t==0 && the_intfs[3].t==0) => 0 hier=top.t
-000002 point: comment=(the_intfs[2].t==0 && the_intfs[3].t==1) => 1 hier=top.t
%000004 if ((~t1 && t2) || (~t3 && t4)) $write(""); %000004 if ((~t1 && t2) || (~t3 && t4)) $write("");
-000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t -000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t
-000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t -000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t
@ -453,3 +467,7 @@
endmodule endmodule
interface intf();
logic t;
endinterface

View File

@ -43,6 +43,13 @@
-000005 point: comment=(b==0) => 0 hier=top.t -000005 point: comment=(b==0) => 0 hier=top.t
endfunction endfunction
localparam int num_intfs = 4;
intf the_intfs [num_intfs-1:0] ();
genvar intf_i;
for (intf_i = 0; intf_i < num_intfs; intf_i++) begin
always_comb the_intfs[intf_i].t = cyc[intf_i];
end
always @ (posedge clk) begin always @ (posedge clk) begin
cyc <= cyc + 1; cyc <= cyc + 1;
%000004 if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write(""); %000004 if ((~cyc[0] && cyc[1]) || (~cyc[2] && cyc[3])) $write("");
@ -59,6 +66,13 @@
-000002 point: comment=(cyc2[33]==0 && cyc2[34]==1) => 0 hier=top.t -000002 point: comment=(cyc2[33]==0 && cyc2[34]==1) => 0 hier=top.t
-000003 point: comment=(cyc2[33]==0 && cyc2[35]==0) => 0 hier=top.t -000003 point: comment=(cyc2[33]==0 && cyc2[35]==0) => 0 hier=top.t
-000002 point: comment=(cyc2[34]==0 && cyc2[35]==1) => 1 hier=top.t -000002 point: comment=(cyc2[34]==0 && cyc2[35]==1) => 1 hier=top.t
%000004 if ((~the_intfs[0].t && the_intfs[1].t) || (~the_intfs[2].t && the_intfs[3].t)) $write("");
-000002 point: comment=(the_intfs[0].t==0 && the_intfs[1].t==1) => 1 hier=top.t
-000002 point: comment=(the_intfs[0].t==1 && the_intfs[2].t==1) => 0 hier=top.t
-000004 point: comment=(the_intfs[0].t==1 && the_intfs[3].t==0) => 0 hier=top.t
-000002 point: comment=(the_intfs[1].t==0 && the_intfs[2].t==1) => 0 hier=top.t
-000003 point: comment=(the_intfs[1].t==0 && the_intfs[3].t==0) => 0 hier=top.t
-000002 point: comment=(the_intfs[2].t==0 && the_intfs[3].t==1) => 1 hier=top.t
%000004 if ((~t1 && t2) || (~t3 && t4)) $write(""); %000004 if ((~t1 && t2) || (~t3 && t4)) $write("");
-000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t -000002 point: comment=(t1==0 && t2==1) => 1 hier=top.t
-000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t -000002 point: comment=(t1==1 && t3==1) => 0 hier=top.t
@ -325,3 +339,7 @@
endmodule endmodule
interface intf();
logic t;
endinterface