21#ifndef ABC__scl_Con__h
22#define ABC__scl_Con__h
52#define SCL_INPUT_CELL "input_cell"
53#define SCL_INPUT_ARR "input_arrival"
54#define SCL_INPUT_SLEW "input_slew"
55#define SCL_INPUT_LOAD "input_load"
56#define SCL_OUTPUT_REQ "output_required"
57#define SCL_OUTPUT_LOAD "output_load"
59#define SCL_DIRECTIVE(ITEM) "."#ITEM
60#define SCL_DEF_DIRECTIVE(ITEM) ".default_"#ITEM
63#define SCL_INFINITY (0x3FFFFFFF)
65static inline int Scl_Flt2Int(
float w ) {
return SCL_NUM*w; }
66static inline float Scl_Int2Flt(
int i ) {
return (
float)i/
SCL_NUM; }
86 p->pFileName = Abc_UtilStrsav( pFileName );
104static inline void Scl_ConFree(
Scl_Con_t *
p )
106 Vec_PtrErase( &
p->vInCellsPtr );
107 Vec_PtrFreeData( &
p->vInCells );
108 Vec_PtrErase( &
p->vInCells );
109 Vec_IntErase( &
p->vInArrs );
110 Vec_IntErase( &
p->vInSlews );
111 Vec_IntErase( &
p->vInLoads );
112 Vec_IntErase( &
p->vOutReqs );
113 Vec_IntErase( &
p->vOutLoads );
137 char * pToken, * pToken2, * pToken3, * pName;
138 int i, Num = -1, nLines = 0;
int Value;
139 FILE * pFile = fopen(
p->pFileName,
"rb" );
140 while ( fgets( Buffer, 1000, pFile ) )
143 pToken =
strtok( Buffer,
" \t\r\n" );
144 if ( pToken == NULL )
146 pToken2 =
strtok( NULL,
" \t\r\n" );
147 if ( pToken2 == NULL )
149 printf(
"Line %d: Skipping directive \"%s\" without argument.\n", nLines, pToken );
152 pToken3 =
strtok( NULL,
" \t\r\n" );
153 if ( !
strcmp(pToken,
".model") )
p->pModelName = Abc_UtilStrsav(pToken2);
160 else if ( pToken3 == NULL ) { printf(
"Directive %s should be followed by two arguments.\n", pToken );
continue; }
161 else if ( !
strcmp(pToken,
SCL_DIRECTIVE(
SCL_INPUT_CELL)) )
if ( (Num =
Abc_NamStrFind(pNamI, pToken2)) > 0 ) Vec_PtrWriteEntry( &
p->vInCells, Num-1, Abc_UtilStrsav(pToken3) );
else printf(
"Line %d: Cannot find input \"%s\".\n", nLines, pToken2 );
167 else printf(
"Line %d: Skipping unrecognized directive \"%s\".\n", nLines, pToken );
170 if (
p->pInCellDef == NULL )
p->pInCellDef = NULL;
178 Vec_PtrForEachEntry(
char *, &
p->vInCells, pName, i)
if ( pName == NULL ) Vec_PtrWriteEntry( &
p->vInCells, i, Abc_UtilStrsav(
p->pInCellDef) );
190 Scl_Con_t *
p = Scl_ConAlloc( pFileName, pNamI, pNamO );
191 if ( Scl_ConParse(
p, pNamI, pNamO) )
196static inline void Scl_ConWrite(
Scl_Con_t *
p,
char * pFileName )
198 char * pName;
int Value;
int i;
199 FILE * pFile = pFileName ? fopen( pFileName,
"wb" ) : stdout;
202 printf(
"Cannot open output file \"%s\".\n", pFileName );
205 fprintf( pFile,
".model %s\n",
p->pModelName );
207 if (
p->pInCellDef ) fprintf( pFile,
".default_%s %s\n",
SCL_INPUT_CELL,
p->pInCellDef );
208 if (
p->tInArrDef != 0 ) fprintf( pFile,
".default_%s %.2f\n",
SCL_INPUT_ARR, Scl_Int2Flt(
p->tInArrDef) );
209 if (
p->tInSlewDef != 0 ) fprintf( pFile,
".default_%s %.2f\n",
SCL_INPUT_SLEW, Scl_Int2Flt(
p->tInSlewDef) );
210 if (
p->tInLoadDef != 0 ) fprintf( pFile,
".default_%s %.2f\n",
SCL_INPUT_LOAD, Scl_Int2Flt(
p->tInLoadDef) );
211 if (
p->tOutReqDef != 0 ) fprintf( pFile,
".default_%s %.2f\n",
SCL_OUTPUT_REQ, Scl_Int2Flt(
p->tOutReqDef) );
212 if (
p->tOutLoadDef != 0 ) fprintf( pFile,
".default_%s %.2f\n",
SCL_OUTPUT_LOAD, Scl_Int2Flt(
p->tOutLoadDef) );
221 if ( pFile != stdout )
236static inline int Scl_ConHasInCells_(
Scl_Con_t *
p ) {
return Vec_PtrCountZero(&
p->vInCells) != Vec_PtrSize(&
p->vInCells); }
237static inline int Scl_ConHasInArrs_(
Scl_Con_t *
p ) {
return Vec_IntCountZero(&
p->vInArrs) != Vec_IntSize(&
p->vInArrs); }
238static inline int Scl_ConHasInSlews_(
Scl_Con_t *
p ) {
return Vec_IntCountZero(&
p->vInSlews) != Vec_IntSize(&
p->vInSlews); }
239static inline int Scl_ConHasInLoads_(
Scl_Con_t *
p ) {
return Vec_IntCountZero(&
p->vInLoads) != Vec_IntSize(&
p->vInLoads); }
240static inline int Scl_ConHasOutReqs_(
Scl_Con_t *
p ) {
return Vec_IntCountZero(&
p->vOutReqs) != Vec_IntSize(&
p->vOutReqs); }
241static inline int Scl_ConHasOutLoads_(
Scl_Con_t *
p ) {
return Vec_IntCountZero(&
p->vOutLoads) != Vec_IntSize(&
p->vOutLoads); }
243static inline char * Scl_ConGetInCell_(
Scl_Con_t *
p,
int i ) {
return (
char*)Vec_PtrEntry( &
p->vInCells, i ); }
244static inline int Scl_ConGetInArr_(
Scl_Con_t *
p,
int i ) {
return Vec_IntEntry( &
p->vInArrs, i ); }
245static inline int Scl_ConGetInSlew_(
Scl_Con_t *
p,
int i ) {
return Vec_IntEntry( &
p->vInSlews, i ); }
246static inline int Scl_ConGetInLoad_(
Scl_Con_t *
p,
int i ) {
return Vec_IntEntry( &
p->vInLoads, i ); }
247static inline int Scl_ConGetOutReq_(
Scl_Con_t *
p,
int i ) {
return Vec_IntEntry( &
p->vOutReqs, i ); }
248static inline int Scl_ConGetOutLoad_(
Scl_Con_t *
p,
int i ) {
return Vec_IntEntry( &
p->vOutLoads, i ); }
263static inline int Scl_ConIsRunning() {
return Scl_ConReadMan() != NULL; }
265static inline int Scl_ConHasInCells() {
return Scl_ConHasInCells_ (
Scl_ConReadMan() ); }
266static inline int Scl_ConHasInArrs() {
return Scl_ConHasInArrs_ (
Scl_ConReadMan() ); }
267static inline int Scl_ConHasInSlews() {
return Scl_ConHasInSlews_ (
Scl_ConReadMan() ); }
268static inline int Scl_ConHasInLoads() {
return Scl_ConHasInLoads_ (
Scl_ConReadMan() ); }
269static inline int Scl_ConHasOutReqs() {
return Scl_ConHasOutReqs_ (
Scl_ConReadMan() ); }
270static inline int Scl_ConHasOutLoads() {
return Scl_ConHasOutLoads_(
Scl_ConReadMan() ); }
272static inline char * Scl_ConGetInCell(
int i ) {
return Scl_ConGetInCell_ (
Scl_ConReadMan(), i ); }
273static inline int Scl_ConGetInArr(
int i ) {
return Scl_ConGetInArr_ (
Scl_ConReadMan(), i ); }
274static inline int Scl_ConGetInSlew(
int i ) {
return Scl_ConGetInSlew_ (
Scl_ConReadMan(), i ); }
275static inline int Scl_ConGetInLoad(
int i ) {
return Scl_ConGetInLoad_ (
Scl_ConReadMan(), i ); }
276static inline int Scl_ConGetOutReq(
int i ) {
return Scl_ConGetOutReq_ (
Scl_ConReadMan(), i ); }
277static inline int Scl_ConGetOutLoad(
int i ) {
return Scl_ConGetOutLoad_(
Scl_ConReadMan(), i ); }
279static inline float Scl_ConGetInArrFloat(
int i ) {
return Scl_Int2Flt( Scl_ConGetInArr(i) ); }
280static inline float Scl_ConGetInSlewFloat(
int i ) {
return Scl_Int2Flt( Scl_ConGetInSlew(i) ); }
281static inline float Scl_ConGetInLoadFloat(
int i ) {
return Scl_Int2Flt( Scl_ConGetInLoad(i) ); }
282static inline float Scl_ConGetOutReqFloat(
int i ) {
return Scl_Int2Flt( Scl_ConGetOutReq(i) ); }
283static inline float Scl_ConGetOutLoadFloat(
int i ) {
return Scl_Int2Flt( Scl_ConGetOutLoad(i) ); }
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Scl_Con_t_ Scl_Con_t
DECLARATIONS ///.
Scl_Con_t * Scl_ConReadMan()
#define SCL_DEF_DIRECTIVE(ITEM)
#define SCL_DIRECTIVE(ITEM)
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
int Abc_NamObjNumMax(Abc_Nam_t *p)
void Abc_NamDeref(Abc_Nam_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.