remove old dtr parser

use new techno
This commit is contained in:
Christophe Alexandre 2008-05-20 16:30:59 +00:00
parent 46cff23d7a
commit e2b58b2730
10 changed files with 3 additions and 1097 deletions

View File

@ -1,5 +1,4 @@
ADD_SUBDIRECTORY(dtr)
ADD_SUBDIRECTORY(technology)
ADD_SUBDIRECTORY(analogic)
ADD_SUBDIRECTORY(device)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(tests)

View File

@ -1,39 +0,0 @@
ADD_CUSTOM_TARGET(DTRParser echo "Creating DTRParser")
SET(source_dir ${CHAMSIN_SOURCE_DIR}/src/dtr)
SET(binary_dir ${CHAMSIN_BINARY_DIR}/src/dtr)
INCLUDE_DIRECTORIES(${HURRICANE_INCLUDE_DIR}
${CHAMSIN_SOURCE_DIR}/src/analogic ${source_dir})
ADD_CUSTOM_COMMAND(
SOURCE ${source_dir}/ParserDtrScan.ll
COMMAND ${FLEX_EXECUTABLE}
ARGS -Pdtr -o${binary_dir}/ParserDtrScan.cpp
${source_dir}/ParserDtrScan.ll
TARGET DTRParser
OUTPUTS ${binary_dir}/ParserDtrScan.cpp)
ADD_CUSTOM_COMMAND(
SOURCE ${source_dir}/ParserDtrGram.yy
COMMAND ${BISON_EXECUTABLE}
ARGS -d -v -p dtr -y ${source_dir}/ParserDtrGram.yy
-o ${binary_dir}/ParserDtrGram.cpp
TARGET DSTParser
DEPENDS ${binary_dir}/ParserDtrScan.cpp
OUTPUTS ${binary_dir}/ParserDtrGram.cpp)
SET(DST_SRCS ${DST_SRCS} ${binary_dir}/ParserDtrGram.cpp
${binary_dir}/ParserDtrScan.cpp)
SET_SOURCE_FILES_PROPERTIES(${binary_dir}/ParserDtrGram.cpp GENERATED)
SET_SOURCE_FILES_PROPERTIES(${binary_dir}/ParserDtrScan.cpp GENERATED)
ADD_LIBRARY(dtr SHARED
${DST_SRCS}
DtrAccess.cpp
RdsUnit.cpp)
TARGET_LINK_LIBRARIES(dtr ${HURRICANE_LIBRARIES})
INSTALL(TARGETS dtr DESTINATION /lib)

View File

