#include "if.h"
Go to the source code of this file.
Function*************************************************************
Synopsis [Computes area of the first level.]
Description [The cut need to be derefed.]
SideEffects []
SeeAlso []
Definition at line 691 of file ifCut.c.
00692 { 00693 float aResult, aResult2; 00694 assert( p->pPars->fSeqMap || pCut->nLeaves > 1 ); 00695 aResult2 = If_CutRef( p, pCut, nLevels ); 00696 aResult = If_CutDeref( p, pCut, nLevels ); 00697 assert( aResult > aResult2 - p->fEpsilon ); 00698 assert( aResult < aResult2 + p->fEpsilon ); 00699 return aResult; 00700 }
Function*************************************************************
Synopsis [Computes area of the first level.]
Description [The cut need to be derefed.]
SideEffects []
SeeAlso []
Definition at line 713 of file ifCut.c.
00714 { 00715 float aResult, aResult2; 00716 assert( p->pPars->fSeqMap || pCut->nLeaves > 1 ); 00717 aResult2 = If_CutDeref( p, pCut, nLevels ); 00718 aResult = If_CutRef( p, pCut, nLevels ); 00719 assert( aResult > aResult2 - p->fEpsilon ); 00720 assert( aResult < aResult2 + p->fEpsilon ); 00721 return aResult; 00722 }
Function*************************************************************
Synopsis [Average number of references of the leaves.]
Description []
SideEffects []
SeeAlso []
CFile****************************************************************
FileName [ifCut.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [FPGA mapping based on priority cuts.]
Synopsis [Cut computation.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 21, 2006.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Returns 1 if pDom is contained in pCut.]
Description []
SideEffects []
SeeAlso []
Definition at line 43 of file ifCut.c.
00044 { 00045 int i, k; 00046 for ( i = 0; i < (int)pDom->nLeaves; i++ ) 00047 { 00048 for ( k = 0; k < (int)pCut->nLeaves; k++ ) 00049 if ( pDom->pLeaves[i] == pCut->pLeaves[k] ) 00050 break; 00051 if ( k == (int)pCut->nLeaves ) // node i in pDom is not contained in pCut 00052 return 0; 00053 } 00054 // every node in pDom is contained in pCut 00055 return 1; 00056 }
Function*************************************************************
Synopsis [Returns 1 if pDom is equal to pCut.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis [Prepares the object for FPGA mapping.]
Description []
SideEffects []
SeeAlso []
Definition at line 375 of file ifCut.c.
00376 { 00377 If_Cut_t * pC0 = *ppC0; 00378 If_Cut_t * pC1 = *ppC1; 00379 if ( pC0->Area < pC1->Area - 0.0001 ) 00380 return -1; 00381 if ( pC0->Area > pC1->Area + 0.0001 ) 00382 return 1; 00383 if ( pC0->AveRefs > pC1->AveRefs ) 00384 return -1; 00385 if ( pC0->AveRefs < pC1->AveRefs ) 00386 return 1; 00387 if ( pC0->nLeaves < pC1->nLeaves ) 00388 return -1; 00389 if ( pC0->nLeaves > pC1->nLeaves ) 00390 return 1; 00391 if ( pC0->Delay < pC1->Delay - 0.0001 ) 00392 return -1; 00393 if ( pC0->Delay > pC1->Delay + 0.0001 ) 00394 return 1; 00395 return 0; 00396 }
Function*************************************************************
Synopsis [Prepares the object for FPGA mapping.]
Description []
SideEffects []
SeeAlso []
Definition at line 315 of file ifCut.c.
00316 { 00317 If_Cut_t * pC0 = *ppC0; 00318 If_Cut_t * pC1 = *ppC1; 00319 if ( pC0->Delay < pC1->Delay - 0.0001 ) 00320 return -1; 00321 if ( pC0->Delay > pC1->Delay + 0.0001 ) 00322 return 1; 00323 if ( pC0->nLeaves < pC1->nLeaves ) 00324 return -1; 00325 if ( pC0->nLeaves > pC1->nLeaves ) 00326 return 1; 00327 if ( pC0->Area < pC1->Area - 0.0001 ) 00328 return -1; 00329 if ( pC0->Area > pC1->Area + 0.0001 ) 00330 return 1; 00331 return 0; 00332 }
Function*************************************************************
Synopsis [Prepares the object for FPGA mapping.]
Description []
SideEffects []
SeeAlso []
Definition at line 345 of file ifCut.c.
00346 { 00347 If_Cut_t * pC0 = *ppC0; 00348 If_Cut_t * pC1 = *ppC1; 00349 if ( pC0->Delay < pC1->Delay - 0.0001 ) 00350 return -1; 00351 if ( pC0->Delay > pC1->Delay + 0.0001 ) 00352 return 1; 00353 if ( pC0->Area < pC1->Area - 0.0001 ) 00354 return -1; 00355 if ( pC0->Area > pC1->Area + 0.0001 ) 00356 return 1; 00357 if ( pC0->nLeaves < pC1->nLeaves ) 00358 return -1; 00359 if ( pC0->nLeaves > pC1->nLeaves ) 00360 return 1; 00361 return 0; 00362 }
Function*************************************************************
Synopsis [Computes area of the first level.]
Description [The cut need to be derefed.]
SideEffects []
SeeAlso []
Definition at line 756 of file ifCut.c.
00757 { 00758 int * pLeaves; 00759 char * pPerm; 00760 unsigned * pTruth; 00761 // save old arrays 00762 pLeaves = pCutDest->pLeaves; 00763 pPerm = pCutDest->pPerm; 00764 pTruth = pCutDest->pTruth; 00765 // copy the cut info 00766 memcpy( pCutDest, pCutSrc, p->nCutBytes ); 00767 // restore the arrays 00768 pCutDest->pLeaves = pLeaves; 00769 pCutDest->pPerm = pPerm; 00770 pCutDest->pTruth = pTruth; 00771 }
Function*************************************************************
Synopsis [Computes area of the first level.]
Description [The cut need to be derefed.]
SideEffects []
SeeAlso []
Definition at line 596 of file ifCut.c.
00597 { 00598 If_Obj_t * pLeaf; 00599 float Area; 00600 int i; 00601 Area = If_CutLutArea(p, pCut); 00602 If_CutForEachLeaf( p, pCut, pLeaf, i ) 00603 { 00604 assert( pLeaf->nRefs > 0 ); 00605 if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) || nLevels == 1 ) 00606 continue; 00607 Area += If_CutDeref( p, If_ObjCutBest(pLeaf), nLevels - 1 ); 00608 } 00609 return Area; 00610 }
Function*************************************************************
Synopsis [Returns 1 if the cut is contained.]
Description []
SideEffects []
SeeAlso []
Definition at line 91 of file ifCut.c.
00092 { 00093 If_Cut_t * pTemp; 00094 int i, k; 00095 assert( pCutSet->ppCuts[pCutSet->nCuts] == pCut ); 00096 for ( i = 0; i < pCutSet->nCuts; i++ ) 00097 { 00098 pTemp = pCutSet->ppCuts[i]; 00099 if ( pTemp->nLeaves > pCut->nLeaves ) 00100 { 00101 // do not fiter the first cut 00102 if ( i == 0 ) 00103 continue; 00104 // skip the non-contained cuts 00105 if ( (pTemp->uSign & pCut->uSign) != pCut->uSign ) 00106 continue; 00107 // check containment seriously 00108 if ( If_CutCheckDominance( pCut, pTemp ) ) 00109 { 00110 // p->ppCuts[i] = p->ppCuts[p->nCuts-1]; 00111 // p->ppCuts[p->nCuts-1] = pTemp; 00112 // p->nCuts--; 00113 // i--; 00114 // remove contained cut 00115 for ( k = i; k < pCutSet->nCuts; k++ ) 00116 pCutSet->ppCuts[k] = pCutSet->ppCuts[k+1]; 00117 pCutSet->ppCuts[pCutSet->nCuts] = pTemp; 00118 pCutSet->nCuts--; 00119 i--; 00120 } 00121 } 00122 else 00123 { 00124 // skip the non-contained cuts 00125 if ( (pTemp->uSign & pCut->uSign) != pTemp->uSign ) 00126 continue; 00127 // check containment seriously 00128 if ( If_CutCheckDominance( pTemp, pCut ) ) 00129 return 1; 00130 } 00131 } 00132 return 0; 00133 }
Function*************************************************************
Synopsis [Computes area flow.]
Description []
SideEffects []
SeeAlso []
Definition at line 541 of file ifCut.c.
00542 { 00543 If_Obj_t * pLeaf; 00544 float Flow; 00545 int i; 00546 assert( p->pPars->fSeqMap || pCut->nLeaves > 1 ); 00547 Flow = If_CutLutArea(p, pCut); 00548 If_CutForEachLeaf( p, pCut, pLeaf, i ) 00549 { 00550 if ( pLeaf->nRefs == 0 ) 00551 Flow += If_ObjCutBest(pLeaf)->Area; 00552 else if ( p->pPars->fSeqMap ) // seq 00553 Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->nRefs; 00554 else 00555 { 00556 assert( pLeaf->EstRefs > p->fEpsilon ); 00557 Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs; 00558 } 00559 } 00560 return Flow; 00561 }
void If_CutLift | ( | If_Cut_t * | pCut | ) |
Function*************************************************************
Synopsis [Moves the cut over the latch.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis [Prepares the object for FPGA mapping.]
Description []
SideEffects []
SeeAlso []
Definition at line 286 of file ifCut.c.
00287 { 00288 assert( pCut->nLimit > 0 ); 00289 // merge the nodes 00290 if ( pCut0->nLeaves < pCut1->nLeaves ) 00291 { 00292 if ( !If_CutMergeOrdered( pCut1, pCut0, pCut ) ) 00293 return 0; 00294 } 00295 else 00296 { 00297 if ( !If_CutMergeOrdered( pCut0, pCut1, pCut ) ) 00298 return 0; 00299 } 00300 pCut->uSign = pCut0->uSign | pCut1->uSign; 00301 return 1; 00302 }
Function*************************************************************
Synopsis [Merges two cuts.]
Description []
SideEffects []
SeeAlso []
Definition at line 146 of file ifCut.c.
00147 { 00148 int i, k, c; 00149 assert( pC0->nLeaves >= pC1->nLeaves ); 00150 // the case of the largest cut sizes 00151 if ( pC0->nLeaves == pC->nLimit && pC1->nLeaves == pC->nLimit ) 00152 { 00153 for ( i = 0; i < (int)pC0->nLeaves; i++ ) 00154 if ( pC0->pLeaves[i] != pC1->pLeaves[i] ) 00155 return 0; 00156 for ( i = 0; i < (int)pC0->nLeaves; i++ ) 00157 pC->pLeaves[i] = pC0->pLeaves[i]; 00158 pC->nLeaves = pC0->nLeaves; 00159 return 1; 00160 } 00161 // the case when one of the cuts is the largest 00162 if ( pC0->nLeaves == pC->nLimit ) 00163 { 00164 for ( i = 0; i < (int)pC1->nLeaves; i++ ) 00165 { 00166 for ( k = (int)pC0->nLeaves - 1; k >= 0; k-- ) 00167 if ( pC0->pLeaves[k] == pC1->pLeaves[i] ) 00168 break; 00169 if ( k == -1 ) // did not find 00170 return 0; 00171 } 00172 for ( i = 0; i < (int)pC0->nLeaves; i++ ) 00173 pC->pLeaves[i] = pC0->pLeaves[i]; 00174 pC->nLeaves = pC0->nLeaves; 00175 return 1; 00176 } 00177 00178 // compare two cuts with different numbers 00179 i = k = 0; 00180 for ( c = 0; c < (int)pC->nLimit; c++ ) 00181 { 00182 if ( k == (int)pC1->nLeaves ) 00183 { 00184 if ( i == (int)pC0->nLeaves ) 00185 { 00186 pC->nLeaves = c; 00187 return 1; 00188 } 00189 pC->pLeaves[c] = pC0->pLeaves[i++]; 00190 continue; 00191 } 00192 if ( i == (int)pC0->nLeaves ) 00193 { 00194 if ( k == (int)pC1->nLeaves ) 00195 { 00196 pC->nLeaves = c; 00197 return 1; 00198 } 00199 pC->pLeaves[c] = pC1->pLeaves[k++]; 00200 continue; 00201 } 00202 if ( pC0->pLeaves[i] < pC1->pLeaves[k] ) 00203 { 00204 pC->pLeaves[c] = pC0->pLeaves[i++]; 00205 continue; 00206 } 00207 if ( pC0->pLeaves[i] > pC1->pLeaves[k] ) 00208 { 00209 pC->pLeaves[c] = pC1->pLeaves[k++]; 00210 continue; 00211 } 00212 pC->pLeaves[c] = pC0->pLeaves[i++]; 00213 k++; 00214 } 00215 if ( i < (int)pC0->nLeaves || k < (int)pC1->nLeaves ) 00216 return 0; 00217 pC->nLeaves = c; 00218 return 1; 00219 }
Function*************************************************************
Synopsis [Merges two cuts.]
Description [Special case when the cut is known to exist.]
SideEffects []
SeeAlso []
Definition at line 232 of file ifCut.c.
00233 { 00234 int i, k, c; 00235 assert( pC0->nLeaves >= pC1->nLeaves ); 00236 // copy the first cut 00237 for ( i = 0; i < (int)pC0->nLeaves; i++ ) 00238 pC->pLeaves[i] = pC0->pLeaves[i]; 00239 pC->nLeaves = pC0->nLeaves; 00240 // the case when one of the cuts is the largest 00241 if ( pC0->nLeaves == pC->nLimit ) 00242 return 1; 00243 // add nodes of the second cut 00244 k = 0; 00245 for ( i = 0; i < (int)pC1->nLeaves; i++ ) 00246 { 00247 // find k-th node before which i-th node should be added 00248 for ( ; k < (int)pC->nLeaves; k++ ) 00249 if ( pC->pLeaves[k] >= pC1->pLeaves[i] ) 00250 break; 00251 // check the case when this should be the last node 00252 if ( k == (int)pC->nLeaves ) 00253 { 00254 pC->pLeaves[k++] = pC1->pLeaves[i]; 00255 pC->nLeaves++; 00256 continue; 00257 } 00258 // check the case when equal node is found 00259 if ( pC1->pLeaves[i] == pC->pLeaves[k] ) 00260 continue; 00261 // add the node 00262 for ( c = (int)pC->nLeaves; c > k; c-- ) 00263 pC->pLeaves[c] = pC->pLeaves[c-1]; 00264 pC->pLeaves[k++] = pC1->pLeaves[i]; 00265 pC->nLeaves++; 00266 } 00267 /* 00268 assert( pC->nLeaves <= pC->nLimit ); 00269 for ( i = 1; i < (int)pC->nLeaves; i++ ) 00270 assert( pC->pLeaves[i-1] < pC->pLeaves[i] ); 00271 */ 00272 return 1; 00273 }
Function*************************************************************
Synopsis [Prints one cut.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis [Prints one cut.]
Description []
SideEffects []
SeeAlso []
Definition at line 670 of file ifCut.c.
00671 { 00672 If_Obj_t * pLeaf; 00673 unsigned i; 00674 printf( "{" ); 00675 If_CutForEachLeaf( p, pCut, pLeaf, i ) 00676 printf( " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required ); 00677 printf( " }\n" ); 00678 }
Function*************************************************************
Synopsis [Computes area of the first level.]
Description [The cut need to be derefed.]
SideEffects []
SeeAlso []
Definition at line 623 of file ifCut.c.
00624 { 00625 If_Obj_t * pLeaf; 00626 float Area; 00627 int i; 00628 Area = If_CutLutArea(p, pCut); 00629 If_CutForEachLeaf( p, pCut, pLeaf, i ) 00630 { 00631 assert( pLeaf->nRefs >= 0 ); 00632 if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) || nLevels == 1 ) 00633 continue; 00634 Area += If_CutRef( p, If_ObjCutBest(pLeaf), nLevels - 1 ); 00635 } 00636 return Area; 00637 }
Function*************************************************************
Synopsis [Performs incremental sorting of cuts.]
Description [Currently only the trivial sorting is implemented.]
SideEffects []
SeeAlso []
Definition at line 498 of file ifCut.c.
00499 { 00500 // int Counter = 0; 00501 int i; 00502 00503 // the new cut is the last one 00504 assert( pCutSet->ppCuts[pCutSet->nCuts] == pCut ); 00505 assert( pCutSet->nCuts <= pCutSet->nCutsMax ); 00506 00507 // cut structure is empty 00508 if ( pCutSet->nCuts == 0 ) 00509 { 00510 pCutSet->nCuts++; 00511 return; 00512 } 00513 00514 // the cut will be added - find its place 00515 for ( i = pCutSet->nCuts-1; i >= 0; i-- ) 00516 { 00517 // Counter++; 00518 if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 ) 00519 break; 00520 pCutSet->ppCuts[i+1] = pCutSet->ppCuts[i]; 00521 pCutSet->ppCuts[i] = pCut; 00522 } 00523 // printf( "%d ", Counter ); 00524 00525 // update the number of cuts 00526 if ( pCutSet->nCuts < pCutSet->nCutsMax ) 00527 pCutSet->nCuts++; 00528 }
Function*************************************************************
Synopsis [Comparison function for two cuts.]
Description []
SideEffects []
SeeAlso []
Definition at line 433 of file ifCut.c.
00434 { 00435 if ( p->SortMode == 1 ) // area 00436 { 00437 if ( pC0->Area < pC1->Area - 0.0001 ) 00438 return -1; 00439 if ( pC0->Area > pC1->Area + 0.0001 ) 00440 return 1; 00441 if ( pC0->AveRefs > pC1->AveRefs ) 00442 return -1; 00443 if ( pC0->AveRefs < pC1->AveRefs ) 00444 return 1; 00445 if ( pC0->nLeaves < pC1->nLeaves ) 00446 return -1; 00447 if ( pC0->nLeaves > pC1->nLeaves ) 00448 return 1; 00449 if ( pC0->Delay < pC1->Delay - 0.0001 ) 00450 return -1; 00451 if ( pC0->Delay > pC1->Delay + 0.0001 ) 00452 return 1; 00453 return 0; 00454 } 00455 if ( p->SortMode == 0 ) // delay 00456 { 00457 if ( pC0->Delay < pC1->Delay - 0.0001 ) 00458 return -1; 00459 if ( pC0->Delay > pC1->Delay + 0.0001 ) 00460 return 1; 00461 if ( pC0->nLeaves < pC1->nLeaves ) 00462 return -1; 00463 if ( pC0->nLeaves > pC1->nLeaves ) 00464 return 1; 00465 if ( pC0->Area < pC1->Area - 0.0001 ) 00466 return -1; 00467 if ( pC0->Area > pC1->Area + 0.0001 ) 00468 return 1; 00469 return 0; 00470 } 00471 assert( p->SortMode == 2 ); // delay old 00472 if ( pC0->Delay < pC1->Delay - 0.0001 ) 00473 return -1; 00474 if ( pC0->Delay > pC1->Delay + 0.0001 ) 00475 return 1; 00476 if ( pC0->Area < pC1->Area - 0.0001 ) 00477 return -1; 00478 if ( pC0->Area > pC1->Area + 0.0001 ) 00479 return 1; 00480 if ( pC0->nLeaves < pC1->nLeaves ) 00481 return -1; 00482 if ( pC0->nLeaves > pC1->nLeaves ) 00483 return 1; 00484 return 0; 00485 }
void If_ManSortCuts | ( | If_Man_t * | p, | |
int | Mode | |||
) |
Function*************************************************************
Synopsis [Sorts the cuts.]
Description []
SideEffects []
SeeAlso []
Definition at line 409 of file ifCut.c.
00410 { 00411 /* 00412 // sort the cuts 00413 if ( Mode || p->pPars->fArea ) // area 00414 qsort( p->ppCuts, p->nCuts, sizeof(If_Cut_t *), (int (*)(const void *, const void *))If_CutCompareArea ); 00415 else if ( p->pPars->fFancy ) 00416 qsort( p->ppCuts, p->nCuts, sizeof(If_Cut_t *), (int (*)(const void *, const void *))If_CutCompareDelayOld ); 00417 else 00418 qsort( p->ppCuts, p->nCuts, sizeof(If_Cut_t *), (int (*)(const void *, const void *))If_CutCompareDelay ); 00419 */ 00420 }