abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
base/abci/abcCut.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcCut.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Interface to cut computation.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcCut.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "opt/cut/cut.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 static void Abc_NtkPrintCuts( void * p, Abc_Ntk_t * pNtk, int fSeq );
32 static void Abc_NtkPrintCuts_( void * p, Abc_Ntk_t * pNtk, int fSeq );
33 
34 extern int nTotal, nGood, nEqual;
35 
37 static int Abc_NtkComputeArea( Abc_Ntk_t * pNtk, Cut_Man_t * p );
38 
39 ////////////////////////////////////////////////////////////////////////
40 /// FUNCTION DEFINITIONS ///
41 ////////////////////////////////////////////////////////////////////////
42 
43 /**Function*************************************************************
44 
45  Synopsis []
46 
47  Description []
48 
49  SideEffects []
50 
51  SeeAlso []
52 
53 ***********************************************************************/
55 {
56  Abc_Obj_t * pObj, * pFan0, * pFan1, * pFanC;
57  int i, Counter = 0;
58  Abc_NtkForEachObj( pNtk, pObj, i )
59  {
60  if ( !Abc_NodeIsMuxType(pObj) )
61  continue;
62  pFanC = Abc_NodeRecognizeMux( pObj, &pFan1, &pFan0 );
63  pFanC = Abc_ObjRegular(pFanC);
64  pFan0 = Abc_ObjRegular(pFan0);
65  assert( pFanC->vFanouts.nSize > 1 );
66  pFanC->vFanouts.nSize--;
67  Counter++;
68  if ( Abc_NodeIsExorType(pObj) )
69  {
70  assert( pFan0->vFanouts.nSize > 1 );
71  pFan0->vFanouts.nSize--;
72  Counter++;
73  }
74  }
75  printf("Substracted %d fanouts\n", Counter );
76 }
77 
78 /**Function*************************************************************
79 
80  Synopsis []
81 
82  Description []
83 
84  SideEffects []
85 
86  SeeAlso []
87 
88 ***********************************************************************/
90 {
91  Abc_Obj_t * pObj, * pFan0, * pFan1, * pFanC;
92  int i, Counter = 0;
93  Abc_NtkForEachObj( pNtk, pObj, i )
94  {
95  if ( !Abc_NodeIsMuxType(pObj) )
96  continue;
97  pFanC = Abc_NodeRecognizeMux( pObj, &pFan1, &pFan0 );
98  pFanC = Abc_ObjRegular(pFanC);
99  pFan0 = Abc_ObjRegular(pFan0);
100  pFanC->vFanouts.nSize++;
101  Counter++;
102  if ( Abc_NodeIsExorType(pObj) )
103  {
104  pFan0->vFanouts.nSize++;
105  Counter++;
106  }
107  }
108  printf("Added %d fanouts\n", Counter );
109 }
110 
111 /**Function*************************************************************
112 
113  Synopsis [Computes the cuts for the network.]
114 
115  Description []
116 
117  SideEffects []
118 
119  SeeAlso []
120 
121 ***********************************************************************/
123 {
124  ProgressBar * pProgress;
125  Cut_Man_t * p;
126  Cut_Cut_t * pList;
127  Abc_Obj_t * pObj, * pNode;
128  Vec_Ptr_t * vNodes;
129  Vec_Int_t * vChoices;
130  int i;
131  abctime clk = Abc_Clock();
132 
133  extern void Abc_NtkBalanceAttach( Abc_Ntk_t * pNtk );
134  extern void Abc_NtkBalanceDetach( Abc_Ntk_t * pNtk );
135 
136  if ( pParams->fAdjust )
138 
139  nTotal = nGood = nEqual = 0;
140 
141  assert( Abc_NtkIsStrash(pNtk) );
142  // start the manager
143  pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
144  p = Cut_ManStart( pParams );
145  // compute node attributes if local or global cuts are requested
146  if ( pParams->fGlobal || pParams->fLocal )
147  {
148  extern Vec_Int_t * Abc_NtkGetNodeAttributes( Abc_Ntk_t * pNtk );
150  }
151  // prepare for cut dropping
152  if ( pParams->fDrop )
154  // set cuts for PIs
155  Abc_NtkForEachCi( pNtk, pObj, i )
156  if ( Abc_ObjFanoutNum(pObj) > 0 )
157  Cut_NodeSetTriv( p, pObj->Id );
158  // compute cuts for internal nodes
159  vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
160  vChoices = Vec_IntAlloc( 100 );
161  pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
162  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
163  {
164  // when we reached a CO, it is time to deallocate the cuts
165  if ( Abc_ObjIsCo(pObj) )
166  {
167  if ( pParams->fDrop )
169  continue;
170  }
171  // skip constant node, it has no cuts
172 // if ( Abc_NodeIsConst(pObj) )
173 // continue;
174  Extra_ProgressBarUpdate( pProgress, i, NULL );
175  // compute the cuts to the internal node
176  pList = (Cut_Cut_t *)Abc_NodeGetCuts( p, pObj, pParams->fDag, pParams->fTree );
177  if ( pParams->fNpnSave && pList )
178  {
179  extern void Npn_ManSaveOne( unsigned * puTruth, int nVars );
180  Cut_Cut_t * pCut;
181  for ( pCut = pList; pCut; pCut = pCut->pNext )
182  if ( pCut->nLeaves >= 4 )
183  Npn_ManSaveOne( Cut_CutReadTruth(pCut), pCut->nLeaves );
184  }
185  // consider dropping the fanins cuts
186  if ( pParams->fDrop )
187  {
190  }
191  // add cuts due to choices
192  if ( Abc_AigNodeIsChoice(pObj) )
193  {
194  Vec_IntClear( vChoices );
195  for ( pNode = pObj; pNode; pNode = (Abc_Obj_t *)pNode->pData )
196  Vec_IntPush( vChoices, pNode->Id );
197  Cut_NodeUnionCuts( p, vChoices );
198  }
199  }
200  Extra_ProgressBarStop( pProgress );
201  Vec_PtrFree( vNodes );
202  Vec_IntFree( vChoices );
203  Cut_ManPrintStats( p );
204 ABC_PRT( "TOTAL", Abc_Clock() - clk );
205 // printf( "Area = %d.\n", Abc_NtkComputeArea( pNtk, p ) );
206 //Abc_NtkPrintCuts( p, pNtk, 0 );
207 // Cut_ManPrintStatsToFile( p, pNtk->pSpec, Abc_Clock() - clk );
208 
209  // temporary printout of stats
210  if ( nTotal )
211  printf( "Total cuts = %d. Good cuts = %d. Ratio = %5.2f\n", nTotal, nGood, ((double)nGood)/nTotal );
212  if ( pParams->fAdjust )
213  Abc_NtkCutsAddFanunt( pNtk );
214  return p;
215 }
216 
217 /**Function*************************************************************
218 
219  Synopsis [Cut computation using the oracle.]
220 
221  Description []
222 
223  SideEffects []
224 
225  SeeAlso []
226 
227 ***********************************************************************/
229 {
230  Abc_Obj_t * pObj;
231  Vec_Ptr_t * vNodes;
232  int i; //, clk = Abc_Clock();
233  int fDrop = Cut_OracleReadDrop(p);
234 
235  assert( Abc_NtkIsStrash(pNtk) );
236 
237  // prepare cut droppping
238  if ( fDrop )
240 
241  // set cuts for PIs
242  Abc_NtkForEachCi( pNtk, pObj, i )
243  if ( Abc_ObjFanoutNum(pObj) > 0 )
244  Cut_OracleNodeSetTriv( p, pObj->Id );
245 
246  // compute cuts for internal nodes
247  vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
248  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
249  {
250  // when we reached a CO, it is time to deallocate the cuts
251  if ( Abc_ObjIsCo(pObj) )
252  {
253  if ( fDrop )
255  continue;
256  }
257  // skip constant node, it has no cuts
258 // if ( Abc_NodeIsConst(pObj) )
259 // continue;
260  // compute the cuts to the internal node
261  Cut_OracleComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
262  Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
263  // consider dropping the fanins cuts
264  if ( fDrop )
265  {
268  }
269  }
270  Vec_PtrFree( vNodes );
271 //ABC_PRT( "Total", Abc_Clock() - clk );
272 //Abc_NtkPrintCuts_( p, pNtk, 0 );
273 }
274 
275 
276 /**Function*************************************************************
277 
278  Synopsis [Computes the cuts for the network.]
279 
280  Description []
281 
282  SideEffects []
283 
284  SeeAlso []
285 
286 ***********************************************************************/
288 {
289 /*
290  Cut_Man_t * p;
291  Abc_Obj_t * pObj, * pNode;
292  int i, nIters, fStatus;
293  Vec_Int_t * vChoices;
294  abctime clk = Abc_Clock();
295 
296  assert( Abc_NtkIsSeq(pNtk) );
297  assert( pParams->fSeq );
298 // assert( Abc_NtkIsDfsOrdered(pNtk) );
299 
300  // start the manager
301  pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
302  pParams->nCutSet = Abc_NtkCutSetNodeNum( pNtk );
303  p = Cut_ManStart( pParams );
304 
305  // set cuts for the constant node and the PIs
306  pObj = Abc_AigConst1(pNtk);
307  if ( Abc_ObjFanoutNum(pObj) > 0 )
308  Cut_NodeSetTriv( p, pObj->Id );
309  Abc_NtkForEachPi( pNtk, pObj, i )
310  {
311 //printf( "Setting trivial cut %d.\n", pObj->Id );
312  Cut_NodeSetTriv( p, pObj->Id );
313  }
314  // label the cutset nodes and set their number in the array
315  // assign the elementary cuts to the cutset nodes
316  Abc_SeqForEachCutsetNode( pNtk, pObj, i )
317  {
318  assert( pObj->fMarkC == 0 );
319  pObj->fMarkC = 1;
320  pObj->pCopy = (Abc_Obj_t *)i;
321  Cut_NodeSetTriv( p, pObj->Id );
322 //printf( "Setting trivial cut %d.\n", pObj->Id );
323  }
324 
325  // process the nodes
326  vChoices = Vec_IntAlloc( 100 );
327  for ( nIters = 0; nIters < 10; nIters++ )
328  {
329 //printf( "ITERATION %d:\n", nIters );
330  // compute the cuts for the internal nodes
331  Abc_AigForEachAnd( pNtk, pObj, i )
332  {
333  Abc_NodeGetCutsSeq( p, pObj, nIters==0 );
334  // add cuts due to choices
335  if ( Abc_AigNodeIsChoice(pObj) )
336  {
337  Vec_IntClear( vChoices );
338  for ( pNode = pObj; pNode; pNode = pNode->pData )
339  Vec_IntPush( vChoices, pNode->Id );
340  Cut_NodeUnionCutsSeq( p, vChoices, (pObj->fMarkC ? (int)pObj->pCopy : -1), nIters==0 );
341  }
342  }
343  // merge the new cuts with the old cuts
344  Abc_NtkForEachPi( pNtk, pObj, i )
345  Cut_NodeNewMergeWithOld( p, pObj->Id );
346  Abc_AigForEachAnd( pNtk, pObj, i )
347  Cut_NodeNewMergeWithOld( p, pObj->Id );
348  // for the cutset, transfer temp cuts to new cuts
349  fStatus = 0;
350  Abc_SeqForEachCutsetNode( pNtk, pObj, i )
351  fStatus |= Cut_NodeTempTransferToNew( p, pObj->Id, i );
352  if ( fStatus == 0 )
353  break;
354  }
355  Vec_IntFree( vChoices );
356 
357  // if the status is not finished, transfer new to old for the cutset
358  Abc_SeqForEachCutsetNode( pNtk, pObj, i )
359  Cut_NodeNewMergeWithOld( p, pObj->Id );
360 
361  // transfer the old cuts to the new positions
362  Abc_NtkForEachObj( pNtk, pObj, i )
363  Cut_NodeOldTransferToNew( p, pObj->Id );
364 
365  // unlabel the cutset nodes
366  Abc_SeqForEachCutsetNode( pNtk, pObj, i )
367  pObj->fMarkC = 0;
368 if ( pParams->fVerbose )
369 {
370  Cut_ManPrintStats( p );
371 ABC_PRT( "TOTAL ", Abc_Clock() - clk );
372 printf( "Converged after %d iterations.\n", nIters );
373 }
374 //Abc_NtkPrintCuts( p, pNtk, 1 );
375  return p;
376 */
377  return NULL;
378 }
379 
380 /**Function*************************************************************
381 
382  Synopsis [Computes area.]
383 
384  Description []
385 
386  SideEffects []
387 
388  SeeAlso []
389 
390 ***********************************************************************/
392 {
393  Abc_Obj_t * pObj;
394  int Counter, i;
395  Counter = 0;
396  Abc_NtkForEachCo( pNtk, pObj, i )
397  Counter += Cut_ManMappingArea_rec( p, Abc_ObjFaninId0(pObj) );
398  return Counter;
399 }
400 
401 /**Function*************************************************************
402 
403  Synopsis [Computes the cuts for the network.]
404 
405  Description []
406 
407  SideEffects []
408 
409  SeeAlso []
410 
411 ***********************************************************************/
412 void * Abc_NodeGetCutsRecursive( void * p, Abc_Obj_t * pObj, int fDag, int fTree )
413 {
414  void * pList;
415  if ( (pList = Abc_NodeReadCuts( p, pObj )) )
416  return pList;
417  Abc_NodeGetCutsRecursive( p, Abc_ObjFanin0(pObj), fDag, fTree );
418  Abc_NodeGetCutsRecursive( p, Abc_ObjFanin1(pObj), fDag, fTree );
419  return Abc_NodeGetCuts( p, pObj, fDag, fTree );
420 }
421 
422 /**Function*************************************************************
423 
424  Synopsis [Computes the cuts for the network.]
425 
426  Description []
427 
428  SideEffects []
429 
430  SeeAlso []
431 
432 ***********************************************************************/
433 void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fDag, int fTree )
434 {
435  Abc_Obj_t * pFanin;
436  int fDagNode, fTriv, TreeCode = 0;
437 // assert( Abc_NtkIsStrash(pObj->pNtk) );
438  assert( Abc_ObjFaninNum(pObj) == 2 );
439 
440  // check if the node is a DAG node
441  fDagNode = (Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj));
442  // increment the counter of DAG nodes
443  if ( fDagNode ) Cut_ManIncrementDagNodes( (Cut_Man_t *)p );
444  // add the trivial cut if the node is a DAG node, or if we compute all cuts
445  fTriv = fDagNode || !fDag;
446  // check if fanins are DAG nodes
447  if ( fTree )
448  {
449  pFanin = Abc_ObjFanin0(pObj);
450  TreeCode |= (Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin));
451  pFanin = Abc_ObjFanin1(pObj);
452  TreeCode |= ((Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin)) << 1);
453  }
454 
455  // changes due to the global/local cut computation
456  {
457  Cut_Params_t * pParams = Cut_ManReadParams((Cut_Man_t *)p);
458  if ( pParams->fLocal )
459  {
460  Vec_Int_t * vNodeAttrs = Cut_ManReadNodeAttrs((Cut_Man_t *)p);
461  fDagNode = Vec_IntEntry( vNodeAttrs, pObj->Id );
462  if ( fDagNode ) Cut_ManIncrementDagNodes( (Cut_Man_t *)p );
463 // fTriv = fDagNode || !pParams->fGlobal;
464  fTriv = !Vec_IntEntry( vNodeAttrs, pObj->Id );
465  TreeCode = 0;
466  pFanin = Abc_ObjFanin0(pObj);
467  TreeCode |= Vec_IntEntry( vNodeAttrs, pFanin->Id );
468  pFanin = Abc_ObjFanin1(pObj);
469  TreeCode |= (Vec_IntEntry( vNodeAttrs, pFanin->Id ) << 1);
470  }
471  }
472  return Cut_NodeComputeCuts( (Cut_Man_t *)p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
473  Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), fTriv, TreeCode );
474 }
475 
476 /**Function*************************************************************
477 
478  Synopsis [Computes the cuts for the network.]
479 
480  Description []
481 
482  SideEffects []
483 
484  SeeAlso []
485 
486 ***********************************************************************/
487 void Abc_NodeGetCutsSeq( void * p, Abc_Obj_t * pObj, int fTriv )
488 {
489 /*
490  int CutSetNum;
491  assert( Abc_NtkIsSeq(pObj->pNtk) );
492  assert( Abc_ObjFaninNum(pObj) == 2 );
493  fTriv = pObj->fMarkC ? 0 : fTriv;
494  CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1;
495  Cut_NodeComputeCutsSeq( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
496  Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), Seq_ObjFaninL0(pObj), Seq_ObjFaninL1(pObj), fTriv, CutSetNum );
497 */
498 }
499 
500 /**Function*************************************************************
501 
502  Synopsis [Computes the cuts for the network.]
503 
504  Description []
505 
506  SideEffects []
507 
508  SeeAlso []
509 
510 ***********************************************************************/
511 void * Abc_NodeReadCuts( void * p, Abc_Obj_t * pObj )
512 {
513  return Cut_NodeReadCutsNew( (Cut_Man_t *)p, pObj->Id );
514 }
515 
516 /**Function*************************************************************
517 
518  Synopsis [Computes the cuts for the network.]
519 
520  Description []
521 
522  SideEffects []
523 
524  SeeAlso []
525 
526 ***********************************************************************/
527 void Abc_NodeFreeCuts( void * p, Abc_Obj_t * pObj )
528 {
529  Cut_NodeFreeCuts( (Cut_Man_t *)p, pObj->Id );
530 }
531 
532 /**Function*************************************************************
533 
534  Synopsis [Computes the cuts for the network.]
535 
536  Description []
537 
538  SideEffects []
539 
540  SeeAlso []
541 
542 ***********************************************************************/
543 void Abc_NtkPrintCuts( void * p, Abc_Ntk_t * pNtk, int fSeq )
544 {
545  Cut_Cut_t * pList;
546  Abc_Obj_t * pObj;
547  int i;
548  printf( "Cuts of the network:\n" );
549  Abc_NtkForEachObj( pNtk, pObj, i )
550  {
551  pList = (Cut_Cut_t *)Abc_NodeReadCuts( (Cut_Man_t *)p, pObj );
552  printf( "Node %s:\n", Abc_ObjName(pObj) );
553  Cut_CutPrintList( pList, fSeq );
554  }
555 }
556 
557 /**Function*************************************************************
558 
559  Synopsis [Computes the cuts for the network.]
560 
561  Description []
562 
563  SideEffects []
564 
565  SeeAlso []
566 
567 ***********************************************************************/
568 void Abc_NtkPrintCuts_( void * p, Abc_Ntk_t * pNtk, int fSeq )
569 {
570  Cut_Cut_t * pList;
571  Abc_Obj_t * pObj;
572  pObj = Abc_NtkObj( pNtk, 2 * Abc_NtkObjNum(pNtk) / 3 );
573  pList = (Cut_Cut_t *)Abc_NodeReadCuts( (Cut_Man_t *)p, pObj );
574  printf( "Node %s:\n", Abc_ObjName(pObj) );
575  Cut_CutPrintList( pList, fSeq );
576 }
577 
578 /**Function*************************************************************
579 
580  Synopsis [Assigns global attributes randomly.]
581 
582  Description [Old code.]
583 
584  SideEffects []
585 
586  SeeAlso []
587 
588 ***********************************************************************/
590 {
591  Vec_Int_t * vAttrs;
592 // Vec_Ptr_t * vNodes;
593  Abc_Obj_t * pObj;//, * pTemp;
594  int i;//, k;
595  int nNodesTotal = 0, nMffcsTotal = 0;
596  extern Vec_Ptr_t * Abc_NodeMffcInsideCollect( Abc_Obj_t * pNode );
597 
598  vAttrs = Vec_IntStart( Abc_NtkObjNumMax(pNtk) + 1 );
599 // Abc_NtkForEachCi( pNtk, pObj, i )
600 // Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
601 
602  Abc_NtkForEachObj( pNtk, pObj, i )
603  {
604  if ( Abc_ObjIsNode(pObj) )
605  nNodesTotal++;
606  if ( Abc_ObjIsCo(pObj) && Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
607  nMffcsTotal += Abc_NodeMffcSize( Abc_ObjFanin0(pObj) );
608 // if ( Abc_ObjIsNode(pObj) && (rand() % 4 == 0) )
609 // if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj) && (rand() % 3 == 0) )
610  if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj) )
611  {
612  int nMffc = Abc_NodeMffcSize(pObj);
613  nMffcsTotal += Abc_NodeMffcSize(pObj);
614 // printf( "%d ", nMffc );
615 
616  if ( nMffc > 2 || Abc_ObjFanoutNum(pObj) > 8 )
617  Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
618  }
619  }
620 /*
621  Abc_NtkForEachObj( pNtk, pObj, i )
622  {
623  if ( Vec_IntEntry( vAttrs, pObj->Id ) )
624  {
625  vNodes = Abc_NodeMffcInsideCollect( pObj );
626  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, k )
627  if ( pTemp != pObj )
628  Vec_IntWriteEntry( vAttrs, pTemp->Id, 0 );
629  Vec_PtrFree( vNodes );
630  }
631  }
632 */
633  printf( "Total nodes = %d. Total MFFC nodes = %d.\n", nNodesTotal, nMffcsTotal );
634  return vAttrs;
635 }
636 
637 /**Function*************************************************************
638 
639  Synopsis [Assigns global attributes randomly.]
640 
641  Description [Old code.]
642 
643  SideEffects []
644 
645  SeeAlso []
646 
647 ***********************************************************************/
648 int Abc_NtkSubDagSize_rec( Abc_Obj_t * pObj, Vec_Int_t * vAttrs )
649 {
650  if ( Abc_NodeIsTravIdCurrent(pObj) )
651  return 0;
653  if ( Vec_IntEntry( vAttrs, pObj->Id ) )
654  return 0;
655  if ( Abc_ObjIsCi(pObj) )
656  return 1;
657  assert( Abc_ObjFaninNum(pObj) == 2 );
658  return 1 + Abc_NtkSubDagSize_rec(Abc_ObjFanin0(pObj), vAttrs) +
659  Abc_NtkSubDagSize_rec(Abc_ObjFanin1(pObj), vAttrs);
660 }
661 
662 /**Function*************************************************************
663 
664  Synopsis [Assigns global attributes randomly.]
665 
666  Description [Old code.]
667 
668  SideEffects []
669 
670  SeeAlso []
671 
672 ***********************************************************************/
674 {
675  Vec_Int_t * vAttrs;
676  Abc_Obj_t * pObj;
677  int i, nSize;
678  assert( Abc_NtkIsDfsOrdered(pNtk) );
679  vAttrs = Vec_IntStart( Abc_NtkObjNumMax(pNtk) + 1 );
680  Abc_NtkForEachObj( pNtk, pObj, i )
681  {
682  // skip no-nodes and nodes without fanouts
683  if ( pObj->Id == 0 || !(Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj)) )
684  continue;
685  // the node has more than one fanout - count its sub-DAG size
686  Abc_NtkIncrementTravId( pNtk );
687  nSize = Abc_NtkSubDagSize_rec( pObj, vAttrs );
688  if ( nSize > 15 )
689  Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
690  }
691  return vAttrs;
692 }
693 
694 ////////////////////////////////////////////////////////////////////////
695 /// END OF FILE ///
696 ////////////////////////////////////////////////////////////////////////
697 
698 
700 
void Abc_NodeFreeCuts(void *p, Abc_Obj_t *pObj)
static int Abc_NtkComputeArea(Abc_Ntk_t *pNtk, Cut_Man_t *p)
void * Abc_NodeGetCutsRecursive(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
void Abc_NtkBalanceAttach(Abc_Ntk_t *pNtk)
Definition: abcBalance.c:506
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void Abc_NodeGetCutsSeq(void *p, Abc_Obj_t *pObj, int fTriv)
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Cut_Cut_t * Cut_OracleComputeCuts(Cut_Oracle_t *p, int Node, int Node0, int Node1, int fCompl0, int fCompl1)
Definition: cutOracle.c:320
int nEqual
Definition: cutTruth.c:39
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
Cut_Man_t * Abc_NtkSeqCuts(Abc_Ntk_t *pNtk, Cut_Params_t *pParams)
void Cut_ManSetNodeAttrs(Cut_Man_t *p, Vec_Int_t *vFanCounts)
Definition: cutMan.c:245
static unsigned * Cut_CutReadTruth(Cut_Cut_t *p)
Definition: cut.h:94
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
void Npn_ManSaveOne(unsigned *puTruth, int nVars)
Definition: abcNpnSave.c:714
static Vec_Int_t * Abc_NtkGetNodeAttributes(Abc_Ntk_t *pNtk)
Cut_Cut_t * pNext
Definition: cut.h:88
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
int Cut_OracleReadDrop(Cut_Oracle_t *p)
Definition: cutOracle.c:176
void Abc_NtkCutsAddFanunt(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static abctime Abc_Clock()
Definition: abc_global.h:279
void Cut_NodeSetTriv(Cut_Man_t *p, int Node)
Definition: cutApi.c:145
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
void Cut_ManSetFanoutCounts(Cut_Man_t *p, Vec_Int_t *vFanCounts)
Definition: cutMan.c:229
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
int Cut_ManMappingArea_rec(Cut_Man_t *p, int Node)
Definition: cutNode.c:544
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
ABC_DLL int Abc_NodeIsMuxControlType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1357
void Cut_OracleTryDroppingCuts(Cut_Oracle_t *p, int Node)
Definition: cutOracle.c:407
void Cut_ManIncrementDagNodes(Cut_Man_t *p)
Definition: cutMan.c:309
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static void Abc_NtkPrintCuts_(void *p, Abc_Ntk_t *pNtk, int fSeq)
unsigned nLeaves
Definition: cut.h:84
DECLARATIONS ///.
void * Abc_NodeGetCuts(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
ABC_DLL int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1301
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Cut_Cut_t * Cut_NodeUnionCuts(Cut_Man_t *p, Vec_Int_t *vNodes)
Definition: cutNode.c:678
void Cut_NodeFreeCuts(Cut_Man_t *p, int Node)
Definition: cutApi.c:184
void Cut_ManPrintStats(Cut_Man_t *p)
Definition: cutMan.c:155
void Cut_NodeTryDroppingCuts(Cut_Man_t *p, int Node)
Definition: cutApi.c:162
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Cut_Man_t * Cut_ManStart(Cut_Params_t *pParams)
FUNCTION DEFINITIONS ///.
Definition: cutMan.c:47
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
ABC_DLL int Abc_NodeMffcSize(Abc_Obj_t *pNode)
FUNCTION DEFINITIONS ///.
Definition: abcRefs.c:48
Cut_Man_t * Abc_NtkCuts(Abc_Ntk_t *pNtk, Cut_Params_t *pParams)
Vec_Int_t * Abc_NtkGetNodeAttributes2(Abc_Ntk_t *pNtk)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static ABC_NAMESPACE_IMPL_START void Abc_NtkPrintCuts(void *p, Abc_Ntk_t *pNtk, int fSeq)
DECLARATIONS ///.
static int Counter
void Abc_NtkCutsOracle(Abc_Ntk_t *pNtk, Cut_Oracle_t *p)
void Abc_NtkCutsSubtractFanunt(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
void Cut_CutPrintList(Cut_Cut_t *pList, int fSeq)
Definition: cutCut.c:308
void Extra_ProgressBarStop(ProgressBar *p)
void Cut_OracleNodeSetTriv(Cut_Oracle_t *p, int Node)
Definition: cutOracle.c:192
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition: abcDfs.c:1014
Cut_Cut_t * Cut_NodeComputeCuts(Cut_Man_t *p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fTriv, int TreeCode)
Definition: cutNode.c:369
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Vec_Int_t vFanouts
Definition: abc.h:144
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Vec_Ptr_t * Abc_NodeMffcInsideCollect(Abc_Obj_t *pNode)
Definition: abcRefs.c:382
void Cut_OracleSetFanoutCounts(Cut_Oracle_t *p, Vec_Int_t *vFanCounts)
Definition: cutOracle.c:160
int Id
Definition: abc.h:132
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int nGood
Definition: cutTruth.c:38
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
ABC_DLL int Abc_NtkIsDfsOrdered(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:667
ABC_DLL Vec_Int_t * Abc_NtkFanoutCounts(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1701
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
void Abc_NtkBalanceDetach(Abc_Ntk_t *pNtk)
Definition: abcBalance.c:531
int Abc_NtkSubDagSize_rec(Abc_Obj_t *pObj, Vec_Int_t *vAttrs)
void * pData
Definition: abc.h:145
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
DECLARATIONS ///.
Definition: cutOracle.c:30
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static int Abc_NtkObjNum(Abc_Ntk_t *pNtk)
Definition: abc.h:283
Cut_Cut_t * Cut_NodeReadCutsNew(Cut_Man_t *p, int Node)
MACRO DEFINITIONS ///.
Definition: cutApi.c:45
Cut_Params_t * Cut_ManReadParams(Cut_Man_t *p)
Definition: cutMan.c:277
ABC_DLL int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1259
Vec_Int_t * Cut_ManReadNodeAttrs(Cut_Man_t *p)
Definition: cutMan.c:293
ABC_DLL Abc_Obj_t * Abc_NodeRecognizeMux(Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
Definition: abcUtil.c:1389
void * Abc_NodeReadCuts(void *p, Abc_Obj_t *pObj)
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223