mirror of https://github.com/YosysHQ/abc.git
Adding switch -g to use global rather than local BDDs in 'muxes'.
This commit is contained in:
parent
71f2b40320
commit
c32a2ece07
|
|
@ -761,7 +761,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist( Abc_Ntk_t * pNtk );
|
|||
extern ABC_DLL Abc_Ntk_t * Abc_NtkToNetlistBench( Abc_Ntk_t * pNtk );
|
||||
/*=== abcNtbdd.c ==========================================================*/
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkDeriveFromBdd( void * dd, void * bFunc, char * pNamePo, Vec_Ptr_t * vNamesPi );
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal );
|
||||
extern ABC_DLL void * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fReverse, int fVerbose );
|
||||
extern ABC_DLL void * Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk, int fFreeMan );
|
||||
extern ABC_DLL int Abc_NtkSizeOfGlobalBdds( Abc_Ntk_t * pNtk );
|
||||
|
|
|
|||
|
|
@ -10845,15 +10845,18 @@ usage:
|
|||
int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
Abc_Ntk_t * pNtk, * pNtkRes;
|
||||
int c;
|
||||
int c, fGlobal = 0;
|
||||
|
||||
pNtk = Abc_FrameReadNtk(pAbc);
|
||||
// set defaults
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "gh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
case 'g':
|
||||
fGlobal ^= 1;
|
||||
break;
|
||||
case 'h':
|
||||
goto usage;
|
||||
default:
|
||||
|
|
@ -10867,14 +10870,25 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 1;
|
||||
}
|
||||
|
||||
if ( !Abc_NtkIsBddLogic(pNtk) )
|
||||
if ( fGlobal )
|
||||
{
|
||||
Abc_Print( -1, "Only a BDD logic network can be converted to MUXes.\n" );
|
||||
return 1;
|
||||
if ( !Abc_NtkIsStrash(pNtk) )
|
||||
{
|
||||
Abc_Print( -1, "The current network should be an AIG.\n" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !Abc_NtkIsBddLogic(pNtk) )
|
||||
{
|
||||
Abc_Print( -1, "Only a BDD logic network can be converted to MUXes.\n" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// get the new network
|
||||
pNtkRes = Abc_NtkBddToMuxes( pNtk );
|
||||
pNtkRes = Abc_NtkBddToMuxes( pNtk, fGlobal );
|
||||
if ( pNtkRes == NULL )
|
||||
{
|
||||
Abc_Print( -1, "Converting to MUXes has failed.\n" );
|
||||
|
|
@ -10885,9 +10899,10 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: muxes [-h]\n" );
|
||||
Abc_Print( -2, "usage: muxes [-gh]\n" );
|
||||
Abc_Print( -2, "\t converts the current network into a network derived by\n" );
|
||||
Abc_Print( -2, "\t replacing all nodes by DAGs isomorphic to the local BDDs\n" );
|
||||
Abc_Print( -2, "\t-g : toggle visualizing the global BDDs of primary outputs [default = %s].\n", fGlobal? "yes": "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ ABC_NAMESPACE_IMPL_START
|
|||
|
||||
#ifdef ABC_USE_CUDD
|
||||
|
||||
static void Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
|
||||
static void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
|
||||
static Abc_Obj_t * Abc_NodeBddToMuxes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew );
|
||||
static Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * pNtkNew, st__table * tBdd2Node );
|
||||
|
|
@ -128,13 +129,17 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( void * dd0, void * bFunc, char * pNamePo, Vec_
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk )
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal )
|
||||
{
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
assert( Abc_NtkIsBddLogic(pNtk) );
|
||||
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
|
||||
Abc_NtkBddToMuxesPerform( pNtk, pNtkNew );
|
||||
Abc_NtkFinalize( pNtk, pNtkNew );
|
||||
if ( fGlobal )
|
||||
Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew );
|
||||
else
|
||||
{
|
||||
Abc_NtkBddToMuxesPerform( pNtk, pNtkNew );
|
||||
Abc_NtkFinalize( pNtk, pNtkNew );
|
||||
}
|
||||
// make sure everything is okay
|
||||
if ( !Abc_NtkCheck( pNtkNew ) )
|
||||
{
|
||||
|
|
@ -162,6 +167,7 @@ void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
|
|||
Abc_Obj_t * pNode, * pNodeNew;
|
||||
Vec_Ptr_t * vNodes;
|
||||
int i;
|
||||
assert( Abc_NtkIsBddLogic(pNtk) );
|
||||
// perform conversion in the topological order
|
||||
vNodes = Abc_NtkDfs( pNtk, 0 );
|
||||
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
|
||||
|
|
@ -242,6 +248,51 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t *
|
|||
return pNodeNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Converts the node to MUXes.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
|
||||
{
|
||||
DdManager * dd;
|
||||
Abc_Obj_t * pObj, * pObjNew; int i;
|
||||
st__table * tBdd2Node;
|
||||
assert( Abc_NtkIsStrash(pNtk) );
|
||||
dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, 0, 0 );
|
||||
if ( dd == NULL )
|
||||
{
|
||||
printf( "Construction of global BDDs has failed.\n" );
|
||||
return;
|
||||
}
|
||||
//printf( "Shared BDD size = %6d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
|
||||
|
||||
tBdd2Node = st__init_table( st__ptrcmp, st__ptrhash );
|
||||
Abc_NtkForEachCi( pNtkNew, pObjNew, i )
|
||||
st__insert( tBdd2Node, (char *)Cudd_bddIthVar(dd, i), (char *)pObjNew );
|
||||
|
||||
// complement the global functions
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
{
|
||||
DdNode * bFunc = Abc_ObjGlobalBdd(pObj);
|
||||
pObjNew = Abc_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNtkNew, tBdd2Node );
|
||||
if ( Cudd_IsComplement(bFunc) )
|
||||
pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew );
|
||||
Abc_ObjAddFanin( pObj->pCopy, pObjNew );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
st__free_table( tBdd2Node );
|
||||
Abc_NtkFreeGlobalBdds( pNtk, 0 );
|
||||
Extra_StopManager( dd );
|
||||
Abc_NtkCleanCopy( pNtk );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -604,7 +655,7 @@ ABC_PRT( "Time", Abc_Clock() - clk );
|
|||
#else
|
||||
|
||||
double Abc_NtkSpacePercentage( Abc_Obj_t * pNode ) { return 0.0; }
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk ) { return NULL; }
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal ) { return NULL; }
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1156,7 +1156,7 @@ Aig_Man_t * Llb_ReachableStates( Aig_Man_t * pAig )
|
|||
Cudd_Quit( dd );
|
||||
|
||||
// convert
|
||||
pNtkMuxes = Abc_NtkBddToMuxes( pNtk );
|
||||
pNtkMuxes = Abc_NtkBddToMuxes( pNtk, 0 );
|
||||
Abc_NtkDelete( pNtk );
|
||||
pNtk = Abc_NtkStrash( pNtkMuxes, 0, 1, 0 );
|
||||
Abc_NtkDelete( pNtkMuxes );
|
||||
|
|
|
|||
Loading…
Reference in New Issue