Initial support for if_generate syntax.
This commit is contained in:
parent
0775e36a67
commit
1249b5dd32
|
|
@ -69,6 +69,16 @@ ForGenerate::~ForGenerate()
|
|||
{
|
||||
}
|
||||
|
||||
IfGenerate::IfGenerate(perm_string gname, Expression*cond,
|
||||
std::list<Architecture::Statement*>&s)
|
||||
: GenerateStatement(gname, s), cond_(cond)
|
||||
{
|
||||
}
|
||||
|
||||
IfGenerate::~IfGenerate()
|
||||
{
|
||||
}
|
||||
|
||||
SignalAssignment::SignalAssignment(ExpName*name, list<Expression*>&rv)
|
||||
: lval_(name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,6 +127,19 @@ class ForGenerate : public GenerateStatement {
|
|||
Expression*msb_;
|
||||
};
|
||||
|
||||
class IfGenerate : public GenerateStatement {
|
||||
|
||||
public:
|
||||
IfGenerate(perm_string gname, Expression*cond,
|
||||
std::list<Architecture::Statement*>&s);
|
||||
~IfGenerate();
|
||||
|
||||
int elaborate(Entity*ent, Architecture*arc);
|
||||
int emit(ostream&out, Entity*entity, Architecture*arc);
|
||||
|
||||
private:
|
||||
Expression*cond_;
|
||||
};
|
||||
|
||||
/*
|
||||
* The SignalAssignment class represents the
|
||||
|
|
|
|||
|
|
@ -117,6 +117,13 @@ int ForGenerate::elaborate(Entity*ent, Architecture*arc)
|
|||
return errors;
|
||||
}
|
||||
|
||||
int IfGenerate::elaborate(Entity*ent, Architecture*arc)
|
||||
{
|
||||
int errors = 0;
|
||||
errors += elaborate_statements(ent, arc);
|
||||
return errors;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method attempts to rewrite the process content as an
|
||||
* always-@(n-edge <expr>) version of the same statement. This makes
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ int GenerateStatement::emit_statements(ostream&out, Entity*ent, Architecture*arc
|
|||
int ForGenerate::emit(ostream&out, Entity*ent, Architecture*arc)
|
||||
{
|
||||
int errors = 0;
|
||||
out << "generate genvar \\" << genvar_ << " ;" << endl;
|
||||
out << "genvar \\" << genvar_ << " ;" << endl;
|
||||
out << "for (\\" << genvar_ << " = ";
|
||||
errors += lsb_->emit(out, ent, arc);
|
||||
out << "; \\" << genvar_ << " <= ";
|
||||
|
|
@ -192,7 +192,21 @@ int ForGenerate::emit(ostream&out, Entity*ent, Architecture*arc)
|
|||
errors += emit_statements(out, ent, arc);
|
||||
|
||||
out << "end" << endl;
|
||||
out << "endgenerate" << endl;
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
int IfGenerate::emit(ostream&out, Entity*ent, Architecture*arc)
|
||||
{
|
||||
int errors = 0;
|
||||
out << "if (";
|
||||
cond_->emit(out, ent, arc);
|
||||
out << ") begin : \\" << get_name() << endl;
|
||||
|
||||
errors += emit_statements(out, ent, arc);
|
||||
|
||||
out << "end" << endl;
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -283,7 +283,8 @@ static list<VTypeRecord::element_t*>* record_elements(list<perm_string>*names,
|
|||
%type <component_specification> component_specification
|
||||
|
||||
%type <arch_statement> concurrent_statement component_instantiation_statement concurrent_signal_assignment_statement
|
||||
%type <arch_statement> for_generate_statement process_statement
|
||||
%type <arch_statement> for_generate_statement generate_statement if_generate_statement
|
||||
%type <arch_statement> process_statement
|
||||
%type <arch_statement_list> architecture_statement_part generate_statement_body
|
||||
|
||||
%type <choice> choice
|
||||
|
|
@ -692,7 +693,7 @@ concurrent_signal_assignment_statement
|
|||
concurrent_statement
|
||||
: component_instantiation_statement
|
||||
| concurrent_signal_assignment_statement
|
||||
| for_generate_statement
|
||||
| generate_statement
|
||||
| process_statement
|
||||
;
|
||||
|
||||
|
|
@ -1068,6 +1069,11 @@ for_generate_statement
|
|||
}
|
||||
;
|
||||
|
||||
generate_statement /* IEEE 1076-2008 P11.8 */
|
||||
: if_generate_statement
|
||||
| for_generate_statement
|
||||
;
|
||||
|
||||
generate_statement_body
|
||||
: architecture_statement_part { $$ = $1; }
|
||||
;
|
||||
|
|
@ -1123,6 +1129,29 @@ identifier_opt : IDENTIFIER { $$ = $1; } | { $$ = 0; } ;
|
|||
|
||||
identifier_colon_opt : IDENTIFIER ':' { $$ = $1; } | { $$ = 0; };
|
||||
|
||||
/* The if_generate_statement rule describes the if_generate syntax.
|
||||
|
||||
NOTE: This does not yet implement the elsif and else parts of the
|
||||
syntax. This shouldn't be hard, but is simply not done yet. */
|
||||
if_generate_statement /* IEEE 1076-2008 P11.8 */
|
||||
: IDENTIFIER ':' K_if expression
|
||||
K_generate generate_statement_body
|
||||
K_end K_generate identifier_opt ';'
|
||||
{ perm_string name = lex_strings.make($1);
|
||||
IfGenerate*tmp = new IfGenerate(name, $4, *$6);
|
||||
FILE_NAME(tmp, @3);
|
||||
|
||||
if ($9 && name != $9) {
|
||||
errormsg(@1, "if-generate name %s does not match closing name %s\n",
|
||||
name.str(), $9);
|
||||
}
|
||||
delete[]$1;
|
||||
delete $6;
|
||||
delete[]$9;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
if_statement
|
||||
: K_if expression K_then sequence_of_statements
|
||||
if_statement_elsif_list_opt if_statement_else
|
||||
|
|
|
|||
Loading…
Reference in New Issue