Visualizingn BDDs without complemented edges in 'show_bdd'.

This commit is contained in:
Alan Mishchenko 2018-09-30 23:37:02 -07:00
parent 6159c95ab3
commit 6f6dba429e
2 changed files with 36 additions and 13 deletions

View File

@ -85,12 +85,13 @@ void Abc_NodeShowBddOne( DdManager * dd, DdNode * bFunc )
SeeAlso []
***********************************************************************/
void Abc_NodeShowBdd( Abc_Obj_t * pNode )
void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl )
{
FILE * pFile;
Vec_Ptr_t * vNamesIn;
char FileNameDot[200];
char * pNameOut;
DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
// create the file name
@ -105,7 +106,14 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode )
// set the node names
vNamesIn = Abc_NodeGetFaninNames( pNode );
pNameOut = Abc_ObjName(pNode);
Cudd_DumpDot( (DdManager *)pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
if ( fCompl )
Cudd_DumpDot( dd, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
else
{
DdNode * bAdd = Cudd_BddToAdd( dd, (DdNode *)pNode->pData ); Cudd_Ref( bAdd );
Cudd_DumpDot( dd, 1, (DdNode **)&bAdd, (char **)vNamesIn->pArray, &pNameOut, pFile );
Cudd_RecursiveDeref( dd, bAdd );
}
Abc_NodeFreeNames( vNamesIn );
Abc_NtkCleanCopy( pNode->pNtk );
fclose( pFile );
@ -113,7 +121,7 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode )
// visualize the file
Abc_ShowFile( FileNameDot );
}
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk )
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl )
{
char FileNameDot[200];
char ** ppNamesIn, ** ppNamesOut;
@ -148,7 +156,18 @@ void Abc_NtkShowBdd( Abc_Ntk_t * pNtk )
// set the node names
ppNamesIn = Abc_NtkCollectCioNames( pNtk, 0 );
ppNamesOut = Abc_NtkCollectCioNames( pNtk, 1 );
Cudd_DumpDot( dd, Abc_NtkCoNum(pNtk), (DdNode **)Vec_PtrArray(vFuncsGlob), ppNamesIn, ppNamesOut, pFile );
if ( fCompl )
Cudd_DumpDot( dd, Abc_NtkCoNum(pNtk), (DdNode **)Vec_PtrArray(vFuncsGlob), ppNamesIn, ppNamesOut, pFile );
else
{
DdNode ** pbAdds = ABC_ALLOC( DdNode *, Vec_PtrSize(vFuncsGlob) );
Vec_PtrForEachEntry( DdNode *, vFuncsGlob, bFunc, i )
{ pbAdds[i] = Cudd_BddToAdd( dd, bFunc ); Cudd_Ref( pbAdds[i] ); }
Cudd_DumpDot( dd, Abc_NtkCoNum(pNtk), pbAdds, ppNamesIn, ppNamesOut, pFile );
Vec_PtrForEachEntry( DdNode *, vFuncsGlob, bFunc, i )
Cudd_RecursiveDeref( dd, pbAdds[i] );
ABC_FREE( pbAdds );
}
ABC_FREE( ppNamesIn );
ABC_FREE( ppNamesOut );
fclose( pFile );
@ -166,8 +185,8 @@ void Abc_NtkShowBdd( Abc_Ntk_t * pNtk )
}
#else
void Abc_NodeShowBdd( Abc_Obj_t * pNode ) {}
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk ) {}
void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl ) {}
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ) {}
#endif
/**Function*************************************************************

View File

@ -3063,16 +3063,19 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c, fGlobal = 0;
extern void Abc_NodeShowBdd( Abc_Obj_t * pNode );
extern void Abc_NtkShowBdd( Abc_Ntk_t * pNtk );
int c, fCompl = 0, fGlobal = 0;
extern void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl );
extern void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl );
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "gh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "cgh" ) ) != EOF )
{
switch ( c )
{
case 'c':
fCompl ^= 1;
break;
case 'g':
fGlobal ^= 1;
break;
@ -3092,7 +3095,7 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( fGlobal )
{
Abc_Ntk_t * pTemp = Abc_NtkIsStrash(pNtk) ? pNtk : Abc_NtkStrash(pNtk, 0, 0, 0);
Abc_NtkShowBdd( pTemp );
Abc_NtkShowBdd( pTemp, fCompl );
if ( pTemp != pNtk )
Abc_NtkDelete( pTemp );
return 0;
@ -3126,11 +3129,11 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
}
Abc_NodeShowBdd( pNode );
Abc_NodeShowBdd( pNode, fCompl );
return 0;
usage:
Abc_Print( -2, "usage: show_bdd [-gh] <node>\n" );
Abc_Print( -2, "usage: show_bdd [-cgh] <node>\n" );
Abc_Print( -2, " uses DOT and GSVIEW to visualize the global BDDs of primary outputs\n" );
Abc_Print( -2, " in terms of primary inputs or the local BDD of a node in terms of its fanins\n" );
#ifdef WIN32
@ -3138,6 +3141,7 @@ usage:
Abc_Print( -2, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
#endif
Abc_Print( -2, "\t<node>: (optional) the node to consider [default = the driver of the first PO]\n");
Abc_Print( -2, "\t-c : toggle visualizing BDD with complemented edges [default = %s].\n", fCompl? "yes": "no" );
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;