diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-04-02 23:03:30 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-04-02 23:03:30 -0700 |
commit | 23229e03bf9253f1820c575444776cb0ae3c5863 (patch) | |
tree | 69b51193cd51baeb7bb8c09cd582cfba263820ed /src/aig | |
parent | 7e85276780c83538813329325ba1b28e95333be5 (diff) | |
download | abc-23229e03bf9253f1820c575444776cb0ae3c5863.tar.gz abc-23229e03bf9253f1820c575444776cb0ae3c5863.tar.bz2 abc-23229e03bf9253f1820c575444776cb0ae3c5863.zip |
Fixing the format mismatch in writing mapped GIA.
Diffstat (limited to 'src/aig')
-rw-r--r-- | src/aig/gia/giaAiger.c | 14 | ||||
-rw-r--r-- | src/aig/gia/giaAigerExt.c | 57 |
2 files changed, 66 insertions, 5 deletions
diff --git a/src/aig/gia/giaAiger.c b/src/aig/gia/giaAiger.c index ee90784e..d7cff42b 100644 --- a/src/aig/gia/giaAiger.c +++ b/src/aig/gia/giaAiger.c @@ -603,14 +603,17 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fSkipS { extern int * Gia_AigerReadMapping( unsigned char ** ppPos, int nSize ); extern int * Gia_AigerReadMappingSimple( unsigned char ** ppPos, int nSize ); - int nSize; + extern int * Gia_AigerReadMappingDoc( unsigned char ** ppPos, int nObjs, int * pOffset ); + int nSize, nOffset; pCur++; nSize = Gia_AigerReadInt(pCur); pCurTemp = pCur + nSize + 4; pCur += 4; // pNew->pMapping = Gia_AigerReadMapping( &pCur, Gia_ManObjNum(pNew) ); - pNew->pMapping = Gia_AigerReadMappingSimple( &pCur, nSize ); - pNew->nOffset = nSize / 4; - pCur += nSize; +// pNew->pMapping = Gia_AigerReadMappingSimple( &pCur, nSize ); +// pNew->nOffset = nSize / 4; +// pCur += nSize; + pNew->pMapping = Gia_AigerReadMappingDoc( &pCur, Gia_ManObjNum(pNew), &nOffset ); + pNew->nOffset = nOffset; assert( pCur == pCurTemp ); if ( fVerbose ) printf( "Finished reading extension \"m\".\n" ); } @@ -1185,8 +1188,9 @@ void Gia_AigerWrite( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int { extern Vec_Str_t * Gia_AigerWriteMapping( Gia_Man_t * p ); extern Vec_Str_t * Gia_AigerWriteMappingSimple( Gia_Man_t * p ); + extern Vec_Str_t * Gia_AigerWriteMappingDoc( Gia_Man_t * p ); fprintf( pFile, "m" ); - vStrExt = Gia_AigerWriteMappingSimple( p ); + vStrExt = Gia_AigerWriteMappingDoc( p ); Gia_FileWriteBufferSize( pFile, Vec_StrSize(vStrExt) ); fwrite( Vec_StrArray(vStrExt), 1, Vec_StrSize(vStrExt), pFile ); Vec_StrFree( vStrExt ); diff --git a/src/aig/gia/giaAigerExt.c b/src/aig/gia/giaAigerExt.c index 1a0dedac..250382cd 100644 --- a/src/aig/gia/giaAigerExt.c +++ b/src/aig/gia/giaAigerExt.c @@ -233,6 +233,63 @@ Vec_Str_t * Gia_AigerWriteMappingSimple( Gia_Man_t * p ) /**Function************************************************************* + Synopsis [Read/write mapping information.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int * Gia_AigerReadMappingDoc( unsigned char ** ppPos, int nObjs, int * pOffset ) +{ + int * pMapping, nLuts, LutSize, iRoot, nFanins, i, k; + nLuts = Gia_AigerReadInt( *ppPos ); *ppPos += 4; + LutSize = Gia_AigerReadInt( *ppPos ); *ppPos += 4; + pMapping = ABC_CALLOC( int, nObjs + (LutSize + 2) * nLuts ); + *pOffset = nObjs; + for ( i = 0; i < nLuts; i++ ) + { + iRoot = Gia_AigerReadInt( *ppPos ); *ppPos += 4; + nFanins = Gia_AigerReadInt( *ppPos ); *ppPos += 4; + pMapping[iRoot] = *pOffset; + // write one + pMapping[ (*pOffset)++ ] = nFanins; + for ( k = 0; k < nFanins; k++ ) + { + pMapping[ (*pOffset)++ ] = Gia_AigerReadInt( *ppPos ); *ppPos += 4; + } + pMapping[ (*pOffset)++ ] = iRoot; + } + return pMapping; +} +Vec_Str_t * Gia_AigerWriteMappingDoc( Gia_Man_t * p ) +{ + unsigned char * pBuffer; + int i, k, iFan, nLuts = 0, LutSize = 0, nSize = 2, nSize2 = 0; + Gia_ManForEachLut( p, i ) + { + nLuts++; + nSize += Gia_ObjLutSize(p, i) + 2; + LutSize = Abc_MaxInt( LutSize, Gia_ObjLutSize(p, i) ); + } + pBuffer = ABC_ALLOC( unsigned char, 4 * nSize ); + Gia_AigerWriteInt( pBuffer + 4 * nSize2++, nLuts ); + Gia_AigerWriteInt( pBuffer + 4 * nSize2++, LutSize ); + Gia_ManForEachLut( p, i ) + { + Gia_AigerWriteInt( pBuffer + 4 * nSize2++, i ); + Gia_AigerWriteInt( pBuffer + 4 * nSize2++, Gia_ObjLutSize(p, i) ); + Gia_LutForEachFanin( p, i, iFan, k ) + Gia_AigerWriteInt( pBuffer + 4 * nSize2++, iFan ); + } + assert( nSize2 == nSize ); + return Vec_StrAllocArray( (char *)pBuffer, 4*nSize ); +} + +/**Function************************************************************* + Synopsis [Read/write packing information.] Description [] |