diff --git a/vhdlpp/architec.cc b/vhdlpp/architec.cc index 580b030a0..79ccbb20f 100644 --- a/vhdlpp/architec.cc +++ b/vhdlpp/architec.cc @@ -71,7 +71,7 @@ ComponentInstantiation::ComponentInstantiation(perm_string i, perm_string c, while (! ports->empty()) { named_expr_t*cur = ports->front(); ports->pop_front(); - port_map_[cur->name()] = cur->expr(); + port_map_.insert(make_pair(cur->name(), cur->expr())); } } diff --git a/vhdlpp/architec.h b/vhdlpp/architec.h index 508bb787a..ba6b8160d 100644 --- a/vhdlpp/architec.h +++ b/vhdlpp/architec.h @@ -122,7 +122,7 @@ class ComponentInstantiation : public Architecture::Statement { perm_string iname_; perm_string cname_; - std::map port_map_; + std::multimap port_map_; }; class ProcessStatement : public Architecture::Statement { diff --git a/vhdlpp/architec_elaborate.cc b/vhdlpp/architec_elaborate.cc index e44563681..b58bcc605 100644 --- a/vhdlpp/architec_elaborate.cc +++ b/vhdlpp/architec_elaborate.cc @@ -56,7 +56,7 @@ int ComponentInstantiation::elaborate(Entity*ent, Architecture*arc) map port_match; - for (map::iterator cur = port_map_.begin() + for (multimap::const_iterator cur = port_map_.begin() ; cur != port_map_.end() ; ++cur) { const InterfacePort*iport = base->find_port(cur->first); if (iport == 0) { @@ -75,6 +75,15 @@ int ComponentInstantiation::elaborate(Entity*ent, Architecture*arc) cur->second->elaborate_expr(ent, arc, iport->type); } + //each formal (component's) port should be associated at most once + for(multimap::const_iterator cur = port_map_.begin() + ; cur != port_map_.end() ; ++cur) + if(port_map_.count(cur->first) != 1) { + //at least one port is associated twice or more + cerr << cur->second->get_fileline() << ": error: At least one port is associated" + << " twice or more in a single component instantiation." << endl; + errors += 1; + } return errors; } diff --git a/vhdlpp/architec_emit.cc b/vhdlpp/architec_emit.cc index 1305426ab..52ddb7b54 100644 --- a/vhdlpp/architec_emit.cc +++ b/vhdlpp/architec_emit.cc @@ -105,7 +105,7 @@ int ComponentInstantiation::emit(ostream&out, Entity*ent, Architecture*arc) out << cname_ << " " << iname_ << "("; const char*comma = ""; - for (map::iterator cur = port_map_.begin() + for (multimap::iterator cur = port_map_.begin() ; cur != port_map_.end() ; ++cur) { // Skip unconnected ports if (cur->second == 0)