vhdlpp: 'wait for' statement.

This commit is contained in:
Maciej Suminski 2015-05-22 18:07:31 +02:00
parent d6ff1946f9
commit 68f8007fc4
6 changed files with 57 additions and 1 deletions

View File

@ -359,7 +359,7 @@ static void touchup_interface_for_functions(std::list<InterfacePort*>*ports)
%type <sequ> sequential_statement if_statement signal_assignment signal_assignment_statement
%type <sequ> case_statement procedure_call procedure_call_statement
%type <sequ> loop_statement variable_assignment variable_assignment_statement
%type <sequ> assertion_statement report_statement return_statement
%type <sequ> assertion_statement report_statement return_statement wait_for_statement
%type <range> range
%type <range_list> range_list index_constraint
@ -2201,6 +2201,7 @@ sequential_statement
| return_statement { $$ = $1; }
| report_statement { $$ = $1; }
| assertion_statement { $$ = $1; }
| wait_for_statement { $$ = $1; }
| K_null ';' { $$ = 0; }
| error ';'
{ errormsg(@1, "Syntax error in sequential statement.\n");
@ -2631,6 +2632,14 @@ variable_declaration /* IEEE 1076-2008 P6.4.2.4 */
}
;
wait_for_statement
: K_wait K_for expression ';'
{ WaitForStmt*tmp = new WaitForStmt($3);
FILE_NAME(tmp, @1);
$$ = tmp;
}
;
waveform
: waveform_elements
{ $$ = $1; }

View File

@ -284,3 +284,8 @@ AssertStmt::AssertStmt(Expression*condition, const char*msg, ReportStmt::severit
}
const std::string AssertStmt::default_msg_ = std::string("Assertion violation.");
WaitForStmt::WaitForStmt(Expression*delay)
: delay_(delay)
{
}

View File

@ -308,4 +308,17 @@ class AssertStmt : public ReportStmt {
static const std::string default_msg_;
};
class WaitForStmt : public SequentialStmt {
public:
WaitForStmt(Expression*delay);
void dump(ostream&out, int indent) const;
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void write_to_stream(std::ostream&fd);
private:
Expression*delay_;
};
#endif /* IVL_sequential_H */

View File

@ -180,3 +180,10 @@ void AssertStmt::dump(ostream&out, int indent) const
cond_->dump(out, indent+3);
ReportStmt::dump(out, indent+3);
}
void WaitForStmt::dump(ostream&out, int indent) const
{
out << setw(indent) << "" << "WaitForStmt at file=" << get_fileline() << endl;
out << setw(indent+3) << "" << "delay: ";
delay_->dump(out, indent+3);
}

View File

@ -197,3 +197,8 @@ int AssertStmt::elaborate(Entity*ent, ScopeBase*scope)
{
return cond_->elaborate_expr(ent, scope, 0);
}
int WaitForStmt::elaborate(Entity*ent, ScopeBase*scope)
{
return delay_->elaborate_expr(ent, scope, 0);
}

View File

@ -512,3 +512,20 @@ void AssertStmt::write_to_stream(std::ostream&fd)
fd << std::endl;
ReportStmt::write_to_stream(fd);
}
int WaitForStmt::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "#(";
errors += delay_->emit(out, ent, scope);
out << ")";
return errors;
}
void WaitForStmt::write_to_stream(std::ostream&fd)
{
fd << "wait for ";
delay_->write_to_stream(fd);
}