From 6f6dba429e3f9d030fcc5a141a2554d7a5d6b5ee Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 30 Sep 2018 23:37:02 -0700 Subject: Visualizingn BDDs without complemented edges in 'show_bdd'. --- src/base/abc/abcShow.c | 31 +++++++++++++++++++++++++------ src/base/abci/abc.c | 18 +++++++++++------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c index e7badb12..f91397df 100644 --- a/src/base/abc/abcShow.c +++ b/src/base/abc/abcShow.c @@ -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************************************************************* diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 679a33d2..820440ac 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -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] \n" ); + Abc_Print( -2, "usage: show_bdd [-cgh] \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: (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; -- cgit v1.2.3