@ -1,279 +0,0 @@
// ****************************************************************************************************
// File: DtrAccess.cpp
// Authors: Wu YiFei
// Date : 21/12/2006
// ****************************************************************************************************
#include "DataBase.h"
#include "Technology.h"
#include "BasicLayer.h"
#include "Error.h"
#include "RdsUnit.h"
#include "DtrAccess.h"
extern void ParseDtr(const char*, Hurricane::DtrAccess*);
namespace Hurricane {
// ****************************************************************************************************
// DtrAccess implementation
// ****************************************************************************************************
// static data defintion
// *********************
DtrAccess* DtrAccess::_singleton = NULL;
map<string, DtrAccess*> DtrAccess::_registry;
DtrAccess * DtrAccess::create() {
DtrAccess* dtraccess = new DtrAccess();
dtraccess->_postCreate();
return dtraccess;
}
void DtrAccess::_postCreate() {
const char* dtrFileName = getenv("DTR_FILE");
if(!dtrFileName) {
throw Error("Can't not get Macro DTR_FILE.");
}
// Use API of DtrParser for get technology informations
// ****************************************************
ParseDtr(dtrFileName, this);
// Traduit Micro to RdsUnit
// ************************
for (Label2RuleMap::iterator lrmit = _label2ruleMap.begin();
lrmit != _label2ruleMap.end();
++lrmit) {
for (list<double>::iterator ldit = lrmit->second.begin();
ldit != lrmit->second.end();
++ldit) {
_label2RdsRuleMap[lrmit->first].push_back(ConvertRealToRdsUnit(*ldit));
}
}
// get Objet Layer from Technology with its name.
// **********************************************
DataBase* db = getDataBase();
if(!db) {
throw Error("In getV1Trans::Generate : can't find DataBase.");
}
Technology* tech = db->getTechnology();
if (!tech) {
throw Error("In getV1Trans::Generate : can't find Technology.");
}
map<string, list<string> >::iterator it_layermap = _label2layerNameMap.begin(),
it_end_layermap = _label2layerNameMap.end();
while(it_layermap != it_end_layermap) {
list<string>::iterator m = (*it_layermap).second.begin(),
n = (*it_layermap).second.end();
while(m!=n) {
Layer * layer = tech->getLayer(Name(*m));
if(!layer) {
//throw Error("Error : in function DtrAccess::_postCreate , Can't find Layer "
// + getString(*m) + " in technology file when parser DtrFile.");
cerr << "In function DtrAccess::_postCreate , Can't find Layer " +
getString(*m) + " in technology file when parser DtrFile" << endl;
}
_label2layerMap[(*it_layermap).first].push_back(layer);
m++;
}
it_layermap++;
}
}
DtrAccess * DtrAccess::getDtrAccess() {
// User or environnement supplies this at startup
// **********************************************
const char * singleton_name = getenv("DTRACCESS_SINGLETON");
if(!singleton_name) { // if MACRO IS INVALID
if(!_singleton) {
_singleton = DtrAccess::create();
}
} else {
if(!_singleton){
if( !(_singleton=LookUp(string(singleton_name))) ) // if singleton hasn't been registered
_singleton = DtrAccess::create();
}
}
return _singleton;
}
GenericCollection<double> DtrAccess::getRuleByLabel(const string& label) const
// ***************************************************************************
{
map<string, list<double> >::const_iterator i = _label2ruleMap.find(label);
if(i==_label2ruleMap.end())
throw Error("Can't find in DtrFile rule the label : " + getString(label));
return getCollection((*i).second);
}
GenericCollection<long> DtrAccess::getRdsRuleByLabel(const string& label) const
// ******************************************************************************
{
map<string, list<long> >::const_iterator i = _label2RdsRuleMap.find(label);
if(i==_label2RdsRuleMap.end())
throw Error("Can't find in DtrFile The Rds Value of Rule by label : " + getString(label));
return getCollection((*i).second);
}
GenericCollection<string> DtrAccess::getLayerNamesByLabel(const string& label) const
// *********************************************************************************
{
map<string, list<string> >::const_iterator i = _label2layerNameMap.find(label);
if(i==_label2layerNameMap.end())
throw Error("Can't find in DtrFile layers the label : " + label);
return getCollection((*i).second);
}
GenericCollection<Layer*> DtrAccess::getLayersByLabel(const string& label) const
// ******************************************************************************
{
map<string, list<Layer*> >::const_iterator i = _label2layerMap.find(label);
if(i==_label2layerMap.end())
throw Error("Can't find in DtrFile objet Layer by label : " + label );
return getCollection((*i).second);
}
GenericCollection<double> DtrAccess::getElectricalsByLabel(const string& label) const
// **********************************************************************************
{
map<string, list<double> >::const_iterator i = _label2electricalMap.find(label);
if(i==_label2electricalMap.end())
throw Error("Can't find in DtrFile electricals by label : " + label);
return getCollection((*i).second);
}
int DtrAccess::getModellingByLabel(const string& label) const
// **********************************************************
{
map<string, int>::const_iterator i = _label2modellingMap.find(label);
if(i==_label2modellingMap.end())
throw Error("Can't find in DtrFile modelling by label : " + getString(label));
return (*i).second;
}
double DtrAccess::getSimpleCapaMimByLabel(const string& label) const
// ****************************************************************
{
map<string, double>::const_iterator i = _label2simplecapamimMap.find(label);
if(i==_label2simplecapamimMap.end())
throw Error("Can't find in DtrFile simple capa mim by label : " + getString(label));
return (*i).second;
}
// ------------------------------------------------------
// Function "DtrAccess::LookUp(const string&)".
//
/* \static DtrAccess* DtrAccess::LookUp(const string& singletonname)
* \param singletonname normally the name of derive class of DtrAccess.
* \return addresse of objet singleton of derive class if success.
* NULL if failure.
*
* Find the singleton objet if it exist according to the singletonname.
*
*/
DtrAccess* DtrAccess::LookUp(const string& singletonname)
// ******************************************************
{
map<string, DtrAccess*>::iterator i = _registry.find(singletonname);
if(i==_registry.end())
return NULL;
return (*i).second;
}
// ------------------------------------------------------------------------
// Function Register(const string&, DtrAccess*)
/* \void DtrAccess::Register(const string& singletonname, DtrAccess* dtraccess)
* \param singletonname the name of derive class.
* \param dtraccess addresse of objet singleton of derive class.
*
*
* This function is to be called when the singleton objet of derive class is
* created.
*
*/
void DtrAccess::Register(const string& singletonname, DtrAccess* dtraccess)
// *************************************************************************
{
_registry[singletonname]=dtraccess;
}
string DtrAccess::_getString() const
// **********************************
{
string s("Singleton DtrAccess");
return s;
}
Record* DtrAccess::_getRecord() const
// **********************************
{
Record* record = new Record(_getString());
return record;
}
}
// ****************************************************************************************************
// Generic functions
// ****************************************************************************************************
string getString(const Hurricane::DtrAccess& access)
// **********************************************
{
return access._getString();
}

