summaryrefslogtreecommitdiffstats
path: root/src/base/io/ioReadBlifMv.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2011-07-28 13:50:34 +0700
committerAlan Mishchenko <alanmi@berkeley.edu>2011-07-28 13:50:34 +0700
commitfddff7a55b127d592d625eb3df703a51e4386518 (patch)
tree7fcb13c6bb4bad945dc068cd579a7925562b5675 /src/base/io/ioReadBlifMv.c
parent8ed6d8e05f5483cbce7e1256bfce6bdacc085667 (diff)
downloadabc-fddff7a55b127d592d625eb3df703a51e4386518.tar.gz
abc-fddff7a55b127d592d625eb3df703a51e4386518.tar.bz2
abc-fddff7a55b127d592d625eb3df703a51e4386518.zip
Other changes to enable new features in the mapper (bug fix).
Diffstat (limited to 'src/base/io/ioReadBlifMv.c')
-rw-r--r--src/base/io/ioReadBlifMv.c168
1 files changed, 167 insertions, 1 deletions
diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c
index 8564331d..edf68ad6 100644
--- a/src/base/io/ioReadBlifMv.c
+++ b/src/base/io/ioReadBlifMv.c
@@ -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 ///