diff --git a/tgt-vhdl/process.cc b/tgt-vhdl/process.cc index 4542469f2..91e109214 100644 --- a/tgt-vhdl/process.cc +++ b/tgt-vhdl/process.cc @@ -33,8 +33,14 @@ static int generate_vhdl_process(vhdl_entity *ent, ivl_process_t proc) { vhdl_process *vhdl_proc = new vhdl_process(); - // TODO: Add statements - + // Initial processes are translated to VHDL processes with + // no sensitivity list and and indefinite wait statement at + // the end + if (ivl_process_type(proc) == IVL_PR_INITIAL) { + vhdl_wait_stmt *wait = new vhdl_wait_stmt(); + vhdl_proc->add_stmt(wait); + } + // Add a comment indicating where it came from ivl_scope_t scope = ivl_process_scope(proc); const char *type = ivl_process_type(proc) == IVL_PR_INITIAL diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc index 2cce979c6..483064acb 100644 --- a/tgt-vhdl/vhdl_element.cc +++ b/tgt-vhdl/vhdl_element.cc @@ -206,10 +206,7 @@ void vhdl_process::emit(std::ofstream &of, int level) const newline(of, level); // ...declarations... of << "begin"; - newline(of, level); - // ...statements... - of << " wait;"; // Just to stop the simulation hanging - newline(of, level); + emit_children(of, stmts_, level); of << "end process;"; newline(of, level); } @@ -261,3 +258,12 @@ void vhdl_component_decl::emit(std::ofstream &of, int level) const newline(of, level); of << "end component;"; } + + +//////// WAIT STATEMENT //////// + +void vhdl_wait_stmt::emit(std::ofstream &of, int level) const +{ + // TODO: There are lots of different types of `wait' + of << "wait;"; +} diff --git a/tgt-vhdl/vhdl_element.hh b/tgt-vhdl/vhdl_element.hh index b178ff325..a03e5785f 100644 --- a/tgt-vhdl/vhdl_element.hh +++ b/tgt-vhdl/vhdl_element.hh @@ -68,6 +68,17 @@ public: typedef std::list seq_stmt_list_t; + +/* + * Delay simulation indefinitely, until an event, or for a + * specified time. + */ +class vhdl_wait_stmt : public vhdl_seq_stmt { +public: + void emit(std::ofstream &of, int level) const; +}; + + /* * A declaration of some sort (variable, component, etc.). * Declarations have names, which is the identifier of the variable,