125 pFile = fopen( pFileName,
"rb" );
128 printf(
"Io_Blif(): The file is unavailable (absent or open).\n" );
147 fprintf( stdout,
"%s\n", p->
sError );
155 printf(
"Io_Blif: The network check has failed.\n" );
237 1291, 1699, 2357, 4177, 5147,
238 5647, 6343, 7103, 7873, 8147
241 for ( i = 0; pName[i] !=
'\0'; i++ )
242 Key ^= s_Primes[i%10]*pName[i]*pName[i];
243 return Key % TableSize;
261 if ( !
strcmp((*ppEntry)->pName, pName) )
281 if ( *ppEntry == NULL )
285 (*ppEntry)->pName = pName;
306 for ( pCur = pInput; pCur < pOutput; pCur++ )
330 for ( pCur = pLine; *pCur != Stop; pCur++ )
353 if ( pToken < pLine )
375 for ( fSpaces = 0; *pCur; pCur++ )
404 int i, CounterOne,
Counter = 0;
412 if ( *pCur ==
'0' || *pCur ==
'1' )
415 Counter += CounterOne - 1;
437 pFile = fopen( pFileName,
"rb" );
440 printf(
"Io_BlifLoadFile(): The file is unavailable (absent or open).\n" );
444 nFileSize = ftell( pFile );
445 if ( nFileSize == 0 )
448 printf(
"Io_BlifLoadFile(): The file is empty.\n" );
451 pContents =
ABC_ALLOC(
char, nFileSize + 10 );
453 RetValue = fread( pContents, nFileSize, 1, pFile );
457 strcpy( pContents + nFileSize,
"\n.end\n" );
480 char * pCur, * pPrev;
484 for ( pCur = p->
pBuffer; *pCur; pCur++ )
492 else if ( *pCur ==
'#' )
505 for ( pPrev = pCur - 2; pPrev >= p->
pBuffer; pPrev-- )
509 if ( *pPrev ==
'\\' )
511 for ( ; *pPrev; pPrev++ )
519 if ( *(pCur-1) !=
'.' )
521 if ( !
strncmp(pCur,
"names", 5) )
523 else if ( !
strncmp(pCur,
"latch", 5) )
525 else if ( !
strncmp(pCur,
"inputs", 6) )
527 else if ( !
strncmp(pCur,
"outputs", 7) )
529 else if ( !
strncmp(pCur,
"model", 5) )
536 if ( pCur[
strlen(pCur)-1] ==
'\r' )
538 fprintf( stdout,
"Line %d: Skipping line \"%s\".\n",
Io_BlifGetLine(p, pCur), pCur );
682 fprintf( stdout,
"Line %d: Primary output (%s) is defined more than once (warning only).\n",
Io_BlifGetLine(p, pToken), pToken );
718 if ( Init < 0 || Init > 2 )
725 else if ( Init == 1 )
807 char * pProduct, * pOutput;
809 int i, k, Polarity = -1;
819 if ( ((pOutput[0] -
'0') & 0x8E) || pOutput[1] )
843 if ( ((pOutput[0] -
'0') & 0x8E) || pOutput[1] )
848 if ( Polarity == -1 )
849 Polarity = pOutput[0] -
'0';
850 else if ( Polarity != pOutput[0] -
'0' )
852 sprintf( p->
sError,
"Line %d: Output value (%s) differs from the value in the first line of the table (%d).",
Io_BlifGetLine(p, pProduct), pOutput, Polarity );
857 for ( k = 0; pProduct[k]; k++ )
859 if ( pProduct[k] ==
'0' )
861 else if ( pProduct[k] ==
'1' )
863 else if ( pProduct[k] !=
'-' )
895 if ( pObjIo == NULL )
917 if ( pFaninAbc == NULL )
977 pLatch->
pData = (
void *)(ABC_PTRUINT_T)pObjIo->
Init;
1008 printf(
"The number of dangling tables = %d.\n", p->
nTablesLeft );
static Io_BlifObj_t * Io_BlifHashFindOrAdd(Io_BlifMan_t *p, char *pName)
static int Io_BlifParseLatch(Io_BlifMan_t *p, char *pLine)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
ABC_DLL Abc_Obj_t * Abc_AigOr(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
static Abc_Obj_t * Io_BlifParseConstruct_rec(Io_BlifMan_t *p, char *pName)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Io_BlifInit_t
DECLARATIONS ///.
static void Io_BlifSplitIntoTokens(Vec_Ptr_t *vTokens, char *pLine, char Stop)
static int Io_BlifParseModel(Io_BlifMan_t *p, char *pLine)
static void Io_BlifCollectTokens(Vec_Ptr_t *vTokens, char *pInput, char *pOutput)
static int Io_BlifParseOutputs(Io_BlifMan_t *p, char *pLine)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
static void Io_BlifFree(Io_BlifMan_t *p)
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
static int Vec_PtrSize(Vec_Ptr_t *p)
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 ///.
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
static int s_Primes[MAX_PRIMES]
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
#define ABC_NAMESPACE_IMPL_END
static unsigned Io_BlifHashString(char *pName, int TableSize)
static Abc_Ntk_t * Io_BlifParse(Io_BlifMan_t *p)
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
static int Io_BlifParseNames(Io_BlifMan_t *p, char *pLine)
static int Io_BlifGetLine(Io_BlifMan_t *p, char *pToken)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
static Abc_Obj_t * Abc_NtkBox(Abc_Ntk_t *pNtk, int i)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static Abc_Obj_t * Io_BlifParseTable(Io_BlifMan_t *p, char *pTable, Vec_Ptr_t *vFanins)
static int Io_BlifEstimateAndNum(Io_BlifMan_t *p)
static char * Io_BlifLoadFile(char *pFileName)
static int Io_BlifEstimatePiNum(Io_BlifMan_t *p)
static int Io_BlifParseConstruct(Io_BlifMan_t *p)
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Io_BlifReadPreparse(Io_BlifMan_t *p)
Abc_Ntk_t * Io_ReadBlifAsAig(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
static Io_BlifMan_t * Io_BlifAlloc()
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
static int Io_BlifCharIsSpace(char s)
static void Vec_PtrClear(Vec_Ptr_t *p)
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Io_BlifParseInputs(Io_BlifMan_t *p, char *pLine)
static Io_BlifObj_t ** Io_BlifHashLookup(Io_BlifMan_t *p, char *pName)
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
static void Vec_PtrFree(Vec_Ptr_t *p)