00001
00021 #include "ivy.h"
00022
00026
00027 #define IVY_INFINITY 10000
00028
00029 typedef struct Ivy_SuppMan_t_ Ivy_SuppMan_t;
00030 struct Ivy_SuppMan_t_
00031 {
00032 int nLimit;
00033 int nObjs;
00034 int nSize;
00035 char * pMem;
00036 Vec_Vec_t * vLuts;
00037 };
00038
00039 typedef struct Ivy_Supp_t_ Ivy_Supp_t;
00040 struct Ivy_Supp_t_
00041 {
00042 char nSize;
00043 char fMark;
00044 char fMark2;
00045 char fMark3;
00046 int nRefs;
00047 short Delay;
00048 short DelayR;
00049 int pArray[0];
00050 };
00051
00052 static inline Ivy_Supp_t * Ivy_ObjSupp( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
00053 {
00054 return (Ivy_Supp_t *)(((Ivy_SuppMan_t*)pAig->pData)->pMem + pObj->Id * ((Ivy_SuppMan_t*)pAig->pData)->nSize);
00055 }
00056 static inline Ivy_Supp_t * Ivy_ObjSuppStart( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
00057 {
00058 Ivy_Supp_t * pSupp;
00059 pSupp = Ivy_ObjSupp( pAig, pObj );
00060 pSupp->fMark = 0;
00061 pSupp->Delay = 0;
00062 pSupp->nSize = 1;
00063 pSupp->pArray[0] = pObj->Id;
00064 return pSupp;
00065 }
00066
00067 static void Ivy_FastMapPrint( Ivy_Man_t * pAig, int Delay, int Area, int Time, char * pStr );
00068 static int Ivy_FastMapDelay( Ivy_Man_t * pAig );
00069 static int Ivy_FastMapArea( Ivy_Man_t * pAig );
00070 static void Ivy_FastMapNode( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit );
00071 static void Ivy_FastMapNodeArea( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit );
00072 static int Ivy_FastMapMerge( Ivy_Supp_t * pSupp0, Ivy_Supp_t * pSupp1, Ivy_Supp_t * pSupp, int nLimit );
00073 static void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay, int fSetInter );
00074 static void Ivy_FastMapRecover( Ivy_Man_t * pAig, int nLimit );
00075 static int Ivy_FastMapNodeDelay( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
00076 static int Ivy_FastMapNodeAreaRefed( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
00077 static int Ivy_FastMapNodeAreaDerefed( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
00078 static void Ivy_FastMapNodeRecover( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld );
00079 static int Ivy_FastMapNodeRef( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
00080 static int Ivy_FastMapNodeDeref( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
00081
00082
00083 extern int s_MappingTime;
00084 extern int s_MappingMem;
00085
00086
00090
00102 void Ivy_FastMapPerform( Ivy_Man_t * pAig, int nLimit, int fRecovery, int fVerbose )
00103 {
00104 Ivy_SuppMan_t * pMan;
00105 Ivy_Obj_t * pObj;
00106 int i, Delay, Area, clk, clkTotal = clock();
00107
00108 pMan = ALLOC( Ivy_SuppMan_t, 1 );
00109 memset( pMan, 0, sizeof(Ivy_SuppMan_t) );
00110 pMan->nLimit = nLimit;
00111 pMan->nObjs = Ivy_ManObjIdMax(pAig) + 1;
00112 pMan->nSize = sizeof(Ivy_Supp_t) + nLimit * sizeof(int);
00113 pMan->pMem = (char *)malloc( pMan->nObjs * pMan->nSize );
00114 memset( pMan->pMem, 0, pMan->nObjs * pMan->nSize );
00115 pMan->vLuts = Vec_VecAlloc( 100 );
00116 pAig->pData = pMan;
00117 clk = clock();
00118
00119 Ivy_ObjSuppStart( pAig, Ivy_ManConst1(pAig) );
00120 Ivy_ManForEachPi( pAig, pObj, i )
00121 Ivy_ObjSuppStart( pAig, pObj );
00122
00123 Ivy_ManForEachNode( pAig, pObj, i )
00124 Ivy_FastMapNode( pAig, pObj, nLimit );
00125
00126 Delay = Ivy_FastMapDelay( pAig );
00127 Area = Ivy_FastMapArea(pAig);
00128 if ( fVerbose )
00129 Ivy_FastMapPrint( pAig, Delay, Area, clock() - clk, "Delay oriented mapping: " );
00130
00131
00132
00133 if ( fRecovery )
00134 {
00135 clk = clock();
00136 Ivy_FastMapRequired( pAig, Delay, 0 );
00137
00138 Ivy_FastMapRecover( pAig, nLimit );
00139 Delay = Ivy_FastMapDelay( pAig );
00140 Area = Ivy_FastMapArea(pAig);
00141 if ( fVerbose )
00142 Ivy_FastMapPrint( pAig, Delay, Area, clock() - clk, "Area recovery 2 : " );
00143
00144 clk = clock();
00145 Ivy_FastMapRequired( pAig, Delay, 0 );
00146
00147 Ivy_ManForEachNode( pAig, pObj, i )
00148 Ivy_FastMapNodeArea( pAig, pObj, nLimit );
00149 Delay = Ivy_FastMapDelay( pAig );
00150 Area = Ivy_FastMapArea(pAig);
00151 if ( fVerbose )
00152 Ivy_FastMapPrint( pAig, Delay, Area, clock() - clk, "Area recovery 1 : " );
00153
00154 clk = clock();
00155 Ivy_FastMapRequired( pAig, Delay, 0 );
00156
00157 Ivy_FastMapRecover( pAig, nLimit );
00158 Delay = Ivy_FastMapDelay( pAig );
00159 Area = Ivy_FastMapArea(pAig);
00160 if ( fVerbose )
00161 Ivy_FastMapPrint( pAig, Delay, Area, clock() - clk, "Area recovery 2 : " );
00162 }
00163
00164
00165 s_MappingTime = clock() - clkTotal;
00166 s_MappingMem = pMan->nObjs * pMan->nSize;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 }
00178
00190 void Ivy_FastMapStop( Ivy_Man_t * pAig )
00191 {
00192 Ivy_SuppMan_t * p = pAig->pData;
00193 Vec_VecFree( p->vLuts );
00194 free( p->pMem );
00195 free( p );
00196 pAig->pData = NULL;
00197 }
00198
00210 void Ivy_FastMapPrint( Ivy_Man_t * pAig, int Delay, int Area, int Time, char * pStr )
00211 {
00212 printf( "%s : Delay = %3d. Area = %6d. ", pStr, Delay, Area );
00213 PRT( "Time", Time );
00214 }
00215
00227 int Ivy_FastMapDelay( Ivy_Man_t * pAig )
00228 {
00229 Ivy_Supp_t * pSupp;
00230 Ivy_Obj_t * pObj;
00231 int i, DelayMax = 0;
00232 Ivy_ManForEachPo( pAig, pObj, i )
00233 {
00234 pObj = Ivy_ObjFanin0(pObj);
00235 if ( !Ivy_ObjIsNode(pObj) )
00236 continue;
00237 pSupp = Ivy_ObjSupp( pAig, pObj );
00238 if ( DelayMax < pSupp->Delay )
00239 DelayMax = pSupp->Delay;
00240 }
00241 return DelayMax;
00242 }
00243
00255 int Ivy_FastMapArea_rec( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Vec_t * vLuts )
00256 {
00257 Ivy_Supp_t * pSupp;
00258 int i, Counter;
00259 pSupp = Ivy_ObjSupp( pAig, pObj );
00260
00261 if ( pSupp->fMark || pSupp->nSize == 1 )
00262 return 0;
00263 pSupp->fMark = 1;
00264
00265 Counter = 0;
00266 for ( i = 0; i < pSupp->nSize; i++ )
00267 Counter += Ivy_FastMapArea_rec( pAig, Ivy_ManObj(pAig, pSupp->pArray[i]), vLuts );
00268
00269 Vec_VecPush( vLuts, pSupp->Delay, pObj );
00270 return 1 + Counter;
00271 }
00272
00284 int Ivy_FastMapArea( Ivy_Man_t * pAig )
00285 {
00286 Vec_Vec_t * vLuts;
00287 Ivy_Obj_t * pObj;
00288 int i, Counter = 0;
00289
00290 vLuts = ((Ivy_SuppMan_t *)pAig->pData)->vLuts;
00291 Vec_VecClear( vLuts );
00292
00293 Ivy_ManForEachPo( pAig, pObj, i )
00294 Counter += Ivy_FastMapArea_rec( pAig, Ivy_ObjFanin0(pObj), vLuts );
00295
00296 Ivy_ManForEachNode( pAig, pObj, i )
00297 Ivy_ObjSupp( pAig, pObj )->fMark = 0;
00298 return Counter;
00299 }
00300
00312 static inline Ivy_ObjIsNodeInt1( Ivy_Obj_t * pObj )
00313 {
00314 return Ivy_ObjIsNode(pObj) && Ivy_ObjRefs(pObj) == 1;
00315 }
00316
00328 static inline Ivy_ObjIsNodeInt2( Ivy_Obj_t * pObj )
00329 {
00330 return Ivy_ObjIsNode(pObj) && Ivy_ObjRefs(pObj) <= 2;
00331 }
00332
00344 static inline void Vec_IntSelectSort( int * pArray, int nSize )
00345 {
00346 int temp, i, j, best_i;
00347 for ( i = 0; i < nSize-1; i++ )
00348 {
00349 best_i = i;
00350 for ( j = i+1; j < nSize; j++ )
00351 if ( pArray[j] < pArray[best_i] )
00352 best_i = j;
00353 temp = pArray[i];
00354 pArray[i] = pArray[best_i];
00355 pArray[best_i] = temp;
00356 }
00357 }
00358
00370 static inline int Vec_IntRemoveDup( int * pArray, int nSize )
00371 {
00372 int i, k;
00373 if ( nSize < 2 )
00374 return nSize;
00375 for ( i = k = 1; i < nSize; i++ )
00376 if ( pArray[i] != pArray[i-1] )
00377 pArray[k++] = pArray[i];
00378 return k;
00379 }
00380
00392 void Ivy_FastMapNodeArea2( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
00393 {
00394 static int Store[32], StoreSize;
00395 static char Supp0[16], Supp1[16];
00396 static Ivy_Supp_t * pTemp0 = (Ivy_Supp_t *)Supp0;
00397 static Ivy_Supp_t * pTemp1 = (Ivy_Supp_t *)Supp1;
00398 Ivy_Obj_t * pFanin0, * pFanin1;
00399 Ivy_Supp_t * pSupp0, * pSupp1, * pSupp;
00400 int RetValue, DelayOld;
00401 assert( nLimit <= 32 );
00402 assert( Ivy_ObjIsNode(pObj) );
00403
00404 pFanin0 = Ivy_ObjFanin0(pObj);
00405 pFanin1 = Ivy_ObjFanin1(pObj);
00406
00407 pSupp0 = Ivy_ObjSupp( pAig, pFanin0 );
00408 pSupp1 = Ivy_ObjSupp( pAig, pFanin1 );
00409 pSupp = Ivy_ObjSupp( pAig, pObj );
00410 assert( pSupp->fMark == 0 );
00411
00412 DelayOld = Ivy_FastMapNodeDelay(pAig, pObj);
00413 assert( DelayOld <= pSupp->DelayR );
00414
00415 memcpy( Store, pSupp->pArray, sizeof(int) * pSupp->nSize );
00416 StoreSize = pSupp->nSize;
00417
00418 if ( Ivy_ObjRefs(pFanin0) > 1 && pSupp0->Delay < pSupp->DelayR )
00419 {
00420 pSupp0 = pTemp0;
00421 pSupp0->nSize = 1;
00422 pSupp0->pArray[0] = Ivy_ObjFaninId0(pObj);
00423 }
00424
00425 if ( Ivy_ObjRefs(pFanin1) > 1 && pSupp1->Delay < pSupp->DelayR )
00426 {
00427 pSupp1 = pTemp1;
00428 pSupp1->nSize = 1;
00429 pSupp1->pArray[0] = Ivy_ObjFaninId1(pObj);
00430 }
00431
00432 if ( pSupp0->nSize < pSupp1->nSize )
00433 RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
00434 else
00435 RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
00436 if ( !RetValue )
00437 {
00438 pSupp->nSize = 2;
00439 pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
00440 pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
00441 }
00442
00443 pSupp->Delay = Ivy_FastMapNodeDelay(pAig, pObj);
00444 if ( pSupp->Delay > pSupp->DelayR )
00445 {
00446 pSupp->nSize = StoreSize;
00447 memcpy( pSupp->pArray, Store, sizeof(int) * pSupp->nSize );
00448 pSupp->Delay = DelayOld;
00449 }
00450 }
00451
00463 void Ivy_FastMapNodeArea( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
00464 {
00465 static int Store[32], StoreSize;
00466 static char Supp0[16], Supp1[16];
00467 static Ivy_Supp_t * pTemp0 = (Ivy_Supp_t *)Supp0;
00468 static Ivy_Supp_t * pTemp1 = (Ivy_Supp_t *)Supp1;
00469 Ivy_Obj_t * pFanin0, * pFanin1;
00470 Ivy_Supp_t * pSupp0, * pSupp1, * pSupp;
00471 int RetValue, DelayOld, RefsOld;
00472 int AreaBef, AreaAft;
00473 assert( nLimit <= 32 );
00474 assert( Ivy_ObjIsNode(pObj) );
00475
00476 pFanin0 = Ivy_ObjFanin0(pObj);
00477 pFanin1 = Ivy_ObjFanin1(pObj);
00478
00479 pSupp0 = Ivy_ObjSupp( pAig, pFanin0 );
00480 pSupp1 = Ivy_ObjSupp( pAig, pFanin1 );
00481 pSupp = Ivy_ObjSupp( pAig, pObj );
00482 assert( pSupp->fMark == 0 );
00483
00484
00485 if ( pSupp->nRefs == 0 )
00486 AreaBef = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
00487 else
00488 AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
00489
00490
00491
00492
00493 if ( pSupp->nRefs != 0 )
00494 Ivy_FastMapNodeDeref( pAig, pObj );
00495
00496
00497 DelayOld = Ivy_FastMapNodeDelay(pAig, pObj);
00498 assert( DelayOld <= pSupp->DelayR );
00499
00500 memcpy( Store, pSupp->pArray, sizeof(int) * pSupp->nSize );
00501 StoreSize = pSupp->nSize;
00502
00503 if ( Ivy_ObjRefs(pFanin0) > 2 && pSupp0->Delay < pSupp->DelayR )
00504
00505 {
00506 pSupp0 = pTemp0;
00507 pSupp0->nSize = 1;
00508 pSupp0->pArray[0] = Ivy_ObjFaninId0(pObj);
00509 }
00510
00511 if ( Ivy_ObjRefs(pFanin1) > 2 && pSupp1->Delay < pSupp->DelayR )
00512
00513 {
00514 pSupp1 = pTemp1;
00515 pSupp1->nSize = 1;
00516 pSupp1->pArray[0] = Ivy_ObjFaninId1(pObj);
00517 }
00518
00519 if ( pSupp0->nSize < pSupp1->nSize )
00520 RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
00521 else
00522 RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
00523 if ( !RetValue )
00524 {
00525 pSupp->nSize = 2;
00526 pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
00527 pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
00528 }
00529
00530
00531 pSupp->Delay = Ivy_FastMapNodeDelay(pAig, pObj);
00532
00533 RefsOld = pSupp->nRefs; pSupp->nRefs = 0;
00534 AreaAft = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
00535 pSupp->nRefs = RefsOld;
00536
00537 if ( AreaAft > AreaBef || pSupp->Delay > pSupp->DelayR )
00538
00539 {
00540 pSupp->nSize = StoreSize;
00541 memcpy( pSupp->pArray, Store, sizeof(int) * pSupp->nSize );
00542 pSupp->Delay = DelayOld;
00543
00544 }
00545
00546
00547
00548 if ( pSupp->nRefs != 0 )
00549 Ivy_FastMapNodeRef( pAig, pObj );
00550 }
00551
00563 void Ivy_FastMapNode( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
00564 {
00565 Ivy_Supp_t * pSupp0, * pSupp1, * pSupp;
00566 int fFaninParam = 2;
00567 int RetValue;
00568 assert( Ivy_ObjIsNode(pObj) );
00569
00570 pSupp0 = Ivy_ObjSupp( pAig, Ivy_ObjFanin0(pObj) );
00571 pSupp1 = Ivy_ObjSupp( pAig, Ivy_ObjFanin1(pObj) );
00572 pSupp = Ivy_ObjSupp( pAig, pObj );
00573 pSupp->fMark = 0;
00574
00575 if ( pSupp0->Delay == pSupp1->Delay )
00576 pSupp->Delay = (pSupp0->Delay == 0) ? pSupp0->Delay + 1: pSupp0->Delay;
00577 else if ( pSupp0->Delay > pSupp1->Delay )
00578 {
00579 pSupp->Delay = pSupp0->Delay;
00580 pSupp1 = Ivy_ObjSupp( pAig, Ivy_ManConst1(pAig) );
00581 pSupp1->pArray[0] = Ivy_ObjFaninId1(pObj);
00582 }
00583 else
00584 {
00585 pSupp->Delay = pSupp1->Delay;
00586 pSupp0 = Ivy_ObjSupp( pAig, Ivy_ManConst1(pAig) );
00587 pSupp0->pArray[0] = Ivy_ObjFaninId0(pObj);
00588 }
00589
00590 if ( pSupp0->nSize < pSupp1->nSize )
00591 RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
00592 else
00593 RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
00594 if ( !RetValue )
00595 {
00596 pSupp->Delay++;
00597 if ( fFaninParam == 2 )
00598 {
00599 pSupp->nSize = 2;
00600 pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
00601 pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
00602 }
00603 else if ( fFaninParam == 3 )
00604 {
00605 Ivy_Obj_t * pFanin0, * pFanin1, * pFaninA, * pFaninB;
00606 pFanin0 = Ivy_ObjFanin0(pObj);
00607 pFanin1 = Ivy_ObjFanin1(pObj);
00608 pSupp->nSize = 0;
00609
00610 if ( Ivy_ObjIsNodeInt1(pFanin0) )
00611 {
00612 pFaninA = Ivy_ObjFanin0(pFanin0);
00613 pFaninB = Ivy_ObjFanin1(pFanin0);
00614 if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
00615 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
00616 else
00617 {
00618 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
00619 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
00620 }
00621 }
00622 else
00623 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
00624
00625 if ( Ivy_ObjIsNodeInt1(pFanin1) )
00626 {
00627 pFaninA = Ivy_ObjFanin0(pFanin1);
00628 pFaninB = Ivy_ObjFanin1(pFanin1);
00629 if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
00630 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
00631 else
00632 {
00633 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
00634 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
00635 }
00636 }
00637 else
00638 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
00639
00640 Vec_IntSelectSort( pSupp->pArray, pSupp->nSize );
00641 pSupp->nSize = Vec_IntRemoveDup( pSupp->pArray, pSupp->nSize );
00642 assert( pSupp->pArray[0] < pSupp->pArray[1] );
00643 }
00644 else if ( fFaninParam == 4 )
00645 {
00646 Ivy_Obj_t * pFanin0, * pFanin1, * pFaninA, * pFaninB;
00647 pFanin0 = Ivy_ObjFanin0(pObj);
00648 pFanin1 = Ivy_ObjFanin1(pObj);
00649 pSupp->nSize = 0;
00650
00651 if ( Ivy_ObjIsNodeInt1(pFanin0) ^ Ivy_ObjIsNodeInt1(pFanin1) )
00652 {
00653 pSupp0 = Ivy_ObjSupp( pAig, Ivy_ObjFanin0(pObj) );
00654 pSupp1 = Ivy_ObjSupp( pAig, Ivy_ObjFanin1(pObj) );
00655 if ( Ivy_ObjIsNodeInt1(pFanin0) && pSupp0->nSize < nLimit )
00656 {
00657 pSupp->Delay = IVY_MAX( pSupp0->Delay, pSupp1->Delay + 1 );
00658 pSupp1 = Ivy_ObjSupp( pAig, Ivy_ManConst1(pAig) );
00659 pSupp1->pArray[0] = Ivy_ObjId(pFanin1);
00660
00661 RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
00662 assert( RetValue );
00663 assert( pSupp->nSize > 1 );
00664 return;
00665 }
00666 if ( Ivy_ObjIsNodeInt1(pFanin1) && pSupp1->nSize < nLimit )
00667 {
00668 pSupp->Delay = IVY_MAX( pSupp1->Delay, pSupp0->Delay + 1 );
00669 pSupp0 = Ivy_ObjSupp( pAig, Ivy_ManConst1(pAig) );
00670 pSupp0->pArray[0] = Ivy_ObjId(pFanin0);
00671
00672 RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
00673 assert( RetValue );
00674 assert( pSupp->nSize > 1 );
00675 return;
00676 }
00677 }
00678
00679 if ( Ivy_ObjIsNodeInt1(pFanin0) )
00680 {
00681 pFaninA = Ivy_ObjFanin0(pFanin0);
00682 pFaninB = Ivy_ObjFanin1(pFanin0);
00683 if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
00684 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
00685 else
00686 {
00687 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
00688 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
00689 }
00690 }
00691 else
00692 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
00693
00694 if ( Ivy_ObjIsNodeInt1(pFanin1) )
00695 {
00696 pFaninA = Ivy_ObjFanin0(pFanin1);
00697 pFaninB = Ivy_ObjFanin1(pFanin1);
00698 if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
00699 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
00700 else
00701 {
00702 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
00703 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
00704 }
00705 }
00706 else
00707 pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
00708
00709 Vec_IntSelectSort( pSupp->pArray, pSupp->nSize );
00710 pSupp->nSize = Vec_IntRemoveDup( pSupp->pArray, pSupp->nSize );
00711 assert( pSupp->pArray[0] < pSupp->pArray[1] );
00712 assert( pSupp->nSize > 1 );
00713 }
00714 }
00715 assert( pSupp->Delay > 0 );
00716 }
00717
00729 int Ivy_FastMapMerge( Ivy_Supp_t * pSupp0, Ivy_Supp_t * pSupp1, Ivy_Supp_t * pSupp, int nLimit )
00730 {
00731 int i, k, c;
00732 assert( pSupp0->nSize >= pSupp1->nSize );
00733
00734 if ( pSupp0->nSize == nLimit && pSupp1->nSize == nLimit )
00735 {
00736 for ( i = 0; i < pSupp0->nSize; i++ )
00737 if ( pSupp0->pArray[i] != pSupp1->pArray[i] )
00738 return 0;
00739 for ( i = 0; i < pSupp0->nSize; i++ )
00740 pSupp->pArray[i] = pSupp0->pArray[i];
00741 pSupp->nSize = pSupp0->nSize;
00742 return 1;
00743 }
00744
00745 if ( pSupp0->nSize == nLimit )
00746 {
00747 for ( i = 0; i < pSupp1->nSize; i++ )
00748 {
00749 for ( k = pSupp0->nSize - 1; k >= 0; k-- )
00750 if ( pSupp0->pArray[k] == pSupp1->pArray[i] )
00751 break;
00752 if ( k == -1 )
00753 return 0;
00754 }
00755 for ( i = 0; i < pSupp0->nSize; i++ )
00756 pSupp->pArray[i] = pSupp0->pArray[i];
00757 pSupp->nSize = pSupp0->nSize;
00758 return 1;
00759 }
00760
00761
00762 i = k = 0;
00763 for ( c = 0; c < nLimit; c++ )
00764 {
00765 if ( k == pSupp1->nSize )
00766 {
00767 if ( i == pSupp0->nSize )
00768 {
00769 pSupp->nSize = c;
00770 return 1;
00771 }
00772 pSupp->pArray[c] = pSupp0->pArray[i++];
00773 continue;
00774 }
00775 if ( i == pSupp0->nSize )
00776 {
00777 if ( k == pSupp1->nSize )
00778 {
00779 pSupp->nSize = c;
00780 return 1;
00781 }
00782 pSupp->pArray[c] = pSupp1->pArray[k++];
00783 continue;
00784 }
00785 if ( pSupp0->pArray[i] < pSupp1->pArray[k] )
00786 {
00787 pSupp->pArray[c] = pSupp0->pArray[i++];
00788 continue;
00789 }
00790 if ( pSupp0->pArray[i] > pSupp1->pArray[k] )
00791 {
00792 pSupp->pArray[c] = pSupp1->pArray[k++];
00793 continue;
00794 }
00795 pSupp->pArray[c] = pSupp0->pArray[i++];
00796 k++;
00797 }
00798 if ( i < pSupp0->nSize || k < pSupp1->nSize )
00799 return 0;
00800 pSupp->nSize = c;
00801 return 1;
00802 }
00803
00815 void Ivy_FastMapReadSupp( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Int_t * vLeaves )
00816 {
00817 Ivy_Supp_t * pSupp;
00818 pSupp = Ivy_ObjSupp( pAig, pObj );
00819 vLeaves->nCap = 8;
00820 vLeaves->nSize = pSupp->nSize;
00821 vLeaves->pArray = pSupp->pArray;
00822 }
00823
00835 void Ivy_FastMapRequired_rec( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Ivy_Obj_t * pRoot, int DelayR )
00836 {
00837 Ivy_Supp_t * pSupp;
00838 pSupp = Ivy_ObjSupp( pAig, pObj );
00839 if ( pObj != pRoot && (pSupp->nRefs > 0 || Ivy_ObjIsCi(pObj)) )
00840 return;
00841 Ivy_FastMapRequired_rec( pAig, Ivy_ObjFanin0(pObj), pRoot, DelayR );
00842 Ivy_FastMapRequired_rec( pAig, Ivy_ObjFanin1(pObj), pRoot, DelayR );
00843
00844 pSupp->DelayR = DelayR;
00845 }
00846
00858 void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay, int fSetInter )
00859 {
00860 Vec_Vec_t * vLuts;
00861 Vec_Ptr_t * vNodes;
00862 Ivy_Obj_t * pObj;
00863 Ivy_Supp_t * pSupp, * pSuppF;
00864 int i, k, c;
00865
00866 Ivy_ManForEachPi( pAig, pObj, i )
00867 {
00868 pSupp = Ivy_ObjSupp( pAig, pObj );
00869 pSupp->DelayR = IVY_INFINITY;
00870 pSupp->nRefs = 0;
00871 }
00872 Ivy_ManForEachNode( pAig, pObj, i )
00873 {
00874 pSupp = Ivy_ObjSupp( pAig, pObj );
00875 pSupp->DelayR = IVY_INFINITY;
00876 pSupp->nRefs = 0;
00877 }
00878
00879 Ivy_ManForEachPo( pAig, pObj, i )
00880 {
00881 pSupp = Ivy_ObjSupp( pAig, Ivy_ObjFanin0(pObj) );
00882 pSupp->DelayR = Delay;
00883 pSupp->nRefs++;
00884 }
00885
00886 vLuts = ((Ivy_SuppMan_t *)pAig->pData)->vLuts;
00887
00888 Vec_VecForEachLevelReverse( vLuts, vNodes, i )
00889 Vec_PtrForEachEntry( vNodes, pObj, k )
00890 {
00891 pSupp = Ivy_ObjSupp( pAig, pObj );
00892 assert( pSupp->nRefs > 0 );
00893 for ( c = 0; c < pSupp->nSize; c++ )
00894 {
00895 pSuppF = Ivy_ObjSupp( pAig, Ivy_ManObj(pAig, pSupp->pArray[c]) );
00896 pSuppF->DelayR = IVY_MIN( pSuppF->DelayR, pSupp->DelayR - 1 );
00897 pSuppF->nRefs++;
00898 }
00899 }
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910 if ( fSetInter )
00911 {
00912
00913 Vec_VecForEachLevelReverse( vLuts, vNodes, i )
00914 Vec_PtrForEachEntry( vNodes, pObj, k )
00915 {
00916 pSupp = Ivy_ObjSupp( pAig, pObj );
00917 Ivy_FastMapRequired_rec( pAig, pObj, pObj, pSupp->DelayR );
00918 }
00919
00920 Ivy_ManForEachNode( pAig, pObj, i )
00921 {
00922 pSupp = Ivy_ObjSupp( pAig, pObj );
00923 assert( pSupp->DelayR < IVY_INFINITY );
00924 }
00925 }
00926 }
00927
00939 void Ivy_FastMapRecover( Ivy_Man_t * pAig, int nLimit )
00940 {
00941 Vec_Ptr_t * vFront, * vFrontOld;
00942 Ivy_Obj_t * pObj;
00943 int i;
00944 vFront = Vec_PtrAlloc( nLimit );
00945 vFrontOld = Vec_PtrAlloc( nLimit );
00946 Ivy_ManCleanTravId( pAig );
00947
00948 Ivy_ManForEachNode( pAig, pObj, i )
00949 Ivy_FastMapNodeRecover( pAig, pObj, nLimit, vFront, vFrontOld );
00950 Vec_PtrFree( vFrontOld );
00951 Vec_PtrFree( vFront );
00952 }
00953
00965 int Ivy_FastMapNodeDelay( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
00966 {
00967 Ivy_Supp_t * pSupp, * pSuppF;
00968 int c, Delay = 0;
00969 pSupp = Ivy_ObjSupp( pAig, pObj );
00970 for ( c = 0; c < pSupp->nSize; c++ )
00971 {
00972 pSuppF = Ivy_ObjSupp( pAig, Ivy_ManObj(pAig, pSupp->pArray[c]) );
00973 Delay = IVY_MAX( Delay, pSuppF->Delay );
00974 }
00975 return 1 + Delay;
00976 }
00977
00978
00990 int Ivy_FastMapNodeRef( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
00991 {
00992 Ivy_Supp_t * pSupp, * pSuppF;
00993 Ivy_Obj_t * pNodeChild;
00994 int aArea, i;
00995
00996 aArea = 1;
00997
00998 pSupp = Ivy_ObjSupp( pAig, pObj );
00999 assert( pSupp->nSize > 1 );
01000 for ( i = 0; i < pSupp->nSize; i++ )
01001 {
01002 pNodeChild = Ivy_ManObj(pAig, pSupp->pArray[i]);
01003 pSuppF = Ivy_ObjSupp( pAig, pNodeChild );
01004 assert( pSuppF->nRefs >= 0 );
01005 if ( pSuppF->nRefs++ > 0 )
01006 continue;
01007 if ( pSuppF->nSize == 1 )
01008 continue;
01009 aArea += Ivy_FastMapNodeRef( pAig, pNodeChild );
01010 }
01011 return aArea;
01012 }
01013
01025 int Ivy_FastMapNodeDeref( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
01026 {
01027 Ivy_Supp_t * pSupp, * pSuppF;
01028 Ivy_Obj_t * pNodeChild;
01029 int aArea, i;
01030
01031 aArea = 1;
01032
01033 pSupp = Ivy_ObjSupp( pAig, pObj );
01034 assert( pSupp->nSize > 1 );
01035 for ( i = 0; i < pSupp->nSize; i++ )
01036 {
01037 pNodeChild = Ivy_ManObj(pAig, pSupp->pArray[i]);
01038 pSuppF = Ivy_ObjSupp( pAig, pNodeChild );
01039 assert( pSuppF->nRefs > 0 );
01040 if ( --pSuppF->nRefs > 0 )
01041 continue;
01042 if ( pSuppF->nSize == 1 )
01043 continue;
01044 aArea += Ivy_FastMapNodeDeref( pAig, pNodeChild );
01045 }
01046 return aArea;
01047 }
01048
01060 int Ivy_FastMapNodeAreaRefed( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
01061 {
01062 Ivy_Supp_t * pSupp;
01063 int aResult, aResult2;
01064 if ( Ivy_ObjIsCi(pObj) )
01065 return 0;
01066 assert( Ivy_ObjIsNode(pObj) );
01067 pSupp = Ivy_ObjSupp( pAig, pObj );
01068 assert( pSupp->nRefs > 0 );
01069 aResult = Ivy_FastMapNodeDeref( pAig, pObj );
01070 aResult2 = Ivy_FastMapNodeRef( pAig, pObj );
01071 assert( aResult == aResult2 );
01072 return aResult;
01073 }
01074
01086 int Ivy_FastMapNodeAreaDerefed( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
01087 {
01088 Ivy_Supp_t * pSupp;
01089 int aResult, aResult2;
01090 if ( Ivy_ObjIsCi(pObj) )
01091 return 0;
01092 assert( Ivy_ObjIsNode(pObj) );
01093 pSupp = Ivy_ObjSupp( pAig, pObj );
01094 assert( pSupp->nRefs == 0 );
01095 aResult2 = Ivy_FastMapNodeRef( pAig, pObj );
01096 aResult = Ivy_FastMapNodeDeref( pAig, pObj );
01097 assert( aResult == aResult2 );
01098 return aResult;
01099 }
01100
01101
01102
01103
01115 int Ivy_FastMapCutCost( Ivy_Man_t * pAig, Vec_Ptr_t * vFront )
01116 {
01117 Ivy_Supp_t * pSuppF;
01118 Ivy_Obj_t * pFanin;
01119 int i, Counter = 0;
01120 Vec_PtrForEachEntry( vFront, pFanin, i )
01121 {
01122 pSuppF = Ivy_ObjSupp( pAig, pFanin );
01123 if ( pSuppF->nRefs == 0 )
01124 Counter++;
01125 }
01126 return Counter;
01127 }
01128
01140 void Ivy_FastMapMark_rec( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
01141 {
01142 if ( Ivy_ObjIsTravIdCurrent(pAig, pObj) )
01143 return;
01144 assert( Ivy_ObjIsNode(pObj) );
01145 Ivy_FastMapMark_rec( pAig, Ivy_ObjFanin0(pObj) );
01146 Ivy_FastMapMark_rec( pAig, Ivy_ObjFanin1(pObj) );
01147 Ivy_ObjSetTravIdCurrent(pAig, pObj);
01148 }
01149
01161 int Ivy_FastMapNodeWillGrow( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
01162 {
01163 Ivy_Obj_t * pFanin0, * pFanin1;
01164 assert( Ivy_ObjIsNode(pObj) );
01165 pFanin0 = Ivy_ObjFanin0(pObj);
01166 pFanin1 = Ivy_ObjFanin1(pObj);
01167 return !Ivy_ObjIsTravIdCurrent(pAig, pFanin0) && !Ivy_ObjIsTravIdCurrent(pAig, pFanin1);
01168 }
01169
01181 int Ivy_FastMapNodeFaninCost( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
01182 {
01183 Ivy_Supp_t * pSuppF;
01184 Ivy_Obj_t * pFanin;
01185 int Counter = 0;
01186 assert( Ivy_ObjIsNode(pObj) );
01187
01188 pSuppF = Ivy_ObjSupp( pAig, pObj );
01189 if ( pSuppF->nRefs == 0 )
01190 Counter--;
01191
01192 pFanin = Ivy_ObjFanin0(pObj);
01193 pSuppF = Ivy_ObjSupp( pAig, pFanin );
01194 if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) && pSuppF->nRefs == 0 )
01195 Counter++;
01196
01197 pFanin = Ivy_ObjFanin1(pObj);
01198 pSuppF = Ivy_ObjSupp( pAig, pFanin );
01199 if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) && pSuppF->nRefs == 0 )
01200 Counter++;
01201 return Counter;
01202 }
01203
01215 void Ivy_FastMapNodeFaninUpdate( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Ptr_t * vFront )
01216 {
01217 Ivy_Obj_t * pFanin;
01218 assert( Ivy_ObjIsNode(pObj) );
01219 Vec_PtrRemove( vFront, pObj );
01220 pFanin = Ivy_ObjFanin0(pObj);
01221 if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) )
01222 {
01223 Ivy_ObjSetTravIdCurrent(pAig, pFanin);
01224 Vec_PtrPush( vFront, pFanin );
01225 }
01226 pFanin = Ivy_ObjFanin1(pObj);
01227 if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) )
01228 {
01229 Ivy_ObjSetTravIdCurrent(pAig, pFanin);
01230 Vec_PtrPush( vFront, pFanin );
01231 }
01232 }
01233
01245 int Ivy_FastMapNodeFaninCompact0( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront )
01246 {
01247 Ivy_Obj_t * pFanin;
01248 int i;
01249 Vec_PtrForEachEntry( vFront, pFanin, i )
01250 {
01251 if ( Ivy_ObjIsCi(pFanin) )
01252 continue;
01253 if ( Ivy_FastMapNodeWillGrow(pAig, pFanin) )
01254 continue;
01255 if ( Ivy_FastMapNodeFaninCost(pAig, pFanin) <= 0 )
01256 {
01257 Ivy_FastMapNodeFaninUpdate( pAig, pFanin, vFront );
01258 return 1;
01259 }
01260 }
01261 return 0;
01262 }
01263
01275 int Ivy_FastMapNodeFaninCompact1( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront )
01276 {
01277 Ivy_Obj_t * pFanin;
01278 int i;
01279 Vec_PtrForEachEntry( vFront, pFanin, i )
01280 {
01281 if ( Ivy_ObjIsCi(pFanin) )
01282 continue;
01283 if ( Ivy_FastMapNodeFaninCost(pAig, pFanin) < 0 )
01284 {
01285 Ivy_FastMapNodeFaninUpdate( pAig, pFanin, vFront );
01286 return 1;
01287 }
01288 }
01289 return 0;
01290 }
01291
01303 int Ivy_FastMapNodeFaninCompact2( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront )
01304 {
01305 Ivy_Obj_t * pFanin;
01306 int i;
01307 Vec_PtrForEachEntry( vFront, pFanin, i )
01308 {
01309 if ( Ivy_ObjIsCi(pFanin) )
01310 continue;
01311 if ( Ivy_FastMapNodeFaninCost(pAig, pFanin) <= 0 )
01312 {
01313 Ivy_FastMapNodeFaninUpdate( pAig, pFanin, vFront );
01314 return 1;
01315 }
01316 }
01317 return 0;
01318 }
01319
01331 int Ivy_FastMapNodeFaninCompact_int( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront )
01332 {
01333 if ( Ivy_FastMapNodeFaninCompact0(pAig, pObj, nLimit, vFront) )
01334 return 1;
01335 if ( Vec_PtrSize(vFront) < nLimit && Ivy_FastMapNodeFaninCompact1(pAig, pObj, nLimit, vFront) )
01336 return 1;
01337 if ( Vec_PtrSize(vFront) < nLimit && Ivy_FastMapNodeFaninCompact2(pAig, pObj, nLimit, vFront) )
01338 return 1;
01339 assert( Vec_PtrSize(vFront) <= nLimit );
01340 return 0;
01341 }
01342
01354 void Ivy_FastMapNodeFaninCompact( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront )
01355 {
01356 while ( Ivy_FastMapNodeFaninCompact_int( pAig, pObj, nLimit, vFront ) );
01357 }
01358
01370 void Ivy_FastMapNodePrepare( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld )
01371 {
01372 Ivy_Supp_t * pSupp;
01373 Ivy_Obj_t * pFanin;
01374 int i;
01375 pSupp = Ivy_ObjSupp( pAig, pObj );
01376
01377 Vec_PtrClear( vFront );
01378 Vec_PtrClear( vFrontOld );
01379 Ivy_ManIncrementTravId( pAig );
01380 for ( i = 0; i < pSupp->nSize; i++ )
01381 {
01382 pFanin = Ivy_ManObj(pAig, pSupp->pArray[i]);
01383 Vec_PtrPush( vFront, pFanin );
01384 Vec_PtrPush( vFrontOld, pFanin );
01385 Ivy_ObjSetTravIdCurrent( pAig, pFanin );
01386 }
01387
01388 Ivy_FastMapMark_rec( pAig, pObj );
01389 }
01390
01402 void Ivy_FastMapNodeUpdate( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Ptr_t * vFront )
01403 {
01404 Ivy_Supp_t * pSupp;
01405 Ivy_Obj_t * pFanin;
01406 int i;
01407 pSupp = Ivy_ObjSupp( pAig, pObj );
01408
01409 Ivy_FastMapNodeDeref( pAig, pObj );
01410
01411 pSupp->nSize = Vec_PtrSize(vFront);
01412 Vec_PtrForEachEntry( vFront, pFanin, i )
01413 pSupp->pArray[i] = pFanin->Id;
01414
01415 Ivy_FastMapNodeRef( pAig, pObj );
01416 }
01417
01429 void Ivy_FastMapNodeRecover2( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld )
01430 {
01431 Ivy_Supp_t * pSupp;
01432 int CostBef, CostAft;
01433 int AreaBef, AreaAft;
01434 pSupp = Ivy_ObjSupp( pAig, pObj );
01435
01436
01437 if ( pSupp->nRefs == 0 )
01438 AreaBef = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
01439 else
01440 AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01441
01442 if ( AreaBef == 1 )
01443 return;
01444
01445 if ( pSupp->nRefs == 0 )
01446 {
01447 pSupp->nRefs = 1000000;
01448 Ivy_FastMapNodeRef( pAig, pObj );
01449 }
01450
01451 Ivy_FastMapNodePrepare( pAig, pObj, nLimit, vFront, vFrontOld );
01452
01453 CostBef = Ivy_FastMapCutCost( pAig, vFront );
01454 Ivy_FastMapNodeFaninCompact( pAig, pObj, nLimit, vFront );
01455 CostAft = Ivy_FastMapCutCost( pAig, vFront );
01456 assert( CostBef >= CostAft );
01457
01458 Ivy_FastMapNodeUpdate( pAig, pObj, vFront );
01459
01460 AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01461 if ( AreaAft > AreaBef )
01462 {
01463 Ivy_FastMapNodeUpdate( pAig, pObj, vFrontOld );
01464 AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01465 assert( AreaAft == AreaBef );
01466 }
01467 if ( pSupp->nRefs == 1000000 )
01468 {
01469 pSupp->nRefs = 0;
01470 Ivy_FastMapNodeDeref( pAig, pObj );
01471 }
01472 }
01473
01485 void Ivy_FastMapNodeRecover( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld )
01486 {
01487 Ivy_Supp_t * pSupp;
01488 int CostBef, CostAft;
01489 int AreaBef, AreaAft;
01490 int DelayOld;
01491 pSupp = Ivy_ObjSupp( pAig, pObj );
01492 DelayOld = pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
01493 assert( pSupp->Delay <= pSupp->DelayR );
01494 if ( pSupp->nRefs == 0 )
01495 return;
01496
01497 AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01498
01499
01500 if ( pObj->Id == 102 )
01501 {
01502 int x = 0;
01503 }
01504
01505 Ivy_FastMapNodePrepare( pAig, pObj, nLimit, vFront, vFrontOld );
01506
01507 Ivy_FastMapNodeDeref( pAig, pObj );
01508 CostBef = Ivy_FastMapCutCost( pAig, vFront );
01509 Ivy_FastMapNodeFaninCompact( pAig, pObj, nLimit, vFront );
01510 CostAft = Ivy_FastMapCutCost( pAig, vFront );
01511 Ivy_FastMapNodeRef( pAig, pObj );
01512 assert( CostBef >= CostAft );
01513
01514 Ivy_FastMapNodeUpdate( pAig, pObj, vFront );
01515 pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
01516
01517 AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01518 if ( AreaAft > AreaBef || pSupp->Delay > pSupp->DelayR )
01519 {
01520 Ivy_FastMapNodeUpdate( pAig, pObj, vFrontOld );
01521 AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01522 assert( AreaAft == AreaBef );
01523 pSupp->Delay = DelayOld;
01524 }
01525 }
01526
01538 void Ivy_FastMapNodeRecover4( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld )
01539 {
01540 Ivy_Supp_t * pSupp;
01541 int CostBef, CostAft;
01542 int AreaBef, AreaAft;
01543 int DelayOld;
01544 pSupp = Ivy_ObjSupp( pAig, pObj );
01545 DelayOld = pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
01546 assert( pSupp->Delay <= pSupp->DelayR );
01547
01548
01549
01550
01551 if ( pSupp->nRefs == 0 )
01552 AreaBef = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
01553 else
01554 AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01555 if ( AreaBef == 1 )
01556 return;
01557
01558 if ( pSupp->nRefs == 0 )
01559 {
01560 pSupp->nRefs = 1000000;
01561 Ivy_FastMapNodeRef( pAig, pObj );
01562 }
01563
01564 Ivy_FastMapNodePrepare( pAig, pObj, nLimit, vFront, vFrontOld );
01565
01566 CostBef = Ivy_FastMapCutCost( pAig, vFront );
01567 Ivy_FastMapNodeFaninCompact( pAig, pObj, nLimit, vFront );
01568 CostAft = Ivy_FastMapCutCost( pAig, vFront );
01569 assert( CostBef >= CostAft );
01570
01571 Ivy_FastMapNodeUpdate( pAig, pObj, vFront );
01572 pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
01573
01574 AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01575 if ( AreaAft > AreaBef || pSupp->Delay > pSupp->DelayR )
01576 {
01577 Ivy_FastMapNodeUpdate( pAig, pObj, vFrontOld );
01578 AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
01579 assert( AreaAft == AreaBef );
01580 pSupp->Delay = DelayOld;
01581 }
01582 if ( pSupp->nRefs == 1000000 )
01583 {
01584 pSupp->nRefs = 0;
01585 Ivy_FastMapNodeDeref( pAig, pObj );
01586 }
01587 }
01588
01592
01593