Commit 23229e03 by Alan Mishchenko

Fixing the format mismatch in writing mapped GIA.

parent 7e852767
...@@ -603,14 +603,17 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fSkipS ...@@ -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_AigerReadMapping( unsigned char ** ppPos, int nSize );
extern int * Gia_AigerReadMappingSimple( 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++; pCur++;
nSize = Gia_AigerReadInt(pCur); nSize = Gia_AigerReadInt(pCur);
pCurTemp = pCur + nSize + 4; pCur += 4; pCurTemp = pCur + nSize + 4; pCur += 4;
// pNew->pMapping = Gia_AigerReadMapping( &pCur, Gia_ManObjNum(pNew) ); // pNew->pMapping = Gia_AigerReadMapping( &pCur, Gia_ManObjNum(pNew) );
pNew->pMapping = Gia_AigerReadMappingSimple( &pCur, nSize ); // pNew->pMapping = Gia_AigerReadMappingSimple( &pCur, nSize );
pNew->nOffset = nSize / 4; // pNew->nOffset = nSize / 4;
pCur += nSize; // pCur += nSize;
pNew->pMapping = Gia_AigerReadMappingDoc( &pCur, Gia_ManObjNum(pNew), &nOffset );
pNew->nOffset = nOffset;
assert( pCur == pCurTemp ); assert( pCur == pCurTemp );
if ( fVerbose ) printf( "Finished reading extension \"m\".\n" ); if ( fVerbose ) printf( "Finished reading extension \"m\".\n" );
} }
...@@ -1185,8 +1188,9 @@ void Gia_AigerWrite( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int ...@@ -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_AigerWriteMapping( Gia_Man_t * p );
extern Vec_Str_t * Gia_AigerWriteMappingSimple( 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" ); fprintf( pFile, "m" );
vStrExt = Gia_AigerWriteMappingSimple( p ); vStrExt = Gia_AigerWriteMappingDoc( p );
Gia_FileWriteBufferSize( pFile, Vec_StrSize(vStrExt) ); Gia_FileWriteBufferSize( pFile, Vec_StrSize(vStrExt) );
fwrite( Vec_StrArray(vStrExt), 1, Vec_StrSize(vStrExt), pFile ); fwrite( Vec_StrArray(vStrExt), 1, Vec_StrSize(vStrExt), pFile );
Vec_StrFree( vStrExt ); Vec_StrFree( vStrExt );
......
...@@ -233,6 +233,63 @@ Vec_Str_t * Gia_AigerWriteMappingSimple( Gia_Man_t * p ) ...@@ -233,6 +233,63 @@ Vec_Str_t * Gia_AigerWriteMappingSimple( Gia_Man_t * p )
/**Function************************************************************* /**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.] Synopsis [Read/write packing information.]
Description [] Description []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment