2010-01-19 03:50:19 -06:00
|
|
|
/*
|
2010-01-29 04:49:15 -06:00
|
|
|
* Netlist.cpp
|
2010-01-19 03:50:19 -06:00
|
|
|
* openChams
|
|
|
|
*
|
|
|
|
* Created by damien dupuis on 12/01/10.
|
|
|
|
* Copyright 2010 UPMC / LIP6. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-01-29 04:49:15 -06:00
|
|
|
#include "Netlist.h"
|
2010-01-19 03:50:19 -06:00
|
|
|
#include "Circuit.h"
|
2010-01-29 03:10:44 -06:00
|
|
|
#include "OpenChamsException.h"
|
2010-01-19 03:50:19 -06:00
|
|
|
|
|
|
|
namespace OpenChams {
|
|
|
|
Netlist::Netlist(Circuit* circuit) : _circuit(circuit) {}
|
|
|
|
|
|
|
|
void Netlist::addInstance(Instance* inst) {
|
2010-01-29 03:10:44 -06:00
|
|
|
for (vector<Instance*>::iterator it = _instances.begin() ; it != _instances.end() ; ++it) {
|
|
|
|
if ((*it)->getName() == inst->getName()) {
|
|
|
|
string error("[ERROR] Cannot define two instances with the same name in netlist (");
|
|
|
|
error += inst->getName().getString();
|
|
|
|
error += ").";
|
|
|
|
throw OpenChamsException(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_instances.push_back(inst);
|
2010-01-19 03:50:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Netlist::addNet(Net* net) {
|
2010-01-29 03:10:44 -06:00
|
|
|
for (vector<Net*>::iterator it = _nets.begin() ; it != _nets.end() ; ++it ) {
|
|
|
|
if ((*it)->getName() == net->getName()) {
|
|
|
|
string error("[ERROR] Cannot define two nets with the same name in netlist (");
|
|
|
|
error += net->getName().getString();
|
|
|
|
error += ").";
|
|
|
|
throw OpenChamsException(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_nets.push_back(net);
|
2010-01-19 03:50:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Instance* Netlist::getInstance(Name instanceName) {
|
|
|
|
for (size_t i = 0 ; i < _instances.size() ; ++i) {
|
|
|
|
if (_instances[i]->getName() == instanceName) {
|
|
|
|
return _instances[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Net* Netlist::getNet(Name netName) {
|
|
|
|
for (size_t i = 0; i < _nets.size(); ++i) {
|
|
|
|
if (_nets[i]->getName() == netName) {
|
|
|
|
return _nets[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-26 09:05:20 -06:00
|
|
|
} // namespace
|
2010-01-29 03:10:44 -06:00
|
|
|
|