diff --git a/Changes b/Changes index 32d95798f..e880cf700 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,8 @@ indicates the contributor was also the author of the fix; Thanks! *** Suppress width warnings between constant strings and wider vectors. [Rodney Sinclair] +**** Ignore SystemVerilog timeunit and timeprecision. + **** Expand environment variables in -f input files. [Lawrence Butcher] **** Report error if port declaration is missing; bug32. [Guy-Armand Kamendje] diff --git a/bin/verilator b/bin/verilator index 2635c5bf2..4594d90f1 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1559,6 +1559,10 @@ full nor unique. All specify blocks and timing checks are ignored. +=item timeunit, timeprecision + +All timing control statements are ignored. + =item uwire Verilator does not perform warning checking on uwires, it treats the uwire diff --git a/src/verilog.l b/src/verilog.l index 8d7a29774..d3cd551cc 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -357,6 +357,8 @@ escid \\[^ \t\f\r\n]+ "iff" {yylval.fileline = CRELINE(); return yIFF;} "priority" {yylval.fileline = CRELINE(); return yPRIORITY;} "static" {yylval.fileline = CRELINE(); return ySTATIC;} + "timeprecision" {yylval.fileline = CRELINE(); return yTIMEPRECISION;} + "timeunit" {yylval.fileline = CRELINE(); return yTIMEUNIT;} "unique" {yylval.fileline = CRELINE(); return yUNIQUE;} /* Generic unsupported warnings */ /* Note assert_strobe was in SystemVerilog 3.1, but removed for SystemVerilog 2005 */ @@ -426,8 +428,6 @@ escid \\[^ \t\f\r\n]+ "tagged" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} "this" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} "throughout" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} - "timeprecision" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} - "timeunit" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} "type" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} "typedef" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} "var" {yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext);} @@ -694,7 +694,7 @@ escid \\[^ \t\f\r\n]+ } [0-9][_0-9]*(\.[_0-9]+)?(fs|ps|ns|us|ms|s|step) { yylval.cdouble = 0; /* Only for times, not used yet */ - return yaFLOATNUM; + return yaTIMENUM; } } diff --git a/src/verilog.y b/src/verilog.y index a577e3937..5f033e054 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -141,6 +141,8 @@ class AstSenTree; // IEEE: integral_number %token yaINTNUM "INTEGER NUMBER" +// IEEE: time_literal + time_unit +%token yaTIMENUM "TIME NUMBER" // IEEE: string_literal %token yaSTRING "STRING" %token yaTIMINGSPEC "TIMING SPEC ELEMENT" @@ -213,6 +215,8 @@ class AstSenTree; %token ySUPPLY0 "supply0" %token ySUPPLY1 "supply1" %token yTASK "task" +%token yTIMEPRECISION "timeprecision" +%token yTIMEUNIT "timeunit" %token yTRI "tri" %token yTRUE "true" %token yUNIQUE "unique" @@ -429,7 +433,7 @@ statePop: /* empty */ { V3Read::statePop(); } // Files fileE: /* empty */ { } - | file { } + | timeunitsDeclE file { } ; file: description { } @@ -440,13 +444,26 @@ file: description { } description: moduleDecl { } ; +// IEEE: timeunits_declaration + empty +timeunitsDeclE: /*empty*/ { } + | yTIMEUNIT yaTIMENUM ';' { } + | yTIMEPRECISION yaTIMENUM ';' { } + | yTIMEUNIT yaTIMENUM ';' yTIMEPRECISION yaTIMENUM ';' { } + | yTIMEPRECISION yaTIMENUM ';' yTIMEUNIT yaTIMENUM ';' { } + ; + //********************************************************************** // Module headers // IEEE: module_declaration: -moduleDecl: modHdr modParE modPortsE ';' modItemListE yENDMODULE endLabelE +moduleDecl: modHeader timeunitsDeclE modItemListE yENDMODULE endLabelE + { if ($3) $1->addStmtp($3); } + ; + +modHeader: + modHdr modParE modPortsE ';' { $1->modTrace(V3Parse::s_trace); // Stash for implicit wires, etc - if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3); if ($5) $1->addStmtp($5); } + if ($2) $1->addStmtp($2); if ($3) $1->addStmtp($3); } ; modHdr: @@ -723,6 +740,7 @@ dlyTerm: yaID { $$ = NULL; } | yaINTNUM { $$ = NULL; } | yaFLOATNUM { $$ = NULL; } + | yaTIMENUM { $$ = NULL; } ; // IEEE: mintypmax_expression and constant_mintypmax_expression diff --git a/test_regress/t/t_inst_sv.v b/test_regress/t/t_inst_sv.v index 663569209..e92973cee 100644 --- a/test_regress/t/t_inst_sv.v +++ b/test_regress/t/t_inst_sv.v @@ -8,6 +8,11 @@ module t (/*AUTOARG*/ clk ); +`ifdef verilator // Otherwise need it in every module, including test, but that'll make a mess + timeunit 1ns; + timeprecision 1ns; +`endif + input clk; integer cyc; initial cyc=1;