abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaScl.c File Reference
#include "gia.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Gia_ManCombMarkUsed_rec (Gia_Man_t *p, Gia_Obj_t *pObj)
 DECLARATIONS ///. More...
 
int Gia_ManCombMarkUsed (Gia_Man_t *p)
 
Gia_Man_tGia_ManCleanup (Gia_Man_t *p)
 
Gia_Man_tGia_ManCleanupOutputs (Gia_Man_t *p, int nOutputs)
 
int Gia_ManSeqMarkUsed_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRoots)
 
int Gia_ManSeqMarkUsed (Gia_Man_t *p)
 
Gia_Man_tGia_ManSeqCleanup (Gia_Man_t *p)
 
Gia_Man_tGia_ManReduceEquiv (Gia_Man_t *p, int fVerbose)
 
Gia_Man_tGia_ManSeqStructSweep (Gia_Man_t *p, int fConst, int fEquiv, int fVerbose)
 

Function Documentation

Gia_Man_t* Gia_ManCleanup ( Gia_Man_t p)

Function*************************************************************

Synopsis [Performs combinational cleanup.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file giaScl.c.

85 {
87  return Gia_ManDupMarked( p );
88 }
Gia_Man_t * Gia_ManDupMarked(Gia_Man_t *p)
Definition: giaDup.c:975
int Gia_ManCombMarkUsed(Gia_Man_t *p)
Definition: giaScl.c:60
Gia_Man_t* Gia_ManCleanupOutputs ( Gia_Man_t p,
int  nOutputs 
)

Function*************************************************************

Synopsis [Skip the first outputs during cleanup.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file giaScl.c.

102 {
103  Gia_Obj_t * pObj;
104  int i;
105  assert( Gia_ManRegNum(p) == 0 );
106  assert( nOutputs < Gia_ManCoNum(p) );
107  Gia_ManCombMarkUsed( p );
108  Gia_ManForEachCo( p, pObj, i )
109  if ( i < nOutputs )
110  pObj->fMark0 = 1;
111  else
112  break;
113  return Gia_ManDupMarked( p );
114 }
Gia_Man_t * Gia_ManDupMarked(Gia_Man_t *p)
Definition: giaDup.c:975
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
Definition: gia.h:75
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define assert(ex)
Definition: util_old.h:213
int Gia_ManCombMarkUsed(Gia_Man_t *p)
Definition: giaScl.c:60
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
int Gia_ManCombMarkUsed ( Gia_Man_t p)

Definition at line 60 of file giaScl.c.

61 {
62  Gia_Obj_t * pObj;
63  int i, nNodes = 0;
64  Gia_ManForEachObj( p, pObj, i )
65  pObj->fMark0 = Gia_ObjIsAnd(pObj) && !Gia_ObjIsBuf(pObj);
66  Gia_ManForEachBuf( p, pObj, i )
67  nNodes += Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) );
68  Gia_ManForEachCo( p, pObj, i )
69  nNodes += Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) );
70  return nNodes;
71 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
Definition: gia.h:75
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
ABC_NAMESPACE_IMPL_START int Gia_ManCombMarkUsed_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
DECLARATIONS ///.
Definition: giaScl.c:45
#define Gia_ManForEachBuf(p, pObj, i)
Definition: gia.h:998
ABC_NAMESPACE_IMPL_START int Gia_ManCombMarkUsed_rec ( Gia_Man_t p,
Gia_Obj_t pObj 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [giaScl.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Sequential cleanup.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaScl.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Marks unreachable internal nodes and returns their number.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file giaScl.c.

46 {
47  if ( pObj == NULL )
48  return 0;
49  if ( !pObj->fMark0 )
50  return 0;
51  pObj->fMark0 = 0;
52  assert( Gia_ObjIsAnd(pObj) );
53  assert( !Gia_ObjIsBuf(pObj) );
54  return 1 + Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) )
56  + (p->pNexts ? Gia_ManCombMarkUsed_rec( p, Gia_ObjNextObj(p, Gia_ObjId(p, pObj)) ) : 0)
57  + (p->pSibls ? Gia_ManCombMarkUsed_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)) ) : 0)
58  + (p->pMuxes ? Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin2(p, pObj) ) : 0);
59 }
static Gia_Obj_t * Gia_ObjSiblObj(Gia_Man_t *p, int Id)
Definition: gia.h:894
int * pNexts
Definition: gia.h:122
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static Gia_Obj_t * Gia_ObjNextObj(Gia_Man_t *p, int Id)
Definition: gia.h:911
static Gia_Obj_t * Gia_ObjFanin2(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:456
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
ABC_NAMESPACE_IMPL_START int Gia_ManCombMarkUsed_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
DECLARATIONS ///.
Definition: giaScl.c:45
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t* Gia_ManReduceEquiv ( Gia_Man_t p,
int  fVerbose 
)

Function*************************************************************

Synopsis [Find representatives due to identical fanins.]

Description [Returns the old manager if there is no changes.]

SideEffects []

SeeAlso []

Definition at line 200 of file giaScl.c.

201 {
202  Gia_Man_t * pNew;
203  Gia_Obj_t * pObjRi, * pObjRo;
204  unsigned * pCi2Lit, * pMaps;
205  int i, iLit, nFanins = 1, Counter0 = 0, Counter = 0;
206  Gia_ManForEachRi( p, pObjRi, i )
207  Gia_ObjFanin0(pObjRi)->Value = 0;
208  Gia_ManForEachRi( p, pObjRi, i )
209  if ( Gia_ObjFanin0(pObjRi)->Value == 0 )
210  Gia_ObjFanin0(pObjRi)->Value = 2*nFanins++;
211  pCi2Lit = ABC_FALLOC( unsigned, Gia_ManCiNum(p) );
212  pMaps = ABC_FALLOC( unsigned, 2 * nFanins );
213  Gia_ManForEachRiRo( p, pObjRi, pObjRo, i )
214  {
215  iLit = Gia_ObjFanin0Copy( pObjRi );
216  if ( Gia_ObjFaninId0p(p, pObjRi) == 0 && Gia_ObjFaninC0(pObjRi) == 0 ) // const 0
217  pCi2Lit[Gia_ManPiNum(p)+i] = 0, Counter0++;
218  else if ( ~pMaps[iLit] ) // in this case, ID(pObj) > ID(pRepr)
219  pCi2Lit[Gia_ManPiNum(p)+i] = pMaps[iLit], Counter++;
220  else
221  pMaps[iLit] = Abc_Var2Lit( Gia_ObjId(p, pObjRo), 0 );
222  }
223 /*
224  Gia_ManForEachCi( p, pObjRo, i )
225  {
226  if ( ~pCi2Lit[i] )
227  {
228  Gia_Obj_t * pObj0 = Gia_ObjRoToRi(p, pObjRo);
229  Gia_Obj_t * pObj1 = Gia_ObjRoToRi(p, Gia_ManObj(p, pCi2Lit[i]));
230  Gia_Obj_t * pFan0 = Gia_ObjChild0( p, Gia_ObjRoToRi(p, pObjRo) );
231  Gia_Obj_t * pFan1 = Gia_ObjChild0( p, Gia_ObjRoToRi(p, Gia_ManObj(p, pCi2Lit[i])) );
232  assert( pFan0 == pFan1 );
233  }
234  }
235 */
236 // if ( fVerbose )
237 // printf( "ReduceEquiv detected %d constant regs and %d equivalent regs.\n", Counter0, Counter );
238  ABC_FREE( pMaps );
239  if ( Counter0 || Counter )
240  pNew = Gia_ManDupDfsCiMap( p, (int *)pCi2Lit, NULL );
241  else
242  pNew = p;
243  ABC_FREE( pCi2Lit );
244  return pNew;
245 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Definition: gia.h:75
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition: gia.h:1042
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
if(last==0)
Definition: sparse_int.h:34
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Counter
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
Gia_Man_t * Gia_ManDupDfsCiMap(Gia_Man_t *p, int *pCi2Lit, Vec_Int_t *vLits)
Definition: giaDup.c:1890
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
Gia_Man_t* Gia_ManSeqCleanup ( Gia_Man_t p)

Function*************************************************************

Synopsis [Performs sequential cleanup.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file giaScl.c.

184 {
185  Gia_ManSeqMarkUsed( p );
186  return Gia_ManDupMarked( p );
187 }
Gia_Man_t * Gia_ManDupMarked(Gia_Man_t *p)
Definition: giaDup.c:975
int Gia_ManSeqMarkUsed(Gia_Man_t *p)
Definition: giaScl.c:156
int Gia_ManSeqMarkUsed ( Gia_Man_t p)

Function*************************************************************

Synopsis [Marks CIs/COs/ANDs unreachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 156 of file giaScl.c.

157 {
158  Vec_Int_t * vRoots;
159  Gia_Obj_t * pObj;
160  int i, nNodes = 0;
161  Gia_ManSetMark0( p );
162  Gia_ManConst0(p)->fMark0 = 0;
163  Gia_ManForEachPi( p, pObj, i )
164  pObj->fMark0 = 0;
165  vRoots = Gia_ManCollectPoIds( p );
166  Gia_ManForEachObjVec( vRoots, p, pObj, i )
167  nNodes += Gia_ManSeqMarkUsed_rec( p, pObj, vRoots );
168  Vec_IntFree( vRoots );
169  return nNodes;
170 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: gia.h:75
int Gia_ManSeqMarkUsed_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRoots)
Definition: giaScl.c:128
void Gia_ManSetMark0(Gia_Man_t *p)
Definition: giaUtil.c:196
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
unsigned fMark0
Definition: gia.h:79
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
Vec_Int_t * Gia_ManCollectPoIds(Gia_Man_t *p)
Definition: giaUtil.c:863
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
int Gia_ManSeqMarkUsed_rec ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vRoots 
)

Function*************************************************************

Synopsis [Marks CIs/COs/ANDs unreachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 128 of file giaScl.c.

129 {
130  if ( !pObj->fMark0 )
131  return 0;
132  pObj->fMark0 = 0;
133  if ( Gia_ObjIsCo(pObj) )
134  return Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin0(pObj), vRoots );
135  if ( Gia_ObjIsRo(p, pObj) )
136  {
137  Vec_IntPush( vRoots, Gia_ObjId(p, Gia_ObjRoToRi(p, pObj)) );
138  return 0;
139  }
140  assert( Gia_ObjIsAnd(pObj) );
141  return 1 + Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin0(pObj), vRoots )
142  + Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin1(pObj), vRoots );
143 }
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
int Gia_ManSeqMarkUsed_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRoots)
Definition: giaScl.c:128
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t* Gia_ManSeqStructSweep ( Gia_Man_t p,
int  fConst,
int  fEquiv,
int  fVerbose 
)

