#include "if.h"
Go to the source code of this file.
Function*************************************************************
Synopsis [Create the new node assuming it does not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 201 of file ifMan.c.
00202 { 00203 If_Obj_t * pObj; 00204 // perform constant propagation 00205 if ( pFan0 == pFan1 ) 00206 return pFan0; 00207 if ( pFan0 == If_Not(pFan1) ) 00208 return If_Not(p->pConst1); 00209 if ( If_Regular(pFan0) == p->pConst1 ) 00210 return pFan0 == p->pConst1 ? pFan1 : If_Not(p->pConst1); 00211 if ( If_Regular(pFan1) == p->pConst1 ) 00212 return pFan1 == p->pConst1 ? pFan0 : If_Not(p->pConst1); 00213 // get memory for the new object 00214 pObj = If_ManSetupObj( p ); 00215 pObj->Type = IF_AND; 00216 pObj->fCompl0 = If_IsComplement(pFan0); pFan0 = If_Regular(pFan0); 00217 pObj->fCompl1 = If_IsComplement(pFan1); pFan1 = If_Regular(pFan1); 00218 pObj->pFanin0 = pFan0; pFan0->nRefs++; pFan0->nVisits++; pFan0->nVisitsCopy++; 00219 pObj->pFanin1 = pFan1; pFan1->nRefs++; pFan1->nVisits++; pFan1->nVisitsCopy++; 00220 pObj->fPhase = (pObj->fCompl0 ^ pFan0->fPhase) & (pObj->fCompl1 ^ pFan1->fPhase); 00221 pObj->Level = 1 + IF_MAX( pFan0->Level, pFan1->Level ); 00222 if ( p->nLevelMax < (int)pObj->Level ) 00223 p->nLevelMax = (int)pObj->Level; 00224 p->nObjs[IF_AND]++; 00225 return pObj; 00226 }
Function*************************************************************
Synopsis [Creates the choice node.]
Description [Should be called after the equivalence class nodes are linked.]
SideEffects []
SeeAlso []
Definition at line 277 of file ifMan.c.
00278 { 00279 If_Obj_t * pTemp; 00280 // mark the node as a representative if its class 00281 assert( pObj->fRepr == 0 ); 00282 pObj->fRepr = 1; 00283 // update the level of this node (needed for correct required time computation) 00284 for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv ) 00285 { 00286 pObj->Level = IF_MAX( pObj->Level, pTemp->Level ); 00287 pTemp->nVisits++; pTemp->nVisitsCopy++; 00288 } 00289 // mark the largest level 00290 if ( p->nLevelMax < (int)pObj->Level ) 00291 p->nLevelMax = (int)pObj->Level; 00292 }
Function*************************************************************
Synopsis [Creates primary input.]
Description []
SideEffects []
SeeAlso []
Definition at line 157 of file ifMan.c.
00158 { 00159 If_Obj_t * pObj; 00160 pObj = If_ManSetupObj( p ); 00161 pObj->Type = IF_CI; 00162 Vec_PtrPush( p->vCis, pObj ); 00163 p->nObjs[IF_CI]++; 00164 return pObj; 00165 }
Function*************************************************************
Synopsis [Creates primary output with the given driver.]
Description []
SideEffects []
SeeAlso []
Definition at line 178 of file ifMan.c.
00179 { 00180 If_Obj_t * pObj; 00181 pObj = If_ManSetupObj( p ); 00182 Vec_PtrPush( p->vCos, pObj ); 00183 pObj->Type = IF_CO; 00184 pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver); 00185 pObj->pFanin0 = pDriver; pDriver->nRefs++; 00186 p->nObjs[IF_CO]++; 00187 return pObj; 00188 }
Function*************************************************************
Synopsis [Create the new node assuming it does not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 258 of file ifMan.c.
00259 { 00260 If_Obj_t * pRes1, * pRes2; 00261 pRes1 = If_ManCreateAnd( p, pFan0, If_Not(pCtrl) ); 00262 pRes2 = If_ManCreateAnd( p, pFan1, pCtrl ); 00263 return If_Not( If_ManCreateAnd( p, If_Not(pRes1), If_Not(pRes2) ) ); 00264 }
Function*************************************************************
Synopsis [Create the new node assuming it does not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 239 of file ifMan.c.
00240 { 00241 If_Obj_t * pRes1, * pRes2; 00242 pRes1 = If_ManCreateAnd( p, If_Not(pFan0), pFan1 ); 00243 pRes2 = If_ManCreateAnd( p, pFan0, If_Not(pFan1) ); 00244 return If_Not( If_ManCreateAnd( p, If_Not(pRes1), If_Not(pRes2) ) ); 00245 }
Function*************************************************************
Synopsis [Dereferences cutset of the node.]
Description []
SideEffects []
SeeAlso []
Definition at line 508 of file ifMan.c.
00509 { 00510 If_Obj_t * pTemp; 00511 assert( If_ObjIsAnd(pObj) ); 00512 assert( pObj->fRepr ); 00513 assert( pObj->nVisits > 0 ); 00514 // consider the nodes in the choice class 00515 for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv ) 00516 { 00517 assert( pTemp == pObj || pTemp->nVisits == 1 ); 00518 if ( --pTemp->nVisits == 0 ) 00519 { 00520 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pTemp->pCutSet ); 00521 If_ManCutSetRecycle( p, pTemp->pCutSet ); 00522 pTemp->pCutSet = NULL; 00523 } 00524 } 00525 }
Function*************************************************************
Synopsis [Dereferences cutset of the node.]
Description []
SideEffects []
SeeAlso []
Definition at line 465 of file ifMan.c.
00466 { 00467 If_Obj_t * pFanin; 00468 assert( If_ObjIsAnd(pObj) ); 00469 // consider the node 00470 assert( pObj->nVisits >= 0 ); 00471 if ( pObj->nVisits == 0 ) 00472 { 00473 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pObj->pCutSet ); 00474 If_ManCutSetRecycle( p, pObj->pCutSet ); 00475 pObj->pCutSet = NULL; 00476 } 00477 // consider the first fanin 00478 pFanin = If_ObjFanin0(pObj); 00479 assert( pFanin->nVisits > 0 ); 00480 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 ) 00481 { 00482 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pFanin->pCutSet ); 00483 If_ManCutSetRecycle( p, pFanin->pCutSet ); 00484 pFanin->pCutSet = NULL; 00485 } 00486 // consider the second fanin 00487 pFanin = If_ObjFanin1(pObj); 00488 assert( pFanin->nVisits > 0 ); 00489 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 ) 00490 { 00491 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pFanin->pCutSet ); 00492 If_ManCutSetRecycle( p, pFanin->pCutSet ); 00493 pFanin->pCutSet = NULL; 00494 } 00495 }
void If_ManRestart | ( | If_Man_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 97 of file ifMan.c.
00098 { 00099 FREE( p->pMemCi ); 00100 Vec_PtrClear( p->vCis ); 00101 Vec_PtrClear( p->vCos ); 00102 Vec_PtrClear( p->vObjs ); 00103 Vec_PtrClear( p->vMapped ); 00104 Vec_PtrClear( p->vTemp ); 00105 Mem_FixedRestart( p->pMemObj ); 00106 // create the constant node 00107 p->pConst1 = If_ManSetupObj( p ); 00108 p->pConst1->Type = IF_CONST1; 00109 p->pConst1->fPhase = 1; 00110 // reset the counter of other nodes 00111 p->nObjs[IF_CI] = p->nObjs[IF_CO] = p->nObjs[IF_AND] = 0; 00112 }
void If_ManSetupCiCutSets | ( | If_Man_t * | p | ) |
Function*************************************************************
Synopsis [Prepares memory for one cut.]
Description []
SideEffects []
SeeAlso []
Definition at line 409 of file ifMan.c.
00410 { 00411 If_Obj_t * pObj; 00412 int i; 00413 assert( p->pMemCi == NULL ); 00414 // create elementary cuts for the CIs 00415 If_ManForEachCi( p, pObj, i ) 00416 If_ManSetupCutTriv( p, &pObj->CutBest, pObj->Id ); 00417 // create elementary cutsets for the CIs 00418 p->pMemCi = (If_Set_t *)malloc( If_ManCiNum(p) * (sizeof(If_Set_t) + sizeof(void *)) ); 00419 If_ManForEachCi( p, pObj, i ) 00420 { 00421 pObj->pCutSet = (If_Set_t *)((char *)p->pMemCi + i * (sizeof(If_Set_t) + sizeof(void *))); 00422 pObj->pCutSet->nCuts = 1; 00423 pObj->pCutSet->nCutsMax = p->pPars->nCutsMax; 00424 pObj->pCutSet->ppCuts = (If_Cut_t **)(pObj->pCutSet + 1); 00425 pObj->pCutSet->ppCuts[0] = &pObj->CutBest; 00426 } 00427 }
Function*************************************************************
Synopsis [Prepares memory for one cut.]
Description []
SideEffects []
SeeAlso []
Definition at line 305 of file ifMan.c.
00306 { 00307 memset( pCut, 0, sizeof(If_Cut_t) ); 00308 pCut->nLimit = p->pPars->nLutSize; 00309 pCut->pLeaves = (int *)(pCut + 1); 00310 if ( p->pPars->fUsePerm ) 00311 pCut->pPerm = (char *)(pCut->pLeaves + p->pPars->nLutSize); 00312 if ( p->pPars->fTruth ) 00313 pCut->pTruth = pCut->pLeaves + p->pPars->nLutSize + p->nPermWords; 00314 }
Function*************************************************************
Synopsis [Prepares memory for one cut.]
Description []
SideEffects []
SeeAlso []
Definition at line 355 of file ifMan.c.
00356 { 00357 pCut->fCompl = 0; 00358 pCut->nLimit = p->pPars->nLutSize; 00359 pCut->nLeaves = 1; 00360 pCut->pLeaves[0] = p->pPars->fLiftLeaves? (ObjId << 8) : ObjId; 00361 pCut->uSign = If_ObjCutSign( pCut->pLeaves[0] ); 00362 // set up elementary truth table of the unit cut 00363 if ( p->pPars->fTruth ) 00364 { 00365 int i, nTruthWords; 00366 nTruthWords = pCut->nLimit <= 5 ? 1 : (1 << (pCut->nLimit - 5)); 00367 for ( i = 0; i < nTruthWords; i++ ) 00368 If_CutTruth(pCut)[i] = 0xAAAAAAAA; 00369 } 00370 }
Function*************************************************************
Synopsis [Prepares cutset of the node.]
Description [Elementary cutset will be added last.]
SideEffects []
SeeAlso []
Definition at line 440 of file ifMan.c.
00441 { 00442 assert( If_ObjIsAnd(pObj) ); 00443 assert( pObj->pCutSet == NULL ); 00444 // pObj->pCutSet = (If_Set_t *)Mem_FixedEntryFetch( p->pMemSet ); 00445 // If_ManSetupSet( p, pObj->pCutSet ); 00446 00447 pObj->pCutSet = If_ManCutSetFetch( p ); 00448 pObj->pCutSet->nCuts = 0; 00449 pObj->pCutSet->nCutsMax = p->pPars->nCutsMax; 00450 00451 return pObj->pCutSet; 00452 }
CFile****************************************************************
FileName [ifMan.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [FPGA mapping based on priority cuts.]
Synopsis [Mapping manager.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 21, 2006.]
Revision [
] DECLARATIONS ///
Function*************************************************************
Synopsis [Prepares memory for the node with cuts.]
Description []
SideEffects []
SeeAlso []
Definition at line 383 of file ifMan.c.
00384 { 00385 If_Obj_t * pObj; 00386 // get memory for the object 00387 pObj = (If_Obj_t *)Mem_FixedEntryFetch( p->pMemObj ); 00388 memset( pObj, 0, sizeof(If_Obj_t) ); 00389 If_ManSetupCut( p, &pObj->CutBest ); 00390 // assign ID and save 00391 pObj->Id = Vec_PtrSize(p->vObjs); 00392 Vec_PtrPush( p->vObjs, pObj ); 00393 // set the required times 00394 pObj->Required = IF_FLOAT_LARGE; 00395 return pObj; 00396 }
Function*************************************************************
Synopsis [Prepares memory for one cutset.]
Description []
SideEffects []
SeeAlso []
Definition at line 327 of file ifMan.c.
00328 { 00329 char * pArray; 00330 int i; 00331 pSet->nCuts = 0; 00332 pSet->nCutsMax = p->pPars->nCutsMax; 00333 pSet->ppCuts = (If_Cut_t **)(pSet + 1); 00334 pArray = (char *)pSet->ppCuts + sizeof(If_Cut_t *) * (pSet->nCutsMax+1); 00335 for ( i = 0; i <= pSet->nCutsMax; i++ ) 00336 { 00337 pSet->ppCuts[i] = (If_Cut_t *)(pArray + i * p->nCutBytes); 00338 If_ManSetupCut( p, pSet->ppCuts[i] ); 00339 } 00340 // pArray += (pSet->nCutsMax + 1) * p->nCutBytes; 00341 // assert( ((char *)pArray) - ((char *)pSet) == p->nSetBytes ); 00342 }
void If_ManSetupSetAll | ( | If_Man_t * | p, | |
int | nCrossCut | |||
) |
Function*************************************************************
Synopsis [Dereferences cutset of the node.]
Description []
SideEffects []
SeeAlso []
Definition at line 538 of file ifMan.c.
00539 { 00540 If_Set_t * pCutSet; 00541 int i, nCutSets; 00542 nCutSets = 128 + nCrossCut; 00543 p->pFreeList = p->pMemAnd = pCutSet = (If_Set_t *)malloc( nCutSets * p->nSetBytes ); 00544 for ( i = 0; i < nCutSets; i++ ) 00545 { 00546 If_ManSetupSet( p, pCutSet ); 00547 if ( i == nCutSets - 1 ) 00548 pCutSet->pNext = NULL; 00549 else 00550 pCutSet->pNext = (If_Set_t *)( (char *)pCutSet + p->nSetBytes ); 00551 pCutSet = pCutSet->pNext; 00552 } 00553 assert( pCutSet == NULL ); 00554 00555 if ( p->pPars->fVerbose ) 00556 { 00557 printf( "Node = %7d. Ch = %5d. Total mem = %7.2f Mb. Peak cut mem = %7.2f Mb.\n", 00558 If_ManAndNum(p), p->nChoices, 00559 1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20), 00560 1.0 * p->nSetBytes * nCrossCut / (1<<20) ); 00561 } 00562 // printf( "Cross cut = %d.\n", nCrossCut ); 00563 00564 }
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Starts the AIG manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 47 of file ifMan.c.
00048 { 00049 If_Man_t * p; 00050 // start the manager 00051 p = ALLOC( If_Man_t, 1 ); 00052 memset( p, 0, sizeof(If_Man_t) ); 00053 p->pPars = pPars; 00054 p->fEpsilon = (float)0.001; 00055 // allocate arrays for nodes 00056 p->vCis = Vec_PtrAlloc( 100 ); 00057 p->vCos = Vec_PtrAlloc( 100 ); 00058 p->vObjs = Vec_PtrAlloc( 100 ); 00059 p->vMapped = Vec_PtrAlloc( 100 ); 00060 p->vTemp = Vec_PtrAlloc( 100 ); 00061 // prepare the memory manager 00062 p->nTruthWords = p->pPars->fTruth? If_CutTruthWords( p->pPars->nLutSize ) : 0; 00063 p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0; 00064 p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords + p->nTruthWords); 00065 p->nCutBytes = sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords + p->nTruthWords); 00066 p->nSetBytes = sizeof(If_Set_t) + (sizeof(If_Cut_t *) + p->nCutBytes) * (p->pPars->nCutsMax + 1); 00067 p->pMemObj = Mem_FixedStart( p->nObjBytes ); 00068 // p->pMemSet = Mem_FixedStart( p->nSetBytes ); 00069 // report expected memory usage 00070 if ( p->pPars->fVerbose ) 00071 printf( "Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d.\n", 00072 4 * p->nTruthWords, p->nCutBytes, p->nObjBytes, p->nSetBytes ); 00073 // room for temporary truth tables 00074 p->puTemp[0] = p->pPars->fTruth? ALLOC( unsigned, 4 * p->nTruthWords ) : NULL; 00075 p->puTemp[1] = p->puTemp[0] + p->nTruthWords; 00076 p->puTemp[2] = p->puTemp[1] + p->nTruthWords; 00077 p->puTemp[3] = p->puTemp[2] + p->nTruthWords; 00078 // create the constant node 00079 p->pConst1 = If_ManSetupObj( p ); 00080 p->pConst1->Type = IF_CONST1; 00081 p->pConst1->fPhase = 1; 00082 p->nObjs[IF_CONST1]++; 00083 return p; 00084 }
void If_ManStop | ( | If_Man_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 125 of file ifMan.c.
00126 { 00127 Vec_PtrFree( p->vCis ); 00128 Vec_PtrFree( p->vCos ); 00129 Vec_PtrFree( p->vObjs ); 00130 Vec_PtrFree( p->vMapped ); 00131 Vec_PtrFree( p->vTemp ); 00132 if ( p->vLatchOrder ) Vec_PtrFree( p->vLatchOrder ); 00133 if ( p->vLags ) Vec_IntFree( p->vLags ); 00134 Mem_FixedStop( p->pMemObj, 0 ); 00135 FREE( p->pMemCi ); 00136 FREE( p->pMemAnd ); 00137 FREE( p->puTemp[0] ); 00138 // free pars memory 00139 if ( p->pPars->pTimesArr ) 00140 FREE( p->pPars->pTimesArr ); 00141 if ( p->pPars->pTimesReq ) 00142 FREE( p->pPars->pTimesReq ); 00143 free( p ); 00144 }