50 if ( pFileName == NULL )
55 if ( !
strcmp( pExt,
"aig" ) )
57 if ( !
strcmp( pExt,
"baf" ) )
59 if ( !
strcmp( pExt,
"bblif" ) )
61 if ( !
strcmp( pExt,
"blif" ) )
63 if ( !
strcmp( pExt,
"bench" ) )
65 if ( !
strcmp( pExt,
"cnf" ) )
67 if ( !
strcmp( pExt,
"dot" ) )
69 if ( !
strcmp( pExt,
"edif" ) )
71 if ( !
strcmp( pExt,
"eqn" ) )
73 if ( !
strcmp( pExt,
"gml" ) )
75 if ( !
strcmp( pExt,
"list" ) )
77 if ( !
strcmp( pExt,
"mv" ) )
79 if ( !
strcmp( pExt,
"pla" ) )
81 if ( !
strcmp( pExt,
"smv" ) )
83 if ( !
strcmp( pExt,
"v" ) )
105 fprintf( stdout,
"Generic file reader requires a known file extension to open \"%s\".\n", pFileName );
109 pFile = fopen( pFileName,
"r" );
112 fprintf( stdout,
"Cannot open input file \"%s\". ", pFileName );
114 fprintf( stdout,
"Did you mean \"%s\"?", pFileName );
115 fprintf( stdout,
"\n" );
130 fprintf( stdout,
"Reading AIG from file has failed.\n" );
148 pNtk =
Io_ReadPla( pFileName, 0, 0, 0, 0, fCheck );
153 fprintf( stderr,
"Unknown file format.\n" );
158 fprintf( stdout,
"Reading network from file has failed.\n" );
162 if ( fCheck && (Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk)) && pNtk->
pDesign )
201 Vec_PtrPush( tempStore, pFormula );
225 assert( tempLtlStore != NULL );
250 if ( !Abc_NtkIsNetlist(pNtk) )
257 assert( Abc_NtkIsLogic(pNtk) );
261 assert( Abc_NtkIsNetlist(pNtk) );
262 if ( Abc_NtkWhiteboxNum(pNtk) > 0 )
268 fprintf( stdout,
"Flattening logic hierarchy has failed.\n" );
273 if ( Abc_NtkBlackboxNum(pNtk) > 0 )
275 printf(
"Hierarchy reader converted %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtk) );
280 fprintf( stdout,
"Converting blackboxes has failed.\n" );
291 fprintf( stdout,
"Converting BLIF-MV to AIG has failed.\n" );
303 fprintf( stdout,
"Converting netlist to logic network after reading has failed.\n" );
326 fprintf( stdout,
"Empty network.\n" );
332 fprintf( stdout,
"The generic file writer requires a known file extension.\n" );
338 if ( !Abc_NtkIsStrash(pNtk) )
340 fprintf( stdout,
"Writing this format is only possible for structurally hashed AIGs.\n" );
367 if ( !Abc_NtkIsLogic(pNtk) )
369 fprintf( stdout,
"Writing Binary BLIF is only possible for logic networks.\n" );
372 if ( !Abc_NtkHasSop(pNtk) )
389 fprintf( stdout,
"PLA writing is available for collapsed networks.\n" );
392 if ( Abc_NtkIsComb(pNtk) )
396 fprintf( stdout,
"Latches are written into the PLA file at PI/PO pairs.\n" );
411 if ( !Abc_NtkIsStrash(pNtk) )
413 fprintf( stdout,
"Writing traditional BENCH is available for AIGs only (use \"write_bench\").\n" );
420 if ( !Abc_NtkIsStrash(pNtk) )
422 fprintf( stdout,
"Writing traditional SMV is available for AIGs only.\n" );
430 if ( pNtkTemp == NULL )
432 fprintf( stdout,
"Converting to netlist has failed.\n" );
438 if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
458 if ( !Abc_NtkHasAig(pNtkTemp) )
466 if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
471 fprintf( stderr,
"Unknown file format.\n" );
488 Abc_Ntk_t * pNtkTemp, * pNtkResult, * pNtkBase = NULL;
493 fprintf( stdout,
"Empty network.\n" );
498 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
506 fprintf( stderr,
"Unknown input file format.\n" );
507 if ( pNtkBase == NULL )
511 if ( Abc_NtkWhiteboxNum(pNtkBase) > 0 && pNtk->
nBarBufs == 0 )
515 if ( pNtkBase == NULL )
527 printf(
"Hierarchy writer replaced %d barbufs by hierarchy boundaries.\n", pNtk->
nBarBufs );
531 if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
533 printf(
"Hierarchy writer does not support BLIF-MV with blackboxes.\n" );
538 assert( !Abc_NtkIsNetlist(pNtk) );
549 else if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
556 printf(
"Hierarchy writer reintroduced %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtkBase) );
560 printf(
"Warning: The output network does not contain blackboxes.\n" );
564 if ( pNtkResult == NULL )
573 if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
578 if ( !Abc_NtkHasSop(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
588 if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
593 if ( !Abc_NtkHasAig(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
603 fprintf( stderr,
"Unknown output file format.\n" );
625 printf(
"Warning: PI \"%s\" appears twice in the list.\n", pName );
628 pTerm = Abc_NtkCreatePi( pNtk );
649 if ( pNet && Abc_ObjFaninNum(pNet) == 0 )
650 printf(
"Warning: PO \"%s\" appears twice in the list.\n", pName );
653 pTerm = Abc_NtkCreatePo( pNtk );
675 pTerm = Abc_NtkCreateBi( pNtk );
678 pLatch = Abc_NtkCreateLatch( pNtk );
681 pTerm = Abc_NtkCreateBo( pNtk );
708 pNetLI = Abc_NtkCreateNet( pNtk );
709 pNetLO = Abc_NtkCreateNet( pNtk );
714 Abc_LatchSetInit0( pLatch );
739 pNode = Abc_NtkCreateNode( pNtk );
741 for ( i = 0; i < nInputs; i++ )
828FILE *
Io_FileOpen(
const char * FileName,
const char * PathVar,
const char * Mode,
int fVerbose )
830 char * t = 0, * c = 0, * i;
834 return fopen( FileName, Mode );
840 char ActualFileName[4096];
843 for (i =
strtok( t,
":" ); i != 0; i =
strtok( 0,
":") )
846 _snprintf ( ActualFileName, 4096,
"%s/%s", i, FileName );
848 snprintf ( ActualFileName, 4096,
"%s/%s", i, FileName );
850 if ( ( fp = fopen ( ActualFileName, Mode ) ) )
853 fprintf ( stdout,
"Using file %s\n", ActualFileName );
863 return fopen( FileName, Mode );
881 int fStart = 0, Size = 1000000;
882 char * pBuffer, * pToken;
883 FILE * pFileIn = fopen( pNameIn,
"rb" );
884 FILE * pFileOut = fopen( pNameOut,
"wb" );
885 if ( pFileIn == NULL )
887 if ( pFileOut ) fclose( pFileOut );
888 printf(
"Cannot open file \"%s\" for reading.\n", pNameIn );
891 if ( pFileOut == NULL )
893 if ( pFileIn ) fclose( pFileIn );
894 printf(
"Cannot open file \"%s\" for writing.\n", pNameOut );
898 fprintf( pFileOut,
".type fd\n" );
899 while ( fgets(pBuffer, Size, pFileIn) )
901 if (
strstr(pBuffer,
"END_SDF") )
903 if (
strstr(pBuffer,
"SDF") )
905 char * pRes = fgets(pBuffer, Size, pFileIn);
907 if ( (pToken =
strtok( pBuffer,
" \t\r\n" )) )
908 fprintf( pFileOut,
".i %d\n", atoi(pToken) );
909 if ( (pToken =
strtok( NULL,
" \t\r\n" )) )
910 fprintf( pFileOut,
".o %d\n", atoi(pToken) );
911 if ( (pToken =
strtok( NULL,
" \t\r\n" )) )
912 fprintf( pFileOut,
".p %d\n", atoi(pToken) );
916 fprintf( pFileOut,
"%s", pBuffer );
918 fprintf( pFileOut,
".e\n" );
937 FILE * pFileOut = fopen( pNameOut,
"wb" );
938 if ( pFileOut == NULL ) {
939 printf(
"Cannot open file \"%s\" for writing.\n", pNameOut );
944 if ( vData == NULL ) {
949 int v, i, nLines = Vec_WrdSize(vData) /
nWords;
950 int nIns = Abc_Base2Log(nLines), nOuts;
953 for ( i = 0; i < nLines; i++ )
954 Abc_TtOr( pTemp, pTemp, Vec_WrdEntryP(vData,
nWords*i),
nWords );
955 for ( nOuts =
nWords*64; nOuts > 0; nOuts-- )
956 if ( Abc_TtGetBit(pTemp, nOuts-1) )
960 fprintf( pFileOut,
".i %d\n", nIns );
961 fprintf( pFileOut,
".o %d\n", nOuts );
962 fprintf( pFileOut,
".p %d\n", nLines );
963 fprintf( pFileOut,
".type fr\n" );
964 for ( i = 0; i < nLines; i++ ) {
965 word * pData = Vec_WrdEntryP(vData,
nWords*i);
966 for ( v = 0; v < nIns; v++ )
967 fprintf( pFileOut,
"%d", (i >> v) & 1 );
968 fprintf( pFileOut,
" " );
969 for ( v = 0; v < nOuts; v++ )
970 fprintf( pFileOut,
"%d", Abc_TtGetBit(pData, v) );
971 fprintf( pFileOut,
"\n" );
973 fprintf( pFileOut,
".e\n\n" );
991 int nSize = (nVars + 3)*Vec_WecSize(vNums);
992 char * pStr =
ABC_ALLOC(
char, nSize+1 );
993 memset( pStr,
'-', nSize );
997 char * pCube = pStr + (nVars + 3)*i;
999 pCube[Abc_Lit2Var(Num)] =
'0' + Abc_LitIsCompl(Num);
1000 pCube[nVars+0] =
' ';
1001 pCube[nVars+1] =
'0';
1002 pCube[nVars+2] =
'\n';
1004 Vec_PtrPush( vSops, pStr );
1009 Vec_Ptr_t * vSops = Vec_PtrAlloc( Vec_WecSize(vNums) );
1013 char * pCube =
ABC_ALLOC(
char, nVars + 4 );
1014 memset( pCube,
'-', nVars );
1016 pCube[Abc_Lit2Var(Num)] =
'0' + Abc_LitIsCompl(Num);
1017 pCube[nVars+0] =
' ';
1018 pCube[nVars+1] =
'0';
1019 pCube[nVars+2] =
'\n';
1020 pCube[nVars+3] =
'\0';
1021 Vec_PtrPush( vSops, pCube );
1028 Vec_Wec_t * vNums = Vec_WecAlloc( 100 );
1030 char * pThis, pLine[10000];
1031 int nVars = -1, nClas = -1;
1032 FILE * pFile = fopen( pFileName,
"rb" );
1033 if ( pFile == NULL ) {
1034 printf(
"Cannot open file \"%s\" for reading.\n", pFileName );
1037 while ( fgets( pLine, 10000, pFile ) )
1039 if ( pLine[0] ==
'c' )
1041 if ( pLine[0] ==
'p' )
1043 pThis =
strtok(pLine+1,
" \t\n\r");
1044 if (
strcmp(pThis,
"cnf") )
1046 Vec_PtrFree( vSops );
1047 Vec_WecFree( vNums );
1049 printf(
"Wrong file format.\n" );
1052 pThis =
strtok(NULL,
" \t\n\r");
1053 nVars = atoi(pThis);
1054 pThis =
strtok(NULL,
" \t\n\r");
1055 nClas = atoi(pThis);
1058 pThis =
strtok(pLine,
" \t\n\r");
1059 if ( pThis == NULL )
1061 vLevel = Vec_WecPushLevel( vNums );
1063 int fComp, Temp = atoi(pThis);
1067 Temp = Temp < 0 ? -Temp : Temp;
1070 Vec_IntPush( vLevel, Abc_Var2Lit(Temp, fComp) );
1071 pThis =
strtok(NULL,
" \t\n\r");
1075 if ( nClas != Vec_WecSize(vNums) )
1076 printf(
"Warning: The number of clauses (%d) listed is different from the actual number (%d).\n", nClas, Vec_WecSize(vNums) );
1082 Vec_WecFree( vNums );
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
ABC_DLL Abc_Ntk_t * Abc_NtkFromBarBufs(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkToBarBufs(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlistBench(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkStrashBlifMv(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_NtkConvertToBlifMv(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
ABC_DLL Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkMakeComb(Abc_Ntk_t *pNtk, int fRemoveLatches)
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
ABC_DLL int Abc_NtkIsAcyclicWithBoxes(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
ABC_DLL Abc_Ntk_t * Abc_NtkConvertBlackboxes(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkInsertNewLogic(Abc_Ntk_t *pNtkH, Abc_Ntk_t *pNtkL)
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
ABC_DLL Abc_Ntk_t * Abc_NtkInsertBlifMv(Abc_Ntk_t *pNtkBase, Abc_Ntk_t *pNtkLogic)
#define ABC_ALLOC(type, num)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL char * Abc_FrameReadFlag(char *pFlag)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Abc_Ntk_t * Io_ReadBlifMv(char *pFileName, int fBlifMv, int fCheck)
FUNCTION DEFINITIONS ///.
void Io_WriteBblif(Abc_Ntk_t *pNtk, char *pFileName)
Abc_Ntk_t * Io_ReadBaf(char *pFileName, int fCheck)
DECLARATIONS ///.
void Io_WriteDot(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
Abc_Ntk_t * Io_ReadEqn(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
Io_FileType_t
INCLUDES ///.
int Io_WritePla(Abc_Ntk_t *pNtk, char *FileName)
Abc_Ntk_t * Io_ReadAiger(char *pFileName, int fCheck)
FUNCTION DECLARATIONS ///.
void Io_WriteEqn(Abc_Ntk_t *pNtk, char *pFileName)
FUNCTION DEFINITIONS ///.
Abc_Ntk_t * Io_ReadVerilog(char *pFileName, int fCheck)
DECLARATIONS ///.
void Io_WriteVerilog(Abc_Ntk_t *pNtk, char *FileName, int fOnlyAnds, int fNewInterface)
FUNCTION DEFINITIONS ///.
Abc_Ntk_t * Io_ReadBblif(char *pFileName, int fCheck)
void Io_WriteAiger(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols, int fCompact, int fUnique)
int Io_WriteBench(Abc_Ntk_t *pNtk, const char *FileName)
FUNCTION DEFINITIONS ///.
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Abc_Ntk_t * Io_ReadBench(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
int Io_WriteMoPla(Abc_Ntk_t *pNtk, char *FileName)
void Io_WriteBlifMv(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
int Io_WriteSmv(Abc_Ntk_t *pNtk, char *FileName)
void Io_WriteGml(Abc_Ntk_t *pNtk, char *pFileName)
DECLARATIONS ///.
void Io_WriteBook(Abc_Ntk_t *pNtk, char *FileName)
Abc_Ntk_t * Io_ReadPla(char *pFileName, int fZeros, int fBoth, int fOnDc, int fSkipPrepro, int fCheck)
void Io_WriteBaf(Abc_Ntk_t *pNtk, char *pFileName)
DECLARATIONS ///.
int Io_WriteCnf(Abc_Ntk_t *pNtk, char *FileName, int fAllPrimes)
FUNCTION DEFINITIONS ///.
Abc_Ntk_t * Io_ReadEdif(char *pFileName, int fCheck)
FUNCTION DEFINITIONS ///.
void Io_WriteHie(Abc_Ntk_t *pNtk, char *pBaseName, char *pFileName)
void Io_TransformSF2PLA(char *pNameIn, char *pNameOut)
Vec_Ptr_t * Io_FileReadCnf(char *pFileName, int fMulti)
Vec_Ptr_t * Io_ConvertNumsToSop(Vec_Wec_t *vNums, int nVars)
Abc_Obj_t * Io_ReadCreateResetLatch(Abc_Ntk_t *pNtk, int fBlifMv)
Abc_Obj_t * Io_ReadCreateBuf(Abc_Ntk_t *pNtk, char *pNameIn, char *pNameOut)
void updateLtlStoreOfNtk(Abc_Ntk_t *pNtk, Vec_Ptr_t *tempLtlStore)
Vec_Ptr_t * Io_ConvertNumsToSopMulti(Vec_Wec_t *vNums, int nVars)
Abc_Obj_t * Io_ReadCreateInv(Abc_Ntk_t *pNtk, char *pNameIn, char *pNameOut)
Abc_Ntk_t * Io_ReadNetlist(char *pFileName, Io_FileType_t FileType, int fCheck)
Abc_Obj_t * Io_ReadCreatePo(Abc_Ntk_t *pNtk, char *pName)
ABC_NAMESPACE_IMPL_START Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
void Io_Write(Abc_Ntk_t *pNtk, char *pFileName, Io_FileType_t FileType)
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
Vec_Ptr_t * temporaryLtlStore(Abc_Ntk_t *pNtk)
Abc_Obj_t * Io_ReadCreateConst(Abc_Ntk_t *pNtk, char *pName, int fConst1)
void Io_TransformROM2PLA(char *pNameIn, char *pNameOut)
Abc_Obj_t * Io_ReadCreatePi(Abc_Ntk_t *pNtk, char *pName)
Abc_Obj_t * Io_ReadCreateLatch(Abc_Ntk_t *pNtk, char *pNetLI, char *pNetLO)
Abc_Obj_t * Io_ReadCreateNode(Abc_Ntk_t *pNtk, char *pNameOut, char *pNamesIn[], int nInputs)
unsigned __int64 word
DECLARATIONS ///.
Vec_Ptr_t * vLtlProperties
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.