abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcHieNew.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcHieNew.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [New hierarchy manager.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcHieNew.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <assert.h>
25 
26 #include "misc/vec/vec.h"
27 #include "misc/util/utilNam.h"
28 #include "misc/extra/extra.h"
29 
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// DECLARATIONS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 #define AU_MAX_FANINS 0x1FFFFFFF
37 
38 typedef enum {
39  AU_OBJ_NONE, // 0: non-existent object
40  AU_OBJ_CONST0, // 1: constant node
41  AU_OBJ_PI, // 2: primary input
42  AU_OBJ_PO, // 3: primary output
43  AU_OBJ_FAN, // 4: box output
44  AU_OBJ_FLOP, // 5: flip-flop
45  AU_OBJ_BOX, // 6: box
46  AU_OBJ_NODE, // 7: logic node
47  AU_OBJ_VOID // 8: placeholder
48 } Au_Type_t;
49 
50 
51 typedef struct Au_Man_t_ Au_Man_t;
52 typedef struct Au_Ntk_t_ Au_Ntk_t;
53 typedef struct Au_Obj_t_ Au_Obj_t;
54 
55 struct Au_Obj_t_ // 16 bytes
56 {
57  unsigned Func : 30; // functionality
58  unsigned Value : 2; // node value
59  unsigned Type : 3; // object type
60  unsigned nFanins : 29; // fanin count (related to AU_MAX_FANIN_NUM)
61  int Fanins[2]; // fanin literals
62 };
63 
64 struct Au_Ntk_t_
65 {
66  char * pName; // model name
67  Au_Man_t * pMan; // model manager
68  int Id; // model ID
69  // objects
70  Vec_Int_t vPis; // primary inputs (CI id -> handle)
71  Vec_Int_t vPos; // primary outputs (CI id -> handle)
72  Vec_Int_t vObjs; // internal nodes (obj id -> handle)
73  int nObjs[AU_OBJ_VOID]; // counter of objects of each type
74  // memory for objects
75  Vec_Ptr_t * vChunks; // memory pages
76  Vec_Ptr_t vPages; // memory pages
77  int iHandle; // currently available ID
78  int nObjsAlloc; // the total number of objects allocated
79  int nObjsUsed; // the number of useful entries
80  // object attributes
81  int nTravIds; // counter of traversal IDs
82  Vec_Int_t vTravIds; // trav IDs of the objects
83  Vec_Int_t vCopies; // object copies
84  // structural hashing
85  int nHTable; // hash table size
86  int * pHTable; // hash table
87  Au_Obj_t * pConst0; // constant node
88  // statistics
89  int fMark;
90  double nBoxes;
91  double nNodes;
92  double nPorts;
93  double nNodeAnds;
94  double nNodeXors;
95  double nNodeMuxs;
96 };
97 
98 struct Au_Man_t_
99 {
100  char * pName; // the name of the library
101  Vec_Ptr_t vNtks; // the array of modules
102  Abc_Nam_t * pFuncs; // hashing functions into integers
103  int nRefs; // reference counter
104  // statistics
105  int nGiaObjMax; // max number of GIA objects
106  double nPortsC0; // const ports
107  double nPortsC1; // const ports
108  double nPortsNC; // non-const ports
109 };
110 
111 
112 static inline int Au_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
113 static inline int Au_Lit2Var( int Lit ) { return Lit >> 1; }
114 static inline int Au_LitIsCompl( int Lit ) { return Lit & 1; }
115 static inline int Au_LitNot( int Lit ) { return Lit ^ 1; }
116 static inline int Au_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
117 static inline int Au_LitRegular( int Lit ) { return Lit & ~01; }
118 
119 static inline Au_Obj_t * Au_Regular( Au_Obj_t * p ) { return (Au_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
120 static inline Au_Obj_t * Au_Not( Au_Obj_t * p ) { return (Au_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
121 static inline Au_Obj_t * Au_NotCond( Au_Obj_t * p, int c ) { return (Au_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
122 static inline int Au_IsComplement( Au_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); }
123 
124 static inline char * Au_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; }
125 
126 static inline char * Au_ManName( Au_Man_t * p ) { return p->pName; }
127 static inline int Au_ManNtkNum( Au_Man_t * p ) { return Vec_PtrSize(&p->vNtks) - 1; }
128 static inline Au_Ntk_t * Au_ManNtk( Au_Man_t * p, int i ) { return (Au_Ntk_t *)Vec_PtrEntry(&p->vNtks, i); }
129 static inline Au_Ntk_t * Au_ManNtkRoot( Au_Man_t * p ) { return Au_ManNtk( p, 1 ); }
130 
131 static inline char * Au_NtkName( Au_Ntk_t * p ) { return p->pName; }
132 static inline Au_Man_t * Au_NtkMan( Au_Ntk_t * p ) { return p->pMan; }
133 static inline int Au_NtkPiNum( Au_Ntk_t * p ) { return p->nObjs[AU_OBJ_PI]; }
134 static inline int Au_NtkPoNum( Au_Ntk_t * p ) { return p->nObjs[AU_OBJ_PO]; }
135 static inline int Au_NtkFanNum( Au_Ntk_t * p ) { return p->nObjs[AU_OBJ_FAN]; }
136 static inline int Au_NtkFlopNum( Au_Ntk_t * p ) { return p->nObjs[AU_OBJ_FLOP]; }
137 static inline int Au_NtkBoxNum( Au_Ntk_t * p ) { return p->nObjs[AU_OBJ_BOX]; }
138 static inline int Au_NtkNodeNum( Au_Ntk_t * p ) { return p->nObjs[AU_OBJ_NODE]; }
139 static inline int Au_NtkObjNumMax( Au_Ntk_t * p ) { return (Vec_PtrSize(&p->vPages) - 1) * (1 << 12) + p->iHandle; }
140 static inline int Au_NtkObjNum( Au_Ntk_t * p ) { return Vec_IntSize(&p->vObjs); }
141 static inline Au_Obj_t * Au_NtkObj( Au_Ntk_t * p, int h ) { return (Au_Obj_t *)p->vPages.pArray[h >> 12] + (h & 0xFFF); }
142 
143 static inline Au_Obj_t * Au_NtkPi( Au_Ntk_t * p, int i ) { return Au_NtkObj(p, Vec_IntEntry(&p->vPis, i)); }
144 static inline Au_Obj_t * Au_NtkPo( Au_Ntk_t * p, int i ) { return Au_NtkObj(p, Vec_IntEntry(&p->vPos, i)); }
145 static inline Au_Obj_t * Au_NtkObjI( Au_Ntk_t * p, int i ) { return Au_NtkObj(p, Vec_IntEntry(&p->vObjs, i)); }
146 
147 static inline int Au_ObjIsNone( Au_Obj_t * p ) { return p->Type == AU_OBJ_NONE; }
148 static inline int Au_ObjIsConst0( Au_Obj_t * p ) { return p->Type == AU_OBJ_CONST0; }
149 static inline int Au_ObjIsPi( Au_Obj_t * p ) { return p->Type == AU_OBJ_PI; }
150 static inline int Au_ObjIsPo( Au_Obj_t * p ) { return p->Type == AU_OBJ_PO; }
151 static inline int Au_ObjIsFan( Au_Obj_t * p ) { return p->Type == AU_OBJ_FAN; }
152 static inline int Au_ObjIsFlop( Au_Obj_t * p ) { return p->Type == AU_OBJ_FLOP; }
153 static inline int Au_ObjIsBox( Au_Obj_t * p ) { return p->Type == AU_OBJ_BOX; }
154 static inline int Au_ObjIsNode( Au_Obj_t * p ) { return p->Type == AU_OBJ_NODE; }
155 static inline int Au_ObjIsTerm( Au_Obj_t * p ) { return p->Type >= AU_OBJ_PI && p->Type <= AU_OBJ_FLOP; }
156 
157 static inline char * Au_ObjBase( Au_Obj_t * p ) { return (char *)p - ((ABC_PTRINT_T)p & 0x3FF); }
158 static inline Au_Ntk_t * Au_ObjNtk( Au_Obj_t * p ) { return ((Au_Ntk_t **)Au_ObjBase(p))[0]; }
159 static inline int Au_ObjId( Au_Obj_t * p ) { return ((int *)Au_ObjBase(p))[2] | (((ABC_PTRINT_T)p & 0x3FF) >> 4); }
160 static inline int Au_ObjPioNum( Au_Obj_t * p ) { assert(Au_ObjIsTerm(p)); return p->Fanins[p->nFanins]; }
161 static inline int Au_ObjFunc( Au_Obj_t * p ) { return p->Func; }
162 static inline Au_Ntk_t * Au_ObjModel( Au_Obj_t * p ) { assert(Au_ObjIsFan(p)||Au_ObjIsBox(p)); return Au_ManNtk(Au_NtkMan(Au_ObjNtk(p)), p->Func); }
163 
164 static inline int Au_ObjFaninNum( Au_Obj_t * p ) { return p->nFanins; }
165 static inline int Au_ObjFaninId( Au_Obj_t * p, int i ) { assert(i >= 0 && i < (int)p->nFanins && p->Fanins[i]); return Au_Lit2Var(p->Fanins[i]); }
166 static inline int Au_ObjFaninId0( Au_Obj_t * p ) { return Au_ObjFaninId(p, 0); }
167 static inline int Au_ObjFaninId1( Au_Obj_t * p ) { return Au_ObjFaninId(p, 1); }
168 static inline int Au_ObjFaninId2( Au_Obj_t * p ) { return Au_ObjFaninId(p, 2); }
169 static inline Au_Obj_t * Au_ObjFanin( Au_Obj_t * p, int i ) { return Au_NtkObj(Au_ObjNtk(p), Au_ObjFaninId(p, i)); }
170 static inline Au_Obj_t * Au_ObjFanin0( Au_Obj_t * p ) { return Au_ObjFanin( p, 0 ); }
171 static inline Au_Obj_t * Au_ObjFanin1( Au_Obj_t * p ) { return Au_ObjFanin( p, 1 ); }
172 static inline Au_Obj_t * Au_ObjFanin2( Au_Obj_t * p ) { return Au_ObjFanin( p, 2 ); }
173 static inline int Au_ObjFaninC( Au_Obj_t * p, int i ) { assert(i >= 0 && i < (int)p->nFanins && p->Fanins[i]); return Au_LitIsCompl(p->Fanins[i]); }
174 static inline int Au_ObjFaninC0( Au_Obj_t * p ) { return Au_ObjFaninC(p, 0); }
175 static inline int Au_ObjFaninC1( Au_Obj_t * p ) { return Au_ObjFaninC(p, 1); }
176 static inline int Au_ObjFaninC2( Au_Obj_t * p ) { return Au_ObjFaninC(p, 2); }
177 static inline int Au_ObjFaninLit( Au_Obj_t * p, int i ) { assert(i >= 0 && i < (int)p->nFanins && p->Fanins[i]); return p->Fanins[i]; }
178 static inline void Au_ObjSetFanin( Au_Obj_t * p, int i, int f ) { assert(f > 0 && p->Fanins[i] == 0); p->Fanins[i] = Au_Var2Lit(f,0); }
179 static inline void Au_ObjSetFaninLit( Au_Obj_t * p, int i, int f){ assert(f >= 0 && p->Fanins[i] == 0); p->Fanins[i] = f; }
180 
181 static inline int Au_BoxFanoutNum( Au_Obj_t * p ) { assert(Au_ObjIsBox(p)); return p->Fanins[p->nFanins]; }
182 static inline int Au_BoxFanoutId( Au_Obj_t * p, int i ) { assert(i >= 0 && i < Au_BoxFanoutNum(p)); return p->Fanins[p->nFanins+1+i]; }
183 static inline Au_Obj_t * Au_BoxFanout( Au_Obj_t * p, int i ) { return Au_NtkObj(Au_ObjNtk(p), Au_BoxFanoutId(p, i)); }
184 
185 static inline int Au_ObjCopy( Au_Obj_t * p ) { return Vec_IntEntry( &Au_ObjNtk(p)->vCopies, Au_ObjId(p) ); }
186 static inline void Au_ObjSetCopy( Au_Obj_t * p, int c ) { Vec_IntWriteEntry( &Au_ObjNtk(p)->vCopies, Au_ObjId(p), c ); }
187 
188 static inline int Au_ObjFanout( Au_Obj_t * p, int i ) { assert(p->Type == AU_OBJ_BOX && i >= 0 && i < p->Fanins[p->nFanins] && p->Fanins[i]); return p->Fanins[p->nFanins + 1 + i]; }
189 static inline void Au_ObjSetFanout( Au_Obj_t * p, int i, int f ) { assert(p->Type == AU_OBJ_BOX && i >= 0 && i < p->Fanins[p->nFanins] && p->Fanins[i] == 0 && f > 0); p->Fanins[p->nFanins + 1 + i] = f; }
190 
191 static inline void Au_NtkIncrementTravId( Au_Ntk_t * p ) { if (p->vTravIds.pArray == NULL) Vec_IntFill(&p->vTravIds, Au_NtkObjNumMax(p)+500, 0); p->nTravIds++; assert(p->nTravIds < (1<<30)); }
192 static inline void Au_ObjSetTravIdCurrent( Au_Obj_t * p ) { Vec_IntSetEntry(&Au_ObjNtk(p)->vTravIds, Au_ObjId(p), Au_ObjNtk(p)->nTravIds ); }
193 static inline void Au_ObjSetTravIdPrevious( Au_Obj_t * p ) { Vec_IntSetEntry(&Au_ObjNtk(p)->vTravIds, Au_ObjId(p), Au_ObjNtk(p)->nTravIds-1 ); }
194 static inline int Au_ObjIsTravIdCurrent( Au_Obj_t * p ) { return (Vec_IntGetEntry(&Au_ObjNtk(p)->vTravIds, Au_ObjId(p)) == Au_ObjNtk(p)->nTravIds); }
195 static inline int Au_ObjIsTravIdPrevious( Au_Obj_t * p ) { return (Vec_IntGetEntry(&Au_ObjNtk(p)->vTravIds, Au_ObjId(p)) == Au_ObjNtk(p)->nTravIds-1); }
196 static inline void Au_ObjSetTravIdCurrentId( Au_Ntk_t * p, int Id ) { Vec_IntSetEntry(&p->vTravIds, Id, p->nTravIds ); }
197 static inline int Au_ObjIsTravIdCurrentId( Au_Ntk_t * p, int Id ) { return (Vec_IntGetEntry(&p->vTravIds, Id) == p->nTravIds); }
198 
199 #define Au_ManForEachNtk( p, pNtk, i ) \
200  for ( i = 1; (i < Vec_PtrSize(&p->vNtks)) && (((pNtk) = Au_ManNtk(p, i)), 1); i++ )
201 #define Au_ManForEachNtkReverse( p, pNtk, i ) \
202  for ( i = Vec_PtrSize(&p->vNtks) - 1;(i>=1) && (((pNtk) = Au_ManNtk(p, i)), 1); i-- )
203 
204 #define Au_ObjForEachFaninId( pObj, hFanin, i ) \
205  for ( i = 0; (i < Au_ObjFaninNum(pObj)) && (((hFanin) = Au_ObjFaninId(pObj, i)), 1); i++ )
206 #define Au_BoxForEachFanoutId( pObj, hFanout, i) \
207  for ( i = 0; (i < Au_BoxFanoutNum(pObj)) && (((hFanout) = Au_BoxFanoutId(pObj, i)), 1); i++ )
208 
209 #define Au_ObjForEachFanin( pObj, pFanin, i ) \
210  for ( i = 0; (i < Au_ObjFaninNum(pObj)) && (((pFanin) = Au_ObjFanin(pObj, i)), 1); i++ )
211 #define Au_BoxForEachFanout( pObj, pFanout, i) \
212  for ( i = 0; (i < Au_BoxFanoutNum(pObj)) && (((pFanout) = Au_BoxFanout(pObj, i)), 1); i++ )
213 
214 #define Au_NtkForEachPi( p, pObj, i ) \
215  for ( i = 0; (i < Vec_IntSize(&p->vPis)) && (((pObj) = Au_NtkPi(p, i)), 1); i++ )
216 #define Au_NtkForEachPo( p, pObj, i ) \
217  for ( i = 0; (i < Vec_IntSize(&p->vPos)) && (((pObj) = Au_NtkPo(p, i)), 1); i++ )
218 #define Au_NtkForEachObj( p, pObj, i ) \
219  for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ )
220 #define Au_NtkForEachNode( p, pObj, i ) \
221  for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ ) if ( !Au_ObjIsNode(pObj) ) {} else
222 #define Au_NtkForEachBox( p, pObj, i ) \
223  for ( i = 0; (i < Vec_IntSize(&p->vObjs)) && (((pObj) = Au_NtkObjI(p, i)), 1); i++ ) if ( !Au_ObjIsBox(pObj) ) {} else
224 
225 
226 
227 extern void Au_ManAddNtk( Au_Man_t * pMan, Au_Ntk_t * p );
228 extern void Au_ManFree( Au_Man_t * p );
229 
230 ////////////////////////////////////////////////////////////////////////
231 /// FUNCTION DEFINITIONS ///
232 ////////////////////////////////////////////////////////////////////////
233 
234 /**Function*************************************************************
235 
236  Synopsis [Working with models.]
237 
238  Description []
239 
240  SideEffects []
241 
242  SeeAlso []
243 
244 ***********************************************************************/
245 Au_Ntk_t * Au_NtkAlloc( Au_Man_t * pMan, char * pName )
246 {
247  Au_Ntk_t * p;
248  p = ABC_CALLOC( Au_Ntk_t, 1 );
249  p->pName = Au_UtilStrsav( pName );
250  p->vChunks = Vec_PtrAlloc( 111 );
251  Vec_IntGrow( &p->vPis, 111 );
252  Vec_IntGrow( &p->vPos, 111 );
253  Vec_IntGrow( &p->vObjs, 1111 );
254  Vec_PtrGrow( &p->vPages, 11 );
255  Au_ManAddNtk( pMan, p );
256  return p;
257 }
259 {
260  Au_ManFree( p->pMan );
261  Vec_PtrFreeFree( p->vChunks );
262  ABC_FREE( p->vCopies.pArray );
263  ABC_FREE( p->vPages.pArray );
264  ABC_FREE( p->vObjs.pArray );
265  ABC_FREE( p->vPis.pArray );
266  ABC_FREE( p->vPos.pArray );
267  ABC_FREE( p->pHTable );
268  ABC_FREE( p->pName );
269  ABC_FREE( p );
270 }
272 {
273  int Mem = sizeof(Au_Ntk_t);
274  Mem += 4 * p->vPis.nCap;
275  Mem += 4 * p->vPos.nCap;
276  Mem += 4 * p->vObjs.nCap;
277  Mem += 16 * p->nObjsAlloc;
278  return Mem;
279 }
281 {
282  printf( "%-30s:", Au_NtkName(p) );
283  printf( " i/o =%6d/%6d", Au_NtkPiNum(p), Au_NtkPoNum(p) );
284  if ( Au_NtkFlopNum(p) )
285  printf( " lat =%5d", Au_NtkFlopNum(p) );
286  printf( " nd =%6d", Au_NtkNodeNum(p) );
287 // if ( Au_NtkBoxNum(p) )
288  printf( " box =%5d", Au_NtkBoxNum(p) );
289  printf( " obj =%7d", Au_NtkObjNum(p) );
290 // printf( " max =%7d", Au_NtkObjNumMax(p) );
291 // printf( " use =%7d", p->nObjsUsed );
292  printf( " %5.1f %%", 100.0 * (Au_NtkObjNumMax(p) - Au_NtkObjNum(p)) / Au_NtkObjNumMax(p) );
293  printf( " %6.1f MB", 1.0 * Au_NtkMemUsage(p) / (1 << 20) );
294  printf( " %5.1f %%", 100.0 * (p->nObjsAlloc - p->nObjsUsed) / p->nObjsAlloc );
295  printf( "\n" );
296 }
298 {
299  Vec_IntFill( &p->vCopies, Au_NtkObjNumMax(p), -1 );
300 }
301 int Au_NtkNodeNumFunc( Au_Ntk_t * p, int Func )
302 {
303  Au_Obj_t * pObj;
304  int i, Counter = 0;
305  if ( p->pMan && p->pMan->pFuncs )
306  return 0;
307  Au_NtkForEachNode( p, pObj, i )
308  {
309  Counter += (pObj->Func == (unsigned)Func);
310 // printf( "%d ", pObj->Func );
311  }
312 // printf( "\n" );
313  return Counter;
314 }
315 
316 /**Function*************************************************************
317 
318  Synopsis [Working with manager.]
319 
320  Description []
321 
322  SideEffects []
323 
324  SeeAlso []
325 
326 ***********************************************************************/
327 Au_Man_t * Au_ManAlloc( char * pName )
328 {
329  Au_Man_t * p;
330  p = ABC_CALLOC( Au_Man_t, 1 );
331  p->pName = Au_UtilStrsav( pName );
332  Vec_PtrGrow( &p->vNtks, 111 );
333  Vec_PtrPush( &p->vNtks, NULL );
334  return p;
335 }
337 {
338  assert( p->nRefs > 0 );
339  if ( --p->nRefs > 0 )
340  return;
341  if ( p->pFuncs )
342  Abc_NamStop( p->pFuncs );
343  ABC_FREE( p->vNtks.pArray );
344  ABC_FREE( p->pName );
345  ABC_FREE( p );
346 }
348 {
349  Au_Ntk_t * pNtk;
350  int i;
351  Au_ManForEachNtk( p, pNtk, i )
352  Au_NtkFree( pNtk );
353 }
354 int Au_ManFindNtk( Au_Man_t * p, char * pName )
355 {
356  Au_Ntk_t * pNtk;
357  int i;
358  Au_ManForEachNtk( p, pNtk, i )
359  if ( !strcmp(Au_NtkName(pNtk), pName) )
360  return i;
361  return -1;
362 }
363 Au_Ntk_t * Au_ManFindNtkP( Au_Man_t * p, char * pName )
364 {
365  int iNtk = Au_ManFindNtk( p, pName );
366  if ( iNtk == -1 )
367  return NULL;
368  return Au_ManNtk( p, iNtk );
369 }
370 void Au_ManAddNtk( Au_Man_t * pMan, Au_Ntk_t * p )
371 {
372  assert( Au_ManFindNtk(pMan, Au_NtkName(p)) == -1 );
373  p->pMan = pMan; pMan->nRefs++;
374  p->Id = Vec_PtrSize( &pMan->vNtks );
375  Vec_PtrPush( &pMan->vNtks, p );
376 }
378 {
379  Au_Ntk_t * pNtk;
380  int i, Mem = 0;
381  Au_ManForEachNtk( p, pNtk, i )
382  Mem += 16 * pNtk->nObjsAlloc;
383  return Mem;
384 }
386 {
387  Au_Ntk_t * pNtk;
388  int i, Mem = 0;
389  Au_ManForEachNtk( p, pNtk, i )
390  Mem += 16 * pNtk->nObjsUsed;
391  return Mem;
392 }
394 {
395  Au_Ntk_t * pNtk;
396  int i;
397  if ( Vec_PtrSize(&p->vNtks) > 2 )
398  printf( "Design %-13s\n", Au_ManName(p) );
399  Au_ManForEachNtk( p, pNtk, i )
400  Au_NtkPrintStats( pNtk );
401  printf( "Different functions = %d. ", p->pFuncs ? Abc_NamObjNumMax(p->pFuncs) : 0 );
402  printf( "Memory = %.1f MB", 1.0 * Au_ManMemUsage(p) / (1 << 20) );
403  printf( " %5.1f %%", 100.0 * (Au_ManMemUsage(p) - Au_ManMemUsageUseful(p)) / Au_ManMemUsage(p) );
404  printf( "\n" );
405 // if ( p->pFuncs )
406 // Abc_NamPrint( p->pFuncs );
407 }
408 
410 {
411  Au_Ntk_t * pBoxModel;
412  Au_Obj_t * pObj;
413  int k;
414  if ( pNtk->fMark )
415  return;
416  pNtk->fMark = 1;
417  Au_NtkForEachBox( pNtk, pObj, k )
418  {
419  pBoxModel = Au_ObjModel(pObj);
420  if ( pBoxModel == NULL || pBoxModel == pNtk )
421  continue;
422  Au_ManReorderModels_rec( pBoxModel, vOrder );
423  }
424  Vec_IntPush( vOrder, pNtk->Id );
425 }
427 {
428  Vec_Ptr_t * vNtksNew;
429  Vec_Int_t * vOrder, * vTemp;
430  Au_Ntk_t * pNtk, * pBoxModel;
431  Au_Obj_t * pBox, * pFan;
432  int i, k, j, Entry;
433  Au_ManForEachNtk( p, pNtk, i )
434  pNtk->fMark = 0;
435  // collect networks in the DFS order
436  vOrder = Vec_IntAlloc( Au_ManNtkNum(p)+1 );
437  Vec_IntPush( vOrder, 0 );
438  Au_ManReorderModels_rec( pRoot, vOrder );
439  assert( Vec_IntEntryLast(vOrder) == pRoot->Id );
440  // add unconnected ones
441  Vec_IntPop( vOrder );
442  Au_ManForEachNtk( p, pNtk, i )
443  if ( pNtk->fMark == 0 )
444  Vec_IntPush( vOrder, pNtk->Id );
445  Vec_IntPush( vOrder, pRoot->Id );
446  assert( Vec_IntSize(vOrder) == Au_ManNtkNum(p)+1 );
447  // reverse order
448  vOrder->nSize--;
449  vOrder->pArray++;
450  Vec_IntReverseOrder( vOrder );
451  vOrder->pArray--;
452  vOrder->nSize++;
453  // compute new order
454  vNtksNew = Vec_PtrAlloc( Au_ManNtkNum(p)+1 );
455  Vec_IntForEachEntry( vOrder, Entry, i )
456  Vec_PtrPush( vNtksNew, Au_ManNtk(p, Entry) );
457  // invert order
458  assert( Vec_IntEntry(vOrder, 1) == pRoot->Id );
459  vOrder = Vec_IntInvert( vTemp = vOrder, 0 );
460  Vec_IntFree( vTemp );
461  assert( Vec_IntEntry(vOrder, 1) == pRoot->Id );
462  // update model numbers
463  Au_ManForEachNtk( p, pNtk, i )
464  {
465  pNtk->Id = Vec_IntEntry( vOrder, pNtk->Id );
466  Au_NtkForEachBox( pNtk, pBox, k )
467  {
468  pBox->Func = Vec_IntEntry( vOrder, pBox->Func );
469  assert( pBox->Func > 0 );
470  Au_BoxForEachFanout( pBox, pFan, j )
471  pFan->Func = pBox->Func;
472  }
473  }
474  // update
475  ABC_FREE( p->vNtks.pArray );
476  p->vNtks.pArray = vNtksNew->pArray;
477  vNtksNew->pArray = NULL;
478  Vec_PtrFree( vNtksNew );
479  // verify
480  Au_ManForEachNtk( p, pNtk, i )
481  Au_NtkForEachBox( pNtk, pBox, k )
482  {
483  pBoxModel = Au_ObjModel(pBox);
484  if ( pBoxModel == NULL || pBoxModel == pNtk )
485  continue;
486  assert( !pBox->Func || pBox->Func >= (unsigned)pNtk->Id );
487  assert( Au_ObjFaninNum(pBox) == Au_NtkPiNum(pBoxModel) );
488  assert( Au_BoxFanoutNum(pBox) == Au_NtkPoNum(pBoxModel) );
489  }
490  Vec_IntFree( vOrder );
491 }
493 {
494  Au_Ntk_t * pNtk, * pBoxModel;
495  Au_Obj_t * pBox;
496  int i, k;//, clk = Abc_Clock();
497  Au_ManForEachNtkReverse( p, pNtk, i )
498  {
499  pNtk->nBoxes = Au_NtkBoxNum(pNtk);
500  pNtk->nNodes = Au_NtkNodeNum(pNtk);
501  pNtk->nPorts = Au_NtkPiNum(pNtk) + Au_NtkPoNum(pNtk);
502  pNtk->nNodeAnds = Au_NtkNodeNumFunc( pNtk, 1 );
503  pNtk->nNodeXors = Au_NtkNodeNumFunc( pNtk, 2 );
504  pNtk->nNodeMuxs = Au_NtkNodeNumFunc( pNtk, 3 );
505 // assert( pNtk->nNodes == pNtk->nNodeAnds + pNtk->nNodeXors + pNtk->nNodeMuxs );
506 // printf( "adding %.0f nodes of model %s\n", pNtk->nNodes, Au_NtkName(pNtk) );
507  Au_NtkForEachBox( pNtk, pBox, k )
508  {
509  pBoxModel = Au_ObjModel(pBox);
510  if ( pBoxModel == NULL || pBoxModel == pNtk )
511  continue;
512  assert( Au_ObjFaninNum(pBox) == Au_NtkPiNum(pBoxModel) );
513  assert( Au_BoxFanoutNum(pBox) == Au_NtkPoNum(pBoxModel) );
514  assert( pBoxModel->Id > pNtk->Id );
515  assert( pBoxModel->nPorts > 0 );
516  pNtk->nBoxes += pBoxModel->nBoxes;
517  pNtk->nNodes += pBoxModel->nNodes;
518  pNtk->nPorts += pBoxModel->nPorts;
519  pNtk->nNodeAnds += pBoxModel->nNodeAnds;
520  pNtk->nNodeXors += pBoxModel->nNodeXors;
521  pNtk->nNodeMuxs += pBoxModel->nNodeMuxs;
522 // printf( " adding %.0f nodes of model %s\n", pBoxModel->nNodes, Au_NtkName(pBoxModel) );
523  }
524 // printf( "total %.0f nodes in model %s\n", pNtk->nNodes, Au_NtkName(pNtk) );
525  }
526  pNtk = Au_ManNtkRoot(p);
527  printf( "Total nodes = %15.0f. Total instances = %15.0f. Total ports = %15.0f.\n",
528 // printf( "Total nodes = %.2e. Total instances = %.2e. Total ports = %.2e.\n",
529  pNtk->nNodes, pNtk->nBoxes, pNtk->nPorts );
530 // printf( "Total ANDs = %15.0f. Total XORs = %15.0f. Total MUXes = %15.0f.\n",
531 // printf( "Total ANDs = %.2e. Total XORs = %.2e. Total MUXes = %.2e. ",
532 // pNtk->nNodeAnds, pNtk->nNodeXors, pNtk->nNodeMuxs );
533  printf( "Total ANDs = %15.0f.\n", pNtk->nNodeAnds );
534  printf( "Total XORs = %15.0f.\n", pNtk->nNodeXors );
535  printf( "Total MUXes = %15.0f.\n", pNtk->nNodeMuxs );
536 // Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
537 }
538 
540 {
541  return strcmp( Au_NtkName(*p1), Au_NtkName(*p2) );
542 }
544 {
545  Vec_Ptr_t * vMods;
546  Au_Ntk_t * pModel, * pBoxModel;
547  Au_Obj_t * pObj;
548  Vec_Int_t * vCounts;
549  int i, k, Num;
550  if ( pNtk->pMan == NULL )
551  {
552  printf( "There is no hierarchy information.\n" );
553  return;
554  }
555  vMods = &pNtk->pMan->vNtks;
556 
557 /*
558  vMods->nSize--;
559  vMods->pArray++;
560  // sort models by name
561  Vec_PtrSort( vMods, (int(*)())Au_NtkCompareNames );
562  // swap the first model
563  Num = Vec_PtrFind( vMods, pNtk );
564  assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
565  pBoxModel = (Au_Ntk_t *)Vec_PtrEntry(vMods, 0);
566  Vec_PtrWriteEntry(vMods, 0, (Au_Ntk_t *)Vec_PtrEntry(vMods, Num) );
567  Vec_PtrWriteEntry(vMods, Num, pBoxModel );
568  vMods->pArray--;
569  vMods->nSize++;
570 */
571 
572 // Vec_PtrForEachEntry( Au_Ntk_t *, vMods, pModel, i )
573 // printf( "%s\n", Au_NtkName(pModel) );
574 
575  // print models
576  vCounts = Vec_IntStart( Vec_PtrSize(vMods) );
577  Vec_PtrForEachEntryStart( Au_Ntk_t *, vMods, pModel, i, 1 )
578  {
579  if ( Au_NtkBoxNum(pModel) == 0 )
580  continue;
581  Vec_IntFill( vCounts, Vec_IntSize(vCounts), 0 );
582  Au_NtkForEachBox( pModel, pObj, k )
583  {
584  pBoxModel = Au_ObjModel(pObj);
585  if ( pBoxModel == NULL || pBoxModel == pModel )
586  continue;
587  Num = Vec_PtrFind( vMods, pBoxModel );
588  assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
589  Vec_IntAddToEntry( vCounts, Num, 1 );
590  }
591 
592 // Au_NtkPrintStats( pModel, 0, 0, 0, 0, 0, 0, 0 );
593  printf( "MODULE " );
594  printf( "%-30s : ", Au_NtkName(pModel) );
595  printf( "PI=%6d ", Au_NtkPiNum(pModel) );
596  printf( "PO=%6d ", Au_NtkPoNum(pModel) );
597  printf( "BB=%6d ", Au_NtkBoxNum(pModel) );
598  printf( "ND=%6d ", Au_NtkNodeNum(pModel) ); // sans constants
599 // printf( "Lev=%5d ", Au_NtkLevel(pModel) );
600  printf( "\n" );
601 
602  Vec_IntForEachEntry( vCounts, Num, k )
603  if ( Num )
604  printf( "%15d : %s\n", Num, Au_NtkName((Au_Ntk_t *)Vec_PtrEntry(vMods, k)) );
605  }
606  Vec_IntFree( vCounts );
607  Vec_PtrForEachEntryStart( Au_Ntk_t *, vMods, pModel, i, 1 )
608  {
609  if ( Au_NtkBoxNum(pModel) != 0 )
610  continue;
611  printf( "MODULE " );
612  printf( "%-30s : ", Au_NtkName(pModel) );
613  printf( "PI=%6d ", Au_NtkPiNum(pModel) );
614  printf( "PO=%6d ", Au_NtkPoNum(pModel) );
615  printf( "BB=%6d ", Au_NtkBoxNum(pModel) );
616  printf( "ND=%6d ", Au_NtkNodeNum(pModel) );
617 // printf( "Lev=%5d ", Au_NtkLevel(pModel) );
618  printf( "\n" );
619  }
620 }
622 {
623  if ( Au_NtkPiNum(*p1) - Au_NtkPiNum(*p2) != 0 )
624  return Au_NtkPiNum(*p1) - Au_NtkPiNum(*p2);
625  else
626  return Au_NtkPoNum(*p1) - Au_NtkPoNum(*p2);
627 }
629 {
630  Vec_Ptr_t * vMods, * vModsNew;
631  Au_Ntk_t * pModel;
632  int i;
633  if ( pNtk->pMan == NULL )
634  {
635  printf( "There is no hierarchy information.\n" );
636  return;
637  }
638  vMods = &pNtk->pMan->vNtks;
639 
640  vMods->nSize--;
641  vMods->pArray++;
642  vModsNew = Vec_PtrDup( vMods );
643  vMods->pArray--;
644  vMods->nSize++;
645 
646  Vec_PtrSort( vModsNew, (int(*)())Au_NtkCompareSign );
647  Vec_PtrForEachEntryStart( Au_Ntk_t *, vModsNew, pModel, i, 1 )
648  {
649  printf( "MODULE " );
650  printf( "%-30s : ", Au_NtkName(pModel) );
651  printf( "PI=%6d ", Au_NtkPiNum(pModel) );
652  printf( "PO=%6d ", Au_NtkPoNum(pModel) );
653  printf( "BB=%6d ", Au_NtkBoxNum(pModel) );
654  printf( "ND=%6d ", Au_NtkNodeNum(pModel) );
655  printf( "\n" );
656  }
657  Vec_PtrFree( vModsNew );
658 }
659 
661 {
662  Vec_Ptr_t * vMods;
663  Au_Ntk_t * pModel;
664  Au_Obj_t * pObj;
665  int i, k, RetValue = 0;
666 
667  if ( pNtk->pMan == NULL )
668  {
669  printf( "There is no hierarchy information.\n" );
670  return RetValue;
671  }
672 
673  vMods = &pNtk->pMan->vNtks;
674  Vec_PtrForEachEntryStart( Au_Ntk_t *, vMods, pModel, i, 1 )
675  {
676  Au_NtkForEachObj( pModel, pObj, k )
677  if ( Au_ObjIsBox(pObj) && Au_ObjModel(pObj) == pModel )
678  {
679  printf( "WARNING: Model \"%s\" contains a recursive defition.\n", Au_NtkName(pModel) );
680  RetValue = 1;
681  break;
682  }
683  }
684  return RetValue;
685 }
686 
687 // count the number of support variables
688 int Au_ObjSuppSize_rec( Au_Ntk_t * p, int Id )
689 {
690  Au_Obj_t * pObj;
691  int i, iFanin, Counter = 0;
692  if ( Au_ObjIsTravIdCurrentId(p, Id) )
693  return 0;
695  pObj = Au_NtkObj( p, Id );
696  if ( Au_ObjIsPi(pObj) )
697  return 1;
698  assert( Au_ObjIsNode(pObj) || Au_ObjIsBox(pObj) || Au_ObjIsFan(pObj) );
699  Au_ObjForEachFaninId( pObj, iFanin, i )
700  Counter += Au_ObjSuppSize_rec( p, iFanin );
701  return Counter;
702 }
704 {
705  Au_Ntk_t * p = Au_ObjNtk(pObj);
707  return Au_ObjSuppSize_rec( p, Au_ObjId(pObj) );
708 }
709 /*
710 // this version is 50% slower than above
711 int Au_ObjSuppSize_rec( Au_Obj_t * pObj )
712 {
713  Au_Obj_t * pFanin;
714  int i, Counter = 0;
715  if ( Au_ObjIsTravIdCurrent(pObj) )
716  return 0;
717  Au_ObjSetTravIdCurrent(pObj);
718  if ( Au_ObjIsPi(pObj) )
719  return 1;
720  assert( Au_ObjIsNode(pObj) || Au_ObjIsBox(pObj) || Au_ObjIsFan(pObj) );
721  Au_ObjForEachFanin( pObj, pFanin, i )
722  Counter += Au_ObjSuppSize_rec( pFanin );
723  return Counter;
724 }
725 int Au_ObjSuppSize( Au_Obj_t * pObj )
726 {
727  Au_NtkIncrementTravId( Au_ObjNtk(pObj) );
728  return Au_ObjSuppSize_rec( pObj );
729 }
730 */
732 {
733  Au_Obj_t * pObj;
734  int i, Counter = 0;
735  Au_NtkForEachObj( p, pObj, i )
736  if ( Au_ObjIsNode(pObj) )
737  Counter += (Au_ObjSuppSize(pObj) <= 16);
738  printf( "Nodes with small support %d (out of %d)\n", Counter, Au_NtkNodeNum(p) );
739  return Counter;
740 }
741 
742 /**Function*************************************************************
743 
744  Synopsis [Returns memory for the next object.]
745 
746  Description []
747 
748  SideEffects []
749 
750  SeeAlso []
751 
752 ***********************************************************************/
753 static inline void Au_NtkInsertHeader( Au_Ntk_t * p )
754 {
755  Au_Obj_t * pMem = (Au_Obj_t *)Vec_PtrEntryLast( &p->vPages );
756  assert( (((ABC_PTRINT_T)(pMem + p->iHandle) & 0x3FF) >> 4) == 0 );
757  ((Au_Ntk_t **)(pMem + p->iHandle))[0] = p;
758  ((int *)(pMem + p->iHandle))[2] = ((Vec_PtrSize(&p->vPages) - 1) << 12) | (p->iHandle & 0xFC0);
759  p->iHandle++;
760 }
761 int Au_NtkAllocObj( Au_Ntk_t * p, int nFanins, int Type )
762 {
763  Au_Obj_t * pMem, * pObj, * pTemp;
764  int nObjInt = ((2+nFanins) >> 2) + (((2+nFanins) & 3) > 0);
765  int Id, nObjIntReal = nObjInt;
766  if ( nObjInt > 63 )
767  nObjInt = 63 + 64 * (((nObjInt-63) >> 6) + (((nObjInt-63) & 63) > 0));
768  if ( Vec_PtrSize(&p->vPages) == 0 || p->iHandle + nObjInt > (1 << 12) )
769  {
770  if ( nObjInt + 64 > (1 << 12) )
771  pMem = ABC_CALLOC( Au_Obj_t, nObjInt + 64 ), p->nObjsAlloc += nObjInt + 64;
772  else
773  pMem = ABC_CALLOC( Au_Obj_t, (1 << 12) + 64 ), p->nObjsAlloc += (1 << 12) + 64;
774  Vec_PtrPush( p->vChunks, pMem );
775  if ( ((ABC_PTRINT_T)pMem & 0xF) )
776  pMem = (Au_Obj_t *)((char *)pMem + 16 - ((ABC_PTRINT_T)pMem & 0xF));
777  assert( ((ABC_PTRINT_T)pMem & 0xF) == 0 );
778  p->iHandle = (((ABC_PTRINT_T)pMem & 0x3FF) >> 4);
779  if ( p->iHandle )
780  {
781  pMem += 64 - (p->iHandle & 63);
782  p->iHandle = 0;
783  }
784  Vec_PtrPush( &p->vPages, pMem );
785  Au_NtkInsertHeader( p );
786  }
787  else
788  {
789  pMem = (Au_Obj_t *)Vec_PtrEntryLast( &p->vPages );
790  if ( (p->iHandle & 63) == 0 || nObjInt > (64 - (p->iHandle & 63)) )
791  {
792  if ( p->iHandle & 63 )
793  p->iHandle += 64 - (p->iHandle & 63);
794  Au_NtkInsertHeader( p );
795  }
796  if ( p->iHandle + nObjInt > (1 << 12) )
797  return Au_NtkAllocObj( p, nFanins, Type );
798  }
799  pObj = pMem + p->iHandle;
800  assert( *((int *)pObj) == 0 );
801  pObj->nFanins = nFanins;
802  p->nObjs[pObj->Type = Type]++;
803  if ( Type == AU_OBJ_PI )
804  {
805  Au_ObjSetFaninLit( pObj, 0, Vec_IntSize(&p->vPis) );
806  Vec_IntPush( &p->vPis, Au_ObjId(pObj) );
807  }
808  else if ( Type == AU_OBJ_PO )
809  {
810  Au_ObjSetFaninLit( pObj, 1, Vec_IntSize(&p->vPos) );
811  Vec_IntPush( &p->vPos, Au_ObjId(pObj) );
812  }
813  p->iHandle += nObjInt;
814  p->nObjsUsed += nObjIntReal;
815 
816  Id = Au_ObjId(pObj);
817  Vec_IntPush( &p->vObjs, Id );
818  pTemp = Au_NtkObj( p, Id );
819  assert( pTemp == pObj );
820  return Id;
821 }
823 {
824  return Au_NtkAllocObj( pNtk, 0, AU_OBJ_CONST0 );
825 }
827 {
828  return Au_NtkAllocObj( pNtk, 0, AU_OBJ_PI );
829 }
830 int Au_NtkCreatePo( Au_Ntk_t * pNtk, int iFanin )
831 {
832  int Id = Au_NtkAllocObj( pNtk, 1, AU_OBJ_PO );
833  if ( iFanin )
834  Au_ObjSetFaninLit( Au_NtkObj(pNtk, Id), 0, iFanin );
835  return Id;
836 }
837 int Au_NtkCreateFan( Au_Ntk_t * pNtk, int iFanin, int iFanout, int iModel )
838 {
839  int Id = Au_NtkAllocObj( pNtk, 1, AU_OBJ_FAN );
840  Au_Obj_t * p = Au_NtkObj( pNtk, Id );
841  if ( iFanin )
842  Au_ObjSetFaninLit( p, 0, iFanin );
843  Au_ObjSetFaninLit( p, 1, iFanout );
844  p->Func = iModel;
845  return Id;
846 }
847 int Au_NtkCreateNode( Au_Ntk_t * pNtk, Vec_Int_t * vFanins, int iFunc )
848 {
849  int i, iFanin;
850  int Id = Au_NtkAllocObj( pNtk, Vec_IntSize(vFanins), AU_OBJ_NODE );
851  Au_Obj_t * p = Au_NtkObj( pNtk, Id );
852  Vec_IntForEachEntry( vFanins, iFanin, i )
853  Au_ObjSetFaninLit( p, i, iFanin );
854  p->Func = iFunc;
855  return Id;
856 }
857 int Au_NtkCreateBox( Au_Ntk_t * pNtk, Vec_Int_t * vFanins, int nFanouts, int iModel )
858 {
859  int i, iFanin, nFanins = Vec_IntSize(vFanins);
860  int Id = Au_NtkAllocObj( pNtk, nFanins + 1 + nFanouts, AU_OBJ_BOX );
861  Au_Obj_t * p = Au_NtkObj( pNtk, Id );
862  Vec_IntForEachEntry( vFanins, iFanin, i )
863  Au_ObjSetFaninLit( p, i, iFanin );
864  Au_ObjSetFaninLit( p, nFanins, nFanouts );
865  for ( i = 0; i < nFanouts; i++ )
866  Au_ObjSetFaninLit( p, nFanins + 1 + i, Au_NtkCreateFan(pNtk, Au_Var2Lit(Id,0), i, iModel) );
867  p->nFanins = nFanins;
868  p->Func = iModel;
869  assert( iModel > 0 );
870  return Id;
871 }
872 
873 /*
874  * 0/1 would denote false/true respectively.
875  * Signals would be even numbers, and negation would be handled by xor with 1.
876  * The output signal for each gate or subckt could be implicitly generated just use the next signal number.
877  * For ranges, we could use "start:cnt" to denote the sequence "start, start+2, ..., start + 2*(cnt- 1)".
878  - "cnt" seems more intuitive when signals are restricted to even numbers.
879  * We'd have subckts and specialized gates .and, .xor, and .mux.
880 
881 Here is a small example:
882 
883 .model test
884 .inputs 3 # Inputs 2 4 6
885 .subckt and3 3 1 2:3 # 8 is implicit output
886 .outputs 1 8
887 .end
888 
889 .model and3
890 .inputs 3 # Inputs 2 4 6
891 .and 2 4 # 8 output
892 .and 6 8 # 10 output
893 .outputs 1 10
894 .end
895 */
896 
897 /**Function*************************************************************
898 
899  Synopsis [Reads one entry.]
900 
901  Description []
902 
903  SideEffects []
904 
905  SeeAlso []
906 
907 ***********************************************************************/
908 static inline int Au_NtkRemapNum( Vec_Int_t * vNum2Obj, int Num )
909 {
910  return Au_Var2Lit(Vec_IntEntry(vNum2Obj, Au_Lit2Var(Num)), Au_LitIsCompl(Num));
911 }
912 /**Function*************************************************************
913 
914  Synopsis [Reads one entry.]
915 
916  Description []
917 
918  SideEffects []
919 
920  SeeAlso []
921 
922 ***********************************************************************/
923 static inline void Au_NtkParseCBlifNum( Vec_Int_t * vFanins, char * pToken, Vec_Int_t * vNum2Obj )
924 {
925  char * pCur;
926  int Num1, Num2, i;
927  assert( pToken[0] >= '0' && pToken[0] <= '9' );
928  Num1 = atoi( pToken );
929  for ( pCur = pToken; *pCur; pCur++ )
930  if ( *pCur == ':' )
931  {
932  Num2 = atoi( pCur+1 );
933  for ( i = 0; i < Num2; i++ )
934  Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num1 + i + i) );
935  return;
936  }
937  else if ( *pCur == '*' )
938  {
939  Num2 = atoi( pCur+1 );
940  for ( i = 0; i < Num2; i++ )
941  Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num1) );
942  return;
943  }
944  assert( *pCur == 0 );
945  Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num1) );
946 }
947 
948 /**Function*************************************************************
949 
950  Synopsis [Parses CBLIF file.]
951 
952  Description []
953 
954  SideEffects []
955 
956  SeeAlso []
957 
958 ***********************************************************************/
959 Au_Ntk_t * Au_NtkParseCBlif( char * pFileName )
960 {
961  FILE * pFile;
962  Au_Man_t * pMan;
963  Au_Ntk_t * pRoot = NULL;
964  Au_Obj_t * pBox, * pFan;
965  char * pBuffer, * pCur;
966  Vec_Int_t * vLines, * vNum2Obj, * vFanins;
967  int i, k, j, Id, nInputs, nOutputs;
968  int Line, Num, Func;
969  // read the file
970  pFile = fopen( pFileName, "rb" );
971  if ( pFile == NULL )
972  {
973  printf( "Cannot open file \"%s\".\n", pFileName );
974  return NULL;
975  }
976  pBuffer = Extra_FileRead( pFile );
977  fclose( pFile );
978  // split into lines
979  vLines = Vec_IntAlloc( 1000 );
980  Vec_IntPush( vLines, 0 );
981  for ( pCur = pBuffer; *pCur; pCur++ )
982  if ( *pCur == '\n' )
983  {
984  *pCur = 0;
985  Vec_IntPush( vLines, pCur - pBuffer + 1 );
986  }
987  // start the manager
988  pMan = Au_ManAlloc( pFileName );
989  // parse the lines
990  vNum2Obj = Vec_IntAlloc( 1000 );
991  vFanins = Vec_IntAlloc( 1000 );
992  Vec_IntForEachEntry( vLines, Line, i )
993  {
994  pCur = strtok( pBuffer + Line, " \t\r" );
995  if ( pCur == NULL || *pCur == '#' )
996  continue;
997  if ( *pCur != '.' )
998  {
999  printf( "Cannot read directive in line %d: \"%s\".\n", i, pBuffer + Line );
1000  continue;
1001  }
1002  Vec_IntClear( vFanins );
1003  if ( !strcmp(pCur, ".and") )
1004  {
1005  for ( k = 0; k < 2; k++ )
1006  {
1007  pCur = strtok( NULL, " \t\r" );
1008  Num = atoi( pCur );
1009  Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num) );
1010  }
1011  Id = Au_NtkCreateNode( pRoot, vFanins, 1 );
1012  Vec_IntPush( vNum2Obj, Id );
1013  }
1014  else if ( !strcmp(pCur, ".xor") )
1015  {
1016  for ( k = 0; k < 2; k++ )
1017  {
1018  pCur = strtok( NULL, " \t\r" );
1019  Num = atoi( pCur );
1020  Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num) );
1021  }
1022  Id = Au_NtkCreateNode( pRoot, vFanins, 2 );
1023  Vec_IntPush( vNum2Obj, Id );
1024  }
1025  else if ( !strcmp(pCur, ".mux") )
1026  {
1027  for ( k = 0; k < 3; k++ )
1028  {
1029  pCur = strtok( NULL, " \t\r" );
1030  Num = atoi( pCur );
1031  Vec_IntPush( vFanins, Au_NtkRemapNum(vNum2Obj, Num) );
1032  }
1033  Id = Au_NtkCreateNode( pRoot, vFanins, 3 );
1034  Vec_IntPush( vNum2Obj, Id );
1035  }
1036  else if ( !strcmp(pCur, ".subckt") )
1037  {
1038  pCur = strtok( NULL, " \t\r" );
1039  Func = pCur - pBuffer;
1040  pCur = strtok( NULL, " \t\r" );
1041  nInputs = atoi( pCur );
1042  pCur = strtok( NULL, " \t\r" );
1043  nOutputs = atoi( pCur );
1044  while ( 1 )
1045  {
1046  pCur = strtok( NULL, " \t\r" );
1047  if ( pCur == NULL || *pCur == '#' )
1048  break;
1049  Au_NtkParseCBlifNum( vFanins, pCur, vNum2Obj );
1050  }
1051  assert( Vec_IntSize(vFanins) == nInputs );
1052  Id = Au_NtkCreateBox( pRoot, vFanins, nOutputs, Func );
1053  pBox = Au_NtkObj( pRoot, Id );
1054  Au_BoxForEachFanoutId( pBox, Num, k )
1055  Vec_IntPush( vNum2Obj, Num );
1056  }
1057  else if ( !strcmp(pCur, ".model") )
1058  {
1059  pCur = strtok( NULL, " \t\r" );
1060  pRoot = Au_NtkAlloc( pMan, pCur );
1061  Id = Au_NtkCreateConst0( pRoot );
1062  Vec_IntClear( vNum2Obj );
1063  Vec_IntPush( vNum2Obj, Id );
1064  }
1065  else if ( !strcmp(pCur, ".inputs") )
1066  {
1067  pCur = strtok( NULL, " \t\r" );
1068  Num = atoi( pCur );
1069  for ( k = 0; k < Num; k++ )
1070  Vec_IntPush( vNum2Obj, Au_NtkCreatePi(pRoot) );
1071  }
1072  else if ( !strcmp(pCur, ".outputs") )
1073  {
1074  pCur = strtok( NULL, " \t\r" );
1075  nOutputs = atoi( pCur );
1076  while ( 1 )
1077  {
1078  pCur = strtok( NULL, " \t\r" );
1079  if ( pCur == NULL || *pCur == '#' )
1080  break;
1081  Au_NtkParseCBlifNum( vFanins, pCur, vNum2Obj );
1082  }
1083  assert( Vec_IntSize(vFanins) == nOutputs );
1084  Vec_IntForEachEntry( vFanins, Num, k )
1085  Au_NtkCreatePo( pRoot, Num );
1086  }
1087  else if ( strcmp(pCur, ".end") )
1088  printf( "Unknown directive in line %d: \"%s\".\n", i, pBuffer + Line );
1089  }
1090  Vec_IntFree( vFanins );
1091  Vec_IntFree( vNum2Obj );
1092  Vec_IntFree( vLines );
1093  // set pointers to models
1094  Au_ManForEachNtk( pMan, pRoot, i )
1095  Au_NtkForEachBox( pRoot, pBox, k )
1096  {
1097  pBox->Func = Au_ManFindNtk( pMan, pBuffer + pBox->Func );
1098  assert( pBox->Func > 0 );
1099  Au_BoxForEachFanout( pBox, pFan, j )
1100  pFan->Func = pBox->Func;
1101  }
1102  ABC_FREE( pBuffer );
1103  // order models in topological order
1104  pRoot = Au_ManNtkRoot( pMan );
1105  Au_ManReorderModels( pMan, pRoot );
1106  return pRoot;
1107 }
1108 
1110 
1111 #include "abc.h"
1112 #include "aig/gia/gia.h"
1113 
1115 
1116 extern Vec_Ptr_t * Abc_NtkDfsBoxes( Abc_Ntk_t * pNtk );
1117 extern int Abc_NtkDeriveFlatGiaSop( Gia_Man_t * pGia, int * gFanins, char * pSop );
1118 extern int Abc_NtkCheckRecursive( Abc_Ntk_t * pNtk );
1119 
1120 /**Function*************************************************************
1121 
1122  Synopsis [Flattens the logic hierarchy of the netlist.]
1123 
1124  Description []
1125 
1126  SideEffects []
1127 
1128  SeeAlso []
1129 
1130 ***********************************************************************/
1132 {
1133  Au_Obj_t * pObj, * pTerm;
1134  int i, k, Lit;
1135  Au_NtkForEachPi( p, pTerm, i )
1136  assert( Au_ObjCopy(pTerm) >= 0 );
1137  if ( strcmp(Au_NtkName(p), "ref_egcd") == 0 )
1138  {
1139  printf( "Replacing one instance of recursive model \"%s\" by a black box.\n", "ref_egcd" );
1140  Au_NtkForEachPo( p, pTerm, i )
1141  Au_ObjSetCopy( pTerm, Gia_ManAppendCi(pGia) );
1142  return;
1143  }
1144  Au_NtkForEachObj( p, pObj, i )
1145  {
1146  if ( Au_ObjIsNode(pObj) )
1147  {
1148  if ( p->pMan->pFuncs )
1149  {
1150  int gFanins[16];
1151  char * pSop = Abc_NamStr( p->pMan->pFuncs, pObj->Func );
1152  assert( Au_ObjFaninNum(pObj) <= 16 );
1153  assert( Au_ObjFaninNum(pObj) == Abc_SopGetVarNum(pSop) );
1154  Au_ObjForEachFanin( pObj, pTerm, k )
1155  {
1156  gFanins[k] = Au_ObjCopy(pTerm);
1157  assert( gFanins[k] >= 0 );
1158  }
1159  Lit = Abc_NtkDeriveFlatGiaSop( pGia, gFanins, pSop );
1160  }
1161  else
1162  {
1163  int Lit0, Lit1, Lit2;
1164  assert( pObj->Func >= 1 && pObj->Func <= 3 );
1165  Lit0 = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin0(pObj)), Au_ObjFaninC0(pObj) );
1166  Lit1 = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin1(pObj)), Au_ObjFaninC1(pObj) );
1167  if ( pObj->Func == 1 )
1168  Lit = Gia_ManHashAnd( pGia, Lit0, Lit1 );
1169  else if ( pObj->Func == 2 )
1170  Lit = Gia_ManHashXor( pGia, Lit0, Lit1 );
1171  else if ( pObj->Func == 3 )
1172  {
1173  Lit2 = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin2(pObj)), Au_ObjFaninC2(pObj) );
1174  Lit = Gia_ManHashMux( pGia, Lit0, Lit1, Lit2 );
1175  }
1176  else assert( 0 );
1177  }
1178  assert( Lit >= 0 );
1179  Au_ObjSetCopy( pObj, Lit );
1180  }
1181  else if ( Au_ObjIsBox(pObj) )
1182  {
1183  Au_Ntk_t * pModel = Au_ObjModel(pObj);
1184  Au_NtkCleanCopy( pModel );
1185  // check the match between the number of actual and formal parameters
1186  assert( Au_ObjFaninNum(pObj) == Au_NtkPiNum(pModel) );
1187  assert( Au_BoxFanoutNum(pObj) == Au_NtkPoNum(pModel) );
1188  // assign PIs
1189  Au_ObjForEachFanin( pObj, pTerm, k )
1190  Au_ObjSetCopy( Au_NtkPi(pModel, k), Au_ObjCopy(pTerm) );
1191  // call recursively
1192  Au_NtkDeriveFlatGia_rec( pGia, pModel );
1193  // assign POs
1194  Au_BoxForEachFanout( pObj, pTerm, k )
1195  Au_ObjSetCopy( pTerm, Au_ObjCopy(Au_NtkPo(pModel, k)) );
1196  }
1197  else if ( Au_ObjIsConst0(pObj) )
1198  Au_ObjSetCopy( pObj, 0 );
1199 
1200  }
1201  Au_NtkForEachPo( p, pTerm, i )
1202  {
1203  Lit = Abc_LitNotCond( Au_ObjCopy(Au_ObjFanin0(pTerm)), Au_ObjFaninC0(pTerm) );
1204  Au_ObjSetCopy( pTerm, Lit );
1205  }
1206  Au_NtkForEachPo( p, pTerm, i )
1207  assert( Au_ObjCopy(pTerm) >= 0 );
1208 // p->pMan->nGiaObjMax = Abc_MaxInt( p->pMan->nGiaObjMax, Gia_ManObjNum(pGia) );
1209 }
1210 
1211 /**Function*************************************************************
1212 
1213  Synopsis [Flattens the logic hierarchy of the netlist.]
1214 
1215  Description []
1216 
1217  SideEffects []
1218 
1219  SeeAlso []
1220 
1221 ***********************************************************************/
1223 {
1224  Gia_Man_t * pTemp, * pGia = NULL;
1225  Au_Obj_t * pTerm;
1226  int i;
1227  printf( "Collapsing model \"%s\"...\n", Au_NtkName(p) );
1228  Au_NtkCleanCopy( p );
1229  // start the network
1230  pGia = Gia_ManStart( (1<<16) );
1231  pGia->pName = Abc_UtilStrsav( Au_NtkName(p) );
1232 // pGia->pSpec = Abc_UtilStrsav( Au_NtkSpec(p) );
1233  Gia_ManHashAlloc( pGia );
1234  Gia_ManFlipVerbose( pGia );
1235  // create PIs
1236  Au_NtkForEachPi( p, pTerm, i )
1237  Au_ObjSetCopy( pTerm, Gia_ManAppendCi(pGia) );
1238  // recursively flatten hierarchy
1239  Au_NtkDeriveFlatGia_rec( pGia, p );
1240  // create POs
1241  Au_NtkForEachPo( p, pTerm, i )
1242  Gia_ManAppendCo( pGia, Au_ObjCopy(pTerm) );
1243  // prepare return value
1244 // Gia_ManHashProfile( pGia );
1245  Gia_ManHashStop( pGia );
1246  Gia_ManSetRegNum( pGia, 0 );
1247  pGia = Gia_ManCleanup( pTemp = pGia );
1248  Gia_ManStop( pTemp );
1249  return pGia;
1250 }
1251 
1252 
1253 // ternary simulation
1254 #define AU_VAL0 1
1255 #define AU_VAL1 2
1256 #define AU_VALX 3
1257 
1258 static inline void Au_ObjSetXsim( Au_Obj_t * pObj, int Value ) { pObj->Value = Value; }
1259 static inline int Au_ObjGetXsim( Au_Obj_t * pObj ) { return pObj->Value; }
1260 static inline int Au_XsimInv( int Value )
1261 {
1262  if ( Value == AU_VAL0 )
1263  return AU_VAL1;
1264  if ( Value == AU_VAL1 )
1265  return AU_VAL0;
1266  assert( Value == AU_VALX );
1267  return AU_VALX;
1268 }
1269 static inline int Au_XsimAnd( int Value0, int Value1 )
1270 {
1271  if ( Value0 == AU_VAL0 || Value1 == AU_VAL0 )
1272  return AU_VAL0;
1273  if ( Value0 == AU_VALX || Value1 == AU_VALX )
1274  return AU_VALX;
1275  assert( Value0 == AU_VAL1 && Value1 == AU_VAL1 );
1276  return AU_VAL1;
1277 }
1278 static inline int Au_XsimXor( int Value0, int Value1 )
1279 {
1280  if ( Value0 == AU_VALX || Value1 == AU_VALX )
1281  return AU_VALX;
1282  if ( (Value0 == AU_VAL0) == (Value1 == AU_VAL0) )
1283  return AU_VAL0;
1284  return AU_VAL1;
1285 }
1286 static inline int Au_XsimMux( int ValueC, int Value1, int Value0 )
1287 {
1288  if ( ValueC == AU_VAL0 )
1289  return Value0;
1290  if ( ValueC == AU_VAL1 )
1291  return Value1;
1292  if ( Value0 == AU_VAL0 && Value1 == AU_VAL0 )
1293  return AU_VAL0;
1294  if ( Value0 == AU_VAL1 && Value1 == AU_VAL1 )
1295  return AU_VAL1;
1296  return AU_VALX;
1297 }
1298 static inline int Au_ObjGetXsimFan0( Au_Obj_t * pObj )
1299 {
1300  int Value = Au_ObjGetXsim( Au_ObjFanin0(pObj) );
1301  return Au_ObjFaninC0(pObj) ? Au_XsimInv(Value) : Value;
1302 }
1303 static inline int Au_ObjGetXsimFan1( Au_Obj_t * pObj )
1304 {
1305  int Value = Au_ObjGetXsim( Au_ObjFanin1(pObj) );
1306  return Au_ObjFaninC1(pObj) ? Au_XsimInv(Value) : Value;
1307 }
1308 static inline int Au_ObjGetXsimFan2( Au_Obj_t * pObj )
1309 {
1310  int Value = Au_ObjGetXsim( Au_ObjFanin2(pObj) );
1311  return Au_ObjFaninC2(pObj) ? Au_XsimInv(Value) : Value;
1312 }
1313 
1314 /**Function*************************************************************
1315 
1316  Synopsis [Flattens the logic hierarchy of the netlist.]
1317 
1318  Description []
1319 
1320  SideEffects []
1321 
1322  SeeAlso []
1323 
1324 ***********************************************************************/
1326 {
1327  Au_Obj_t * pObj = NULL, * pTerm;
1328  int i, k;
1329  Au_NtkForEachPi( p, pTerm, i )
1330  {
1331  assert( Au_ObjGetXsim(pTerm) > 0 );
1332  if ( Au_ObjGetXsim(pTerm) == AU_VALX )
1333  p->pMan->nPortsNC++;
1334  else if ( Au_ObjGetXsim(pTerm) == AU_VAL0 )
1335  p->pMan->nPortsC0++;
1336  else
1337  p->pMan->nPortsC1++;
1338  }
1339  if ( strcmp(Au_NtkName(p), "ref_egcd") == 0 )
1340  {
1341  printf( "Replacing one instance of recursive model \"%s\" by a black box.\n", "ref_egcd" );
1342  Au_NtkForEachPo( p, pTerm, i )
1343  Au_ObjSetXsim( pTerm, AU_VALX );
1344  return;
1345  }
1346  Au_NtkForEachObj( p, pObj, i )
1347  {
1348  if ( Au_ObjIsNode(pObj) )
1349  {
1350  if ( pObj->Func == 1 )
1352  else if ( pObj->Func == 2 )
1354  else if ( pObj->Func == 3 )
1356  else assert( 0 );
1357  }
1358  else if ( Au_ObjIsBox(pObj) )
1359  {
1360  Au_Ntk_t * pModel = Au_ObjModel(pObj);
1361  // check the match between the number of actual and formal parameters
1362  assert( Au_ObjFaninNum(pObj) == Au_NtkPiNum(pModel) );
1363  assert( Au_BoxFanoutNum(pObj) == Au_NtkPoNum(pModel) );
1364  // assign PIs
1365  Au_ObjForEachFanin( pObj, pTerm, k )
1366  Au_ObjSetXsim( Au_NtkPi(pModel, k), Au_ObjGetXsim(pTerm) );
1367  // call recursively
1368  Au_NtkTerSimulate_rec( pModel );
1369  // assign POs
1370  Au_BoxForEachFanout( pObj, pTerm, k )
1371  Au_ObjSetXsim( pTerm, Au_ObjGetXsim(Au_NtkPo(pModel, k)) );
1372  }
1373  else if ( Au_ObjIsConst0(pObj) )
1374  Au_ObjSetXsim( pObj, AU_VAL0 );
1375 
1376  }
1377  Au_NtkForEachPo( p, pTerm, i )
1378  Au_ObjSetXsim( pTerm, Au_ObjGetXsimFan0(pObj) );
1379  Au_NtkForEachPo( p, pTerm, i )
1380  {
1381  assert( Au_ObjGetXsim(pTerm) > 0 );
1382  if ( Au_ObjGetXsim(pTerm) == AU_VALX )
1383  p->pMan->nPortsNC++;
1384  else if ( Au_ObjGetXsim(pTerm) == AU_VAL0 )
1385  p->pMan->nPortsC0++;
1386  else
1387  p->pMan->nPortsC1++;
1388  }
1389 }
1390 
1391 /**Function*************************************************************
1392 
1393  Synopsis [Flattens the logic hierarchy of the netlist.]
1394 
1395  Description []
1396 
1397  SideEffects []
1398 
1399  SeeAlso []
1400 
1401 ***********************************************************************/
1403 {
1404  Au_Obj_t * pTerm;
1405  int i, Counter[2] = {0};
1406  assert( p->pMan->pFuncs == NULL );
1407  printf( "Collapsing model \"%s\"...\n", Au_NtkName(p) );
1408  // create PIs
1409  Au_NtkForEachPi( p, pTerm, i )
1410  Au_ObjSetXsim( pTerm, AU_VALX );
1411  // recursively flatten hierarchy
1412  p->pMan->nPortsC0 = 0;
1413  p->pMan->nPortsC1 = 0;
1414  p->pMan->nPortsNC = 0;
1415  Au_NtkTerSimulate_rec( p );
1416  // analyze outputs
1417  Au_NtkForEachPo( p, pTerm, i )
1418  if ( Au_ObjGetXsim(pTerm) == AU_VAL0 )
1419  Counter[0]++;
1420  else if ( Au_ObjGetXsim(pTerm) == AU_VAL1 )
1421  Counter[1]++;
1422  // print results
1423  printf( "Const0 outputs =%15d. Const1 outputs =%15d. Total outputs =%15d.\n",
1424  Counter[0], Counter[1], Au_NtkPoNum(p) );
1425  printf( "Const0 ports = %.0f. Const1 ports = %.0f. Non-const ports= %.0f. Total ports = %.0f.\n",
1426  p->pMan->nPortsC0, p->pMan->nPortsC1, p->pMan->nPortsNC, p->pMan->nPortsC0 + p->pMan->nPortsC1 + p->pMan->nPortsNC );
1427 }
1428 
1429 
1430 /**Function*************************************************************
1431 
1432  Synopsis [Duplicates ABC network.]
1433 
1434  Description []
1435 
1436  SideEffects []
1437 
1438  SeeAlso []
1439 
1440 ***********************************************************************/
1441 Au_Ntk_t * Au_NtkDerive( Au_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * vOrder )
1442 {
1443  Au_Ntk_t * p;
1444  Au_Obj_t * pAuObj;
1445  Abc_Obj_t * pObj, * pTerm;
1446 // Vec_Ptr_t * vOrder;
1447  Vec_Int_t * vFanins;
1448  int i, k, iFunc;
1449  assert( Abc_NtkIsNetlist(pNtk) );
1450  Abc_NtkCleanCopy( pNtk );
1451  p = Au_NtkAlloc( pMan, Abc_NtkName(pNtk) );
1452  // copy PIs
1453  Abc_NtkForEachPi( pNtk, pTerm, i )
1454  Abc_ObjFanout0(pTerm)->iTemp = Au_NtkCreatePi(p);
1455  // copy nodes and boxes
1456  vFanins = Vec_IntAlloc( 100 );
1457 // vOrder = Abc_NtkDfsBoxes( pNtk );
1458  Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pObj, i )
1459  {
1460  Vec_IntClear( vFanins );
1461  if ( Abc_ObjIsNode(pObj) )
1462  {
1463  Abc_ObjForEachFanin( pObj, pTerm, k )
1464  Vec_IntPush( vFanins, Au_Var2Lit(pTerm->iTemp, 0) );
1465  iFunc = Abc_NamStrFindOrAdd( pMan->pFuncs, (char *)pObj->pData, NULL );
1466  Abc_ObjFanout0(pObj)->iTemp = Au_NtkCreateNode(p, vFanins, iFunc);
1467  continue;
1468  }
1469  assert( Abc_ObjIsBox(pObj) );
1470  Abc_ObjForEachFanin( pObj, pTerm, k )
1471  Vec_IntPush( vFanins, Au_Var2Lit(Abc_ObjFanin0(pTerm)->iTemp, 0) );
1472  pObj->iTemp = Au_NtkCreateBox(p, vFanins, Abc_ObjFanoutNum(pObj), ((Abc_Ntk_t *)pObj->pData)->iStep );
1473  pAuObj = Au_NtkObj(p, pObj->iTemp);
1474  Abc_ObjForEachFanout( pObj, pTerm, k )
1475  Abc_ObjFanout0(pTerm)->iTemp = Au_ObjFanout(pAuObj, k);
1476  }
1477 // Vec_PtrFree( vOrder );
1478  Vec_IntFree( vFanins );
1479  // copy POs
1480  Abc_NtkForEachPo( pNtk, pTerm, i )
1481  Au_NtkCreatePo( p, Au_Var2Lit(Abc_ObjFanin0(pTerm)->iTemp, 0) );
1482 // Au_NtkPrintStats( p );
1483  return p;
1484 }
1485 
1487 {
1488  extern Vec_Ptr_t * Abc_NtkCollectHie( Abc_Ntk_t * pNtk );
1489 
1490 // char * pModelName = NULL;
1491  char * pModelName = "path_0_r_x_lhs";
1492  Gia_Man_t * pGia = NULL;
1493  Vec_Ptr_t * vOrder, * vModels;
1494  Abc_Ntk_t * pMod;
1495  Au_Man_t * pMan;
1496  Au_Ntk_t * pNtk = NULL;
1497  abctime clk1, clk2 = 0, clk3 = 0, clk = Abc_Clock();
1498  int i;
1499 
1500  clk1 = Abc_Clock();
1501  pMan = Au_ManAlloc( pRoot->pDesign ? pRoot->pDesign->pName : pRoot->pName );
1502  pMan->pFuncs = Abc_NamStart( 100, 16 );
1503  clk2 += Abc_Clock() - clk1;
1504 
1505  vModels = Abc_NtkCollectHie( pRoot );
1506  Vec_PtrForEachEntry( Abc_Ntk_t *, vModels, pMod, i )
1507  {
1508  vOrder = Abc_NtkDfsBoxes( pMod );
1509 
1510  clk1 = Abc_Clock();
1511  pNtk = Au_NtkDerive( pMan, pMod, vOrder );
1512  pMod->iStep = pNtk->Id;
1513  pMod->pData = pNtk;
1514  clk2 += Abc_Clock() - clk1;
1515 
1516  Vec_PtrFree( vOrder );
1517  }
1518  Vec_PtrFree( vModels );
1519  // order models in topological order
1520  Au_ManReorderModels( pMan, pNtk );
1521 
1522  // print statistics
1523  Au_ManPrintStats( pMan );
1524  Au_ManCountThings( pNtk->pMan );
1525 
1526  // select network
1527  if ( pModelName )
1528  {
1529  pNtk = Au_ManFindNtkP( pMan, pModelName );
1530  if ( pNtk == NULL )
1531  printf( "Could not find module \"%s\".\n", pModelName );
1532  }
1533  if ( pNtk == NULL )
1534  pNtk = (Au_Ntk_t *)pRoot->pData;
1535 
1536 
1537 // if ( !Abc_NtkCheckRecursive(pRoot) )
1538  {
1539  clk1 = Abc_Clock();
1540  pGia = Au_NtkDeriveFlatGia( pNtk );
1541  clk3 = Abc_Clock() - clk1;
1542 // printf( "GIA objects max = %d.\n", pMan->nGiaObjMax );
1543  }
1544 
1545 // clk1 = Abc_Clock();
1546 // Au_NtkSuppSizeTest( (Au_Ntk_t *)pRoot->pData );
1547 // clk4 = Abc_Clock() - clk1;
1548 
1549  clk1 = Abc_Clock();
1550  Au_ManDelete( pMan );
1551  clk2 += Abc_Clock() - clk1;
1552 
1553  Abc_PrintTime( 1, "Time all ", Abc_Clock() - clk );
1554  Abc_PrintTime( 1, "Time new ", clk2 );
1555  Abc_PrintTime( 1, "Time GIA ", clk3 );
1556 // Abc_PrintTime( 1, "Time supp", clk4 );
1557  return pGia;
1558 }
1559 
1560 /**Function*************************************************************
1561 
1562  Synopsis [Performs hierarchical equivalence checking.]
1563 
1564  Description []
1565 
1566  SideEffects []
1567 
1568  SeeAlso []
1569 
1570 ***********************************************************************/
1571 Gia_Man_t * Abc_NtkHieCecTest2( char * pFileName, char * pModelName, int fVerbose )
1572 {
1573  int fSimulation = 0;
1574  Gia_Man_t * pGia = NULL;
1575  Au_Ntk_t * pNtk, * pNtkClp = NULL;
1576  abctime clk1 = 0, clk = Abc_Clock();
1577 
1578  // read hierarchical netlist
1579  pNtk = Au_NtkParseCBlif( pFileName );
1580  if ( pNtk == NULL )
1581  {
1582  printf( "Reading CBLIF file has failed.\n" );
1583  return NULL;
1584  }
1585  if ( pNtk->pMan == NULL || pNtk->pMan->vNtks.pArray == NULL )
1586  {
1587  printf( "There is no hierarchy information.\n" );
1588  Au_NtkFree( pNtk );
1589  return NULL;
1590  }
1591  Abc_PrintTime( 1, "Reading file", Abc_Clock() - clk );
1592 
1593  if ( fVerbose )
1594  {
1595  Au_ManPrintBoxInfo( pNtk );
1596 // Au_ManPrintBoxInfoSorted( pNtk );
1597  Au_ManPrintStats( pNtk->pMan );
1598  }
1599  Au_ManCountThings( pNtk->pMan );
1600 
1601  // select network
1602  if ( pModelName )
1603  pNtkClp = Au_ManFindNtkP( pNtk->pMan, pModelName );
1604  if ( pNtkClp == NULL )
1605  pNtkClp = pNtk;
1606 
1607  // check if the model is recursive
1608  Au_NtkCheckRecursive( pNtkClp );
1609 
1610  // collapse
1611  clk1 = Abc_Clock();
1612  if ( fSimulation )
1613  {
1614  Au_NtkTerSimulate( pNtkClp );
1615  Abc_PrintTime( 1, "Time sim ", Abc_Clock() - clk1 );
1616  }
1617  else
1618  {
1619  pGia = Au_NtkDeriveFlatGia( pNtkClp );
1620  Abc_PrintTime( 1, "Time GIA ", Abc_Clock() - clk1 );
1621  }
1622 
1623  // delete
1624  Au_ManDelete( pNtk->pMan );
1625  Abc_PrintTime( 1, "Time all ", Abc_Clock() - clk );
1626  return pGia;
1627 }
1628 
1629 ////////////////////////////////////////////////////////////////////////
1630 /// END OF FILE ///
1631 ////////////////////////////////////////////////////////////////////////
1632 
1633 
1635 
void Au_NtkDeriveFlatGia_rec(Gia_Man_t *pGia, Au_Ntk_t *p)
Definition: abcHieNew.c:1131
int Au_NtkAllocObj(Au_Ntk_t *p, int nFanins, int Type)
Definition: abcHieNew.c:761
double nNodes
Definition: abcHieNew.c:91
int iTemp
Definition: abc.h:149
static int Au_ObjFaninId(Au_Obj_t *p, int i)
Definition: abcHieNew.c:165
#define Au_ObjForEachFaninId(pObj, hFanin, i)
Definition: abcHieNew.c:204
void Au_ManFree(Au_Man_t *p)
Definition: abcHieNew.c:336
Vec_Ptr_t * Abc_NtkCollectHie(Abc_Ntk_t *pNtk)
Definition: abcHieCec.c:499
static char * Au_ManName(Au_Man_t *p)
Definition: abcHieNew.c:126
#define Au_NtkForEachPi(p, pObj, i)
Definition: abcHieNew.c:214
static Au_Obj_t * Au_ObjFanin(Au_Obj_t *p, int i)
Definition: abcHieNew.c:169
unsigned Func
Definition: abcHieNew.c:57
#define Au_BoxForEachFanout(pObj, pFanout, i)
Definition: abcHieNew.c:211
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Au_ObjFaninC0(Au_Obj_t *p)
Definition: abcHieNew.c:174
static int Au_NtkFlopNum(Au_Ntk_t *p)
Definition: abcHieNew.c:136
void Abc_NamStop(Abc_Nam_t *p)
Definition: utilNam.c:110
static int Au_ObjIsConst0(Au_Obj_t *p)
Definition: abcHieNew.c:148
int Au_NtkNodeNumFunc(Au_Ntk_t *p, int Func)
Definition: abcHieNew.c:301
#define Au_NtkForEachObj(p, pObj, i)
Definition: abcHieNew.c:218
int Au_NtkSuppSizeTest(Au_Ntk_t *p)
Definition: abcHieNew.c:731
#define Au_ManForEachNtk(p, pNtk, i)
Definition: abcHieNew.c:199
Gia_Man_t * Abc_NtkHieCecTest2(char *pFileName, char *pModelName, int fVerbose)
Definition: abcHieNew.c:1571
static int Au_NtkNodeNum(Au_Ntk_t *p)
Definition: abcHieNew.c:138
static int Au_ObjFaninC1(Au_Obj_t *p)
Definition: abcHieNew.c:175
static int Au_ObjIsBox(Au_Obj_t *p)
Definition: abcHieNew.c:153
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static int Au_ObjIsPo(Au_Obj_t *p)
Definition: abcHieNew.c:150
static void Au_NtkInsertHeader(Au_Ntk_t *p)
Definition: abcHieNew.c:753
int Au_ObjSuppSize_rec(Au_Ntk_t *p, int Id)
Definition: abcHieNew.c:688
int nHTable
Definition: abcHieNew.c:85
static int Au_ObjGetXsimFan2(Au_Obj_t *pObj)
Definition: abcHieNew.c:1308
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
#define Au_ObjForEachFanin(pObj, pFanin, i)
Definition: abcHieNew.c:209
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Au_NtkCreateConst0(Au_Ntk_t *pNtk)
Definition: abcHieNew.c:822
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
int Fanins[2]
Definition: abcHieNew.c:61
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static int Au_Var2Lit(int Var, int fCompl)
Definition: abcHieNew.c:112
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
Definition: vecPtr.h:430
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static void Au_ObjSetTravIdPrevious(Au_Obj_t *p)
Definition: abcHieNew.c:193
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Vec_Ptr_t * Abc_NtkDfsBoxes(Abc_Ntk_t *pNtk)
Definition: abcHieCec.c:104
Vec_Int_t vTravIds
Definition: abcHieNew.c:82
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
static int Au_ObjIsTravIdCurrent(Au_Obj_t *p)
Definition: abcHieNew.c:194
void Au_ManReorderModels_rec(Au_Ntk_t *pNtk, Vec_Int_t *vOrder)
Definition: abcHieNew.c:409
static Vec_Int_t * Vec_IntInvert(Vec_Int_t *p, int Fill)
Definition: vecInt.h:1092
static int Au_ObjPioNum(Au_Obj_t *p)
Definition: abcHieNew.c:160
char * strtok()
static int Au_ObjFunc(Au_Obj_t *p)
Definition: abcHieNew.c:161
static int Au_NtkObjNum(Au_Ntk_t *p)
Definition: abcHieNew.c:140
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
static Au_Obj_t * Au_Not(Au_Obj_t *p)
Definition: abcHieNew.c:120
static int Au_NtkPoNum(Au_Ntk_t *p)
Definition: abcHieNew.c:134
static Au_Ntk_t * Au_ManNtkRoot(Au_Man_t *p)
Definition: abcHieNew.c:129
static void Au_ObjSetFanin(Au_Obj_t *p, int i, int f)
Definition: abcHieNew.c:178
Au_Type_t
Definition: abcHieNew.c:38
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
char * pName
Definition: abcHieNew.c:100
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Au_Obj_t * Au_Regular(Au_Obj_t *p)
Definition: abcHieNew.c:119
static int Vec_IntGetEntry(Vec_Int_t *p, int i)
Definition: bblif.c:401
static Au_Man_t * Au_NtkMan(Au_Ntk_t *p)
Definition: abcHieNew.c:132
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
int Au_ManMemUsage(Au_Man_t *p)
Definition: abcHieNew.c:377
char * pName
Definition: abc.h:220
static Vec_Ptr_t * Vec_PtrDup(Vec_Ptr_t *pVec)
Definition: vecPtr.h:169
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition: utilNam.c:392
void Au_NtkCleanCopy(Au_Ntk_t *p)
Definition: abcHieNew.c:297
static Au_Obj_t * Au_NtkObjI(Au_Ntk_t *p, int i)
Definition: abcHieNew.c:145
static int Au_NtkFanNum(Au_Ntk_t *p)
Definition: abcHieNew.c:135
#define AU_VAL0
Definition: abcHieNew.c:1254
static abctime Abc_Clock()
Definition: abc_global.h:279
static Au_Obj_t * Au_ObjFanin0(Au_Obj_t *p)
Definition: abcHieNew.c:170
static int Au_ObjIsTravIdPrevious(Au_Obj_t *p)
Definition: abcHieNew.c:195
static int Au_ObjFanout(Au_Obj_t *p, int i)
Definition: abcHieNew.c:188
static Au_Obj_t * Au_NotCond(Au_Obj_t *p, int c)
Definition: abcHieNew.c:121
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Au_ObjCopy(Au_Obj_t *p)
Definition: abcHieNew.c:185
int nRefs
Definition: abcHieNew.c:103
static Au_Obj_t * Au_NtkObj(Au_Ntk_t *p, int h)
Definition: abcHieNew.c:141
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
Vec_Ptr_t vNtks
Definition: abcHieNew.c:101
static int Au_ObjFaninId2(Au_Obj_t *p)
Definition: abcHieNew.c:168
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Au_BoxFanoutNum(Au_Obj_t *p)
Definition: abcHieNew.c:181
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
Definition: utilNam.c:78
Vec_Ptr_t vPages
Definition: abcHieNew.c:76
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:694
static char * Au_ObjBase(Au_Obj_t *p)
Definition: abcHieNew.c:157
double nPortsNC
Definition: abcHieNew.c:108
static void Au_NtkParseCBlifNum(Vec_Int_t *vFanins, char *pToken, Vec_Int_t *vNum2Obj)
Definition: abcHieNew.c:923
void Au_NtkTerSimulate(Au_Ntk_t *p)
Definition: abcHieNew.c:1402
static void Au_NtkIncrementTravId(Au_Ntk_t *p)
Definition: abcHieNew.c:191
Au_Ntk_t * Au_ManFindNtkP(Au_Man_t *p, char *pName)
Definition: abcHieNew.c:363
static void Au_ObjSetCopy(Au_Obj_t *p, int c)
Definition: abcHieNew.c:186
double nPortsC0
Definition: abcHieNew.c:106
int Abc_NtkCheckRecursive(Abc_Ntk_t *pNtk)
Definition: abcHieCec.c:626
int strcmp()
void * pData
Definition: abc.h:203
Vec_Int_t vCopies
Definition: abcHieNew.c:83
Vec_Int_t vObjs
Definition: abcHieNew.c:72
int iStep
Definition: abc.h:178
static Au_Ntk_t * Au_ObjModel(Au_Obj_t *p)
Definition: abcHieNew.c:162
static int Au_NtkObjNumMax(Au_Ntk_t *p)
Definition: abcHieNew.c:139
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
void Au_ManDelete(Au_Man_t *p)
Definition: abcHieNew.c:347
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Au_Man_t * pMan
Definition: abcHieNew.c:67
char * pName
Definition: abcHieNew.c:66
static int Au_ObjFaninNum(Au_Obj_t *p)
Definition: abcHieNew.c:164
double nNodeAnds
Definition: abcHieNew.c:93
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
double nPortsC1
Definition: abcHieNew.c:107
void Au_ManPrintStats(Au_Man_t *p)
Definition: abcHieNew.c:393
Abc_Nam_t * pFuncs
Definition: abcHieNew.c:102
#define Au_NtkForEachNode(p, pObj, i)
Definition: abcHieNew.c:220
unsigned Type
Definition: abcHieNew.c:59
Au_Ntk_t * Au_NtkAlloc(Au_Man_t *pMan, char *pName)
FUNCTION DEFINITIONS ///.
Definition: abcHieNew.c:245
unsigned nFanins
Definition: abcHieNew.c:60
int nGiaObjMax
Definition: abcHieNew.c:105
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int Au_NtkCreatePi(Au_Ntk_t *pNtk)
Definition: abcHieNew.c:826
static int Au_ObjFaninC2(Au_Obj_t *p)
Definition: abcHieNew.c:176
static int Au_ObjGetXsim(Au_Obj_t *pObj)
Definition: abcHieNew.c:1259
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
int nObjsUsed
Definition: abcHieNew.c:79
static int Au_ObjFaninId1(Au_Obj_t *p)
Definition: abcHieNew.c:167
static int Au_ObjFaninC(Au_Obj_t *p, int i)
Definition: abcHieNew.c:173
int Au_NtkCreateBox(Au_Ntk_t *pNtk, Vec_Int_t *vFanins, int nFanouts, int iModel)
Definition: abcHieNew.c:857
int nObjs[AU_OBJ_VOID]
Definition: abcHieNew.c:73
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
int Abc_NtkDeriveFlatGiaSop(Gia_Man_t *pGia, int *gFanins, char *pSop)
Definition: abcHieCec.c:131
double nBoxes
Definition: abcHieNew.c:90
static int Au_ObjId(Au_Obj_t *p)
Definition: abcHieNew.c:159
static int Au_ManNtkNum(Au_Man_t *p)
Definition: abcHieNew.c:127
static int Au_ObjGetXsimFan0(Au_Obj_t *pObj)
Definition: abcHieNew.c:1298
int nObjsAlloc
Definition: abcHieNew.c:78
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Au_Obj_t * Au_BoxFanout(Au_Obj_t *p, int i)
Definition: abcHieNew.c:183
static int Au_LitNot(int Lit)
Definition: abcHieNew.c:115
static int Au_Lit2Var(int Lit)
Definition: abcHieNew.c:113
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static char * Au_NtkName(Au_Ntk_t *p)
Definition: abcHieNew.c:131
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Au_BoxFanoutId(Au_Obj_t *p, int i)
Definition: abcHieNew.c:182
static int Au_ObjFaninLit(Au_Obj_t *p, int i)
Definition: abcHieNew.c:177
int Au_NtkCreateFan(Au_Ntk_t *pNtk, int iFanin, int iFanout, int iModel)
Definition: abcHieNew.c:837
int Au_NtkCompareNames(Au_Ntk_t **p1, Au_Ntk_t **p2)
Definition: abcHieNew.c:539
static int Au_ObjIsFan(Au_Obj_t *p)
Definition: abcHieNew.c:151
static int Vec_IntPop(Vec_Int_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
double nNodeXors
Definition: abcHieNew.c:94
Au_Ntk_t * Au_NtkDerive(Au_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vOrder)
Definition: abcHieNew.c:1441
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Au_NtkRemapNum(Vec_Int_t *vNum2Obj, int Num)
Definition: abcHieNew.c:908
#define Au_NtkForEachPo(p, pObj, i)
Definition: abcHieNew.c:216
static int Au_NtkPiNum(Au_Ntk_t *p)
Definition: abcHieNew.c:133
static int Counter
Gia_Man_t * Au_NtkDeriveFlatGia(Au_Ntk_t *p)
Definition: abcHieNew.c:1222
#define Au_NtkForEachBox(p, pObj, i)
Definition: abcHieNew.c:222
Au_Man_t * Au_ManAlloc(char *pName)
Definition: abcHieNew.c:327
int Id
Definition: abcHieNew.c:68
static int Au_ObjGetXsimFan1(Au_Obj_t *pObj)
Definition: abcHieNew.c:1303
void Au_ManPrintBoxInfoSorted(Au_Ntk_t *pNtk)
Definition: abcHieNew.c:628
void Au_ManPrintBoxInfo(Au_Ntk_t *pNtk)
Definition: abcHieNew.c:543
void Au_NtkFree(Au_Ntk_t *p)
Definition: abcHieNew.c:258
int Au_NtkCreatePo(Au_Ntk_t *pNtk, int iFanin)
Definition: abcHieNew.c:830
static int Au_ObjIsFlop(Au_Obj_t *p)
Definition: abcHieNew.c:152
char * strcpy()
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
int Au_NtkCreateNode(Au_Ntk_t *pNtk, Vec_Int_t *vFanins, int iFunc)
Definition: abcHieNew.c:847
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int * pHTable
Definition: abcHieNew.c:86
static int Au_ObjIsTravIdCurrentId(Au_Ntk_t *p, int Id)
Definition: abcHieNew.c:197
static int Au_LitIsCompl(int Lit)
Definition: abcHieNew.c:114
void Au_NtkPrintStats(Au_Ntk_t *p)
Definition: abcHieNew.c:280
static void Au_ObjSetTravIdCurrentId(Au_Ntk_t *p, int Id)
Definition: abcHieNew.c:196
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
#define Au_ManForEachNtkReverse(p, pNtk, i)
Definition: abcHieNew.c:201
struct Au_Ntk_t_ Au_Ntk_t
Definition: abcHieNew.c:52
double nPorts
Definition: abcHieNew.c:92
static int Au_XsimXor(int Value0, int Value1)
Definition: abcHieNew.c:1278
int nTravIds
Definition: abcHieNew.c:81
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static char * Au_UtilStrsav(char *s)
Definition: abcHieNew.c:124
static int Au_XsimMux(int ValueC, int Value1, int Value0)
Definition: abcHieNew.c:1286
static int Au_IsComplement(Au_Obj_t *p)
Definition: abcHieNew.c:122
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
static Au_Ntk_t * Au_ManNtk(Au_Man_t *p, int i)
Definition: abcHieNew.c:128
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Int_t vPos
Definition: abcHieNew.c:71
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Au_ObjIsPi(Au_Obj_t *p)
Definition: abcHieNew.c:149
static void Au_ObjSetXsim(Au_Obj_t *pObj, int Value)
Definition: abcHieNew.c:1258
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
int Au_NtkCheckRecursive(Au_Ntk_t *pNtk)
Definition: abcHieNew.c:660
Gia_Man_t * Au_ManDeriveTest(Abc_Ntk_t *pRoot)
Definition: abcHieNew.c:1486
static int Au_ObjIsNone(Au_Obj_t *p)
Definition: abcHieNew.c:147
static void Au_ObjSetFaninLit(Au_Obj_t *p, int i, int f)
Definition: abcHieNew.c:179
static Au_Obj_t * Au_NtkPi(Au_Ntk_t *p, int i)
Definition: abcHieNew.c:143
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int Var
Definition: SolverTypes.h:42
#define Au_BoxForEachFanoutId(pObj, hFanout, i)
Definition: abcHieNew.c:206
Au_Ntk_t * Au_NtkParseCBlif(char *pFileName)
Definition: abcHieNew.c:959
char * Extra_FileRead(FILE *pFile)
static Au_Obj_t * Au_ObjFanin1(Au_Obj_t *p)
Definition: abcHieNew.c:171
unsigned Value
Definition: abcHieNew.c:58
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition: utilNam.h:39
static void Au_ObjSetFanout(Au_Obj_t *p, int i, int f)
Definition: abcHieNew.c:189
static void Au_ObjSetTravIdCurrent(Au_Obj_t *p)
Definition: abcHieNew.c:192
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
int strlen()
static int Abc_ObjIsBox(Abc_Obj_t *pObj)
Definition: abc.h:357
int iHandle
Definition: abcHieNew.c:77
int Au_NtkCompareSign(Au_Ntk_t **p1, Au_Ntk_t **p2)
Definition: abcHieNew.c:621
static int Au_ObjIsTerm(Au_Obj_t *p)
Definition: abcHieNew.c:155
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
int Au_NtkMemUsage(Au_Ntk_t *p)
Definition: abcHieNew.c:271
int Au_ManFindNtk(Au_Man_t *p, char *pName)
Definition: abcHieNew.c:354
int Au_ObjSuppSize(Au_Obj_t *pObj)
Definition: abcHieNew.c:703
static Au_Obj_t * Au_NtkPo(Au_Ntk_t *p, int i)
Definition: abcHieNew.c:144
static Au_Ntk_t * Au_ObjNtk(Au_Obj_t *p)
Definition: abcHieNew.c:158
void * pData
Definition: abc.h:145
Au_Obj_t * pConst0
Definition: abcHieNew.c:87
void Au_NtkTerSimulate_rec(Au_Ntk_t *p)
Definition: abcHieNew.c:1325
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
Vec_Ptr_t * vChunks
Definition: abcHieNew.c:75
double nNodeMuxs
Definition: abcHieNew.c:95
#define AU_VALX
Definition: abcHieNew.c:1256
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
void Au_ManReorderModels(Au_Man_t *p, Au_Ntk_t *pRoot)
Definition: abcHieNew.c:426
Vec_Int_t vPis
Definition: abcHieNew.c:70
int fMark
Definition: abcHieNew.c:89
static int Au_LitNotCond(int Lit, int c)
Definition: abcHieNew.c:116
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Au_NtkBoxNum(Au_Ntk_t *p)
Definition: abcHieNew.c:137
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Au_XsimAnd(int Value0, int Value1)
Definition: abcHieNew.c:1269
Abc_Des_t * pDesign
Definition: abc.h:180
#define AU_VAL1
Definition: abcHieNew.c:1255
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
void Au_ManCountThings(Au_Man_t *p)
Definition: abcHieNew.c:492
static int Au_ObjFaninId0(Au_Obj_t *p)
Definition: abcHieNew.c:166
static int Au_ObjIsNode(Au_Obj_t *p)
Definition: abcHieNew.c:154
static int Au_LitRegular(int Lit)
Definition: abcHieNew.c:117
char * pName
Definition: abc.h:158
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
int Au_ManMemUsageUseful(Au_Man_t *p)
Definition: abcHieNew.c:385
void Au_ManAddNtk(Au_Man_t *pMan, Au_Ntk_t *p)
Definition: abcHieNew.c:370
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 Au_XsimInv(int Value)
Definition: abcHieNew.c:1260
static Au_Obj_t * Au_ObjFanin2(Au_Obj_t *p)
Definition: abcHieNew.c:172
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static void Gia_ManFlipVerbose(Gia_Man_t *p)
Definition: gia.h:396