Support 'E', 'p', and 'P' when overriding floating point parameter. (#2310)

This commit is contained in:
Yutetsu TAKATSUKASA 2020-05-06 20:45:07 +09:00 committed by GitHub
parent b6b3482010
commit aa86e0bbc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View File

@ -881,7 +881,10 @@ octal (0..) or binary (0b..) notation.
=item Double literals
Double literals must contain a dot (.) and/or an exponent (e).
Double literals must be one of the following styles:
- contains a dot (.) (e.g. 1.23)
- contains an expornent (e/E) (e.g. 12e3)
- contains p/P for hexadecimal floating point in C99 (e.g. 0x123.ABCp1)
=item Strings

View File

@ -712,13 +712,13 @@ class LinkDotFindVisitor : public AstNVisitor {
// METHODS
int debug() { return LinkDotState::debug(); }
virtual AstConst* parseParamLiteral(FileLine* fl, const string& literal) {
AstConst* parseParamLiteral(FileLine* fl, const string& literal) const {
bool success = false;
if (literal[0] == '"') {
// This is a string
string v = literal.substr(1, literal.find('"', 1) - 1);
return new AstConst(fl, AstConst::VerilogStringLiteral(), v);
} else if ((literal.find('.') != string::npos) || (literal.find('e') != string::npos)) {
} else if (literal.find_first_of(".eEpP") != string::npos) {
// This may be a real
double v = V3ParseImp::parseDouble(literal.c_str(), literal.length(), &success);
if (success) return new AstConst(fl, AstConst::RealDouble(), v);

View File

@ -36,6 +36,10 @@ module t;
parameter real22 = 0.1;
parameter real31 = 0.1;
parameter real32 = 0.1;
parameter real41 = 0.1;
parameter real42 = 0.1;
parameter real51 = 0.1;
parameter real52 = 0.1;
parameter int11 = 1;
parameter int12 = 1;
@ -63,6 +67,10 @@ module t;
`check(real22,400);
`check(real31,20);
`check(real32,20);
`check(real41,582.5);
`check(real42,582.5);
`check(real51,145.5);
`check(real52,145.5);
`check(int11,16);
`check(int12,16);
`check(int21,16);

View File

@ -6,10 +6,14 @@
-pvalue+string22=\"New\ String\"
-Greal11=0.2
-pvalue+real12=0.2
-Greal21=4e2
-Greal21=4E2
-pvalue+real22=4e2
-Greal31=0.2e2
-pvalue+real32=0.2e2
-Greal41=0x123.4p1
-pvalue+real42=0X123.4P1
-Greal51=0x123p-1
-pvalue+real52=0X123P-1
-Gint11=0x10
-pvalue+int12=0x10
-Gint21=020