58 unsigned x = 0, i = 0;
62 while ((ch = *(*ppPos)++) & 0x80)
63 x |= (ch & 0x7f) << (7 * i++);
65 return x | (ch << (7 * i));
82 int Lit, LitPrev, Diff, i;
86 for ( i = 1; i < nEntries; i++ )
92 Diff = (Diff & 1)? -(Diff >> 1) : Diff >> 1;
129 pFile = fopen( pFileName,
"rb" );
132 printf(
"Ioa_ReadLoadFileBz2(): The file is unavailable (absent or open).\n" );
136 if (bzError !=
BZ_OK) {
137 printf(
"Ioa_ReadLoadFileBz2(): BZ2_bzReadOpen() failed with error %d.\n",bzError );
145 nFileSize += buf->nBuf =
BZ2_bzRead(&bzError,b,buf->buf,1<<20);
147 }
while (bzError ==
BZ_OK);
153 p = pContents =
ABC_ALLOC(
char, nFileSize + 10 );
156 memcpy(p+nBytes,buf->buf,buf->nBuf);
161 }
while((buf = pNext));
166 nFileSize = ftell( pFile );
167 if ( nFileSize == 0 )
169 printf(
"Ioa_ReadLoadFileBz2(): The file is empty.\n" );
172 pContents =
ABC_ALLOC(
char, nFileSize + 10 );
174 RetValue = fread( pContents, nFileSize, 1, pFile );
177 printf(
"Ioa_ReadLoadFileBz2(): Unable to read the compressed BLIF.\n" );
184 *pFileSize = nFileSize;
201 const int READ_BLOCK_SIZE = 100000;
204 int amtRead, readBlock, nFileSize = READ_BLOCK_SIZE;
205 pFile =
gzopen( pFileName,
"rb" );
206 pContents =
ABC_ALLOC(
char, nFileSize );
208 while ((amtRead =
gzread(pFile, pContents + readBlock * READ_BLOCK_SIZE, READ_BLOCK_SIZE)) == READ_BLOCK_SIZE) {
210 nFileSize += READ_BLOCK_SIZE;
211 pContents =
ABC_REALLOC(
char, pContents, nFileSize);
216 nFileSize -= (READ_BLOCK_SIZE - amtRead);
218 *pFileSize = nFileSize;
242 int nTotal, nInputs, nOutputs, nLatches, nAnds;
243 int nBad = 0, nConstr = 0, nJust = 0, nFair = 0;
244 int nFileSize = -1, iTerm, nDigits, i;
245 char * pContents, * pDrivers = NULL, * pSymbols, * pCur, * pName, * pType;
246 unsigned uLit0, uLit1, uLit;
258 pFile = fopen( pFileName,
"rb" );
259 pContents =
ABC_ALLOC(
char, nFileSize );
260 RetValue = fread( pContents, nFileSize, 1, pFile );
266 if (
strncmp(pContents,
"aig", 3) != 0 || (pContents[3] !=
' ' && pContents[3] !=
'2') )
268 fprintf( stdout,
"Wrong input file format.\n" );
274 pCur = pContents;
while ( *pCur !=
' ' ) pCur++; pCur++;
276 nTotal = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
278 nInputs = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
280 nLatches = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
282 nOutputs = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
284 nAnds = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
290 nBad = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
297 nConstr = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
304 nJust = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
311 nFair = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
316 fprintf( stdout,
"The parameter line is in a wrong format.\n" );
323 if ( nTotal != nInputs + nLatches + nAnds )
325 fprintf( stdout,
"The number of objects does not match.\n" );
329 if ( nJust || nFair )
331 fprintf( stdout,
"Reading AIGER files with liveness properties is currently not supported.\n" );
339 fprintf( stdout,
"Warning: The last output is interpreted as a constraint.\n" );
341 fprintf( stdout,
"Warning: The last %d outputs are interpreted as constraints.\n", nConstr );
353 vNodes =
Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
357 for ( i = 0; i < nInputs; i++ )
363 for ( i = 0; i < nOutputs; i++ )
369 for ( i = 0; i < nLatches; i++ )
384 if ( pContents[3] ==
' ' )
389 for ( i = 0; i < nLatches + nOutputs; )
390 if ( *pCur++ ==
'\n' )
400 for ( i = 0; i < nAnds; i++ )
403 uLit = ((i + 1 + nInputs + nLatches) << 1);
419 if ( pContents[3] ==
' ' )
423 uLit0 = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
431 else if ( Init == 1 )
439 while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
443 fprintf( stdout,
"The initial value of latch number %d is not recongnized.\n", i );
454 uLit0 = atoi( pCur );
while ( *pCur++ !=
'\n' );
480 if ( pCur < pContents + nFileSize && *pCur !=
'c' )
483 while ( pCur < pContents + nFileSize && *pCur !=
'c' )
488 vTerms = pNtkNew->
vPis;
489 else if ( *pCur ==
'l' )
491 else if ( *pCur ==
'o' || *pCur ==
'b' || *pCur ==
'c' || *pCur ==
'j' || *pCur ==
'f' )
492 vTerms = pNtkNew->
vPos;
499 iTerm = atoi( ++pCur );
while ( *pCur++ !=
' ' );
503 fprintf( stdout,
"The number of terminal is out of bound.\n" );
510 pName = pCur;
while ( *pCur++ !=
'\n' );
526 if ( pObj->
pCopy )
continue;
532 if ( pObj->
pCopy )
continue;
540 if ( pObj->
pCopy )
continue;
555 if ( pCur + 1 < pContents + nFileSize && *pCur ==
'c' )
578 if ( nBad || nConstr || nJust || nFair )
584 printf(
"Io_ReadAiger: The network check has failed.\n" );
static char * Ioa_ReadLoadFileBz2Aig(char *pFileName, int *pFileSize)
ABC_DLL void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Io_ReadAiger(char *pFileName, int fCheck)
FUNCTION DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define BZ_DATA_ERROR_MAGIC
#define ABC_REALLOC(type, obj, num)
#define Abc_NtkForEachLatchOutput(pNtk, pObj, i)
static int Abc_Var2Lit(int Var, int fCompl)
ABC_DLL void Abc_NtkShortNames(Abc_Ntk_t *pNtk)
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
ABC_NAMESPACE_IMPL_START int ZEXPORT gzclose(gzFile file)
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void Abc_LatchSetInitDc(Abc_Obj_t *pLatch)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
void BZ_API() BZ2_bzReadClose(int *bzerror, BZFILE *b)
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Abc_Base10Log(unsigned n)
#define ABC_NAMESPACE_IMPL_END
BZFILE *BZ_API() BZ2_bzReadOpen(int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused)
int BZ_API() BZ2_bzRead(int *bzerror, BZFILE *b, void *buf, int len)
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static ABC_NAMESPACE_IMPL_START unsigned Io_ReadAigerDecode(char **ppPos)
DECLARATIONS ///.
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
static Abc_Obj_t * Abc_NtkBox(Abc_Ntk_t *pNtk, int i)
static char * Ioa_ReadLoadFileGzAig(char *pFileName, int *pFileSize)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static void Abc_LatchSetInit1(Abc_Obj_t *pLatch)
gzFile ZEXPORT gzopen(const char *path, const char *mode)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
#define Abc_NtkForEachPo(pNtk, pPo, i)
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
static void Vec_IntFree(Vec_Int_t *p)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Vec_Int_t * Io_WriteDecodeLiterals(char **ppPos, int nEntries)
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
int nTotal
DECLARATIONS ///.
#define Abc_NtkForEachPi(pNtk, pPi, i)
static void Vec_PtrFree(Vec_Ptr_t *p)