Fix emitting unbounded parameters (#6912).

Fixes #6912.
This commit is contained in:
Wilson Snyder 2026-01-12 22:56:23 -05:00
parent 8a24897c13
commit 09ca7ea8d1
3 changed files with 20 additions and 14 deletions

View File

@ -389,6 +389,7 @@ Verilator 5.040 2025-08-30
* Fix wide select expansion and substitution (#6341) (#6345). [Geza Lore]
* Fix upcasting class type parameters (#6344). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix undefined weak link for Apple GCC etc (#6348). [Congcong Cai]
* Fix emitting unbounded parameters (#6912).
* Fix syntax error on unsupported defparam array (#6915).

View File

@ -99,6 +99,11 @@ protected:
UASSERT_OBJ(!num.isFourState(), nodep, "4-state value in constant pool");
putns(nodep, num.emitC());
}
void visit(AstUnbounded* nodep) override {
// e.g. when emitting a public parameter's "$" value
// But Unbounded is only special during elaboration, so just use zero
putns(nodep, "0");
}
// Default
void visit(AstNode* nodep) override { // LCOV_EXCL_START

View File

@ -4,20 +4,20 @@
// any use, without warranty, 2014 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t();
module t;
localparam UNB = $;
localparam int UNB2 = $;
localparam SIX = 6;
parameter int UNB /*verilator public*/ = $;
localparam int UNB2 = $;
localparam SIX = 6;
initial begin
if ($bits($isunbounded(0)) !== 1) $stop;
if ($isunbounded(0) !== 1'b0) $stop;
if ($isunbounded(SIX) !== 0) $stop;
if ($isunbounded($) !== 1) $stop;
if ($isunbounded(UNB) !== 1) $stop;
if ($isunbounded(UNB2) !== 1) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
initial begin
if ($bits($isunbounded(0)) !== 1) $stop;
if ($isunbounded(0) !== 1'b0) $stop;
if ($isunbounded(SIX) !== 0) $stop;
if ($isunbounded($) !== 1) $stop;
if ($isunbounded(UNB) !== 1) $stop;
if ($isunbounded(UNB2) !== 1) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule