ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifMan.c
Go to the documentation of this file.
1
20
21#include "if.h"
22
24
25
29
30static If_Obj_t * If_ManSetupObj( If_Man_t * p );
31
32static void If_ManCutSetRecycle( If_Man_t * p, If_Set_t * pSet ) { pSet->pNext = p->pFreeList; p->pFreeList = pSet; }
33static If_Set_t * If_ManCutSetFetch( If_Man_t * p ) { If_Set_t * pTemp = p->pFreeList; p->pFreeList = p->pFreeList->pNext; return pTemp; }
34
38
51{
52 If_Man_t * p; int v;
53 assert( !pPars->fUseDsd || !pPars->fUseTtPerm );
54 // start the manager
55 p = ABC_ALLOC( If_Man_t, 1 );
56 memset( p, 0, sizeof(If_Man_t) );
57 p->pPars = pPars;
58 p->fEpsilon = pPars->Epsilon;
59 // allocate arrays for nodes
60 p->vCis = Vec_PtrAlloc( 100 );
61 p->vCos = Vec_PtrAlloc( 100 );
62 p->vObjs = Vec_PtrAlloc( 100 );
63 p->vTemp = Vec_PtrAlloc( 100 );
64 p->vVisited = Vec_PtrAlloc( 100 );
65 // prepare the memory manager
66 if ( p->pPars->fTruth )
67 {
68 for ( v = 0; v <= p->pPars->nLutSize; v++ )
69 p->nTruth6Words[v] = Abc_Truth6WordNum( v );
70 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
71 p->vTtMem[v] = Vec_MemAllocForTT( v, pPars->fUseTtPerm );
72 for ( v = 0; v < 6; v++ )
73 p->vTtMem[v] = p->vTtMem[6];
74 if ( p->pPars->fDelayOpt || pPars->nGateSize > 0 )
75 {
76 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
77 p->vTtIsops[v] = Vec_WecAlloc( 1000 );
78 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
79 Vec_WecInit( p->vTtIsops[v], 2 );
80 for ( v = 0; v < 6; v++ )
81 p->vTtIsops[v] = p->vTtIsops[6];
82 }
83 if ( pPars->fDelayOpt || pPars->nGateSize > 0 || pPars->fDsdBalance )
84 {
85 p->vCover = Vec_IntAlloc( 0 );
86 p->vArray = Vec_IntAlloc( 1000 );
87 }
88 }
89 p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0;
90 p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords);
91 p->nCutBytes = sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords);
92 p->nSetBytes = sizeof(If_Set_t) + (sizeof(If_Cut_t *) + p->nCutBytes) * (p->pPars->nCutsMax + 1);
93 p->pMemObj = Mem_FixedStart( p->nObjBytes );
94 // report expected memory usage
95 if ( p->pPars->fVerbose )
96 Abc_Print( 1, "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d. CutMin = %s\n",
97 p->pPars->nLutSize, 8 * p->nTruth6Words[p->pPars->nLutSize], p->nCutBytes, p->nObjBytes, p->nSetBytes, p->pPars->fCutMin? "yes":"no" );
98 // room for temporary truth tables
99 p->puTemp[0] = p->pPars->fTruth? ABC_ALLOC( unsigned, 8 * p->nTruth6Words[p->pPars->nLutSize] ) : NULL;
100 p->puTemp[1] = p->pPars->fTruth? p->puTemp[0] + p->nTruth6Words[p->pPars->nLutSize]*2 : NULL;
101 p->puTemp[2] = p->pPars->fTruth? p->puTemp[1] + p->nTruth6Words[p->pPars->nLutSize]*2 : NULL;
102 p->puTemp[3] = p->pPars->fTruth? p->puTemp[2] + p->nTruth6Words[p->pPars->nLutSize]*2 : NULL;
103 p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words[p->pPars->nLutSize] ) : NULL;
104 if ( pPars->fUseDsd )
105 {
106 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
107 {
108 p->vTtDsds[v] = Vec_IntAlloc( 1000 );
109 Vec_IntPush( p->vTtDsds[v], 0 );
110 Vec_IntPush( p->vTtDsds[v], 2 );
111 p->vTtPerms[v] = Vec_StrAlloc( 10000 );
112 Vec_StrFill( p->vTtPerms[v], 2 * v, IF_BIG_CHAR );
113 Vec_StrWriteEntry( p->vTtPerms[v], v, 0 );
114 }
115 for ( v = 0; v < 6; v++ )
116 {
117 p->vTtDsds[v] = p->vTtDsds[6];
118 p->vTtPerms[v] = p->vTtPerms[6];
119 }
120 }
121 if ( pPars->fUseTtPerm )
122 {
123 p->vPairHash = Hash_IntManStart( 10000 );
124 p->vPairPerms = Vec_StrAlloc( 10000 );
125 Vec_StrFill( p->vPairPerms, p->pPars->nLutSize, 0 );
126 p->vPairRes = Vec_IntAlloc( 1000 );
127 Vec_IntPush( p->vPairRes, -1 );
128 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
129 p->vTtOccurs[v] = Vec_IntAlloc( 1000 );
130 for ( v = 0; v < 6; v++ )
131 p->vTtOccurs[v] = p->vTtOccurs[6];
132 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
133 Vec_IntPushTwo( p->vTtOccurs[v], 0, 0 );
134 }
135 if ( pPars->fUseCofVars )
136 {
137 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
138 {
139 p->vTtVars[v] = Vec_StrAlloc( 1000 );
140 Vec_StrPush( p->vTtVars[v], 0 );
141 Vec_StrPush( p->vTtVars[v], 0 );
142 }
143 for ( v = 0; v < 6; v++ )
144 p->vTtVars[v] = p->vTtVars[6];
145 }
146 if ( pPars->fUseAndVars )
147 {
148 for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
149 {
150 p->vTtDecs[v] = Vec_IntAlloc( 1000 );
151 Vec_IntPush( p->vTtDecs[v], 0 );
152 Vec_IntPush( p->vTtDecs[v], 0 );
153 }
154 for ( v = 0; v < 6; v++ )
155 p->vTtDecs[v] = p->vTtDecs[6];
156 }
157 if ( pPars->fUseBat )
158 {
159// abctime clk = Abc_Clock();
160 extern int Bat_ManCellFuncLookup( void * pMan, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
161 extern void Bat_ManFuncSetupTable();
162 pPars->pFuncCell = (int (*) (If_Man_t *, unsigned *, int, int, char *))Bat_ManCellFuncLookup;
164// Abc_PrintTime( 1, "Setup time", Abc_Clock() - clk );
165 }
166 // create the constant node
167 p->pConst1 = If_ManSetupObj( p );
168 p->pConst1->Type = IF_CONST1;
169 p->pConst1->fPhase = 1;
170 p->nObjs[IF_CONST1]++;
171 return p;
172}
173
186{
187 ABC_FREE( p->pMemCi );
188 Vec_PtrClear( p->vCis );
189 Vec_PtrClear( p->vCos );
190 Vec_PtrClear( p->vObjs );
191 Vec_PtrClear( p->vTemp );
192 Mem_FixedRestart( p->pMemObj );
193 // create the constant node
194 p->pConst1 = If_ManSetupObj( p );
195 p->pConst1->Type = IF_CONST1;
196 p->pConst1->fPhase = 1;
197 // reset the counter of other nodes
198 p->nObjs[IF_CI] = p->nObjs[IF_CO] = p->nObjs[IF_AND] = 0;
199}
200
213{
214 extern void If_ManCacheAnalize( If_Man_t * p );
215 int i;
216 if ( p->pPars->fVerbose && p->vCutData )
218 if ( p->pPars->fVerbose && p->pPars->fTruth )
219 {
220 int nUnique = 0, nMemTotal = 0;
221 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
222 nUnique += Vec_MemEntryNum(p->vTtMem[i]);
223 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
224 nMemTotal += (int)Vec_MemMemory(p->vTtMem[i]);
225 printf( "Unique truth tables = %d Memory = %.2f MB ", nUnique, 1.0 * nMemTotal / (1<<20) );
226 Abc_PrintTime( 1, "Time", p->timeCache[4] );
227 if ( p->nCacheMisses )
228 {
229 printf( "Cache hits = %d. Cache misses = %d (%.2f %%)\n", p->nCacheHits, p->nCacheMisses, 100.0 * p->nCacheMisses / (p->nCacheHits + p->nCacheMisses) );
230 Abc_PrintTime( 1, "Non-DSD ", p->timeCache[0] );
231 Abc_PrintTime( 1, "DSD hits ", p->timeCache[1] );
232 Abc_PrintTime( 1, "DSD misses", p->timeCache[2] );
233 Abc_PrintTime( 1, "TOTAL ", p->timeCache[0] + p->timeCache[1] + p->timeCache[2] );
234 Abc_PrintTime( 1, "Canon ", p->timeCache[3] );
235 }
236 }
237 if ( p->pPars->fVerbose && p->nCutsUselessAll )
238 {
239 for ( i = 0; i <= 16; i++ )
240 if ( p->nCutsUseless[i] )
241 Abc_Print( 1, "Useless cuts %2d = %9d (out of %9d) (%6.2f %%)\n", i, p->nCutsUseless[i], p->nCutsCount[i], 100.0*p->nCutsUseless[i]/Abc_MaxInt(p->nCutsCount[i],1) );
242 Abc_Print( 1, "Useless cuts all = %9d (out of %9d) (%6.2f %%)\n", p->nCutsUselessAll, p->nCutsCountAll, 100.0*p->nCutsUselessAll/Abc_MaxInt(p->nCutsCountAll,1) );
243 }
244// if ( p->pPars->fVerbose && p->nCuts5 )
245// Abc_Print( 1, "Statistics about 5-cuts: Total = %d Non-decomposable = %d (%.2f %%)\n", p->nCuts5, p->nCuts5-p->nCuts5a, 100.0*(p->nCuts5-p->nCuts5a)/p->nCuts5 );
246 if ( p->pIfDsdMan )
247 p->pIfDsdMan = NULL;
248 if ( p->pPars->fUseDsd && (p->nCountNonDec[0] || p->nCountNonDec[1]) )
249 printf( "NonDec0 = %d. NonDec1 = %d.\n", p->nCountNonDec[0], p->nCountNonDec[1] );
250 Vec_IntFreeP( &p->vCoAttrs );
251 Vec_PtrFree( p->vCis );
252 Vec_PtrFree( p->vCos );
253 Vec_PtrFree( p->vObjs );
254 Vec_PtrFree( p->vTemp );
255 Vec_IntFreeP( &p->vCover );
256 Vec_IntFreeP( &p->vArray );
257 Vec_WrdFreeP( &p->vAnds );
258 Vec_WrdFreeP( &p->vAndGate );
259 Vec_WrdFreeP( &p->vOrGate );
260 Vec_PtrFreeP( &p->vObjsRev );
261 Vec_PtrFreeP( &p->vLatchOrder );
262 Vec_IntFreeP( &p->vLags );
263 Vec_IntFreeP( &p->vDump );
264 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
265 Vec_IntFreeP( &p->vTtDsds[i] );
266 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
267 Vec_StrFreeP( &p->vTtPerms[i] );
268 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
269 Vec_StrFreeP( &p->vTtVars[i] );
270 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
271 Vec_IntFreeP( &p->vTtDecs[i] );
272 Vec_IntFreeP( &p->vCutData );
273 Vec_IntFreeP( &p->vPairRes );
274 Vec_StrFreeP( &p->vPairPerms );
275 Vec_PtrFreeP( &p->vVisited );
276 Vec_StrFreeP( &p->vMarks );
277 Vec_IntFreeP( &p->vVisited2 );
278 if ( p->vPairHash )
279 Hash_IntManStop( p->vPairHash );
280 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
281 Vec_MemHashFree( p->vTtMem[i] );
282 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
283 Vec_MemFreeP( &p->vTtMem[i] );
284 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
285 Vec_WecFreeP( &p->vTtIsops[i] );
286 for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
287 Vec_IntFreeP( &p->vTtOccurs[i] );
288 Mem_FixedStop( p->pMemObj, 0 );
289 if ( p->vTtMem6 )
290 {
291 Vec_MemHashFree( p->vTtMem6 );
292 Vec_MemFreeP( &p->vTtMem6 );
293 }
294 ABC_FREE( p->pMemCi );
295 ABC_FREE( p->pMemAnd );
296 ABC_FREE( p->puTemp[0] );
297 ABC_FREE( p->puTempW );
298 // free pars memory
299 ABC_FREE( p->pPars->pTimesArr );
300 ABC_FREE( p->pPars->pTimesReq );
301 if ( p->pManTim )
302 Tim_ManStop( p->pManTim );
303 if ( p->vSwitching )
304 Vec_IntFree( p->vSwitching );
305 if ( p->pPars->fUseBat )
306 {
307 extern void Bat_ManFuncSetdownTable();
309 }
310 // hash table
311// if ( p->pPars->fVerbose && p->nTableEntries[0] )
312// printf( "Hash table 2: Entries = %7d. Size = %7d.\n", p->nTableEntries[0], p->nTableSize[0] );
313// if ( p->pPars->fVerbose && p->nTableEntries[1] )
314// printf( "Hash table 3: Entries = %7d. Size = %7d.\n", p->nTableEntries[1], p->nTableSize[1] );
315 ABC_FREE( p->pHashTable[0] );
316 ABC_FREE( p->pHashTable[1] );
317 if ( p->pMemEntries )
318 Mem_FixedStop( p->pMemEntries, 0 );
319 ABC_FREE( p->pName );
320 ABC_FREE( p );
321}
322
335{
336 If_Obj_t * pObj;
337 pObj = If_ManSetupObj( p );
338 pObj->Type = IF_CI;
339 pObj->IdPio = Vec_PtrSize( p->vCis );
340 Vec_PtrPush( p->vCis, pObj );
341 p->nObjs[IF_CI]++;
342 return pObj;
343}
344
357{
358 If_Obj_t * pObj;
359 pObj = If_ManSetupObj( p );
360 pObj->IdPio = Vec_PtrSize( p->vCos );
361 Vec_PtrPush( p->vCos, pObj );
362 pObj->Type = IF_CO;
363 pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver);
364 pObj->pFanin0 = pDriver; pDriver->nRefs++;
365 pObj->fPhase = (pObj->fCompl0 ^ pDriver->fPhase);
366 pObj->Level = pDriver->Level;
367 if ( p->nLevelMax < (int)pObj->Level )
368 p->nLevelMax = (int)pObj->Level;
369 p->nObjs[IF_CO]++;
370 return pObj;
371}
372
385{
386 If_Obj_t * pObj;
387 // perform constant propagation
388 if ( pFan0 == pFan1 )
389 return pFan0;
390 if ( pFan0 == If_Not(pFan1) )
391 return If_Not(p->pConst1);
392 if ( If_Regular(pFan0) == p->pConst1 )
393 return pFan0 == p->pConst1 ? pFan1 : If_Not(p->pConst1);
394 if ( If_Regular(pFan1) == p->pConst1 )
395 return pFan1 == p->pConst1 ? pFan0 : If_Not(p->pConst1);
396 // get memory for the new object
397 pObj = If_ManSetupObj( p );
398 pObj->Type = IF_AND;
399 pObj->fCompl0 = If_IsComplement(pFan0); pFan0 = If_Regular(pFan0);
400 pObj->fCompl1 = If_IsComplement(pFan1); pFan1 = If_Regular(pFan1);
401 pObj->pFanin0 = pFan0; pFan0->nRefs++; pFan0->nVisits++; pFan0->nVisitsCopy++;
402 pObj->pFanin1 = pFan1; pFan1->nRefs++; pFan1->nVisits++; pFan1->nVisitsCopy++;
403 pObj->fPhase = (pObj->fCompl0 ^ pFan0->fPhase) & (pObj->fCompl1 ^ pFan1->fPhase);
404 pObj->Level = 1 + IF_MAX( pFan0->Level, pFan1->Level );
405 if ( p->nLevelMax < (int)pObj->Level )
406 p->nLevelMax = (int)pObj->Level;
407 p->nObjs[IF_AND]++;
408 return pObj;
409}
410
423{
424 If_Obj_t * pRes1, * pRes2;
425 pRes1 = If_ManCreateAnd( p, If_Not(pFan0), pFan1 );
426 pRes2 = If_ManCreateAnd( p, pFan0, If_Not(pFan1) );
427 return If_Not( If_ManCreateAnd( p, If_Not(pRes1), If_Not(pRes2) ) );
428}
429
441If_Obj_t * If_ManCreateMux( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1, If_Obj_t * pCtrl )
442{
443 If_Obj_t * pRes1, * pRes2;
444 pRes1 = If_ManCreateAnd( p, pFan0, If_Not(pCtrl) );
445 pRes2 = If_ManCreateAnd( p, pFan1, pCtrl );
446 return If_Not( If_ManCreateAnd( p, If_Not(pRes1), If_Not(pRes2) ) );
447}
448
461{
462 If_Obj_t * pTemp;
463 // mark the node as a representative if its class
464 assert( pObj->fRepr == 0 );
465 pObj->fRepr = 1;
466 // update the level of this node (needed for correct required time computation)
467 for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
468 {
469 pObj->Level = IF_MAX( pObj->Level, pTemp->Level );
470 pTemp->nVisits++; pTemp->nVisitsCopy++;
471 }
472 // mark the largest level
473 if ( p->nLevelMax < (int)pObj->Level )
474 p->nLevelMax = (int)pObj->Level;
475 p->nChoices++;
476}
477
490{
491 char * pArray;
492 int i;
493 pSet->nCuts = 0;
494 pSet->nCutsMax = p->pPars->nCutsMax;
495 pSet->ppCuts = (If_Cut_t **)(pSet + 1);
496 pArray = (char *)pSet->ppCuts + sizeof(If_Cut_t *) * (pSet->nCutsMax+1);
497 for ( i = 0; i <= pSet->nCutsMax; i++ )
498 {
499 pSet->ppCuts[i] = (If_Cut_t *)(pArray + i * p->nCutBytes);
500 If_CutSetup( p, pSet->ppCuts[i] );
501 }
502// pArray += (pSet->nCutsMax + 1) * p->nCutBytes;
503// assert( ((char *)pArray) - ((char *)pSet) == p->nSetBytes );
504}
505
517void If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId )
518{
519 pCut->fCompl = 0;
520 pCut->nLimit = p->pPars->nLutSize;
521 pCut->nLeaves = 1;
522 pCut->pLeaves[0] = p->pPars->fLiftLeaves? (ObjId << 8) : ObjId;
523 pCut->uSign = If_ObjCutSign( pCut->pLeaves[0] );
524 pCut->iCutFunc = p->pPars->fUseTtPerm ? 3 : (p->pPars->fTruth ? 2: -1);
525 pCut->uMaskFunc = 0;
526 assert( pCut->pLeaves[0] < p->vObjs->nSize );
527}
528
540If_Obj_t * If_ManSetupObj( If_Man_t * p )
541{
542 If_Obj_t * pObj;
543 // get memory for the object
544 pObj = (If_Obj_t *)Mem_FixedEntryFetch( p->pMemObj );
545 memset( pObj, 0, sizeof(If_Obj_t) );
546 If_CutSetup( p, &pObj->CutBest );
547 // assign ID and save
548 pObj->Id = Vec_PtrSize(p->vObjs);
549 Vec_PtrPush( p->vObjs, pObj );
550 // set the required times
551 pObj->Required = IF_FLOAT_LARGE;
552 return pObj;
553}
554
567{
568 If_Obj_t * pObj;
569 int i;
570 assert( p->pMemCi == NULL );
571 // create elementary cuts for the CIs
572 If_ManForEachCi( p, pObj, i )
573 If_ManSetupCutTriv( p, &pObj->CutBest, pObj->Id );
574 // create elementary cutsets for the CIs
575 p->pMemCi = (If_Set_t *)ABC_ALLOC( char, If_ManCiNum(p) * (sizeof(If_Set_t) + sizeof(void *)) );
576 If_ManForEachCi( p, pObj, i )
577 {
578 pObj->pCutSet = (If_Set_t *)((char *)p->pMemCi + i * (sizeof(If_Set_t) + sizeof(void *)));
579 pObj->pCutSet->nCuts = 1;
580 pObj->pCutSet->nCutsMax = p->pPars->nCutsMax;
581 pObj->pCutSet->ppCuts = (If_Cut_t **)(pObj->pCutSet + 1);
582 pObj->pCutSet->ppCuts[0] = &pObj->CutBest;
583 }
584}
585
598{
599 assert( If_ObjIsAnd(pObj) );
600 assert( pObj->pCutSet == NULL );
601// pObj->pCutSet = (If_Set_t *)Mem_FixedEntryFetch( p->pMemSet );
602// If_ManSetupSet( p, pObj->pCutSet );
603 pObj->pCutSet = If_ManCutSetFetch( p );
604 pObj->pCutSet->nCuts = 0;
605 pObj->pCutSet->nCutsMax = p->pPars->nCutsMax;
606 return pObj->pCutSet;
607}
608
621{
622 If_Obj_t * pFanin;
623 assert( If_ObjIsAnd(pObj) );
624 // consider the node
625 assert( pObj->nVisits >= 0 );
626 if ( pObj->nVisits == 0 )
627 {
628// Mem_FixedEntryRecycle( p->pMemSet, (char *)pObj->pCutSet );
629 If_ManCutSetRecycle( p, pObj->pCutSet );
630 pObj->pCutSet = NULL;
631 }
632 // consider the first fanin
633 pFanin = If_ObjFanin0(pObj);
634 assert( pFanin->nVisits > 0 );
635 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
636 {
637// Mem_FixedEntryRecycle( p->pMemSet, (char *)pFanin->pCutSet );
638 If_ManCutSetRecycle( p, pFanin->pCutSet );
639 pFanin->pCutSet = NULL;
640 }
641 // consider the second fanin
642 pFanin = If_ObjFanin1(pObj);
643 assert( pFanin->nVisits > 0 );
644 if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
645 {
646// Mem_FixedEntryRecycle( p->pMemSet, (char *)pFanin->pCutSet );
647 If_ManCutSetRecycle( p, pFanin->pCutSet );
648 pFanin->pCutSet = NULL;
649 }
650}
651
664{
665 If_Obj_t * pTemp;
666 assert( If_ObjIsAnd(pObj) );
667 assert( pObj->fRepr );
668 assert( pObj->nVisits > 0 );
669 // consider the nodes in the choice class
670 for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
671 {
672// assert( pTemp == pObj || pTemp->nVisits == 1 );
673 if ( --pTemp->nVisits == 0 )
674 {
675// Mem_FixedEntryRecycle( p->pMemSet, (char *)pTemp->pCutSet );
676 If_ManCutSetRecycle( p, pTemp->pCutSet );
677 pTemp->pCutSet = NULL;
678 }
679 }
680}
681
693void If_ManSetupSetAll( If_Man_t * p, int nCrossCut )
694{
695 If_Set_t * pCutSet;
696 int i, nCutSets;
697 nCutSets = 128 + nCrossCut;
698 p->pFreeList = p->pMemAnd = pCutSet = (If_Set_t *)ABC_ALLOC( char, nCutSets * p->nSetBytes );
699 for ( i = 0; i < nCutSets; i++ )
700 {
701 If_ManSetupSet( p, pCutSet );
702 if ( i == nCutSets - 1 )
703 pCutSet->pNext = NULL;
704 else
705 pCutSet->pNext = (If_Set_t *)( (char *)pCutSet + p->nSetBytes );
706 pCutSet = pCutSet->pNext;
707 }
708 assert( pCutSet == NULL );
709
710 if ( p->pPars->fVerbose )
711 {
712 Abc_Print( 1, "Node = %7d. Ch = %5d. Total mem = %7.2f MB. Peak cut mem = %7.2f MB.\n",
713 If_ManAndNum(p), p->nChoices,
714 1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
715 1.0 * p->nSetBytes * nCrossCut / (1<<20) );
716 }
717// Abc_Print( 1, "Cross cut = %d.\n", nCrossCut );
718
719}
720
724
725
727
#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
Cube * p
Definition exorList.c:222
void If_ManCacheAnalize(If_Man_t *p)
Definition ifCache.c:70
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition ifMan.c:517
If_Obj_t * If_ManCreateCo(If_Man_t *p, If_Obj_t *pDriver)
Definition ifMan.c:356
void If_ManSetupCiCutSets(If_Man_t *p)
Definition ifMan.c:566
void If_ManCreateChoice(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:460
If_Set_t * If_ManSetupNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:597
If_Obj_t * If_ManCreateXor(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
Definition ifMan.c:422
void If_ManDerefChoiceCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:663
void If_ManRestart(If_Man_t *p)
Definition ifMan.c:185
If_Obj_t * If_ManCreateAnd(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
Definition ifMan.c:384
If_Obj_t * If_ManCreateMux(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1, If_Obj_t *pCtrl)
Definition ifMan.c:441
void If_ManStop(If_Man_t *p)
Definition ifMan.c:212
void If_ManSetupSetAll(If_Man_t *p, int nCrossCut)
Definition ifMan.c:693
void If_ManSetupSet(If_Man_t *p, If_Set_t *pSet)
Definition ifMan.c:489
void If_ManDerefNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition ifMan.c:620
If_Man_t * If_ManStart(If_Par_t *pPars)
FUNCTION DEFINITIONS ///.
Definition ifMan.c:50
If_Obj_t * If_ManCreateCi(If_Man_t *p)
Definition ifMan.c:334
int Bat_ManCellFuncLookup(void *pMan, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition ifMatch2.c:51
ABC_NAMESPACE_IMPL_START void Bat_ManFuncSetupTable()
DECLARATIONS ///.
Definition ifMatch2.c:45
void Bat_ManFuncSetdownTable()
Definition ifMatch2.c:48
struct If_Par_t_ If_Par_t
Definition if.h:78
@ IF_CO
Definition if.h:68
@ IF_AND
Definition if.h:69
@ IF_CONST1
Definition if.h:66
@ IF_CI
Definition if.h:67
struct If_Cut_t_ If_Cut_t
Definition if.h:80
#define IF_BIG_CHAR
Definition if.h:61
#define IF_FLOAT_LARGE
Definition if.h:469
struct If_Set_t_ If_Set_t
Definition if.h:81
#define IF_MAX(a, b)
Definition if.h:466
#define If_ManForEachCi(p, pObj, i)
Definition if.h:474
struct If_Man_t_ If_Man_t
BASIC TYPES ///.
Definition if.h:77
struct If_Obj_t_ If_Obj_t
Definition if.h:79
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
void Mem_FixedStop(Mem_Fixed_t *p, int fVerbose)
Definition mem.c:139
char * Mem_FixedEntryFetch(Mem_Fixed_t *p)
Definition mem.c:184
void Mem_FixedRestart(Mem_Fixed_t *p)
Definition mem.c:255
Mem_Fixed_t * Mem_FixedStart(int nEntrySize)
FUNCTION DEFINITIONS ///.
Definition mem.c:100
int pLeaves[0]
Definition if.h:318
unsigned nLeaves
Definition if.h:316
unsigned nLimit
Definition if.h:315
unsigned fCompl
Definition if.h:311
unsigned uSign
Definition if.h:309
int uMaskFunc
Definition if.h:308
int iCutFunc
Definition if.h:307
int nRefs
Definition if.h:346
unsigned fPhase
Definition if.h:336
int IdPio
Definition if.h:345
If_Obj_t * pFanin1
Definition if.h:350
If_Obj_t * pFanin0
Definition if.h:349
unsigned Level
Definition if.h:343
int nVisits
Definition if.h:347
unsigned fRepr
Definition if.h:337
unsigned fCompl1
Definition if.h:335
If_Cut_t CutBest
Definition if.h:361
unsigned Type
Definition if.h:333
int nVisitsCopy
Definition if.h:348
If_Set_t * pCutSet
Definition if.h:360
unsigned fCompl0
Definition if.h:334
float Required
Definition if.h:353
int Id
Definition if.h:344
If_Obj_t * pEquiv
Definition if.h:351
int fUseDsd
Definition if.h:140
int nGateSize
Definition if.h:108
int fDelayOpt
Definition if.h:126
float Epsilon
Definition if.h:111
int fUseAndVars
Definition if.h:143
int fUseCofVars
Definition if.h:142
int fUseTtPerm
Definition if.h:144
int fUseBat
Definition if.h:133
int(* pFuncCell)(If_Man_t *, unsigned *, int, int, char *)
Definition if.h:180
int fDsdBalance
Definition if.h:128
If_Cut_t ** ppCuts
Definition if.h:327
short nCutsMax
Definition if.h:324
If_Set_t * pNext
Definition if.h:326
short nCuts
Definition if.h:325
void Tim_ManStop(Tim_Man_t *p)
Definition timMan.c:378
#define assert(ex)
Definition util_old.h:213
char * memset()