View File

@ -1,165 +0,0 @@
// ****************************************************************************************************
// File: DtrAccess.h
// Authors: Wu YiFei
// Date : 21/12/2006
// ****************************************************************************************************
#ifndef HURRICANE_DTRACCESS
#define HURRICANE_DTRACCESS
#include "Layer.h"
#include "Layers.h"
namespace Hurricane {
class DtrAccess {
# if !defined(__DOXYGEN_PROCESSOR__)
// Attributes
// **********
private: typedef map<string, list<double> > Label2RuleMap;
private: static DtrAccess * _singleton;
private: Label2RuleMap _label2ruleMap;
private: map<string, list<string> > _label2layerNameMap;
private: map<string, list<double> > _label2electricalMap;
private: map<string, int> _label2modellingMap;
private: map<string, double> _label2simplecapamimMap;
private: map<string, list<long> > _label2RdsRuleMap;
private: map<string, list<Layer*> > _label2layerMap;
// For reusability of software
// ***************************
private : static map<string, DtrAccess*> _registry;
// Constructors
// ************
private : DtrAccess& operator=(const DtrAccess&);
protected : static DtrAccess * create();
protected : virtual void _postCreate();
# endif
public : static DtrAccess* getDtrAccess();
// Accessors
// *********
// If can't find data , throw Hurricane::Error
// *******************************************
public : GenericCollection<double> getRuleByLabel(const string&) const;
public : GenericCollection<long> getRdsRuleByLabel(const string&) const;
public : GenericCollection<string> getLayerNamesByLabel(const string&) const;
public : Layers getLayersByLabel(const string&) const;
public : GenericCollection<double> getElectricalsByLabel(const string& ) const;
public : int getModellingByLabel(const string&) const;
public : double getSimpleCapaMimByLabel(const string&) const;
# if !defined(__DOXYGEN_PROCESSOR__)
public : double getSingleRealRuleByLabel(const string& s) const
// *************************************************
{
GenericLocator<double> locator = getRuleByLabel(s).getLocator();
return locator.getElement();
}
public : long getSingleRdsRuleByLabel(const string& s) const
// ************************************************
{
GenericLocator<long> locator = getRdsRuleByLabel(s).getLocator();
return locator.getElement();
}
public : string getSingleLayerNameByLabel(const string& s) const
// ****************************************************
{
GenericLocator<string> locator = getLayerNamesByLabel(s).getLocator();
return locator.getElement();
}
public : Layer* getSingleLayerByLabel(const string& s) const
// ************************************************
{
LayerLocator locator = getLayersByLabel(s).getLocator();
return locator.getElement();
}
public : double getSingleRealRuleByLabel(char* prefix, const string& type, char* suffix) const
// **********************************************************************************
{
return getSingleRealRuleByLabel(prefix + type + suffix);
}
public : long getSingleRdsRuleByLabel(char* prefix, const string& type, char* suffix) const
// *******************************************************************************
{
return getSingleRdsRuleByLabel(prefix + type + suffix);
}
public : string getSingleLayerNameByLabel(char* prefix, const string& type, const string& suffix) const
// ************************************************************************************
{
return getSingleLayerNameByLabel(prefix + type + suffix);
}
public : Layer* getSingleLayerByLabel(char* prefix, const string& type, const string& suffix) const
// ***************************************************************************************
{
return getSingleLayerByLabel(prefix + type + suffix);
}
# endif
// Updators
// ********
public : void AddRuleByLabel(const string& label, const list<double>& rule){ _label2ruleMap[label]=rule; };
public : void AddLayersByLabel(const string& label, const list<string>& layers) { _label2layerNameMap[label]=layers; };
public : void AddElectricalsByLabel(const string& label, const list<double>& electricals)
{ _label2electricalMap[label]=electricals; };
public : void AddModellingByLabel(const string& label, const int modelling) { _label2modellingMap[label]=modelling; };
public : void AddSimpleCapaMimByLabel(const string& label, const double capamim) { _label2simplecapamimMap[label]=capamim; };
// Operations
// **********
// For reusability of software
// ***************************
protected : static DtrAccess* LookUp(const string&);
protected : static void Register(const string& , DtrAccess* );
# if !defined(__DOXYGEN_PROCESSOR__)
// Others
// ******
public: virtual string _getTypeName() const {return _TName("DtrAccess");};
public: virtual string _getString() const;
public: virtual Record* _getRecord() const;
public: map<string, list<double> >& _getLabel2RuleMap() { return _label2ruleMap; };
public: map<string, list<string> >& _getLabel2LayerNameMap() { return _label2layerNameMap; };
public: map<string, list<double> >& _getLabel2ElectricalMap()
{ return _label2electricalMap; };
public: map<string, int>& _getLabel2ModellingMap() { return _label2modellingMap; };
public: map<string, double>& _getLabel2SimpleCapaMimMap()
{ return _label2simplecapamimMap; };
#endif
};
}
// ****************************************************************************************************
// Generic functions
// ****************************************************************************************************
string getString(const Hurricane::DtrAccess&);
#endif // HURRICANE_DTRACCESS

