From 95af979753aa48744acfcba0a3707fed31391027 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 6 Jul 2015 22:47:47 -0700 Subject: Adding new Python API 'co_supp'. --- src/base/abc/abc.h | 1 + src/base/abc/abcDfs.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'src/base') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index 3374b453..e4136810 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -625,6 +625,7 @@ extern ABC_DLL int Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk ); extern ABC_DLL Vec_Ptr_t * Abc_NtkDfsWithBoxes( Abc_Ntk_t * pNtk ); extern ABC_DLL Vec_Ptr_t * Abc_NtkSupport( Abc_Ntk_t * pNtk ); extern ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes ); +extern ABC_DLL Vec_Int_t * Abc_NtkNodeSupportInt( Abc_Ntk_t * pNtk, int iCo ); extern ABC_DLL Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll, int fCollectCos ); extern ABC_DLL Vec_Ptr_t * Abc_AigDfsMap( Abc_Ntk_t * pNtk ); extern ABC_DLL Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, int fTfi ); diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c index 8784ec1a..1d15f236 100644 --- a/src/base/abc/abcDfs.c +++ b/src/base/abc/abcDfs.c @@ -903,6 +903,57 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod return vNodes; } +/**Function************************************************************* + + Synopsis [Returns the set of CI node IDs in the support of the given node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_NtkNodeSupportInt_rec( Abc_Obj_t * pNode, Vec_Int_t * vNodes ) +{ + Abc_Obj_t * pFanin; + int i; + assert( !Abc_ObjIsNet(pNode) ); + // if this node is already visited, skip + if ( Abc_NodeIsTravIdCurrent( pNode ) ) + return; + // mark the node as visited + Abc_NodeSetTravIdCurrent( pNode ); + // collect the CI + if ( Abc_ObjIsCi(pNode) || (Abc_NtkIsStrash(pNode->pNtk) && Abc_ObjFaninNum(pNode) == 0) ) + { + if ( Abc_ObjIsCi(pNode) ) + Vec_IntPush( vNodes, pNode->iTemp ); + return; + } + assert( Abc_ObjIsNode( pNode ) ); + // visit the transitive fanin of the node + Abc_ObjForEachFanin( pNode, pFanin, i ) + Abc_NtkNodeSupportInt_rec( Abc_ObjFanin0Ntk(pFanin), vNodes ); +} +Vec_Int_t * Abc_NtkNodeSupportInt( Abc_Ntk_t * pNtk, int iCo ) +{ + Vec_Int_t * vNodes; + Abc_Obj_t * pObj; + int i; + if ( iCo < 0 || iCo >= Abc_NtkCoNum(pNtk) ) + return NULL; + // save node indices in the CI nodes + Abc_NtkForEachCi( pNtk, pObj, i ) + pObj->iTemp = i; + // collect the indexes of CI nodes in the TFI of the CO node + Abc_NtkIncrementTravId( pNtk ); + pObj = Abc_NtkCo( pNtk, iCo ); + vNodes = Vec_IntAlloc( 100 ); + Abc_NtkNodeSupportInt_rec( Abc_ObjFanin0(pObj), vNodes ); + return vNodes; +} + /**Function************************************************************* Synopsis [Computes support size of the node.] -- cgit v1.2.3