diff --git a/bin/verilator b/bin/verilator index 2d3c6c538..c0324a0c3 100755 --- a/bin/verilator +++ b/bin/verilator @@ -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 diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 9b080c9c4..a01190964 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -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); diff --git a/test_regress/t/t_flag_parameter.v b/test_regress/t/t_flag_parameter.v index 0ac314b7f..33f1c102e 100644 --- a/test_regress/t/t_flag_parameter.v +++ b/test_regress/t/t_flag_parameter.v @@ -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); diff --git a/test_regress/t/t_flag_parameter.vc b/test_regress/t/t_flag_parameter.vc index 49e71571d..955540440 100644 --- a/test_regress/t/t_flag_parameter.vc +++ b/test_regress/t/t_flag_parameter.vc @@ -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