diff --git a/bin/verilator b/bin/verilator index 08ef741b4..12716f020 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1256,15 +1256,12 @@ Verilator supports $clog2. Verilator partially supports the uwire keyword. -=head1 SYSTEMVERILOG (IEEE 1800-2005) SUPPORT +=head1 SYSTEMVERILOG 2005 (IEEE 1800-2005) SUPPORT Verilator currently has some support for SystemVerilog synthesis constructs. As SystemVerilog features enter common usage they are added; please file a bug if a feature you need is missing. -Verilator implements the full SystemVerilog 1800-2005 preprocessor, -including function call-like preprocessor defines. - Verilator supports ==? and !=? operators, $bits, $countones, $error, $fatal, $info, $isunknown, $onehot, $onehot0, $unit, $warning, always_comb, always_ff, always_latch, bit, byte, chandle, do-while, export, final, @@ -1276,6 +1273,12 @@ It also supports .name and .* interconnection. Verilator partially supports concurrent assert and cover statements; see the enclosed coverage tests for the syntax which is allowed. +=head1 SYSTEMVERILOG 2009 (IEEE 1800-2009) SUPPORT + +Verilator implements a full SystemVerilog 2009 preprocessor, including +function call-like preprocessor defines, default define arguments, +`__FILE__, `__LINE__ and `undefineall. + =head1 SUGAR/PSL SUPPORT Most future work is being directed towards improving SystemVerilog @@ -1329,15 +1332,15 @@ or `ifdef's may break other tools. =item `__FILE__ -The __FILE__ define expands to the current filename, like C++'s __FILE__. -This is in the draft SystemVerilog 2009 standard (but supported by -Verilator since 2006!) +The __FILE__ define expands to the current filename as a string, like C++'s +__FILE__. This was incorporated into to the 1800-2009 standard (but +supported by Verilator since 2006!) =item `__LINE__ -The __LINE__ define expands to the current line number, like C++'s -__LINE__. This is in the draft SystemVerilog 2009 standard (but supported -by Verilator since 2006!) +The __LINE__ define expands to the current filename as a string, like C++'s +__LINE__. This was incorporated into to the 1800-2009 standard (but +supported by Verilator since 2006!) =item `error I diff --git a/src/V3PreLex.h b/src/V3PreLex.h index 33d2b4feb..bec527a4f 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -113,7 +113,7 @@ class V3PreLex { // State to lexer static V3PreLex* s_currentLexp; // Current lexing point int m_keepComments; // Emit comments in output text - bool m_pedantic; // Obey standard; don't Substitute `__FILE__ and `__LINE__ + bool m_pedantic; // Obey standard; don't Substitute `error // State from lexer int m_formalLevel; // Parenthesis counting inside def formals diff --git a/src/V3PreLex.l b/src/V3PreLex.l index 5aea4f207..842c768c3 100644 --- a/src/V3PreLex.l +++ b/src/V3PreLex.l @@ -92,17 +92,14 @@ psl [p]sl "`undefineall" { return(VP_UNDEFINEALL); } /* Optional directives we recognize */ -"`__FILE__" { if (!pedantic()) { - static string rtnfile; - rtnfile = '"'; rtnfile += LEXP->m_curFilelinep->cfilename(); - rtnfile += '"'; yytext=(char*)rtnfile.c_str(); yyleng = rtnfile.length(); - return (VP_STRING); - } else return(VP_DEFREF); } -"`__LINE__" { if (!pedantic()) { - static char buf[10]; - sprintf(buf, "%d",LEXP->m_curFilelinep->lineno()); - yytext = buf; yyleng = strlen(yytext); return (VP_TEXT); - } else return(VP_DEFREF); } +"`__FILE__" { static string rtnfile; + rtnfile = '"'; rtnfile += LEXP->m_curFilelinep->cfilename(); + rtnfile += '"'; yytext=(char*)rtnfile.c_str(); yyleng = rtnfile.length(); + return (VP_STRING); } +"`__LINE__" { static char buf[10]; + sprintf(buf, "%d",LEXP->m_curFilelinep->lineno()); + yytext = buf; yyleng = strlen(yytext); + return (VP_TEXT); } "`error" { if (!pedantic()) return (VP_ERROR); else return(VP_DEFREF); } /* Pass-through strings */ diff --git a/src/V3PreProc.h b/src/V3PreProc.h index 1971fc8c4..d3ecfed5e 100644 --- a/src/V3PreProc.h +++ b/src/V3PreProc.h @@ -62,7 +62,7 @@ public: // These options control how the parsing proceeds int keepComments() { return 2; } // Return comments, 0=no, 1=yes, 2=callback bool lineDirectives() { return true; } // Insert `line directives - bool pedantic() { return false; } // Obey standard; Don't substitute `__FILE__ and `__LINE__ + bool pedantic() { return false; } // Obey standard; Don't substitute `error static bool optPsl(); // CALLBACK METHODS