252 int i, nPis, nPos, nRegs, Number;
253 int * pNum2Id = NULL;
255 pFile = fopen( pFileName,
"r" );
258 printf(
"Saig_ManReadBlif(): Cannot open file for reading.\n" );
263 if ( pToken == NULL )
264 { printf(
"Saig_ManReadBlif(): Error 1.\n" );
return NULL; }
267 if ( pToken == NULL )
268 { printf(
"Saig_ManReadBlif(): Error 2.\n" );
return NULL; }
275 if ( pToken == NULL ||
strcmp( pToken,
".inputs" ) )
276 { printf(
"Saig_ManReadBlif(): Error 3.\n" );
Aig_ManStop(p);
return NULL; }
277 for ( nPis = 0; (pToken =
Saig_ManReadToken( pFile )) && pToken[0] !=
'.'; nPis++ );
279 if ( pToken == NULL ||
strcmp( pToken,
".outputs" ) )
280 { printf(
"Saig_ManReadBlif(): Error 4.\n" );
Aig_ManStop(p);
return NULL; }
281 for ( nPos = 0; (pToken =
Saig_ManReadToken( pFile )) && pToken[0] !=
'.'; nPos++ );
283 if ( pToken == NULL )
284 { printf(
"Saig_ManReadBlif(): Error 5.\n" );
Aig_ManStop(p);
return NULL; }
285 for ( nRegs = 0;
strcmp( pToken,
".latch" ) == 0; nRegs++ )
288 if ( pToken == NULL )
289 { printf(
"Saig_ManReadBlif(): Error 6.\n" );
Aig_ManStop(p);
return NULL; }
291 if ( pToken == NULL )
292 { printf(
"Saig_ManReadBlif(): Error 7.\n" );
Aig_ManStop(p);
return NULL; }
294 if ( pToken == NULL )
295 { printf(
"Saig_ManReadBlif(): Error 8.\n" );
Aig_ManStop(p);
return NULL; }
297 if ( pToken == NULL )
298 { printf(
"Saig_ManReadBlif(): Error 9.\n" );
Aig_ManStop(p);
return NULL; }
301 for ( i = 0; i < nPis + nRegs; i++ )
305 for ( i = 0;
strcmp( pToken,
".names" ) == 0; i++ )
309 if ( i == 0 && pToken[0] ==
'n' )
313 if ( pToken == NULL ||
strcmp( pToken,
"1" ) )
314 { printf(
"Saig_ManReadBlif(): Error 10.\n" );
Aig_ManStop(p);
return NULL; }
317 if ( pToken == NULL )
318 { printf(
"Saig_ManReadBlif(): Error 11.\n" );
Aig_ManStop(p);
return NULL; }
325 if ( (pToken[0] ==
'p' && pToken[1] ==
'o') || (pToken[0] ==
'l' && pToken[1] ==
'i') )
329 if ( pToken == NULL )
330 { printf(
"Saig_ManReadBlif(): Error 12.\n" );
Aig_ManStop(p);
return NULL; }
331 if ( pToken[0] ==
'0' )
335 if ( pToken == NULL ||
strcmp( pToken,
"1" ) )
336 { printf(
"Saig_ManReadBlif(): Error 13.\n" );
Aig_ManStop(p);
return NULL; }
340 if ( pToken == NULL )
341 { printf(
"Saig_ManReadBlif(): Error 14.\n" );
Aig_ManStop(p);
return NULL; }
351 if ( pNum2Id == NULL )
354 int Size = (int)pow(10.0, (
double)(
strlen(pToken) - 1));
361 if ( pToken == NULL )
362 { printf(
"Saig_ManReadBlif(): Error 15.\n" );
Aig_ManStop(p);
return NULL; }
363 if ( pToken[0] ==
'0' )
365 if ( pToken[1] ==
'0' )
369 if ( pToken == NULL ||
strcmp( pToken,
"1" ) )
370 { printf(
"Saig_ManReadBlif(): Error 16.\n" );
Aig_ManStop(p);
return NULL; }
373 if ( pToken == NULL )
374 { printf(
"Saig_ManReadBlif(): Error 17.\n" );
Aig_ManStop(p);
return NULL; }
377 pNode =
Aig_And( p, pFanin0, pFanin1 );
379 { printf(
"Saig_ManReadBlif(): Error 18.\n" );
Aig_ManStop(p);
return NULL; }
381 pNum2Id[ Number ] = pNode->
Id;
383 if ( pToken == NULL ||
strcmp( pToken,
".end" ) )
384 { printf(
"Saig_ManReadBlif(): Error 19.\n" );
Aig_ManStop(p);
return NULL; }
386 { printf(
"Saig_ManReadBlif(): Error 20.\n" );
Aig_ManStop(p);
return NULL; }
389 pNum2Id[pNode->Id] = pNode->Id;
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
void Aig_ManStop(Aig_Man_t *p)
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
char * Saig_ManReadToken(FILE *pFile)
int Saig_ManReadNumber(Aig_Man_t *p, char *pToken)
static int Aig_IsComplement(Aig_Obj_t *p)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
static int Aig_ManCoNum(Aig_Man_t *p)
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Aig_Obj_t * Saig_ManReadNode(Aig_Man_t *p, int *pNum2Id, char *pToken)
#define ABC_CALLOC(type, num)
Aig_Man_t * Saig_ManReadBlif(char *pFileName)
char * Abc_UtilStrsav(char *s)