2011-01-03 08:38:08 +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"
|
|
|
|
|
# include "compiler.h"
|
2011-01-31 20:16:14 +01:00
|
|
|
# include "architec.h"
|
2011-01-03 08:38:08 +01:00
|
|
|
# include <iostream>
|
|
|
|
|
# include <fstream>
|
|
|
|
|
# include <iomanip>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int elaborate_entities(void)
|
|
|
|
|
{
|
|
|
|
|
int errors = 0;
|
|
|
|
|
|
|
|
|
|
for (map<perm_string,Entity*>::iterator cur = design_entities.begin()
|
|
|
|
|
; cur != design_entities.end() ; ++cur) {
|
|
|
|
|
errors += cur->second->elaborate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Entity::elaborate()
|
|
|
|
|
{
|
|
|
|
|
int errors = 0;
|
|
|
|
|
|
|
|
|
|
if (verbose_flag)
|
2011-01-24 05:26:27 +01:00
|
|
|
cerr << "Elaborate entity " << name_ << "..." << endl;
|
2011-01-03 08:38:08 +01:00
|
|
|
|
2011-01-31 20:16:14 +01:00
|
|
|
if (arch_.size() == 0) {
|
|
|
|
|
cerr << get_fileline() << ": error: "
|
|
|
|
|
<< "No architectures to choose from for entity " << name_
|
|
|
|
|
<< "." << endl;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2011-01-06 17:12:55 +01:00
|
|
|
|
2011-01-03 08:38:08 +01:00
|
|
|
|
2011-01-31 20:16:14 +01:00
|
|
|
if (arch_.size() > 1) {
|
|
|
|
|
cerr << get_fileline() << ": sorry: "
|
|
|
|
|
<< "Too many architectures for entity " << name_
|
|
|
|
|
<< ". Architectures are:" << endl;
|
|
|
|
|
for (map<perm_string,Architecture*>::const_iterator cur = arch_.begin()
|
|
|
|
|
; cur != arch_.end() ; ++cur) {
|
|
|
|
|
cerr << get_fileline() << ": : " << cur->first
|
|
|
|
|
<< " at " << cur->second->get_fileline() << endl;
|
2011-01-03 08:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:16:14 +01:00
|
|
|
errors += 1;
|
|
|
|
|
}
|
2011-01-03 08:38:08 +01:00
|
|
|
|
2011-01-31 20:16:14 +01:00
|
|
|
bind_arch_ = arch_.begin()->second;
|
|
|
|
|
if (verbose_flag)
|
|
|
|
|
cerr << "For entity " << get_name()
|
|
|
|
|
<< ", choosing architecture " << bind_arch_->get_name()
|
|
|
|
|
<< "." << endl;
|
2011-01-03 08:38:08 +01:00
|
|
|
|
|
|
|
|
return errors;
|
|
|
|
|
}
|