49 unsigned x = 0, i = 0;
53 while ((ch = *(*ppPos)++) & 0x80)
54 x |= (ch & 0x7f) << (7 * i++);
56 return x | (ch << (7 * i));
73 int Lit, LitPrev, Diff, i;
77 for ( i = 1; i < nEntries; i++ )
83 Diff = (Diff & 1)? -(Diff >> 1) : Diff >> 1;
111 int nTotal, nInputs, nOutputs, nLatches, nAnds, i;
112 int nBad = 0, nConstr = 0, nJust = 0, nFair = 0;
113 char * pDrivers, * pSymbols, * pCur;
114 unsigned uLit0, uLit1, uLit;
117 if (
strncmp(pContents,
"aig", 3) != 0 || (pContents[3] !=
' ' && pContents[3] !=
'2') )
119 fprintf( stdout,
"Wrong input file format.\n" );
124 pCur = pContents;
while ( *pCur !=
' ' ) pCur++; pCur++;
126 nTotal = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
128 nInputs = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
130 nLatches = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
132 nOutputs = atoi( pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
134 nAnds = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
140 nBad = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
147 nConstr = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
154 nJust = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
161 nFair = atoi( pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
166 fprintf( stdout,
"The parameter line is in a wrong format.\n" );
172 if ( nTotal != nInputs + nLatches + nAnds )
174 fprintf( stdout,
"The number of objects does not match.\n" );
177 if ( nJust || nFair )
179 fprintf( stdout,
"Reading AIGER files with liveness properties are currently not supported.\n" );
186 fprintf( stdout,
"Warning: The last output is interpreted as a constraint.\n" );
188 fprintf( stdout,
"Warning: The last %d outputs are interpreted as constraints.\n", nConstr );
193 pNew->nConstrs = nConstr;
196 vNodes =
Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
200 for ( i = 0; i < nInputs + nLatches; i++ )
213 pNew->nRegs = nLatches;
233 if ( pContents[3] ==
' ' )
236 for ( i = 0; i < nLatches + nOutputs; )
237 if ( *pCur++ ==
'\n' )
247 for ( i = 0; i < nAnds; i++ )
250 uLit = ((i + 1 + nInputs + nLatches) << 1);
266 if ( pContents[3] ==
' ' )
269 for ( i = 0; i < nLatches; i++ )
271 uLit0 = atoi( pCur );
while ( *pCur++ !=
'\n' );
276 for ( i = 0; i < nOutputs; i++ )
278 uLit0 = atoi( pCur );
while ( *pCur++ !=
'\n' );
287 for ( i = 0; i < nLatches; i++ )
294 for ( i = 0; i < nOutputs; i++ )
304 for ( i = 0; i < nOutputs; i++ )
306 for ( i = 0; i < nLatches; i++ )
387 if ( pCur + 1 < pContents + nFileSize && *pCur ==
'c' )
407 if ( nBad || nConstr || nJust || nFair )
413 printf(
"Ioa_ReadAiger: The network check has failed.\n" );
435 char * pName, * pContents;
436 int nFileSize, RetValue;
440 pFile = fopen( pFileName,
"rb" );
441 pContents =
ABC_ALLOC(
char, nFileSize );
442 RetValue = fread( pContents, nFileSize, 1, pFile );
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Aig_ManStop(Aig_Man_t *p)
Aig_Man_t * Ioa_ReadAigerFromMemory(char *pContents, int nFileSize, int fCheck)
INCLUDES ///.
int Ioa_FileSize(char *pFileName)
DECLARATIONS ///.
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
#define ABC_ALLOC(type, num)
static int Vec_PtrSize(Vec_Ptr_t *p)
ABC_NAMESPACE_IMPL_START unsigned Ioa_ReadAigerDecode(char **ppPos)
DECLARATIONS ///.
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Aig_Man_t * Ioa_ReadAiger(char *pFileName, int fCheck)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
static int Vec_IntEntry(Vec_Int_t *p, int i)
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Vec_Int_t * Ioa_WriteDecodeLiterals(char **ppPos, int nEntries)
void Aig_ManInvertConstraints(Aig_Man_t *pAig)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static int Aig_ManRegNum(Aig_Man_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
static void Vec_IntFree(Vec_Int_t *p)
char * Ioa_FileNameGeneric(char *FileName)
char * Abc_UtilStrsav(char *s)
int Aig_ManCleanup(Aig_Man_t *p)
int nTotal
DECLARATIONS ///.
static void Vec_PtrFree(Vec_Ptr_t *p)