ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraClass.c
Go to the documentation of this file.
1
20
21#include "fra.h"
22
24
25
26/*
27 The candidate equivalence classes are stored as a vector of pointers
28 to the array of pointers to the nodes in each class.
29 The first node of the class is its representative node.
30 The representative has the smallest topological order among the class nodes.
31 The nodes inside each class are ordered according to their topological order.
32 The classes are ordered according to the topological order of their representatives.
33 The array of pointers to the class nodes is terminated with a NULL pointer.
34 To enable dynamic addition of new classes (during class refinement),
35 each array has at least as many NULLs in the end, as there are nodes in the class.
36*/
37
41
42static inline Aig_Obj_t * Fra_ObjNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pObj ) { return ppNexts[pObj->Id]; }
43static inline void Fra_ObjSetNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pObj, Aig_Obj_t * pNext ) { ppNexts[pObj->Id] = pNext; }
44
48
61{
62 Fra_Cla_t * p;
63 p = ABC_ALLOC( Fra_Cla_t, 1 );
64 memset( p, 0, sizeof(Fra_Cla_t) );
65 p->pAig = pAig;
66 p->pMemRepr = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
67 memset( p->pMemRepr, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) );
68 p->vClasses = Vec_PtrAlloc( 100 );
69 p->vClasses1 = Vec_PtrAlloc( 100 );
70 p->vClassesTemp = Vec_PtrAlloc( 100 );
71 p->vClassOld = Vec_PtrAlloc( 100 );
72 p->vClassNew = Vec_PtrAlloc( 100 );
73 p->pFuncNodeHash = Fra_SmlNodeHash;
74 p->pFuncNodeIsConst = Fra_SmlNodeIsConst;
75 p->pFuncNodesAreEqual = Fra_SmlNodesAreEqual;
76 return p;
77}
78
91{
92 ABC_FREE( p->pMemClasses );
93 ABC_FREE( p->pMemRepr );
94 if ( p->vClassesTemp ) Vec_PtrFree( p->vClassesTemp );
95 if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
96 if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
97 if ( p->vClasses1 ) Vec_PtrFree( p->vClasses1 );
98 if ( p->vClasses ) Vec_PtrFree( p->vClasses );
99 if ( p->vImps ) Vec_IntFree( p->vImps );
100 ABC_FREE( p );
101}
102
115{
116 Aig_Obj_t * pObj;
117 int i;
118 Aig_ManReprStart( p->pAig, Aig_ManObjNumMax(p->pAig) );
119 memmove( p->pAig->pReprs, p->pMemRepr, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p->pAig) );
120 if ( Vec_PtrSize(p->vClasses1) == 0 && Vec_PtrSize(p->vClasses) == 0 )
121 {
122 Aig_ManForEachObj( p->pAig, pObj, i )
123 {
124 if ( p->pAig->pReprs[i] != NULL )
125 printf( "Classes are not cleared!\n" );
126 assert( p->pAig->pReprs[i] == NULL );
127 }
128 }
129 if ( vFailed )
130 Vec_PtrForEachEntry( Aig_Obj_t *, vFailed, pObj, i )
131 p->pAig->pReprs[pObj->Id] = NULL;
132}
133
145int Fra_ClassCount( Aig_Obj_t ** pClass )
146{
147 Aig_Obj_t * pTemp;
148 int i;
149 for ( i = 0; (pTemp = pClass[i]); i++ );
150 return i;
151}
152
165{
166 Aig_Obj_t ** pClass;
167 int i, nNodes, nLits = 0;
168 nLits = Vec_PtrSize( p->vClasses1 );
169 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
170 {
171 nNodes = Fra_ClassCount( pClass );
172 assert( nNodes > 1 );
173 nLits += nNodes - 1;
174 }
175 return nLits;
176}
177
190{
191 Aig_Obj_t ** pClass;
192 int i, nNodes, nPairs = 0;
193 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
194 {
195 nNodes = Fra_ClassCount( pClass );
196 assert( nNodes > 1 );
197 nPairs += nNodes * (nNodes - 1) / 2;
198 }
199 return nPairs;
200}
201
214{
215 Aig_Obj_t * pTemp;
216 int i;
217 for ( i = 1; (pTemp = pClass[i]); i++ )
218 assert( Fra_ClassObjRepr(pTemp) == pClass[0] );
219 printf( "{ " );
220 for ( i = 0; (pTemp = pClass[i]); i++ )
221 printf( "%d(%d,%d) ", pTemp->Id, pTemp->Level, Aig_SupportSize(p->pAig,pTemp) );
222 printf( "}\n" );
223}
224
236void Fra_ClassesPrint( Fra_Cla_t * p, int fVeryVerbose )
237{
238 Aig_Obj_t ** pClass;
239 Aig_Obj_t * pObj;
240 int i;
241
242 printf( "Const = %5d. Class = %5d. Lit = %5d. ",
243 Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses), Fra_ClassesCountLits(p) );
244 if ( p->vImps && Vec_IntSize(p->vImps) > 0 )
245 printf( "Imp = %5d. ", Vec_IntSize(p->vImps) );
246 printf( "\n" );
247
248 if ( fVeryVerbose )
249 {
250 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
251 assert( Fra_ClassObjRepr(pObj) == Aig_ManConst1(p->pAig) );
252 printf( "Constants { " );
253 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
254 printf( "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
255 printf( "}\n" );
256 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
257 {
258 printf( "%3d (%3d) : ", i, Fra_ClassCount(pClass) );
259 Fra_PrintClass( p, pClass );
260 }
261 printf( "\n" );
262 }
263}
264
276void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs )
277{
278 Aig_Obj_t ** ppTable, ** ppNexts;
279 Aig_Obj_t * pObj, * pTemp;
280 int i, k, nTableSize, nEntries, nNodes, iEntry;
281
282 // allocate the hash table hashing simulation info into nodes
283 nTableSize = Abc_PrimeCudd( Aig_ManObjNumMax(p->pAig) );
284 ppTable = ABC_FALLOC( Aig_Obj_t *, nTableSize );
285 ppNexts = ABC_FALLOC( Aig_Obj_t *, nTableSize );
286 memset( ppTable, 0, sizeof(Aig_Obj_t *) * nTableSize );
287
288 // add all the nodes to the hash table
289 Vec_PtrClear( p->vClasses1 );
290 Aig_ManForEachObj( p->pAig, pObj, i )
291 {
292 if ( fLatchCorr )
293 {
294 if ( !Aig_ObjIsCi(pObj) )
295 continue;
296 }
297 else
298 {
299 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
300 continue;
301 // skip the node with more that the given number of levels
302 if ( nMaxLevs && (int)pObj->Level > nMaxLevs )
303 continue;
304 }
305 // hash the node by its simulation info
306 iEntry = p->pFuncNodeHash( pObj, nTableSize );
307 // check if the node belongs to the class of constant 1
308 if ( p->pFuncNodeIsConst( pObj ) )
309 {
310 Vec_PtrPush( p->vClasses1, pObj );
311 Fra_ClassObjSetRepr( pObj, Aig_ManConst1(p->pAig) );
312 continue;
313 }
314 // add the node to the class
315 if ( ppTable[iEntry] == NULL )
316 {
317 ppTable[iEntry] = pObj;
318 Fra_ObjSetNext( ppNexts, pObj, pObj );
319 }
320 else
321 {
322 Fra_ObjSetNext( ppNexts, pObj, Fra_ObjNext(ppNexts,ppTable[iEntry]) );
323 Fra_ObjSetNext( ppNexts, ppTable[iEntry], pObj );
324 }
325 }
326
327 // count the total number of nodes in the non-trivial classes
328 // mark the representative nodes of each equivalence class
329 nEntries = 0;
330 for ( i = 0; i < nTableSize; i++ )
331 if ( ppTable[i] && ppTable[i] != Fra_ObjNext(ppNexts, ppTable[i]) )
332 {
333 for ( pTemp = Fra_ObjNext(ppNexts, ppTable[i]), k = 1;
334 pTemp != ppTable[i];
335 pTemp = Fra_ObjNext(ppNexts, pTemp), k++ );
336 assert( k > 1 );
337 nEntries += k;
338 // mark the node
339 assert( ppTable[i]->fMarkA == 0 );
340 ppTable[i]->fMarkA = 1;
341 }
342
343 // allocate room for classes
344 p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
345 p->pMemClassesFree = p->pMemClasses + 2*nEntries;
346
347 // copy the entries into storage in the topological order
348 Vec_PtrClear( p->vClasses );
349 nEntries = 0;
350 Aig_ManForEachObj( p->pAig, pObj, i )
351 {
352 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
353 continue;
354 // skip the nodes that are not representatives of non-trivial classes
355 if ( pObj->fMarkA == 0 )
356 continue;
357 pObj->fMarkA = 0;
358 // add the class of nodes
359 Vec_PtrPush( p->vClasses, p->pMemClasses + 2*nEntries );
360 // count the number of entries in this class
361 for ( pTemp = Fra_ObjNext(ppNexts, pObj), k = 1;
362 pTemp != pObj;
363 pTemp = Fra_ObjNext(ppNexts, pTemp), k++ );
364 nNodes = k;
365 assert( nNodes > 1 );
366 // add the nodes to the class in the topological order
367 p->pMemClasses[2*nEntries] = pObj;
368 for ( pTemp = Fra_ObjNext(ppNexts, pObj), k = 1;
369 pTemp != pObj;
370 pTemp = Fra_ObjNext(ppNexts, pTemp), k++ )
371 {
372 p->pMemClasses[2*nEntries+nNodes-k] = pTemp;
373 Fra_ClassObjSetRepr( pTemp, pObj );
374 }
375 // add as many empty entries
376 p->pMemClasses[2*nEntries + nNodes] = NULL;
377 // increment the number of entries
378 nEntries += k;
379 }
380 ABC_FREE( ppTable );
381 ABC_FREE( ppNexts );
382 // now it is time to refine the classes
384// Fra_ClassesPrint( p, 0 );
385}
386
399{
400 Aig_Obj_t * pObj, ** ppThis;
401 int i;
402 assert( ppClass[0] != NULL && ppClass[1] != NULL );
403
404 // check if the class is going to be refined
405 for ( ppThis = ppClass + 1; (pObj = *ppThis); ppThis++ )
406 if ( !p->pFuncNodesAreEqual(ppClass[0], pObj) )
407 break;
408 if ( pObj == NULL )
409 return NULL;
410 // split the class
411 Vec_PtrClear( p->vClassOld );
412 Vec_PtrClear( p->vClassNew );
413 Vec_PtrPush( p->vClassOld, ppClass[0] );
414 for ( ppThis = ppClass + 1; (pObj = *ppThis); ppThis++ )
415 if ( p->pFuncNodesAreEqual(ppClass[0], pObj) )
416 Vec_PtrPush( p->vClassOld, pObj );
417 else
418 Vec_PtrPush( p->vClassNew, pObj );
419/*
420 printf( "Refining class (" );
421 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
422 printf( "%d,", pObj->Id );
423 printf( ") + (" );
424 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
425 printf( "%d,", pObj->Id );
426 printf( ")\n" );
427*/
428 // put the nodes back into the class memory
429 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
430 {
431 ppClass[i] = pObj;
432 ppClass[Vec_PtrSize(p->vClassOld)+i] = NULL;
433 Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
434 }
435 ppClass += 2*Vec_PtrSize(p->vClassOld);
436 // put the new nodes into the class memory
437 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
438 {
439 ppClass[i] = pObj;
440 ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
441 Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
442 }
443 return ppClass;
444}
445
458{
459 Aig_Obj_t ** pClass, ** pClass2;
460 int nRefis;
461 pClass = (Aig_Obj_t **)Vec_PtrEntryLast( vClasses );
462 for ( nRefis = 0; (pClass2 = Fra_RefineClassOne( p, pClass )); nRefis++ )
463 {
464 // if the original class is trivial, remove it
465 if ( pClass[1] == NULL )
466 Vec_PtrPop( vClasses );
467 // if the new class is trivial, stop
468 if ( pClass2[1] == NULL )
469 {
470 nRefis++;
471 break;
472 }
473 // othewise, add the class and continue
474 assert( pClass2[0] != NULL );
475 Vec_PtrPush( vClasses, pClass2 );
476 pClass = pClass2;
477 }
478 return nRefis;
479}
480
494{
495 Vec_Ptr_t * vTemp;
496 Aig_Obj_t ** pClass;
497 int i, nRefis;
498 // refine the classes
499 nRefis = 0;
500 Vec_PtrClear( p->vClassesTemp );
501 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
502 {
503 // add the class to the new array
504 assert( pClass[0] != NULL );
505 Vec_PtrPush( p->vClassesTemp, pClass );
506 // refine the class iteratively
507 nRefis += Fra_RefineClassLastIter( p, p->vClassesTemp );
508 }
509 // exchange the class representation
510 vTemp = p->vClassesTemp;
511 p->vClassesTemp = p->vClasses;
512 p->vClasses = vTemp;
513 return nRefis;
514}
515
527int Fra_ClassesRefine1( Fra_Cla_t * p, int fRefineNewClass, int * pSkipped )
528{
529 Aig_Obj_t * pObj, ** ppClass;
530 int i, k, nRefis = 1;
531 // check if there is anything to refine
532 if ( Vec_PtrSize(p->vClasses1) == 0 )
533 return 0;
534 // make sure constant 1 class contains only non-constant nodes
535 assert( Vec_PtrEntry(p->vClasses1,0) != Aig_ManConst1(p->pAig) );
536 // collect all the nodes to be refined
537 k = 0;
538 Vec_PtrClear( p->vClassNew );
539 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
540 {
541 if ( p->pFuncNodeIsConst( pObj ) )
542 Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
543 else
544 Vec_PtrPush( p->vClassNew, pObj );
545 }
546 Vec_PtrShrink( p->vClasses1, k );
547 if ( Vec_PtrSize(p->vClassNew) == 0 )
548 return 0;
549/*
550 printf( "Refined const-1 class: {" );
551 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
552 printf( " %d", pObj->Id );
553 printf( " }\n" );
554*/
555 if ( Vec_PtrSize(p->vClassNew) == 1 )
556 {
557 Fra_ClassObjSetRepr( (Aig_Obj_t *)Vec_PtrEntry(p->vClassNew,0), NULL );
558 return 1;
559 }
560 // create a new class composed of these nodes
561 ppClass = p->pMemClassesFree;
562 p->pMemClassesFree += 2 * Vec_PtrSize(p->vClassNew);
563 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
564 {
565 ppClass[i] = pObj;
566 ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
567 Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
568 }
569 assert( ppClass[0] != NULL );
570 Vec_PtrPush( p->vClasses, ppClass );
571 // iteratively refine this class
572 if ( fRefineNewClass )
573 nRefis += Fra_RefineClassLastIter( p, p->vClasses );
574 else if ( pSkipped )
575 (*pSkipped)++;
576 return nRefis;
577}
578
590void Fra_ClassesTest( Fra_Cla_t * p, int Id1, int Id2 )
591{
592 Aig_Obj_t ** pClass;
593 p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 4 );
594 pClass = p->pMemClasses;
595 assert( Id1 < Id2 );
596 pClass[0] = Aig_ManObj( p->pAig, Id1 );
597 pClass[1] = Aig_ManObj( p->pAig, Id2 );
598 pClass[2] = NULL;
599 pClass[3] = NULL;
600 Fra_ClassObjSetRepr( pClass[1], pClass[0] );
601 Vec_PtrPush( p->vClasses, pClass );
602}
603
616{
617 Aig_Obj_t * pObj;
618 int i, nEntries = 0;
619 Vec_PtrClear( p->pCla->vClasses1 );
620 Aig_ManForEachLoSeq( p->pManAig, pObj, i )
621 {
622 Vec_PtrPush( p->pCla->vClasses1, pObj );
623 Fra_ClassObjSetRepr( pObj, Aig_ManConst1(p->pManAig) );
624 }
625 // allocate room for classes
626 p->pCla->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) );
627 p->pCla->pMemClassesFree = p->pCla->pMemClasses + 2*nEntries;
628}
629
642{
643 int Ratio = 2;
644 Fra_Sml_t * pComb;
645 Aig_Obj_t * pObj, * pRepr, ** ppClass;
646 int * pWeights, WeightMax = 0, i, k, c;
647 // perform combinational simulation
648 pComb = Fra_SmlSimulateComb( p->pAig, 32, 0 );
649 // compute the weight of each node in the classes
650 pWeights = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) );
651 memset( pWeights, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) );
652 Aig_ManForEachObj( p->pAig, pObj, i )
653 {
654 pRepr = Fra_ClassObjRepr( pObj );
655 if ( pRepr == NULL )
656 continue;
657 pWeights[i] = Fra_SmlNodeNotEquWeight( pComb, pRepr->Id, pObj->Id );
658 WeightMax = Abc_MaxInt( WeightMax, pWeights[i] );
659 }
660 Fra_SmlStop( pComb );
661 printf( "Before: Const = %6d. Class = %6d. ", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
662 // remove nodes from classes whose weight is less than WeightMax/Ratio
663 k = 0;
664 Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
665 {
666 if ( pWeights[pObj->Id] >= WeightMax/Ratio )
667 Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
668 else
669 Fra_ClassObjSetRepr( pObj, NULL );
670 }
671 Vec_PtrShrink( p->vClasses1, k );
672 // in each class, compact the nodes
673 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
674 {
675 k = 1;
676 for ( c = 1; ppClass[c]; c++ )
677 {
678 if ( pWeights[ppClass[c]->Id] >= WeightMax/Ratio )
679 ppClass[k++] = ppClass[c];
680 else
681 Fra_ClassObjSetRepr( ppClass[c], NULL );
682 }
683 ppClass[k] = NULL;
684 }
685 // remove classes with only repr
686 k = 0;
687 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
688 if ( ppClass[1] != NULL )
689 Vec_PtrWriteEntry( p->vClasses, k++, ppClass );
690 Vec_PtrShrink( p->vClasses, k );
691 printf( "After: Const = %6d. Class = %6d. \n", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
692 ABC_FREE( pWeights );
693}
694
707{
708 Aig_Obj_t ** pClass, * pNodeMin;
709 int i, c, cMinSupp, nSuppSizeMin, nSuppSizeCur;
710 // reassign representatives in each class
711 Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
712 {
713 // collect support sizes and find the min-support node
714 cMinSupp = -1;
715 pNodeMin = NULL;
716 nSuppSizeMin = ABC_INFINITY;
717 for ( c = 0; pClass[c]; c++ )
718 {
719 nSuppSizeCur = Aig_SupportSize( p->pAig, pClass[c] );
720// nSuppSizeCur = 1;
721 if ( nSuppSizeMin > nSuppSizeCur ||
722 (nSuppSizeMin == nSuppSizeCur && pNodeMin->Level > pClass[c]->Level) )
723 {
724 nSuppSizeMin = nSuppSizeCur;
725 pNodeMin = pClass[c];
726 cMinSupp = c;
727 }
728 }
729 // skip the case when the repr did not change
730 if ( cMinSupp == 0 )
731 continue;
732 // make the new node the representative of the class
733 pClass[cMinSupp] = pClass[0];
734 pClass[0] = pNodeMin;
735 // set the representative
736 for ( c = 0; pClass[c]; c++ )
737 Fra_ClassObjSetRepr( pClass[c], c? pClass[0] : NULL );
738 }
739}
740
741
742
743static inline Aig_Obj_t * Fra_ObjEqu( Aig_Obj_t ** ppEquivs, Aig_Obj_t * pObj ) { return ppEquivs[pObj->Id]; }
744static inline void Fra_ObjSetEqu( Aig_Obj_t ** ppEquivs, Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { ppEquivs[pObj->Id] = pNode; }
745
746static inline Aig_Obj_t * Fra_ObjChild0Equ( Aig_Obj_t ** ppEquivs, Aig_Obj_t * pObj ) { return Aig_NotCond(Fra_ObjEqu(ppEquivs,Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj)); }
747static inline Aig_Obj_t * Fra_ObjChild1Equ( Aig_Obj_t ** ppEquivs, Aig_Obj_t * pObj ) { return Aig_NotCond(Fra_ObjEqu(ppEquivs,Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj)); }
748
760static inline void Fra_ClassesDeriveNode( Aig_Man_t * pManFraig, Aig_Obj_t * pObj, Aig_Obj_t ** ppEquivs )
761{
762 Aig_Obj_t * pObjNew, * pObjRepr, * pObjReprNew, * pMiter;//, * pObjNew2;
763 // skip nodes without representative
764 if ( (pObjRepr = Fra_ClassObjRepr(pObj)) == NULL )
765 return;
766 assert( pObjRepr->Id < pObj->Id );
767 // get the new node
768 pObjNew = Fra_ObjEqu( ppEquivs, pObj );
769 // get the new node of the representative
770 pObjReprNew = Fra_ObjEqu( ppEquivs, pObjRepr );
771 // if this is the same node, no need to add constraints
772 if ( Aig_Regular(pObjNew) == Aig_Regular(pObjReprNew) )
773 return;
774 // these are different nodes - perform speculative reduction
775// pObjNew2 = Aig_NotCond( pObjReprNew, pObj->fPhase ^ pObjRepr->fPhase );
776 // set the new node
777// Fra_ObjSetEqu( ppEquivs, pObj, pObjNew2 );
778 // add the constraint
779 pMiter = Aig_Exor( pManFraig, Aig_Regular(pObjNew), Aig_Regular(pObjReprNew) );
780 pMiter = Aig_NotCond( pMiter, Aig_Regular(pMiter)->fPhase ^ Aig_IsComplement(pMiter) );
781 pMiter = Aig_Not( pMiter );
782 Aig_ObjCreateCo( pManFraig, pMiter );
783}
784
797{
798 Aig_Man_t * pManFraig;
799 Aig_Obj_t * pObj, * pObjNew;
800 Aig_Obj_t ** pLatches, ** ppEquivs;
801 int i, k, f, nFramesAll = nFramesK + 1;
802 assert( Aig_ManRegNum(p->pAig) > 0 );
803 assert( Aig_ManRegNum(p->pAig) < Aig_ManCiNum(p->pAig) );
804 assert( nFramesK > 0 );
805 // start the fraig package
806 pManFraig = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * nFramesAll );
807 pManFraig->pName = Abc_UtilStrsav( p->pAig->pName );
808 pManFraig->pSpec = Abc_UtilStrsav( p->pAig->pSpec );
809 // allocate place for the node mapping
810 ppEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
811 Fra_ObjSetEqu( ppEquivs, Aig_ManConst1(p->pAig), Aig_ManConst1(pManFraig) );
812 // create latches for the first frame
813 Aig_ManForEachLoSeq( p->pAig, pObj, i )
814 Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreateCi(pManFraig) );
815 // add timeframes
816 pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
817 for ( f = 0; f < nFramesAll; f++ )
818 {
819 // create PIs for this frame
820 Aig_ManForEachPiSeq( p->pAig, pObj, i )
821 Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreateCi(pManFraig) );
822 // set the constraints on the latch outputs
823 Aig_ManForEachLoSeq( p->pAig, pObj, i )
824 Fra_ClassesDeriveNode( pManFraig, pObj, ppEquivs );
825 // add internal nodes of this frame
826 Aig_ManForEachNode( p->pAig, pObj, i )
827 {
828 pObjNew = Aig_And( pManFraig, Fra_ObjChild0Equ(ppEquivs, pObj), Fra_ObjChild1Equ(ppEquivs, pObj) );
829 Fra_ObjSetEqu( ppEquivs, pObj, pObjNew );
830 Fra_ClassesDeriveNode( pManFraig, pObj, ppEquivs );
831 }
832 if ( f == nFramesAll - 1 )
833 break;
834 if ( f == nFramesAll - 2 )
835 pManFraig->nAsserts = Aig_ManCoNum(pManFraig);
836 // save the latch input values
837 k = 0;
838 Aig_ManForEachLiSeq( p->pAig, pObj, i )
839 pLatches[k++] = Fra_ObjChild0Equ( ppEquivs, pObj );
840 // insert them to the latch output values
841 k = 0;
842 Aig_ManForEachLoSeq( p->pAig, pObj, i )
843 Fra_ObjSetEqu( ppEquivs, pObj, pLatches[k++] );
844 }
845 ABC_FREE( pLatches );
846 ABC_FREE( ppEquivs );
847 // mark the asserts
848 assert( Aig_ManCoNum(pManFraig) % nFramesAll == 0 );
849printf( "Assert miters = %6d. Output miters = %6d.\n",
850 pManFraig->nAsserts, Aig_ManCoNum(pManFraig) - pManFraig->nAsserts );
851 // remove dangling nodes
852 Aig_ManCleanup( pManFraig );
853 return pManFraig;
854}
855
859
860
862
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition aigRepr.c:45
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition aig.h:447
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
int Aig_SupportSize(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition aigDfs.c:772
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Aig_Obj_t * Aig_Exor(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:220
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition aig.h:438
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition aig.h:441
Cube * p
Definition exorList.c:222
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition fraClass.c:527
void Fra_ClassesCopyReprs(Fra_Cla_t *p, Vec_Ptr_t *vFailed)
Definition fraClass.c:114
Fra_Cla_t * Fra_ClassesStart(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition fraClass.c:60
Aig_Man_t * Fra_ClassesDeriveAig(Fra_Cla_t *p, int nFramesK)
Definition fraClass.c:796
void Fra_ClassesTest(Fra_Cla_t *p, int Id1, int Id2)
Definition fraClass.c:590
void Fra_ClassesStop(Fra_Cla_t *p)
Definition fraClass.c:90
void Fra_ClassesPrepare(Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
Definition fraClass.c:276
void Fra_PrintClass(Fra_Cla_t *p, Aig_Obj_t **pClass)
Definition fraClass.c:213
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition fraClass.c:493
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition fraClass.c:164
void Fra_ClassesPostprocess(Fra_Cla_t *p)
Definition fraClass.c:641
void Fra_ClassesLatchCorr(Fra_Man_t *p)
Definition fraClass.c:615
Aig_Obj_t ** Fra_RefineClassOne(Fra_Cla_t *p, Aig_Obj_t **ppClass)
Definition fraClass.c:398
void Fra_ClassesSelectRepr(Fra_Cla_t *p)
Definition fraClass.c:706
int Fra_RefineClassLastIter(Fra_Cla_t *p, Vec_Ptr_t *vClasses)
Definition fraClass.c:457
int Fra_ClassesCountPairs(Fra_Cla_t *p)
Definition fraClass.c:189
void Fra_ClassesPrint(Fra_Cla_t *p, int fVeryVerbose)
Definition fraClass.c:236
int Fra_ClassCount(Aig_Obj_t **pClass)
Definition fraClass.c:145
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
Definition fraSim.c:86
void Fra_SmlStop(Fra_Sml_t *p)
Definition fraSim.c:839
struct Fra_Man_t_ Fra_Man_t
Definition fra.h:56
int Fra_SmlNodeNotEquWeight(Fra_Sml_t *p, int Left, int Right)
Definition fraSim.c:133
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition fraClass.c:164
struct Fra_Sml_t_ Fra_Sml_t
Definition fra.h:58
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Definition fraSim.c:856
int Fra_SmlNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition fraSim.c:109
int Fra_SmlNodeHash(Aig_Obj_t *pObj, int nTableSize)
DECLARATIONS ///.
Definition fraSim.c:46
struct Fra_Cla_t_ Fra_Cla_t
Definition fra.h:57
int Id
Definition aig.h:85
unsigned int fMarkA
Definition aig.h:79
unsigned Level
Definition aig.h:82
#define assert(ex)
Definition util_old.h:213
char * memset()
char * memmove()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55