forked from github/verilator
Fix -G to treat simple integer literals as signed (#3060)
The -G option now correctly parses simple integer literals as signed numbers, which is in line with the standard and is significant when overriding parameters without a type specifier. Fixes #3060
This commit is contained in:
parent
686baaf2cf
commit
a4f5d95648
2
Changes
2
Changes
@ -13,6 +13,8 @@ Verilator 4.211 devel
|
||||
|
||||
**Minor:**
|
||||
|
||||
* Fix -G to treat simple integer literals as signed (#3060). [Anikin1610]
|
||||
|
||||
|
||||
Verilator 4.210 2021-07-07
|
||||
==========================
|
||||
|
@ -267,7 +267,7 @@ AstConst* AstConst::parseParamLiteral(FileLine* fl, const string& literal) {
|
||||
char* endp;
|
||||
int v = strtol(literal.c_str(), &endp, 0);
|
||||
if ((v != 0) && (endp[0] == 0)) { // C literal
|
||||
return new AstConst(fl, AstConst::WidthedValue(), 32, v);
|
||||
return new AstConst(fl, AstConst::Signed32(), v);
|
||||
} else { // Try a Verilog literal (fatals if not)
|
||||
return new AstConst(fl, AstConst::StringToParse(), literal.c_str());
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ module t;
|
||||
parameter int52 = 1;
|
||||
parameter int61 = 1;
|
||||
parameter int62 = 1;
|
||||
parameter int71 = 1;
|
||||
parameter int72 = 1;
|
||||
|
||||
initial begin
|
||||
`check(string1,"New String");
|
||||
@ -83,6 +85,11 @@ module t;
|
||||
`check(int52,32'hdeadbeef);
|
||||
`check(int61,32'hdeadbeef);
|
||||
`check(int62,32'hdeadbeef);
|
||||
`check(int71,-1000);
|
||||
`check(int72,-1000);
|
||||
|
||||
// Check parameter assigned simple integer literal is signed
|
||||
if ((int11 << 27) >>> 31 != -1) $stop;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
|
@ -26,3 +26,5 @@
|
||||
-pvalue+int52=32\'hdead_beef
|
||||
-Gint61="32'hdead_beef"
|
||||
-pvalue+int62="32'hdead_beef"
|
||||
-Gint71=-1000
|
||||
-pvalue+int72=-1000
|
||||
|
Loading…
Reference in New Issue
Block a user