48 static char Buffer[16];
82 printf(
"Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
87 pFile = fopen( pFileName,
"w" );
90 printf(
"Saig_ManDumpBlif(): Cannot open file for writing.\n" );
93 fprintf( pFile,
"# BLIF file written by procedure Saig_ManDumpBlif()\n" );
94 fprintf( pFile,
"# If unedited, this file can be read by Saig_ManReadBlif()\n" );
95 fprintf( pFile,
"# AIG stats: pi=%d po=%d reg=%d and=%d obj=%d maxid=%d\n",
98 fprintf( pFile,
".model %s\n", p->pName );
100 fprintf( pFile,
".inputs" );
103 fprintf( pFile,
"\n" );
105 fprintf( pFile,
".outputs" );
108 fprintf( pFile,
"\n" );
114 fprintf( pFile,
".latch" );
117 fprintf( pFile,
" 0\n" );
126 fprintf( pFile,
".names" );
135 fprintf( pFile,
".names" );
140 fprintf( pFile,
".end\n" );
157 static char Buffer[1000];
158 if ( fscanf( pFile,
"%s", Buffer ) == 1 )
176 if ( pToken[0] ==
'n' )
177 return atoi( pToken + 1 );
178 if ( pToken[0] ==
'p' )
179 return atoi( pToken + 2 );
180 if ( pToken[0] ==
'l' )
181 return atoi( pToken + 2 );
200 if ( pToken[0] ==
'n' )
202 Num = atoi( pToken + 1 );
205 if ( pToken[0] ==
'p' )
208 if ( pToken[0] ==
'i' )
210 Num = atoi( pToken + 1 );
213 if ( pToken[0] ==
'o' )
218 if ( pToken[0] ==
'l' )
221 if ( pToken[0] ==
'o' )
223 Num = atoi( pToken + 1 );
226 if ( pToken[0] ==
'i' )
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;
395 printf(
"Saig_ManReadBlif(): Check has failed.\n" );
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
static int Saig_ManPoNum(Aig_Man_t *p)
static int Saig_ObjIsLo(Aig_Man_t *p, Aig_Obj_t *pObj)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
void Aig_ManStop(Aig_Man_t *p)
static int Aig_ManObjNum(Aig_Man_t *p)
static Aig_Obj_t * Saig_ManLo(Aig_Man_t *p, int i)
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
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 ///.
#define Aig_ManForEachCo(p, pObj, i)
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
ABC_NAMESPACE_IMPL_START char * Saig_ObjName(Aig_Man_t *p, Aig_Obj_t *pObj)
DECLARATIONS ///.
static int Aig_ManNodeNum(Aig_Man_t *p)
static int Saig_ObjIsLi(Aig_Man_t *p, Aig_Obj_t *pObj)
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
static int Aig_ManCoNum(Aig_Man_t *p)
#define Aig_ManForEachNode(p, pObj, i)
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
static int Abc_Base10Log(unsigned n)
static int Saig_ObjIsPo(Aig_Man_t *p, Aig_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
void Aig_ManSetCioIds(Aig_Man_t *p)
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
static int Saig_ManRegNum(Aig_Man_t *p)
static int Aig_ManObjNumMax(Aig_Man_t *p)
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
#define ABC_NAMESPACE_IMPL_START
static int Aig_ManRegNum(Aig_Man_t *p)
void Saig_ManDumpBlif(Aig_Man_t *p, char *pFileName)
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Aig_Obj_t * Saig_ManReadNode(Aig_Man_t *p, int *pNum2Id, char *pToken)
#define ABC_CALLOC(type, num)
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
static int Aig_ObjId(Aig_Obj_t *pObj)
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Aig_Man_t * Saig_ManReadBlif(char *pFileName)
#define Aig_ManForEachPoSeq(p, pObj, i)
char * Abc_UtilStrsav(char *s)
static int Saig_ObjIsPi(Aig_Man_t *p, Aig_Obj_t *pObj)
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
static int Aig_ObjCioId(Aig_Obj_t *pObj)