Add VHDL syntax element for `with .. select' statement
This will be used to implement combinatorial UDPs
This commit is contained in:
parent
6dcf936807
commit
bf3734110e
|
|
@ -888,3 +888,41 @@ void vhdl_param_decl::emit(std::ostream &of, int level) const
|
|||
of << name_ << " : ";
|
||||
type_->emit(of, level);
|
||||
}
|
||||
|
||||
vhdl_with_select_stmt::~vhdl_with_select_stmt()
|
||||
{
|
||||
delete test_;
|
||||
|
||||
for (when_list_t::const_iterator it = whens_.begin();
|
||||
it != whens_.end();
|
||||
++it) {
|
||||
delete (*it).value;
|
||||
delete (*it).cond;
|
||||
}
|
||||
}
|
||||
|
||||
void vhdl_with_select_stmt::emit(std::ostream &of, int level) const
|
||||
{
|
||||
emit_comment(of, level);
|
||||
|
||||
of << "with ";
|
||||
test_->emit(of, level);
|
||||
of << " select";
|
||||
newline(of, indent(level));
|
||||
|
||||
when_list_t::const_iterator it = whens_.begin();
|
||||
while (it != whens_.end()) {
|
||||
if (++it != whens_.end()) {
|
||||
of << ",";
|
||||
newline(of, indent(level));
|
||||
}
|
||||
else
|
||||
of << ";";
|
||||
}
|
||||
}
|
||||
|
||||
void vhdl_with_select_stmt::add_condition(vhdl_expr *value, vhdl_expr *cond)
|
||||
{
|
||||
when_part_t when = { value, cond };
|
||||
whens_.push_back(when);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,6 +254,16 @@ public:
|
|||
|
||||
typedef std::list<vhdl_conc_stmt*> conc_stmt_list_t;
|
||||
|
||||
/*
|
||||
* A '<value> when <cond>' clause that appears in several
|
||||
* statement types.
|
||||
*/
|
||||
struct when_part_t {
|
||||
vhdl_expr *value, *cond;
|
||||
};
|
||||
typedef std::list<when_part_t> when_list_t;
|
||||
|
||||
|
||||
/*
|
||||
* A concurrent signal assignment (i.e. not part of a process).
|
||||
* Can have any number of `when' clauses, in which case the original
|
||||
|
|
@ -272,13 +282,23 @@ private:
|
|||
vhdl_var_ref *lhs_;
|
||||
vhdl_expr *rhs_;
|
||||
vhdl_expr *after_;
|
||||
|
||||
struct when_part_t {
|
||||
vhdl_expr *value, *cond;
|
||||
};
|
||||
std::list<when_part_t> whens_;
|
||||
when_list_t whens_;
|
||||
};
|
||||
|
||||
|
||||
class vhdl_with_select_stmt : public vhdl_conc_stmt {
|
||||
public:
|
||||
vhdl_with_select_stmt(vhdl_expr *test) : test_(test) {}
|
||||
~vhdl_with_select_stmt();
|
||||
|
||||
void emit(std::ostream &of, int level) const;
|
||||
void add_condition(vhdl_expr *value, vhdl_expr *cond);
|
||||
private:
|
||||
vhdl_expr *test_;
|
||||
when_list_t whens_;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Any sequential statement in a process.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue