2011-01-03 07:30:09 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "entity.h"
|
2011-01-24 05:26:27 +01:00
|
|
|
# include "architec.h"
|
2011-05-16 01:17:51 +02:00
|
|
|
# include <cassert>
|
2011-01-03 07:30:09 +01:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
std::map<perm_string,Entity*> design_entities;
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
ComponentBase::ComponentBase(perm_string name)
|
2011-01-24 05:26:27 +01:00
|
|
|
: name_(name)
|
2011-01-03 07:30:09 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
ComponentBase::~ComponentBase()
|
2011-01-03 07:30:09 +01:00
|
|
|
{
|
2011-07-20 18:16:08 +02:00
|
|
|
for(std::vector<InterfacePort*>::iterator it = ports_.begin()
|
|
|
|
|
; it != ports_.end(); ++it)
|
|
|
|
|
delete *it;
|
2011-01-03 07:30:09 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
void ComponentBase::set_interface(std::list<InterfacePort*>*ports)
|
2011-02-03 04:59:20 +01:00
|
|
|
{
|
2011-07-29 02:07:49 +02:00
|
|
|
while (! ports->empty()) {
|
2011-02-03 04:59:20 +01:00
|
|
|
ports_.push_back(ports->front());
|
|
|
|
|
ports->pop_front();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-10 18:42:22 +02:00
|
|
|
const InterfacePort* ComponentBase::find_port(perm_string my_name) const
|
|
|
|
|
{
|
|
|
|
|
for (size_t idx = 0 ; idx < ports_.size() ; idx += 1) {
|
|
|
|
|
if (ports_[idx]->name == my_name)
|
|
|
|
|
return ports_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-22 17:16:20 +01:00
|
|
|
Entity::Entity(perm_string name)
|
|
|
|
|
: ComponentBase(name)
|
|
|
|
|
{
|
2011-07-29 02:07:49 +02:00
|
|
|
bind_arch_ = 0;
|
2011-03-22 17:16:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Entity::~Entity()
|
|
|
|
|
{
|
2011-07-20 18:16:08 +02:00
|
|
|
for(map<perm_string,Architecture*>::reverse_iterator it = arch_.rbegin()
|
|
|
|
|
; it != arch_.rend(); ++it)
|
|
|
|
|
delete it->second;
|
2011-03-22 17:16:20 +01:00
|
|
|
}
|
|
|
|
|
|
2011-01-24 05:26:27 +01:00
|
|
|
Architecture* Entity::add_architecture(Architecture*that)
|
2011-01-03 07:30:09 +01:00
|
|
|
{
|
2011-01-24 05:26:27 +01:00
|
|
|
if (Architecture*tmp = arch_ [that->get_name()]) {
|
|
|
|
|
return tmp;
|
2011-01-03 07:30:09 +01:00
|
|
|
}
|
2011-01-24 05:26:27 +01:00
|
|
|
|
|
|
|
|
return arch_[that->get_name()] = that;
|
2011-01-03 07:30:09 +01:00
|
|
|
}
|
2011-05-16 01:17:51 +02:00
|
|
|
|
|
|
|
|
void Entity::set_declaration_l_value(perm_string nam, bool flag)
|
|
|
|
|
{
|
|
|
|
|
map<perm_string,VType::decl_t>::iterator cur = declarations_.find(nam);
|
|
|
|
|
assert(cur != declarations_.end());
|
|
|
|
|
cur->second.reg_flag = flag;
|
|
|
|
|
}
|