diff --git a/vhdlpp/debug.cc b/vhdlpp/debug.cc index 3cba11096..6dfe102a9 100644 --- a/vhdlpp/debug.cc +++ b/vhdlpp/debug.cc @@ -57,12 +57,12 @@ void Entity::dump(ostream&out) const { out << "entity " << name_ << " file=" << get_fileline() << endl; - if (ports.size() == 0) { + if (ports_.size() == 0) { out << " No ports" << endl; } else { out << " PORTS:" << endl; - for (vector::const_iterator cur = ports.begin() - ; cur != ports.end() ; ++cur) { + for (vector::const_iterator cur = ports_.begin() + ; cur != ports_.end() ; ++cur) { InterfacePort*item = *cur; out << setw(6) << "" << item->name << " : " << item->mode diff --git a/vhdlpp/entity.cc b/vhdlpp/entity.cc index a674b558a..e0a847486 100644 --- a/vhdlpp/entity.cc +++ b/vhdlpp/entity.cc @@ -34,6 +34,14 @@ Entity::~Entity() { } +void Entity::set_interface(std::list*ports) +{ + while (ports->size() > 0) { + ports_.push_back(ports->front()); + ports->pop_front(); + } +} + Architecture* Entity::add_architecture(Architecture*that) { if (Architecture*tmp = arch_ [that->get_name()]) { diff --git a/vhdlpp/entity.h b/vhdlpp/entity.h index 2974a6fb4..ffeb5246c 100644 --- a/vhdlpp/entity.h +++ b/vhdlpp/entity.h @@ -20,6 +20,7 @@ */ # include +# include # include # include "StringHeap.h" # include "LineInfo.h" @@ -47,6 +48,12 @@ class Entity : public LineInfo { // Entities have names. perm_string get_name() const { return name_; } + // Declare the ports for the entity. The parser calls this + // method with a list of interface elements that were parsed + // for the entity. This method collects those entities, and + // empties the list in the process. + void set_interface(std::list*ports); + // bind an architecture to the entity, and return the // Architecture that was bound. If there was a previous // architecture with the same name bound, then do not replace @@ -60,12 +67,11 @@ class Entity : public LineInfo { void dump(ostream&out) const; - public: - std::vector ports; - private: perm_string name_; + std::vector ports_; + std::maparch_; Architecture*bind_arch_; diff --git a/vhdlpp/entity_emit.cc b/vhdlpp/entity_emit.cc index 03299e83e..91d41a39f 100644 --- a/vhdlpp/entity_emit.cc +++ b/vhdlpp/entity_emit.cc @@ -42,11 +42,11 @@ int Entity::emit(ostream&out) out << "module " << name_; // If there are ports, emit them. - if (ports.size() > 0) { + if (ports_.size() > 0) { out << "("; const char*sep = 0; - for (vector::iterator cur = ports.begin() - ; cur != ports.end() ; ++cur) { + for (vector::iterator cur = ports_.begin() + ; cur != ports_.end() ; ++cur) { InterfacePort*port = *cur; // FIXME: this is a stub. This port handling code diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index ebec95bbf..77178ab6a 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -194,10 +194,7 @@ entity_declaration FILE_NAME(tmp, @1); // Transfer the ports std::list*ports = $4; - while (ports->size() > 0) { - tmp->ports.push_back(ports->front()); - ports->pop_front(); - } + tmp->set_interface(ports); delete ports; // Save the entity in the entity map. design_entities[tmp->get_name()] = tmp; @@ -214,10 +211,7 @@ entity_declaration delete[]$7; // Transfer the ports std::list*ports = $4; - while (ports->size() > 0) { - tmp->ports.push_back(ports->front()); - ports->pop_front(); - } + tmp->set_interface(ports); delete ports; // Save the entity in the entity map. design_entities[tmp->get_name()] = tmp;