From 6f46930c235745dd98dd26bd3a34e91e74b4178b Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 15 Sep 2008 17:58:45 -0700 Subject: [PATCH] Make it an error to have a `timescale inside a module definition. While the standard is not completely clear about this, we are making it an error for a `timescale directive to be inside a (macro)module definition. This means that all modules and any statements contained within have a single well defined time unit and precision. --- lexor.lex | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/lexor.lex b/lexor.lex index 936f5ce0f..c487bd28a 100644 --- a/lexor.lex +++ b/lexor.lex @@ -87,6 +87,7 @@ static void process_timescale(const char*txt); static list keyword_mask_stack; static int comment_enter; +static bool in_module = false; %} %x CCOMMENT @@ -227,6 +228,15 @@ S [afpnumkKMGT] BEGIN(EDGES); break; + case K_module: + case K_macromodule: + in_module = true; + break; + + case K_endmodule: + in_module = false; + break; + default: yylval.text = 0; break; @@ -343,6 +353,12 @@ S [afpnumkKMGT] ^{W}?`timescale { BEGIN(PPTIMESCALE); } .* { process_timescale(yytext); } \n { + if (in_module) { + cerr << yylloc.text << ":" << yylloc.first_line << ": error: " + "`timescale directive can not be inside a module " + "definition." << endl; + error_count += 1; + } yylloc.first_line += 1; BEGIN(0); } @@ -439,7 +455,7 @@ S [afpnumkKMGT] } else { cerr << yylloc.text << ":" << yylloc.first_line - << " error: Net type " << yytext + << ": error: Net type " << yytext << " is not a valid (and supported)" << " default net type." << endl; net_type = NetNet::WIRE; @@ -457,37 +473,37 @@ S [afpnumkKMGT] ^{W}?`define{W}?.* { cerr << yylloc.text << ":" << yylloc.first_line << - ": `define not supported. Use an external preprocessor." + ": warning: `define not supported. Use an external preprocessor." << endl; } ^{W}?`else{W}?.* { cerr << yylloc.text << ":" << yylloc.first_line << - ": `else not supported. Use an external preprocessor." + ": warning: `else not supported. Use an external preprocessor." << endl; } ^{W}?`endif{W}?.* { cerr << yylloc.text << ":" << yylloc.first_line << - ": `endif not supported. Use an external preprocessor." + ": warning: `endif not supported. Use an external preprocessor." << endl; } ^{W}?`ifdef{W}?.* { cerr << yylloc.text << ":" << yylloc.first_line << - ": `ifdef not supported. Use an external preprocessor." + ": warning: `ifdef not supported. Use an external preprocessor." << endl; } ^`include{W}?.* { cerr << yylloc.text << ":" << yylloc.first_line << - ": `include not supported. Use an external preprocessor." + ": warning: `include not supported. Use an external preprocessor." << endl; } ^`undef{W}?.* { cerr << yylloc.text << ":" << yylloc.first_line << - ": `undef not supported. Use an external preprocessor." + ": warning: `undef not supported. Use an external preprocessor." << endl; }