abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cgtInt.h File Reference
#include "aig/saig/saig.h"
#include "sat/bsat/satSolver.h"
#include "sat/cnf/cnf.h"
#include "cgt.h"

Go to the source code of this file.

Data Structures

struct  Cgt_Man_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Cgt_Man_t_ 
Cgt_Man_t
 INCLUDES ///. More...
 

Functions

void Cgt_ManDetectCandidates (Aig_Man_t *pAig, Vec_Int_t *vUseful, Aig_Obj_t *pObj, int nLevelMax, Vec_Ptr_t *vCands)
 MACRO DEFINITIONS ///. More...
 
Aig_Man_tCgt_ManDeriveAigForGating (Cgt_Man_t *p)
 
Aig_Man_tCgt_ManDupPartition (Aig_Man_t *pAig, int nVarsMin, int nFlopsMin, int iStart, Aig_Man_t *pCare, Vec_Vec_t *vSuppsInv, int *pnOutputs)
 
Aig_Man_tCgt_ManDeriveGatedAig (Aig_Man_t *pAig, Vec_Vec_t *vGates, int fReduce, int *pnUsedNodes)
 
Vec_Vec_tCgt_ManDecideSimple (Aig_Man_t *pAig, Vec_Vec_t *vGatesAll, int nOdcMax, int fVerbose)
 
Vec_Vec_tCgt_ManDecideArea (Aig_Man_t *pAig, Vec_Vec_t *vGatesAll, int nOdcMax, int fVerbose)
 
Cgt_Man_tCgt_ManCreate (Aig_Man_t *pAig, Aig_Man_t *pCare, Cgt_Par_t *pPars)
 DECLARATIONS ///. More...
 
void Cgt_ManClean (Cgt_Man_t *p)
 
void Cgt_ManStop (Cgt_Man_t *p)
 
int Cgt_CheckImplication (Cgt_Man_t *p, Aig_Obj_t *pGate, Aig_Obj_t *pFlop)
 DECLARATIONS ///. More...
 

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Cgt_Man_t_ Cgt_Man_t

INCLUDES ///.

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

FileName [cgtInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Clock gating package.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
cgtInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 47 of file cgtInt.h.

Function Documentation

int Cgt_CheckImplication ( Cgt_Man_t p,
Aig_Obj_t pGate,
Aig_Obj_t pMiter 
)

DECLARATIONS ///.

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

FileName [cgtSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Clock gating package.]

Synopsis [Checking implications using SAT.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Runs equivalence test for the two nodes.]

Description [Both nodes should be regular and different from each other.]

SideEffects []

SeeAlso []

Definition at line 46 of file cgtSat.c.

47 {
48  int nBTLimit = p->pPars->nConfMax;
49  int pLits[2], RetValue;
50  abctime clk;
51  p->nCalls++;
52 
53  // sanity checks
54  assert( p->pSat && p->pCnf );
55  assert( !Aig_IsComplement(pMiter) );
56  assert( Aig_Regular(pGate) != pMiter );
57 
58  // solve under assumptions
59  // G => !M -- true G & M -- false
60  pLits[0] = toLitCond( p->pCnf->pVarNums[Aig_Regular(pGate)->Id], Aig_IsComplement(pGate) );
61  pLits[1] = toLitCond( p->pCnf->pVarNums[pMiter->Id], 0 );
62 
63 clk = Abc_Clock();
64  RetValue = sat_solver_solve( p->pSat, pLits, pLits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
65 p->timeSat += Abc_Clock() - clk;
66  if ( RetValue == l_False )
67  {
68 p->timeSatUnsat += Abc_Clock() - clk;
69  pLits[0] = lit_neg( pLits[0] );
70  pLits[1] = lit_neg( pLits[1] );
71  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
72  assert( RetValue );
73  sat_solver_compress( p->pSat );
74  p->nCallsUnsat++;
75  return 1;
76  }
77  else if ( RetValue == l_True )
78  {
79 p->timeSatSat += Abc_Clock() - clk;
80  p->nCallsSat++;
81  return 0;
82  }
83  else // if ( RetValue1 == l_Undef )
84  {
85 p->timeSatUndec += Abc_Clock() - clk;
86  p->nCallsUndec++;
87  return -1;
88  }
89  return -2;
90 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
static void sat_solver_compress(sat_solver *s)
Definition: satSolver.h:217
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
#define l_True
Definition: SolverTypes.h:84
static abctime Abc_Clock()
Definition: abc_global.h:279
static lit lit_neg(lit l)
Definition: satVec.h:144
static lit toLitCond(int v, int c)
Definition: satVec.h:143
#define l_False
Definition: SolverTypes.h:85
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int Id
Definition: aig.h:85
void Cgt_ManClean ( Cgt_Man_t p)

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

Synopsis [Creates the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file cgtMan.c.

87 {
88  if ( p->pPart )
89  {
90  Aig_ManStop( p->pPart );
91  p->pPart = NULL;
92  }
93  if ( p->pCnf )
94  {
95  Cnf_DataFree( p->pCnf );
96  p->pCnf = NULL;
97  }
98  if ( p->pSat )
99  {
100  sat_solver_delete( p->pSat );
101  p->pSat = NULL;
102  }
103  if ( p->vPatts )
104  {
105  Vec_PtrFree( p->vPatts );
106  p->vPatts = NULL;
107  }
108 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Cgt_Man_t* Cgt_ManCreate ( Aig_Man_t pAig,
Aig_Man_t pCare,
Cgt_Par_t pPars 
)

DECLARATIONS ///.

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

FileName [cgtMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Clock gating package.]

Synopsis [Manipulation of clock gating manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Creates the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file cgtMan.c.

46 {
47  Cgt_Man_t * p;
48  // prepare the sequential AIG
49  assert( Saig_ManRegNum(pAig) > 0 );
50  Aig_ManFanoutStart( pAig );
51  Aig_ManSetCioIds( pAig );
52  // create interpolation manager
53  p = ABC_ALLOC( Cgt_Man_t, 1 );
54  memset( p, 0, sizeof(Cgt_Man_t) );
55  p->pPars = pPars;
56  p->pAig = pAig;
57  p->vGatesAll = Vec_VecStart( Saig_ManRegNum(pAig) );
58  p->vFanout = Vec_PtrAlloc( 1000 );
59  p->vVisited = Vec_PtrAlloc( 1000 );
60  p->nPattWords = 16;
61  if ( pCare == NULL )
62  return p;
63  // check out the constraints
64  if ( Aig_ManCiNum(pCare) != Aig_ManCiNum(pAig) )
65  {
66  printf( "The PI count of care (%d) and AIG (%d) differ. Careset is not used.\n",
67  Aig_ManCiNum(pCare), Aig_ManCiNum(pAig) );
68  return p;
69  }
70  p->pCare = pCare;
71  p->vSuppsInv = (Vec_Vec_t *)Aig_ManSupportsInverse( p->pCare );
72  return p;
73 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: aigFanout.c:56
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition: aigUtil.c:965
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
Vec_Ptr_t * Aig_ManSupportsInverse(Aig_Man_t *p)
Definition: aigPart.c:385
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Cgt_Man_t_ Cgt_Man_t
INCLUDES ///.
Definition: cgtInt.h:47
Vec_Vec_t* Cgt_ManDecideArea ( Aig_Man_t pAig,
Vec_Vec_t vGatesAll,
int  nOdcMax,
int  fVerbose 
)

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

Synopsis [Computes the set of complete clock gates.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file cgtDecide.c.

256 {
257  Vec_Vec_t * vGates;
258  Vec_Ptr_t * vCompletes, * vOne;
259  Aig_Obj_t * pGate;
260  int i, k, Counter = 0;
261  abctime clk = Abc_Clock();
262  // derive and label complete gates
263  vCompletes = Cgt_ManCompleteGates( pAig, vGatesAll, nOdcMax, fVerbose );
264  // label complete gates
265  Vec_PtrForEachEntry( Aig_Obj_t *, vCompletes, pGate, i )
266  Aig_Regular(pGate)->fMarkA = 1;
267  // select only complete gates
268  vGates = Vec_VecStart( Saig_ManRegNum(pAig) );
269  Vec_VecForEachEntry( Aig_Obj_t *, vGatesAll, pGate, i, k )
270  if ( Aig_Regular(pGate)->fMarkA )
271  Vec_VecPush( vGates, i, pGate );
272  // unlabel complete gates
273  Vec_PtrForEachEntry( Aig_Obj_t *, vCompletes, pGate, i )
274  Aig_Regular(pGate)->fMarkA = 0;
275  // count the number of gated flops
276  Vec_VecForEachLevel( vGates, vOne, i )
277  {
278  Counter += (int)(Vec_PtrSize(vOne) > 0);
279 // printf( "%d ", Vec_PtrSize(vOne) );
280  }
281 // printf( "\n" );
282  if ( fVerbose )
283  {
284  printf( "Gating signals = %6d. Gated flops = %6d. (Total flops = %6d.)\n",
285  Vec_VecSizeSize(vGatesAll), Counter, Saig_ManRegNum(pAig) );
286  printf( "Complete gates = %6d. Gated transitions = %5.2f %%. ",
287  Vec_PtrSize(vCompletes), Cgt_ManComputeCoverage(pAig, vGates) );
288  ABC_PRT( "Time", Abc_Clock() - clk );
289  }
290  Vec_PtrFree( vCompletes );
291  return vGates;
292 }
#define Vec_VecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition: vecVec.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition: vecVec.h:87
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static int Counter
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
Vec_Ptr_t * Cgt_ManCompleteGates(Aig_Man_t *pAig, Vec_Vec_t *vGatesAll, int nOdcMax, int fVerbose)
Definition: cgtDecide.c:124
float Cgt_ManComputeCoverage(Aig_Man_t *pAig, Vec_Vec_t *vGates)
Definition: cgtDecide.c:158
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static int Vec_VecSizeSize(Vec_Vec_t *p)
Definition: vecVec.h:417
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Vec_t* Cgt_ManDecideSimple ( Aig_Man_t pAig,
Vec_Vec_t vGatesAll,
int  nOdcMax,
int  fVerbose 
)

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

Synopsis [Chooses what clock-gate to use for this register.]

Description [Currently uses the naive approach: For each register, choose the clock gate, which covers most of the transitions.]

SideEffects []

SeeAlso []

Definition at line 184 of file cgtDecide.c.

185 {
186  int nFrames = 32;
187  int nWords = 1;
188  Ssw_Sml_t * pSml;
189  Vec_Vec_t * vGates;
190  Vec_Ptr_t * vCands;
191  Aig_Obj_t * pObjLi, * pObjLo, * pCand, * pCandBest;
192  int i, k, nHitsCur, nHitsMax, Counter = 0;
193  abctime clk = Abc_Clock();
194  int nTransTotal = 0, nTransSaved = 0;
195  vGates = Vec_VecStart( Saig_ManRegNum(pAig) );
196  pSml = Ssw_SmlSimulateSeq( pAig, 0, nFrames, nWords );
197  Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
198  {
199  nHitsMax = 0;
200  pCandBest = NULL;
201  vCands = Vec_VecEntry( vGatesAll, i );
202  Vec_PtrForEachEntry( Aig_Obj_t *, vCands, pCand, k )
203  {
204  // check if this is indeed a clock-gate
205  if ( nOdcMax == 0 && !Ssw_SmlCheckXorImplication( pSml, pObjLi, pObjLo, pCand ) )
206  printf( "Clock gate candidate is invalid!\n" );
207  // find its characteristic number
208  nHitsCur = Ssw_SmlNodeCountOnesReal( pSml, pCand );
209  if ( nHitsMax < nHitsCur )
210  {
211  nHitsMax = nHitsCur;
212  pCandBest = pCand;
213  }
214  }
215  if ( pCandBest != NULL )
216  {
217  Vec_VecPush( vGates, i, pCandBest );
218  Counter++;
219  nTransSaved += nHitsMax;
220  }
221  nTransTotal += 32 * nFrames * nWords;
222  }
223  Ssw_SmlStop( pSml );
224  if ( fVerbose )
225  {
226  printf( "Gating signals = %6d. Gated flops = %6d. (Total flops = %6d.)\n",
227  Vec_VecSizeSize(vGatesAll), Counter, Saig_ManRegNum(pAig) );
228 // printf( "Gated transitions = %5.2f %%. (%5.2f %%.) ",
229 // 100.0*nTransSaved/nTransTotal, Cgt_ManComputeCoverage(pAig, vGates) );
230  printf( "Gated transitions = %5.2f %%. ", Cgt_ManComputeCoverage(pAig, vGates) );
231  ABC_PRT( "Time", Abc_Clock() - clk );
232  }
233 /*
234  {
235  Vec_Ptr_t * vCompletes;
236  vCompletes = Cgt_ManCompleteGates( pAig, vGatesAll, nOdcMax, fVerbose );
237  printf( "Complete gates = %d. \n", Vec_PtrSize(vCompletes) );
238  Vec_PtrFree( vCompletes );
239  }
240 */
241  return vGates;
242 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
Ssw_Sml_t * Ssw_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords)
Definition: sswSim.c:1248
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
static abctime Abc_Clock()
Definition: abc_global.h:279
int nWords
Definition: abcNpn.c:127
int Ssw_SmlNodeCountOnesReal(Ssw_Sml_t *p, Aig_Obj_t *pObj)
Definition: sswSim.c:333
Definition: aig.h:69
static int Counter
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
void Ssw_SmlStop(Ssw_Sml_t *p)
Definition: sswSim.c:1211
ABC_NAMESPACE_IMPL_START int Ssw_SmlCheckXorImplication(Ssw_Sml_t *p, Aig_Obj_t *pObjLi, Aig_Obj_t *pObjLo, Aig_Obj_t *pCand)
DECLARATIONS ///.
Definition: sswSim.c:202
float Cgt_ManComputeCoverage(Aig_Man_t *pAig, Vec_Vec_t *vGates)
Definition: cgtDecide.c:158
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static int Vec_VecSizeSize(Vec_Vec_t *p)
Definition: vecVec.h:417
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
Definition: vecVec.h:271
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
DECLARATIONS ///.
Definition: sswSim.c:31
Aig_Man_t* Cgt_ManDeriveAigForGating ( Cgt_Man_t p)

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

Synopsis [Derives AIG for clock-gating.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file cgtAig.c.

267 {
268  Aig_Man_t * pNew;
269  Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pCare, * pMiter;
270  Vec_Ptr_t * vCopy0, * vCopy1;
271  int i;
272  assert( Aig_ManRegNum(p->pAig) );
273  pNew = Aig_ManStart( Aig_ManObjNumMax(p->pAig) );
274  pNew->pName = Abc_UtilStrsav( "CG_miter" );
275  // build the first frame
277  Aig_ManForEachCi( p->pAig, pObj, i )
278  pObj->pData = Aig_ObjCreateCi( pNew );
279  Aig_ManForEachNode( p->pAig, pObj, i )
280  pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
281 // Saig_ManForEachPo( p->pAig, pObj, i )
282 // pObj->pData = Aig_ObjCreateCo( pNew, Aig_ObjChild0Copy(pObj) );
283  if ( p->pPars->nOdcMax > 0 )
284  {
285  // create storage for observability conditions
286  vCopy0 = Vec_PtrStart( Aig_ManObjNumMax(p->pAig) );
287  vCopy1 = Vec_PtrStart( Aig_ManObjNumMax(p->pAig) );
288  // initialize register outputs
289  Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
290  {
291  Vec_PtrWriteEntry( vCopy0, Aig_ObjId(pObjLo), Aig_ObjChild0Copy(pObjLi) );
292  Vec_PtrWriteEntry( vCopy1, Aig_ObjId(pObjLo), Aig_ObjChild0Copy(pObjLi) );
293  }
294  // compute observability condition for each latch output
295  Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
296  {
297  // set the constants
298  Vec_PtrWriteEntry( vCopy0, Aig_ObjId(pObjLo), Aig_ManConst0(pNew) );
299  Vec_PtrWriteEntry( vCopy1, Aig_ObjId(pObjLo), Aig_ManConst1(pNew) );
300  // compute condition
301  pCare = Cgt_ManConstructCareCondition( p, pNew, pObjLo, vCopy0, vCopy1 );
302  // restore the values
303  Vec_PtrWriteEntry( vCopy0, Aig_ObjId(pObjLo), Aig_ObjChild0Copy(pObjLi) );
304  Vec_PtrWriteEntry( vCopy1, Aig_ObjId(pObjLo), Aig_ObjChild0Copy(pObjLi) );
305  // compute the miter
306  pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
307  pMiter = Aig_And( pNew, pMiter, pCare );
308  pObjLi->pData = Aig_ObjCreateCo( pNew, pMiter );
309  }
310  Vec_PtrFree( vCopy0 );
311  Vec_PtrFree( vCopy1 );
312  }
313  else
314  {
315  // construct clock-gating miters for each register input
316  Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
317  {
318  pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
319  pObjLi->pData = Aig_ObjCreateCo( pNew, pMiter );
320  }
321  }
322  Aig_ManCleanup( pNew );
323  Aig_ManSetCioIds( pNew );
324  return pNew;
325 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * pAig
Definition: llb3Image.c:49
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
void * pData
Definition: aig.h:87
Aig_Obj_t * Aig_Exor(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:220
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Aig_Obj_t * Cgt_ManConstructCareCondition(Cgt_Man_t *p, Aig_Man_t *pNew, Aig_Obj_t *pObjLo, Vec_Ptr_t *vCopy0, Vec_Ptr_t *vCopy1)
Definition: cgtAig.c:212
if(last==0)
Definition: sparse_int.h:34
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition: aigUtil.c:965
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Aig_Man_t* Cgt_ManDeriveGatedAig ( Aig_Man_t pAig,
Vec_Vec_t vGates,
int  fReduce,
int *  pnUsedNodes 
)

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

Synopsis [Derives AIG after clock-gating.]

Description [The array contains, for each flop, its gate if present.]

SideEffects []

SeeAlso []

Definition at line 524 of file cgtAig.c.

525 {
526  Aig_Man_t * pNew;
527  Aig_Obj_t * pObj, * pObjNew, * pObjLi, * pObjLo, * pGateNew;
528  Vec_Ptr_t * vOne;
529  int i, k;
530  Aig_ManCleanNext( pAig );
531  // label nodes
532  Vec_VecForEachEntry( Aig_Obj_t *, vGates, pObj, i, k )
533  {
534  if ( Aig_IsComplement(pObj) )
535  Aig_Regular(pObj)->fMarkB = 1;
536  else
537  Aig_Regular(pObj)->fMarkA = 1;
538  }
539  // construct AIG
540  assert( Aig_ManRegNum(pAig) );
541  pNew = Aig_ManStart( Aig_ManObjNumMax(pAig) );
542  pNew->pName = Abc_UtilStrsav( pAig->pName );
543  pNew->pSpec = Abc_UtilStrsav( pAig->pSpec );
544  Aig_ManConst1(pAig)->pData = Aig_ManConst1(pNew);
545  Aig_ManForEachCi( pAig, pObj, i )
546  pObj->pData = Aig_ObjCreateCi( pNew );
547  if ( fReduce )
548  {
549  Aig_ManForEachNode( pAig, pObj, i )
550  {
551  assert( !(pObj->fMarkA && pObj->fMarkB) );
552  pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
553  if ( pObj->fMarkA )
554  {
555  pObj->pNext = (Aig_Obj_t *)pObj->pData;
556  pObj->pData = Aig_ManConst0(pNew);
557  }
558  else if ( pObj->fMarkB )
559  {
560  pObj->pNext = (Aig_Obj_t *)pObj->pData;
561  pObj->pData = Aig_ManConst1(pNew);
562  }
563  }
564  }
565  else
566  {
567  Aig_ManForEachNode( pAig, pObj, i )
568  pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
569  }
570  if ( pnUsedNodes != NULL )
571  *pnUsedNodes = Aig_ManNodeNum(pNew);
572  Saig_ManForEachPo( pAig, pObj, i )
573  pObj->pData = Aig_ObjCreateCo( pNew, Aig_ObjChild0Copy(pObj) );
574  Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
575  {
576  vOne = Vec_VecEntry( vGates, i );
577  if ( Vec_PtrSize(vOne) == 0 )
578  pObjNew = Aig_ObjChild0Copy(pObjLi);
579  else
580  {
581 // pGateNew = Aig_NotCond( Aig_Regular(pGate)->pData, Aig_IsComplement(pGate) );
582  pGateNew = Cgt_ManBuildClockGate( pNew, vOne );
583  pObjNew = Aig_Mux( pNew, pGateNew, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
584  }
585  pObjLi->pData = Aig_ObjCreateCo( pNew, pObjNew );
586  }
587  Aig_ManCleanup( pNew );
588  Aig_ManSetRegNum( pNew, Aig_ManRegNum(pAig) );
589  // unlabel nodes
590  Aig_ManCleanMarkAB( pAig );
591  Aig_ManCleanNext( pAig );
592  return pNew;
593 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
unsigned int fMarkB
Definition: aig.h:80
void * pData
Definition: aig.h:87
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition: vecVec.h:87
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
unsigned int fMarkA
Definition: aig.h:79
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Aig_Obj_t * Cgt_ManBuildClockGate(Aig_Man_t *pNew, Vec_Ptr_t *vGates)
Definition: cgtAig.c:496
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
if(last==0)
Definition: sparse_int.h:34
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
Aig_Obj_t * Aig_Mux(Aig_Man_t *p, Aig_Obj_t *pC, Aig_Obj_t *p1, Aig_Obj_t *p0)
Definition: aigOper.c:317
void Aig_ManCleanMarkAB(Aig_Man_t *p)
Definition: aigUtil.c:186
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
#define assert(ex)
Definition: util_old.h:213
void Aig_ManCleanNext(Aig_Man_t *p)
Definition: aigUtil.c:224
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
Definition: vecVec.h:271
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
void Cgt_ManDetectCandidates ( Aig_Man_t pAig,
Vec_Int_t vUseful,
Aig_Obj_t pObj,
int  nLevelMax,
Vec_Ptr_t vCands 
)

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis [Computes transitive fanout cone of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file cgtAig.c.

71 {
72  Vec_PtrClear( vCands );
73  if ( !Aig_ObjIsNode(pObj) )
74  return;
75  Aig_ManIncrementTravId( pAig );
76  Cgt_ManDetectCandidates_rec( pAig, vUseful, pObj, nLevelMax, vCands );
77 }
ABC_NAMESPACE_IMPL_START void Cgt_ManDetectCandidates_rec(Aig_Man_t *pAig, Vec_Int_t *vUseful, Aig_Obj_t *pObj, int nLevelMax, Vec_Ptr_t *vCands)
DECLARATIONS ///.
Definition: cgtAig.c:45
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Aig_Man_t* Cgt_ManDupPartition ( Aig_Man_t pFrame,
int  nVarsMin,
int  nFlopsMin,
int  iStart,
Aig_Man_t pCare,
Vec_Vec_t vSuppsInv,
int *  pnOutputs 
)

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

Synopsis [Duplicates register outputs starting from the given one.]

Description []

SideEffects []

SeeAlso []

Definition at line 441 of file cgtAig.c.

442 {
443  Vec_Ptr_t * vRoots, * vLeaves, * vPos;
444  Aig_Man_t * pNew;
445  Aig_Obj_t * pObj;
446  int i;
447  assert( Aig_ManRegNum(pFrame) == 0 );
448  vRoots = Vec_PtrAlloc( 100 );
449  vLeaves = Vec_PtrAlloc( 100 );
450  vPos = Vec_PtrAlloc( 100 );
451  pNew = Aig_ManStart( nVarsMin );
452  pNew->pName = Abc_UtilStrsav( "partition" );
453  Aig_ManIncrementTravId( pFrame );
454  Aig_ManConst1(pFrame)->pData = Aig_ManConst1(pNew);
455  Aig_ObjSetTravIdCurrent( pFrame, Aig_ManConst1(pFrame) );
456  for ( i = iStart; i < iStart + nFlopsMin && i < Aig_ManCoNum(pFrame); i++ )
457  {
458  pObj = Aig_ManCo( pFrame, i );
459  Cgt_ManDupPartition_rec( pNew, pFrame, Aig_ObjFanin0(pObj), vLeaves );
460  Vec_PtrPush( vRoots, Aig_ObjChild0Copy(pObj) );
461  Vec_PtrPush( vPos, pObj );
462  }
463  for ( ; Aig_ManObjNum(pNew) < nVarsMin && i < Aig_ManCoNum(pFrame); i++ )
464  {
465  pObj = Aig_ManCo( pFrame, i );
466  Cgt_ManDupPartition_rec( pNew, pFrame, Aig_ObjFanin0(pObj), vLeaves );
467  Vec_PtrPush( vRoots, Aig_ObjChild0Copy(pObj) );
468  Vec_PtrPush( vPos, pObj );
469  }
470  assert( nFlopsMin >= Vec_PtrSize(vRoots) || Vec_PtrSize(vRoots) >= nFlopsMin );
471  // create constaints
472  if ( pCare )
473  Cgt_ManConstructCare( pNew, pCare, vSuppsInv, vLeaves );
474  // create POs
475  Vec_PtrForEachEntry( Aig_Obj_t *, vPos, pObj, i )
476  pObj->pData = (Aig_Obj_t *)Aig_ObjCreateCo( pNew, (Aig_Obj_t *)Vec_PtrEntry(vRoots, i) );
477  if ( pnOutputs != NULL )
478  *pnOutputs = Vec_PtrSize( vPos );
479  Vec_PtrFree( vRoots );
480  Vec_PtrFree( vLeaves );
481  Vec_PtrFree( vPos );
482  return pNew;
483 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Obj_t * Cgt_ManDupPartition_rec(Aig_Man_t *pNew, Aig_Man_t *pAig, Aig_Obj_t *pObj, Vec_Ptr_t *vLeaves)
Definition: cgtAig.c:414
static int Aig_ManObjNum(Aig_Man_t *p)
Definition: aig.h:258
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
void Cgt_ManConstructCare(Aig_Man_t *pNew, Aig_Man_t *pCare, Vec_Vec_t *vSuppsInv, Vec_Ptr_t *vLeaves)
Definition: cgtAig.c:368
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Cgt_ManStop ( Cgt_Man_t p)

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

Synopsis [Frees the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file cgtMan.c.

155 {
156  if ( p->pPars->fVerbose )
157  Cgt_ManPrintStats( p );
158  if ( p->pFrame )
159  Aig_ManStop( p->pFrame );
160  Cgt_ManClean( p );
161  Vec_PtrFree( p->vFanout );
162  Vec_PtrFree( p->vVisited );
163  if ( p->vGates )
164  Vec_PtrFree( p->vGates );
165  if ( p->vGatesAll )
166  Vec_VecFree( p->vGatesAll );
167  if ( p->vSuppsInv )
168  Vec_VecFree( p->vSuppsInv );
169  ABC_FREE( p );
170 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
void Cgt_ManPrintStats(Cgt_Man_t *p)
Definition: cgtMan.c:122
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Cgt_ManClean(Cgt_Man_t *p)
Definition: cgtMan.c:86
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223