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.
This commit is contained in:
parent
0e699ca226
commit
6f46930c23
30
lexor.lex
30
lexor.lex
|
|
@ -87,6 +87,7 @@ static void process_timescale(const char*txt);
|
||||||
static list<int> keyword_mask_stack;
|
static list<int> keyword_mask_stack;
|
||||||
|
|
||||||
static int comment_enter;
|
static int comment_enter;
|
||||||
|
static bool in_module = false;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%x CCOMMENT
|
%x CCOMMENT
|
||||||
|
|
@ -227,6 +228,15 @@ S [afpnumkKMGT]
|
||||||
BEGIN(EDGES);
|
BEGIN(EDGES);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case K_module:
|
||||||
|
case K_macromodule:
|
||||||
|
in_module = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_endmodule:
|
||||||
|
in_module = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
yylval.text = 0;
|
yylval.text = 0;
|
||||||
break;
|
break;
|
||||||
|
|
@ -343,6 +353,12 @@ S [afpnumkKMGT]
|
||||||
^{W}?`timescale { BEGIN(PPTIMESCALE); }
|
^{W}?`timescale { BEGIN(PPTIMESCALE); }
|
||||||
<PPTIMESCALE>.* { process_timescale(yytext); }
|
<PPTIMESCALE>.* { process_timescale(yytext); }
|
||||||
<PPTIMESCALE>\n {
|
<PPTIMESCALE>\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;
|
yylloc.first_line += 1;
|
||||||
BEGIN(0); }
|
BEGIN(0); }
|
||||||
|
|
||||||
|
|
@ -439,7 +455,7 @@ S [afpnumkKMGT]
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line
|
cerr << yylloc.text << ":" << yylloc.first_line
|
||||||
<< " error: Net type " << yytext
|
<< ": error: Net type " << yytext
|
||||||
<< " is not a valid (and supported)"
|
<< " is not a valid (and supported)"
|
||||||
<< " default net type." << endl;
|
<< " default net type." << endl;
|
||||||
net_type = NetNet::WIRE;
|
net_type = NetNet::WIRE;
|
||||||
|
|
@ -457,37 +473,37 @@ S [afpnumkKMGT]
|
||||||
|
|
||||||
^{W}?`define{W}?.* {
|
^{W}?`define{W}?.* {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line <<
|
cerr << yylloc.text << ":" << yylloc.first_line <<
|
||||||
": `define not supported. Use an external preprocessor."
|
": warning: `define not supported. Use an external preprocessor."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
^{W}?`else{W}?.* {
|
^{W}?`else{W}?.* {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line <<
|
cerr << yylloc.text << ":" << yylloc.first_line <<
|
||||||
": `else not supported. Use an external preprocessor."
|
": warning: `else not supported. Use an external preprocessor."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
^{W}?`endif{W}?.* {
|
^{W}?`endif{W}?.* {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line <<
|
cerr << yylloc.text << ":" << yylloc.first_line <<
|
||||||
": `endif not supported. Use an external preprocessor."
|
": warning: `endif not supported. Use an external preprocessor."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
^{W}?`ifdef{W}?.* {
|
^{W}?`ifdef{W}?.* {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line <<
|
cerr << yylloc.text << ":" << yylloc.first_line <<
|
||||||
": `ifdef not supported. Use an external preprocessor."
|
": warning: `ifdef not supported. Use an external preprocessor."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
^`include{W}?.* {
|
^`include{W}?.* {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line <<
|
cerr << yylloc.text << ":" << yylloc.first_line <<
|
||||||
": `include not supported. Use an external preprocessor."
|
": warning: `include not supported. Use an external preprocessor."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
^`undef{W}?.* {
|
^`undef{W}?.* {
|
||||||
cerr << yylloc.text << ":" << yylloc.first_line <<
|
cerr << yylloc.text << ":" << yylloc.first_line <<
|
||||||
": `undef not supported. Use an external preprocessor."
|
": warning: `undef not supported. Use an external preprocessor."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue