Permalink
Browse files

Detect and warn about anachronistic use of begin/end in generate.

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...
1 parent b2c9352 commit ce9fd0147f2fa1e227b2b6bf5df69172f1996301 @steveicarus committed Jun 19, 2008
Showing with 23 additions and 8 deletions.
  1. +9 −0 parse.y
  2. +11 −8 parse_misc.cc
  3. +3 −0 parse_misc.h
View
@@ -2200,6 +2200,15 @@ module_item
K_endcase
{ 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. */
| K_specify K_endspecify
View
@@ -30,6 +30,15 @@ unsigned error_count = 0;
unsigned warn_count = 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)
{
error_count += 1;
@@ -39,20 +48,14 @@ void VLerror(const char*msg)
void VLerror(const YYLTYPE&loc, const char*msg)
{
error_count += 1;
- if (loc.text)
- cerr << loc.text << ":";
-
- cerr << loc.first_line << ": " << msg << endl;
+ cerr << loc << ": " << msg << endl;
based_size = 0; /* Clear the base information if we have an error. */
}
void yywarn(const YYLTYPE&loc, const char*msg)
{
warn_count += 1;
- if (loc.text)
- cerr << loc.text << ":";
-
- cerr << loc.first_line << ": warning: " << msg << endl;
+ cerr << loc << ": warning: " << msg << endl;
}
int VLwrap()
View
@@ -23,6 +23,7 @@
#endif
# include <list>
+# include <ostream>
# include "compiler.h"
# include "pform.h"
@@ -62,6 +63,8 @@ extern void VLerror(const YYLTYPE&loc, const char*msg);
#define yywarn VLwarn
extern void VLwarn(const YYLTYPE&loc, const char*msg);
+extern ostream& operator << (ostream&, const YYLTYPE&loc);
+
extern unsigned error_count, warn_count;
extern unsigned long based_size;

0 comments on commit ce9fd01

Please sign in to comment.