Commit fddff7a5 by Alan Mishchenko

Other changes to enable new features in the mapper (bug fix).

parent 8ed6d8e0
......@@ -2150,7 +2150,7 @@ static inline int Abc_MapBox2Prev( Vec_Ptr_t * vDrivers, Vec_Int_t * vMapIn, Vec
SeeAlso []
***********************************************************************/
static Vec_Vec_t * Io_MvExtractBoxInfo( Abc_Ntk_t * pNtk )
static Vec_Vec_t * Io_MvExtractBoxInfo_( Abc_Ntk_t * pNtk )
{
Vec_Int_t * vMapIn, * vMapOut, * vList;
Vec_Ptr_t * vBoxInfo, * vDrivers;
......@@ -2208,6 +2208,172 @@ static Vec_Vec_t * Io_MvExtractBoxInfo( Abc_Ntk_t * pNtk )
return (Vec_Vec_t *)vBoxInfo;
}
/**Function*************************************************************
Synopsis [Compares strings up to the first underscore.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Io_MvExtractCompareStr( char * pName1, char * pName2 )
{
while ( *pName1 && *pName1 != '_' && (*pName1 == *pName2) )
pName1++, pName2++;
return *pName1 - *pName2;
}
/**Function*************************************************************
Synopsis [Returns the first number of the string.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Io_MvExtractReadNum1( char * pName )
{
while ( *pName && (*pName < '0' || *pName > '9') )
pName++;
if ( *pName == 0 )
return -1;
return atoi( pName );
}
/**Function*************************************************************
Synopsis [Returns the second number of the string.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Io_MvExtractReadNum2( char * pName )
{
int Counter = 0;
while ( *pName )
{
Counter += (*pName++ == '_');
if ( Counter == 2 )
break;
}
if ( *pName == 0 )
return -1;
return atoi( pName );
}
/**Function*************************************************************
Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Io_MvExtractCompareNames( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
{
char * pName1 = (char *)(*pp1)->pCopy;
char * pName2 = (char *)(*pp2)->pCopy;
// int Diff = Io_MvExtractReadNum1(pName1) - Io_MvExtractReadNum1(pName2);
int Diff = Io_MvExtractCompareStr( pName1, pName2 );
if ( Diff < 0 )
return -1;
if ( Diff > 0 )
return 1;
Diff = Io_MvExtractReadNum2(pName1) - Io_MvExtractReadNum2(pName2);
if ( Diff < 0 )
return -1;
if ( Diff > 0 )
return 1;
return 0;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static Vec_Vec_t * Io_MvExtractBoxInfo( Abc_Ntk_t * pNtk )
{
int fVerbose = 0;
Vec_Vec_t * vBoxInfo = NULL;
Vec_Ptr_t * vPetals;
Abc_Obj_t * pObj;
char * pPrev, * pThis;
int i, Level;
// quit if there is no boxes
if ( pNtk->nRealPos == 0 || (Abc_NtkPoNum(pNtk) - pNtk->nRealPos) % 5 != 0 )
return NULL;
// transfer names
Abc_NtkForEachPo( pNtk, pObj, i )
{
pObj->pCopy = (Abc_Obj_t *)Abc_ObjName( Abc_ObjFanin0(pObj) );
pObj->iData = i;
}
// collect POs
vPetals = Vec_PtrAlloc( Abc_NtkPoNum(pNtk) );
for ( i = pNtk->nRealPos; i < Abc_NtkPoNum(pNtk); i += 5 )
Vec_PtrPush( vPetals, Abc_NtkPo(pNtk, i) );
// sort by name
qsort( (void *)Vec_PtrArray(vPetals), Vec_PtrSize(vPetals), sizeof(Abc_Obj_t *),
(int (*)(const void *, const void *)) Io_MvExtractCompareNames );
// sort the POs
Level = -1;
pPrev = "dummy";
vBoxInfo = Vec_VecAlloc( 32 );
Vec_PtrForEachEntry( Abc_Obj_t *, vPetals, pObj, i )
{
pThis = (char *)pObj->pCopy;
if ( Io_MvExtractCompareStr( pPrev, pThis ) )
{
Level++;
if ( fVerbose )
printf( "\n" );
}
Vec_VecPushInt( vBoxInfo, Level, pObj->iData );
if ( fVerbose )
printf( "%s ", (char *)pObj->pCopy );
pPrev = pThis;
}
if ( fVerbose )
printf( "\n" );
if ( 5 * Vec_VecSizeSize(vBoxInfo) != (Abc_NtkPoNum(pNtk) - pNtk->nRealPos) )
printf( "Mismatch in the number of boxes!!!\n" );
// clean up
Vec_PtrFree( vPetals );
// remove names
Abc_NtkForEachPo( pNtk, pObj, i )
{
pObj->pCopy = NULL;
pObj->iData = 0;
}
return vBoxInfo;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
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