Detect generate regions within generate schemes.

Generate schemes may nest freely, but generate regions
(an anachronistic concept from 1364-2001) cannot nest,
not within schemes or other regions. Have the parser detect
the nesting and print an error message.
This commit is contained in:
Stephen Williams 2010-03-11 16:06:02 -08:00
parent 70fc742c9d
commit 47e68e21b1
3 changed files with 22 additions and 1 deletions

12
parse.y
View File

@ -2425,9 +2425,19 @@ module_item
/* A generate region can contain further module items. Actually, it
is supposed to be limited to certain kinds of module items, but
the semantic tests will check that for us. */
the semantic tests will check that for us. Do check that the
generate/endgenerate regions do not nest. Generate schemes nest,
but generate regions do not. */
| K_generate module_item_list_opt K_endgenerate
{ // Test for bad nesting. I understand it, but it is illegal.
if (pform_parent_generate()) {
cerr << @1 << ": error: Generate/endgenerate regions cannot nest." << endl;
cerr << @1 << ": : Try removing optional generate/endgenerate keywords," << endl;
cerr << @1 << ": : or move them to surround the parent generate scheme." << endl;
error_count += 1;
}
}
| K_genvar list_of_identifiers ';'
{ pform_genvars(@1, $2); }

View File

@ -342,6 +342,11 @@ PBlock* pform_push_block_scope(char*name, PBlock::BL_TYPE bt)
return block;
}
PGenerate* pform_parent_generate(void)
{
return pform_cur_generate;
}
void pform_bind_attributes(map<perm_string,PExpr*>&attributes,
svector<named_pexpr_t*>*attr)
{

View File

@ -214,6 +214,12 @@ extern void pform_generate_case_item(const struct vlltype&lp, svector<PExpr*>*te
extern void pform_generate_block_name(char*name);
extern void pform_endgenerate();
/*
* This function returns the lexically containing generate scheme, if
* there is one. The parser may use this to check if we are within a
* generate scheme.
*/
extern PGenerate* pform_parent_generate(void);
/*
* The makewire functions announce to the pform code new wires. These