Modifications in OpenChams description:

- Add OpenChams::SlicingNode class to drive/parse XML files.
  OpenChams::SlicingNode contains information to create a real slicing tree (SlicingNode from hurricaneAMS)
- Minor modification in Circuit.cpp for case when HBTree are not described in XML file.
This commit is contained in:
EricLaoGitHub 2016-02-16 19:21:37 +01:00
parent 0930660a1f
commit 5809fc7aa0
7 changed files with 2046 additions and 258 deletions

View File

@ -38,6 +38,7 @@ projects = [
, "graph" , "graph"
, "pharos" , "pharos"
, "isis" , "isis"
, "horus"
#, "schematic" #, "schematic"
, "solver" , "solver"
, "autoDTR" , "autoDTR"

View File

@ -20,6 +20,7 @@
find_package(BISON REQUIRED) find_package(BISON REQUIRED)
find_package(FLEX REQUIRED) find_package(FLEX REQUIRED)
find_package(Doxygen) find_package(Doxygen)
find_package(HURRICANE REQUIRED)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(cmake_modules) add_subdirectory(cmake_modules)

View File

@ -1,4 +1,9 @@
INCLUDE_DIRECTORIES(${VLSISAPD_SOURCE_DIR}/src/openChams/src ${LIBXML2_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH}) INCLUDE_DIRECTORIES( ${VLSISAPD_SOURCE_DIR}/src/openChams/src
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${PYTHON_INCLUDE_PATH}
${HURRICANE_INCLUDE_DIR}
)
SET ( hpps vlsisapd/openChams/Circuit.h SET ( hpps vlsisapd/openChams/Circuit.h
vlsisapd/openChams/Netlist.h vlsisapd/openChams/Netlist.h
@ -21,6 +26,7 @@ SET ( hpps vlsisapd/openChams/Circuit.h
vlsisapd/openChams/NRCCstr.h vlsisapd/openChams/NRCCstr.h
vlsisapd/openChams/DDP.h vlsisapd/openChams/DDP.h
vlsisapd/openChams/DesignerCstrOC.h vlsisapd/openChams/DesignerCstrOC.h
vlsisapd/openChams/SlicingTree.h
) )
SET ( cpps Circuit.cpp SET ( cpps Circuit.cpp
Netlist.cpp Netlist.cpp
@ -41,6 +47,7 @@ SET ( cpps Circuit.cpp
NRCCstr.cpp NRCCstr.cpp
DDP.cpp DDP.cpp
DesignerCstrOC.cpp DesignerCstrOC.cpp
SlicingTree.cpp
) )
SET ( pycpps PyOpenChams.cpp SET ( pycpps PyOpenChams.cpp
) )

View File

@ -2,13 +2,14 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the VLSI SAPD Software. // This file is part of the VLSI SAPD Software.
// Copyright (c) UPMC/LIP6 2009-2012, All Rights Reserved // Copyright (c) UPMC/LIP6 2009-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | V L S I S A P D | // | V L S I S A P D |
// | OpenChams Circuit Data Base | // | OpenChams Circuit Data Base |
// | | // | |
// | Author : Damien Dupuis | // | Author : Damien Dupuis |
// | Eric Lao |
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./Circuit.cpp" | // | C++ Module : "./Circuit.cpp" |
@ -152,6 +153,7 @@ namespace OpenChams {
static bool readSchematicDone = false; static bool readSchematicDone = false;
static bool readSizingDone = false; static bool readSizingDone = false;
static bool readLayoutDone = false; static bool readLayoutDone = false;
static bool readSlicingTreeDone = false;
Circuit::Circuit(const std::string& name, const std::string& techno) Circuit::Circuit(const std::string& name, const std::string& techno)
: _name (name) : _name (name)
@ -161,6 +163,7 @@ namespace OpenChams {
, _schematic (NULL) , _schematic (NULL)
, _sizing (NULL) , _sizing (NULL)
, _layout (NULL) , _layout (NULL)
, _slicingtree (NULL)
{ {
readSubCircuitsPathsDone = false; readSubCircuitsPathsDone = false;
readCircuitParametersDone = false; readCircuitParametersDone = false;
@ -1103,6 +1106,254 @@ namespace OpenChams {
_absolutePath = _absolutePath.substr(0, found); _absolutePath = _absolutePath.substr(0, found);
} }
// SLICINGTREE //
void Circuit::readSlicingTree(xmlNode* node) {
if (readSlicingTreeDone) {
cerr << "[WARNING] Only one 'slicingtree' is allowed in circuit, others will be ignored." << endl;
return;
}
_slicingtree = readSlicingNode(node);
readSlicingTreeDone = true;
}
SlicingNode* Circuit::readSlicingNode(xmlNode* xnode, SlicingNode* slicingNode) {
SlicingNode* snode = NULL;
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
if (node->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(node->name , (xmlChar*)"vertical" )) {
snode = createVerticalSlicingNode (node, slicingNode);
} else if (xmlStrEqual(node->name , (xmlChar*)"horizontal")) {
snode = createHorizontalSlicingNode(node, slicingNode);
} else if (xmlStrEqual(node->name , (xmlChar*)"device" )) {
snode = createDeviceSlicingNode (node, slicingNode);
} else if (xmlStrEqual(node->name , (xmlChar*)"routing" )) {
snode = createRoutingSlicingNode (node, slicingNode);
} else if (!xmlStrEqual(node->name, (xmlChar*)"comment" )) {
cerr << "[WARNING] Unknown " << node->name << " node in 'slicingtree' section, it will be ignored." << endl;
}
}
}
return snode;
}
VSlicingNode* Circuit::createVerticalSlicingNode (xmlNode* xnode, SlicingNode* slicingNode) {
VSlicingNode* vnode = VSlicingNode::create(slicingNode);
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
if (xmlStrEqual(node->name , (xmlChar*)"parameters")) {
setHVParameters(node, vnode);
} else if (xmlStrEqual(node->name, (xmlChar*)"symmetries")) {
setHVSymmetries(node, vnode);
} else if (xmlStrEqual(node->name, (xmlChar*)"children" )) {
addChildren(node, vnode);
} else if (!xmlStrEqual(node->name,(xmlChar*)"comment" )) {
cerr << "[WARNING] Unknown " << node->name << " node in 'vertical' section, it will be ignored." << endl;
}
}
return vnode;
}
HSlicingNode* Circuit::createHorizontalSlicingNode (xmlNode* xnode, SlicingNode* slicingNode) {
HSlicingNode* hnode = HSlicingNode::create(slicingNode);
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
if (xmlStrEqual(node->name, (xmlChar*)"children")) {
addChildren(node, hnode);
} else if (xmlStrEqual(node->name , (xmlChar*)"parameters")) {
setHVParameters(node, hnode);
} else if (xmlStrEqual(node->name , (xmlChar*)"symmetries")) {
setHVSymmetries(node, hnode);
} else if (!xmlStrEqual(node->name, (xmlChar*)"comment" )){
cerr << "[WARNING] Unknown " << node->name << " node in 'horizontal' section, it will be ignored." << endl;
}
}
return hnode;
}
void Circuit::addChildren (xmlNode* xnode, HVSlicingNode* hvnode) {
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
if (node->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(node->name , (xmlChar*)"vertical" )) {
hvnode->push_back(createVerticalSlicingNode (node, hvnode));
} else if (xmlStrEqual(node->name , (xmlChar*)"horizontal")) {
hvnode->push_back(createHorizontalSlicingNode(node, hvnode));
} else if (xmlStrEqual(node->name , (xmlChar*)"device" )) {
hvnode->push_back(createDeviceSlicingNode (node, hvnode));
} else if (xmlStrEqual(node->name , (xmlChar*)"routing" )) {
hvnode->push_back(createRoutingSlicingNode (node, hvnode));
} else if (!xmlStrEqual(node->name, (xmlChar*)"comment" )){
cerr << "[WARNING] Unknown " << node->name << " node in 'slicingtree' section, it will be ignored." << endl;
}
}
}
}
void Circuit::setHVParameters (xmlNode* xnode, HVSlicingNode* hvnode) {
bool toleranceRatioHSet = false;
bool toleranceRatioWSet = false;
bool toleranceBandHSet = false;
bool toleranceBandWSet = false;
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
xmlChar* typeC = xmlGetProp(node, (xmlChar*)"type");
if (typeC) {
string type ((const char*)typeC);
if (type == "alignment") {
xmlChar* alignmentC = xmlGetProp(node, (xmlChar*)"alignment");
if (alignmentC){
string alignment ((const char*)alignmentC);
hvnode->setAlignment(alignment);
}
} else if (type == "toleranceBandH") {
xmlChar* toleranceBandHC = xmlGetProp(node, (xmlChar*)"toleranceBandH");
if (toleranceBandHC){
string toleranceBandH ((const char*)toleranceBandHC);
hvnode->setToleranceBandH(toleranceBandH);
toleranceBandHSet = true;
}
} else if (type == "toleranceBandW") {
xmlChar* toleranceBandWC = xmlGetProp(node, (xmlChar*)"toleranceBandW");
if (toleranceBandWC){
string toleranceBandW ((const char*)toleranceBandWC);
hvnode->setToleranceBandW(toleranceBandW);
toleranceBandWSet = true;
}
} else if (type == "toleranceRatioH") {
xmlChar* toleranceRatioHC = xmlGetProp(node, (xmlChar*)"toleranceRatioH");
if (toleranceRatioHC){
string toleranceRatioH ((const char*)toleranceRatioHC);
hvnode->setToleranceRatioH(toleranceRatioH);
toleranceRatioHSet = true;
}
} else if (type == "toleranceRatioW") {
xmlChar* toleranceRatioWC = xmlGetProp(node, (xmlChar*)"toleranceRatioW");
if (toleranceRatioWC){
string toleranceRatioW ((const char*)toleranceRatioWC);
hvnode->setToleranceRatioW(toleranceRatioW);
toleranceRatioWSet = true;
}
} else if (!xmlStrEqual(node->name, (xmlChar*)"comment" )){
cerr << "[WARNING] Unknown " << node->name << " node in 'HVparameters' section, it will be ignored." << endl;
}
}
}
if (!hvnode->isRoot()){
if (!toleranceRatioHSet){
hvnode->setToleranceRatioH(hvnode->getParent()->getToleranceRatioH());
}
if (!toleranceRatioWSet){
hvnode->setToleranceRatioW(hvnode->getParent()->getToleranceRatioW());
}
if (!toleranceBandHSet){
hvnode->setToleranceBandH(hvnode->getParent()->getToleranceBandH());
}
if (!toleranceBandWSet){
hvnode->setToleranceBandW(hvnode->getParent()->getToleranceBandW());
}
}
}
void Circuit::setHVSymmetries (xmlNode* xnode, HVSlicingNode* hvnode) {
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
xmlChar* sourceC = xmlGetProp(node, (xmlChar*)"source");
xmlChar* targetC = xmlGetProp(node, (xmlChar*)"target");
if ((sourceC)&&(targetC)) {
string source ((const char*)sourceC);
string target ((const char*)targetC);
hvnode->addSymmetry(source, target);
} else if (!xmlStrEqual(node->name, (xmlChar*)"comment" )){
cerr << "[WARNING] Unknown " << node->name << " node in 'HVsymmetries' section, it will be ignored." << endl;
}
}
}
DSlicingNode* Circuit::createDeviceSlicingNode (xmlNode* xnode, SlicingNode* slicingNode) {
DSlicingNode* dnode = NULL;
xmlChar* instanceNameC = xmlGetProp(xnode, (xmlChar*)"instance");
if (instanceNameC){
string instanceName ((const char*)instanceNameC);
dnode = DSlicingNode::create( instanceName, slicingNode );
xmlNode* child = xnode->children;
for (xmlNode* node = child; node; node = node->next) {
xmlChar* typeC = xmlGetProp(node, (xmlChar*)"type");
if (typeC) {
string type ((const char*)typeC);
if (type == "alignment") {
xmlChar* alignmentC = xmlGetProp(node, (xmlChar*)"alignment");
if (alignmentC){
string alignment ((const char*)alignmentC);
dnode->setAlignment(alignment);
}
} else if (type == "preset") {
xmlChar* presetC = xmlGetProp(node, (xmlChar*)"preset");
if (presetC){
string preset ((const char*)presetC);
dnode->setPreset(preset);
}
} else if (type == "nfing") {
xmlChar* nfingC = xmlGetProp(node, (xmlChar*)"nfing");
if (nfingC){
string nfing ((const char*)nfingC);
dnode->setNFing(nfing);
}
} else if (type == "x") {
xmlChar* xC = xmlGetProp(node, (xmlChar*)"x");
if (xC){
string x ((const char*)xC);
dnode->setX(x);
}
} else if (type == "y") {
xmlChar* yC = xmlGetProp(node, (xmlChar*)"y");
if (yC){
string y ((const char*)yC);
dnode->setY(y);
}
} else if (type == "nodeSets") {
xmlChar* startC = xmlGetProp(node, (xmlChar*)"start");
xmlChar* stepC = xmlGetProp(node, (xmlChar*)"step");
xmlChar* countC = xmlGetProp(node, (xmlChar*)"count");
if ( (startC) && (stepC) && (countC) ){
string start ((const char*)startC);
string step ((const char*)stepC);
string count ((const char*)countC);
dnode->setStart(start);
dnode->setStep (step);
dnode->setCount(count);
}
} else
cerr << "[WARNING] Unknown " << type << " type in 'device/parameter' section, it will be ignored." << endl;
} else if (!xmlStrEqual(node->name, (xmlChar*)"comment" )){
cerr << "[WARNING] Unknown " << node->name << " node in 'device' section, it will be ignored." << endl;
}
}
}
return dnode;
}
RSlicingNode* Circuit::createRoutingSlicingNode (xmlNode* xnode, SlicingNode* slicingNode) {
RSlicingNode* rnode = NULL;
xmlChar* valueC = xmlGetProp(xnode, (xmlChar*)"value");
if (valueC){
string value ((const char*)valueC);
rnode = RSlicingNode::create(value, slicingNode);
}
return rnode;
}
Circuit* Circuit::readFromFile(const string filePath) { Circuit* Circuit::readFromFile(const string filePath) {
LIBXML_TEST_VERSION; LIBXML_TEST_VERSION;
Circuit* cir = NULL; Circuit* cir = NULL;
@ -1153,6 +1404,9 @@ namespace OpenChams {
else if (xmlStrEqual(node->name, (xmlChar*)"layout")) { else if (xmlStrEqual(node->name, (xmlChar*)"layout")) {
cir->readLayout(node); cir->readLayout(node);
} }
else if (xmlStrEqual(node->name, (xmlChar*)"slicingtree")) {
cir->readSlicingTree(node);
}
else { else {
string error("[ERROR] Unknown section "); string error("[ERROR] Unknown section ");
error += string((const char*)node->name); error += string((const char*)node->name);
@ -1213,6 +1467,16 @@ namespace OpenChams {
return _layout; return _layout;
} }
void Circuit::setSlicingTree( SlicingNode* slicingtree ) {
if (_slicingtree)
throw OpenChamsException("[ERROR] Cannot create two slicing trees in one circuit.");
_slicingtree = slicingtree;
if (!_slicingtree)
throw OpenChamsException("[ERROR] Cannot create slicingtree.");
}
void Circuit::driveHBTree(ofstream& file, Node* node, unsigned indent) { void Circuit::driveHBTree(ofstream& file, Node* node, unsigned indent) {
if (!node) return; if (!node) return;
for (unsigned i = 0 ; i < indent ; i++) for (unsigned i = 0 ; i < indent ; i++)
@ -1275,6 +1539,17 @@ namespace OpenChams {
} }
} }
void Circuit::driveSlicingTree(ofstream& file, SlicingNode* snode, unsigned indent) {
if (!snode) return;
for (unsigned i = 0 ; i < indent ; i++){ file << " "; }
file << "<slicingtree>" << endl;
snode->toXML(file, indent+1);
for (unsigned i = 0 ; i < indent ; i++){ file << " "; }
file << "</slicingtree>" << endl;
}
bool Circuit::writeToFile(string filePath) { bool Circuit::writeToFile(string filePath) {
ofstream file; ofstream file;
file.open(filePath.c_str()); file.open(filePath.c_str());
@ -1521,7 +1796,6 @@ namespace OpenChams {
if(_sizing && (!_sizing->hasNoOperators() || !_sizing->hasNoEquations()) ) if(_sizing && (!_sizing->hasNoOperators() || !_sizing->hasNoEquations()) )
file << " </sizing>" << endl; file << " </sizing>" << endl;
// ******************************************************************************************* // *******************************************************************************************
if (_layout) { if (_layout) {
file << " <layout>" << endl; file << " <layout>" << endl;
if (!_layout->hasNoInstance()) { if (!_layout->hasNoInstance()) {
@ -1536,6 +1810,14 @@ namespace OpenChams {
} }
file << " </layout>" << endl; file << " </layout>" << endl;
} }
// *******************************************************************************************
if (_slicingtree) {
driveSlicingTree(file, _slicingtree, 1);
}
file << "</circuit>" << endl; file << "</circuit>" << endl;
file.close(); file.close();
return true; return true;

File diff suppressed because it is too large Load Diff

View File

@ -2,13 +2,14 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the VLSI SAPD Software. // This file is part of the VLSI SAPD Software.
// Copyright (c) UPMC/LIP6 2009-2012, All Rights Reserved // Copyright (c) UPMC/LIP6 2009-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | V L S I S A P D | // | V L S I S A P D |
// | OpenChams Circuit Data Base | // | OpenChams Circuit Data Base |
// | | // | |
// | Author : Damien Dupuis | // | Author : Damien Dupuis |
// | Eric Lao |
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./vlsisapd/openChams/Circuit.h" | // | C++ Header : "./vlsisapd/openChams/Circuit.h" |
@ -27,6 +28,7 @@
#include "vlsisapd/openChams/Parameters.h" #include "vlsisapd/openChams/Parameters.h"
#include "vlsisapd/openChams/SimulModel.h" #include "vlsisapd/openChams/SimulModel.h"
#include "vlsisapd/openChams/SlicingTree.h"
namespace OpenChams { namespace OpenChams {
@ -58,6 +60,7 @@ namespace OpenChams {
inline Parameters getParameters (); inline Parameters getParameters ();
inline void addSubCircuitPath ( std::string ); inline void addSubCircuitPath ( std::string );
inline std::vector<std::string>& getSubCircuitPaths (); inline std::vector<std::string>& getSubCircuitPaths ();
inline SlicingNode* getSlicingTree ();
// Mutators. // Mutators.
void addSimulModel ( unsigned void addSimulModel ( unsigned
, SimulModel::Base , SimulModel::Base
@ -69,7 +72,9 @@ namespace OpenChams {
Schematic* createSchematic (); Schematic* createSchematic ();
Sizing* createSizing (); Sizing* createSizing ();
Layout* createLayout (); Layout* createLayout ();
void setSlicingTree ( SlicingNode* slicingtree );
void driveHBTree ( std::ofstream&, Node*, unsigned ); void driveHBTree ( std::ofstream&, Node*, unsigned );
void driveSlicingTree ( std::ofstream&, SlicingNode*, unsigned );
bool writeToFile ( std::string filePath ); bool writeToFile ( std::string filePath );
static Circuit* readFromFile ( const std::string filePath ); static Circuit* readFromFile ( const std::string filePath );
@ -112,6 +117,17 @@ namespace OpenChams {
void readHBTree ( xmlNode*, Layout* ); void readHBTree ( xmlNode*, Layout* );
Node* readNodeOrBloc ( xmlNode*, Node* parent = NULL ); Node* readNodeOrBloc ( xmlNode*, Node* parent = NULL );
void setAbsolutePath ( const std::string filePath ); void setAbsolutePath ( const std::string filePath );
// Slicingtree related XML methods.
void readSlicingTree ( xmlNode* );
SlicingNode* readSlicingNode ( xmlNode* xnode, SlicingNode* slicingNode = NULL );
VSlicingNode* createVerticalSlicingNode ( xmlNode* xnode, SlicingNode* slicingNode = NULL );
HSlicingNode* createHorizontalSlicingNode ( xmlNode* xnode, SlicingNode* slicingNode = NULL );
DSlicingNode* createDeviceSlicingNode ( xmlNode* xnode, SlicingNode* slicingNode = NULL );
RSlicingNode* createRoutingSlicingNode ( xmlNode* xnode, SlicingNode* slicingNode = NULL );
void addChildren ( xmlNode*, HVSlicingNode* );
void setHVParameters ( xmlNode*, HVSlicingNode* );
void setHVSymmetries ( xmlNode*, HVSlicingNode* );
// Utilities methods. // Utilities methods.
void check_uppercase ( std::string& str, std::vector<std::string>& compares, std::string message ); void check_uppercase ( std::string& str, std::vector<std::string>& compares, std::string message );
void check_lowercase ( std::string& str, std::vector<std::string>& compares, std::string message ); void check_lowercase ( std::string& str, std::vector<std::string>& compares, std::string message );
@ -127,6 +143,7 @@ namespace OpenChams {
Layout* _layout; Layout* _layout;
std::vector<std::string> _subCircuitsPaths; std::vector<std::string> _subCircuitsPaths;
std::map<unsigned, SimulModel*> _simulModels; std::map<unsigned, SimulModel*> _simulModels;
SlicingNode* _slicingtree;
}; };
@ -142,7 +159,7 @@ namespace OpenChams {
inline Parameters Circuit::getParameters () { return _params; } inline Parameters Circuit::getParameters () { return _params; }
inline void Circuit::addSubCircuitPath (std::string path) { _subCircuitsPaths.push_back(path); } inline void Circuit::addSubCircuitPath (std::string path) { _subCircuitsPaths.push_back(path); }
inline std::vector<std::string>& Circuit::getSubCircuitPaths () { return _subCircuitsPaths; } inline std::vector<std::string>& Circuit::getSubCircuitPaths () { return _subCircuitsPaths; }
inline SlicingNode* Circuit::getSlicingTree () { return _slicingtree; }
template<typename T> template<typename T>
inline std::string asString ( T value ) inline std::string asString ( T value )

View File

@ -0,0 +1,392 @@
// -*- C++ -*-
//
// This file is part of the VLSI SAPD Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | V L S I S A P D |
// | OpenChams Circuit Data Base |
// | |
// | Author : Eric Lao |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./vlsisapd/openChams/SlicingTree.h" |
// +-----------------------------------------------------------------+
#ifndef __OPENCHAMS_SLICINGTREE_H__
#define __OPENCHAMS_SLICINGTREE_H__
#include <vector>
#include <list>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
namespace OpenChams {
enum Flags { UnknownType = 1 << 0
, HorizontalSNode = 1 << 1
, VerticalSNode = 1 << 2
, DeviceSNode = 1 << 3
, RoutingSNode = 1 << 4
, UnknownAlignment = 1 << 5
, AlignLeft = 1 << 6
, AlignRight = 1 << 7
, AlignCenter = 1 << 8
, AlignTop = 1 << 9
, AlignBottom = 1 << 10
};
// -----------------------------------------------------------------------------------------------//
// Class : SlicingNode
// -----------------------------------------------------------------------------------------------//
class SlicingNode
{
public:
SlicingNode( SlicingNode* parent = NULL );
virtual ~SlicingNode(){};
public:
virtual unsigned int getType () const { return UnknownType; }
virtual void print () const {};
inline void recursiveDestroy ();
void setParent ( SlicingNode* parent );
SlicingNode* getParent () const;
inline bool isRoot () const;
virtual void setAlignment ( std::string alignment );
std::string alignmentToString() const;
//Error Methods
virtual std::string getInstanceName () const;
virtual unsigned int getAlignment () const;
virtual bool getPreset () const;
virtual double getX () const;
virtual double getY () const;
virtual int getNFing () const;
virtual double getStart () const;
virtual double getStep () const;
virtual double getCount () const;
virtual void setInstanceName ( std::string instanceName );
virtual void setPreset ( std::string preset );
virtual void setX ( std::string x );
virtual void setY ( std::string y );
virtual void setNFing ( std::string nfing );
virtual void setStart ( std::string start );
virtual void setStep ( std::string step );
virtual void setCount ( std::string count );
virtual void setPreset ( bool preset );
virtual void setX ( double x );
virtual void setY ( double y );
virtual void setNFing ( int nfing );
virtual void setStart ( double start );
virtual void setStep ( double step );
virtual void setCount ( double count );
virtual const std::vector<SlicingNode*> getChildren () const;
virtual std::list<std::pair <int,int> > getSymmetries () const;
virtual double getToleranceRatioH() const;
virtual double getToleranceRatioW() const;
virtual double getToleranceBandH () const;
virtual double getToleranceBandW () const;
virtual void setToleranceRatioH( std::string value );
virtual void setToleranceRatioW( std::string value );
virtual void setToleranceBandH ( std::string value );
virtual void setToleranceBandW ( std::string value );
virtual void setToleranceRatioH( double value );
virtual void setToleranceRatioW( double value );
virtual void setToleranceBandH ( double value );
virtual void setToleranceBandW ( double value );
virtual void push_back ( SlicingNode* node );
virtual void addSymmetry ( std::string source, std::string target );
virtual void addSymmetry ( int source, int target );
virtual double getValue () const;
virtual void setValue ( std::string value );
virtual void toXML ( std::ofstream& file, unsigned indent ){};
virtual std::string presetToString () const;
virtual std::string xToString () const;
virtual std::string yToString () const;
virtual std::string nfingToString () const;
virtual std::string startToString () const;
virtual std::string stepToString () const;
virtual std::string countToString () const;
virtual std::string valueToString () const;
virtual std::string toleranceRatioHToString() const;
virtual std::string toleranceRatioWToString() const;
virtual std::string toleranceBandHToString () const;
virtual std::string toleranceBandWToString () const;
virtual bool hasSameParentToleranceRatioH () const;
virtual bool hasSameParentToleranceRatioW () const;
virtual bool hasSameParentToleranceBandH () const;
virtual bool hasSameParentToleranceBandW () const;
virtual bool checkInitialPlacement( int& cpt ) const;
virtual std::list<SlicingNode*> getLeaves () const;
protected:
SlicingNode* _parent;
unsigned int _alignment;
};
inline void SlicingNode::recursiveDestroy(){ delete(this); }
inline bool SlicingNode::isRoot () const { return (_parent == NULL); }
// -----------------------------------------------------------------------------------------------//
// Class : DeviceSNode
// -----------------------------------------------------------------------------------------------//
class DSlicingNode : public SlicingNode
{
private:
DSlicingNode( std::string instanceName, SlicingNode* parent = NULL );
~DSlicingNode(){};
public:
inline static DSlicingNode* create ( std::string instanceName, SlicingNode* parent = NULL );
inline std::string getInstanceName () const;
inline unsigned int getAlignment () const;
inline bool getPreset () const;
inline double getX () const;
inline double getY () const;
inline int getNFing () const;
inline double getStart () const;
inline double getStep () const;
inline double getCount () const;
inline unsigned int getType () const;
void setInstanceName ( std::string instanceName );
void setPreset ( std::string preset );
void setX ( std::string x );
void setY ( std::string y );
void setNFing ( std::string nfing );
void setStart ( std::string start );
void setStep ( std::string step );
void setCount ( std::string count );
inline void setPreset ( bool preset );
inline void setX ( double x );
inline void setY ( double y );
inline void setNFing ( int nfing );
inline void setStart ( double start );
inline void setStep ( double step );
inline void setCount ( double count );
void print () const;
void toXML ( std::ofstream& file, unsigned indent );
inline std::string presetToString () const;
inline std::string xToString () const;
inline std::string yToString () const;
inline std::string nfingToString () const;
inline std::string startToString () const;
inline std::string stepToString () const;
inline std::string countToString () const;
bool checkInitialPlacement ( int& cpt ) const;
private:
std::string _instanceName;
bool _preset;
double _x;
double _y;
int _nfing;
double _start;
double _step;
double _count;
};
inline DSlicingNode* DSlicingNode::create ( std::string instanceName, SlicingNode* parent ){ return new DSlicingNode( instanceName ); }
inline std::string DSlicingNode::getInstanceName () const { return _instanceName ; }
inline unsigned int DSlicingNode::getAlignment () const { return _alignment ; }
inline bool DSlicingNode::getPreset () const { return _preset ; }
inline double DSlicingNode::getX () const { return _x ; }
inline double DSlicingNode::getY () const { return _y ; }
inline int DSlicingNode::getNFing () const { return _nfing ; }
inline double DSlicingNode::getStart () const { return _start ; }
inline double DSlicingNode::getStep () const { return _step ; }
inline double DSlicingNode::getCount () const { return _count ; }
inline unsigned int DSlicingNode::getType () const { return DeviceSNode ; }
inline void DSlicingNode::setPreset ( bool preset ) { _preset = preset; }
inline void DSlicingNode::setX ( double x ) { _x = x ; }
inline void DSlicingNode::setY ( double y ) { _y = y ; }
inline void DSlicingNode::setNFing ( int nfing ) { _nfing = nfing ; }
inline void DSlicingNode::setStart ( double start ) { _start = start ; }
inline void DSlicingNode::setStep ( double step ) { _step = step ; }
inline void DSlicingNode::setCount ( double count ) { _count = count ; }
inline std::string DSlicingNode::presetToString () const { return _preset ? "true" : "false"; }
inline std::string DSlicingNode::xToString () const { return std::to_string(_x ); }
inline std::string DSlicingNode::yToString () const { return std::to_string(_y ); }
inline std::string DSlicingNode::nfingToString () const { return std::to_string(_nfing); }
inline std::string DSlicingNode::startToString () const { return std::to_string(_start); }
inline std::string DSlicingNode::stepToString () const { return std::to_string(_step ); }
inline std::string DSlicingNode::countToString () const { return std::to_string(_count); }
// -----------------------------------------------------------------------------------------------//
// Class : HVSlicingNode
// -----------------------------------------------------------------------------------------------//
class HVSlicingNode : public SlicingNode
{
protected:
HVSlicingNode( SlicingNode* parent = NULL );
virtual ~HVSlicingNode(){};
public:
inline unsigned int getAlignment () const;
inline double getToleranceRatioH() const;
inline double getToleranceRatioW() const;
inline double getToleranceBandH () const;
inline double getToleranceBandW () const;
inline const std::vector<SlicingNode*> getChildren () const;
inline std::list<std::pair <int,int> > getSymmetries () const;
void setToleranceRatioH( std::string value );
void setToleranceRatioW( std::string value );
void setToleranceBandH ( std::string value );
void setToleranceBandW ( std::string value );
void setToleranceRatioH( double value );
void setToleranceRatioW( double value );
void setToleranceBandH ( double value );
void setToleranceBandW ( double value );
void push_back ( SlicingNode* node );
void addSymmetry ( std::string source, std::string target );
void addSymmetry ( int source, int target );
void recursiveDestroy ();
void print () const;
inline std::string toleranceRatioHToString () const;
inline std::string toleranceRatioWToString () const;
inline std::string toleranceBandHToString () const;
inline std::string toleranceBandWToString () const;
bool hasSameParentToleranceRatioH () const;
bool hasSameParentToleranceRatioW () const;
bool hasSameParentToleranceBandH () const;
bool hasSameParentToleranceBandW () const;
bool checkInitialPlacement ( int& cpt ) const;
std::list<SlicingNode*> getLeaves () const;
protected:
double _toleranceRatioH;
double _toleranceRatioW;
double _toleranceBandH;
double _toleranceBandW;
std::list<std::pair <int,int> > _symmetries;
std::vector<SlicingNode*> _children;
};
inline unsigned int HVSlicingNode::getAlignment () const { return _alignment ; }
inline double HVSlicingNode::getToleranceRatioH() const { return _toleranceRatioH; }
inline double HVSlicingNode::getToleranceRatioW() const { return _toleranceRatioW; }
inline double HVSlicingNode::getToleranceBandH () const { return _toleranceBandH ; }
inline double HVSlicingNode::getToleranceBandW () const { return _toleranceBandW ; }
inline const std::vector<SlicingNode*> HVSlicingNode::getChildren () const { return _children ; }
inline std::list<std::pair<int,int> > HVSlicingNode::getSymmetries () const { return _symmetries ; }
inline std::string HVSlicingNode::toleranceRatioHToString() const { return std::to_string(_toleranceRatioH); }
inline std::string HVSlicingNode::toleranceRatioWToString() const { return std::to_string(_toleranceRatioW); }
inline std::string HVSlicingNode::toleranceBandHToString () const { return std::to_string(_toleranceBandH); }
inline std::string HVSlicingNode::toleranceBandWToString () const { return std::to_string(_toleranceBandW); }
// -----------------------------------------------------------------------------------------------//
// Class : HSlicingNode
// -----------------------------------------------------------------------------------------------//
class HSlicingNode: public HVSlicingNode
{
private:
HSlicingNode( SlicingNode* parent = NULL );
~HSlicingNode(){};
public:
inline static HSlicingNode* create ( SlicingNode* parent = NULL );
inline unsigned int getType () const;
void print () const;
void toXML ( std::ofstream& file, unsigned indent );
};
inline HSlicingNode* HSlicingNode::create ( SlicingNode* parent ){ return new HSlicingNode(parent); }
inline unsigned int HSlicingNode::getType() const { return HorizontalSNode ; }
// -----------------------------------------------------------------------------------------------//
// Class : VSlicingNode
// -----------------------------------------------------------------------------------------------//
class VSlicingNode: public HVSlicingNode
{
private:
VSlicingNode( SlicingNode* parent = NULL );
~VSlicingNode(){};
public:
inline static VSlicingNode* create ( SlicingNode* parent = NULL );
inline unsigned int getType () const;
void print () const;
void toXML ( std::ofstream& file, unsigned indent );
};
inline VSlicingNode* VSlicingNode::create ( SlicingNode* parent ){ return new VSlicingNode(parent); }
inline unsigned int VSlicingNode::getType() const { return VerticalSNode ; }
// -----------------------------------------------------------------------------------------------//
// Class : RoutingSNode
// -----------------------------------------------------------------------------------------------//
class RSlicingNode: public SlicingNode
{
private:
RSlicingNode( std::string value, SlicingNode* parent = NULL );
RSlicingNode( double value, SlicingNode* parent = NULL );
~RSlicingNode(){};
public:
inline static RSlicingNode* create ( std::string value, SlicingNode* parent = NULL );
inline static RSlicingNode* create ( double value, SlicingNode* parent = NULL );
inline void recursiveDestroy ();
inline double getValue () const;
void setValue ( std::string value );
inline unsigned int getType () const;
void print () const;
void setAlignment ( std::string alignment) {};
void toXML ( std::ofstream& file, unsigned indent );
inline std::string valueToString () const;
private:
double _value;
};
inline RSlicingNode* RSlicingNode::create ( std::string value, SlicingNode* parent ){ return new RSlicingNode( value, parent ); }
inline RSlicingNode* RSlicingNode::create ( double value, SlicingNode* parent ){ return new RSlicingNode( value, parent ); }
inline double RSlicingNode::getValue () const{ return _value ; }
inline unsigned int RSlicingNode::getType () const{ return RoutingSNode; }
inline std::string RSlicingNode::valueToString () const { return std::to_string(_value); }
} // OpenChams namespace
#endif