Function*************************************************************

Synopsis [Performs sequential cleanup.]

Description []

SideEffects []

SeeAlso []

Definition at line 258 of file giaScl.c.

259 {
260  Gia_Man_t * pTemp;
261  if ( Gia_ManRegNum(p) == 0 )
262  return Gia_ManCleanup( p );
263  if ( fVerbose )
264  printf( "Performing sequential cleanup.\n" );
265  p = Gia_ManSeqCleanup( pTemp = p );
266  if ( fVerbose )
267  Gia_ManReportImprovement( pTemp, p );
268  if ( fConst && Gia_ManRegNum(p) )
269  {
270  p = Gia_ManReduceConst( pTemp = p, fVerbose );
271  if ( fVerbose )
272  Gia_ManReportImprovement( pTemp, p );
273  Gia_ManStop( pTemp );
274  }
275  if ( fVerbose && fEquiv )
276  printf( "Merging combinationally equivalent flops.\n" );
277  if ( fEquiv )
278  while ( 1 )
279  {
280  p = Gia_ManSeqCleanup( pTemp = p );
281  if ( fVerbose )
282  Gia_ManReportImprovement( pTemp, p );
283  Gia_ManStop( pTemp );
284  if ( Gia_ManRegNum(p) == 0 )
285  break;
286  p = Gia_ManReduceEquiv( pTemp = p, fVerbose );
287  if ( p == pTemp )
288  break;
289  Gia_ManStop( pTemp );
290  }
291  return p;
292 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Gia_Man_t * Gia_ManReduceConst(Gia_Man_t *pAig, int fVerbose)
Definition: giaTsim.c:737
Gia_Man_t * Gia_ManSeqCleanup(Gia_Man_t *p)
Definition: giaScl.c:183
void Gia_ManReportImprovement(Gia_Man_t *p, Gia_Man_t *pNew)
Definition: giaMan.c:646
Definition: gia.h:95
Gia_Man_t * Gia_ManReduceEquiv(Gia_Man_t *p, int fVerbose)
Definition: giaScl.c:200
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387