179 Vec_Int_t * vLits = NULL, * vPoTypes = NULL;
180 Vec_Int_t * vNodes, * vDrivers, * vInits = NULL;
181 int iObj, iNode0, iNode1, fHieOnly = 0;
182 int nTotal, nInputs, nOutputs, nLatches, nAnds, i;
183 int nBad = 0, nConstr = 0, nJust = 0, nFair = 0;
184 unsigned char * pDrivers, * pSymbols, * pCur;
185 unsigned uLit0, uLit1, uLit;
188 pCur = (
unsigned char *)pContents;
while ( *pCur !=
' ' ) pCur++; pCur++;
190 nTotal = atoi( (
const char *)pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
192 nInputs = atoi( (
const char *)pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
194 nLatches = atoi( (
const char *)pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
196 nOutputs = atoi( (
const char *)pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
198 nAnds = atoi( (
const char *)pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
204 nBad = atoi( (
const char *)pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
211 nConstr = atoi( (
const char *)pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
218 nJust = atoi( (
const char *)pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
225 nFair = atoi( (
const char *)pCur );
while ( *pCur !=
' ' && *pCur !=
'\n' ) pCur++;
230 fprintf( stdout,
"The parameter line is in a wrong format.\n" );
236 if ( nTotal != nInputs + nLatches + nAnds )
238 fprintf( stdout,
"The number of objects does not match.\n" );
241 if ( nJust || nFair )
243 fprintf( stdout,
"Reading AIGER files with liveness properties is currently not supported.\n" );
250 fprintf( stdout,
"Warning: The last output is interpreted as a constraint.\n" );
252 fprintf( stdout,
"Warning: The last %d outputs are interpreted as constraints.\n", nConstr );
256 pNew =
Gia_ManStart( nTotal + nLatches + nOutputs + 1 );
264 for ( i = 0; i < nInputs + nLatches; i++ )
272 if ( pContents[3] ==
' ' )
275 for ( i = 0; i < nLatches + nOutputs; )
276 if ( *pCur++ ==
'\n' )
287 for ( i = 0; i < nAnds; i++ )
289 uLit = ((i + 1 + nInputs + nLatches) << 1);
298 if ( iNode0 == iNode1 )
314 if ( pContents[3] ==
' ' )
318 for ( i = 0; i < nLatches; i++ )
320 uLit0 = atoi( (
char *)pCur );
321 while ( *pCur !=
' ' && *pCur !=
'\n' )
327 while ( *pCur++ !=
'\n' );
338 for ( i = 0; i < nOutputs; i++ )
340 uLit0 = atoi( (
char *)pCur );
while ( *pCur++ !=
'\n' );
349 for ( i = 0; i < nLatches; i++ )
356 for ( i = 0; i < nOutputs; i++ )
366 for ( i = 0; i < nOutputs; i++ )
368 for ( i = 0; i < nLatches; i++ )
377 if ( pCur < (
unsigned char *)pContents + nFileSize && *pCur !=
'c' )
380 unsigned char * pCurOld = pCur;
384 while ( pCur < (
unsigned char *)pContents + nFileSize && *pCur !=
'c' )
387 char * pType = (
char *)pCur;
389 if ( *pCur !=
'i' && *pCur !=
'o' && *pCur !=
'l' )
396 iTerm = atoi( (
char *)++pCur );
while ( *pCur++ !=
' ' );
398 while ( *pCur ==
' ' )
404 if ( *pCur++ !=
'@' )
409 if ( *pCur ==
'i' && *pType ==
'i' )
411 else if ( *pCur ==
'o' && *pType ==
'o' )
413 else if ( *pCur ==
'l' && *pType ==
'l' )
417 fprintf( stdout,
"Wrong name format.\n" );
422 while ( *pCur++ !=
'\n' );
427 unsigned char * pName;
428 int Entry, nInvars, nConstr, iTerm;
438 pCur = (
unsigned char *)pCurOld;
439 while ( pCur < (
unsigned char *)pContents + nFileSize && *pCur !=
'c' )
442 if ( *pCur ==
'i' || *pCur ==
'l' )
445 while ( *pCur++ !=
'\n' );
456 iTerm = atoi( (
char *)++pCur );
while ( *pCur++ !=
' ' );
458 if ( iTerm < 0 || iTerm >= nOutputs )
460 fprintf( stdout,
"The output number (%d) is out of range.\n", iTerm );
466 fprintf( stdout,
"The output number (%d) is listed twice.\n", iTerm );
472 pName = pCur;
while ( *pCur++ !=
'\n' );
481 nInvars = nConstr = 0;
487 if (
strncmp( pContents+Entry,
"constraint:", 11 ) == 0 )
492 if (
strncmp( pContents+Entry,
"invariant:", 10 ) == 0 )
499 fprintf( stdout,
"Recognized and added %d constraints.\n", nConstr );
501 fprintf( stdout,
"Recognized and skipped %d invariants.\n", nInvars );
502 if ( nConstr == 0 && nInvars == 0 )
511 if ( pCur + 1 < (
unsigned char *)pContents + nFileSize && *pCur ==
'c' )
515 unsigned char * pCurTemp;
520 while ( pCur < (
unsigned char *)pContents + nFileSize )
531 if ( fVerbose ) printf(
"Finished reading extension \"a\".\n" );
534 else if ( *pCur ==
'c' )
539 if ( fVerbose ) printf(
"Finished reading extension \"c\".\n" );
542 else if ( *pCur ==
'd' )
547 if ( fVerbose ) printf(
"Finished reading extension \"d\".\n" );
549 else if ( *pCur ==
'i' )
555 if ( fVerbose ) printf(
"Finished reading extension \"i\".\n" );
557 else if ( *pCur ==
'o' )
563 if ( fVerbose ) printf(
"Finished reading extension \"o\".\n" );
566 else if ( *pCur ==
'e' )
573 assert( pCur == pCurTemp );
574 if ( fVerbose ) printf(
"Finished reading extension \"e\".\n" );
577 else if ( *pCur ==
'f' )
583 if ( fVerbose ) printf(
"Finished reading extension \"f\".\n" );
586 else if ( *pCur ==
'g' )
592 if ( fVerbose ) printf(
"Finished reading extension \"g\".\n" );
595 else if ( *pCur ==
'h' )
604 if ( fVerbose ) printf(
"Finished reading extension \"h\".\n" );
607 else if ( *pCur ==
'k' )
613 pCurTemp = pCur + nSize + 4; pCur += 4;
615 assert( pCur == pCurTemp );
616 if ( fVerbose ) printf(
"Finished reading extension \"k\".\n" );
619 else if ( *pCur ==
'm' )
627 pCurTemp = pCur + nSize + 4; pCur += 4;
629 assert( pCur == pCurTemp );
630 if ( fVerbose ) printf(
"Finished reading extension \"m\".\n" );
633 else if ( *pCur ==
'n' )
636 if ( (*pCur >=
'a' && *pCur <=
'z') || (*pCur >=
'A' && *pCur <=
'Z') || (*pCur >=
'0' && *pCur <=
'9') )
645 assert( pCur == pCurTemp );
649 else if ( *pCur ==
'p' )
656 assert( pCur == pCurTemp );
658 if ( fVerbose ) printf(
"Finished reading extension \"p\".\n" );
661 else if ( *pCur ==
'r' )
667 for ( i = 0; i < nRegs; i++ )
669 if ( fVerbose ) printf(
"Finished reading extension \"r\".\n" );
672 else if ( *pCur ==
'q' )
674 int i, nPairs, iRepr, iNode;
680 for ( i = 0; i < nPairs; i++ )
684 pNew->
pSibls[iRepr] = iNode;
687 assert( pCur == pCurTemp );
688 if ( fVerbose ) printf(
"Finished reading extension \"q\".\n" );
691 else if ( *pCur ==
'u' )
693 unsigned char * pSwitching;
698 assert( pCur == pCurTemp );
699 if ( fVerbose ) printf(
"Finished reading extension \"s\".\n" );
702 else if ( *pCur ==
't' )
709 if ( fVerbose ) printf(
"Finished reading extension \"t\".\n" );
712 else if ( *pCur ==
'v' )
718 if ( fVerbose ) printf(
"Finished reading extension \"v\".\n" );
728 if ( nBad || nConstr || nJust || nFair )
742 Vec_Int_t * vFlopMap, * vGateMap, * vObjMap;
749 printf(
"Cleanup removed objects after reading. Old gate/object abstraction maps are invalid!\n" );
761 printf(
"Warning: Creating unit-delay box delay tables because box library is not available.\n" );
802 if ( !fSkipStrash && pNew->
vMapping )
804 Abc_Print( 0,
"Structural hashing enabled while reading AIGER invalidated the mapping. Consider using \"&r -s\".\n" );
static int * Vec_IntArray(Vec_Int_t *p)
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManInvertConstraints(Gia_Man_t *pAig)
void Gia_ManStop(Gia_Man_t *p)
static int Gia_ManPoNum(Gia_Man_t *p)
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static char * Vec_StrArray(Vec_Str_t *p)
static int Gia_ManAppendCi(Gia_Man_t *p)
static int Abc_Var2Lit(int Var, int fCompl)
#define ABC_ALLOC(type, num)
static float * Vec_FltArray(Vec_Flt_t *p)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
ABC_NAMESPACE_IMPL_START Gia_Rpr_t * Gia_AigerReadEquivClasses(unsigned char **ppPos, int nSize)
DECLARATIONS ///.
int * Gia_AigerReadMapping(unsigned char **ppPos, int nSize)
Vec_Int_t * Gia_AigerReadLiterals(unsigned char **ppPos, int nEntries)
static Vec_Int_t * Vec_IntStartFull(int nSize)
static void Vec_FltFreeP(Vec_Flt_t **p)
static int Abc_LitNotCond(int Lit, int c)
Gia_Man_t * Gia_ManDupZeroUndc(Gia_Man_t *p, char *pInit, int fVerbose)
int Gia_ManHasDangling(Gia_Man_t *p)
static int Gia_ManHasChoices(Gia_Man_t *p)
void Tim_ManCreate(Tim_Man_t *p, void *pLib, Vec_Flt_t *vInArrs, Vec_Flt_t *vOutReqs)
static Vec_Flt_t * Vec_FltStart(int nSize)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static Vec_Int_t * Vec_IntStart(int nSize)
static int Gia_AigerReadInt(unsigned char *pPos)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Vec_StrFree(Vec_Str_t *p)
static int Gia_ManAppendBuf(Gia_Man_t *p, int iLit)
static int Vec_IntEntry(Vec_Int_t *p, int i)
ABC_DLL void * Abc_FrameReadLibBox()
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
static Vec_Str_t * Vec_StrStart(int nSize)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
static void Vec_IntFreeP(Vec_Int_t **p)
static void Abc_Print(int level, const char *format,...)
int * Gia_ManDeriveNexts(Gia_Man_t *p)
Vec_Int_t * Gia_AigerReadMappingDoc(unsigned char **ppPos, int nObjs)
static int Vec_StrSize(Vec_Str_t *p)
static int Vec_IntSize(Vec_Int_t *p)
static int Vec_IntSum(Vec_Int_t *p)
#define ABC_CALLOC(type, num)
#define Gia_ManForEachRo(p, pObj, i)
int * Gia_AigerReadMappingSimple(unsigned char **ppPos, int nSize)
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
static unsigned Gia_AigerReadUnsigned(unsigned char **ppPos)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_AigerReadFromMemory(char *pContents, int nFileSize, int fSkipStrash, int fCheck)
Tim_Man_t * Tim_ManLoad(Vec_Str_t *p, int fHieOnly)
static void Vec_IntFree(Vec_Int_t *p)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
char * Abc_UtilStrsav(char *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Gia_Man_t * Gia_ManDupWithConstraints(Gia_Man_t *p, Vec_Int_t *vPoTypes)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Vec_Int_t * Gia_AigerReadPacking(unsigned char **ppPos, int nSize)
static int Gia_ManObjNum(Gia_Man_t *p)
int nTotal
DECLARATIONS ///.
void Gia_ManHashStop(Gia_Man_t *p)
static int Gia_ManRegNum(Gia_Man_t *p)