Added classes to handle equations (HighLevelCstr, DDP, DesignerCstrOC, NRCCstr), all child of Equation.

Modified openChams parser and driver to take into account these classes.
This commit is contained in:
Farakh Javid 2011-11-08 17:59:52 +00:00
parent f1ba48f977
commit 64ae150d5e
17 changed files with 1410 additions and 950 deletions

View File

@ -17,6 +17,11 @@ SET ( hpps vlsisapd/openChams/Circuit.h
vlsisapd/openChams/Port.h
vlsisapd/openChams/Wire.h
vlsisapd/openChams/OpenChamsException.h
vlsisapd/openChams/Equation.h
vlsisapd/openChams/HighLevelCstr.h
vlsisapd/openChams/NRCCstr.h
vlsisapd/openChams/DDP.h
vlsisapd/openChams/DesignerCstrOC.h
)
SET ( cpps Circuit.cpp
Netlist.cpp
@ -33,6 +38,11 @@ SET ( cpps Circuit.cpp
Node.cpp
Transistor.cpp
Wire.cpp
Equation.cpp
HighLevelCstr.cpp
NRCCstr.cpp
DDP.cpp
DesignerCstrOC.cpp
)
SET ( pycpps PyOpenChams.cpp
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
/*
* DDP.cpp
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
#include <string>
#include <iostream>
using namespace std;
#include "vlsisapd/openChams/DDP.h"
namespace OpenChams {
DDP::DDP()
: Equation()
{}
// This function prints all equations
void DDP::printEquations() {
map<int, string>::iterator it;
cerr << "Printing equations of a DDP : " << endl;
for(it=_equations.begin(); it!=_equations.end(); ++it) {
cerr << (*it).first << "\t" << (*it).second << endl;
}
}
} // namespace

View File

@ -0,0 +1,31 @@
/*
* DesignerCstrOC.cpp
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
#include <string>
#include <iostream>
using namespace std;
#include "vlsisapd/openChams/DesignerCstrOC.h"
namespace OpenChams {
DesignerCstrOC::DesignerCstrOC()
: Equation()
{}
// This function prints all equations
void DesignerCstrOC::printEquations() {
map<int, string>::iterator it;
cerr << "Printing equations of a DesignerCstrOC : " << endl;
for(it=_equations.begin(); it!=_equations.end(); ++it) {
cerr << (*it).first << "\t" << (*it).second << endl;
}
}
} // namespace

View File

@ -0,0 +1,25 @@
/*
* Equation.cpp
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
#include <string>
using namespace std;
#include "vlsisapd/openChams/Equation.h"
namespace OpenChams {
Equation::Equation()
: _equations()
// , _paramsInEquation()
{}
void Equation::addEquation(std::string eq) {
_equations[_equations.size()] = eq;
}
} // namespace

View File

@ -0,0 +1,31 @@
/*
* HighLevelCstr.cpp
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
#include <string>
#include <iostream>
using namespace std;
#include "vlsisapd/openChams/HighLevelCstr.h"
namespace OpenChams {
HighLevelCstr::HighLevelCstr()
: Equation()
{}
// This function prints all equations
void HighLevelCstr::printEquations() {
map<int, string>::iterator it;
cerr << "Printing equations of a HighLevelCstr : " << endl;
for(it=_equations.begin(); it!=_equations.end(); ++it) {
cerr << (*it).first << "\t" << (*it).second << endl;
}
}
} // namespace

View File

@ -0,0 +1,33 @@
/*
* NRCCstr.cpp
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
#include <string>
#include <iostream>
using namespace std;
#include "vlsisapd/openChams/NRCCstr.h"
namespace OpenChams {
NRCCstr::NRCCstr(string controlVoltage)
: Equation()
, _controlVoltage(controlVoltage)
{}
// This function prints all equations
void NRCCstr::printEquations() {
map<int, string>::iterator it;
cerr << "Printing equations of a NRCCstr : " << endl;
cerr << "Control voltage = " << _controlVoltage << endl;
for(it=_equations.begin(); it!=_equations.end(); ++it) {
cerr << (*it).first << "\t" << (*it).second << endl;
}
}
} // namespace

View File

@ -59,6 +59,7 @@ void Parameters::addParameter(Name name, string eqStr) {
throw OpenChamsException(error);
}
_paramsEq[name] = eqStr;
cerr << "987* _paramsEq.size() = " << _paramsEq.size() << endl;
}
} // namespace

View File

@ -299,6 +299,7 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
;
} // end operatorScope
/*
// map wrapping for OpenChams::Sizing
STL_MAP_WRAPPING_PTR(Name, Operator*, "OperatorsMap")
// class OpenChams::Sizing
@ -313,6 +314,7 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
.def("getEquations", &Sizing::getEquations, return_internal_reference<>())
.def("getOperators", &Sizing::getOperators, return_internal_reference<>())
;
*/
// map wrapping for OpenChams::Layout
STL_MAP_WRAPPING(Name, Name, "LayoutInstancesMap")

View File

@ -13,6 +13,7 @@ using namespace std;
#include "vlsisapd/openChams/Sizing.h"
#include "vlsisapd/openChams/Circuit.h"
#include "vlsisapd/openChams/Operator.h"
#include "vlsisapd/openChams/Equation.h"
#include "vlsisapd/openChams/OpenChamsException.h"
namespace OpenChams {
@ -31,8 +32,8 @@ Operator* Sizing::addOperator(Name instanceName, Name operatorName, Name simulMo
return op;
}
void Sizing::addEquation(Name equationName, string equation) {
map<Name, string>::iterator it = _equations.find(equationName);
void Sizing::addEquation(Name equationName, Equation* equation) {
map<Name, Equation*>::iterator it = _equations.find(equationName);
if (it != _equations.end()) {
string error("[ERROR] Cannot set several equations with the same name in 'sizing' (");
error += equationName.getString();

View File

@ -91,8 +91,13 @@ class Circuit {
void readSizing(xmlNode*);
void readInstanceSizing(xmlNode*, Sizing*);
void readConstraint(xmlNode*, Operator*);
void readEquations(xmlNode*, Sizing*);
void readEquation(xmlNode*, Sizing*);
void readEquation_CircuitLevel(xmlNode*, Sizing*);
void readEquation_NRC(xmlNode*, Sizing*);
void readEquation_DDPs(xmlNode*, Sizing*);
void readEquation_DesignerCstr(xmlNode*, Sizing*);
void readLayout(xmlNode*);
void readInstanceLayout(xmlNode*, Layout*);
void readHBTree(xmlNode*, Layout*);

View File

@ -0,0 +1,24 @@
/*
* DDP.h
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2008-2010 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __OPENCHAMS_DDP_H__
#define __OPENCHAMS_DDP_H__
#include "vlsisapd/openChams/Equation.h"
namespace OpenChams {
class DDP : public Equation {
public:
DDP();
virtual void printEquations();
};
} // namespace
#endif

View File

@ -0,0 +1,24 @@
/*
* DesignerCstrOC.h
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2008-2010 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __OPENCHAMS_DESIGNERCSTROC_H__
#define __OPENCHAMS_DESIGNERCSTROC_H__
#include "vlsisapd/openChams/Equation.h"
namespace OpenChams {
class DesignerCstrOC : public Equation {
public:
DesignerCstrOC();
virtual void printEquations();
};
} // namespace
#endif

View File

@ -0,0 +1,34 @@
/*
* Equation.h
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2008-2010 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __OPENCHAMS_EQUATION_H__
#define __OPENCHAMS_EQUATION_H__
#include <vector>
#include <map>
//using namespace std;
namespace OpenChams {
class Equation {
public:
Equation();
void addEquation(std::string eq);
inline std::map<int, std::string>& getEquationStr();
virtual void printEquations() = 0;
protected:
std::map<int, std::string> _equations; // this map contains the equation(s)
// std::vector<std::string> _paramsInEquation; //
};
inline std::map<int, std::string>& Equation::getEquationStr() {return _equations;}
} // namespace
#endif

View File

@ -0,0 +1,24 @@
/*
* HighLevelCstr.h
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2008-2010 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __OPENCHAMS_HIGHLEVELCSTR_H__
#define __OPENCHAMS_HIGHLEVELCSTR_H__
#include "vlsisapd/openChams/Equation.h"
namespace OpenChams {
class HighLevelCstr : public Equation {
public:
HighLevelCstr();
virtual void printEquations();
};
} // namespace
#endif

View File

@ -0,0 +1,33 @@
/*
* NRCCstr.h
* openChams
*
* Created by Farakh JAVID on 25/10/2011.
* Copyright 2008-2010 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __OPENCHAMS_NRCCSTR_H__
#define __OPENCHAMS_NRCCSTR_H__
#include "vlsisapd/openChams/Equation.h"
namespace OpenChams {
class NRCCstr : public Equation {
public:
NRCCstr(string controlVoltage);
inline void setVoltage(std::string s);
inline std::string getVoltage();
virtual void printEquations();
private:
std::string _controlVoltage;
};
inline void NRCCstr::setVoltage(std::string s) {_controlVoltage = s;}
inline std::string NRCCstr::getVoltage() {return _controlVoltage;}
} // namespace
#endif

View File

@ -13,32 +13,40 @@
#include <map>
namespace OpenChams {
class Name;
class Circuit;
class Operator;
class Name;
class Circuit;
class Operator;
class Equation;
// class HighLevelCstr;
// class NRCCstr;
// class DDP;
class Sizing {
public:
Sizing(Circuit*);
Operator* addOperator(Name instanceName, Name operatorName, Name simulModel);
void addEquation(Name equationName, std::string equation);
inline bool hasNoOperators();
inline bool hasNoEquations();
inline const std::map<Name, Operator*>& getOperators();
inline const std::map<Name, std::string>& getEquations();
private:
Circuit* _circuit;
std::map<Name, Operator*> _operators; // instanceName <-> operator
std::map<Name, std::string> _equations; // equationName <-> equation (string)
};
class Sizing {
public:
Sizing(Circuit*);
inline bool Sizing::hasNoOperators() { return (_operators.size() == 0) ? true : false; };
inline bool Sizing::hasNoEquations() { return (_equations.size() == 0) ? true : false; };
inline const std::map<Name, Operator*>& Sizing::getOperators() { return _operators; };
inline const std::map<Name, std::string>& Sizing::getEquations() { return _equations; };
Operator* addOperator(Name instanceName, Name operatorName, Name simulModel);
// void addEquation(Name equationName, HighLevelCstr*);
// void addEquation(Name equationName, NRCCstr*);
// void addEquation(Name equationName, DDP*);
void addEquation(Name equationName, Equation*);
inline bool hasNoOperators();
inline bool hasNoEquations();
inline const std::map<Name, Operator*>& getOperators();
inline const std::map<Name, Equation*>& getEquations();
private:
Circuit* _circuit;
std::map<Name, Operator*> _operators; // instanceName <-> operator
std::map<Name, Equation*> _equations; // equationName <-> equation (string)
};
inline bool Sizing::hasNoOperators() { return (_operators.size() == 0) ? true : false; };
inline bool Sizing::hasNoEquations() { return (_equations.size() == 0) ? true : false; };
inline const std::map<Name, Operator*>& Sizing::getOperators() { return _operators; };
inline const std::map<Name, Equation*>& Sizing::getEquations() { return _equations; };
} // namespace
#endif