From 1fb01d4d9815dc93a1056fb1c7fe226cb9405db4 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 9 Jun 2008 16:37:05 +0100 Subject: [PATCH] Emit port declarations --- tgt-vhdl/vhdl_helper.hh | 5 ++++- tgt-vhdl/vhdl_syntax.cc | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tgt-vhdl/vhdl_helper.hh b/tgt-vhdl/vhdl_helper.hh index b6dc0444f..656a35409 100644 --- a/tgt-vhdl/vhdl_helper.hh +++ b/tgt-vhdl/vhdl_helper.hh @@ -27,16 +27,19 @@ template void emit_children(std::ofstream &of, const std::list &children, - int level) + int level, const char *delim="") { // Don't indent if there are no children if (children.size() == 0) newline(of, level); else { typename std::list::const_iterator it; + int sz = children.size(); for (it = children.begin(); it != children.end(); ++it) { newline(of, indent(level)); (*it)->emit(of, indent(level)); + if (--sz > 0) + of << delim; } newline(of, level); } diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index f25449108..3a96d107b 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -85,8 +85,14 @@ void vhdl_entity::emit(std::ofstream &of, int level) const emit_comment(of, level); of << "entity " << name_ << " is"; - // ...ports... - // newline(indent(level)); + + if (ports_.size() > 0) { + newline(of, indent(level)); + of << "port ("; + emit_children(of, ports_, indent(level), ";"); + of << ");"; + } + newline(of, level); of << "end entity; "; blank_line(of, level); // Extra blank line after entities @@ -332,8 +338,6 @@ void vhdl_port_decl::emit(std::ofstream &of, int level) const } type_->emit(of, level); - of << ";"; - emit_comment(of, level, true); } void vhdl_var_decl::emit(std::ofstream &of, int level) const