2010-01-19 03:50:19 -06:00
|
|
|
/*
|
|
|
|
* Instance.cpp
|
|
|
|
* openChams
|
|
|
|
*
|
|
|
|
* Created by damien dupuis on 12/01/10.
|
|
|
|
* Copyright 2010 UPMC / LIP6. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "Instance.h"
|
|
|
|
#include "Netlist.h"
|
|
|
|
#include "Net.h"
|
2010-03-02 07:25:31 -06:00
|
|
|
#include "Transistor.h"
|
2010-01-29 03:10:44 -06:00
|
|
|
#include "OpenChamsException.h"
|
2010-01-19 03:50:19 -06:00
|
|
|
|
|
|
|
namespace OpenChams {
|
2010-01-29 03:10:44 -06:00
|
|
|
Instance::Instance(Name name, Name model, Name mosType, bool sourceBulkConnected, Netlist* netlist)
|
2010-01-19 03:50:19 -06:00
|
|
|
: _name(name)
|
|
|
|
, _model(model)
|
|
|
|
, _mosType(mosType)
|
2010-01-29 03:10:44 -06:00
|
|
|
, _sourceBulkConnected(sourceBulkConnected)
|
2010-01-19 03:50:19 -06:00
|
|
|
, _netlist(netlist) {}
|
|
|
|
|
|
|
|
void Instance::addConnector(Name name) {
|
|
|
|
// si name n'est pas déjà présent dans la map on ajoute name, NULL (pas de net)
|
|
|
|
map<Name, Net*>::iterator it = _netMap.find(name);
|
|
|
|
if (it == _netMap.end())
|
|
|
|
_netMap[name] = NULL;
|
2010-01-29 03:10:44 -06:00
|
|
|
else {
|
|
|
|
string error("[ERROR] The same instance cannot have several connectors with same name (");
|
|
|
|
error += name.getString();
|
|
|
|
error += ").";
|
|
|
|
throw OpenChamsException(error);
|
|
|
|
}
|
2010-01-19 03:50:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::connect(Name connectorName, Name netName) {
|
|
|
|
// si connectorName n'est pas déjà présent dans la map :
|
|
|
|
// on cherche le net associé a netName dans la netlist (getNet(Name))
|
|
|
|
// on ajoute cName, net a la map
|
|
|
|
map<Name, Net*>::iterator it = _netMap.find(connectorName);
|
|
|
|
if (it != _netMap.end()) {
|
|
|
|
Net* net = _netlist->getNet(netName);
|
2010-01-29 03:10:44 -06:00
|
|
|
if (!net) {
|
|
|
|
string error("[ERROR] While connecting instance : net (");
|
|
|
|
error += netName.getString();
|
|
|
|
error += ") does not exist.";
|
|
|
|
throw OpenChamsException(error);
|
|
|
|
}
|
2010-01-19 03:50:19 -06:00
|
|
|
else
|
|
|
|
_netMap[connectorName] = net;
|
|
|
|
}
|
2010-01-29 03:10:44 -06:00
|
|
|
else {
|
|
|
|
string error("[ERROR] While connecting instance : connector (");
|
|
|
|
error += connectorName.getString();
|
|
|
|
error += ") does not exist.";
|
|
|
|
throw OpenChamsException(error);
|
|
|
|
}
|
2010-01-19 03:50:19 -06:00
|
|
|
}
|
2010-01-29 04:49:15 -06:00
|
|
|
}
|
|
|
|
|