Commit c9210580 by Alan Mishchenko

Added static fanout to GIA package.

parent 7fd65344
...@@ -126,6 +126,8 @@ struct Gia_Man_t_ ...@@ -126,6 +126,8 @@ struct Gia_Man_t_
int nTerStates; // the total number of ternary states int nTerStates; // the total number of ternary states
int * pFanData; // the database to store fanout information int * pFanData; // the database to store fanout information
int nFansAlloc; // the size of fanout representation int nFansAlloc; // the size of fanout representation
Vec_Int_t * vFanoutNums; // static fanout
Vec_Int_t * vFanout; // static fanout
int * pMapping; // mapping for each node int * pMapping; // mapping for each node
Vec_Int_t * vLutConfigs; // LUT configurations Vec_Int_t * vLutConfigs; // LUT configurations
Abc_Cex_t * pCexComb; // combinational counter-example Abc_Cex_t * pCexComb; // combinational counter-example
...@@ -624,6 +626,16 @@ static inline void Gia_ClassUndoPair( Gia_Man_t * p, int i ) { a ...@@ -624,6 +626,16 @@ static inline void Gia_ClassUndoPair( Gia_Man_t * p, int i ) { a
for ( assert(Gia_ObjIsHead(p, i)), iObj = Gia_ObjNext(p, i); iObj; iObj = Gia_ObjNext(p, iObj) ) for ( assert(Gia_ObjIsHead(p, i)), iObj = Gia_ObjNext(p, i); iObj; iObj = Gia_ObjNext(p, iObj) )
static inline int Gia_ObjFoffset( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Vec_IntEntry( p->vFanout, Gia_ObjId(p, pObj) ); }
static inline int Gia_ObjFanoutNum( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Vec_IntEntry( p->vFanoutNums, Gia_ObjId(p, pObj) ); }
static inline int Gia_ObjFanoutId( Gia_Man_t * p, Gia_Obj_t * pObj, int i ){ return Vec_IntEntry( p->vFanout, Gia_ObjFoffset(p, pObj) + i ); }
static inline Gia_Obj_t * Gia_ObjFanout0( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ManObj( p, Gia_ObjFanoutId(p, pObj, 0) ); }
static inline Gia_Obj_t * Gia_ObjFanout( Gia_Man_t * p, Gia_Obj_t * pObj, int i ) { return Gia_ManObj( p, Gia_ObjFanoutId(p, pObj, i) ); }
static inline void Gia_ObjSetFanout( Gia_Man_t * p, Gia_Obj_t * pObj, int i, Gia_Obj_t * pFan ) { Vec_IntWriteEntry( p->vFanout, Gia_ObjFoffset(p, pObj) + i, Gia_ObjId(p, pFan) ); }
#define Gia_ObjForEachFanoutStatic( p, pObj, pFanout, i ) \
for ( i = 0; (i < Gia_ObjFanoutNum(p, pObj)) && (((pFanout) = Gia_ObjFanout(p, pObj, i)), 1); i++ )
static inline int Gia_ObjIsLut( Gia_Man_t * p, int Id ) { return p->pMapping[Id] != 0; } static inline int Gia_ObjIsLut( Gia_Man_t * p, int Id ) { return p->pMapping[Id] != 0; }
static inline int Gia_ObjLutSize( Gia_Man_t * p, int Id ) { return p->pMapping[p->pMapping[Id]]; } static inline int Gia_ObjLutSize( Gia_Man_t * p, int Id ) { return p->pMapping[p->pMapping[Id]]; }
static inline int * Gia_ObjLutFanins( Gia_Man_t * p, int Id ) { return p->pMapping + p->pMapping[Id] + 1; } static inline int * Gia_ObjLutFanins( Gia_Man_t * p, int Id ) { return p->pMapping + p->pMapping[Id] + 1; }
...@@ -787,6 +799,8 @@ extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gi ...@@ -787,6 +799,8 @@ extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gi
extern void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout ); extern void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
extern void Gia_ManFanoutStart( Gia_Man_t * p ); extern void Gia_ManFanoutStart( Gia_Man_t * p );
extern void Gia_ManFanoutStop( Gia_Man_t * p ); extern void Gia_ManFanoutStop( Gia_Man_t * p );
extern void Gia_ManStaticFanoutStart( Gia_Man_t * p );
extern void Gia_ManStaticFanoutStop( Gia_Man_t * p );
/*=== giaForce.c =========================================================*/ /*=== giaForce.c =========================================================*/
extern void For_ManExperiment( Gia_Man_t * pGia, int nIters, int fClustered, int fVerbose ); extern void For_ManExperiment( Gia_Man_t * pGia, int nIters, int fClustered, int fVerbose );
/*=== giaFrames.c =========================================================*/ /*=== giaFrames.c =========================================================*/
......
...@@ -41,6 +41,7 @@ static inline int * Gia_FanoutNext( int * pData, int iFan ) { return pData + 5 ...@@ -41,6 +41,7 @@ static inline int * Gia_FanoutNext( int * pData, int iFan ) { return pData + 5
// these two procedures are only here for the use inside the iterator // these two procedures are only here for the use inside the iterator
static inline int Gia_ObjFanout0Int( Gia_Man_t * p, int ObjId ) { assert(ObjId < p->nFansAlloc); return p->pFanData[5*ObjId]; } static inline int Gia_ObjFanout0Int( Gia_Man_t * p, int ObjId ) { assert(ObjId < p->nFansAlloc); return p->pFanData[5*ObjId]; }
static inline int Gia_ObjFanoutNext( Gia_Man_t * p, int iFan ) { assert(iFan/2 < p->nFansAlloc); return p->pFanData[5*(iFan >> 1) + 3 + (iFan & 1)]; } static inline int Gia_ObjFanoutNext( Gia_Man_t * p, int iFan ) { assert(iFan/2 < p->nFansAlloc); return p->pFanData[5*(iFan >> 1) + 3 + (iFan & 1)]; }
// iterator over the fanouts // iterator over the fanouts
#define Gia_ObjForEachFanout( p, pObj, pFanout, iFan, i ) \ #define Gia_ObjForEachFanout( p, pObj, pFanout, iFan, i ) \
for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \ for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \
...@@ -193,6 +194,133 @@ void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout ) ...@@ -193,6 +194,133 @@ void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout )
*pNextC = 0; *pNextC = 0;
} }
/**Function*************************************************************
Synopsis [Compute the map of all edges.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Gia_ManStartFanoutMap( Gia_Man_t * p, Vec_Int_t * vFanoutNums )
{
Vec_Int_t * vEdgeMap;
Gia_Obj_t * pObj;
int i, iOffset;
iOffset = Gia_ManObjNum(p);
vEdgeMap = Vec_IntStart( iOffset + 2 * Gia_ManAndNum(p) + Gia_ManCoNum(p) );
Gia_ManForEachObj( p, pObj, i )
{
Vec_IntWriteEntry( vEdgeMap, i, iOffset );
iOffset += Vec_IntEntry( vFanoutNums, Gia_ObjId(p, pObj) );
}
assert( iOffset <= Vec_IntSize(vEdgeMap) );
return vEdgeMap;
}
/**Function*************************************************************
Synopsis [Allocates static fanout.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManStaticFanoutStart( Gia_Man_t * p )
{
Vec_Int_t * vCounts;
int * pRefsOld;
Gia_Obj_t * pObj, * pFanin;
int i, iFanout;
assert( p->vFanoutNums == NULL );
assert( p->vFanout == NULL );
// recompute reference counters
pRefsOld = p->pRefs; p->pRefs = NULL;
Gia_ManCreateRefs(p);
p->vFanoutNums = Vec_IntAllocArray( p->pRefs, Gia_ManObjNum(p) );
p->pRefs = pRefsOld;
// start the fanout maps
p->vFanout = Gia_ManStartFanoutMap( p, p->vFanoutNums );
// incrementally add fanouts
vCounts = Vec_IntStart( Gia_ManObjNum(p) );
Gia_ManForEachObj( p, pObj, i )
{
if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
{
pFanin = Gia_ObjFanin0(pObj);
iFanout = Vec_IntEntry( vCounts, Gia_ObjId(p, pFanin) );
Gia_ObjSetFanout( p, pFanin, iFanout, pObj );
Vec_IntAddToEntry( vCounts, Gia_ObjId(p, pFanin), 1 );
}
if ( Gia_ObjIsAnd(pObj) )
{
pFanin = Gia_ObjFanin1(pObj);
iFanout = Vec_IntEntry( vCounts, Gia_ObjId(p, pFanin) );
Gia_ObjSetFanout( p, pFanin, iFanout, pObj );
Vec_IntAddToEntry( vCounts, Gia_ObjId(p, pFanin), 1 );
}
}
// double-check the current number of fanouts added
Gia_ManForEachObj( p, pObj, i )
assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(p, pObj) );
Vec_IntFree( vCounts );
}
/**Function*************************************************************
Synopsis [Deallocates static fanout.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManStaticFanoutStop( Gia_Man_t * p )
{
Vec_IntFreeP( &p->vFanoutNums );
Vec_IntFreeP( &p->vFanout );
}
/**Function*************************************************************
Synopsis [Tests static fanout.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManStaticFanoutTest( Gia_Man_t * p )
{
Gia_Obj_t * pObj, * pFanout;
int i, k;
Gia_ManStaticFanoutStart( p );
Gia_ManForEachObj( p, pObj, i )
{
Gia_ObjPrint( p, pObj );
printf( " Fanouts : " );
Gia_ObjForEachFanoutStatic( p, pObj, pFanout, k )
printf( "%5d ", Gia_ObjId(p, pFanout) );
printf( "\n" );
}
Gia_ManStaticFanoutStop( p );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -70,6 +70,7 @@ Gia_Man_t * Gia_ManStart( int nObjsMax ) ...@@ -70,6 +70,7 @@ Gia_Man_t * Gia_ManStart( int nObjsMax )
***********************************************************************/ ***********************************************************************/
void Gia_ManStop( Gia_Man_t * p ) void Gia_ManStop( Gia_Man_t * p )
{ {
Gia_ManStaticFanoutStop( p );
Tim_ManStopP( (Tim_Man_t **)&p->pManTime ); Tim_ManStopP( (Tim_Man_t **)&p->pManTime );
assert( p->pManTime == NULL ); assert( p->pManTime == NULL );
Vec_PtrFreeFree( p->vNamesIn ); Vec_PtrFreeFree( p->vNamesIn );
......
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