Allow delays in combinatorial UDPs

Add a `after' clause to the `with .. select' statement.
This commit is contained in:
Nick Gasson 2008-08-11 20:36:09 +01:00
parent d55a3a073a
commit 9d7e4ac15f
3 changed files with 13 additions and 6 deletions

View File

@ -152,8 +152,9 @@ static void udp_logic(vhdl_arch *arch, ivl_net_logic_t log)
vhdl_expr *value = new vhdl_const_bit(row[nin]);
vhdl_expr *cond = new vhdl_const_bits(row, nin, false);
vhdl_expr *delay = translate_time_expr(ivl_logic_delay(log, 1));
ws->add_condition(value, cond);
ws->add_condition(value, cond, delay);
}
ss.str("");

View File

@ -611,7 +611,7 @@ vhdl_cassign_stmt::~vhdl_cassign_stmt()
void vhdl_cassign_stmt::add_condition(vhdl_expr *value, vhdl_expr *cond)
{
when_part_t when = { value, cond };
when_part_t when = { value, cond, NULL };
whens_.push_back(when);
}
@ -899,6 +899,8 @@ vhdl_with_select_stmt::~vhdl_with_select_stmt()
++it) {
delete (*it).value;
delete (*it).cond;
if ((*it).delay)
delete (*it).delay;
}
}
@ -916,6 +918,10 @@ void vhdl_with_select_stmt::emit(std::ostream &of, int level) const
when_list_t::const_iterator it = whens_.begin();
while (it != whens_.end()) {
(*it).value->emit(of, level);
if ((*it).delay) {
of << " after ";
(*it).delay->emit(of, level);
}
of << " when ";
(*it).cond->emit(of, level);
@ -928,8 +934,8 @@ void vhdl_with_select_stmt::emit(std::ostream &of, int level) const
}
}
void vhdl_with_select_stmt::add_condition(vhdl_expr *value, vhdl_expr *cond)
void vhdl_with_select_stmt::add_condition(vhdl_expr *value, vhdl_expr *cond, vhdl_expr *delay)
{
when_part_t when = { value, cond };
when_part_t when = { value, cond, delay };
whens_.push_back(when);
}

View File

@ -259,7 +259,7 @@ typedef std::list<vhdl_conc_stmt*> conc_stmt_list_t;
* statement types.
*/
struct when_part_t {
vhdl_expr *value, *cond;
vhdl_expr *value, *cond, *delay;
};
typedef std::list<when_part_t> when_list_t;
@ -293,7 +293,7 @@ public:
~vhdl_with_select_stmt();
void emit(std::ostream &of, int level) const;
void add_condition(vhdl_expr *value, vhdl_expr *cond);
void add_condition(vhdl_expr *value, vhdl_expr *cond, vhdl_expr *delay=NULL);
private:
vhdl_expr *test_;
vhdl_var_ref *out_;