abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcPrint.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcPrint.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Printing statistics.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcPrint.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include <math.h>
22 #include "base/abc/abc.h"
23 #include "bool/dec/dec.h"
24 #include "base/main/main.h"
25 #include "map/mio/mio.h"
26 #include "aig/aig/aig.h"
27 #include "map/if/if.h"
28 #include "misc/extra/extraBdd.h"
29 
30 #ifdef WIN32
31 #include <windows.h>
32 #endif
33 
35 
36 
37 ////////////////////////////////////////////////////////////////////////
38 /// DECLARATIONS ///
39 ////////////////////////////////////////////////////////////////////////
40 
41 //extern int s_TotalNodes = 0;
42 //extern int s_TotalChanges = 0;
43 
45 int s_MappingMem = 0;
48 
49 ////////////////////////////////////////////////////////////////////////
50 /// FUNCTION DEFINITIONS ///
51 ////////////////////////////////////////////////////////////////////////
52 
53 /**Function*************************************************************
54 
55  Synopsis [If the network is best, saves it in "best.blif" and returns 1.]
56 
57  Description [If the networks are incomparable, saves the new network,
58  returns its parameters in the internal parameter structure, and returns 1.
59  If the new network is not a logic network, quits without saving and returns 0.]
60 
61  SideEffects []
62 
63  SeeAlso []
64 
65 ***********************************************************************/
67 {
68  extern void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType );
69  static struct ParStruct {
70  char * pName; // name of the best saved network
71  int Depth; // depth of the best saved network
72  int Flops; // flops in the best saved network
73  int Nodes; // nodes in the best saved network
74  int Edges; // edges in the best saved network
75  int nPis; // the number of primary inputs
76  int nPos; // the number of primary outputs
77  } ParsNew, ParsBest = { 0 };
78  char * pFileNameOut;
79  // free storage for the name
80  if ( pNtk == NULL )
81  {
82  ABC_FREE( ParsBest.pName );
83  return 0;
84  }
85  // quit if not a logic network
86  if ( !Abc_NtkIsLogic(pNtk) )
87  return 0;
88  // get the parameters
89  ParsNew.Depth = Abc_NtkLevel( pNtk );
90  ParsNew.Flops = Abc_NtkLatchNum( pNtk );
91  ParsNew.Nodes = Abc_NtkNodeNum( pNtk );
92  ParsNew.Edges = Abc_NtkGetTotalFanins( pNtk );
93  ParsNew.nPis = Abc_NtkPiNum( pNtk );
94  ParsNew.nPos = Abc_NtkPoNum( pNtk );
95  // reset the parameters if the network has the same name
96  if ( ParsBest.pName == NULL ||
97  strcmp(ParsBest.pName, pNtk->pName) ||
98  ParsBest.Depth > ParsNew.Depth ||
99  (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops) ||
100  (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Edges > ParsNew.Edges) )
101  {
102  ABC_FREE( ParsBest.pName );
103  ParsBest.pName = Extra_UtilStrsav( pNtk->pName );
104  ParsBest.Depth = ParsNew.Depth;
105  ParsBest.Flops = ParsNew.Flops;
106  ParsBest.Nodes = ParsNew.Nodes;
107  ParsBest.Edges = ParsNew.Edges;
108  ParsBest.nPis = ParsNew.nPis;
109  ParsBest.nPos = ParsNew.nPos;
110  // writ the network
111  if ( strcmp(pNtk->pSpec + strlen(pNtk->pSpec) - strlen("_best.blif"), "_best.blif") )
112  pFileNameOut = Extra_FileNameGenericAppend( pNtk->pSpec, "_best.blif" );
113  else
114  pFileNameOut = pNtk->pSpec;
115  Io_Write( pNtk, pFileNameOut, IO_FILE_BLIF );
116  return 1;
117  }
118  return 0;
119 }
120 
121 /**Function*************************************************************
122 
123  Synopsis [Marks nodes for power-optimization.]
124 
125  Description []
126 
127  SideEffects []
128 
129  SeeAlso []
130 
131 ***********************************************************************/
133 {
134  extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
135  extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne );
136  Vec_Int_t * vSwitching;
137  float * pSwitching;
138  Abc_Ntk_t * pNtkStr;
139  Aig_Man_t * pAig;
140  Aig_Obj_t * pObjAig;
141  Abc_Obj_t * pObjAbc, * pObjAbc2;
142  float Result = (float)0;
143  int i;
144  // strash the network
145  pNtkStr = Abc_NtkStrash( pNtk, 0, 1, 0 );
146  Abc_NtkForEachObj( pNtk, pObjAbc, i )
147  if ( Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)->Type == ABC_FUNC_NONE || (!Abc_ObjIsCi(pObjAbc) && !Abc_ObjIsNode(pObjAbc)) )
148  pObjAbc->pTemp = NULL;
149  // map network into an AIG
150  pAig = Abc_NtkToDar( pNtkStr, 0, (int)(Abc_NtkLatchNum(pNtk) > 0) );
151  vSwitching = Saig_ManComputeSwitchProbs( pAig, 48, 16, 0 );
152  pSwitching = (float *)vSwitching->pArray;
153  Abc_NtkForEachObj( pNtk, pObjAbc, i )
154  {
155  if ( (pObjAbc2 = Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)) && (pObjAig = Aig_Regular((Aig_Obj_t *)pObjAbc2->pTemp)) )
156  {
157  Result += Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id];
158 // Abc_ObjPrint( stdout, pObjAbc );
159 // printf( "%d = %.2f\n", i, Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id] );
160  }
161  }
162  Vec_IntFree( vSwitching );
163  Aig_ManStop( pAig );
164  Abc_NtkDelete( pNtkStr );
165  return Result;
166 }
167 
168 /**Function*************************************************************
169 
170  Synopsis [Compute area using LUT library.]
171 
172  Description []
173 
174  SideEffects []
175 
176  SeeAlso []
177 
178 ***********************************************************************/
179 float Abc_NtkGetArea( Abc_Ntk_t * pNtk )
180 {
181  If_LibLut_t * pLutLib;
182  Abc_Obj_t * pObj;
183  float Counter = 0.0;
184  int i;
185  assert( Abc_NtkIsLogic(pNtk) );
186  // get the library
187  pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut();
188  if ( pLutLib && pLutLib->LutMax >= Abc_NtkGetFaninMax(pNtk) )
189  {
190  Abc_NtkForEachNode( pNtk, pObj, i )
191  Counter += pLutLib->pLutAreas[Abc_ObjFaninNum(pObj)];
192  }
193  return Counter;
194 }
195 
196 /**Function*************************************************************
197 
198  Synopsis [Print the vital stats of the network.]
199 
200  Description []
201 
202  SideEffects []
203 
204  SeeAlso []
205 
206 ***********************************************************************/
207 void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch, int fSkipBuf )
208 {
209  int nSingles = fSkipBuf ? Abc_NtkGetBufNum(pNtk) : 0;
210  if ( fPrintMuxes && Abc_NtkIsStrash(pNtk) )
211  {
212  extern int Abc_NtkCountMuxes( Abc_Ntk_t * pNtk );
213  int nXors = Abc_NtkGetExorNum(pNtk);
214  int nMuxs = Abc_NtkCountMuxes(pNtk) - nXors;
215  int nAnds = Abc_NtkNodeNum(pNtk) - (nMuxs + nXors) * 3 - nSingles;
216  Abc_Print( 1, "XMA stats: " );
217  Abc_Print( 1,"Xor =%7d (%6.2f %%) ", nXors, 300.0 * nXors / Abc_NtkNodeNum(pNtk) );
218  Abc_Print( 1,"Mux =%7d (%6.2f %%) ", nMuxs, 300.0 * nMuxs / Abc_NtkNodeNum(pNtk) );
219  Abc_Print( 1,"And =%7d (%6.2f %%)", nAnds, 100.0 * nAnds / Abc_NtkNodeNum(pNtk) );
220  Abc_Print( 1,"\n" );
221  return;
222  }
223  if ( fSaveBest )
225 /*
226  if ( fDumpResult )
227  {
228  char Buffer[1000] = {0};
229  const char * pNameGen = pNtk->pSpec? Extra_FileNameGeneric( pNtk->pSpec ) : "nameless_";
230  sprintf( Buffer, "%s_dump.blif", pNameGen );
231  Io_Write( pNtk, Buffer, IO_FILE_BLIF );
232  if ( pNtk->pSpec ) ABC_FREE( pNameGen );
233  }
234 */
235 
236 // if ( Abc_NtkIsStrash(pNtk) )
237 // Abc_AigCountNext( pNtk->pManFunc );
238 
239 #ifdef WIN32
240  SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 15 ); // bright
241  Abc_Print( 1,"%-30s:", pNtk->pName );
242  SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 7 ); // normal
243 #else
244  Abc_Print( 1,"%s%-30s:%s", "\033[1;37m", pNtk->pName, "\033[0m" ); // bright
245 #endif
246  Abc_Print( 1," i/o =%5d/%5d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
247  if ( Abc_NtkConstrNum(pNtk) )
248  Abc_Print( 1,"(c=%d)", Abc_NtkConstrNum(pNtk) );
249  Abc_Print( 1," lat =%5d", Abc_NtkLatchNum(pNtk) );
250  if ( pNtk->nBarBufs )
251  Abc_Print( 1,"(b=%d)", pNtk->nBarBufs );
252  if ( Abc_NtkIsNetlist(pNtk) )
253  {
254  Abc_Print( 1," net =%5d", Abc_NtkNetNum(pNtk) );
255  Abc_Print( 1," nd =%5d", Abc_NtkNodeNum(pNtk) - nSingles );
256  Abc_Print( 1," wbox =%3d", Abc_NtkWhiteboxNum(pNtk) );
257  Abc_Print( 1," bbox =%3d", Abc_NtkBlackboxNum(pNtk) );
258  }
259  else if ( Abc_NtkIsStrash(pNtk) )
260  {
261  Abc_Print( 1," and =%7d", Abc_NtkNodeNum(pNtk) );
262  if ( Abc_NtkGetChoiceNum(pNtk) )
263  Abc_Print( 1," (choice = %d)", Abc_NtkGetChoiceNum(pNtk) );
264  }
265  else
266  {
267  Abc_Print( 1," nd =%6d", Abc_NtkNodeNum(pNtk) - nSingles );
268  Abc_Print( 1," edge =%7d", Abc_NtkGetTotalFanins(pNtk) - nSingles );
269  }
270 
271  if ( Abc_NtkIsStrash(pNtk) || Abc_NtkIsNetlist(pNtk) )
272  {
273  }
274  else if ( Abc_NtkHasSop(pNtk) )
275  {
276 
277  Abc_Print( 1," cube =%6d", Abc_NtkGetCubeNum(pNtk) - nSingles );
278  if ( fFactored )
279  Abc_Print( 1," lit(sop) =%6d", Abc_NtkGetLitNum(pNtk) - nSingles );
280  if ( fFactored )
281  Abc_Print( 1," lit(fac) =%6d", Abc_NtkGetLitFactNum(pNtk) - nSingles );
282  }
283  else if ( Abc_NtkHasAig(pNtk) )
284  Abc_Print( 1," aig =%6d", Abc_NtkGetAigNodeNum(pNtk) - nSingles );
285  else if ( Abc_NtkHasBdd(pNtk) )
286  Abc_Print( 1," bdd =%6d", Abc_NtkGetBddNodeNum(pNtk) - nSingles );
287  else if ( Abc_NtkHasMapping(pNtk) )
288  {
289  assert( pNtk->pManFunc == Abc_FrameReadLibGen() );
290  Abc_Print( 1," area =%5.2f", Abc_NtkGetMappedArea(pNtk) );
291  Abc_Print( 1," delay =%5.2f", Abc_NtkDelayTrace(pNtk, NULL, NULL, 0) );
292  if ( pNtk->pManTime )
293  Abc_ManTimeStop( pNtk->pManTime );
294  pNtk->pManTime = NULL;
295  }
296  else if ( !Abc_NtkHasBlackbox(pNtk) )
297  {
298  assert( 0 );
299  }
300 
301  if ( Abc_NtkIsStrash(pNtk) )
302  {
303  extern int Abc_NtkGetMultiRefNum( Abc_Ntk_t * pNtk );
304  Abc_Print( 1," lev =%3d", Abc_AigLevel(pNtk) );
305 // Abc_Print( 1," ff = %5d", Abc_NtkNodeNum(pNtk) + 2 * (Abc_NtkCoNum(pNtk)+Abc_NtkGetMultiRefNum(pNtk)) );
306 // Abc_Print( 1," var = %5d", Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk)+Abc_NtkGetMultiRefNum(pNtk) );
307  }
308  else
309  Abc_Print( 1," lev = %d", Abc_NtkLevel(pNtk) );
310  if ( pNtk->nBarBufs2 )
311  Abc_Print( 1," buf = %d", pNtk->nBarBufs2 );
312  if ( fUseLutLib && Abc_FrameReadLibLut() )
313  Abc_Print( 1," delay =%5.2f", Abc_NtkDelayTraceLut(pNtk, 1) );
314  if ( fUseLutLib && Abc_FrameReadLibLut() )
315  Abc_Print( 1," area =%5.2f", Abc_NtkGetArea(pNtk) );
316  if ( fPower )
317  Abc_Print( 1," power =%7.2f", Abc_NtkMfsTotalSwitching(pNtk) );
318  if ( fGlitch )
319  {
320  extern float Abc_NtkMfsTotalGlitching( Abc_Ntk_t * pNtk );
321  if ( Abc_NtkIsLogic(pNtk) && Abc_NtkGetFaninMax(pNtk) <= 6 )
322  Abc_Print( 1," glitch =%7.2f %%", Abc_NtkMfsTotalGlitching(pNtk) );
323  else
324  printf( "\nCurrently computes glitching only for K-LUT networks with K <= 6." );
325  }
326  Abc_Print( 1,"\n" );
327 
328  // print the statistic into a file
329  if ( fDumpResult )
330  {
331  FILE * pTable = fopen( "abcstats.txt", "a+" );
332  fprintf( pTable, "%s ", pNtk->pName );
333  fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
334  fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
335  fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
336  fprintf( pTable, "%d ", Abc_NtkGetTotalFanins(pNtk) );
337  fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
338  fprintf( pTable, "\n" );
339  fclose( pTable );
340  }
341 /*
342  {
343  FILE * pTable;
344  pTable = fopen( "ibm/seq_stats.txt", "a+" );
345 // fprintf( pTable, "%s ", pNtk->pName );
346 // fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
347 // fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
348  fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
349  fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
350  fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
351  fprintf( pTable, "\n" );
352  fclose( pTable );
353  }
354 */
355 
356 /*
357  // print the statistic into a file
358  {
359  FILE * pTable;
360  pTable = fopen( "ucsb/stats.txt", "a+" );
361 // fprintf( pTable, "%s ", pNtk->pSpec );
362  fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
363 // fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
364 // fprintf( pTable, "%.0f ", Abc_NtkGetMappedArea(pNtk) );
365 // fprintf( pTable, "%.2f ", Abc_NtkDelayTrace(pNtk) );
366  fprintf( pTable, "\n" );
367  fclose( pTable );
368  }
369 */
370 
371 /*
372  // print the statistic into a file
373  {
374  FILE * pTable;
375  pTable = fopen( "x/stats_new.txt", "a+" );
376  fprintf( pTable, "%s ", pNtk->pName );
377 // fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
378 // fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
379 // fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
380 // fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
381 // fprintf( pTable, "%d ", Abc_NtkGetTotalFanins(pNtk) );
382 // fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
383 // fprintf( pTable, "%.2f ", (float)(s_MappingMem)/(float)(1<<20) );
384  fprintf( pTable, "%.2f", (float)(s_MappingTime)/(float)(CLOCKS_PER_SEC) );
385 // fprintf( pTable, "%.2f", (float)(s_ResynTime)/(float)(CLOCKS_PER_SEC) );
386  fprintf( pTable, "\n" );
387  fclose( pTable );
388 
389  s_ResynTime = 0;
390  }
391 */
392 
393 /*
394  // print the statistic into a file
395  {
396  static int Counter = 0;
397  extern int timeRetime;
398  FILE * pTable;
399  Counter++;
400  pTable = fopen( "d/stats.txt", "a+" );
401  fprintf( pTable, "%s ", pNtk->pName );
402 // fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
403 // fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
404 // fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
405  fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
406  fprintf( pTable, "%.2f ", (float)(timeRetime)/(float)(CLOCKS_PER_SEC) );
407  fprintf( pTable, "\n" );
408  fclose( pTable );
409  }
410 
411 
412  s_TotalNodes += Abc_NtkNodeNum(pNtk);
413  printf( "Total nodes = %6d %6.2f MB Changes = %6d.\n",
414  s_TotalNodes, s_TotalNodes * 20.0 / (1<<20), s_TotalChanges );
415 */
416 
417 // if ( Abc_NtkHasSop(pNtk) )
418 // printf( "The total number of cube pairs = %d.\n", Abc_NtkGetCubePairNum(pNtk) );
419 
420  fflush( stdout );
421  if ( pNtk->pExdc )
422  Abc_NtkPrintStats( pNtk->pExdc, fFactored, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch, fSkipBuf );
423 }
424 
425 /**Function*************************************************************
426 
427  Synopsis [Prints PIs/POs and LIs/LOs.]
428 
429  Description []
430 
431  SideEffects []
432 
433  SeeAlso []
434 
435 ***********************************************************************/
436 void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk, int fPrintFlops )
437 {
438  Abc_Obj_t * pObj;
439  int i;
440 
441  fprintf( pFile, "Primary inputs (%d): ", Abc_NtkPiNum(pNtk) );
442  Abc_NtkForEachPi( pNtk, pObj, i )
443  fprintf( pFile, " %s", Abc_ObjName(pObj) );
444 // fprintf( pFile, " %s(%d)", Abc_ObjName(pObj), Abc_ObjFanoutNum(pObj) );
445  fprintf( pFile, "\n" );
446 
447  fprintf( pFile, "Primary outputs (%d):", Abc_NtkPoNum(pNtk) );
448  Abc_NtkForEachPo( pNtk, pObj, i )
449  fprintf( pFile, " %s", Abc_ObjName(pObj) );
450  fprintf( pFile, "\n" );
451 
452  if ( !fPrintFlops )
453  return;
454 
455  fprintf( pFile, "Latches (%d): ", Abc_NtkLatchNum(pNtk) );
456  Abc_NtkForEachLatch( pNtk, pObj, i )
457  fprintf( pFile, " %s(%s=%s)", Abc_ObjName(pObj),
459  fprintf( pFile, "\n" );
460 }
461 
462 /**Function*************************************************************
463 
464  Synopsis [Prints statistics about latches.]
465 
466  Description []
467 
468  SideEffects []
469 
470  SeeAlso []
471 
472 ***********************************************************************/
473 void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk )
474 {
475  Abc_Obj_t * pLatch, * pFanin;
476  int i, Counter0, Counter1, Counter2;
477  int InitNums[4], Init;
478 
479  assert( !Abc_NtkIsNetlist(pNtk) );
480  if ( Abc_NtkLatchNum(pNtk) == 0 )
481  {
482  fprintf( pFile, "The network is combinational.\n" );
483  return;
484  }
485 
486  for ( i = 0; i < 4; i++ )
487  InitNums[i] = 0;
488  Counter0 = Counter1 = Counter2 = 0;
489  Abc_NtkForEachLatch( pNtk, pLatch, i )
490  {
491  Init = Abc_LatchInit( pLatch );
492  assert( Init < 4 );
493  InitNums[Init]++;
494 
495  pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
496  if ( Abc_NtkIsLogic(pNtk) )
497  {
498  if ( !Abc_NodeIsConst(pFanin) )
499  continue;
500  }
501  else if ( Abc_NtkIsStrash(pNtk) )
502  {
503  if ( !Abc_AigNodeIsConst(pFanin) )
504  continue;
505  }
506  else
507  assert( 0 );
508 
509  // the latch input is a constant node
510  Counter0++;
511  if ( Abc_LatchIsInitDc(pLatch) )
512  {
513  Counter1++;
514  continue;
515  }
516  // count the number of cases when the constant is equal to the initial value
517  if ( Abc_NtkIsStrash(pNtk) )
518  {
519  if ( Abc_LatchIsInit1(pLatch) == !Abc_ObjFaninC0(pLatch) )
520  Counter2++;
521  }
522  else
523  {
525  Counter2++;
526  }
527  }
528 // fprintf( pFile, "%-15s: ", pNtk->pName );
529  fprintf( pFile, "Total latches = %5d. Init0 = %d. Init1 = %d. InitDC = %d. Const data = %d.\n",
530  Abc_NtkLatchNum(pNtk), InitNums[1], InitNums[2], InitNums[3], Counter0 );
531 // fprintf( pFile, "Const fanin = %3d. DC init = %3d. Matching init = %3d. ", Counter0, Counter1, Counter2 );
532 // fprintf( pFile, "Self-feed latches = %2d.\n", -1 ); //Abc_NtkCountSelfFeedLatches(pNtk) );
533 }
534 
535 /**Function*************************************************************
536 
537  Synopsis [Prints the distribution of fanins/fanouts in the network.]
538 
539  Description []
540 
541  SideEffects []
542 
543  SeeAlso []
544 
545 ***********************************************************************/
546 void Abc_NtkPrintFanio( FILE * pFile, Abc_Ntk_t * pNtk, int fUsePis )
547 {
548  Abc_Obj_t * pNode;
549  int i, k, nFanins, nFanouts;
550  Vec_Int_t * vFanins, * vFanouts;
551  int nOldSize, nNewSize;
552 
553  vFanins = Vec_IntAlloc( 0 );
554  vFanouts = Vec_IntAlloc( 0 );
555  Vec_IntFill( vFanins, 100, 0 );
556  Vec_IntFill( vFanouts, 100, 0 );
557  Abc_NtkForEachNode( pNtk, pNode, i )
558  {
559  nFanins = Abc_ObjFaninNum(pNode);
560  if ( Abc_NtkIsNetlist(pNtk) )
561  nFanouts = Abc_ObjFanoutNum( Abc_ObjFanout0(pNode) );
562  else
563  nFanouts = Abc_ObjFanoutNum(pNode);
564 // nFanouts = Abc_NodeMffcSize(pNode);
565  if ( nFanins > vFanins->nSize || nFanouts > vFanouts->nSize )
566  {
567  nOldSize = vFanins->nSize;
568  nNewSize = Abc_MaxInt(nFanins, nFanouts) + 10;
569  Vec_IntGrow( vFanins, nNewSize );
570  Vec_IntGrow( vFanouts, nNewSize );
571  for ( k = nOldSize; k < nNewSize; k++ )
572  {
573  Vec_IntPush( vFanins, 0 );
574  Vec_IntPush( vFanouts, 0 );
575  }
576  }
577  vFanins->pArray[nFanins]++;
578  vFanouts->pArray[nFanouts]++;
579  }
580  if ( fUsePis )
581  {
582  Vec_IntFill( vFanouts, Vec_IntSize(vFanouts), 0 );
583  Abc_NtkForEachCi( pNtk, pNode, i )
584  {
585  if ( Abc_NtkIsNetlist(pNtk) )
586  nFanouts = Abc_ObjFanoutNum( Abc_ObjFanout0(pNode) );
587  else
588  nFanouts = Abc_ObjFanoutNum(pNode);
589  vFanouts->pArray[nFanouts]++;
590  }
591  }
592  fprintf( pFile, "The distribution of fanins and fanouts in the network:\n" );
593  fprintf( pFile, " Number Nodes with fanin Nodes with fanout\n" );
594  for ( k = 0; k < vFanins->nSize; k++ )
595  {
596  if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
597  continue;
598  fprintf( pFile, "%5d : ", k );
599  if ( vFanins->pArray[k] == 0 )
600  fprintf( pFile, " " );
601  else
602  fprintf( pFile, "%12d ", vFanins->pArray[k] );
603  fprintf( pFile, " " );
604  if ( vFanouts->pArray[k] == 0 )
605  fprintf( pFile, " " );
606  else
607  fprintf( pFile, "%12d ", vFanouts->pArray[k] );
608  fprintf( pFile, "\n" );
609  }
610  Vec_IntFree( vFanins );
611  Vec_IntFree( vFanouts );
612 }
613 
614 /**Function*************************************************************
615 
616  Synopsis [Prints the distribution of fanins/fanouts in the network.]
617 
618  Description []
619 
620  SideEffects []
621 
622  SeeAlso []
623 
624 ***********************************************************************/
625 void Abc_NtkPrintFanioNew( FILE * pFile, Abc_Ntk_t * pNtk, int fMffc )
626 {
627  char Buffer[100];
628  Abc_Obj_t * pNode;
629  Vec_Int_t * vFanins, * vFanouts;
630  int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
631  int i, k, nSizeMax;
632 
633  // determine the largest fanin and fanout
634  nFaninsMax = nFanoutsMax = 0;
635  nFaninsAll = nFanoutsAll = 0;
636  Abc_NtkForEachNode( pNtk, pNode, i )
637  {
638  if ( fMffc && Abc_ObjFanoutNum(pNode) == 1 )
639  continue;
640  nFanins = Abc_ObjFaninNum(pNode);
641  if ( Abc_NtkIsNetlist(pNtk) )
642  nFanouts = Abc_ObjFanoutNum( Abc_ObjFanout0(pNode) );
643  else if ( fMffc )
644  nFanouts = Abc_NodeMffcSize(pNode);
645  else
646  nFanouts = Abc_ObjFanoutNum(pNode);
647  nFaninsAll += nFanins;
648  nFanoutsAll += nFanouts;
649  nFaninsMax = Abc_MaxInt( nFaninsMax, nFanins );
650  nFanoutsMax = Abc_MaxInt( nFanoutsMax, nFanouts );
651  }
652 
653  // allocate storage for fanin/fanout numbers
654  nSizeMax = Abc_MaxInt( 10 * (Abc_Base10Log(nFaninsMax) + 1), 10 * (Abc_Base10Log(nFanoutsMax) + 1) );
655  vFanins = Vec_IntStart( nSizeMax );
656  vFanouts = Vec_IntStart( nSizeMax );
657 
658  // count the number of fanins and fanouts
659  Abc_NtkForEachNode( pNtk, pNode, i )
660  {
661  if ( fMffc && Abc_ObjFanoutNum(pNode) == 1 )
662  continue;
663  nFanins = Abc_ObjFaninNum(pNode);
664  if ( Abc_NtkIsNetlist(pNtk) )
665  nFanouts = Abc_ObjFanoutNum( Abc_ObjFanout0(pNode) );
666  else if ( fMffc )
667  nFanouts = Abc_NodeMffcSize(pNode);
668  else
669  nFanouts = Abc_ObjFanoutNum(pNode);
670 
671  if ( nFanins < 10 )
672  Vec_IntAddToEntry( vFanins, nFanins, 1 );
673  else if ( nFanins < 100 )
674  Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
675  else if ( nFanins < 1000 )
676  Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
677  else if ( nFanins < 10000 )
678  Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
679  else if ( nFanins < 100000 )
680  Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
681  else if ( nFanins < 1000000 )
682  Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
683  else if ( nFanins < 10000000 )
684  Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
685 
686  if ( nFanouts < 10 )
687  Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
688  else if ( nFanouts < 100 )
689  Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
690  else if ( nFanouts < 1000 )
691  Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
692  else if ( nFanouts < 10000 )
693  Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
694  else if ( nFanouts < 100000 )
695  Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
696  else if ( nFanouts < 1000000 )
697  Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
698  else if ( nFanouts < 10000000 )
699  Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
700  }
701 
702  fprintf( pFile, "The distribution of fanins and fanouts in the network:\n" );
703  fprintf( pFile, " Number Nodes with fanin Nodes with fanout\n" );
704  for ( k = 0; k < nSizeMax; k++ )
705  {
706  if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
707  continue;
708  if ( k < 10 )
709  fprintf( pFile, "%15d : ", k );
710  else
711  {
712  sprintf( Buffer, "%d - %d", (int)pow((double)10, k/10) * (k%10), (int)pow((double)10, k/10) * (k%10+1) - 1 );
713  fprintf( pFile, "%15s : ", Buffer );
714  }
715  if ( vFanins->pArray[k] == 0 )
716  fprintf( pFile, " " );
717  else
718  fprintf( pFile, "%12d ", vFanins->pArray[k] );
719  fprintf( pFile, " " );
720  if ( vFanouts->pArray[k] == 0 )
721  fprintf( pFile, " " );
722  else
723  fprintf( pFile, "%12d ", vFanouts->pArray[k] );
724  fprintf( pFile, "\n" );
725  }
726  Vec_IntFree( vFanins );
727  Vec_IntFree( vFanouts );
728 
729  fprintf( pFile, "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
730  nFaninsMax, 1.0*nFaninsAll/Abc_NtkNodeNum(pNtk),
731  nFanoutsMax, 1.0*nFanoutsAll/Abc_NtkNodeNum(pNtk) );
732 /*
733  Abc_NtkForEachCi( pNtk, pNode, i )
734  {
735  printf( "%d ", Abc_ObjFanoutNum(pNode) );
736  }
737  printf( "\n" );
738 */
739 }
740 
741 /**Function*************************************************************
742 
743  Synopsis [Prints the fanins/fanouts of a node.]
744 
745  Description []
746 
747  SideEffects []
748 
749  SeeAlso []
750 
751 ***********************************************************************/
752 void Abc_NodePrintFanio( FILE * pFile, Abc_Obj_t * pNode )
753 {
754  Abc_Obj_t * pNode2;
755  int i;
756  if ( Abc_ObjIsPo(pNode) )
757  pNode = Abc_ObjFanin0(pNode);
758 
759  fprintf( pFile, "Node %s", Abc_ObjName(pNode) );
760  fprintf( pFile, "\n" );
761 
762  fprintf( pFile, "Fanins (%d): ", Abc_ObjFaninNum(pNode) );
763  Abc_ObjForEachFanin( pNode, pNode2, i )
764  fprintf( pFile, " %s", Abc_ObjName(pNode2) );
765  fprintf( pFile, "\n" );
766 
767  fprintf( pFile, "Fanouts (%d): ", Abc_ObjFaninNum(pNode) );
768  Abc_ObjForEachFanout( pNode, pNode2, i )
769  fprintf( pFile, " %s", Abc_ObjName(pNode2) );
770  fprintf( pFile, "\n" );
771 }
772 
773 /**Function*************************************************************
774 
775  Synopsis [Prints the MFFCs of the nodes.]
776 
777  Description []
778 
779  SideEffects []
780 
781  SeeAlso []
782 
783 ***********************************************************************/
784 void Abc_NtkPrintMffc( FILE * pFile, Abc_Ntk_t * pNtk )
785 {
786  Abc_Obj_t * pNode;
787  int i;
788  extern void Abc_NodeMffcConeSuppPrint( Abc_Obj_t * pNode );
789  Abc_NtkForEachNode( pNtk, pNode, i )
790  if ( Abc_ObjFanoutNum(pNode) > 1 )
791  Abc_NodeMffcConeSuppPrint( pNode );
792 }
793 
794 /**Function*************************************************************
795 
796  Synopsis [Prints the factored form of one node.]
797 
798  Description []
799 
800  SideEffects []
801 
802  SeeAlso []
803 
804 ***********************************************************************/
805 void Abc_NtkPrintFactor( FILE * pFile, Abc_Ntk_t * pNtk, int fUseRealNames )
806 {
807  Abc_Obj_t * pNode;
808  int i;
809  assert( Abc_NtkIsSopLogic(pNtk) );
810  Abc_NtkForEachNode( pNtk, pNode, i )
811  Abc_NodePrintFactor( pFile, pNode, fUseRealNames );
812 }
813 
814 /**Function*************************************************************
815 
816  Synopsis [Prints the factored form of one node.]
817 
818  Description []
819 
820  SideEffects []
821 
822  SeeAlso []
823 
824 ***********************************************************************/
825 void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode, int fUseRealNames )
826 {
827  Dec_Graph_t * pGraph;
828  Vec_Ptr_t * vNamesIn;
829  if ( Abc_ObjIsCo(pNode) )
830  pNode = Abc_ObjFanin0(pNode);
831  if ( Abc_ObjIsPi(pNode) )
832  {
833  fprintf( pFile, "Skipping the PI node.\n" );
834  return;
835  }
836  if ( Abc_ObjIsLatch(pNode) )
837  {
838  fprintf( pFile, "Skipping the latch.\n" );
839  return;
840  }
841  assert( Abc_ObjIsNode(pNode) );
842  pGraph = Dec_Factor( (char *)pNode->pData );
843  if ( fUseRealNames )
844  {
845  vNamesIn = Abc_NodeGetFaninNames(pNode);
846  Dec_GraphPrint( stdout, pGraph, (char **)vNamesIn->pArray, Abc_ObjName(pNode) );
847  Abc_NodeFreeNames( vNamesIn );
848  }
849  else
850  Dec_GraphPrint( stdout, pGraph, (char **)NULL, Abc_ObjName(pNode) );
851  Dec_GraphFree( pGraph );
852 }
853 
854 
855 /**Function*************************************************************
856 
857  Synopsis [Prints the level stats of the PO node.]
858 
859  Description []
860 
861  SideEffects []
862 
863  SeeAlso []
864 
865 ***********************************************************************/
866 void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListNodes, int fVerbose )
867 {
868  Abc_Obj_t * pNode;
869  int i, k, Length;
870 
871  if ( fListNodes )
872  {
873  int nLevels;
874  nLevels = Abc_NtkLevel(pNtk);
875  printf( "Nodes by level:\n" );
876  for ( i = 0; i <= nLevels; i++ )
877  {
878  printf( "%2d : ", i );
879  Abc_NtkForEachNode( pNtk, pNode, k )
880  if ( (int)pNode->Level == i )
881  printf( " %s", Abc_ObjName(pNode) );
882  printf( "\n" );
883  }
884  return;
885  }
886 
887  // print the delay profile
888  if ( fProfile && Abc_NtkHasMapping(pNtk) )
889  {
890  int nIntervals = 12;
891  float DelayMax, DelayCur, DelayDelta;
892  int * pLevelCounts;
893  int DelayInt, nOutsSum, nOutsTotal;
894 
895  // get the max delay and delta
896  DelayMax = Abc_NtkDelayTrace( pNtk, NULL, NULL, 0 );
897  DelayDelta = DelayMax/nIntervals;
898  // collect outputs by delay
899  pLevelCounts = ABC_ALLOC( int, nIntervals );
900  memset( pLevelCounts, 0, sizeof(int) * nIntervals );
901  Abc_NtkForEachCo( pNtk, pNode, i )
902  {
903  if ( Abc_ObjIsNode(Abc_ObjFanin0(pNode)) && Abc_ObjFaninNum(Abc_ObjFanin0(pNode)) == 0 )
904  DelayInt = 0;
905  else
906  {
907  DelayCur = Abc_NodeReadArrivalWorst( Abc_ObjFanin0(pNode) );
908  DelayInt = (int)(DelayCur / DelayDelta);
909  if ( DelayInt >= nIntervals )
910  DelayInt = nIntervals - 1;
911  }
912  pLevelCounts[DelayInt]++;
913  }
914 
915  nOutsSum = 0;
916  nOutsTotal = Abc_NtkCoNum(pNtk);
917  for ( i = 0; i < nIntervals; i++ )
918  {
919  nOutsSum += pLevelCounts[i];
920  printf( "[%8.2f - %8.2f] : COs = %4d. %5.1f %%\n",
921  DelayDelta * i, DelayDelta * (i+1), pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal );
922  }
923  ABC_FREE( pLevelCounts );
924  return;
925  }
926  else if ( fProfile )
927  {
928  int LevelMax, * pLevelCounts;
929  int nOutsSum, nOutsTotal;
930 
931  if ( !Abc_NtkIsStrash(pNtk) )
932  Abc_NtkLevel(pNtk);
933 
934  LevelMax = 0;
935  Abc_NtkForEachCo( pNtk, pNode, i )
936  if ( LevelMax < (int)Abc_ObjFanin0(pNode)->Level )
937  LevelMax = Abc_ObjFanin0(pNode)->Level;
938  pLevelCounts = ABC_ALLOC( int, LevelMax + 1 );
939  memset( pLevelCounts, 0, sizeof(int) * (LevelMax + 1) );
940  Abc_NtkForEachCo( pNtk, pNode, i )
941  pLevelCounts[Abc_ObjFanin0(pNode)->Level]++;
942 
943  nOutsSum = 0;
944  nOutsTotal = Abc_NtkCoNum(pNtk);
945  for ( i = 0; i <= LevelMax; i++ )
946  if ( pLevelCounts[i] )
947  {
948  nOutsSum += pLevelCounts[i];
949  printf( "Level = %4d. COs = %4d. %5.1f %%\n", i, pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal );
950  }
951  ABC_FREE( pLevelCounts );
952  return;
953  }
954  assert( Abc_NtkIsStrash(pNtk) );
955 
956  if ( fVerbose )
957  {
958  // find the longest name
959  Length = 0;
960  Abc_NtkForEachCo( pNtk, pNode, i )
961  if ( Length < (int)strlen(Abc_ObjName(pNode)) )
962  Length = strlen(Abc_ObjName(pNode));
963  if ( Length < 5 )
964  Length = 5;
965  // print stats for each output
966  Abc_NtkForEachCo( pNtk, pNode, i )
967  {
968  fprintf( pFile, "CO %4d : %*s ", i, Length, Abc_ObjName(pNode) );
969  Abc_NodePrintLevel( pFile, pNode );
970  }
971  }
972 }
973 
974 /**Function*************************************************************
975 
976  Synopsis [Prints the factored form of one node.]
977 
978  Description []
979 
980  SideEffects []
981 
982  SeeAlso []
983 
984 ***********************************************************************/
985 void Abc_NodePrintLevel( FILE * pFile, Abc_Obj_t * pNode )
986 {
987  Abc_Obj_t * pDriver;
988  Vec_Ptr_t * vNodes;
989 
990  pDriver = Abc_ObjIsCo(pNode)? Abc_ObjFanin0(pNode) : pNode;
991  if ( Abc_ObjIsPi(pDriver) )
992  {
993  fprintf( pFile, "Primary input.\n" );
994  return;
995  }
996  if ( Abc_ObjIsLatch(pDriver) )
997  {
998  fprintf( pFile, "Latch.\n" );
999  return;
1000  }
1001  if ( Abc_NodeIsConst(pDriver) )
1002  {
1003  fprintf( pFile, "Constant %d.\n", !Abc_ObjFaninC0(pNode) );
1004  return;
1005  }
1006  // print the level
1007  fprintf( pFile, "Level = %3d. ", pDriver->Level );
1008  // print the size of MFFC
1009  fprintf( pFile, "Mffc = %5d. ", Abc_NodeMffcSize(pDriver) );
1010  // print the size of the shole cone
1011  vNodes = Abc_NtkDfsNodes( pNode->pNtk, &pDriver, 1 );
1012  fprintf( pFile, "Cone = %5d. ", Vec_PtrSize(vNodes) );
1013  Vec_PtrFree( vNodes );
1014  fprintf( pFile, "\n" );
1015 }
1016 
1017 /**Function*************************************************************
1018 
1019  Synopsis [Prints the factored form of one node.]
1020 
1021  Description []
1022 
1023  SideEffects []
1024 
1025  SeeAlso []
1026 
1027 ***********************************************************************/
1028 void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames )
1029 {
1030  Vec_Ptr_t * vNamesIn;
1031  if ( fUseRealNames )
1032  {
1033  vNamesIn = Abc_NodeGetFaninNames(pNode);
1034  Extra_PrintKMap( stdout, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, Cudd_Not(pNode->pData),
1035  Abc_ObjFaninNum(pNode), NULL, 0, (char **)vNamesIn->pArray );
1036  Abc_NodeFreeNames( vNamesIn );
1037  }
1038  else
1039  Extra_PrintKMap( stdout, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, Cudd_Not(pNode->pData),
1040  Abc_ObjFaninNum(pNode), NULL, 0, NULL );
1041 
1042 }
1043 
1044 /**Function*************************************************************
1045 
1046  Synopsis [Prints statistics about gates used in the network.]
1047 
1048  Description []
1049 
1050  SideEffects []
1051 
1052  SeeAlso []
1053 
1054 ***********************************************************************/
1055 void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
1056 {
1057  Abc_Obj_t * pObj;
1058  int fHasBdds, i;
1059  int CountConst, CountBuf, CountInv, CountAnd, CountOr, CountOther, CounterTotal;
1060  char * pSop;
1061 
1062  if ( fUseLibrary && Abc_NtkHasMapping(pNtk) )
1063  {
1064  Mio_Gate_t ** ppGates;
1065  double Area, AreaTotal;
1066  int Counter, nGates, i, nGateNameLen;
1067 
1068  // clean value of all gates
1069  nGates = Mio_LibraryReadGateNum( (Mio_Library_t *)pNtk->pManFunc );
1070  ppGates = Mio_LibraryReadGateArray( (Mio_Library_t *)pNtk->pManFunc );
1071  for ( i = 0; i < nGates; i++ )
1072  Mio_GateSetValue( ppGates[i], 0 );
1073 
1074  // count the gates by name
1075  CounterTotal = 0;
1076  Abc_NtkForEachNode( pNtk, pObj, i )
1077  {
1078  if ( i == 0 ) continue;
1080  CounterTotal++;
1081  // assuming that twin gates follow each other
1082  if ( Abc_NtkFetchTwinNode(pObj) )
1083  i++;
1084  }
1085 
1086  // determine the longest gate name
1087  nGateNameLen = 5;
1088  for ( i = 0; i < nGates; i++ )
1089  {
1090  Counter = Mio_GateReadValue( ppGates[i] );
1091  if ( Counter == 0 )
1092  continue;
1093  nGateNameLen = Abc_MaxInt( nGateNameLen, strlen(Mio_GateReadName(ppGates[i])) );
1094  }
1095 
1096  // print the gates
1097  AreaTotal = Abc_NtkGetMappedArea(pNtk);
1098  for ( i = 0; i < nGates; i++ )
1099  {
1100  Counter = Mio_GateReadValue( ppGates[i] );
1101  if ( Counter == 0 )
1102  continue;
1103  Area = Counter * Mio_GateReadArea( ppGates[i] );
1104  printf( "%-*s Fanin = %2d Instance = %8d Area = %10.2f %6.2f %% %s\n",
1105  nGateNameLen, Mio_GateReadName( ppGates[i] ),
1106  Mio_GateReadPinNum( ppGates[i] ),
1107  Counter, Area, 100.0 * Area / AreaTotal,
1108  Mio_GateReadForm(ppGates[i]) );
1109  }
1110  printf( "%-*s Instance = %8d Area = %10.2f %6.2f %%\n",
1111  nGateNameLen, "TOTAL",
1112  CounterTotal, AreaTotal, 100.0 );
1113  return;
1114  }
1115 
1116  if ( Abc_NtkIsAigLogic(pNtk) )
1117  return;
1118 
1119  // transform logic functions from BDD to SOP
1120  if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) )
1121  {
1122  if ( !Abc_NtkBddToSop(pNtk, 0) )
1123  {
1124  printf( "Abc_NtkPrintGates(): Converting to SOPs has failed.\n" );
1125  return;
1126  }
1127  }
1128 
1129  // get hold of the SOP of the node
1130  CountConst = CountBuf = CountInv = CountAnd = CountOr = CountOther = CounterTotal = 0;
1131  Abc_NtkForEachNode( pNtk, pObj, i )
1132  {
1133  if ( i == 0 ) continue;
1134  if ( Abc_NtkHasMapping(pNtk) )
1135  pSop = Mio_GateReadSop((Mio_Gate_t *)pObj->pData);
1136  else
1137  pSop = (char *)pObj->pData;
1138  // collect the stats
1139  if ( Abc_SopIsConst0(pSop) || Abc_SopIsConst1(pSop) )
1140  CountConst++;
1141  else if ( Abc_SopIsBuf(pSop) )
1142  CountBuf++;
1143  else if ( Abc_SopIsInv(pSop) )
1144  CountInv++;
1145  else if ( (!Abc_SopIsComplement(pSop) && Abc_SopIsAndType(pSop)) ||
1146  ( Abc_SopIsComplement(pSop) && Abc_SopIsOrType(pSop)) )
1147  CountAnd++;
1148  else if ( ( Abc_SopIsComplement(pSop) && Abc_SopIsAndType(pSop)) ||
1149  (!Abc_SopIsComplement(pSop) && Abc_SopIsOrType(pSop)) )
1150  CountOr++;
1151  else
1152  CountOther++;
1153  CounterTotal++;
1154  }
1155  printf( "Const = %8d %6.2f %%\n", CountConst , 100.0 * CountConst / CounterTotal );
1156  printf( "Buffer = %8d %6.2f %%\n", CountBuf , 100.0 * CountBuf / CounterTotal );
1157  printf( "Inverter = %8d %6.2f %%\n", CountInv , 100.0 * CountInv / CounterTotal );
1158  printf( "And = %8d %6.2f %%\n", CountAnd , 100.0 * CountAnd / CounterTotal );
1159  printf( "Or = %8d %6.2f %%\n", CountOr , 100.0 * CountOr / CounterTotal );
1160  printf( "Other = %8d %6.2f %%\n", CountOther , 100.0 * CountOther / CounterTotal );
1161  printf( "TOTAL = %8d %6.2f %%\n", CounterTotal, 100.0 * CounterTotal / CounterTotal );
1162 
1163  // convert the network back into BDDs if this is how it was
1164  if ( fHasBdds )
1165  Abc_NtkSopToBdd(pNtk);
1166 }
1167 
1168 /**Function*************************************************************
1169 
1170  Synopsis [Prints statistics about gates used in the network.]
1171 
1172  Description []
1173 
1174  SideEffects []
1175 
1176  SeeAlso []
1177 
1178 ***********************************************************************/
1180 {
1181  Vec_Ptr_t * vNodes1, * vNodes2;
1182  Abc_Obj_t * pObj1, * pObj2, * pNode1, * pNode2;
1183  int i, k, m, n, Counter;
1184 
1185  // print the template
1186  printf( "Statistics about sharing of logic nodes among the CO pairs.\n" );
1187  printf( "(CO1,CO2)=NumShared : " );
1188  // go though the CO pairs
1189  Abc_NtkForEachCo( pNtk, pObj1, i )
1190  {
1191  vNodes1 = Abc_NtkDfsNodes( pNtk, &pObj1, 1 );
1192  // mark the nodes
1193  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes1, pNode1, m )
1194  pNode1->fMarkA = 1;
1195  // go through the second COs
1196  Abc_NtkForEachCo( pNtk, pObj2, k )
1197  {
1198  if ( i >= k )
1199  continue;
1200  vNodes2 = Abc_NtkDfsNodes( pNtk, &pObj2, 1 );
1201  // count the number of marked
1202  Counter = 0;
1203  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes2, pNode2, n )
1204  Counter += pNode2->fMarkA;
1205  // print
1206  printf( "(%d,%d)=%d ", i, k, Counter );
1207  Vec_PtrFree( vNodes2 );
1208  }
1209  // unmark the nodes
1210  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes1, pNode1, m )
1211  pNode1->fMarkA = 0;
1212  Vec_PtrFree( vNodes1 );
1213  }
1214  printf( "\n" );
1215 }
1216 
1217 /**Function*************************************************************
1218 
1219  Synopsis [Prints info for each output cone.]
1220 
1221  Description []
1222 
1223  SideEffects []
1224 
1225  SeeAlso []
1226 
1227 ***********************************************************************/
1229 {
1230  Abc_Obj_t * pObj;
1231  int i, Counter = 0;
1232  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
1233  Counter += Abc_ObjIsPi(pObj);
1234  return Counter;
1235 }
1236 void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk, int fMatrix )
1237 {
1238  Vec_Ptr_t * vSupp, * vNodes;
1239  Abc_Obj_t * pObj;
1240  int i, k, nPis;
1241  printf( "Structural support info:\n" );
1242  Abc_NtkForEachCo( pNtk, pObj, i )
1243  {
1244  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
1245  vNodes = Abc_NtkDfsNodes( pNtk, &pObj, 1 );
1246  nPis = Abc_NtkCountPis( vSupp );
1247  printf( "%5d %20s : Cone = %5d. Supp = %5d. (PIs = %5d. FFs = %5d.)\n",
1248  i, Abc_ObjName(pObj), vNodes->nSize, vSupp->nSize, nPis, vSupp->nSize - nPis );
1249  Vec_PtrFree( vNodes );
1250  Vec_PtrFree( vSupp );
1251  }
1252  if ( !fMatrix )
1253  return;
1254 
1255  Abc_NtkForEachCi( pNtk, pObj, k )
1256  pObj->fMarkA = 0;
1257 
1258  printf( "Actual support info:\n" );
1259  Abc_NtkForEachCo( pNtk, pObj, i )
1260  {
1261  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
1262  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, k )
1263  pObj->fMarkA = 1;
1264  Vec_PtrFree( vSupp );
1265 
1266  Abc_NtkForEachCi( pNtk, pObj, k )
1267  printf( "%d", pObj->fMarkA );
1268  printf( "\n" );
1269 
1270  Abc_NtkForEachCi( pNtk, pObj, k )
1271  pObj->fMarkA = 0;
1272  }
1273 
1274 }
1275 
1276 /**Function*************************************************************
1277 
1278  Synopsis [Prints information about the object.]
1279 
1280  Description []
1281 
1282  SideEffects []
1283 
1284  SeeAlso []
1285 
1286 ***********************************************************************/
1287 void Abc_ObjPrint( FILE * pFile, Abc_Obj_t * pObj )
1288 {
1289  Abc_Obj_t * pFanin;
1290  int i;
1291  fprintf( pFile, "Object %5d : ", pObj->Id );
1292  switch ( pObj->Type )
1293  {
1294  case ABC_OBJ_NONE:
1295  fprintf( pFile, "NONE " );
1296  break;
1297  case ABC_OBJ_CONST1:
1298  fprintf( pFile, "Const1 " );
1299  break;
1300  case ABC_OBJ_PI:
1301  fprintf( pFile, "PI " );
1302  break;
1303  case ABC_OBJ_PO:
1304  fprintf( pFile, "PO " );
1305  break;
1306  case ABC_OBJ_BI:
1307  fprintf( pFile, "BI " );
1308  break;
1309  case ABC_OBJ_BO:
1310  fprintf( pFile, "BO " );
1311  break;
1312  case ABC_OBJ_NET:
1313  fprintf( pFile, "Net " );
1314  break;
1315  case ABC_OBJ_NODE:
1316  fprintf( pFile, "Node " );
1317  break;
1318  case ABC_OBJ_LATCH:
1319  fprintf( pFile, "Latch " );
1320  break;
1321  case ABC_OBJ_WHITEBOX:
1322  fprintf( pFile, "Whitebox" );
1323  break;
1324  case ABC_OBJ_BLACKBOX:
1325  fprintf( pFile, "Blackbox" );
1326  break;
1327  default:
1328  assert(0);
1329  break;
1330  }
1331  // print the fanins
1332  fprintf( pFile, " Fanins ( " );
1333  Abc_ObjForEachFanin( pObj, pFanin, i )
1334  fprintf( pFile, "%d ", pFanin->Id );
1335  fprintf( pFile, ") " );
1336 /*
1337  fprintf( pFile, " Fanouts ( " );
1338  Abc_ObjForEachFanout( pObj, pFanin, i )
1339  fprintf( pFile, "%d(%c) ", pFanin->Id, Abc_NodeIsTravIdCurrent(pFanin)? '+' : '-' );
1340  fprintf( pFile, ") " );
1341 */
1342  // print the logic function
1343  if ( Abc_ObjIsNode(pObj) && Abc_NtkIsSopLogic(pObj->pNtk) )
1344  fprintf( pFile, " %s", (char*)pObj->pData );
1345  else
1346  fprintf( pFile, "\n" );
1347 }
1348 
1349 
1350 /**Function*************************************************************
1351 
1352  Synopsis [Checks the status of the miter.]
1353 
1354  Description []
1355 
1356  SideEffects []
1357 
1358  SeeAlso []
1359 
1360 ***********************************************************************/
1362 {
1363  Abc_Obj_t * pObj, * pChild, * pConst1 = Abc_AigConst1(pNtk);
1364  int i, iOut = -1;
1365  abctime Time = Abc_Clock();
1366  int nUnsat = 0;
1367  int nSat = 0;
1368  int nUndec = 0;
1369  int nPis = 0;
1370  Abc_NtkForEachPi( pNtk, pObj, i )
1371  nPis += (int)( Abc_ObjFanoutNum(pObj) > 0 );
1372  Abc_NtkForEachPo( pNtk, pObj, i )
1373  {
1374  pChild = Abc_ObjChild0(pObj);
1375  // check if the output is constant 0
1376  if ( pChild == Abc_ObjNot(pConst1) )
1377  nUnsat++;
1378  // check if the output is constant 1
1379  else if ( pChild == pConst1 )
1380  {
1381  nSat++;
1382  if ( iOut == -1 )
1383  iOut = i;
1384  }
1385  // check if the output is a primary input
1386  else if ( Abc_ObjIsPi(Abc_ObjRegular(pChild)) )
1387  {
1388  nSat++;
1389  if ( iOut == -1 )
1390  iOut = i;
1391  }
1392  // check if the output is 1 for the 0000 pattern
1393  else if ( Abc_ObjRegular(pChild)->fPhase != (unsigned)Abc_ObjIsComplement(pChild) )
1394  {
1395  nSat++;
1396  if ( iOut == -1 )
1397  iOut = i;
1398  }
1399  else
1400  nUndec++;
1401  }
1402  printf( "Miter: I =%6d", nPis );
1403  printf( " N =%7d", Abc_NtkNodeNum(pNtk) );
1404  printf( " ? =%7d", nUndec );
1405  printf( " U =%6d", nUnsat );
1406  printf( " S =%6d", nSat );
1407  Time = Abc_Clock() - Time;
1408  printf(" %7.2f sec\n", (float)(Time)/(float)(CLOCKS_PER_SEC));
1409  if ( iOut >= 0 )
1410  printf( "The first satisfiable output is number %d (%s).\n", iOut, Abc_ObjName( Abc_NtkPo(pNtk, iOut) ) );
1411 }
1412 
1413 
1414 
1415 
1416 typedef struct Gli_Man_t_ Gli_Man_t;
1417 
1418 extern Gli_Man_t * Gli_ManAlloc( int nObjs, int nRegs, int nFanioPairs );
1419 extern void Gli_ManStop( Gli_Man_t * p );
1420 extern int Gli_ManCreateCi( Gli_Man_t * p, int nFanouts );
1421 extern int Gli_ManCreateCo( Gli_Man_t * p, int iFanin );
1422 extern int Gli_ManCreateNode( Gli_Man_t * p, Vec_Int_t * vFanins, int nFanouts, unsigned * puTruth );
1423 
1424 extern void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb, int fVerbose );
1425 extern int Gli_ObjNumSwitches( Gli_Man_t * p, int iNode );
1426 extern int Gli_ObjNumGlitches( Gli_Man_t * p, int iNode );
1427 
1428 /**Function*************************************************************
1429 
1430  Synopsis [Returns the percentable of increased power due to glitching.]
1431 
1432  Description []
1433 
1434  SideEffects []
1435 
1436  SeeAlso []
1437 
1438 ***********************************************************************/
1440 {
1441  int nSwitches, nGlitches;
1442  Gli_Man_t * p;
1443  Vec_Ptr_t * vNodes;
1444  Vec_Int_t * vFanins, * vTruth;
1445  Abc_Obj_t * pObj, * pFanin;
1446  unsigned * puTruth;
1447  int i, k;
1448  assert( Abc_NtkIsLogic(pNtk) );
1449  assert( Abc_NtkGetFaninMax(pNtk) <= 6 );
1450  if ( Abc_NtkGetFaninMax(pNtk) > 6 )
1451  {
1452  printf( "Abc_NtkMfsTotalGlitching() This procedure works only for mapped networks with LUTs size up to 6 inputs.\n" );
1453  return -1.0;
1454  }
1455  Abc_NtkToAig( pNtk );
1456  vNodes = Abc_NtkDfs( pNtk, 0 );
1457  vFanins = Vec_IntAlloc( 6 );
1458  vTruth = Vec_IntAlloc( 1 << 12 );
1459 
1460  // derive network for glitch computation
1461  p = Gli_ManAlloc( Vec_PtrSize(vNodes) + Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk),
1462  Abc_NtkLatchNum(pNtk), Abc_NtkGetTotalFanins(pNtk) + Abc_NtkCoNum(pNtk) );
1463  Abc_NtkForEachObj( pNtk, pObj, i )
1464  pObj->iTemp = -1;
1465  Abc_NtkForEachCi( pNtk, pObj, i )
1466  pObj->iTemp = Gli_ManCreateCi( p, Abc_ObjFanoutNum(pObj) );
1467  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
1468  {
1469  Vec_IntClear( vFanins );
1470  Abc_ObjForEachFanin( pObj, pFanin, k )
1471  Vec_IntPush( vFanins, pFanin->iTemp );
1472  puTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj), vTruth, 0 );
1473  pObj->iTemp = Gli_ManCreateNode( p, vFanins, Abc_ObjFanoutNum(pObj), puTruth );
1474  }
1475  Abc_NtkForEachCo( pNtk, pObj, i )
1476  Gli_ManCreateCo( p, Abc_ObjFanin0(pObj)->iTemp );
1477 
1478  // compute glitching
1479  Gli_ManSwitchesAndGlitches( p, 4000, 1.0/8.0, 0 );
1480 
1481  // compute the ratio
1482  nSwitches = nGlitches = 0;
1483  Abc_NtkForEachObj( pNtk, pObj, i )
1484  if ( pObj->iTemp >= 0 )
1485  {
1486  nSwitches += Abc_ObjFanoutNum(pObj) * Gli_ObjNumSwitches(p, pObj->iTemp);
1487  nGlitches += Abc_ObjFanoutNum(pObj) * Gli_ObjNumGlitches(p, pObj->iTemp);
1488  }
1489 
1490  Gli_ManStop( p );
1491  Vec_PtrFree( vNodes );
1492  Vec_IntFree( vTruth );
1493  Vec_IntFree( vFanins );
1494  return nSwitches ? 100.0*(nGlitches-nSwitches)/nSwitches : 0.0;
1495 }
1496 
1497 /**Function*************************************************************
1498 
1499  Synopsis [Prints K-map of 6-var function represented by truth table.]
1500 
1501  Description []
1502 
1503  SideEffects []
1504 
1505  SeeAlso []
1506 
1507 ***********************************************************************/
1509 {
1510  // order of cells in the Karnaugh map
1511 // int Cells[8] = { 0, 1, 3, 2, 6, 7, 5, 4 };
1512  int Cells[8] = { 0, 4, 6, 2, 3, 7, 5, 1 };
1513  // intermediate variables
1514  int s; // symbol counter
1515  int h; // horizontal coordinate;
1516  int v; // vertical coordinate;
1517  assert( (F0 & F1) == 0 );
1518 
1519  // output minterms above
1520  for ( s = 0; s < 4; s++ )
1521  printf( " " );
1522  printf( " " );
1523  for ( h = 0; h < 8; h++ )
1524  {
1525  for ( s = 0; s < 3; s++ )
1526  printf( "%d", ((Cells[h] >> (2-s)) & 1) );
1527  printf( " " );
1528  }
1529  printf( "\n" );
1530 
1531  // output horizontal line above
1532  for ( s = 0; s < 4; s++ )
1533  printf( " " );
1534  printf( "+" );
1535  for ( h = 0; h < 8; h++ )
1536  {
1537  for ( s = 0; s < 3; s++ )
1538  printf( "-" );
1539  printf( "+" );
1540  }
1541  printf( "\n" );
1542 
1543  // output lines with function values
1544  for ( v = 0; v < 8; v++ )
1545  {
1546  for ( s = 0; s < 3; s++ )
1547  printf( "%d", ((Cells[v] >> (2-s)) & 1) );
1548  printf( " |" );
1549 
1550  for ( h = 0; h < 8; h++ )
1551  {
1552  printf( " " );
1553  if ( ((F0 >> ((Cells[v]*8)+Cells[h])) & 1) )
1554  printf( "0" );
1555  else if ( ((F1 >> ((Cells[v]*8)+Cells[h])) & 1) )
1556  printf( "1" );
1557  else
1558  printf( " " );
1559  printf( " |" );
1560  }
1561  printf( "\n" );
1562 
1563  // output horizontal line above
1564  for ( s = 0; s < 4; s++ )
1565  printf( " " );
1566 // printf( "%c", v == 7 ? '+' : '|' );
1567  printf( "+" );
1568  for ( h = 0; h < 8; h++ )
1569  {
1570  for ( s = 0; s < 3; s++ )
1571  printf( "-" );
1572 // printf( "%c", v == 7 ? '+' : '|' );
1573  printf( "%c", (v == 7 || h == 7) ? '+' : '|' );
1574  }
1575  printf( "\n" );
1576  }
1577 }
1578 
1579 /**Function*************************************************************
1580 
1581  Synopsis [Prints K-map of 6-var function represented by truth table.]
1582 
1583  Description []
1584 
1585  SideEffects []
1586 
1587  SeeAlso []
1588 
1589 ***********************************************************************/
1590 void Abc_NtkShow6VarFunc( char * pF0, char * pF1 )
1591 {
1592  word F0, F1;
1593  if ( strlen(pF0) != 16 )
1594  {
1595  printf( "Wrong length (%d) of 6-var truth table.\n", (int)strlen(pF0) );
1596  return;
1597  }
1598  if ( strlen(pF1) != 16 )
1599  {
1600  printf( "Wrong length (%d) of 6-var truth table.\n", (int)strlen(pF1) );
1601  return;
1602  }
1603  Extra_ReadHexadecimal( (unsigned *)&F0, pF0, 6 );
1604  Extra_ReadHexadecimal( (unsigned *)&F1, pF1, 6 );
1605  Abc_Show6VarFunc( F0, F1 );
1606 }
1607 
1608 
1609 ////////////////////////////////////////////////////////////////////////
1610 /// END OF FILE ///
1611 ////////////////////////////////////////////////////////////////////////
1612 
1613 
char * memset()
ABC_DLL int Abc_NtkGetBufNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:410
void Abc_NtkPrintGates(Abc_Ntk_t *pNtk, int fUseLibrary)
Definition: abcPrint.c:1055
int iTemp
Definition: abc.h:149
int Abc_NtkCompareAndSaveBest(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcPrint.c:66
void Abc_NodePrintFanio(FILE *pFile, Abc_Obj_t *pNode)
Definition: abcPrint.c:752
void Abc_NtkPrintSharing(Abc_Ntk_t *pNtk)
Definition: abcPrint.c:1179
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
Definition: abc.h:91
static int Abc_LatchInit(Abc_Obj_t *pLatch)
Definition: abc.h:425
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
abctime s_ResubTime
Definition: abcPrint.c:46
static int Abc_NtkHasBdd(Abc_Ntk_t *pNtk)
Definition: abc.h:254
Gli_Man_t * Gli_ManAlloc(int nObjs, int nRegs, int nFanioPairs)
FUNCTION DEFINITIONS ///.
Definition: giaGlitch.c:144
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
ABC_DLL int Abc_NtkGetExorNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:370
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
unsigned fMarkA
Definition: abc.h:134
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
ABC_DLL float Abc_NtkDelayTrace(Abc_Ntk_t *pNtk, Abc_Obj_t *pOut, Abc_Obj_t *pIn, int fPrint)
Definition: abcTiming.c:919
int Gli_ObjNumSwitches(Gli_Man_t *p, int iNode)
Definition: giaGlitch.c:394
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
ABC_DLL double Abc_NtkGetMappedArea(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:334
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Abc_Ntk_t * pExdc
Definition: abc.h:201
Io_FileType_t
INCLUDES ///.
Definition: ioAbc.h:46
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
ABC_DLL int Abc_SopIsOrType(char *pSop)
Definition: abcSop.c:772
float Abc_NtkMfsTotalSwitching(Abc_Ntk_t *pNtk)
Definition: abcPrint.c:132
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
int Gli_ManCreateCi(Gli_Man_t *p, int nFanouts)
Definition: giaGlitch.c:288
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
int Gli_ManCreateNode(Gli_Man_t *p, Vec_Int_t *vFanins, int nFanouts, unsigned *puTruth)
Definition: giaGlitch.c:369
void Abc_NtkPrintStats(Abc_Ntk_t *pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch, int fSkipBuf)
Definition: abcPrint.c:207
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
int nBarBufs2
Definition: abc.h:175
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
int LutMax
Definition: if.h:173
void Abc_NodeMffcConeSuppPrint(Abc_Obj_t *pNode)
Definition: abcRefs.c:321
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
void Abc_NtkPrintStrSupports(Abc_Ntk_t *pNtk, int fMatrix)
Definition: abcPrint.c:1236
ABC_DLL int Abc_SopIsInv(char *pSop)
Definition: abcSop.c:728
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
void * pTemp
Definition: abc.h:147
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
int Mio_GateReadValue(Mio_Gate_t *pGate)
Definition: mioApi.c:156
void Abc_NtkPrintFanio(FILE *pFile, Abc_Ntk_t *pNtk, int fUsePis)
Definition: abcPrint.c:546
float Abc_NtkGetArea(Abc_Ntk_t *pNtk)
Definition: abcPrint.c:179
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
Definition: decFactor.c:55
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:264
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
ABC_DLL Vec_Ptr_t * Abc_NodeGetFaninNames(Abc_Obj_t *pNode)
Definition: abcNames.c:199
static abctime Abc_Clock()
Definition: abc_global.h:279
ABC_DLL int Abc_NtkGetCubeNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:112
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned Type
Definition: abc.h:133
ABC_DLL int Abc_NtkGetTotalFanins(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:487
ABC_DLL float Abc_NtkDelayTraceLut(Abc_Ntk_t *pNtk, int fUseLutLib)
Definition: abcSpeedup.c:100
void Abc_ObjPrint(FILE *pFile, Abc_Obj_t *pObj)
Definition: abcPrint.c:1287
static int Abc_NtkIsAigLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:266
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
void Abc_NtkPrintLevel(FILE *pFile, Abc_Ntk_t *pNtk, int fProfile, int fListNodes, int fVerbose)
Definition: abcPrint.c:866
Definition: hop.h:65
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
void Abc_NodePrintKMap(Abc_Obj_t *pNode, int fUseRealNames)
Definition: abcPrint.c:1028
ABC_DLL int Abc_SopIsBuf(char *pSop)
Definition: abcSop.c:708
void Extra_PrintKMap(FILE *pFile, DdManager *dd, DdNode *OnSet, DdNode *OffSet, int nVars, DdNode **XVars, int fSuppType, char **pVarNames)
Definition: extraBddKmap.c:201
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
int nRegs
Definition: giaGlitch.c:64
char * Extra_UtilStrsav(const char *s)
int strcmp()
ABC_DLL int Abc_NtkGetBddNodeNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:240
char * Mio_GateReadForm(Mio_Gate_t *pGate)
Definition: mioApi.c:146
void Abc_NtkPrintFactor(FILE *pFile, Abc_Ntk_t *pNtk, int fUseRealNames)
Definition: abcPrint.c:805
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition: mioApi.c:151
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static Abc_Obj_t * Abc_ObjChild0(Abc_Obj_t *pObj)
Definition: abc.h:383
ABC_DLL void Abc_NodeFreeNames(Vec_Ptr_t *vNames)
Definition: abcNames.c:257
void Io_Write(Abc_Ntk_t *pNtk, char *pFileName, Io_FileType_t FileType)
Definition: ioUtil.c:317
void Abc_NtkPrintFanioNew(FILE *pFile, Abc_Ntk_t *pNtk, int fMffc)
Definition: abcPrint.c:625
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
void Gli_ManStop(Gli_Man_t *p)
Definition: giaGlitch.c:170
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
void Abc_NtkPrintMiter(Abc_Ntk_t *pNtk)
Definition: abcPrint.c:1361
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
ABC_NAMESPACE_IMPL_START abctime s_MappingTime
DECLARATIONS ///.
Definition: abcPrint.c:44
void Dec_GraphPrint(FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
FUNCTION DEFINITIONS ///.
Definition: decPrint.c:49
ABC_DLL int Abc_NtkGetAigNodeNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:266
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Mio_GateSetValue(Mio_Gate_t *pGate, int Value)
Definition: mioApi.c:157
Vec_Int_t * Saig_ManComputeSwitchProbs(Aig_Man_t *pAig, int nFrames, int nPref, int fProbOne)
Definition: giaSwitch.c:684
static int Abc_NtkHasBlackbox(Abc_Ntk_t *pNtk)
Definition: abc.h:258
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Definition: abcDar.c:233
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
Definition: abcAig.c:292
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
ABC_DLL int Abc_NtkSopToBdd(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:113
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
#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
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:859
if(last==0)
Definition: sparse_int.h:34
int Abc_NtkCountMuxes(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1336
int Gli_ObjNumGlitches(Gli_Man_t *p, int iNode)
Definition: giaGlitch.c:410
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
ABC_DLL int Abc_SopIsConst0(char *pSop)
Definition: abcSop.c:676
ABC_DLL int Abc_SopIsConst1(char *pSop)
Definition: abcSop.c:692
void Abc_NtkShow6VarFunc(char *pF0, char *pF1)
Definition: abcPrint.c:1590
char * sprintf()
static int Counter
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
ABC_DLL int Abc_NtkGetLitFactNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:189
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
int Extra_ReadHexadecimal(unsigned Sign[], char *pString, int nVars)
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NtkConstrNum(Abc_Ntk_t *pNtk)
Definition: abc.h:299
void Abc_NodePrintFactor(FILE *pFile, Abc_Obj_t *pNode, int fUseRealNames)
Definition: abcPrint.c:825
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
double Mio_GateReadArea(Mio_Gate_t *pGate)
Definition: mioApi.c:145
char * pSpec
Definition: abc.h:159
ABC_DLL void Abc_ManTimeStop(Abc_ManTime_t *p)
Definition: abcTiming.c:455
int nObjs
Definition: giaGlitch.c:63
ABC_DLL float Abc_NodeReadArrivalWorst(Abc_Obj_t *pNode)
Definition: abcTiming.c:95
Mio_Gate_t ** Mio_LibraryReadGateArray(Mio_Library_t *pLib)
Definition: mioApi.c:46
int s_MappingMem
Definition: abcPrint.c:45
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: abc.h:89
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:359
void Abc_Show6VarFunc(word F0, word F1)
Definition: abcPrint.c:1508
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
abctime s_ResynTime
Definition: abcPrint.c:47
int nBarBufs
Definition: abc.h:174
int Gli_ManCreateCo(Gli_Man_t *p, int iFanin)
Definition: giaGlitch.c:308
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:265
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Id
Definition: abc.h:132
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
Abc_ManTime_t * pManTime
Definition: abc.h:192
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
ABC_DLL Abc_Obj_t * Abc_NtkFetchTwinNode(Abc_Obj_t *pNode)
Definition: abcMap.c:740
void Abc_NtkPrintIo(FILE *pFile, Abc_Ntk_t *pNtk, int fPrintFlops)
Definition: abcPrint.c:436
void Abc_NodePrintLevel(FILE *pFile, Abc_Obj_t *pNode)
Definition: abcPrint.c:985
Definition: abc.h:90
float pLutAreas[IF_MAX_LUTSIZE+1]
Definition: if.h:175
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1192
static void Dec_GraphFree(Dec_Graph_t *pGraph)
Definition: dec.h:307
Definition: abc.h:92
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
Definition: hopTruth.c:143
int Abc_NtkCountPis(Vec_Ptr_t *vSupp)
Definition: abcPrint.c:1228
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
Definition: abcObj.c:890
ABC_DLL int Abc_NtkGetLitNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:165
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkHasAig(Abc_Ntk_t *pNtk)
Definition: abc.h:255
ABC_DLL int Abc_SopIsAndType(char *pSop)
Definition: abcSop.c:748
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
int strlen()
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
void * pData
Definition: abc.h:145
ABC_DLL Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:120
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
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
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
void Abc_NtkPrintLatch(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: abcPrint.c:473
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
float Abc_NtkMfsTotalGlitching(Abc_Ntk_t *pNtk)
Definition: abcPrint.c:1439
ABC_DLL void * Abc_FrameReadLibLut()
Definition: mainFrame.c:54
int Id
Definition: aig.h:85
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition: abcSop.c:655
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition: mioApi.c:153
char * pName
Definition: abc.h:158
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition: mioApi.c:44
void Abc_NtkPrintMffc(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: abcPrint.c:784
int Abc_NtkGetMultiRefNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:218
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static int Abc_NtkNetNum(Abc_Ntk_t *pNtk)
Definition: abc.h:292
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Gli_ManSwitchesAndGlitches(Gli_Man_t *p, int nPatterns, float PiTransProb, int fVerbose)
Definition: giaGlitch.c:741
static int Depth
Definition: dsdProc.c:56