summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-03-11 23:06:14 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-03-11 23:06:14 -0700
commit795b5a6ce794f72be156fa80f36f7671e7966b94 (patch)
tree52fde9aca81e343efc841d742abc0a10ef6dd37d /src/base
parent2e97ffdd1ac0b759e8919eb37726d2bbc9b796ab (diff)
downloadabc-795b5a6ce794f72be156fa80f36f7671e7966b94.tar.gz
abc-795b5a6ce794f72be156fa80f36f7671e7966b94.tar.bz2
abc-795b5a6ce794f72be156fa80f36f7671e7966b94.zip
Added command 'nodedup' to duplicate nodes with high fanout.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/abc/abcNtk.c44
-rw-r--r--src/base/abci/abc.c81
2 files changed, 125 insertions, 0 deletions
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c
index 42036f4b..51b12609 100644
--- a/src/base/abc/abcNtk.c
+++ b/src/base/abc/abcNtk.c
@@ -1784,6 +1784,50 @@ void Abc_NtkUnpermute( Abc_Ntk_t * pNtk )
Vec_IntFreeP( &pNtk->vObjPerm );
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkNodeDup( Abc_Ntk_t * pNtkInit, int nLimit, int fVerbose )
+{
+ Vec_Ptr_t * vNodes, * vFanouts;
+ Abc_Ntk_t * pNtk;
+ Abc_Obj_t * pObj, * pObjNew, * pFanin, * pFanout;
+ int i, k;
+ pNtk = Abc_NtkDup( pNtkInit );
+ vNodes = Vec_PtrAlloc( 100 );
+ vFanouts = Vec_PtrAlloc( 100 );
+ do
+ {
+ Vec_PtrClear( vNodes );
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ if ( Abc_ObjFanoutNum(pObj) >= nLimit )
+ Vec_PtrPush( vNodes, pObj );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ {
+ pObjNew = Abc_NtkDupObj( pNtk, pObj, 0 );
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ Abc_ObjAddFanin( pObjNew, pFanin );
+ Abc_NodeCollectFanouts( pObj, vFanouts );
+ Vec_PtrShrink( vFanouts, nLimit / 2 );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, k )
+ Abc_ObjPatchFanin( pFanout, pObj, pObjNew );
+ }
+ if ( fVerbose )
+ printf( "Duplicated %d nodes.\n", Vec_PtrSize(vNodes) );
+ }
+ while ( Vec_PtrSize(vNodes) > 0 );
+ Vec_PtrFree( vFanouts );
+ Vec_PtrFree( vNodes );
+ return pNtk;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 079d1336..eca3eb2a 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -154,6 +154,7 @@ static int Abc_CommandDouble ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandInter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBb2Wb ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandOutdec ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandNodeDup ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandQuaVar ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -596,6 +597,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Various", "inter", Abc_CommandInter, 1 );
Cmd_CommandAdd( pAbc, "Various", "bb2wb", Abc_CommandBb2Wb, 0 );
Cmd_CommandAdd( pAbc, "Various", "outdec", Abc_CommandOutdec, 1 );
+ Cmd_CommandAdd( pAbc, "Various", "nodedup", Abc_CommandNodeDup, 1 );
Cmd_CommandAdd( pAbc, "Various", "test", Abc_CommandTest, 0 );
// Cmd_CommandAdd( pAbc, "Various", "qbf_solve", Abc_CommandTest, 0 );
@@ -8720,6 +8722,82 @@ usage:
SeeAlso []
***********************************************************************/
+int Abc_CommandNodeDup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern Abc_Ntk_t * Abc_NtkNodeDup( Abc_Ntk_t * pNtk, int nLimit, int fVerbose );
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ Abc_Ntk_t * pNtkRes;
+ int c, nLimit = 30;
+ int fVerbose = 0;
+
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+ if ( Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "Only works for logic networks.\n" );
+ return 1;
+ }
+ if ( nLimit < 2 )
+ {
+ Abc_Print( -1, "The fanout limit should be more than 1.\n" );
+ return 1;
+ }
+ pNtkRes = Abc_NtkNodeDup( pNtk, nLimit, fVerbose );
+ if ( pNtkRes == NULL )
+ {
+ Abc_Print( -1, "Command has failed.\n" );
+ return 0;
+ }
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: nodedup [-Nvh]\n" );
+ Abc_Print( -2, "\t duplicates internal nodes with high fanout\n" );
+ Abc_Print( -2, "\t-N num : the number of fanouts to start duplication [default = %d]\n", nLimit );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
@@ -8845,6 +8923,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
extern Vec_Vec_t * Saig_IsoDetectFast( Aig_Man_t * pAig );
extern Aig_Man_t * Abc_NtkToDarBmc( Abc_Ntk_t * pNtk, Vec_Int_t ** pvMap );
+ extern void Abc2_NtkTestGia( char * pFileName, int fVerbose );
if ( pNtk )
{
@@ -8858,6 +8937,8 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
}
Aig_ManStop( pAig );
}
+
+// Abc2_NtkTestGia( "", 1 );
}
return 0;