Commit 95af9797 by Alan Mishchenko

Adding new Python API 'co_supp'.

parent 9894fc76
...@@ -625,6 +625,7 @@ extern ABC_DLL int Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk ); ...@@ -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_NtkDfsWithBoxes( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_NtkSupport( 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_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_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_Ptr_t * Abc_AigDfsMap( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, int fTfi ); extern ABC_DLL Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, int fTfi );
......
...@@ -905,6 +905,57 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod ...@@ -905,6 +905,57 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod
/**Function************************************************************* /**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.] Synopsis [Computes support size of the node.]
Description [] Description []
......
...@@ -359,6 +359,31 @@ PyObject* eq_classes() ...@@ -359,6 +359,31 @@ PyObject* eq_classes()
return 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() void _pyabc_array_clear()
{ {
Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame(); Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
...@@ -715,6 +740,7 @@ int _cex_get_po(Abc_Cex_t* pCex); ...@@ -715,6 +740,7 @@ int _cex_get_po(Abc_Cex_t* pCex);
int _cex_get_frame(Abc_Cex_t* pCex); int _cex_get_frame(Abc_Cex_t* pCex);
PyObject* eq_classes(); PyObject* eq_classes();
PyObject* co_supp(int iCo);
void _pyabc_array_clear(); void _pyabc_array_clear();
void _pyabc_array_push(int i); void _pyabc_array_push(int i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment