diff options
Diffstat (limited to 'src/bdd/reo')
-rw-r--r-- | src/bdd/reo/reo.h | 16 | ||||
-rw-r--r-- | src/bdd/reo/reoApi.c | 30 | ||||
-rw-r--r-- | src/bdd/reo/reoCore.c | 86 | ||||
-rw-r--r-- | src/bdd/reo/reoProfile.c | 8 | ||||
-rw-r--r-- | src/bdd/reo/reoSwap.c | 4 | ||||
-rw-r--r-- | src/bdd/reo/reoTest.c | 6 | ||||
-rw-r--r-- | src/bdd/reo/reoTransfer.c | 6 | ||||
-rw-r--r-- | src/bdd/reo/reoUnits.c | 10 |
8 files changed, 81 insertions, 85 deletions
diff --git a/src/bdd/reo/reo.h b/src/bdd/reo/reo.h index 24e12c32..2f9c421e 100644 --- a/src/bdd/reo/reo.h +++ b/src/bdd/reo/reo.h @@ -19,20 +19,18 @@ #ifndef __REO_H__ #define __REO_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdio.h> #include <stdlib.h> #include "extra.h" -//#pragma warning( disable : 4514 ) - //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + // reordering parameters #define REO_REORDER_LIMIT 1.15 // determines the quality/runtime trade-off #define REO_QUAL_PAR 3 // the quality [1 = simple lower bound, 2 = strict, larger = heuristic] @@ -171,9 +169,9 @@ struct _reo_man }; // used to manipulate units -#define Unit_Regular(u) ((reo_unit *)((PORT_PTRUINT_T)(u) & ~01)) -#define Unit_Not(u) ((reo_unit *)((PORT_PTRUINT_T)(u) ^ 01)) -#define Unit_NotCond(u,c) ((reo_unit *)((PORT_PTRUINT_T)(u) ^ (c))) +#define Unit_Regular(u) ((reo_unit *)((ABC_PTRUINT_T)(u) & ~01)) +#define Unit_Not(u) ((reo_unit *)((ABC_PTRUINT_T)(u) ^ 01)) +#define Unit_NotCond(u,c) ((reo_unit *)((ABC_PTRUINT_T)(u) ^ (c))) #define Unit_IsConstant(u) ((int)((u)->lev == REO_CONST_LEVEL)) //////////////////////////////////////////////////////////////////////// diff --git a/src/bdd/reo/reoApi.c b/src/bdd/reo/reoApi.c index e833dabd..000489ed 100644 --- a/src/bdd/reo/reoApi.c +++ b/src/bdd/reo/reoApi.c @@ -48,7 +48,7 @@ reo_man * Extra_ReorderInit( int nDdVarsMax, int nNodesMax ) { reo_man * p; // allocate and clean the data structure - p = ALLOC( reo_man, 1 ); + p = ABC_ALLOC( reo_man, 1 ); memset( p, 0, sizeof(reo_man) ); // resize the manager to meet user's needs reoResizeStructures( p, nDdVarsMax, nNodesMax, 100 ); @@ -75,21 +75,21 @@ reo_man * Extra_ReorderInit( int nDdVarsMax, int nNodesMax ) ***********************************************************************/ void Extra_ReorderQuit( reo_man * p ) { - free( p->pTops ); - free( p->pSupp ); - free( p->pOrderInt ); - free( p->pWidthCofs ); - free( p->pMapToPlanes ); - free( p->pMapToDdVarsOrig ); - free( p->pMapToDdVarsFinal ); - free( p->pPlanes ); - free( p->pVarCosts ); - free( p->pLevelOrder ); - free( p->HTable ); - free( p->pRefNodes ); + ABC_FREE( p->pTops ); + ABC_FREE( p->pSupp ); + ABC_FREE( p->pOrderInt ); + ABC_FREE( p->pWidthCofs ); + ABC_FREE( p->pMapToPlanes ); + ABC_FREE( p->pMapToDdVarsOrig ); + ABC_FREE( p->pMapToDdVarsFinal ); + ABC_FREE( p->pPlanes ); + ABC_FREE( p->pVarCosts ); + ABC_FREE( p->pLevelOrder ); + ABC_FREE( p->HTable ); + ABC_FREE( p->pRefNodes ); reoUnitsStopDispenser( p ); - free( p->pMemChunks ); - free( p ); + ABC_FREE( p->pMemChunks ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/bdd/reo/reoCore.c b/src/bdd/reo/reoCore.c index 3782631c..a37bae13 100644 --- a/src/bdd/reo/reoCore.c +++ b/src/bdd/reo/reoCore.c @@ -22,8 +22,6 @@ /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -#define CALLOC(type, num) ((type *) calloc((long)(num), (long)sizeof(type))) - static int reoRecursiveDeref( reo_unit * pUnit ); static int reoCheckZeroRefs( reo_plane * pPlane ); static int reoCheckLevels( reo_man * p ); @@ -217,7 +215,7 @@ s_AplAfter = p->nAplEnd; if ( p->pOrder == NULL ) { - pOrder = ALLOC( int, p->nSupp ); + pOrder = ABC_ALLOC( int, p->nSupp ); for ( i = 0; i < p->nSupp; i++ ) pOrder[ p->pMapToDdVarsFinal[i] ] = p->pMapToDdVarsOrig[ p->pOrderInt[i] ]; } @@ -246,7 +244,7 @@ s_AplAfter = p->nAplEnd; printf( "REO: Internal verification is okay!\n" ); if ( p->pOrder == NULL ) - free( pOrder ); + ABC_FREE( pOrder ); } // recycle the data structure @@ -270,35 +268,35 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs // resize data structures depending on the number of variables in the DD manager if ( p->nSuppAlloc == 0 ) { - p->pSupp = ALLOC( int, nDdVarsMax + 1 ); - p->pOrderInt = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToPlanes = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsOrig = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsFinal = ALLOC( int, nDdVarsMax + 1 ); - p->pPlanes = CALLOC( reo_plane, nDdVarsMax + 1 ); - p->pVarCosts = ALLOC( double, nDdVarsMax + 1 ); - p->pLevelOrder = ALLOC( int, nDdVarsMax + 1 ); + p->pSupp = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pOrderInt = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToPlanes = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsOrig = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsFinal = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pPlanes = ABC_CALLOC( reo_plane, nDdVarsMax + 1 ); + p->pVarCosts = ABC_ALLOC( double, nDdVarsMax + 1 ); + p->pLevelOrder = ABC_ALLOC( int, nDdVarsMax + 1 ); p->nSuppAlloc = nDdVarsMax + 1; } else if ( p->nSuppAlloc < nDdVarsMax ) { - free( p->pSupp ); - free( p->pOrderInt ); - free( p->pMapToPlanes ); - free( p->pMapToDdVarsOrig ); - free( p->pMapToDdVarsFinal ); - free( p->pPlanes ); - free( p->pVarCosts ); - free( p->pLevelOrder ); - - p->pSupp = ALLOC( int, nDdVarsMax + 1 ); - p->pOrderInt = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToPlanes = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsOrig = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsFinal = ALLOC( int, nDdVarsMax + 1 ); - p->pPlanes = CALLOC( reo_plane, nDdVarsMax + 1 ); - p->pVarCosts = ALLOC( double, nDdVarsMax + 1 ); - p->pLevelOrder = ALLOC( int, nDdVarsMax + 1 ); + ABC_FREE( p->pSupp ); + ABC_FREE( p->pOrderInt ); + ABC_FREE( p->pMapToPlanes ); + ABC_FREE( p->pMapToDdVarsOrig ); + ABC_FREE( p->pMapToDdVarsFinal ); + ABC_FREE( p->pPlanes ); + ABC_FREE( p->pVarCosts ); + ABC_FREE( p->pLevelOrder ); + + p->pSupp = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pOrderInt = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToPlanes = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsOrig = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsFinal = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pPlanes = ABC_CALLOC( reo_plane, nDdVarsMax + 1 ); + p->pVarCosts = ABC_ALLOC( double, nDdVarsMax + 1 ); + p->pLevelOrder = ABC_ALLOC( int, nDdVarsMax + 1 ); p->nSuppAlloc = nDdVarsMax + 1; } @@ -310,10 +308,10 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs p->nRefNodesAlloc = 3*nNodesMax + 1; p->nMemChunksAlloc = (10*nNodesMax + 1)/REO_CHUNK_SIZE + 1; - p->HTable = CALLOC( reo_hash, p->nTableSize ); - p->pRefNodes = ALLOC( DdNode *, p->nRefNodesAlloc ); - p->pWidthCofs = ALLOC( reo_unit *, p->nRefNodesAlloc ); - p->pMemChunks = ALLOC( reo_unit *, p->nMemChunksAlloc ); + p->HTable = ABC_CALLOC( reo_hash, p->nTableSize ); + p->pRefNodes = ABC_ALLOC( DdNode *, p->nRefNodesAlloc ); + p->pWidthCofs = ABC_ALLOC( reo_unit *, p->nRefNodesAlloc ); + p->pMemChunks = ABC_ALLOC( reo_unit *, p->nMemChunksAlloc ); } else if ( p->nNodesMaxAlloc < nNodesMax ) { @@ -325,29 +323,29 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs p->nRefNodesAlloc = 3*nNodesMax + 1; p->nMemChunksAlloc = (10*nNodesMax + 1)/REO_CHUNK_SIZE + 1; - free( p->HTable ); - free( p->pRefNodes ); - free( p->pWidthCofs ); - p->HTable = CALLOC( reo_hash, p->nTableSize ); - p->pRefNodes = ALLOC( DdNode *, p->nRefNodesAlloc ); - p->pWidthCofs = ALLOC( reo_unit *, p->nRefNodesAlloc ); + ABC_FREE( p->HTable ); + ABC_FREE( p->pRefNodes ); + ABC_FREE( p->pWidthCofs ); + p->HTable = ABC_CALLOC( reo_hash, p->nTableSize ); + p->pRefNodes = ABC_ALLOC( DdNode *, p->nRefNodesAlloc ); + p->pWidthCofs = ABC_ALLOC( reo_unit *, p->nRefNodesAlloc ); // p->pMemChunks should be reallocated because it contains pointers currently in use - pTemp = ALLOC( reo_unit *, p->nMemChunksAlloc ); + pTemp = ABC_ALLOC( reo_unit *, p->nMemChunksAlloc ); memmove( pTemp, p->pMemChunks, sizeof(reo_unit *) * nMemChunksAllocPrev ); - free( p->pMemChunks ); + ABC_FREE( p->pMemChunks ); p->pMemChunks = pTemp; } // resize the data structures depending on the number of functions if ( p->nTopsAlloc == 0 ) { - p->pTops = ALLOC( reo_unit *, nFuncs ); + p->pTops = ABC_ALLOC( reo_unit *, nFuncs ); p->nTopsAlloc = nFuncs; } else if ( p->nTopsAlloc < nFuncs ) { - free( p->pTops ); - p->pTops = ALLOC( reo_unit *, nFuncs ); + ABC_FREE( p->pTops ); + p->pTops = ABC_ALLOC( reo_unit *, nFuncs ); p->nTopsAlloc = nFuncs; } } diff --git a/src/bdd/reo/reoProfile.c b/src/bdd/reo/reoProfile.c index 84a0bc19..8a48d809 100644 --- a/src/bdd/reo/reoProfile.c +++ b/src/bdd/reo/reoProfile.c @@ -132,8 +132,8 @@ void reoProfileWidthStart( reo_man * p ) int v; // allocate and clean the storage for starting and stopping levels - pWidthStart = ALLOC( int, p->nSupp + 1 ); - pWidthStop = ALLOC( int, p->nSupp + 1 ); + pWidthStart = ABC_ALLOC( int, p->nSupp + 1 ); + pWidthStop = ABC_ALLOC( int, p->nSupp + 1 ); memset( pWidthStart, 0, sizeof(int) * (p->nSupp + 1) ); memset( pWidthStop, 0, sizeof(int) * (p->nSupp + 1) ); @@ -200,8 +200,8 @@ void reoProfileWidthStart( reo_man * p ) // printf( "Level %2d: Width = %5d. Correct = %d.\n", v, Temp, p->pPlanes[v].statsWidth ); } p->nWidthBeg = p->nWidthCur; - free( pWidthStart ); - free( pWidthStop ); + ABC_FREE( pWidthStart ); + ABC_FREE( pWidthStop ); } /**Function******************************************************************** diff --git a/src/bdd/reo/reoSwap.c b/src/bdd/reo/reoSwap.c index d3a9c7a5..0e829407 100644 --- a/src/bdd/reo/reoSwap.c +++ b/src/bdd/reo/reoSwap.c @@ -233,7 +233,7 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp ) // (2) walk through the uppoer level, and tranform all the remaning nodes // while employing cache for the new lower level // (3) walk through the old lower level, find those nodes whose ref counters are not zero, - // and move them to the new uppoer level, free other nodes + // and move them to the new uppoer level, ABC_FREE other nodes // (1) walk through the upper level, find units without cofactors in the lower level // and move them to the new lower level (while adding to the cache) @@ -759,7 +759,7 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp ) } // (3) walk through the old lower level, find those nodes whose ref counters are not zero, - // and move them to the new uppoer level, free other nodes + // and move them to the new uppoer level, ABC_FREE other nodes for ( pLoop = pListOld1; pLoop; ) { pUnit = pLoop; diff --git a/src/bdd/reo/reoTest.c b/src/bdd/reo/reoTest.c index 82f3d5f5..f0e70cf9 100644 --- a/src/bdd/reo/reoTest.c +++ b/src/bdd/reo/reoTest.c @@ -115,9 +115,9 @@ DdNode * Extra_ReorderCudd( DdManager * dd, DdNode * aFunc, int pPermuteReo[] ) // start the reordering manager if ( ddReorder == NULL ) { - Permute = ALLOC( int, dd->size ); - PermuteReo1 = ALLOC( int, dd->size ); - PermuteReo2 = ALLOC( int, dd->size ); + Permute = ABC_ALLOC( int, dd->size ); + PermuteReo1 = ABC_ALLOC( int, dd->size ); + PermuteReo2 = ABC_ALLOC( int, dd->size ); ddReorder = Cudd_Init( dd->size, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); Cudd_AutodynDisable(ddReorder); } diff --git a/src/bdd/reo/reoTransfer.c b/src/bdd/reo/reoTransfer.c index 26a6689e..ec02ac0c 100644 --- a/src/bdd/reo/reoTransfer.c +++ b/src/bdd/reo/reoTransfer.c @@ -69,7 +69,7 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F ) if ( cuddIsConstant(F) ) { pUnit->lev = REO_CONST_LEVEL; - pUnit->pE = (reo_unit*)((int)(PORT_PTRUINT_T)(cuddV(F))); + pUnit->pE = (reo_unit*)((int)(ABC_PTRUINT_T)(cuddV(F))); pUnit->pT = NULL; // check if the diagram that is being reordering has complement edges if ( F != dd->one ) @@ -89,7 +89,7 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F ) // add to the hash table if ( F->ref != 1 ) { - // the next free entry is already found - it is pointed to by HKey + // the next ABC_FREE entry is already found - it is pointed to by HKey // while we traversed the diagram, the hash entry to which HKey points, // might have been used. Make sure that its signature is different. for ( ; p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize ); @@ -139,7 +139,7 @@ DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit ) // treat the case of constants if ( Unit_IsConstant(pUnit) ) { - bRes = cuddUniqueConst( dd, ((double)((int)(PORT_PTRUINT_T)(pUnit->pE))) ); + bRes = cuddUniqueConst( dd, ((double)((int)(ABC_PTRUINT_T)(pUnit->pE))) ); cuddRef( bRes ); } else diff --git a/src/bdd/reo/reoUnits.c b/src/bdd/reo/reoUnits.c index 52137027..f8bca7ad 100644 --- a/src/bdd/reo/reoUnits.c +++ b/src/bdd/reo/reoUnits.c @@ -30,7 +30,7 @@ static void reoUnitsAddToFreeUnitList( reo_man * p ); /**Function************************************************************* - Synopsis [Extract the next unit from the free unit list.] + Synopsis [Extract the next unit from the ABC_FREE unit list.] Description [] @@ -54,7 +54,7 @@ reo_unit * reoUnitsGetNextUnit(reo_man * p ) /**Function************************************************************* - Synopsis [Returns the unit to the free unit list.] + Synopsis [Returns the unit to the ABC_FREE unit list.] Description [] @@ -72,7 +72,7 @@ void reoUnitsRecycleUnit( reo_man * p, reo_unit * pUnit ) /**Function************************************************************* - Synopsis [Returns the list of units to the free unit list.] + Synopsis [Returns the list of units to the ABC_FREE unit list.] Description [] @@ -112,7 +112,7 @@ void reoUnitsStopDispenser( reo_man * p ) { int i; for ( i = 0; i < p->nMemChunks; i++ ) - free( p->pMemChunks[i] ); + ABC_FREE( p->pMemChunks[i] ); // printf("\nThe number of chunks used is %d, each of them %d units\n", p->nMemChunks, REO_CHUNK_SIZE ); p->nMemChunks = 0; } @@ -167,7 +167,7 @@ void reoUnitsAddToFreeUnitList( reo_man * p ) } // allocate the next chunk assert( p->pUnitFreeList == NULL ); - p->pUnitFreeList = ALLOC( reo_unit, REO_CHUNK_SIZE ); + p->pUnitFreeList = ABC_ALLOC( reo_unit, REO_CHUNK_SIZE ); // split chunks into list-connected units for ( c = 0; c < REO_CHUNK_SIZE-1; c++ ) (p->pUnitFreeList + c)->Next = p->pUnitFreeList + c + 1; |