abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigFact.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [aigFactor.c]
4 
5  SystemName []
6 
7  PackageName []
8 
9  Synopsis []
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation []
14 
15  Date [Ver. 1.0. Started - April 17, 2009.]
16 
17  Revision [$Id: aigFactor.c,v 1.00 2009/04/17 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "aig.h"
22 #include "bool/kit/kit.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis [Detects multi-input AND gate rooted at this node.]
38 
39  Description []
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
47 {
48  if ( Aig_IsComplement(pObj) || Aig_ObjIsCi(pObj) )
49  {
50  Vec_PtrPushUnique( vImplics, pObj );
51  return;
52  }
53  Aig_ManFindImplications_rec( Aig_ObjChild0(pObj), vImplics );
54  Aig_ManFindImplications_rec( Aig_ObjChild1(pObj), vImplics );
55 }
56 
57 /**Function*************************************************************
58 
59  Synopsis [Returns the nodes whose values are implied by pNode.]
60 
61  Description [Attention! Both pNode and results can be complemented!
62  Also important: Currently, this procedure only does backward propagation.
63  In general, it may find more implications if forward propagation is enabled.]
64 
65  SideEffects []
66 
67  SeeAlso []
68 
69 ***********************************************************************/
71 {
72  Vec_Ptr_t * vImplics;
73  vImplics = Vec_PtrAlloc( 100 );
74  Aig_ManFindImplications_rec( pNode, vImplics );
75  return vImplics;
76 }
77 
78 /**Function*************************************************************
79 
80  Synopsis [Returns 1 if the cone of the node overlaps with the vector.]
81 
82  Description []
83 
84  SideEffects []
85 
86  SeeAlso []
87 
88 ***********************************************************************/
90 {
91  if ( Aig_ObjIsTravIdPrevious( p, pNode ) )
92  return 1;
93  if ( Aig_ObjIsTravIdCurrent( p, pNode ) )
94  return 0;
95  Aig_ObjSetTravIdCurrent( p, pNode );
96  if ( Aig_ObjIsCi(pNode) )
97  return 0;
98  if ( Aig_ManFindConeOverlap_rec( p, Aig_ObjFanin0(pNode) ) )
99  return 1;
100  if ( Aig_ManFindConeOverlap_rec( p, Aig_ObjFanin1(pNode) ) )
101  return 1;
102  return 0;
103 }
104 
105 /**Function*************************************************************
106 
107  Synopsis [Returns 1 if the cone of the node overlaps with the vector.]
108 
109  Description []
110 
111  SideEffects []
112 
113  SeeAlso []
114 
115 ***********************************************************************/
116 int Aig_ManFindConeOverlap( Aig_Man_t * p, Vec_Ptr_t * vImplics, Aig_Obj_t * pNode )
117 {
118  Aig_Obj_t * pTemp;
119  int i;
120  assert( !Aig_IsComplement(pNode) );
121  assert( !Aig_ObjIsConst1(pNode) );
123  Vec_PtrForEachEntry( Aig_Obj_t *, vImplics, pTemp, i )
126  return Aig_ManFindConeOverlap_rec( p, pNode );
127 }
128 
129 /**Function*************************************************************
130 
131  Synopsis [Returns 1 if the cone of the node overlaps with the vector.]
132 
133  Description []
134 
135  SideEffects []
136 
137  SeeAlso []
138 
139 ***********************************************************************/
141 {
142  if ( Aig_ObjIsTravIdCurrent( p, pNode ) )
143  return (Aig_Obj_t *)pNode->pData;
144  Aig_ObjSetTravIdCurrent( p, pNode );
145  if ( Aig_ObjIsCi(pNode) )
146  return (Aig_Obj_t *)(pNode->pData = pNode);
149  return (Aig_Obj_t *)(pNode->pData = Aig_And( p, Aig_ObjChild0Copy(pNode), Aig_ObjChild1Copy(pNode) ));
150 }
151 
152 /**Function*************************************************************
153 
154  Synopsis [Returns 1 if the cone of the node overlaps with the vector.]
155 
156  Description []
157 
158  SideEffects []
159 
160  SeeAlso []
161 
162 ***********************************************************************/
164 {
165  Aig_Obj_t * pTemp;
166  int i;
167  assert( !Aig_IsComplement(pNode) );
168  assert( !Aig_ObjIsConst1(pNode) );
170  Vec_PtrForEachEntry( Aig_Obj_t *, vImplics, pTemp, i )
171  {
174  }
175  return Aig_ManDeriveNewCone_rec( p, pNode );
176 }
177 
178 /**Function*************************************************************
179 
180  Synopsis [Returns algebraic factoring of B in terms of A.]
181 
182  Description [Returns internal node C (an AND gate) that is equal to B
183  under assignment A = 'Value', or NULL if there is no such node C. ]
184 
185  SideEffects []
186 
187  SeeAlso []
188 
189 ***********************************************************************/
191 {
192  Aig_Obj_t * pNodeA, * pNodeC;
193  Vec_Ptr_t * vImplics;
194  int RetValue;
196  return NULL;
197  if ( Aig_ObjIsCi(Aig_ObjFanin0(pPoB)) )
198  return NULL;
199  // get the internal node representing function of A under assignment A = 'Value'
200  pNodeA = Aig_ObjChild0( pPoA );
201  pNodeA = Aig_NotCond( pNodeA, Value==0 );
202  // find implications of this signal (nodes whose value is fixed under assignment A = 'Value')
203  vImplics = Aig_ManFindImplications( p, pNodeA );
204  // check if the TFI cone of B overlaps with the implied nodes
205  RetValue = Aig_ManFindConeOverlap( p, vImplics, Aig_ObjFanin0(pPoB) );
206  if ( RetValue == 0 ) // no overlap
207  {
208  Vec_PtrFree( vImplics );
209  return NULL;
210  }
211  // there is overlap - derive node representing value of B under assignment A = 'Value'
212  pNodeC = Aig_ManDeriveNewCone( p, vImplics, Aig_ObjFanin0(pPoB) );
213  pNodeC = Aig_NotCond( pNodeC, Aig_ObjFaninC0(pPoB) );
214  Vec_PtrFree( vImplics );
215  return pNodeC;
216 }
217 
218 /**Function*************************************************************
219 
220  Synopsis [Returns algebraic factoring of B in terms of A.]
221 
222  Description [Returns internal node C (an AND gate) that is equal to B
223  under assignment A = 'Value', or NULL if there is no such node C. ]
224 
225  SideEffects []
226 
227  SeeAlso []
228 
229 ***********************************************************************/
230 Aig_Obj_t * Aig_ManFactorAlgebraic( Aig_Man_t * p, int iPoA, int iPoB, int Value )
231 {
232  assert( iPoA >= 0 && iPoA < Aig_ManCoNum(p) );
233  assert( iPoB >= 0 && iPoB < Aig_ManCoNum(p) );
234  assert( Value == 0 || Value == 1 );
235  return Aig_ManFactorAlgebraic_int( p, Aig_ManCo(p, iPoA), Aig_ManCo(p, iPoB), Value );
236 }
237 
238 /**Function*************************************************************
239 
240  Synopsis [Testing procedure.]
241 
242  Description []
243 
244  SideEffects []
245 
246  SeeAlso []
247 
248 ***********************************************************************/
250 {
251  int iPoA = 0;
252  int iPoB = 1;
253  int Value = 0;
254  Aig_Obj_t * pRes;
255 // Aig_Obj_t * pObj;
256 // int i;
257  pRes = Aig_ManFactorAlgebraic( p, iPoA, iPoB, Value );
258  Aig_ManShow( p, 0, NULL );
259  Aig_ObjPrint( p, pRes );
260  printf( "\n" );
261 /*
262  printf( "Results:\n" );
263  Aig_ManForEachObj( p, pObj, i )
264  {
265  printf( "Object = %d.\n", i );
266  Aig_ObjPrint( p, pObj );
267  printf( "\n" );
268  Aig_ObjPrint( p, pObj->pData );
269  printf( "\n" );
270  }
271 */
272 }
273 
274 
275 
276 /**Function*************************************************************
277 
278  Synopsis [Determines what support variables can be cofactored.]
279 
280  Description []
281 
282  SideEffects []
283 
284  SeeAlso []
285 
286 ***********************************************************************/
288 {
289  Aig_Obj_t * pObj;
290  Vec_Ptr_t * vTrSupp, * vTrNode, * vCofs;
291  unsigned * uFunc = NULL, * uCare, * uFunc0, * uFunc1;
292  unsigned * uCof0, * uCof1, * uCare0, * uCare1;
293  int i, nWords = Abc_TruthWordNum( Vec_PtrSize(vSupp) );
294  // assign support nodes
295  vTrSupp = Vec_PtrAllocTruthTables( Vec_PtrSize(vSupp) );
296  Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
297  pObj->pData = Vec_PtrEntry( vTrSupp, i );
298  // compute internal nodes
299  vTrNode = Vec_PtrAllocSimInfo( Vec_PtrSize(vNodes) + 5, nWords );
300  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
301  {
302  pObj->pData = uFunc = (unsigned *)Vec_PtrEntry( vTrNode, i );
303  uFunc0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
304  uFunc1 = (unsigned *)Aig_ObjFanin1(pObj)->pData;
305  Kit_TruthAndPhase( uFunc, uFunc0, uFunc1, Vec_PtrSize(vSupp), Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
306  }
307  // uFunc contains the result of computation
308  // compute care set
309  uCare = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes) );
310  Kit_TruthClear( uCare, Vec_PtrSize(vSupp) );
311  Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pObj, i )
312  Kit_TruthOrPhase( uCare, uCare, (unsigned *)Aig_Regular(pObj)->pData, Vec_PtrSize(vSupp), 0, Aig_IsComplement(pObj) );
313  // try cofactoring each variable in both polarities
314  vCofs = Vec_PtrAlloc( 10 );
315  uCof0 = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes)+1 );
316  uCof1 = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes)+2 );
317  uCare0 = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes)+3 );
318  uCare1 = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes)+4 );
319  Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
320  {
321  Kit_TruthCofactor0New( uCof0, uFunc, Vec_PtrSize(vSupp), i );
322  Kit_TruthCofactor1New( uCof1, uFunc, Vec_PtrSize(vSupp), i );
323  Kit_TruthCofactor0New( uCare0, uCare, Vec_PtrSize(vSupp), i );
324  Kit_TruthCofactor1New( uCare1, uCare, Vec_PtrSize(vSupp), i );
325  if ( Kit_TruthIsEqualWithCare( uCof0, uCof1, uCare1, Vec_PtrSize(vSupp) ) )
326  Vec_PtrPush( vCofs, Aig_Not(pObj) );
327  else if ( Kit_TruthIsEqualWithCare( uCof0, uCof1, uCare0, Vec_PtrSize(vSupp) ) )
328  Vec_PtrPush( vCofs, pObj );
329  }
330  Vec_PtrFree( vTrNode );
331  Vec_PtrFree( vTrSupp );
332  return vCofs;
333 }
334 
335 
336 
337 /**Function*************************************************************
338 
339  Synopsis [Returns the new node after cofactoring.]
340 
341  Description []
342 
343  SideEffects []
344 
345  SeeAlso []
346 
347 ***********************************************************************/
349 {
350  Aig_Obj_t * pObj = NULL;
351  int i;
352  // set the value of the support variables
353  Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
354  assert( !Aig_IsComplement(pObj) );
355  Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
356  pObj->pData = pObj;
357  // set the value of the cofactoring variables
358  Vec_PtrForEachEntry( Aig_Obj_t *, vCofs, pObj, i )
360  // reconstruct the node
361  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
362  pObj->pData = Aig_And( p, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
363  return (Aig_Obj_t *)pObj->pData;
364 }
365 
366 /**Function*************************************************************
367 
368  Synopsis [Returns 1 if all nodes of vOrGate are in vSupp.]
369 
370  Description []
371 
372  SideEffects []
373 
374  SeeAlso []
375 
376 ***********************************************************************/
378 {
379  Aig_Obj_t * pObj;
380  int i;
382  Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
383  Aig_ObjSetTravIdCurrent( p, pObj );
384  Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pObj, i )
385  if ( !Aig_ObjIsTravIdCurrent( p, Aig_Regular(pObj) ) )
386  return 0;
387  return 1;
388 }
389 
390 
391 /**Function*************************************************************
392 
393  Synopsis [Collects fanins of the marked nodes.]
394 
395  Description []
396 
397  SideEffects []
398 
399  SeeAlso []
400 
401 ***********************************************************************/
403 {
404  Vec_Ptr_t * vSupp;
405  Aig_Obj_t * pObj, * pFanin;
406  int i;
407  vSupp = Vec_PtrAlloc( 4 );
408  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
409  {
410  assert( Aig_ObjIsTravIdCurrent(p, pObj) );
411  assert( Aig_ObjIsNode(pObj) );
412  pFanin = Aig_ObjFanin0( pObj );
413  if ( !Aig_ObjIsTravIdCurrent(p, pFanin) )
414  {
415  Aig_ObjSetTravIdCurrent( p, pFanin );
416  Vec_PtrPush( vSupp, pFanin );
417  }
418  pFanin = Aig_ObjFanin1( pObj );
419  if ( !Aig_ObjIsTravIdCurrent(p, pFanin) )
420  {
421  Aig_ObjSetTravIdCurrent( p, pFanin );
422  Vec_PtrPush( vSupp, pFanin );
423  }
424  }
425  return vSupp;
426 }
427 
428 /**Function*************************************************************
429 
430  Synopsis [Marks the nodes in the cone with current trav ID.]
431 
432  Description []
433 
434  SideEffects []
435 
436  SeeAlso []
437 
438 ***********************************************************************/
440 {
441  if ( Aig_ObjIsTravIdCurrent( p, pObj ) ) // visited
442  return;
443  if ( !Aig_ObjIsTravIdPrevious( p, pObj ) ) // not visited, but outside
444  return;
445  assert( Aig_ObjIsTravIdPrevious(p, pObj) ); // not visited, inside
446  assert( Aig_ObjIsNode(pObj) );
447  Aig_ObjSetTravIdCurrent( p, pObj );
448  Aig_SuppMinCollectCone_rec( p, Aig_ObjFanin0(pObj), vNodes );
449  Aig_SuppMinCollectCone_rec( p, Aig_ObjFanin1(pObj), vNodes );
450  Vec_PtrPush( vNodes, pObj );
451 }
452 
453 /**Function*************************************************************
454 
455  Synopsis [Collects nodes with the current trav ID rooted in the node.]
456 
457  Description []
458 
459  SideEffects []
460 
461  SeeAlso []
462 
463 ***********************************************************************/
465 {
466  Vec_Ptr_t * vNodes;
467  assert( !Aig_IsComplement(pRoot) );
468 // assert( Aig_ObjIsTravIdCurrent( p, pRoot ) );
469  vNodes = Vec_PtrAlloc( 4 );
471  Aig_SuppMinCollectCone_rec( p, Aig_Regular(pRoot), vNodes );
472  return vNodes;
473 }
474 
475 /**Function*************************************************************
476 
477  Synopsis [Marks the nodes in the cone with current trav ID.]
478 
479  Description []
480 
481  SideEffects []
482 
483  SeeAlso []
484 
485 ***********************************************************************/
487 {
488  int RetValue;
489  if ( Aig_ObjIsTravIdCurrent( p, pObj ) ) // visited, marks there
490  return 1;
491  if ( Aig_ObjIsTravIdPrevious( p, pObj ) ) // visited, no marks there
492  return 0;
493  Aig_ObjSetTravIdPrevious( p, pObj );
494  if ( Aig_ObjIsCi(pObj) )
495  return 0;
496  RetValue = Aig_SuppMinHighlightCone_rec( p, Aig_ObjFanin0(pObj) ) |
498 // printf( "%d %d\n", Aig_ObjId(pObj), RetValue );
499  if ( RetValue )
500  Aig_ObjSetTravIdCurrent( p, pObj );
501  return RetValue;
502 }
503 
504 /**Function*************************************************************
505 
506  Synopsis [Marks the nodes in the cone with current trav ID.]
507 
508  Description []
509 
510  SideEffects []
511 
512  SeeAlso []
513 
514 ***********************************************************************/
516 {
517  Aig_Obj_t * pLeaf;
518  int i, RetValue;
519  assert( !Aig_IsComplement(pRoot) );
522  Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pLeaf, i )
524  RetValue = Aig_SuppMinHighlightCone_rec( p, pRoot );
525  Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pLeaf, i )
527  return RetValue;
528 }
529 
530 
531 /**Function*************************************************************
532 
533  Synopsis [Collects the supergate.]
534 
535  Description []
536 
537  SideEffects []
538 
539  SeeAlso []
540 
541 ***********************************************************************/
543 {
544  // if the new node is complemented or a PI, another gate begins
545  if ( Aig_IsComplement(pObj) || Aig_ObjIsCi(pObj) ) // || (Aig_ObjRefs(pObj) > 1) )
546  {
547  Vec_PtrPushUnique( vSuper, Aig_Not(pObj) );
548  return;
549  }
550  // go through the branches
553 }
554 
555 /**Function*************************************************************
556 
557  Synopsis [Collects the supergate.]
558 
559  Description []
560 
561  SideEffects []
562 
563  SeeAlso []
564 
565 ***********************************************************************/
567 {
568  Vec_Ptr_t * vSuper;
569  assert( !Aig_IsComplement(pObj) );
570  assert( !Aig_ObjIsCi(pObj) );
571  vSuper = Vec_PtrAlloc( 4 );
574  return vSuper;
575 }
576 
577 /**Function*************************************************************
578 
579  Synopsis [Returns the result of support minimization.]
580 
581  Description [Returns internal AIG node that is equal to pFunc under
582  assignment pCond == 1, or NULL if there is no such node. status is
583  -1 if condition is not OR;
584  -2 if cone is too large or no cone;
585  -3 if no support reduction is possible.]
586 
587  SideEffects []
588 
589  SeeAlso []
590 
591 ***********************************************************************/
592 Aig_Obj_t * Aig_ManSupportMinimization( Aig_Man_t * p, Aig_Obj_t * pCond, Aig_Obj_t * pFunc, int * pStatus )
593 {
594  int nSuppMax = 16;
595  Vec_Ptr_t * vOrGate, * vNodes, * vSupp, * vCofs;
596  Aig_Obj_t * pResult;
597  int RetValue;
598  *pStatus = 0;
599  // if pCond is not OR
600  if ( !Aig_IsComplement(pCond) || Aig_ObjIsCi(Aig_Regular(pCond)) || Aig_ObjIsConst1(Aig_Regular(pCond)) )
601  {
602  *pStatus = -1;
603  return NULL;
604  }
605  // if pFunc is not a node
606  if ( !Aig_ObjIsNode(Aig_Regular(pFunc)) )
607  {
608  *pStatus = -2;
609  return NULL;
610  }
611  // collect the multi-input OR gate rooted in the condition
612  vOrGate = Aig_SuppMinCollectSuper( Aig_Regular(pCond) );
613  if ( Vec_PtrSize(vOrGate) > nSuppMax )
614  {
615  Vec_PtrFree( vOrGate );
616  *pStatus = -2;
617  return NULL;
618  }
619  // highlight the cone limited by these gates
620  RetValue = Aig_SuppMinHighlightCone( p, Aig_Regular(pFunc), vOrGate );
621  if ( RetValue == 0 ) // no overlap
622  {
623  Vec_PtrFree( vOrGate );
624  *pStatus = -2;
625  return NULL;
626  }
627  // collect the cone rooted in pFunc limited by vOrGate
628  vNodes = Aig_SuppMinCollectCone( p, Aig_Regular(pFunc) );
629  // collect the support nodes reachable from the cone
630  vSupp = Aig_SuppMinCollectSupport( p, vNodes );
631  if ( Vec_PtrSize(vSupp) > nSuppMax )
632  {
633  Vec_PtrFree( vOrGate );
634  Vec_PtrFree( vNodes );
635  Vec_PtrFree( vSupp );
636  *pStatus = -2;
637  return NULL;
638  }
639  // check if all nodes belonging to OR gate are included in the support
640  // (if this is not the case, don't-care minimization is not possible)
641  if ( !Aig_SuppMinGateIsInSupport( p, vOrGate, vSupp ) )
642  {
643  Vec_PtrFree( vOrGate );
644  Vec_PtrFree( vNodes );
645  Vec_PtrFree( vSupp );
646  *pStatus = -3;
647  return NULL;
648  }
649  // create truth tables of all nodes and find the maximal number
650  // of support varialbles that can be replaced by constants
651  vCofs = Aig_SuppMinPerform( p, vOrGate, vNodes, vSupp );
652  if ( Vec_PtrSize(vCofs) == 0 )
653  {
654  Vec_PtrFree( vCofs );
655  Vec_PtrFree( vOrGate );
656  Vec_PtrFree( vNodes );
657  Vec_PtrFree( vSupp );
658  *pStatus = -3;
659  return NULL;
660  }
661  // reconstruct the cone
662  pResult = Aig_SuppMinReconstruct( p, vCofs, vNodes, vSupp );
663  pResult = Aig_NotCond( pResult, Aig_IsComplement(pFunc) );
664  Vec_PtrFree( vCofs );
665  Vec_PtrFree( vOrGate );
666  Vec_PtrFree( vNodes );
667  Vec_PtrFree( vSupp );
668  return pResult;
669 }
670 /**Function*************************************************************
671 
672  Synopsis [Testing procedure.]
673 
674  Description []
675 
676  SideEffects []
677 
678  SeeAlso []
679 
680 ***********************************************************************/
682 {
683  Aig_Man_t * p;
684  Aig_Obj_t * pFunc, * pCond, * pRes;
685  int i, Status;
686  p = Aig_ManStart( 100 );
687  for ( i = 0; i < 5; i++ )
688  Aig_IthVar(p,i);
689  pFunc = Aig_Mux( p, Aig_IthVar(p,3), Aig_IthVar(p,1), Aig_IthVar(p,0) );
690  pFunc = Aig_Mux( p, Aig_IthVar(p,4), Aig_IthVar(p,2), pFunc );
691  pCond = Aig_Or( p, Aig_IthVar(p,3), Aig_IthVar(p,4) );
692  pRes = Aig_ManSupportMinimization( p, pCond, pFunc, &Status );
693  assert( Status == 0 );
694 
695  Aig_ObjPrint( p, Aig_Regular(pRes) ); printf( "\n" );
696  Aig_ObjPrint( p, Aig_ObjFanin0(Aig_Regular(pRes)) ); printf( "\n" );
697  Aig_ObjPrint( p, Aig_ObjFanin1(Aig_Regular(pRes)) ); printf( "\n" );
698 
699  Aig_ManStop( p );
700 }
702 {
703  Aig_Man_t * p;
704  Aig_Obj_t * node09, * node10, * node11, * node12, * node13, * pRes;
705  int i, Status;
706  p = Aig_ManStart( 100 );
707  for ( i = 0; i < 3; i++ )
708  Aig_IthVar(p,i);
709 
710  node09 = Aig_And( p, Aig_IthVar(p,0), Aig_Not(Aig_IthVar(p,1)) );
711  node10 = Aig_And( p, Aig_Not(node09), Aig_Not(Aig_IthVar(p,2)) );
712  node11 = Aig_And( p, node10, Aig_IthVar(p,1) );
713 
714  node12 = Aig_Or( p, Aig_IthVar(p,1), Aig_IthVar(p,2) );
715  node13 = Aig_Or( p, node12, Aig_IthVar(p,0) );
716 
717  pRes = Aig_ManSupportMinimization( p, node13, node11, &Status );
718  assert( Status == 0 );
719 
720  printf( "Compl = %d ", Aig_IsComplement(pRes) );
721  Aig_ObjPrint( p, Aig_Regular(pRes) ); printf( "\n" );
722  if ( Aig_ObjIsNode(Aig_Regular(pRes)) )
723  {
724  Aig_ObjPrint( p, Aig_ObjFanin0(Aig_Regular(pRes)) ); printf( "\n" );
725  Aig_ObjPrint( p, Aig_ObjFanin1(Aig_Regular(pRes)) ); printf( "\n" );
726  }
727 
728  Aig_ManStop( p );
729 }
730 ////////////////////////////////////////////////////////////////////////
731 /// END OF FILE ///
732 ////////////////////////////////////////////////////////////////////////
734 
static int Aig_ObjIsTravIdPrevious(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:296
static void Kit_TruthAndPhase(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars, int fCompl0, int fCompl1)
Definition: kit.h:409
Vec_Ptr_t * Aig_SuppMinCollectSuper(Aig_Obj_t *pObj)
Definition: aigFact.c:566
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Aig_ManShow(Aig_Man_t *pMan, int fHaig, Vec_Ptr_t *vBold)
Definition: aigShow.c:340
Vec_Ptr_t * Aig_SuppMinCollectCone(Aig_Man_t *p, Aig_Obj_t *pRoot)
Definition: aigFact.c:464
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
void * pData
Definition: aig.h:87
int Aig_ManFindConeOverlap(Aig_Man_t *p, Vec_Ptr_t *vImplics, Aig_Obj_t *pNode)
Definition: aigFact.c:116
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Aig_ManSupportMinimizationTest2()
Definition: aigFact.c:701
ABC_NAMESPACE_IMPL_START void Aig_ManFindImplications_rec(Aig_Obj_t *pObj, Vec_Ptr_t *vImplics)
DECLARATIONS ///.
Definition: aigFact.c:46
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int nSuppMax
Definition: llb3Image.c:83
int nWords
Definition: abcNpn.c:127
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
Vec_Ptr_t * Aig_ManFindImplications(Aig_Man_t *p, Aig_Obj_t *pNode)
Definition: aigFact.c:70
Aig_Obj_t * Aig_ManDeriveNewCone_rec(Aig_Man_t *p, Aig_Obj_t *pNode)
Definition: aigFact.c:140
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
void Aig_ObjPrint(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:316
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
Aig_Obj_t * Aig_ManSupportMinimization(Aig_Man_t *p, Aig_Obj_t *pCond, Aig_Obj_t *pFunc, int *pStatus)
Definition: aigFact.c:592
void Aig_ManFactorAlgebraicTest(Aig_Man_t *p)
Definition: aigFact.c:249
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: aigOper.c:63
int Aig_SuppMinHighlightCone(Aig_Man_t *p, Aig_Obj_t *pRoot, Vec_Ptr_t *vOrGate)
Definition: aigFact.c:515
Aig_Obj_t * Aig_ManDeriveNewCone(Aig_Man_t *p, Vec_Ptr_t *vImplics, Aig_Obj_t *pNode)
Definition: aigFact.c:163
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:259
Definition: aig.h:69
Aig_Obj_t * Aig_ManFactorAlgebraic_int(Aig_Man_t *p, Aig_Obj_t *pPoA, Aig_Obj_t *pPoB, int Value)
Definition: aigFact.c:190
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static void Kit_TruthOrPhase(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars, int fCompl0, int fCompl1)
Definition: kit.h:433
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static void Aig_ObjSetTravIdPrevious(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:294
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Kit_TruthIsEqualWithCare(unsigned *pIn0, unsigned *pIn1, unsigned *pCare, int nVars)
Definition: kit.h:282
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
void Aig_SuppMinCollectCone_rec(Aig_Man_t *p, Aig_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: aigFact.c:439
int Aig_ManFindConeOverlap_rec(Aig_Man_t *p, Aig_Obj_t *pNode)
Definition: aigFact.c:89
Aig_Obj_t * Aig_Mux(Aig_Man_t *p, Aig_Obj_t *pC, Aig_Obj_t *p1, Aig_Obj_t *p0)
Definition: aigOper.c:317
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Aig_SuppMinCollectSuper_rec(Aig_Obj_t *pObj, Vec_Ptr_t *vSuper)
Definition: aigFact.c:542
Vec_Ptr_t * Aig_SuppMinPerform(Aig_Man_t *p, Vec_Ptr_t *vOrGate, Vec_Ptr_t *vNodes, Vec_Ptr_t *vSupp)
Definition: aigFact.c:287
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
Vec_Ptr_t * Aig_SuppMinCollectSupport(Aig_Man_t *p, Vec_Ptr_t *vNodes)
Definition: aigFact.c:402
int Aig_SuppMinGateIsInSupport(Aig_Man_t *p, Vec_Ptr_t *vOrGate, Vec_Ptr_t *vSupp)
Definition: aigFact.c:377
#define assert(ex)
Definition: util_old.h:213
Aig_Obj_t * Aig_ManFactorAlgebraic(Aig_Man_t *p, int iPoA, int iPoB, int Value)
Definition: aigFact.c:230
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
void Aig_ManSupportMinimizationTest()
Definition: aigFact.c:681
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Aig_SuppMinHighlightCone_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigFact.c:486
Aig_Obj_t * Aig_SuppMinReconstruct(Aig_Man_t *p, Vec_Ptr_t *vCofs, Vec_Ptr_t *vNodes, Vec_Ptr_t *vSupp)
Definition: aigFact.c:348
static void Kit_TruthClear(unsigned *pOut, int nVars)
Definition: kit.h:361
static Vec_Ptr_t * Vec_PtrAllocSimInfo(int nEntries, int nWords)
Definition: vecPtr.h:929
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223