Skip to content

Commit

Permalink
Detect and warn about anachronistic use of begin/end in generate.
Browse files Browse the repository at this point in the history
Verilog-2001 only allows a single generate item within a generate-
endgenerate region, but allowed one to collect generate schemes with
begin/end blocks. Verilog-2005 cleaned up that mess, and it is the
2005 syntax that Icarus Verilog implements. This patch detects the
anachronistic use of begin/end within the generate region, ignores
the begin/end words, and prints a warning that the user is using an
obsolete syntax.
  • Loading branch information
steveicarus committed Jun 19, 2008
1 parent b2c9352 commit ce9fd01
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
9 changes: 9 additions & 0 deletions parse.y
Expand Up @@ -2200,6 +2200,15 @@ module_item
K_endcase K_endcase
{ pform_endgenerate(); } { pform_endgenerate(); }


/* Handle some anachronistic syntax cases. */
| K_generate K_begin module_item_list_opt K_end K_endgenerate
{ /* Detect and warn about anachronistic begin/end use */
if (generation_flag > GN_VER2001) {
warn_count += 1;
cerr << @2 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl;
}
}

/* specify blocks are parsed but ignored. */ /* specify blocks are parsed but ignored. */


| K_specify K_endspecify | K_specify K_endspecify
Expand Down
19 changes: 11 additions & 8 deletions parse_misc.cc
Expand Up @@ -30,6 +30,15 @@ unsigned error_count = 0;
unsigned warn_count = 0; unsigned warn_count = 0;
unsigned long based_size = 0; unsigned long based_size = 0;


std::ostream& operator << (std::ostream&o, const YYLTYPE&loc)
{
if (loc.text)
o << loc.text << ":";
o << loc.first_line;
return o;
}


void VLerror(const char*msg) void VLerror(const char*msg)
{ {
error_count += 1; error_count += 1;
Expand All @@ -39,20 +48,14 @@ void VLerror(const char*msg)
void VLerror(const YYLTYPE&loc, const char*msg) void VLerror(const YYLTYPE&loc, const char*msg)
{ {
error_count += 1; error_count += 1;
if (loc.text) cerr << loc << ": " << msg << endl;
cerr << loc.text << ":";

cerr << loc.first_line << ": " << msg << endl;
based_size = 0; /* Clear the base information if we have an error. */ based_size = 0; /* Clear the base information if we have an error. */
} }


void yywarn(const YYLTYPE&loc, const char*msg) void yywarn(const YYLTYPE&loc, const char*msg)
{ {
warn_count += 1; warn_count += 1;
if (loc.text) cerr << loc << ": warning: " << msg << endl;
cerr << loc.text << ":";

cerr << loc.first_line << ": warning: " << msg << endl;
} }


int VLwrap() int VLwrap()
Expand Down
3 changes: 3 additions & 0 deletions parse_misc.h
Expand Up @@ -23,6 +23,7 @@
#endif #endif


# include <list> # include <list>
# include <ostream>
# include "compiler.h" # include "compiler.h"
# include "pform.h" # include "pform.h"


Expand Down Expand Up @@ -62,6 +63,8 @@ extern void VLerror(const YYLTYPE&loc, const char*msg);
#define yywarn VLwarn #define yywarn VLwarn
extern void VLwarn(const YYLTYPE&loc, const char*msg); extern void VLwarn(const YYLTYPE&loc, const char*msg);


extern ostream& operator << (ostream&, const YYLTYPE&loc);

extern unsigned error_count, warn_count; extern unsigned error_count, warn_count;
extern unsigned long based_size; extern unsigned long based_size;


Expand Down

0 comments on commit ce9fd01

Please sign in to comment.