diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index 3a96d107b..9593ca385 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -279,6 +279,8 @@ vhdl_component_decl *vhdl_component_decl::component_decl_for(const vhdl_entity * vhdl_component_decl *decl = new vhdl_component_decl (ent->get_name().c_str()); + decl->ports_ = ent->get_ports(); + return decl; } @@ -286,7 +288,14 @@ void vhdl_component_decl::emit(std::ofstream &of, int level) const { emit_comment(of, level); of << "component " << name_ << " is"; - // ...ports... + + if (ports_.size() > 0) { + newline(of, indent(level)); + of << "port ("; + emit_children(of, ports_, indent(level), ";"); + of << ");"; + } + newline(of, level); of << "end component;"; } diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 0b85a2ff1..2e351e3b2 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -302,7 +302,7 @@ public: private: vhdl_component_decl(const char *name); - // TODO: Ports, etc. + decl_list_t ports_; }; @@ -429,6 +429,7 @@ public: void add_port(vhdl_port_decl *decl); vhdl_arch *get_arch() const { return arch_; } vhdl_decl *get_decl(const std::string &name) const; + const decl_list_t &get_ports() const { return ports_; } const std::string &get_name() const { return name_; } void requires_package(const char *spec); const std::string &get_derived_from() const { return derived_from_; }