39 #define vsnprintf _vsnprintf
171 ch = (x & 0x7f) | 0x80;
226 int Pos = 0, Lit, LitPrev, Diff, i;
232 Diff = Lit - LitPrev;
233 Diff = (Lit < LitPrev)? -Diff : Diff;
234 Diff = (Diff << 1) | (
int)(Lit < LitPrev);
237 if ( Pos + 10 > vBinary->
nCap )
274 int i, nNodes, nBufferSize,
Pos, fExtended;
275 unsigned char * pBuffer;
276 unsigned uLit0, uLit1, uLit;
289 fprintf( stdout,
"Io_WriteAiger(): Cannot write AIGER format with non-0 latch init values. Run \"zero\".\n" );
294 pFile = fopen( pFileName,
"wb" );
297 fprintf( stdout,
"Io_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
310 fprintf( pFile,
"aig%s %u %u %u %u %u",
320 fprintf( pFile,
"\n" );
336 fprintf( pFile,
"%u\n", uLit );
338 fprintf( pFile,
"%u 1\n", uLit );
366 pBuffer =
ABC_ALLOC(
unsigned char, nBufferSize );
376 unsigned Temp = uLit0;
383 if ( Pos > nBufferSize - 10 )
385 printf(
"Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
390 assert( Pos < nBufferSize );
394 fwrite( pBuffer, 1, Pos, pFile );
402 fprintf( pFile,
"i%d %s\n", i,
Abc_ObjName(pObj) );
409 fprintf( pFile,
"o%d %s\n", i,
Abc_ObjName(pObj) );
411 fprintf( pFile,
"b%d %s\n", i,
Abc_ObjName(pObj) );
417 fprintf( pFile,
"c\n" );
419 fprintf( pFile,
".model %s\n", pNtk->
pName );
420 fprintf( pFile,
"This file was produced by ABC on %s\n",
Extra_TimeStamp() );
421 fprintf( pFile,
"For information about AIGER format, refer to %s\n",
"http://fmv.jku.at/aiger" );
441 int i, nNodes,
Pos, nBufferSize, fExtended;
442 unsigned char * pBuffer;
443 unsigned uLit0, uLit1, uLit;
447 pFile =
gzopen( pFileName,
"wb" );
450 fprintf( stdout,
"Io_WriteAigerGz(): Cannot open the output file \"%s\".\n", pFileName );
465 gzprintf( pFile,
"aig %u %u %u %u %u",
509 pBuffer =
ABC_ALLOC(
unsigned char, nBufferSize );
519 unsigned Temp = uLit0;
526 if ( Pos > nBufferSize - 10 )
528 printf(
"Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
533 assert( Pos < nBufferSize );
564 gzprintf( pFile,
"For information about AIGER format, refer to %s\n",
"http://fmv.jku.at/aiger" );
610 fprintf( stdout,
"Ioa_WriteBlif(): I/O error writing to compressed stream.\n" );
618 n = vfprintf( b->
f, fmt, ap);
640 int i, nNodes, nBufferSize, bzError,
Pos, fExtended;
641 unsigned char * pBuffer;
642 unsigned uLit0, uLit1, uLit;
664 fprintf( stdout,
"Io_WriteAiger(): Cannot write AIGER format with non-0 latch init values. Run \"zero\".\n" );
680 b.
f = fopen( pFileName,
"wb" );
683 fprintf( stdout,
"Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
689 if ( bzError !=
BZ_OK ) {
691 fprintf( stdout,
"Ioa_WriteBlif(): Cannot start compressed stream.\n" );
760 fprintf( stdout,
"Io_WriteAiger(): I/O error writing to compressed stream.\n" );
775 pBuffer =
ABC_ALLOC(
unsigned char, nBufferSize );
785 unsigned Temp = uLit0;
792 if ( Pos > nBufferSize - 10 )
794 printf(
"Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
801 assert( Pos < nBufferSize );
806 fwrite( pBuffer, 1, Pos, b.
f );
811 fprintf( stdout,
"Io_WriteAiger(): I/O error writing to compressed stream.\n" );
845 fprintfBz2Aig( &b,
"For information about AIGER format, refer to %s\n",
"http://fmv.jku.at/aiger" );
852 fprintf( stdout,
"Io_WriteAiger(): I/O error closing compressed stream.\n" );
897 else if ( pGia != NULL &&
905 printf(
"AIG parameters do not match those of the CEX.\n" );
910 pFile = fopen( pFileName,
"wb" );
911 fprintf( pFile,
"1\n" );
913 for ( k = 0; k < pCex->nRegs; k++ )
914 fprintf( pFile,
"0" );
915 fprintf( pFile,
" " );
917 for ( f = 0; f <= pCex->iFrame; f++ )
919 for ( k = 0; k < pCex->nPis; k++ )
924 fprintf( pFile,
" " );
931 fprintf( pFile,
"%d", pObj->
fMarkA );
932 fprintf( pFile,
" " );
934 fprintf( pFile,
"%d", pObj->
fMarkA );
935 fprintf( pFile,
"\n" );
936 if ( f == pCex->iFrame )
939 fprintf( pFile,
"%d", pObj->
fMarkA );
940 fprintf( pFile,
" " );
944 assert( b == pCex->nBits );
ABC_DLL void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
void BZ_API() BZ2_bzWrite(int *bzerror, BZFILE *b, void *buf, int len)
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START void Io_WriteAigerCex(Abc_Cex_t *pCex, Abc_Ntk_t *pNtk, void *pG, char *pFileName)
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
static ABC_NAMESPACE_IMPL_START unsigned Io_ObjMakeLit(int Var, int fCompl)
DECLARATIONS ///.
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
static int Abc_LatchIsInitNone(Abc_Obj_t *pLatch)
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
void BZ_API() BZ2_bzWriteClose(int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Aig_ManStop(Aig_Man_t *p)
static char * Vec_StrArray(Vec_Str_t *p)
static int Abc_InfoHasBit(unsigned *p, int i)
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
#define ABC_REALLOC(type, obj, num)
Vec_Str_t * Io_WriteEncodeLiterals(Vec_Int_t *vLits)
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
void Io_WriteAiger(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols, int fCompact, int fUnique)
#define Aig_ManForEachCo(p, pObj, i)
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
#define ABC_ALLOC(type, num)
ABC_NAMESPACE_IMPL_START int ZEXPORT gzclose(gzFile file)
static Vec_Str_t * Vec_StrAlloc(int nCap)
int Io_WriteAigerEncode(unsigned char *pBuffer, int Pos, unsigned x)
FUNCTION DEFINITIONS ///.
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
BZFILE *BZ_API() BZ2_bzWriteOpen(int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
static unsigned Io_ObjAigerNum(Abc_Obj_t *pObj)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
#define Abc_AigForEachAnd(pNtk, pNode, i)
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
static void Vec_StrGrow(Vec_Str_t *p, int nCapMin)
#define Aig_ManForEachNode(p, pObj, i)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
#define Saig_ManForEachLi(p, pObj, i)
static void Vec_StrFree(Vec_Str_t *p)
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
static int Vec_IntEntry(Vec_Int_t *p, int i)
#define ABC_NAMESPACE_IMPL_END
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Vec_Int_t * Io_WriteAigerLiterals(Abc_Ntk_t *pNtk)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
static int Abc_NtkConstrNum(Abc_Ntk_t *pNtk)
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20)
#define ABC_NAMESPACE_IMPL_START
static int Vec_StrSize(Vec_Str_t *p)
void Io_WriteAiger_old(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols, int fCompact)
gzFile ZEXPORT gzopen(const char *path, const char *mode)
static int Vec_IntSize(Vec_Int_t *p)
#define Abc_NtkForEachCi(pNtk, pCi, i)
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
void Aig_ManCleanMarkA(Aig_Man_t *p)
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
static void Io_ObjSetAigerNum(Abc_Obj_t *pObj, unsigned Num)
#define Saig_ManForEachPo(p, pObj, i)
void Io_WriteAigerGz(Abc_Ntk_t *pNtk, char *pFileName, int fWriteSymbols)
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
int fprintfBz2Aig(bz2file *b, char *fmt,...)
#define Abc_NtkForEachPo(pNtk, pPo, i)
static void Vec_IntFree(Vec_Int_t *p)
static int Gia_ManPiNum(Gia_Man_t *p)
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
#define Abc_NtkForEachPi(pNtk, pPi, i)
static int Gia_ManRegNum(Gia_Man_t *p)