Fix ENUMVALUE error when overriding enum param from CLI using -G/-pvalue

This commit is contained in:
Geza Lore 2025-10-30 10:08:34 +00:00
parent 2a0b331ee3
commit a4c5d2e29c
9 changed files with 17456 additions and 17382 deletions

View File

@ -1627,6 +1627,8 @@ class LinkDotFindVisitor final : public VNVisitor {
UINFO(9, " with " << valuep);
if (nodep->valuep()) pushDeletep(nodep->valuep()->unlinkFrBack());
nodep->valuep(valuep);
// Do not warn ENUMVALUE when overriding an enum param from the cli.
nodep->fileline()->warnOff(V3ErrorCode::ENUMVALUE, true);
}
}
}

View File

@ -23,6 +23,13 @@
`define stop $stop
`define check(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: Wrong parameter value", `__FILE__,`__LINE__); `stop; end while(0);
typedef enum logic [1:0] {
enum_val_0 = 2'd0,
enum_val_1 = 2'd1,
enum_val_2 = 2'd2,
enum_val_3 = 2'd3
} enum_t;
module t;
parameter string1 = "Original String";
parameter string2 = "Original String";
@ -62,6 +69,11 @@ module t;
parameter bit bit0to1 = 0;
parameter bit bit1to0 = 1;
parameter enum_t enum11 = enum_val_1;
parameter enum_t enum12 = enum_val_1;
parameter enum_t enum21 = enum_val_1;
parameter enum_t enum22 = enum_val_1;
initial begin
`check(string1,"New String");
`check(string2,"New String");
@ -97,6 +109,10 @@ module t;
`check(bit1to1, 1'b1);
`check(bit0to1, 1'b1);
`check(bit1to0, 1'b0);
`check(enum11, enum_val_2);
`check(enum12, enum_val_2);
`check(enum21, enum_val_3);
`check(enum22, enum_val_3);
// Check parameter assigned simple integer literal is signed
if ((int11 << 27) >>> 31 != -1) $stop;

View File

@ -36,3 +36,7 @@
-pvalue+bit0to1=1
-Gbit1to0=0
-pvalue+bit1to0=0
-Genum11=2'd2
-pvalue+enum12=2'd2
-Genum21=2'd3
-pvalue+enum22=2'd3

View File

@ -20,6 +20,13 @@ interface byte_ifs(input clk);
modport receiver(input clk, input data);
endinterface;
typedef enum logic [1:0] {
enum_val_0 = 2'd0,
enum_val_1 = 2'd1,
enum_val_2 = 2'd2,
enum_val_3 = 2'd3
} enum_t;
`ifdef AS_PROT_LIB
module secret (
clk
@ -176,9 +183,9 @@ module non_hier_sub3(
assign in_wire = in.data;
localparam string sparam = "single quote escape comma:'\\,";
// Parameter appears in the different order from module declaration
sub3 #(.STR(sparam), .UNUSED(-16'sd3), .P0(8'd3)) i_sub3(.clk(in.clk), .in(in.data), .out(out_1));
sub3 #(.STR(sparam), .UNUSED(-16'sd3), .P0(8'd3), .ENUM(enum_val_3)) i_sub3(.clk(in.clk), .in(in.data), .out(out_1));
// Instantiate again, should use the same wrapper
sub3 #(.STR(sparam), .UNUSED(-16'sd3), .P0(8'd3)) i_sub3_2(.clk(in.clk), .in(in.data), .out(out_2));
sub3 #(.STR(sparam), .UNUSED(-16'sd3), .P0(8'd3), .ENUM(enum_val_3)) i_sub3_2(.clk(in.clk), .in(in.data), .out(out_2));
always @(posedge in.clk)
if (out_1 != out_2) $stop;
@ -190,12 +197,13 @@ module sub3 #(
type TYPE = logic,
parameter int UNPACKED_ARRAY[2] = '{0, 1},
parameter logic signed [15:0] UNUSED = -3,
parameter string STR = "str") (
parameter string STR = "str",
parameter enum_t ENUM = enum_val_0) (
input wire clk,
input wire [7:0] in,
output wire [7:0] out); `HIER_BLOCK
initial $display("P0:%d UNUSED:%d %s", P0, UNUSED, STR);
initial $display("P0:%d UNUSED:%d %s %d", P0, UNUSED, STR, ENUM);
TYPE [7:0] ff;
always_ff @(posedge clk) ff <= in + P0;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -811,6 +811,8 @@
(UNUSED\[13\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[14\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[15\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(ENUM\[0\] (T0 170) (T1 0) (TZ 0) (TX 0) (TB 0) (TC 0))
(ENUM\[1\] (T0 170) (T1 0) (TZ 0) (TX 0) (TB 0) (TC 0))
(clk (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 33))
(in\[0\] (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 7))
(in\[1\] (T0 80) (T1 90) (TZ 0) (TX 0) (TB 0) (TC 12))
@ -4828,6 +4830,8 @@
(UNUSED\[13\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[14\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[15\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(ENUM\[0\] (T0 170) (T1 0) (TZ 0) (TX 0) (TB 0) (TC 0))
(ENUM\[1\] (T0 170) (T1 0) (TZ 0) (TX 0) (TB 0) (TC 0))
(clk (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 33))
(in\[0\] (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 7))
(in\[1\] (T0 80) (T1 90) (TZ 0) (TX 0) (TB 0) (TC 12))
@ -9074,6 +9078,8 @@
(UNUSED\[13\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[14\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[15\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(ENUM\[0\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(ENUM\[1\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(clk (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 33))
(in\[0\] (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 7))
(in\[1\] (T0 80) (T1 90) (TZ 0) (TX 0) (TB 0) (TC 10))
@ -14363,6 +14369,8 @@
(UNUSED\[13\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[14\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(UNUSED\[15\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(ENUM\[0\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(ENUM\[1\] (T0 0) (T1 170) (TZ 0) (TX 0) (TB 0) (TC 1))
(clk (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 33))
(in\[0\] (T0 90) (T1 80) (TZ 0) (TX 0) (TB 0) (TC 7))
(in\[1\] (T0 80) (T1 90) (TZ 0) (TX 0) (TB 0) (TC 10))

File diff suppressed because it is too large Load Diff