summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base/abc/abc.h1
-rw-r--r--src/base/abc/abcDfs.c51
-rw-r--r--src/python/pyabc.i26
3 files changed, 78 insertions, 0 deletions
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
@@ -905,6 +905,57 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod
/**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.]
Description []
diff --git a/src/python/pyabc.i b/src/python/pyabc.i
index 91c52872..208235a4 100644
--- a/src/python/pyabc.i
+++ b/src/python/pyabc.i
@@ -359,6 +359,31 @@ PyObject* eq_classes()
return eq_classes;
}
+PyObject* co_supp( int iCo )
+{
+ PyObject* co_supp;
+ Vec_Int_t * vSupp;
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ if ( !pNtk )
+ {
+ Py_RETURN_NONE;
+ }
+
+ vSupp = Abc_NtkNodeSupportInt( pNtk, iCo );
+
+ if( !vSupp )
+ {
+ Py_RETURN_NONE;
+ }
+
+ co_supp = VecInt_To_PyList( vSupp );
+ Vec_IntFree( vSupp );
+
+ return co_supp;
+}
+
void _pyabc_array_clear()
{
Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
@@ -715,6 +740,7 @@ int _cex_get_po(Abc_Cex_t* pCex);
int _cex_get_frame(Abc_Cex_t* pCex);
PyObject* eq_classes();
+PyObject* co_supp(int iCo);
void _pyabc_array_clear();
void _pyabc_array_push(int i);