ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cgtDecide.c File Reference
#include "cgtInt.h"
#include "proof/ssw/sswInt.h"
Include dependency graph for cgtDecide.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Ssw_SmlCheckXorImplication (Ssw_Sml_t *p, Aig_Obj_t *pObjLi, Aig_Obj_t *pObjLo, Aig_Obj_t *pCand)
 DECLARATIONS ///.
 
int Ssw_SmlCountXorImplication (Ssw_Sml_t *p, Aig_Obj_t *pObjLi, Aig_Obj_t *pObjLo, Aig_Obj_t *pCand)
 
int Ssw_SmlCountEqual (Ssw_Sml_t *p, Aig_Obj_t *pObjLi, Aig_Obj_t *pObjLo)
 
int Ssw_SmlNodeCountOnesReal (Ssw_Sml_t *p, Aig_Obj_t *pObj)
 
int Ssw_SmlNodeCountOnesRealVec (Ssw_Sml_t *p, Vec_Ptr_t *vObjs)
 
void Cgt_ManCollectFanoutPos_rec (Aig_Man_t *pAig, Aig_Obj_t *pObj, Vec_Ptr_t *vFanout)
 FUNCTION DEFINITIONS ///.
 
void Cgt_ManCollectFanoutPos (Aig_Man_t *pAig, Aig_Obj_t *pObj, Vec_Ptr_t *vFanout)
 
int Cgt_ManCheckGateComplete (Aig_Man_t *pAig, Vec_Vec_t *vGatesAll, Aig_Obj_t *pGate, Vec_Ptr_t *vFanout)
 
Vec_Ptr_tCgt_ManCompleteGates (Aig_Man_t *pAig, Vec_Vec_t *vGatesAll, int nOdcMax, int fVerbose)
 
float Cgt_ManComputeCoverage (Aig_Man_t *pAig, Vec_Vec_t *vGates)
 
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)
 

Function Documentation

◆ Cgt_ManCheckGateComplete()

int Cgt_ManCheckGateComplete ( Aig_Man_t * pAig,
Vec_Vec_t * vGatesAll,
Aig_Obj_t * pGate,
Vec_Ptr_t * vFanout )

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

Synopsis [Checks if all PO fanouts can be gated by this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file cgtDecide.c.

98{
99 Vec_Ptr_t * vGates;
100 Aig_Obj_t * pObj;
101 int i;
102 Vec_PtrForEachEntry( Aig_Obj_t *, vFanout, pObj, i )
103 {
104 if ( Saig_ObjIsPo(pAig, pObj) )
105 return 0;
106 vGates = Vec_VecEntry( vGatesAll, Aig_ObjCioId(pObj) - Saig_ManPoNum(pAig) );
107 if ( Vec_PtrFind( vGates, pGate ) == -1 )
108 return 0;
109 }
110 return 1;
111}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Cgt_ManCollectFanoutPos()

void Cgt_ManCollectFanoutPos ( Aig_Man_t * pAig,
Aig_Obj_t * pObj,
Vec_Ptr_t * vFanout )

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

Synopsis [Collects POs in the transitive fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file cgtDecide.c.

80{
81 Vec_PtrClear( vFanout );
83 Cgt_ManCollectFanoutPos_rec( pAig, pObj, vFanout );
84}
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigUtil.c:44
void Cgt_ManCollectFanoutPos_rec(Aig_Man_t *pAig, Aig_Obj_t *pObj, Vec_Ptr_t *vFanout)
FUNCTION DEFINITIONS ///.
Definition cgtDecide.c:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cgt_ManCollectFanoutPos_rec()

void Cgt_ManCollectFanoutPos_rec ( Aig_Man_t * pAig,
Aig_Obj_t * pObj,
Vec_Ptr_t * vFanout )

FUNCTION DEFINITIONS ///.

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

Synopsis [Collects POs in the transitive fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 52 of file cgtDecide.c.

53{
54 Aig_Obj_t * pFanout;
55 int f, iFanout = -1;
56 if ( Aig_ObjIsTravIdCurrent(pAig, pObj) )
57 return;
58 Aig_ObjSetTravIdCurrent(pAig, pObj);
59 if ( Aig_ObjIsCo(pObj) )
60 {
61 Vec_PtrPush( vFanout, pObj );
62 return;
63 }
64 Aig_ObjForEachFanout( pAig, pObj, pFanout, iFanout, f )
65 Cgt_ManCollectFanoutPos_rec( pAig, pFanout, vFanout );
66}
#define Aig_ObjForEachFanout(p, pObj, pFanout, iFan, i)
Definition aig.h:427
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cgt_ManCompleteGates()

Vec_Ptr_t * Cgt_ManCompleteGates ( 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 124 of file cgtDecide.c.

125{
126 Vec_Ptr_t * vFanout, * vGatesFull;
127 Aig_Obj_t * pGate, * pGateR;
128 int i, k;
129 vFanout = Vec_PtrAlloc( 100 );
130 vGatesFull = Vec_PtrAlloc( 100 );
131 Vec_VecForEachEntry( Aig_Obj_t *, vGatesAll, pGate, i, k )
132 {
133 pGateR = Aig_Regular(pGate);
134 if ( pGateR->fMarkA )
135 continue;
136 pGateR->fMarkA = 1;
137 Cgt_ManCollectFanoutPos( pAig, pGateR, vFanout );
138 if ( Cgt_ManCheckGateComplete( pAig, vGatesAll, pGate, vFanout ) )
139 Vec_PtrPush( vGatesFull, pGate );
140 }
141 Vec_PtrFree( vFanout );
142 Vec_VecForEachEntry( Aig_Obj_t *, vGatesAll, pGate, i, k )
143 Aig_Regular(pGate)->fMarkA = 0;
144 return vGatesFull;
145}
void Cgt_ManCollectFanoutPos(Aig_Man_t *pAig, Aig_Obj_t *pObj, Vec_Ptr_t *vFanout)
Definition cgtDecide.c:79
int Cgt_ManCheckGateComplete(Aig_Man_t *pAig, Vec_Vec_t *vGatesAll, Aig_Obj_t *pGate, Vec_Ptr_t *vFanout)
Definition cgtDecide.c:97
unsigned int fMarkA
Definition aig.h:79
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition vecVec.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cgt_ManComputeCoverage()

float Cgt_ManComputeCoverage ( Aig_Man_t * pAig,
Vec_Vec_t * vGates )

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

Synopsis [Calculates coverage.]

Description []

SideEffects []

SeeAlso []

Definition at line 158 of file cgtDecide.c.

159{
160 int nFrames = 32;
161 int nWords = 1;
162 Ssw_Sml_t * pSml;
163 Vec_Ptr_t * vOne;
164 int i, nTransSaved = 0;
165 pSml = Ssw_SmlSimulateSeq( pAig, 0, nFrames, nWords );
166 Vec_VecForEachLevel( vGates, vOne, i )
167 nTransSaved += Ssw_SmlNodeCountOnesRealVec( pSml, vOne );
168 Ssw_SmlStop( pSml );
169 return (float)100.0*nTransSaved/32/nFrames/nWords/Vec_VecSize(vGates);
170}
int nWords
Definition abcNpn.c:127
int Ssw_SmlNodeCountOnesRealVec(Ssw_Sml_t *p, Vec_Ptr_t *vObjs)
Definition sswSim.c:362
struct Ssw_Sml_t_ Ssw_Sml_t
Definition ssw.h:120
Ssw_Sml_t * Ssw_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords)
Definition sswSim.c:1248
void Ssw_SmlStop(Ssw_Sml_t *p)
Definition sswSim.c:1211
#define Vec_VecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecVec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cgt_ManDecideArea()

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}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
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
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cgt_ManDecideSimple()

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}
int Ssw_SmlNodeCountOnesReal(Ssw_Sml_t *p, Aig_Obj_t *pObj)
Definition sswSim.c:333
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
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_SmlCheckXorImplication()

ABC_NAMESPACE_IMPL_START int Ssw_SmlCheckXorImplication ( Ssw_Sml_t * p,
Aig_Obj_t * pObjLi,
Aig_Obj_t * pObjLo,
Aig_Obj_t * pCand )
extern

DECLARATIONS ///.

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

FileName [cgtMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Clock gating package.]

Synopsis [Decide what gate to use for what flop.]

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*************************************************************

Synopsis [Checks implication.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file sswSim.c.

203{
204 unsigned * pSimLi, * pSimLo, * pSimCand;
205 int k;
206 assert( pObjLo->fPhase == 0 );
207 // pObjLi->fPhase may be 1, but the LI simulation data is not complemented!
208 pSimCand = Ssw_ObjSim( p, Aig_Regular(pCand)->Id );
209 pSimLi = Ssw_ObjSim( p, pObjLi->Id );
210 pSimLo = Ssw_ObjSim( p, pObjLo->Id );
211 if ( Aig_Regular(pCand)->fPhase ^ Aig_IsComplement(pCand) )
212 {
213 for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
214 if ( ~pSimCand[k] & (pSimLi[k] ^ pSimLo[k]) )
215 return 0;
216 }
217 else
218 {
219 for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
220 if ( pSimCand[k] & (pSimLi[k] ^ pSimLo[k]) )
221 return 0;
222 }
223 return 1;
224}
Cube * p
Definition exorList.c:222
int Id
Definition aig.h:85
unsigned int fPhase
Definition aig.h:78
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Ssw_SmlCountEqual()

int Ssw_SmlCountEqual ( Ssw_Sml_t * p,
Aig_Obj_t * pObjLi,
Aig_Obj_t * pObjLo )
extern

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

Synopsis [Counts the number of 1s in the implication.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file sswSim.c.

271{
272 unsigned * pSimLi, * pSimLo;
273 int k, Counter = 0;
274 assert( pObjLo->fPhase == 0 );
275 // pObjLi->fPhase may be 1, but the LI simulation data is not complemented!
276 pSimLi = Ssw_ObjSim( p, pObjLi->Id );
277 pSimLo = Ssw_ObjSim( p, pObjLo->Id );
278 for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
279 Counter += Aig_WordCountOnes( ~(pSimLi[k] ^ pSimLo[k]) );
280 return Counter;
281}

◆ Ssw_SmlCountXorImplication()

int Ssw_SmlCountXorImplication ( Ssw_Sml_t * p,
Aig_Obj_t * pObjLi,
Aig_Obj_t * pObjLo,
Aig_Obj_t * pCand )
extern

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

Synopsis [Counts the number of 1s in the implication.]

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file sswSim.c.

238{
239 unsigned * pSimLi, * pSimLo, * pSimCand;
240 int k, Counter = 0;
241 assert( pObjLo->fPhase == 0 );
242 // pObjLi->fPhase may be 1, but the LI simulation data is not complemented!
243 pSimCand = Ssw_ObjSim( p, Aig_Regular(pCand)->Id );
244 pSimLi = Ssw_ObjSim( p, pObjLi->Id );
245 pSimLo = Ssw_ObjSim( p, pObjLo->Id );
246 if ( Aig_Regular(pCand)->fPhase ^ Aig_IsComplement(pCand) )
247 {
248 for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
249 Counter += Aig_WordCountOnes(~pSimCand[k] & ~(pSimLi[k] ^ pSimLo[k]));
250 }
251 else
252 {
253 for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
254 Counter += Aig_WordCountOnes(pSimCand[k] & ~(pSimLi[k] ^ pSimLo[k]));
255 }
256 return Counter;
257}

◆ Ssw_SmlNodeCountOnesReal()

int Ssw_SmlNodeCountOnesReal ( Ssw_Sml_t * p,
Aig_Obj_t * pObj )
extern

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

Synopsis [Counts the number of one's in the pattern of the object.]

Description []

SideEffects []

SeeAlso []

Definition at line 333 of file sswSim.c.

334{
335 unsigned * pSims;
336 int i, Counter = 0;
337 pSims = Ssw_ObjSim(p, Aig_Regular(pObj)->Id);
338 if ( Aig_Regular(pObj)->fPhase ^ Aig_IsComplement(pObj) )
339 {
340 for ( i = 0; i < p->nWordsTotal; i++ )
341 Counter += Aig_WordCountOnes( ~pSims[i] );
342 }
343 else
344 {
345 for ( i = 0; i < p->nWordsTotal; i++ )
346 Counter += Aig_WordCountOnes( pSims[i] );
347 }
348 return Counter;
349}
Here is the caller graph for this function:

◆ Ssw_SmlNodeCountOnesRealVec()

int Ssw_SmlNodeCountOnesRealVec ( Ssw_Sml_t * p,
Vec_Ptr_t * vObjs )
extern

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

Synopsis [Counts the number of one's in the pattern of the objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 362 of file sswSim.c.

363{
364 Aig_Obj_t * pObj;
365 unsigned * pSims, uWord;
366 int i, k, Counter = 0;
367 if ( Vec_PtrSize(vObjs) == 0 )
368 return 0;
369 for ( i = 0; i < p->nWordsTotal; i++ )
370 {
371 uWord = 0;
372 Vec_PtrForEachEntry( Aig_Obj_t *, vObjs, pObj, k )
373 {
374 pSims = Ssw_ObjSim(p, Aig_Regular(pObj)->Id);
375 if ( Aig_Regular(pObj)->fPhase ^ Aig_IsComplement(pObj) )
376 uWord |= ~pSims[i];
377 else
378 uWord |= pSims[i];
379 }
380 Counter += Aig_WordCountOnes( uWord );
381 }
382 return Counter;
383}
Here is the caller graph for this function: