Clean up entity interface.
This commit is contained in:
parent
798ead9345
commit
5914617727
|
|
@ -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<InterfacePort*>::const_iterator cur = ports.begin()
|
||||
; cur != ports.end() ; ++cur) {
|
||||
for (vector<InterfacePort*>::const_iterator cur = ports_.begin()
|
||||
; cur != ports_.end() ; ++cur) {
|
||||
InterfacePort*item = *cur;
|
||||
out << setw(6) << "" << item->name
|
||||
<< " : " << item->mode
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ Entity::~Entity()
|
|||
{
|
||||
}
|
||||
|
||||
void Entity::set_interface(std::list<InterfacePort*>*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()]) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
# include <map>
|
||||
# include <list>
|
||||
# include <vector>
|
||||
# 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<InterfacePort*>*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<InterfacePort*> ports;
|
||||
|
||||
private:
|
||||
perm_string name_;
|
||||
|
||||
std::vector<InterfacePort*> ports_;
|
||||
|
||||
std::map<perm_string,Architecture*>arch_;
|
||||
|
||||
Architecture*bind_arch_;
|
||||
|
|
|
|||
|
|
@ -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<InterfacePort*>::iterator cur = ports.begin()
|
||||
; cur != ports.end() ; ++cur) {
|
||||
for (vector<InterfacePort*>::iterator cur = ports_.begin()
|
||||
; cur != ports_.end() ; ++cur) {
|
||||
InterfacePort*port = *cur;
|
||||
|
||||
// FIXME: this is a stub. This port handling code
|
||||
|
|
|
|||
|
|
@ -194,10 +194,7 @@ entity_declaration
|
|||
FILE_NAME(tmp, @1);
|
||||
// Transfer the ports
|
||||
std::list<InterfacePort*>*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<InterfacePort*>*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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue