diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-15 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-15 08:01:00 -0800 |
commit | 0871bffae307e0553e0c5186336189e8b55cf6a6 (patch) | |
tree | 4571d1563fe33a53a57fea1c35fb668b9d33265f /src/aig/gia/giaDfs.c | |
parent | f936cc0680c98ffe51b3a1716c996072d5dbf76c (diff) | |
download | abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.gz abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.bz2 abc-0871bffae307e0553e0c5186336189e8b55cf6a6.zip |
Version abc90215
Diffstat (limited to 'src/aig/gia/giaDfs.c')
-rw-r--r-- | src/aig/gia/giaDfs.c | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/src/aig/gia/giaDfs.c b/src/aig/gia/giaDfs.c new file mode 100644 index 00000000..a978dcc3 --- /dev/null +++ b/src/aig/gia/giaDfs.c @@ -0,0 +1,243 @@ +/**CFile**************************************************************** + + FileName [giaDfs.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [DFS procedures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Counts the support size of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectCis_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSupp ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + Vec_IntPush( vSupp, Gia_ObjId(p, pObj) ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + Gia_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp ); + Gia_ManCollectCis_rec( p, Gia_ObjFanin1(pObj), vSupp ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp ) +{ + Gia_Obj_t * pObj; + int i; + Vec_IntClear( vSupp ); + Gia_ManIncrementTravId( p ); + Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); + for ( i = 0; i < nNodes; i++ ) + { + pObj = Gia_ManObj( p, pNodes[i] ); + if ( Gia_ObjIsCo(pObj) ) + Gia_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp ); + else + Gia_ManCollectCis_rec( p, pObj, vSupp ); + } +} + +/**Function************************************************************* + + Synopsis [Counts the support size of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectAnds_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + return; + assert( Gia_ObjIsAnd(pObj) ); + Gia_ManCollectAnds_rec( p, Gia_ObjFanin0(pObj), vNodes ); + Gia_ManCollectAnds_rec( p, Gia_ObjFanin1(pObj), vNodes ); + Vec_IntPush( vNodes, Gia_ObjId(p, pObj) ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectAnds( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vNodes ) +{ + Gia_Obj_t * pObj; + int i; + Vec_IntClear( vNodes ); + Gia_ManIncrementTravId( p ); + Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); + for ( i = 0; i < nNodes; i++ ) + { + pObj = Gia_ManObj( p, pNodes[i] ); + if ( Gia_ObjIsCo(pObj) ) + Gia_ManCollectAnds_rec( p, Gia_ObjFanin0(pObj), vNodes ); + else + Gia_ManCollectAnds_rec( p, pObj, vNodes ); + } +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSuppSize_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + return 1; + assert( Gia_ObjIsAnd(pObj) ); + return Gia_ManSuppSize_rec( p, Gia_ObjFanin0(pObj) ) + + Gia_ManSuppSize_rec( p, Gia_ObjFanin1(pObj) ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes ) +{ + Gia_Obj_t * pObj; + int i, Counter = 0; + Gia_ManIncrementTravId( p ); + Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); + for ( i = 0; i < nNodes; i++ ) + { + pObj = Gia_ManObj( p, pNodes[i] ); + if ( Gia_ObjIsCo(pObj) ) + Counter += Gia_ManSuppSize_rec( p, Gia_ObjFanin0(pObj) ); + else + Counter += Gia_ManSuppSize_rec( p, pObj ); + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManConeSize_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + return 0; + assert( Gia_ObjIsAnd(pObj) ); + return 1 + Gia_ManConeSize_rec( p, Gia_ObjFanin0(pObj) ) + + Gia_ManConeSize_rec( p, Gia_ObjFanin1(pObj) ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes ) +{ + Gia_Obj_t * pObj; + int i, Counter = 0; + Gia_ManIncrementTravId( p ); + Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); + for ( i = 0; i < nNodes; i++ ) + { + pObj = Gia_ManObj( p, pNodes[i] ); + if ( Gia_ObjIsCo(pObj) ) + Counter += Gia_ManConeSize_rec( p, Gia_ObjFanin0(pObj) ); + else + Counter += Gia_ManConeSize_rec( p, pObj ); + } + return Counter; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + |