ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
absDup.c
Go to the documentation of this file.
1
20
21#include "abs.h"
22
24
28
32
45{
46 if ( ~pObj->Value )
47 return;
48 assert( Gia_ObjIsAnd(pObj) );
49 Gia_ManDupAbsFlops_rec( pNew, Gia_ObjFanin0(pObj) );
50 Gia_ManDupAbsFlops_rec( pNew, Gia_ObjFanin1(pObj) );
51 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
52}
53
66{
67 Gia_Man_t * pNew, * pTemp;
68 Gia_Obj_t * pObj;
69 int i, nFlops = 0;
71 // start the new manager
72 pNew = Gia_ManStart( 5000 );
73 pNew->pName = Abc_UtilStrsav( p->pName );
74 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
75 // create PIs
76 Gia_ManConst0(p)->Value = 0;
77 Gia_ManForEachPi( p, pObj, i )
78 pObj->Value = Gia_ManAppendCi(pNew);
79 // create additional PIs
80 Gia_ManForEachRo( p, pObj, i )
81 if ( !Vec_IntEntry(vFlopClasses, i) )
82 pObj->Value = Gia_ManAppendCi(pNew);
83 // create ROs
84 Gia_ManForEachRo( p, pObj, i )
85 if ( Vec_IntEntry(vFlopClasses, i) )
86 pObj->Value = Gia_ManAppendCi(pNew);
87 // create POs
88 Gia_ManHashAlloc( pNew );
89 Gia_ManForEachPo( p, pObj, i )
90 {
91 Gia_ManDupAbsFlops_rec( pNew, Gia_ObjFanin0(pObj) );
92 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
93 }
94 // create RIs
95 Gia_ManForEachRi( p, pObj, i )
96 if ( Vec_IntEntry(vFlopClasses, i) )
97 {
98 Gia_ManDupAbsFlops_rec( pNew, Gia_ObjFanin0(pObj) );
99 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
100 nFlops++;
101 }
102 Gia_ManHashStop( pNew );
103 Gia_ManSetRegNum( pNew, nFlops );
104 // clean up
105 pNew = Gia_ManSeqCleanup( pTemp = pNew );
106 Gia_ManStop( pTemp );
107 return pNew;
108}
109
122{
123 Vec_Int_t * vAssigned;
124 Gia_Obj_t * pObj;
125 int i, Entry;
126 vAssigned = Vec_IntAlloc( 1000 );
127 Vec_IntForEachEntry( vGateClasses, Entry, i )
128 {
129 if ( Entry == 0 )
130 continue;
131 assert( Entry > 0 );
132 pObj = Gia_ManObj( p, i );
133 Vec_IntPush( vAssigned, Gia_ObjId(p, pObj) );
134 if ( Gia_ObjIsAnd(pObj) )
135 {
136 Vec_IntPush( vAssigned, Gia_ObjFaninId0p(p, pObj) );
137 Vec_IntPush( vAssigned, Gia_ObjFaninId1p(p, pObj) );
138 }
139 else if ( Gia_ObjIsRo(p, pObj) )
140 Vec_IntPush( vAssigned, Gia_ObjFaninId0p(p, Gia_ObjRoToRi(p, pObj)) );
141 else assert( Gia_ObjIsConst0(pObj) );
142 }
143 Vec_IntUniqify( vAssigned );
144 return vAssigned;
145}
146
158void Gia_ManGlaCollect( Gia_Man_t * p, Vec_Int_t * vGateClasses, Vec_Int_t ** pvPis, Vec_Int_t ** pvPPis, Vec_Int_t ** pvFlops, Vec_Int_t ** pvNodes )
159{
160 Vec_Int_t * vAssigned;
161 Gia_Obj_t * pObj;
162 int i;
163 assert( Gia_ManPoNum(p) == 1 );
164 assert( Vec_IntSize(vGateClasses) == Gia_ManObjNum(p) );
165 // create included objects and their fanins
166 vAssigned = Gia_GlaCollectAssigned( p, vGateClasses );
167 // create additional arrays
168 if ( pvPis ) *pvPis = Vec_IntAlloc( 100 );
169 if ( pvPPis ) *pvPPis = Vec_IntAlloc( 100 );
170 if ( pvFlops ) *pvFlops = Vec_IntAlloc( 100 );
171 if ( pvNodes ) *pvNodes = Vec_IntAlloc( 1000 );
172 Gia_ManForEachObjVec( vAssigned, p, pObj, i )
173 {
174 if ( Gia_ObjIsPi(p, pObj) )
175 { if ( pvPis ) Vec_IntPush( *pvPis, Gia_ObjId(p,pObj) ); }
176 else if ( !Vec_IntEntry(vGateClasses, Gia_ObjId(p,pObj)) )
177 { if ( pvPPis ) Vec_IntPush( *pvPPis, Gia_ObjId(p,pObj) ); }
178 else if ( Gia_ObjIsRo(p, pObj) )
179 { if ( pvFlops ) Vec_IntPush( *pvFlops, Gia_ObjId(p,pObj) ); }
180 else if ( Gia_ObjIsAnd(pObj) )
181 { if ( pvNodes ) Vec_IntPush( *pvNodes, Gia_ObjId(p,pObj) ); }
182 else assert( Gia_ObjIsConst0(pObj) );
183 }
184 Vec_IntFree( vAssigned );
185}
186
199{
200 if ( ~pObj->Value )
201 return;
202 assert( Gia_ObjIsAnd(pObj) );
203 Gia_ManDupAbsGates_rec( pNew, Gia_ObjFanin0(pObj) );
204 Gia_ManDupAbsGates_rec( pNew, Gia_ObjFanin1(pObj) );
205 pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
206}
207
221{
222 Vec_Int_t * vPis, * vPPis, * vFlops, * vNodes;
223 Gia_Man_t * pNew, * pTemp;
224 Gia_Obj_t * pObj, * pCopy;
225 int i;//, nFlops = 0;
226 assert( Gia_ManPoNum(p) == 1 );
227 assert( Vec_IntSize(vGateClasses) == Gia_ManObjNum(p) );
228
229 // create additional arrays
230 Gia_ManGlaCollect( p, vGateClasses, &vPis, &vPPis, &vFlops, &vNodes );
231
232 // start the new manager
233 pNew = Gia_ManStart( 5000 );
234 pNew->pName = Abc_UtilStrsav( p->pName );
235 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
236 // create constant
238 Gia_ManConst0(p)->Value = 0;
239 // create PIs
240 Gia_ManForEachObjVec( vPis, p, pObj, i )
241 pObj->Value = Gia_ManAppendCi(pNew);
242 // create additional PIs
243 Gia_ManForEachObjVec( vPPis, p, pObj, i )
244 pObj->Value = Gia_ManAppendCi(pNew);
245 // create ROs
246 Gia_ManForEachObjVec( vFlops, p, pObj, i )
247 pObj->Value = Gia_ManAppendCi(pNew);
248 // create internal nodes
249 Gia_ManForEachObjVec( vNodes, p, pObj, i )
250 pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
251// Gia_ManDupAbsGates_rec( pNew, pObj );
252 // create PO
253 Gia_ManForEachPo( p, pObj, i )
254 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
255 // create RIs
256 Gia_ManForEachObjVec( vFlops, p, pObj, i )
257 Gia_ObjRoToRi(p, pObj)->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ObjRoToRi(p, pObj)) );
258 Gia_ManSetRegNum( pNew, Vec_IntSize(vFlops) );
259 // clean up
260 pNew = Gia_ManSeqCleanup( pTemp = pNew );
261 // transfer copy values: (p -> pTemp -> pNew) => (p -> pNew)
262 if ( Gia_ManObjNum(pTemp) != Gia_ManObjNum(pNew) )
263 {
264// printf( "Gia_ManDupAbsGates() Internal error: object mismatch.\n" );
265 Gia_ManForEachObj( p, pObj, i )
266 {
267 if ( !~pObj->Value )
268 continue;
269 assert( !Abc_LitIsCompl(pObj->Value) );
270 pCopy = Gia_ObjCopy( pTemp, pObj );
271 if ( !~pCopy->Value )
272 {
273 Vec_IntWriteEntry( vGateClasses, i, 0 );
274 pObj->Value = ~0;
275 continue;
276 }
277 assert( !Abc_LitIsCompl(pCopy->Value) );
278 pObj->Value = pCopy->Value;
279 }
280 }
281 Gia_ManStop( pTemp );
282
283 Vec_IntFree( vPis );
284 Vec_IntFree( vPPis );
285 Vec_IntFree( vFlops );
286 Vec_IntFree( vNodes );
287 return pNew;
288}
289
302{
303 int Counter0, Counter1;
304 if ( p->vFlopClasses == NULL )
305 return;
306 if ( Vec_IntSize(p->vFlopClasses) != Gia_ManRegNum(p) )
307 {
308 printf( "Gia_ManPrintFlopClasses(): The number of flop map entries differs from the number of flops.\n" );
309 return;
310 }
311 Counter0 = Vec_IntCountEntry( p->vFlopClasses, 0 );
312 Counter1 = Vec_IntCountEntry( p->vFlopClasses, 1 );
313 printf( "Flop-level abstraction: Excluded FFs = %d Included FFs = %d (%.2f %%) ",
314 Counter0, Counter1, 100.0*Counter1/(Counter0 + Counter1 + 1) );
315 if ( Counter0 + Counter1 < Gia_ManRegNum(p) )
316 printf( "and there are other FF classes..." );
317 printf( "\n" );
318}
319
332{
333 Vec_Int_t * vPis, * vPPis, * vFlops, * vNodes;
334 int nTotal;
335 if ( p->vGateClasses == NULL )
336 return;
337 if ( Vec_IntSize(p->vGateClasses) != Gia_ManObjNum(p) )
338 {
339 printf( "Gia_ManPrintGateClasses(): The number of flop map entries differs from the number of flops.\n" );
340 return;
341 }
342 // create additional arrays
343 Gia_ManGlaCollect( p, p->vGateClasses, &vPis, &vPPis, &vFlops, &vNodes );
344 nTotal = 1 + Vec_IntSize(vFlops) + Vec_IntSize(vNodes);
345 printf( "Gate-level abstraction: PI = %d PPI = %d FF = %d (%.2f %%) AND = %d (%.2f %%) Obj = %d (%.2f %%)\n",
346 Vec_IntSize(vPis), Vec_IntSize(vPPis),
347 Vec_IntSize(vFlops), 100.0*Vec_IntSize(vFlops)/(Gia_ManRegNum(p)+1),
348 Vec_IntSize(vNodes), 100.0*Vec_IntSize(vNodes)/(Gia_ManAndNum(p)+1),
349 nTotal, 100.0*nTotal /(Gia_ManRegNum(p)+Gia_ManAndNum(p)+1) );
350 Vec_IntFree( vPis );
351 Vec_IntFree( vPPis );
352 Vec_IntFree( vFlops );
353 Vec_IntFree( vNodes );
354}
355
368{
369 Vec_Int_t * vSeens; // objects seen so far
370 Vec_Int_t * vAbs = p->vObjClasses;
371 int i, k, Entry, iStart, iStop = -1, nFrames;
372 int nObjBits, nObjMask, iObj, iFrame, nWords;
373 unsigned * pInfo;
374 int * pCountAll, * pCountUni;
375 if ( vAbs == NULL )
376 return;
377 nFrames = Vec_IntEntry( vAbs, 0 );
378 assert( Vec_IntEntry(vAbs, nFrames+1) == Vec_IntSize(vAbs) );
379 pCountAll = ABC_ALLOC( int, nFrames + 1 );
380 pCountUni = ABC_ALLOC( int, nFrames + 1 );
381 // start storage for seen objects
382 nWords = Abc_BitWordNum( nFrames );
383 vSeens = Vec_IntStart( Gia_ManObjNum(p) * nWords );
384 // get the bitmasks
385 nObjBits = Abc_Base2Log( Gia_ManObjNum(p) );
386 nObjMask = (1 << nObjBits) - 1;
387 assert( Gia_ManObjNum(p) <= nObjMask );
388 // print info about frames
389 printf( "Frame Core F0 F1 F2 F3 ...\n" );
390 for ( i = 0; i < nFrames; i++ )
391 {
392 iStart = Vec_IntEntry( vAbs, i+1 );
393 iStop = Vec_IntEntry( vAbs, i+2 );
394 memset( pCountAll, 0, sizeof(int) * (nFrames + 1) );
395 memset( pCountUni, 0, sizeof(int) * (nFrames + 1) );
396 Vec_IntForEachEntryStartStop( vAbs, Entry, k, iStart, iStop )
397 {
398 iObj = (Entry & nObjMask);
399 iFrame = (Entry >> nObjBits);
400 pInfo = (unsigned *)Vec_IntEntryP( vSeens, nWords * iObj );
401 if ( Abc_InfoHasBit(pInfo, iFrame) == 0 )
402 {
403 Abc_InfoSetBit( pInfo, iFrame );
404 pCountUni[iFrame+1]++;
405 pCountUni[0]++;
406 }
407 pCountAll[iFrame+1]++;
408 pCountAll[0]++;
409 }
410 assert( pCountAll[0] == (iStop - iStart) );
411// printf( "%5d%5d ", pCountAll[0], pCountUni[0] );
412 printf( "%3d :", i );
413 printf( "%7d", pCountAll[0] );
414 if ( i >= 10 )
415 {
416 for ( k = 0; k < 4; k++ )
417 printf( "%5d", pCountAll[k+1] );
418 printf( " ..." );
419 for ( k = i-4; k <= i; k++ )
420 printf( "%5d", pCountAll[k+1] );
421 }
422 else
423 {
424 for ( k = 0; k <= i; k++ )
425 if ( k <= i )
426 printf( "%5d", pCountAll[k+1] );
427 }
428// for ( k = 0; k < nFrames; k++ )
429// if ( k <= i )
430// printf( "%5d", pCountAll[k+1] );
431 printf( "\n" );
432 }
433 assert( iStop == Vec_IntSize(vAbs) );
434 Vec_IntFree( vSeens );
435 ABC_FREE( pCountAll );
436 ABC_FREE( pCountUni );
437}
438
442
443
445
int nWords
Definition abcNpn.c:127
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Gia_Man_t * Gia_ManDupAbsGates(Gia_Man_t *p, Vec_Int_t *vGateClasses)
Definition absDup.c:220
void Gia_ManPrintGateClasses(Gia_Man_t *p)
Definition absDup.c:331
void Gia_ManPrintObjClasses(Gia_Man_t *p)
Definition absDup.c:367
void Gia_ManDupAbsGates_rec(Gia_Man_t *pNew, Gia_Obj_t *pObj)
Definition absDup.c:198
Gia_Man_t * Gia_ManDupAbsFlops(Gia_Man_t *p, Vec_Int_t *vFlopClasses)
FUNCTION DECLARATIONS ///.
Definition absDup.c:65
void Gia_ManPrintFlopClasses(Gia_Man_t *p)
Definition absDup.c:301
void Gia_ManGlaCollect(Gia_Man_t *p, Vec_Int_t *vGateClasses, Vec_Int_t **pvPis, Vec_Int_t **pvPPis, Vec_Int_t **pvFlops, Vec_Int_t **pvNodes)
Definition absDup.c:158
Vec_Int_t * Gia_GlaCollectAssigned(Gia_Man_t *p, Vec_Int_t *vGateClasses)
Definition absDup.c:121
ABC_NAMESPACE_IMPL_START void Gia_ManDupAbsFlops_rec(Gia_Man_t *pNew, Gia_Obj_t *pObj)
DECLARATIONS ///.
Definition absDup.c:44
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
#define Gia_ManForEachRi(p, pObj, i)
Definition gia.h:1254
Gia_Man_t * Gia_ManSeqCleanup(Gia_Man_t *p)
Definition giaScl.c:183
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
#define assert(ex)
Definition util_old.h:213
char * memset()
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryStartStop(vVec, Entry, i, Start, Stop)
Definition vecInt.h:60