View File

@ -1,72 +0,0 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
T_TABLE = 258,
T_TABLE_END = 259,
T_DOUBLE = 260,
T_ID = 261
};
#endif
/* Tokens. */
#define T_TABLE 258
#define T_TABLE_END 259
#define T_DOUBLE 260
#define T_ID 261
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 47 "/home/xtof/workspace/hurricane/src/analogic/ParserDtrGram.yy"
{ double _value;
char * _text;
}
/* Line 1489 of yacc.c. */
#line 65 "/home/xtof/workspace/hurricane/src/analogic/ParserDtrGram.hpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE dtrlval;

View File

@ -1,202 +0,0 @@
%{
#include <stdio.h>
#include <map>
#include <list>
#include <string>
#include "Error.h"
#include "DtrAccess.h"
using namespace Hurricane;
#include "ParserDtrGram.hpp"
extern FILE * dtrin;
extern int dtrlex(void);
extern char * dtrtext;
extern int DTRlineno;
// *************************************************************************
// Static Function&Data
// *************************************************************************
static int dtrerror( char * message)
// *********************************
{
char * str = (char*)malloc(200*sizeof(char));
sprintf(str, "ParserDtr():\n %s before %s at line %d.\n", message, dtrtext, DTRlineno);
string errmsg = str;
throw Error (errmsg);
return 0;
}
static DtrAccess * dtraccess = NULL;
static char* table_name = NULL;
static list<double> doubleList;
static list<string> stringList;
%}
%union { double _value;
char * _text;
};
%token T_TABLE T_TABLE_END T_DOUBLE T_ID
%type < _value > T_DOUBLE
%type < _text > T_ID
%start file
%%
file: lines tables
;
lines : '\n'
| lines '\n'
;
tables: table
|tables table
;
table: T_TABLE T_ID '\n'
{ table_name = $2; }
items T_TABLE_END lines
;
items: item
|items item
;
item: T_ID elems '\n'
{
string label = $1;
delete $1;
if( strcmp(table_name, "RULES")==0 ) {
if ( doubleList.empty() ) {
dtrerror("ParserDtr detect no data in a line of table RULES : Please check it");
}
list<double>::iterator i = doubleList.begin()
, j = doubleList.end();
while(i!=j) {
(dtraccess->_getLabel2RuleMap())[label].push_back(*i);
i++;
}
}
else if( strcmp(table_name, "LAYERS")==0 ) {
if ( stringList.empty() ) {
dtrerror("ParserDtr detect no data in a line of table LAYERS : Please check it");
}
list<string>::iterator i = stringList.begin()
, j = stringList.end();
while(i!=j) {
(dtraccess->_getLabel2LayerNameMap())[label].push_back(*i);;
i++;
}
}
else if( strcmp(table_name, "ELECTRICAL") == 0 ) {
if ( doubleList.empty() ) {
dtrerror("ParserDtr detect no data in a line of table ELECTRICAL : Please check it");
}
list<double>::iterator i = doubleList.begin()
, j = doubleList.end();
while(i!=j) {
(dtraccess->_getLabel2ElectricalMap())[label].push_back(*i);
i++;
}
}
else if( strcmp(table_name, "MODELLING") == 0 ) {
if ( (doubleList.empty()) || (doubleList.size()!=1) ) {
dtrerror("ParserDtr detect no data or mutli datas in a line of table MODELLING: Please check it");
}
list<double>::iterator i = doubleList.begin();
(dtraccess->_getLabel2ModellingMap())[label] = (int)(*i);
}
else if( strcmp(table_name, "SIMPLE_CAPA_MIM")==0 ) {
if( (doubleList.empty()) || (doubleList.size()!=1) ) {
dtrerror("ParserDtr detect no data or mutli datas in a line of table SIMPLE_CAPA_MIM : Please check it");
}
list<double>::iterator i = doubleList.begin();
(dtraccess->_getLabel2SimpleCapaMimMap())[label] = (*i);
}
else {
throw Error("ParserDtr detect unknown table name " + string(table_name));
}
// Vide temporary list
// ********************
doubleList.clear();
stringList.clear();
}
| lines
;
elems: elem
|elems elem
;
elem: T_ID
{
if(!(doubleList.empty())) {
dtrerror("ParserDtr detect incompatibles datas : Please check it");
}
stringList.push_back(string($1));
delete $1;
}
| T_DOUBLE
{
if(!(stringList.empty())) {
dtrerror("ParserDtr detect incompatibles datas : Please check it");
}
doubleList.push_back($1);
}
;
%%
// *************************************************************************
// Generic Function
// *************************************************************************
void ParseDtr(const char* dtrfilename, DtrAccess* dtr)
// ***************************************************
{
dtraccess = dtr;
if((dtrin=fopen(dtrfilename, "r"))==NULL)
{
throw Error("Can't open dtr file : " + string(dtrfilename));
}
dtrparse();
}

View File

@ -1,27 +0,0 @@
%{
#include <map>
#include <vector>
#include <iostream>
using namespace std;
#include "ParserDtrGram.hpp"
#define YY_NO_UNPUT
int DTRlineno = 1;
%}
%%
([ \t]+|#.*) {/* nothing to do */}
\n { DTRlineno++; return '\n'; }
TABLE_1DM { return T_TABLE;}
END_TABLE_1DM { return T_TABLE_END;}
[1-9]?[0-9]*(\.)?[0-9]+ { dtrlval._value=atof(dtrtext); return T_DOUBLE;}
[a-zA-Z0-9]+(_?[a-zA-Z0-9]+)* {dtrlval._text=strdup(dtrtext); return T_ID;}
. { return *dtrtext; }
%%
int dtrwrap() {return 1;}

View File

@ -1,255 +0,0 @@
// ****************************************************************************************************
// File: RdsUnit.cpp
// Authors: Wu YiFei
// Date : 21/12/2006
// ****************************************************************************************************
#include "Error.h"
#include "stdio.h"
#include "regex.h"
#include "math.h"
#include "Commons.h"
#include "RdsUnit.h"
// ****************************************************************************************************
// Static data&function
// ****************************************************************************************************
static long RDS_UNIT = -1;
static long RDS_PHYSICAL_GRID = 2;
static long RDS_LAMBDA = -1;
// -----------------------------------------------------------------------
// Function : "getPattern()".
/* \static char * getPattern (const string& str, const char* pattern)
* \param str the string to check for regex.
* \param pattern the pattern to find.
*
* get and return the march substring from str according to the pattern.
*
* \return NULL if Failure.
* \return the according substring if Success.
*/
static char* getPattern(const string& str, const char* pattern)
// ************************************************************
{
int err;
regex_t preg;
const char *str_request = str.c_str();
const char *str_regex = pattern;
/* (1) */
err = regcomp (&preg, str_regex, REG_EXTENDED);
if (err == 0)
{
int match;
size_t nmatch = 0;
regmatch_t *pmatch = NULL;
nmatch= 1;
pmatch = (regmatch_t*)malloc (sizeof (*pmatch) * nmatch);
if (pmatch)
{
/* (2) */
match = regexec (&preg, str_request, nmatch, pmatch, 0);
/* (3) */
regfree (&preg);
/* (4) */
if (match == 0)
{
char *site = NULL;
int start = pmatch[0].rm_so;
int end = pmatch[0].rm_eo;
size_t size = end - start;
site = (char*)malloc (sizeof (*site) * (size + 1));
if (site)
{
strncpy (site, &str_request[start], size);
site[size] = '\0';
return site;
}
else {
fprintf (stderr, "Memoire insuffisante\n");
exit (EXIT_FAILURE);
}
}
/* (5) */
else if (match == REG_NOMATCH)
{
printf ("%s doesn't accord to %s\n", str_request, str_regex);
return NULL;
}
/* (6) */
else
{
char *text;
size_t size;
/* (7) */
size = regerror (err, &preg, NULL, 0);
text = (char*)malloc (sizeof (*text) * size);
if (text)
{
/* (8) */
regerror (err, &preg, text, size);
fprintf (stderr, "%s\n", text);
free (text);
}
else
{
fprintf (stderr, "Memoire insuffisante\n");
}
exit (EXIT_FAILURE);
}
}
else
{
fprintf (stderr, "Memoire insuffisante\n");
exit (EXIT_FAILURE);
}
}
else {
fprintf (stderr, "Regcomp fail\n");
exit (EXIT_FAILURE);
}
}
// -------------------------------------------------------------------
// Function : "CalculateRdsUnit()".
/* static void CalculateRdsUnit()
*
* Open rds techno file who's name is MACRO RDS_TECHNO_FILE,
* and get values technology : rds_physical_grid, rds_lambda.
* Calculate the RDS_UNIT according to these values.
*
* If RDS_TECHNO_FILE is invalid or operaton of reading values technologys
* fail, a Hurricane Error will be throwed to explain the reason of failure.
*/
static void CalculateRdsUnit() {
using Hurricane::Error;
const char * rdsfilename = getenv("RDS_TECHNO_NAME");
FILE * rdstechnofile;
if(!rdsfilename) {
throw Error("Cannot find macro RDS_TECHNO_NAME");
}
if( !(rdstechnofile = fopen(rdsfilename, "r")) ) {
throw Error("Can't not open rds techno file : " + getString(rdsfilename));
}
char buffer[80]; // For stock a line of the rds techno file
double rds_physical_grid = -0.1; // For stock value of physical_grid
double rds_lambda = -0.1; // For stock value of lamba
while(fgets(buffer, 80, rdstechnofile )!=NULL){
string tmp = buffer;
if( tmp.find("define physical_grid")!=string::npos) { // Find the ligne begin with "define physical_grid"
string pattern;
if( (pattern = getPattern(tmp, "[[:digit:]\\.]+")).size()==0 ) { // get the value behind
throw Error("Can't get rds_physical_grid : getPattern(string&, char*) return NULL");
}
if(!Scan(pattern, rds_physical_grid)){ // Convert from string to double
throw Error("Can't get rds_physical_grid " + pattern + " : Hurricane::Scan(string&, double&) return false");
}
}
if( tmp.find("define lambda")!=string::npos ) {
string pattern;
if( (pattern = getPattern(tmp, "[[:digit:]\\.]+")).size()==0 ) {
throw Error("Can't get rds_lambda : getPattern(string&, char*) return NULL");
}
if(!Scan(pattern, rds_lambda)){
throw Error("Can't get rds_lambda " + pattern + " : Hurricane::Scan(string&, double&) return false");
}
}
// if rds_physical_grid and rds_lambda are finded, break the loop
// **************************************************************
if( (rds_physical_grid!=-0.1) && (rds_lambda!=-0.1) )
break;
} // end of while
if( (rds_physical_grid==-0.1) && (rds_lambda==-0.1) ) {
throw Error("Can't get rds_physical_grid and rds_lambda from rds techno file : \n" + string(rdsfilename));
}
long rds_physical_grid_nano = (long)rint(rds_physical_grid*(double)1000);
rds_physical_grid_nano = (long)rint( (double)1000/(double)rds_physical_grid_nano );
RDS_UNIT = rds_physical_grid_nano << 1;
long rds_lambda_nano = (long)rint( rds_lambda*(double)1000 );
RDS_LAMBDA = rds_lambda_nano * RDS_UNIT / 1000 ;
fclose(rdstechnofile);
}
namespace Hurricane {
// ****************************************************************************************************
// Utilitarians
// ****************************************************************************************************
const long& getRdsUnit()
// *********************
{
if ( RDS_UNIT == -1)
CalculateRdsUnit();
return RDS_UNIT;
}
const long& getRdsPhysicalGrid()
// *****************************
{
return RDS_PHYSICAL_GRID;
}
const long& getRdsLambda()
// ***********************
{
if ( RDS_LAMBDA == -1)
CalculateRdsUnit();
return RDS_LAMBDA;
}
}

View File

@ -1,54 +0,0 @@
// ****************************************************************************************************
// File: RdsUnit.h
// Authors: Wu YiFei
// Date : 21/12/2006
// ****************************************************************************************************
#ifndef HURRICANE_RDSUNIT
#define HURRICANE_RDSUNIT
#include <math.h>
//BEGIN_NAMESPACE_HURRICANE
namespace Hurricane {
// ****************************************************************************************************
// Utilitarians
// ****************************************************************************************************
extern const long& getRdsUnit();
extern const long& getRdsPhysicalGrid();
extern const long& getRdsLambda();
// ------------------------------------------------------------------------
// Function : "ConvertRealToRdsUnit(const double&)".
//
/* \inline long ConvertRealToRdsUnit(const double& value)
* \param value the value en Micro to convert to RdsUnit.
*
* Get and return the value en RdsUnit.
*
*/
inline long ConvertRealToRdsUnit(const double& value)
// *******************************************************
{
long tmp_value = (long)rint(value*getRdsUnit());
return (tmp_value%2)==0?tmp_value:(tmp_value+1);
}
//END_NAMESPACE_HURRICANE
}
#endif // HURRICANE_RDSUNIT

View File

@ -4,7 +4,7 @@
using namespace Hurricane;
#include "crlcore/GraphicsParser.h"
#include "crlcore/TechnologyParser.h"
#include "crlcore/SymbolicTechnologyParser.h"
using namespace CRL;
#include "ATechnology.h"
@ -18,7 +18,7 @@ void AEnv::create(const char* technoFilePath, const char* graphicFilePath, const
throw Error("");
}
db = DataBase::create();
TechnologyParser::load(db, technoFilePath);
SymbolicTechnologyParser::load(db, technoFilePath);
GraphicsParser::load(graphicFilePath);
Library* rootLibrary = Library::create(db, Name("RootLibrary"));