00001
00021 #include "abc.h"
00022
00026
00027 static Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk );
00028 static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc );
00029
00033
00045 Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fVerbose )
00046 {
00047 Abc_Ntk_t * pNtkNew;
00048 int clk = clock();
00049
00050 assert( Abc_NtkIsStrash(pNtk) );
00051
00052 if ( Abc_NtkBuildGlobalBdds(pNtk, fBddSizeMax, 1, fReorder, fVerbose) == NULL )
00053 return NULL;
00054 if ( fVerbose )
00055 {
00056 DdManager * dd = Abc_NtkGlobalBddMan( pNtk );
00057 printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
00058 PRT( "BDD construction time", clock() - clk );
00059 }
00060
00061
00062 pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
00063
00064 Abc_NtkFreeGlobalBdds( pNtk, 1 );
00065 if ( pNtkNew == NULL )
00066 {
00067
00068
00069 return NULL;
00070 }
00071
00072
00073
00074
00075 Abc_NtkMinimumBase( pNtkNew );
00076
00077 if ( pNtk->pExdc )
00078 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
00079
00080
00081 if ( !Abc_NtkCheck( pNtkNew ) )
00082 {
00083 printf( "Abc_NtkCollapse: The network check has failed.\n" );
00084 Abc_NtkDelete( pNtkNew );
00085 return NULL;
00086 }
00087 return pNtkNew;
00088 }
00089
00101 Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
00102 {
00103 ProgressBar * pProgress;
00104 Abc_Ntk_t * pNtkNew;
00105 Abc_Obj_t * pNode, * pDriver, * pNodeNew;
00106
00107 DdManager * dd = Abc_NtkGlobalBddMan( pNtk );
00108 int i;
00109
00110 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
00111
00112 Cudd_bddIthVar( pNtkNew->pManFunc, dd->size-1 );
00113
00114 pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
00115 Abc_NtkForEachCo( pNtk, pNode, i )
00116 {
00117 Extra_ProgressBarUpdate( pProgress, i, NULL );
00118 pDriver = Abc_ObjFanin0(pNode);
00119 if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
00120 {
00121 Abc_ObjAddFanin( pNode->pCopy, pDriver->pCopy );
00122 continue;
00123 }
00124
00125 pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Abc_ObjGlobalBdd(pNode) );
00126 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
00127 }
00128 Extra_ProgressBarStop( pProgress );
00129 return pNtkNew;
00130 }
00131
00143 Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc )
00144 {
00145 Abc_Obj_t * pNodeNew, * pTemp;
00146 int i;
00147
00148 pNodeNew = Abc_NtkCreateNode( pNtkNew );
00149
00150 Abc_NtkForEachCi( pNtkNew, pTemp, i )
00151 Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, dd->invperm[i]) );
00152
00153 pNodeNew->pData = Extra_TransferLevelByLevel( dd, pNtkNew->pManFunc, bFunc ); Cudd_Ref( pNodeNew->pData );
00154 return pNodeNew;
00155 }
00156
00157
00161
00162