Optimise away empty (VHDL) processes
This commit is contained in:
parent
be3c4cf268
commit
9fbb449e06
|
|
@ -51,7 +51,11 @@ static int generate_vhdl_process(vhdl_entity *ent, ivl_process_t proc)
|
||||||
// Initial processes are translated to VHDL processes with
|
// Initial processes are translated to VHDL processes with
|
||||||
// no sensitivity list and and indefinite wait statement at
|
// no sensitivity list and and indefinite wait statement at
|
||||||
// the end
|
// the end
|
||||||
if (ivl_process_type(proc) == IVL_PR_INITIAL) {
|
// However, if no statements were added to the container
|
||||||
|
// by draw_stmt, don't bother adding a wait as `emit'
|
||||||
|
// will optimise the process out of the output
|
||||||
|
if (ivl_process_type(proc) == IVL_PR_INITIAL
|
||||||
|
&& !vhdl_proc->get_container()->empty()) {
|
||||||
vhdl_wait_stmt *wait = new vhdl_wait_stmt();
|
vhdl_wait_stmt *wait = new vhdl_wait_stmt();
|
||||||
vhdl_proc->get_container()->add_stmt(wait);
|
vhdl_proc->get_container()->add_stmt(wait);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,14 @@ bool vhdl_process::have_declared_var(const std::string &name) const
|
||||||
|
|
||||||
void vhdl_process::emit(std::ofstream &of, int level) const
|
void vhdl_process::emit(std::ofstream &of, int level) const
|
||||||
{
|
{
|
||||||
|
// If there are no statements in the body, this process
|
||||||
|
// can't possibly do anything, so don't bother to emit it
|
||||||
|
if (stmts_.empty()) {
|
||||||
|
of << "-- Removed one empty process";
|
||||||
|
newline(of, level);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit_comment(of, level);
|
emit_comment(of, level);
|
||||||
if (name_.size() > 0)
|
if (name_.size() > 0)
|
||||||
of << name_ << ": ";
|
of << name_ << ": ";
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,7 @@ public:
|
||||||
|
|
||||||
void add_stmt(vhdl_seq_stmt *stmt);
|
void add_stmt(vhdl_seq_stmt *stmt);
|
||||||
void emit(std::ofstream &of, int level) const;
|
void emit(std::ofstream &of, int level) const;
|
||||||
|
bool empty() const { return stmts_.empty(); }
|
||||||
private:
|
private:
|
||||||
std::list<vhdl_seq_stmt*> stmts_;
|
std::list<vhdl_seq_stmt*> stmts_;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue