Support 1-bit params with -G and -pvalue (#6051) (#6082)

This commit is contained in:
Paul Swirhun 2025-06-10 14:39:13 -07:00 committed by GitHub
parent ac06b6fc4f
commit 4925f9ad73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View File

@ -425,7 +425,7 @@ AstConst* AstConst::parseParamLiteral(FileLine* fl, const string& literal) {
// the Verilog literal parser.
char* endp;
const int v = strtol(literal.c_str(), &endp, 0);
if ((v != 0) && (endp[0] == 0)) { // C literal
if ((v != 0) && (v != 1) && (endp[0] == 0)) { // C literal
return new AstConst{fl, AstConst::Signed32{}, v};
} else { // Try a Verilog literal (fatals if not)
return new AstConst{fl, AstConst::StringToParse{}, literal.c_str()};

View File

@ -57,6 +57,11 @@ module t;
parameter int71 = 1;
parameter int72 = 1;
parameter bit bit0to0 = 0;
parameter bit bit1to1 = 1;
parameter bit bit0to1 = 0;
parameter bit bit1to0 = 1;
initial begin
`check(string1,"New String");
`check(string2,"New String");
@ -88,6 +93,10 @@ module t;
`check(int62,32'hdeadbeef);
`check(int71,-1000);
`check(int72,-1000);
`check(bit0to0, 1'b0);
`check(bit1to1, 1'b1);
`check(bit0to1, 1'b1);
`check(bit1to0, 1'b0);
// Check parameter assigned simple integer literal is signed
if ((int11 << 27) >>> 31 != -1) $stop;

View File

@ -28,3 +28,11 @@
-pvalue+int62="32'hdead_beef"
-Gint71=-1000
-pvalue+int72=-1000
-Gbit0to0=0
-pvalue+bit0to0=0
-Gbit1to1=1
-pvalue+bit1to1=1
-Gbit0to1=1
-pvalue+bit0to1=1
-Gbit1to0=0
-pvalue+bit1to0=0