Fix false UNUSEDPARAM on generate localparam (#4427).

This commit is contained in:
Wilson Snyder 2023-08-25 07:59:29 -04:00
parent 2daa32b98b
commit 10dd675371
3 changed files with 22 additions and 0 deletions

View File

@ -20,6 +20,7 @@ Verilator 5.015 devel
* Fix jumping over object initialization (#4411). [Krzysztof Boroński]
* Fix variable lifetimes in extern methods (#4414). [Krzysztof Boroński]
* Fix multple function definitions in V3Sched (#4416). [Hennadii Chernyshchyk]
* Fix false UNUSEDPARAM on generate localparam (#4427). [Bill Pringlemeir]
Verilator 5.014 2023-08-06

View File

@ -2256,6 +2256,11 @@ private:
// parameters or vice versa
return pinp->param() == refVarType.isParam();
}
void updateVarUse(AstVar* nodep) {
// Avoid dotted.PARAM false positive when in a parameter block
// that is if ()'ed off by same dotted name as another block
if (nodep && nodep->isParam()) nodep->usedParam(true);
}
// VISITs
void visit(AstNetlist* nodep) override {
@ -2922,6 +2927,7 @@ private:
if (AstVar* const varp
= foundp ? foundToVarp(foundp, nodep, nodep->access()) : nullptr) {
nodep->varp(varp);
updateVarUse(nodep->varp());
// Generally set by parse, but might be an import
nodep->classOrPackagep(foundp->classOrPackagep());
}
@ -2964,6 +2970,7 @@ private:
AstVar* const varp
= foundp ? foundToVarp(foundp, nodep, nodep->access()) : nullptr;
nodep->varp(varp);
updateVarUse(nodep->varp());
UINFO(7, " Resolved " << nodep << endl); // Also prints varp
if (!nodep->varp()) {
nodep->v3error("Can't find definition of "
@ -3001,6 +3008,7 @@ private:
// later optimizations to deal with VarXRef.
nodep->varp(vscp->varp());
nodep->varScopep(vscp);
updateVarUse(nodep->varp());
UINFO(7, " Resolved " << nodep << endl); // Also prints taskp
AstVarRef* const newvscp
= new AstVarRef{nodep->fileline(), vscp, nodep->access()};

View File

@ -64,10 +64,23 @@ module sub;
genvar linter_genvar4;
// verilator lint_on UNUSED
case (2)
1: begin : named
localparam BLOCK_PARAM = 10;
end
2: begin : named
localparam BLOCK_PARAM = 20;
end
3: begin : named
localparam BLOCK_PARAM = 30;
end
endcase
initial begin
if (0 && assunu1[0] != 0 && udrb2 != 0) begin end
if (0 && assunub2[THREE] && assunub2[1:0]!=0) begin end
if (0 && mixed[1:0] != 0) begin end
if (named.BLOCK_PARAM != 20) $stop;
end
generate