abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaMuxes.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [giaMuxes.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Scalable AIG package.]
8 
9  Synopsis [Multiplexer profiling algorithm.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: giaMuxes.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "gia.h"
22 #include "misc/util/utilNam.h"
23 #include "misc/vec/vecWec.h"
24 
26 
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// DECLARATIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// FUNCTION DEFINITIONS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 /**Function*************************************************************
37 
38  Synopsis [Counts XORs and MUXes.]
39 
40  Description []
41 
42  SideEffects []
43 
44  SeeAlso []
45 
46 ***********************************************************************/
47 void Gia_ManCountMuxXor( Gia_Man_t * p, int * pnMuxes, int * pnXors )
48 {
49  Gia_Obj_t * pObj, * pFan0, * pFan1; int i;
50  *pnMuxes = *pnXors = 0;
51  Gia_ManForEachAnd( p, pObj, i )
52  {
53  if ( !Gia_ObjIsMuxType(pObj) )
54  continue;
55  if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
56  (*pnXors)++;
57  else
58  (*pnMuxes)++;
59  }
60 }
62 {
63  int nAnds, nMuxes, nXors, nTotal;
64  if ( p->pMuxes )
65  {
67  nXors = Gia_ManXorNum(p);
68  nMuxes = Gia_ManMuxNum(p);
69  nTotal = nAnds + 3*nXors + 3*nMuxes;
70  }
71  else
72  {
73  Gia_ManCountMuxXor( p, &nMuxes, &nXors );
74  nAnds = Gia_ManAndNotBufNum(p) - 3*nMuxes - 3*nXors;
75  nTotal = Gia_ManAndNotBufNum(p);
76  }
77  Abc_Print( 1, "stats: " );
78  Abc_Print( 1, "xor =%8d %6.2f %% ", nXors, 300.0*nXors/nTotal );
79  Abc_Print( 1, "mux =%8d %6.2f %% ", nMuxes, 300.0*nMuxes/nTotal );
80  Abc_Print( 1, "and =%8d %6.2f %% ", nAnds, 100.0*nAnds/nTotal );
81  Abc_Print( 1, "obj =%8d ", Gia_ManAndNotBufNum(p) );
82  fflush( stdout );
83 }
84 
85 /**Function*************************************************************
86 
87  Synopsis [Derives GIA with MUXes.]
88 
89  Description [Create MUX if the sum of fanin references does not exceed limit.]
90 
91  SideEffects []
92 
93  SeeAlso []
94 
95 ***********************************************************************/
97 {
98  Gia_Man_t * pNew, * pTemp;
99  Gia_Obj_t * pObj, * pFan0, * pFan1, * pFanC, * pSiblNew, * pObjNew;
100  int i;
101  assert( p->pMuxes == NULL );
102  assert( Limit >= 2 );
103  ABC_FREE( p->pRefs );
104  Gia_ManCreateRefs( p );
105  // start the new manager
106  pNew = Gia_ManStart( Gia_ManObjNum(p) );
107  pNew->pName = Abc_UtilStrsav( p->pName );
108  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
109  pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
110  if ( Gia_ManHasChoices(p) )
111  pNew->pSibls = ABC_CALLOC( int, pNew->nObjsAlloc );
112  Gia_ManConst0(p)->Value = 0;
113  Gia_ManHashStart( pNew );
114  Gia_ManForEachObj1( p, pObj, i )
115  {
116  if ( Gia_ObjIsCi(pObj) )
117  pObj->Value = Gia_ManAppendCi( pNew );
118  else if ( Gia_ObjIsCo(pObj) )
119  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
120  else if ( Gia_ObjIsBuf(pObj) )
121  pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
122  else if ( !Gia_ObjIsMuxType(pObj) || Gia_ObjSibl(p, Gia_ObjFaninId0(pObj, i)) || Gia_ObjSibl(p, Gia_ObjFaninId1(pObj, i)) )
123  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
124  else if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
125  pObj->Value = Gia_ManHashXorReal( pNew, Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan0)), Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan1)) );
126  else if ( Gia_ObjRefNum(p, Gia_ObjFanin0(pObj)) + Gia_ObjRefNum(p, Gia_ObjFanin1(pObj)) > Limit )
127  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
128  else
129  {
130  pFanC = Gia_ObjRecognizeMux( pObj, &pFan1, &pFan0 );
131  pObj->Value = Gia_ManHashMuxReal( pNew, Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFanC)), Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan1)), Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan0)) );
132  }
133  if ( !Gia_ObjSibl(p, i) )
134  continue;
135  pObjNew = Gia_ManObj( pNew, Abc_Lit2Var(pObj->Value) );
136  pSiblNew = Gia_ManObj( pNew, Abc_Lit2Var(Gia_ObjSiblObj(p, i)->Value) );
137  if ( Gia_ObjIsAnd(pObjNew) && Gia_ObjIsAnd(pSiblNew) && Gia_ObjId(pNew, pObjNew) > Gia_ObjId(pNew, pSiblNew) )
138  pNew->pSibls[Gia_ObjId(pNew, pObjNew)] = Gia_ObjId(pNew, pSiblNew);
139  }
140  Gia_ManHashStop( pNew );
141  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
142  // perform cleanup
143  pNew = Gia_ManCleanup( pTemp = pNew );
144  Gia_ManStop( pTemp );
145  return pNew;
146 }
147 
148 /**Function*************************************************************
149 
150  Synopsis [Derives GIA without MUXes.]
151 
152  Description []
153 
154  SideEffects []
155 
156  SeeAlso []
157 
158 ***********************************************************************/
160 {
161  Gia_Man_t * pNew, * pTemp;
162  Gia_Obj_t * pObj;
163  int i;
164  assert( p->pMuxes != NULL );
165  // start the new manager
166  pNew = Gia_ManStart( 5000 );
167  pNew->pName = Abc_UtilStrsav( p->pName );
168  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
169  Gia_ManConst0(p)->Value = 0;
170  Gia_ManHashStart( pNew );
171  Gia_ManForEachObj1( p, pObj, i )
172  {
173  if ( Gia_ObjIsCi(pObj) )
174  pObj->Value = Gia_ManAppendCi( pNew );
175  else if ( Gia_ObjIsCo(pObj) )
176  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
177  else if ( Gia_ObjIsBuf(pObj) )
178  pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
179  else if ( Gia_ObjIsMuxId(p, i) )
180  pObj->Value = Gia_ManHashMux( pNew, Gia_ObjFanin2Copy(p, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
181  else if ( Gia_ObjIsXor(pObj) )
182  pObj->Value = Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
183  else
184  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
185  }
186  Gia_ManHashStop( pNew );
187  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
188  // perform cleanup
189  pNew = Gia_ManCleanup( pTemp = pNew );
190  Gia_ManStop( pTemp );
191  return pNew;
192 }
193 
194 /**Function*************************************************************
195 
196  Synopsis [Test these procedures.]
197 
198  Description []
199 
200  SideEffects []
201 
202  SeeAlso []
203 
204 ***********************************************************************/
206 {
207  Gia_Man_t * pNew, * pNew2;
208  pNew = Gia_ManDupMuxes( p, 2 );
209  pNew2 = Gia_ManDupNoMuxes( pNew );
210  Gia_ManPrintStats( p, NULL );
211  Gia_ManPrintStats( pNew, NULL );
212  Gia_ManPrintStats( pNew2, NULL );
213  Gia_ManStop( pNew );
214 // Gia_ManStop( pNew2 );
215  return pNew2;
216 }
217 
218 
219 /**Function*************************************************************
220 
221  Synopsis [Returns the size of MUX structure.]
222 
223  Description []
224 
225  SideEffects []
226 
227  SeeAlso []
228 
229 ***********************************************************************/
230 int Gia_MuxRef_rec( Gia_Man_t * p, int iObj )
231 {
232  Gia_Obj_t * pObj;
233  if ( !Gia_ObjIsMuxId(p, iObj) )
234  return 0;
235  pObj = Gia_ManObj( p, iObj );
236  if ( Gia_ObjRefInc(p, pObj) )
237  return 0;
238  return Gia_MuxRef_rec( p, Gia_ObjFaninId0p(p, pObj) ) +
239  Gia_MuxRef_rec( p, Gia_ObjFaninId1p(p, pObj) ) +
240  Gia_MuxRef_rec( p, Gia_ObjFaninId2p(p, pObj) ) + 1;
241 }
242 int Gia_MuxRef( Gia_Man_t * p, int iObj )
243 {
244  Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
245  assert( Gia_ObjIsMuxId(p, iObj) );
246  return Gia_MuxRef_rec( p, Gia_ObjFaninId0p(p, pObj) ) +
247  Gia_MuxRef_rec( p, Gia_ObjFaninId1p(p, pObj) ) +
248  Gia_MuxRef_rec( p, Gia_ObjFaninId2p(p, pObj) ) + 1;
249 }
250 int Gia_MuxDeref_rec( Gia_Man_t * p, int iObj )
251 {
252  Gia_Obj_t * pObj;
253  if ( !Gia_ObjIsMuxId(p, iObj) )
254  return 0;
255  pObj = Gia_ManObj( p, iObj );
256  if ( Gia_ObjRefDec(p, pObj) )
257  return 0;
258  return Gia_MuxDeref_rec( p, Gia_ObjFaninId0p(p, pObj) ) +
259  Gia_MuxDeref_rec( p, Gia_ObjFaninId1p(p, pObj) ) +
260  Gia_MuxDeref_rec( p, Gia_ObjFaninId2p(p, pObj) ) + 1;
261 }
262 int Gia_MuxDeref( Gia_Man_t * p, int iObj )
263 {
264  Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
265  assert( Gia_ObjIsMuxId(p, iObj) );
266  return Gia_MuxDeref_rec( p, Gia_ObjFaninId0p(p, pObj) ) +
267  Gia_MuxDeref_rec( p, Gia_ObjFaninId1p(p, pObj) ) +
268  Gia_MuxDeref_rec( p, Gia_ObjFaninId2p(p, pObj) ) + 1;
269 }
270 int Gia_MuxMffcSize( Gia_Man_t * p, int iObj )
271 {
272  int Count1, Count2;
273  if ( !Gia_ObjIsMuxId(p, iObj) )
274  return 0;
275  Count1 = Gia_MuxDeref( p, iObj );
276  Count2 = Gia_MuxRef( p, iObj );
277  assert( Count1 == Count2 );
278  return Count1;
279 }
280 
281 /**Function*************************************************************
282 
283  Synopsis []
284 
285  Description []
286 
287  SideEffects []
288 
289  SeeAlso []
290 
291 ***********************************************************************/
292 void Gia_MuxStructPrint_rec( Gia_Man_t * p, int iObj, int fFirst )
293 {
294  Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
295  int iCtrl;
296  if ( !fFirst && (!Gia_ObjIsMuxId(p, iObj) || Gia_ObjRefNumId(p, iObj) > 0) )
297  {
298 // printf( "%d", iObj );
299  printf( "<%02d>", Gia_ObjLevelId(p, iObj) );
300  return;
301  }
302  iCtrl = Gia_ObjFaninId2p(p, pObj);
303  printf( " [(" );
304  if ( Gia_ObjIsMuxId(p, iCtrl) && Gia_ObjRefNumId(p, iCtrl) == 0 )
305  Gia_MuxStructPrint_rec( p, iCtrl, 0 );
306  else
307  {
308  printf( "%d", iCtrl );
309  printf( "<%d>", Gia_ObjLevelId(p, iCtrl) );
310  }
311  printf( ")" );
312  if ( Gia_ObjFaninC2(p, pObj) )
313  {
314  Gia_MuxStructPrint_rec( p, Gia_ObjFaninId0p(p, pObj), 0 );
315  printf( "|" );
316  Gia_MuxStructPrint_rec( p, Gia_ObjFaninId1p(p, pObj), 0 );
317  printf( "]" );
318  }
319  else
320  {
321  Gia_MuxStructPrint_rec( p, Gia_ObjFaninId1p(p, pObj), 0 );
322  printf( "|" );
323  Gia_MuxStructPrint_rec( p, Gia_ObjFaninId0p(p, pObj), 0 );
324  printf( "]" );
325  }
326 }
327 void Gia_MuxStructPrint( Gia_Man_t * p, int iObj )
328 {
329  int Count1, Count2;
330  assert( Gia_ObjIsMuxId(p, iObj) );
331  Count1 = Gia_MuxDeref( p, iObj );
332  Gia_MuxStructPrint_rec( p, iObj, 1 );
333  Count2 = Gia_MuxRef( p, iObj );
334  assert( Count1 == Count2 );
335  printf( "\n" );
336 }
337 
338 /**Function*************************************************************
339 
340  Synopsis []
341 
342  Description []
343 
344  SideEffects []
345 
346  SeeAlso []
347 
348 ***********************************************************************/
349 void Gia_MuxStructDump_rec( Gia_Man_t * p, int iObj, int fFirst, Vec_Str_t * vStr, int nDigitsId )
350 {
351  Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
352  int iCtrl;
353  if ( !fFirst && (!Gia_ObjIsMuxId(p, iObj) || Gia_ObjRefNumId(p, iObj) > 0) )
354  return;
355  iCtrl = Gia_ObjFaninId2p(p, pObj);
356  Vec_StrPush( vStr, '[' );
357  Vec_StrPush( vStr, '(' );
358  if ( Gia_ObjIsMuxId(p, iCtrl) && Gia_ObjRefNumId(p, iCtrl) == 0 )
359  Gia_MuxStructDump_rec( p, iCtrl, 0, vStr, nDigitsId );
360  else
361  Vec_StrPrintNumStar( vStr, iCtrl, nDigitsId );
362  Vec_StrPush( vStr, ')' );
363  if ( Gia_ObjFaninC2(p, pObj) )
364  {
365  Gia_MuxStructDump_rec( p, Gia_ObjFaninId0p(p, pObj), 0, vStr, nDigitsId );
366  Vec_StrPush( vStr, '|' );
367  Gia_MuxStructDump_rec( p, Gia_ObjFaninId1p(p, pObj), 0, vStr, nDigitsId );
368  Vec_StrPush( vStr, ']' );
369  }
370  else
371  {
372  Gia_MuxStructDump_rec( p, Gia_ObjFaninId1p(p, pObj), 0, vStr, nDigitsId );
373  Vec_StrPush( vStr, '|' );
374  Gia_MuxStructDump_rec( p, Gia_ObjFaninId0p(p, pObj), 0, vStr, nDigitsId );
375  Vec_StrPush( vStr, ']' );
376  }
377 }
378 int Gia_MuxStructDump( Gia_Man_t * p, int iObj, Vec_Str_t * vStr, int nDigitsNum, int nDigitsId )
379 {
380  int Count1, Count2;
381  assert( Gia_ObjIsMuxId(p, iObj) );
382  Count1 = Gia_MuxDeref( p, iObj );
383  Vec_StrClear( vStr );
384  Vec_StrPrintNumStar( vStr, Count1, nDigitsNum );
385  Gia_MuxStructDump_rec( p, iObj, 1, vStr, nDigitsId );
386  Vec_StrPush( vStr, '\0' );
387  Count2 = Gia_MuxRef( p, iObj );
388  assert( Count1 == Count2 );
389  return Count1;
390 }
391 
392 /**Function*************************************************************
393 
394  Synopsis []
395 
396  Description []
397 
398  SideEffects []
399 
400  SeeAlso []
401 
402 ***********************************************************************/
403 int Gia_ManMuxCompare( char ** pp1, char ** pp2 )
404 {
405  int Diff = strcmp( *pp1, *pp2 );
406  if ( Diff < 0 )
407  return 1;
408  if ( Diff > 0)
409  return -1;
410  return 0;
411 }
412 int Gia_ManMuxCountOne( char * p )
413 {
414  int Count = 0;
415  for ( ; *p; p++ )
416  Count += (*p == '[');
417  return Count;
418 }
419 
420 typedef struct Mux_Man_t_ Mux_Man_t;
422 {
423  Gia_Man_t * pGia; // manager
424  Abc_Nam_t * pNames; // hashing name into ID
425  Vec_Wec_t * vTops; // top nodes for each struct
426 };
427 
428 /**Function*************************************************************
429 
430  Synopsis []
431 
432  Description []
433 
434  SideEffects []
435 
436  SeeAlso []
437 
438 ***********************************************************************/
440 {
441  Mux_Man_t * p;
442  p = ABC_CALLOC( Mux_Man_t, 1 );
443  p->pGia = pGia;
444  p->pNames = Abc_NamStart( 10000, 50 );
445  p->vTops = Vec_WecAlloc( 1000 );
446  Vec_WecPushLevel( p->vTops );
447  return p;
448 }
450 {
451  Abc_NamStop( p->pNames );
452  Vec_WecFree( p->vTops );
453  ABC_FREE( p );
454 }
455 
456 /**Function*************************************************************
457 
458  Synopsis []
459 
460  Description []
461 
462  SideEffects []
463 
464  SeeAlso []
465 
466 ***********************************************************************/
467 int Gia_ManMuxProfile( Mux_Man_t * p, int fWidth )
468 {
469  int i, Entry, Counter, Total;
470  Vec_Int_t * vVec, * vCounts;
471  vCounts = Vec_IntStart( 1000 );
472  if ( fWidth )
473  {
474  Vec_WecForEachLevelStart( p->vTops, vVec, i, 1 )
475  Vec_IntAddToEntry( vCounts, Abc_MinInt(Vec_IntSize(vVec), 999), 1 );
476  }
477  else
478  {
479  for ( i = 1; i < Vec_WecSize(p->vTops); i++ )
480  Vec_IntAddToEntry( vCounts, Abc_MinInt(atoi(Abc_NamStr(p->pNames, i)), 999), 1 );
481  }
482  Total = Vec_IntCountPositive(vCounts);
483  if ( Total == 0 )
484  return 0;
485  printf( "The distribution of MUX tree %s:\n", fWidth ? "widths" : "sizes" );
486  Counter = 0;
487  Vec_IntForEachEntry( vCounts, Entry, i )
488  {
489  if ( !Entry ) continue;
490  if ( ++Counter == 12 )
491  printf( "\n" ), Counter = 0;
492  printf( " %d=%d", i, Entry );
493  }
494  printf( "\nSummary: " );
495  printf( "Max = %d ", Vec_IntFindMax(vCounts) );
496  printf( "Ave = %.2f", 1.0*Vec_IntSum(vCounts)/Total );
497  printf( "\n" );
498  Vec_IntFree( vCounts );
499  return 1;
500 }
501 
502 /**Function*************************************************************
503 
504  Synopsis []
505 
506  Description []
507 
508  SideEffects []
509 
510  SeeAlso []
511 
512 ***********************************************************************/
514 {
515  Mux_Man_t * pMan;
516  Gia_Man_t * pNew;
517  Gia_Obj_t * pObj;
518  Vec_Str_t * vStr;
519  Vec_Int_t * vFans, * vVec;
520  int i, Counter, fFound, iStructId, nDigitsId;
521  abctime clk = Abc_Clock();
522 
523  pNew = Gia_ManDupMuxes( p, 2 );
524  nDigitsId = Abc_Base10Log( Gia_ManObjNum(pNew) );
525 
526  pMan = Mux_ManAlloc( pNew );
527 
528  Gia_ManLevelNum( pNew );
529  Gia_ManCreateRefs( pNew );
530  Gia_ManForEachCo( pNew, pObj, i )
531  Gia_ObjRefFanin0Inc( pNew, pObj );
532 
533  vStr = Vec_StrAlloc( 1000 );
534  vFans = Gia_ManFirstFanouts( pNew );
535  Gia_ManForEachMux( pNew, pObj, i )
536  {
537  // skip MUXes in the middle of the tree (which have only one MUX fanout)
538  if ( Gia_ObjRefNumId(pNew, i) == 1 && Gia_ObjIsMuxId(pNew, Vec_IntEntry(vFans, i)) )
539  continue;
540  // this node is the root of the MUX structure - create hash key
541  Counter = Gia_MuxStructDump( pNew, i, vStr, 3, nDigitsId );
542  if ( Counter == 1 )
543  continue;
544  iStructId = Abc_NamStrFindOrAdd( pMan->pNames, Vec_StrArray(vStr), &fFound );
545  if ( !fFound )
546  Vec_WecPushLevel( pMan->vTops );
547  assert( Abc_NamObjNumMax(pMan->pNames) == Vec_WecSize(pMan->vTops) );
548  Vec_IntPush( Vec_WecEntry(pMan->vTops, iStructId), i );
549  }
550  Vec_StrFree( vStr );
551  Vec_IntFree( vFans );
552 
553  printf( "MUX structure profile for AIG \"%s\":\n", p->pName );
554  printf( "Total MUXes = %d. Total trees = %d. Unique trees = %d. Memory = %.2f MB ",
555  Gia_ManMuxNum(pNew), Vec_WecSizeSize(pMan->vTops), Vec_WecSize(pMan->vTops)-1,
556  1.0*Abc_NamMemUsed(pMan->pNames)/(1<<20) );
557  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
558 
559  if ( Gia_ManMuxProfile(pMan, 0) )
560  {
561  Gia_ManMuxProfile( pMan, 1 );
562 
563  // short the first ones
564  printf( "The first %d structures: \n", 10 );
565  Vec_WecForEachLevelStartStop( pMan->vTops, vVec, i, 1, Abc_MinInt(Vec_WecSize(pMan->vTops), 10) )
566  {
567  char * pTemp = Abc_NamStr(pMan->pNames, i);
568  printf( "%5d : ", i );
569  printf( "Occur = %4d ", Vec_IntSize(vVec) );
570  printf( "Size = %4d ", atoi(pTemp) );
571  printf( "%s\n", pTemp );
572  }
573 
574  // print trees for the first one
575  Counter = 0;
576  Vec_WecForEachLevelStart( pMan->vTops, vVec, i, 1 )
577  {
578  char * pTemp = Abc_NamStr(pMan->pNames, i);
579  if ( Vec_IntSize(vVec) > 5 && atoi(pTemp) > 5 )
580  {
581  int k, Entry;
582  printf( "For example, structure %d has %d MUXes and bit-width %d:\n", i, atoi(pTemp), Vec_IntSize(vVec) );
583  Vec_IntForEachEntry( vVec, Entry, k )
584  Gia_MuxStructPrint( pNew, Entry );
585  if ( ++Counter == 5 )
586  break;
587  }
588  }
589  }
590 
591  Mux_ManFree( pMan );
592  Gia_ManStop( pNew );
593 }
594 
595 
596 ////////////////////////////////////////////////////////////////////////
597 /// END OF FILE ///
598 ////////////////////////////////////////////////////////////////////////
599 
600 
602 
int nObjsAlloc
Definition: gia.h:102
static int Gia_ObjFanin2Copy(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:483
static int Vec_IntCountPositive(Vec_Int_t *p)
Definition: vecInt.h:1175
static int Gia_ObjToLit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:497
static int Gia_ObjLevelId(Gia_Man_t *p, int Id)
Definition: gia.h:500
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
static void Gia_ObjRefFanin0Inc(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:524
static int Gia_ManMuxNum(Gia_Man_t *p)
Definition: gia.h:391
int Gia_ObjRecognizeExor(Gia_Obj_t *pObj, Gia_Obj_t **ppFan0, Gia_Obj_t **ppFan1)
Definition: giaUtil.c:921
static int Gia_ObjFaninC2(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:453
Abc_Nam_t * pNames
Definition: giaMuxes.c:424
int Gia_MuxDeref_rec(Gia_Man_t *p, int iObj)
Definition: giaMuxes.c:250
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
void Abc_NamStop(Abc_Nam_t *p)
Definition: utilNam.c:110
Vec_Wec_t * vTops
Definition: giaMuxes.c:425
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition: vecWec.h:42
static Gia_Obj_t * Gia_ObjSiblObj(Gia_Man_t *p, int Id)
Definition: gia.h:894
int Gia_MuxStructDump(Gia_Man_t *p, int iObj, Vec_Str_t *vStr, int nDigitsNum, int nDigitsId)
Definition: giaMuxes.c:378
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Gia_MuxStructDump_rec(Gia_Man_t *p, int iObj, int fFirst, Vec_Str_t *vStr, int nDigitsId)
Definition: giaMuxes.c:349
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:658
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Vec_Int_t * Gia_ManFirstFanouts(Gia_Man_t *p)
Definition: giaUtil.c:1635
int * pSibls
Definition: gia.h:123
static void Vec_WecFree(Vec_Wec_t *p)
Definition: vecWec.h:345
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Gia_ObjRefNumId(Gia_Man_t *p, int Id)
Definition: gia.h:518
void Gia_MuxStructPrint_rec(Gia_Man_t *p, int iObj, int fFirst)
Definition: giaMuxes.c:292
unsigned * pMuxes
Definition: gia.h:104
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
void Gia_ManMuxProfiling(Gia_Man_t *p)
Definition: giaMuxes.c:513
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition: utilNam.c:392
static int Gia_ManAndNotBufNum(Gia_Man_t *p)
Definition: gia.h:393
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
Definition: utilNam.c:78
#define Gia_ManForEachMux(p, pObj, i)
Definition: gia.h:1014
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
ABC_NAMESPACE_IMPL_START void Gia_ManCountMuxXor(Gia_Man_t *p, int *pnMuxes, int *pnXors)
DECLARATIONS ///.
Definition: giaMuxes.c:47
int strcmp()
int Gia_ManMuxProfile(Mux_Man_t *p, int fWidth)
Definition: giaMuxes.c:467
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
#define Vec_WecForEachLevelStartStop(vGlob, vVec, i, LevelStart, LevelStop)
Definition: vecWec.h:63
int Gia_MuxDeref(Gia_Man_t *p, int iObj)
Definition: giaMuxes.c:262
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static int Gia_ObjSibl(Gia_Man_t *p, int Id)
Definition: gia.h:893
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Gia_ObjIsMuxId(Gia_Man_t *p, int iObj)
Definition: gia.h:424
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
char * pName
Definition: gia.h:97
void Gia_MuxStructPrint(Gia_Man_t *p, int iObj)
Definition: giaMuxes.c:327
int Abc_NamMemUsed(Abc_Nam_t *p)
Definition: utilNam.c:202
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static int Gia_ManAppendBuf(Gia_Man_t *p, int iLit)
Definition: gia.h:694
static int nMuxes
Definition: abcSat.c:36
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntFindMax(Vec_Int_t *p)
Definition: vecInt.h:996
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
static int Gia_ObjRefInc(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:522
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
int Gia_MuxMffcSize(Gia_Man_t *p, int iObj)
Definition: giaMuxes.c:270
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
int Gia_ManMuxCountOne(char *p)
Definition: giaMuxes.c:412
Gia_Man_t * Gia_ManDupMuxesTest(Gia_Man_t *p)
Definition: giaMuxes.c:205
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
int Gia_ManMuxCompare(char **pp1, char **pp2)
Definition: giaMuxes.c:403
static int Gia_ObjIsXor(Gia_Obj_t *pObj)
Definition: gia.h:423
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
void Gia_ManPrintMuxStats(Gia_Man_t *p)
Definition: giaMuxes.c:61
int Gia_ManHashXorReal(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:465
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Counter
static int Gia_ManXorNum(Gia_Man_t *p)
Definition: gia.h:390
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Gia_ObjLitCopy(Gia_Man_t *p, int iLit)
Definition: gia.h:479
static void Vec_StrPrintNumStar(Vec_Str_t *p, int Num, int nDigits)
Definition: vecStr.h:594
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Gia_ObjRefDec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:523
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
Gia_Man_t * pGia
Definition: giaMuxes.c:423
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Vec_WecForEachLevelStart(vGlob, vVec, i, LevelStart)
Definition: vecWec.h:59
static int Vec_IntSum(Vec_Int_t *p)
Definition: vecInt.h:1137
Mux_Man_t * Mux_ManAlloc(Gia_Man_t *pGia)
Definition: giaMuxes.c:439
int Gia_MuxRef(Gia_Man_t *p, int iObj)
Definition: giaMuxes.c:242
#define ABC_FREE(obj)
Definition: abc_global.h:232
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
static int Gia_ObjFaninId2p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:465
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition: utilNam.h:39
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
Definition: giaMuxes.c:96
#define assert(ex)
Definition: util_old.h:213
int Gia_ManLevelNum(Gia_Man_t *p)
Definition: giaUtil.c:505
unsigned Value
Definition: gia.h:87
int Gia_ManHashMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
Definition: giaHash.c:517
#define Gia_ManForEachObj1(p, pObj, i)
Definition: gia.h:986
void Mux_ManFree(Mux_Man_t *p)
Definition: giaMuxes.c:449
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Gia_MuxRef_rec(Gia_Man_t *p, int iObj)
Definition: giaMuxes.c:230
static int Vec_WecSizeSize(Vec_Wec_t *p)
Definition: vecWec.h:202
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
Gia_Man_t * Gia_ManDupNoMuxes(Gia_Man_t *p)
Definition: giaMuxes.c:159
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387