abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaForce.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [gia.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Scalable AIG package.]
8 
9  Synopsis []
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "gia.h"
22 
24 
25 
26 /*
27  The code is based on the paper by F. A. Aloul, I. L. Markov, and K. A. Sakallah.
28  "FORCE: A Fast and Easy-To-Implement Variable-Ordering Heuristic", Proc. GLSVLSI�03.
29  http://www.eecs.umich.edu/~imarkov/pubs/conf/glsvlsi03-force.pdf
30 */
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// DECLARATIONS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 typedef struct Frc_Obj_t_ Frc_Obj_t;
37 struct Frc_Obj_t_
38 {
39  unsigned fCi : 1; // terminal node CI
40  unsigned fCo : 1; // terminal node CO
41  unsigned fMark0 : 1; // first user-controlled mark
42  unsigned fMark1 : 1; // second user-controlled mark
43  unsigned nFanins : 28; // the number of fanins
44  unsigned nFanouts; // the number of fanouts
45  unsigned iFanout; // the current number of fanouts
46  int hHandle; // the handle of the node
47  int pPlace; // the placement of each node
48  union {
49  float fEdgeCenter; // center-of-gravity of the edge
50  unsigned iFanin;
51  };
52  int Fanios[0]; // the array of fanins/fanouts
53 };
54 
55 typedef struct Frc_Man_t_ Frc_Man_t;
56 struct Frc_Man_t_
57 {
58  Gia_Man_t * pGia; // the original AIG manager
59  Vec_Int_t * vCis; // the vector of CIs (PIs + LOs)
60  Vec_Int_t * vCos; // the vector of COs (POs + LIs)
61  int nObjs; // the number of objects
62  int nRegs; // the number of registers
63  int * pObjData; // the array containing data for objects
64  int nObjData; // the size of array to store the logic network
65  int fVerbose; // verbose output flag
66  int nCutCur; // current cut
67  int nCutMax; // max cut seen
68 };
69 
70 static inline int Frc_ManRegNum( Frc_Man_t * p ) { return p->nRegs; }
71 static inline int Frc_ManCiNum( Frc_Man_t * p ) { return Vec_IntSize(p->vCis); }
72 static inline int Frc_ManCoNum( Frc_Man_t * p ) { return Vec_IntSize(p->vCos); }
73 static inline int Frc_ManPiNum( Frc_Man_t * p ) { return Vec_IntSize(p->vCis) - p->nRegs; }
74 static inline int Frc_ManPoNum( Frc_Man_t * p ) { return Vec_IntSize(p->vCos) - p->nRegs; }
75 static inline int Frc_ManObjNum( Frc_Man_t * p ) { return p->nObjs; }
76 static inline int Frc_ManNodeNum( Frc_Man_t * p ) { return p->nObjs - Vec_IntSize(p->vCis) - Vec_IntSize(p->vCos); }
77 
78 static inline Frc_Obj_t * Frc_ManObj( Frc_Man_t * p, int hHandle ) { return (Frc_Obj_t *)(p->pObjData + hHandle); }
79 static inline Frc_Obj_t * Frc_ManCi( Frc_Man_t * p, int i ) { return Frc_ManObj( p, Vec_IntEntry(p->vCis,i) ); }
80 static inline Frc_Obj_t * Frc_ManCo( Frc_Man_t * p, int i ) { return Frc_ManObj( p, Vec_IntEntry(p->vCos,i) ); }
81 
82 static inline int Frc_ObjIsTerm( Frc_Obj_t * pObj ) { return pObj->fCi || pObj->fCo; }
83 static inline int Frc_ObjIsCi( Frc_Obj_t * pObj ) { return pObj->fCi; }
84 static inline int Frc_ObjIsCo( Frc_Obj_t * pObj ) { return pObj->fCo; }
85 static inline int Frc_ObjIsPi( Frc_Obj_t * pObj ) { return pObj->fCi && pObj->nFanins == 0; }
86 static inline int Frc_ObjIsPo( Frc_Obj_t * pObj ) { return pObj->fCo && pObj->nFanouts == 0; }
87 static inline int Frc_ObjIsNode( Frc_Obj_t * pObj ) { return!Frc_ObjIsTerm(pObj) && pObj->nFanins > 0; }
88 static inline int Frc_ObjIsConst0( Frc_Obj_t * pObj ) { return!Frc_ObjIsTerm(pObj) && pObj->nFanins == 0; }
89 
90 static inline int Frc_ObjSize( Frc_Obj_t * pObj ) { return sizeof(Frc_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; }
91 static inline int Frc_ObjFaninNum( Frc_Obj_t * pObj ) { return pObj->nFanins; }
92 static inline int Frc_ObjFanoutNum( Frc_Obj_t * pObj ) { return pObj->nFanouts; }
93 static inline Frc_Obj_t * Frc_ObjFanin( Frc_Obj_t * pObj, int i ) { return (Frc_Obj_t *)(((int *)pObj) - pObj->Fanios[i]); }
94 static inline Frc_Obj_t * Frc_ObjFanout( Frc_Obj_t * pObj, int i ) { return (Frc_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i]); }
95 
96 #define Frc_ManForEachObj( p, pObj, i ) \
97  for ( i = 0; (i < p->nObjData) && (pObj = Frc_ManObj(p,i)); i += Frc_ObjSize(pObj) )
98 #define Frc_ManForEachObjVec( vVec, p, pObj, i ) \
99  for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Frc_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
100 
101 #define Frc_ManForEachNode( p, pObj, i ) \
102  for ( i = 0; (i < p->nObjData) && (pObj = Frc_ManObj(p,i)); i += Frc_ObjSize(pObj) ) if ( Frc_ObjIsTerm(pObj) ) {} else
103 #define Frc_ManForEachCi( p, pObj, i ) \
104  for ( i = 0; (i < Vec_IntSize(p->vCis)) && (pObj = Frc_ManObj(p,Vec_IntEntry(p->vCis,i))); i++ )
105 #define Frc_ManForEachCo( p, pObj, i ) \
106  for ( i = 0; (i < Vec_IntSize(p->vCos)) && (pObj = Frc_ManObj(p,Vec_IntEntry(p->vCos,i))); i++ )
107 
108 #define Frc_ObjForEachFanin( pObj, pNext, i ) \
109  for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Frc_ObjFanin(pObj,i)); i++ )
110 #define Frc_ObjForEachFaninReverse( pObj, pNext, i ) \
111  for ( i = (int)pObj->nFanins - 1; (i >= 0) && (pNext = Frc_ObjFanin(pObj,i)); i-- )
112 #define Frc_ObjForEachFanout( pObj, pNext, i ) \
113  for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Frc_ObjFanout(pObj,i)); i++ )
114 
115 ////////////////////////////////////////////////////////////////////////
116 /// FUNCTION DEFINITIONS ///
117 ////////////////////////////////////////////////////////////////////////
118 
119 
120 /**Function*************************************************************
121 
122  Synopsis [Creates fanin/fanout pair.]
123 
124  Description []
125 
126  SideEffects []
127 
128  SeeAlso []
129 
130 ***********************************************************************/
131 void Frc_ObjAddFanin( Frc_Obj_t * pObj, Frc_Obj_t * pFanin )
132 {
133  assert( pObj->iFanin < pObj->nFanins );
134  assert( pFanin->iFanout < pFanin->nFanouts );
135  pFanin->Fanios[pFanin->nFanins + pFanin->iFanout++] =
136  pObj->Fanios[pObj->iFanin++] = pObj->hHandle - pFanin->hHandle;
137 }
138 
139 /**Function*************************************************************
140 
141  Synopsis [Creates logic network isomorphic to the given AIG.]
142 
143  Description []
144 
145  SideEffects []
146 
147  SeeAlso []
148 
149 ***********************************************************************/
151 {
152  Frc_Man_t * p;
153  Frc_Obj_t * pObjLog, * pFanLog;
154  Gia_Obj_t * pObj;//, * pObjRi, * pObjRo;
155  int i, nNodes, hHandle = 0;
156  // prepare the AIG
157  Gia_ManCreateRefs( pGia );
158  // create logic network
159  p = ABC_CALLOC( Frc_Man_t, 1 );
160  p->pGia = pGia;
161  p->nRegs = Gia_ManRegNum(pGia);
162  p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) );
163  p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
164  p->nObjData = (sizeof(Frc_Obj_t) / 4) * Gia_ManObjNum(pGia) + 2 * (2 * Gia_ManAndNum(pGia) + Gia_ManCoNum(pGia));
165  p->pObjData = ABC_CALLOC( int, p->nObjData );
166  // create constant node
167  Gia_ManConst0(pGia)->Value = hHandle;
168  pObjLog = Frc_ManObj( p, hHandle );
169  pObjLog->hHandle = hHandle;
170  pObjLog->nFanins = 0;
171  pObjLog->nFanouts = Gia_ObjRefNum( pGia, Gia_ManConst0(pGia) );
172  // count objects
173  hHandle += Frc_ObjSize( pObjLog );
174  nNodes = 1;
175  p->nObjs++;
176  // create the PIs
177  Gia_ManForEachCi( pGia, pObj, i )
178  {
179  // create PI object
180  pObj->Value = hHandle;
181  Vec_IntPush( p->vCis, hHandle );
182  pObjLog = Frc_ManObj( p, hHandle );
183  pObjLog->hHandle = hHandle;
184  pObjLog->nFanins = 0;
185  pObjLog->nFanouts = Gia_ObjRefNum( pGia, pObj );
186  pObjLog->fCi = 0;
187  // count objects
188  hHandle += Frc_ObjSize( pObjLog );
189  p->nObjs++;
190  }
191  // create internal nodes
192  Gia_ManForEachAnd( pGia, pObj, i )
193  {
194  assert( Gia_ObjRefNum( pGia, pObj ) > 0 );
195  // create node object
196  pObj->Value = hHandle;
197  pObjLog = Frc_ManObj( p, hHandle );
198  pObjLog->hHandle = hHandle;
199  pObjLog->nFanins = 2;
200  pObjLog->nFanouts = Gia_ObjRefNum( pGia, pObj );
201  // add fanins
202  pFanLog = Frc_ManObj( p, Gia_ObjValue(Gia_ObjFanin0(pObj)) );
203  Frc_ObjAddFanin( pObjLog, pFanLog );
204  pFanLog = Frc_ManObj( p, Gia_ObjValue(Gia_ObjFanin1(pObj)) );
205  Frc_ObjAddFanin( pObjLog, pFanLog );
206  // count objects
207  hHandle += Frc_ObjSize( pObjLog );
208  nNodes++;
209  p->nObjs++;
210  }
211  // create the POs
212  Gia_ManForEachCo( pGia, pObj, i )
213  {
214  // create PO object
215  pObj->Value = hHandle;
216  Vec_IntPush( p->vCos, hHandle );
217  pObjLog = Frc_ManObj( p, hHandle );
218  pObjLog->hHandle = hHandle;
219  pObjLog->nFanins = 1;
220  pObjLog->nFanouts = 0;
221  pObjLog->fCo = 1;
222  // add fanins
223  pFanLog = Frc_ManObj( p, Gia_ObjValue(Gia_ObjFanin0(pObj)) );
224  Frc_ObjAddFanin( pObjLog, pFanLog );
225  // count objects
226  hHandle += Frc_ObjSize( pObjLog );
227  p->nObjs++;
228  }
229  // connect registers
230 // Gia_ManForEachRiRo( pGia, pObjRi, pObjRo, i )
231 // Frc_ObjAddFanin( Frc_ManObj(p,Gia_ObjValue(pObjRo)), Frc_ManObj(p,Gia_ObjValue(pObjRi)) );
232  assert( nNodes == Frc_ManNodeNum(p) );
233  assert( hHandle == p->nObjData );
234  if ( hHandle != p->nObjData )
235  printf( "Frc_ManStartSimple(): Fatal error in internal representation.\n" );
236  // make sure the fanin/fanout counters are correct
237  Gia_ManForEachObj( pGia, pObj, i )
238  {
239  if ( !~Gia_ObjValue(pObj) )
240  continue;
241  pObjLog = Frc_ManObj( p, Gia_ObjValue(pObj) );
242  assert( pObjLog->nFanins == pObjLog->iFanin );
243  assert( pObjLog->nFanouts == pObjLog->iFanout );
244  pObjLog->iFanin = pObjLog->iFanout = 0;
245  }
246  ABC_FREE( pGia->pRefs );
247  return p;
248 }
249 
250 /**Function*************************************************************
251 
252  Synopsis [Collect the fanin IDs.]
253 
254  Description []
255 
256  SideEffects []
257 
258  SeeAlso []
259 
260 ***********************************************************************/
261 void Frc_ManCollectSuper_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper, Vec_Int_t * vVisit )
262 {
263  if ( pObj->fMark1 )
264  return;
265  pObj->fMark1 = 1;
266  Vec_IntPush( vVisit, Gia_ObjId(p, pObj) );
267  if ( pObj->fMark0 )
268  {
269  Vec_IntPush( vSuper, Gia_ObjId(p, pObj) );
270  return;
271  }
272  assert( Gia_ObjIsAnd(pObj) );
273  Frc_ManCollectSuper_rec( p, Gia_ObjFanin0(pObj), vSuper, vVisit );
274  Frc_ManCollectSuper_rec( p, Gia_ObjFanin1(pObj), vSuper, vVisit );
275 
276 }
277 
278 /**Function*************************************************************
279 
280  Synopsis [Collect the fanin IDs.]
281 
282  Description []
283 
284  SideEffects []
285 
286  SeeAlso []
287 
288 ***********************************************************************/
289 void Frc_ManCollectSuper( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper, Vec_Int_t * vVisit )
290 {
291  int Entry, i;
292  Vec_IntClear( vSuper );
293  Vec_IntClear( vVisit );
294  assert( pObj->fMark0 == 1 );
295  pObj->fMark0 = 0;
296  Frc_ManCollectSuper_rec( p, pObj, vSuper, vVisit );
297  pObj->fMark0 = 1;
298  Vec_IntForEachEntry( vVisit, Entry, i )
299  Gia_ManObj(p, Entry)->fMark1 = 0;
300 }
301 
302 /**Function*************************************************************
303 
304  Synopsis [Assigns references while removing the MUX/XOR ones.]
305 
306  Description []
307 
308  SideEffects []
309 
310  SeeAlso []
311 
312 ***********************************************************************/
314 {
315  Gia_Obj_t * pObj, * pFan0, * pFan1;
316  Gia_Obj_t * pObjC, * pObjD0, * pObjD1;
317  int i;
318  assert( p->pRefs == NULL );
319  Gia_ManCleanMark0( p );
320  Gia_ManCreateRefs( p );
321  Gia_ManForEachAnd( p, pObj, i )
322  {
323  assert( pObj->fMark0 == 0 );
324  pFan0 = Gia_ObjFanin0(pObj);
325  pFan1 = Gia_ObjFanin1(pObj);
326  // skip nodes whose fanins are PIs or are already marked
327  if ( Gia_ObjIsCi(pFan0) || pFan0->fMark0 ||
328  Gia_ObjIsCi(pFan1) || pFan1->fMark0 )
329  continue;
330  // skip nodes that are not MUX type
331  if ( !Gia_ObjIsMuxType(pObj) )
332  continue;
333  // the node is MUX type, mark it and its fanins
334  pObj->fMark0 = 1;
335  pFan0->fMark0 = 1;
336  pFan1->fMark0 = 1;
337  // deref the control
338  pObjC = Gia_ObjRecognizeMux( pObj, &pObjD1, &pObjD0 );
339  Gia_ObjRefDec( p, Gia_Regular(pObjC) );
340  if ( Gia_Regular(pObjD0) == Gia_Regular(pObjD1) )
341  Gia_ObjRefDec( p, Gia_Regular(pObjD0) );
342  }
343  Gia_ManForEachAnd( p, pObj, i )
344  assert( Gia_ObjRefNum(p, pObj) > 0 );
345  Gia_ManCleanMark0( p );
346 }
347 
348 /**Function*************************************************************
349 
350  Synopsis [Assigns references while removing the MUX/XOR ones.]
351 
352  Description []
353 
354  SideEffects []
355 
356  SeeAlso []
357 
358 ***********************************************************************/
359 void Frc_ManTransformRefs( Gia_Man_t * p, int * pnObjs, int * pnFanios )
360 {
361  Vec_Int_t * vSuper, * vVisit;
362  Gia_Obj_t * pObj, * pFanin;
363  int i, k, Counter;
364  assert( p->pRefs != NULL );
365 
366  // mark nodes to be used in the logic network
367  Gia_ManCleanMark0( p );
368  Gia_ManConst0(p)->fMark0 = 1;
369  // mark the inputs
370  Gia_ManForEachCi( p, pObj, i )
371  pObj->fMark0 = 1;
372  // mark those nodes that have ref count more than 1
373  Gia_ManForEachAnd( p, pObj, i )
374  pObj->fMark0 = (Gia_ObjRefNum(p, pObj) > 1);
375  // mark the output drivers
376  Gia_ManForEachCoDriver( p, pObj, i )
377  pObj->fMark0 = 1;
378 
379  // count the number of nodes
380  Counter = 0;
381  Gia_ManForEachObj( p, pObj, i )
382  Counter += pObj->fMark0;
383  *pnObjs = Counter + Gia_ManCoNum(p);
384 
385  // reset the references
386  ABC_FREE( p->pRefs );
387  p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) );
388  // reference from internal nodes
389  Counter = 0;
390  vSuper = Vec_IntAlloc( 100 );
391  vVisit = Vec_IntAlloc( 100 );
392  Gia_ManCleanMark1( p );
393  Gia_ManForEachAnd( p, pObj, i )
394  {
395  if ( pObj->fMark0 == 0 )
396  continue;
397  Frc_ManCollectSuper( p, pObj, vSuper, vVisit );
398  Gia_ManForEachObjVec( vSuper, p, pFanin, k )
399  {
400  assert( pFanin->fMark0 );
401  Gia_ObjRefInc( p, pFanin );
402  }
403  Counter += Vec_IntSize( vSuper );
404  }
405  Gia_ManCheckMark1( p );
406  Vec_IntFree( vSuper );
407  Vec_IntFree( vVisit );
408  // reference from outputs
409  Gia_ManForEachCoDriver( p, pObj, i )
410  {
411  assert( pObj->fMark0 );
412  Gia_ObjRefInc( p, pObj );
413  }
414  *pnFanios = Counter + Gia_ManCoNum(p);
415 }
416 
417 /**Function*************************************************************
418 
419  Synopsis [Creates logic network isomorphic to the given AIG.]
420 
421  Description []
422 
423  SideEffects []
424 
425  SeeAlso []
426 
427 ***********************************************************************/
429 {
430  Frc_Man_t * p;
431  Frc_Obj_t * pObjLog, * pFanLog;
432  Gia_Obj_t * pObj, * pFanin;//, * pObjRi, * pObjRo;
433  Vec_Int_t * vSuper, * vVisit;
434  int nObjs, nFanios, nNodes = 0;
435  int i, k, hHandle = 0;
436  // prepare the AIG
437 // Gia_ManCreateRefs( pGia );
438  Frc_ManCreateRefsSpecial( pGia );
439  Frc_ManTransformRefs( pGia, &nObjs, &nFanios );
440  Gia_ManFillValue( pGia );
441  // create logic network
442  p = ABC_CALLOC( Frc_Man_t, 1 );
443  p->pGia = pGia;
444  p->nRegs = Gia_ManRegNum(pGia);
445  p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) );
446  p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
447  p->nObjData = (sizeof(Frc_Obj_t) / 4) * nObjs + 2 * nFanios;
448  p->pObjData = ABC_CALLOC( int, p->nObjData );
449  // create constant node
450  Gia_ManConst0(pGia)->Value = hHandle;
451  pObjLog = Frc_ManObj( p, hHandle );
452  pObjLog->hHandle = hHandle;
453  pObjLog->nFanins = 0;
454  pObjLog->nFanouts = Gia_ObjRefNum( pGia, Gia_ManConst0(pGia) );
455  // count objects
456  hHandle += Frc_ObjSize( pObjLog );
457  nNodes++;
458  p->nObjs++;
459  // create the PIs
460  Gia_ManForEachCi( pGia, pObj, i )
461  {
462  // create PI object
463  pObj->Value = hHandle;
464  Vec_IntPush( p->vCis, hHandle );
465  pObjLog = Frc_ManObj( p, hHandle );
466  pObjLog->hHandle = hHandle;
467  pObjLog->nFanins = 0;
468  pObjLog->nFanouts = Gia_ObjRefNum( pGia, pObj );
469  pObjLog->fCi = 1;
470  // count objects
471  hHandle += Frc_ObjSize( pObjLog );
472  p->nObjs++;
473  }
474  // create internal nodes
475  vSuper = Vec_IntAlloc( 100 );
476  vVisit = Vec_IntAlloc( 100 );
477  Gia_ManForEachAnd( pGia, pObj, i )
478  {
479  if ( pObj->fMark0 == 0 )
480  {
481  assert( Gia_ObjRefNum( pGia, pObj ) == 0 );
482  continue;
483  }
484  assert( Gia_ObjRefNum( pGia, pObj ) > 0 );
485  Frc_ManCollectSuper( pGia, pObj, vSuper, vVisit );
486  // create node object
487  pObj->Value = hHandle;
488  pObjLog = Frc_ManObj( p, hHandle );
489  pObjLog->hHandle = hHandle;
490  pObjLog->nFanins = Vec_IntSize( vSuper );
491  pObjLog->nFanouts = Gia_ObjRefNum( pGia, pObj );
492  // add fanins
493  Gia_ManForEachObjVec( vSuper, pGia, pFanin, k )
494  {
495  pFanLog = Frc_ManObj( p, Gia_ObjValue(pFanin) );
496  Frc_ObjAddFanin( pObjLog, pFanLog );
497  }
498  // count objects
499  hHandle += Frc_ObjSize( pObjLog );
500  nNodes++;
501  p->nObjs++;
502  }
503  Vec_IntFree( vSuper );
504  Vec_IntFree( vVisit );
505  // create the POs
506  Gia_ManForEachCo( pGia, pObj, i )
507  {
508  // create PO object
509  pObj->Value = hHandle;
510  Vec_IntPush( p->vCos, hHandle );
511  pObjLog = Frc_ManObj( p, hHandle );
512  pObjLog->hHandle = hHandle;
513  pObjLog->nFanins = 1;
514  pObjLog->nFanouts = 0;
515  pObjLog->fCo = 1;
516  // add fanins
517  pFanLog = Frc_ManObj( p, Gia_ObjValue(Gia_ObjFanin0(pObj)) );
518  Frc_ObjAddFanin( pObjLog, pFanLog );
519  // count objects
520  hHandle += Frc_ObjSize( pObjLog );
521  p->nObjs++;
522  }
523  // connect registers
524 // Gia_ManForEachRiRo( pGia, pObjRi, pObjRo, i )
525 // Frc_ObjAddFanin( Frc_ManObj(p,Gia_ObjValue(pObjRo)), Frc_ManObj(p,Gia_ObjValue(pObjRi)) );
526  Gia_ManCleanMark0( pGia );
527  assert( nNodes == Frc_ManNodeNum(p) );
528  assert( nObjs == p->nObjs );
529  assert( hHandle == p->nObjData );
530  if ( hHandle != p->nObjData )
531  printf( "Frc_ManStart(): Fatal error in internal representation.\n" );
532  // make sure the fanin/fanout counters are correct
533  Gia_ManForEachObj( pGia, pObj, i )
534  {
535  if ( !~Gia_ObjValue(pObj) )
536  continue;
537  pObjLog = Frc_ManObj( p, Gia_ObjValue(pObj) );
538  assert( pObjLog->nFanins == pObjLog->iFanin );
539  assert( pObjLog->nFanouts == pObjLog->iFanout );
540  pObjLog->iFanin = pObjLog->iFanout = 0;
541  }
542  ABC_FREE( pGia->pRefs );
543  return p;
544 }
545 
546 /**Function*************************************************************
547 
548  Synopsis [Creates logic network isomorphic to the given AIG.]
549 
550  Description []
551 
552  SideEffects []
553 
554  SeeAlso []
555 
556 ***********************************************************************/
558 {
559 // if ( p->pName )
560 // printf( "%8s : ", p->pName );
561  printf( "i/o =%7d/%7d ", Frc_ManPiNum(p), Frc_ManPoNum(p) );
562  if ( Frc_ManRegNum(p) )
563  printf( "ff =%7d ", Frc_ManRegNum(p) );
564  printf( "node =%8d ", Frc_ManNodeNum(p) );
565  printf( "obj =%8d ", Frc_ManObjNum(p) );
566 // printf( "lev =%5d ", Frc_ManLevelNum(p) );
567 // printf( "cut =%5d ", Frc_ManCrossCut(p) );
568  printf( "mem =%5.2f MB", 4.0*p->nObjData/(1<<20) );
569 // printf( "obj =%5d ", Frc_ManObjNum(p) );
570  printf( "\n" );
571 }
572 
573 /**Function*************************************************************
574 
575  Synopsis [Creates logic network isomorphic to the given AIG.]
576 
577  Description []
578 
579  SideEffects []
580 
581  SeeAlso []
582 
583 ***********************************************************************/
585 {
586  Vec_IntFree( p->vCis );
587  Vec_IntFree( p->vCos );
588  ABC_FREE( p->pObjData );
589  ABC_FREE( p );
590 }
591 
592 
593 /**Function*************************************************************
594 
595  Synopsis [Computes cross cut size for the given order of POs.]
596 
597  Description []
598 
599  SideEffects []
600 
601  SeeAlso []
602 
603 ***********************************************************************/
605 {
606  assert( pObj->iFanout > 0 );
607  if ( pObj->iFanout-- == pObj->nFanouts )
608  {
609  Frc_Obj_t * pFanin;
610  int i;
611  p->nCutCur++;
612  p->nCutMax = Abc_MaxInt( p->nCutMax, p->nCutCur );
613  if ( !Frc_ObjIsCi(pObj) )
614  Frc_ObjForEachFanin( pObj, pFanin, i )
615  p->nCutCur -= Frc_ManCrossCut_rec( p, pFanin );
616  }
617  return pObj->iFanout == 0;
618 }
619 
620 /**Function*************************************************************
621 
622  Synopsis [Computes cross cut size for the given order of POs.]
623 
624  Description []
625 
626  SideEffects []
627 
628  SeeAlso []
629 
630 ***********************************************************************/
632 {
633  assert( pObj->iFanout > 0 );
634  if ( pObj->iFanout-- == pObj->nFanouts )
635  {
636  Frc_Obj_t * pFanin;
637  int i;
638  p->nCutCur++;
639  p->nCutMax = Abc_MaxInt( p->nCutMax, p->nCutCur );
640  if ( !Frc_ObjIsCi(pObj) )
641  Frc_ObjForEachFaninReverse( pObj, pFanin, i )
642  p->nCutCur -= Frc_ManCrossCut2_rec( p, pFanin );
643  }
644  return pObj->iFanout == 0;
645 }
646 
647 /**Function*************************************************************
648 
649  Synopsis [Computes cross cut size for the given order of POs.]
650 
651  Description []
652 
653  SideEffects []
654 
655  SeeAlso []
656 
657 ***********************************************************************/
658 int Frc_ManCrossCut( Frc_Man_t * p, Vec_Int_t * vOrder, int fReverse )
659 {
660  Frc_Obj_t * pObj;
661  int i;
662  assert( Vec_IntSize(vOrder) == Frc_ManCoNum(p) );
663  p->nCutCur = 0;
664  p->nCutMax = 0;
665  Frc_ManForEachObj( p, pObj, i )
666  pObj->iFanout = pObj->nFanouts;
667  Frc_ManForEachObjVec( vOrder, p, pObj, i )
668  {
669  assert( Frc_ObjIsCo(pObj) );
670  if ( fReverse )
671  p->nCutCur -= Frc_ManCrossCut2_rec( p, Frc_ObjFanin(pObj,0) );
672  else
673  p->nCutCur -= Frc_ManCrossCut_rec( p, Frc_ObjFanin(pObj,0) );
674  }
675  assert( p->nCutCur == 0 );
676 // Frc_ManForEachObj( p, pObj, i )
677 // assert( pObj->iFanout == 0 );
678  return p->nCutMax;
679 }
680 
681 /**Function*************************************************************
682 
683  Synopsis [Collects CO handles.]
684 
685  Description []
686 
687  SideEffects []
688 
689  SeeAlso []
690 
691 ***********************************************************************/
693 {
694  Vec_Int_t * vCoOrder;
695  Frc_Obj_t * pObj;
696  int i;
697  vCoOrder = Vec_IntAlloc( Frc_ManCoNum(p) );
698  Frc_ManForEachCo( p, pObj, i )
699  Vec_IntPush( vCoOrder, pObj->hHandle );
700  return vCoOrder;
701 }
702 
703 /**Function*************************************************************
704 
705  Synopsis [Computes cross cut size for the given order of POs.]
706 
707  Description []
708 
709  SideEffects []
710 
711  SeeAlso []
712 
713 ***********************************************************************/
714 void Frc_ManCrossCutTest( Frc_Man_t * p, Vec_Int_t * vOrderInit )
715 {
716  Vec_Int_t * vOrder;
717 // abctime clk = Abc_Clock();
718  vOrder = vOrderInit? vOrderInit : Frc_ManCollectCos( p );
719  printf( "CrossCut = %6d\n", Frc_ManCrossCut( p, vOrder, 0 ) );
720  printf( "CrossCut = %6d\n", Frc_ManCrossCut( p, vOrder, 1 ) );
721  Vec_IntReverseOrder( vOrder );
722  printf( "CrossCut = %6d\n", Frc_ManCrossCut( p, vOrder, 0 ) );
723  printf( "CrossCut = %6d\n", Frc_ManCrossCut( p, vOrder, 1 ) );
724  Vec_IntReverseOrder( vOrder );
725  if ( vOrder != vOrderInit )
726  Vec_IntFree( vOrder );
727 // ABC_PRT( "Time", Abc_Clock() - clk );
728 }
729 
730 
731 
732 /**Function*************************************************************
733 
734  Synopsis [Generates random placement.]
735 
736  Description []
737 
738  SideEffects []
739 
740  SeeAlso []
741 
742 ***********************************************************************/
744 {
745  Frc_Obj_t * pThis;
746  int * pPlacement;
747  int i, h, Temp, iNext, Counter;
748  pPlacement = ABC_ALLOC( int, p->nObjs );
749  for ( i = 0; i < p->nObjs; i++ )
750  pPlacement[i] = i;
751  for ( i = 0; i < p->nObjs; i++ )
752  {
753  iNext = Gia_ManRandom( 0 ) % p->nObjs;
754  Temp = pPlacement[i];
755  pPlacement[i] = pPlacement[iNext];
756  pPlacement[iNext] = Temp;
757  }
758  Counter = 0;
759  Frc_ManForEachObj( p, pThis, h )
760  pThis->pPlace = pPlacement[Counter++];
761  ABC_FREE( pPlacement );
762 }
763 
764 /**Function*************************************************************
765 
766  Synopsis [Shuffles array of random integers.]
767 
768  Description []
769 
770  SideEffects []
771 
772  SeeAlso []
773 
774 ***********************************************************************/
776 {
777  int i, iNext, Temp;
778  for ( i = 0; i < vArray->nSize; i++ )
779  {
780  iNext = Gia_ManRandom( 0 ) % vArray->nSize;
781  Temp = vArray->pArray[i];
782  vArray->pArray[i] = vArray->pArray[iNext];
783  vArray->pArray[iNext] = Temp;
784  }
785 }
786 
787 /**Function*************************************************************
788 
789  Synopsis [Computes cross cut size for the given order of POs.]
790 
791  Description []
792 
793  SideEffects []
794 
795  SeeAlso []
796 
797 ***********************************************************************/
798 void Frc_ManPlaceDfs_rec( Frc_Man_t * p, Frc_Obj_t * pObj, int * piPlace )
799 {
800  assert( pObj->iFanout > 0 );
801  if ( pObj->iFanout-- == pObj->nFanouts )
802  {
803  Frc_Obj_t * pFanin;
804  int i;
805  if ( !Frc_ObjIsCi(pObj) )
806  Frc_ObjForEachFanin( pObj, pFanin, i )
807  Frc_ManPlaceDfs_rec( p, pFanin, piPlace );
808  pObj->pPlace = (*piPlace)++;
809  }
810 }
811 
812 /**Function*************************************************************
813 
814  Synopsis [Generates DFS placement.]
815 
816  Description []
817 
818  SideEffects []
819 
820  SeeAlso []
821 
822 ***********************************************************************/
823 void Frc_ManPlaceDfs( Frc_Man_t * p, Vec_Int_t * vCoOrder )
824 {
825  Frc_Obj_t * pObj;
826  int i, nPlaces = 0;
827  Frc_ManForEachObj( p, pObj, i )
828  {
829  pObj->iFanout = pObj->nFanouts;
830  if ( pObj->nFanouts == 0 && !Frc_ObjIsCo(pObj) )
831  pObj->pPlace = nPlaces++;
832  }
833  Frc_ManForEachObjVec( vCoOrder, p, pObj, i )
834  {
835  assert( Frc_ObjIsCo(pObj) );
836  Frc_ManPlaceDfs_rec( p, Frc_ObjFanin(pObj,0), &nPlaces );
837  pObj->pPlace = nPlaces++;
838  }
839  assert( nPlaces == p->nObjs );
840 }
841 
842 /**Function*************************************************************
843 
844  Synopsis [Generates DFS placement by trying both orders.]
845 
846  Description [Returns the cross cut size of the best order. ]
847 
848  SideEffects []
849 
850  SeeAlso []
851 
852 ***********************************************************************/
853 int Frc_ManPlaceDfsBoth( Frc_Man_t * p, Vec_Int_t * vCoOrder, int * piCutSize2 )
854 {
855  int nCutStart1, nCutStart2;
856  nCutStart1 = Frc_ManCrossCut( p, vCoOrder, 0 );
857  Vec_IntReverseOrder( vCoOrder );
858  nCutStart2 = Frc_ManCrossCut( p, vCoOrder, 0 );
859  if ( nCutStart1 <= nCutStart2 )
860  {
861  Vec_IntReverseOrder( vCoOrder ); // undo
862  Frc_ManPlaceDfs( p, vCoOrder );
863  *piCutSize2 = nCutStart2;
864  return nCutStart1;
865  }
866  else
867  {
868  Frc_ManPlaceDfs( p, vCoOrder );
869  Vec_IntReverseOrder( vCoOrder ); // undo
870  *piCutSize2 = nCutStart1;
871  return nCutStart2;
872  }
873 }
874 
875 /**Function*************************************************************
876 
877  Synopsis [Performs iterative refinement of the given placement.]
878 
879  Description []
880 
881  SideEffects []
882 
883  SeeAlso []
884 
885 ***********************************************************************/
886 void Frc_ManPlacementRefine( Frc_Man_t * p, int nIters, int fVerbose )
887 {
888  int fRandomize = 0;
889  Vec_Int_t * vCoOrder;
890  Frc_Obj_t * pThis, * pNext;
891  double CostThis, CostPrev;
892  float * pVertX, VertX;
893  int * pPermX, * pHandles;
894  int k, h, Iter, iMinX, iMaxX, Counter, nCutStart, nCutCur, nCutCur2, nCutPrev;
895  abctime clk = Abc_Clock(), clk2, clk2Total = 0;
896  // create starting one-dimensional placement
897  vCoOrder = Frc_ManCollectCos( p );
898  if ( fRandomize )
899  Frc_ManArrayShuffle( vCoOrder );
900  nCutStart = Frc_ManPlaceDfsBoth( p, vCoOrder, &nCutCur2 );
901  // refine placement
902  CostPrev = 0.0;
903  nCutPrev = nCutStart;
904  pHandles = ABC_ALLOC( int, p->nObjs );
905  pVertX = ABC_ALLOC( float, p->nObjs );
906  for ( Iter = 0; Iter < nIters; Iter++ )
907  {
908  // compute centers of hyperedges
909  CostThis = 0.0;
910  Frc_ManForEachObj( p, pThis, h )
911  {
912  iMinX = iMaxX = pThis->pPlace;
913  Frc_ObjForEachFanout( pThis, pNext, k )
914  {
915  iMinX = Abc_MinInt( iMinX, pNext->pPlace );
916  iMaxX = Abc_MaxInt( iMaxX, pNext->pPlace );
917  }
918  pThis->fEdgeCenter = 0.5 * (iMaxX + iMinX);
919  CostThis += (iMaxX - iMinX);
920  }
921  // compute new centers of objects
922  Counter = 0;
923  Frc_ManForEachObj( p, pThis, h )
924  {
925  VertX = pThis->fEdgeCenter;
926  Frc_ObjForEachFanin( pThis, pNext, k )
927  VertX += pNext->fEdgeCenter;
928  pVertX[Counter] = VertX / (Frc_ObjFaninNum(pThis) + 1);
929  pHandles[Counter++] = h;
930  }
931  assert( Counter == Frc_ManObjNum(p) );
932  // sort these numbers
933  clk2 = Abc_Clock();
934  pPermX = Gia_SortFloats( pVertX, pHandles, p->nObjs );
935  clk2Total += Abc_Clock() - clk2;
936  assert( pPermX == pHandles );
937  Vec_IntClear( vCoOrder );
938  for ( k = 0; k < p->nObjs; k++ )
939  {
940  pThis = Frc_ManObj( p, pPermX[k] );
941  pThis->pPlace = k;
942  if ( Frc_ObjIsCo(pThis) )
943  Vec_IntPush( vCoOrder, pThis->hHandle );
944  }
945 /*
946  printf( "Ordering of PIs:\n" );
947  Frc_ManForEachCi( p, pThis, k )
948  printf( "PI number = %7d. Object handle = %7d, Coordinate = %7d.\n",
949  k, pThis->hHandle, pThis->pPlace );
950 */
951  nCutCur = Frc_ManPlaceDfsBoth( p, vCoOrder, &nCutCur2 );
952  // evaluate cost
953  if ( fVerbose )
954  {
955  printf( "%2d : Span = %e ", Iter+1, CostThis );
956  printf( "Cut = %6d (%5.2f %%) CutR = %6d ", nCutCur, 100.0*(nCutStart-nCutCur)/nCutStart, nCutCur2 );
957  ABC_PRTn( "Total", Abc_Clock() - clk );
958  ABC_PRT( "Sort", clk2Total );
959 // Frc_ManCrossCutTest( p, vCoOrder );
960  }
961 // if ( 1.0 * nCutPrev / nCutCur < 1.001 )
962 // break;
963  nCutPrev = nCutCur;
964  }
965  ABC_FREE( pHandles );
966  ABC_FREE( pVertX );
967  Vec_IntFree( vCoOrder );
968 }
969 
970 /**Function*************************************************************
971 
972  Synopsis [Returns 1 if all fanouts are COsw.]
973 
974  Description []
975 
976  SideEffects []
977 
978  SeeAlso []
979 
980 ***********************************************************************/
982 {
983  Frc_Obj_t * pNext;
984  int i;
985  Frc_ObjForEachFanout( pThis, pNext, i )
986  if ( !Frc_ObjIsCo(pNext) )
987  return 0;
988  return 1;
989 }
990 
991 /**Function*************************************************************
992 
993  Synopsis [Computes the distances from the given set of objects.]
994 
995  Description [Returns one of the most distant objects.]
996 
997  SideEffects []
998 
999  SeeAlso []
1000 
1001 ***********************************************************************/
1003 {
1004  FILE * pFile;
1005  Frc_Obj_t * pThis, * pNext;
1006  int i, k, Counter = 0;
1007  // assign numbers to CIs and internal nodes
1008  Frc_ManForEachObj( p, pThis, i )
1009  {
1010  if ( i && ((Frc_ObjIsCi(pThis) && !Frc_ObjFanoutsAreCos(pThis)) || Frc_ObjIsNode(pThis)) )
1011  pThis->iFanin = Counter++;
1012  else
1013  pThis->iFanin = ~0;
1014  }
1015  // assign numbers to all other nodes
1016  pFile = fopen( "x\\large\\aig\\dg1.g", "w" );
1017  Frc_ManForEachObj( p, pThis, i )
1018  {
1019  Frc_ObjForEachFanout( pThis, pNext, k )
1020  {
1021  if ( ~pThis->iFanin && ~pNext->iFanin )
1022  fprintf( pFile, "%d %d\n", pThis->iFanin, pNext->iFanin );
1023  }
1024  }
1025  fclose( pFile );
1026 }
1027 
1028 /**Function*************************************************************
1029 
1030  Synopsis [Experiment with the FORCE algorithm.]
1031 
1032  Description []
1033 
1034  SideEffects []
1035 
1036  SeeAlso []
1037 
1038 ***********************************************************************/
1039 void For_ManExperiment( Gia_Man_t * pGia, int nIters, int fClustered, int fVerbose )
1040 {
1041  Frc_Man_t * p;
1042  Gia_ManRandom( 1 );
1043  if ( fClustered )
1044  p = Frc_ManStart( pGia );
1045  else
1046  p = Frc_ManStartSimple( pGia );
1047 // Frc_DumpGraphIntoFile( p );
1048  if ( fVerbose )
1049  Frc_ManPrintStats( p );
1050 // Frc_ManCrossCutTest( p, NULL );
1051  Frc_ManPlacementRefine( p, nIters, fVerbose );
1052  Frc_ManStop( p );
1053 }
1054 
1055 /**Function*************************************************************
1056 
1057  Synopsis [Experiment with the FORCE algorithm.]
1058 
1059  Description []
1060 
1061  SideEffects []
1062 
1063  SeeAlso []
1064 
1065 ***********************************************************************/
1067 {
1068  FILE * pFile;
1069  int * pBuffer;
1070  int i, Size, Exp = 25;
1071  abctime clk = Abc_Clock();
1072  int RetValue;
1073 
1074  Size = (1 << Exp);
1075  printf( "2^%d machine words (%d bytes).\n", Exp, (int)sizeof(int) * Size );
1076 
1077  pBuffer = ABC_ALLOC( int, Size );
1078  for ( i = 0; i < Size; i++ )
1079  pBuffer[i] = i;
1080 ABC_PRT( "Fillup", Abc_Clock() - clk );
1081 
1082 clk = Abc_Clock();
1083  pFile = fopen( "test.txt", "rb" );
1084  RetValue = fread( pBuffer, 1, sizeof(int) * Size, pFile );
1085  fclose( pFile );
1086 ABC_PRT( "Read ", Abc_Clock() - clk );
1087 
1088 clk = Abc_Clock();
1089  pFile = fopen( "test.txt", "wb" );
1090  fwrite( pBuffer, 1, sizeof(int) * Size, pFile );
1091  fclose( pFile );
1092 ABC_PRT( "Write ", Abc_Clock() - clk );
1093 /*
1094 2^25 machine words (134217728 bytes).
1095 Fillup = 0.06 sec
1096 Read = 0.08 sec
1097 Write = 1.81 sec
1098 */
1099 }
1100 
1101 ////////////////////////////////////////////////////////////////////////
1102 /// END OF FILE ///
1103 ////////////////////////////////////////////////////////////////////////
1104 
1106 
#define Frc_ObjForEachFanout(pObj, pNext, i)
Definition: giaForce.c:112
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
Frc_Man_t * Frc_ManStartSimple(Gia_Man_t *pGia)
Definition: giaForce.c:150
int nObjData
Definition: giaForce.c:64
static int Frc_ObjFanoutNum(Frc_Obj_t *pObj)
Definition: giaForce.c:92
static int Frc_ObjIsConst0(Frc_Obj_t *pObj)
Definition: giaForce.c:88
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
unsigned fCo
Definition: giaForce.c:40
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Frc_Obj_t * Frc_ManObj(Frc_Man_t *p, int hHandle)
Definition: giaForce.c:78
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
Frc_Man_t * Frc_ManStart(Gia_Man_t *pGia)
Definition: giaForce.c:428
int nCutMax
Definition: giaForce.c:67
int * pObjData
Definition: giaForce.c:63
static Frc_Obj_t * Frc_ManCo(Frc_Man_t *p, int i)
Definition: giaForce.c:80
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition: giaUtil.c:215
int Fanios[0]
Definition: giaForce.c:52
static int Frc_ObjIsCo(Frc_Obj_t *pObj)
Definition: giaForce.c:84
unsigned nFanouts
Definition: giaForce.c:44
int Frc_ManCrossCut2_rec(Frc_Man_t *p, Frc_Obj_t *pObj)
Definition: giaForce.c:631
static int Frc_ObjIsNode(Frc_Obj_t *pObj)
Definition: giaForce.c:87
void For_ManExperiment(Gia_Man_t *pGia, int nIters, int fClustered, int fVerbose)
Definition: giaForce.c:1039
unsigned iFanin
Definition: giaForce.c:50
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
void Frc_ManPlaceRandom(Frc_Man_t *p)
Definition: giaForce.c:743
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
static int Frc_ManNodeNum(Frc_Man_t *p)
Definition: giaForce.c:76
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Frc_ObjForEachFaninReverse(pObj, pNext, i)
Definition: giaForce.c:110
unsigned fMark1
Definition: gia.h:84
void Frc_ManArrayShuffle(Vec_Int_t *vArray)
Definition: giaForce.c:775
#define Frc_ObjForEachFanin(pObj, pNext, i)
Definition: giaForce.c:108
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
#define Gia_ManForEachCoDriver(p, pObj, i)
Definition: gia.h:1030
int hHandle
Definition: giaForce.c:46
unsigned nFanins
Definition: giaForce.c:43
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
int fVerbose
Definition: giaForce.c:65
int Frc_ManPlaceDfsBoth(Frc_Man_t *p, Vec_Int_t *vCoOrder, int *piCutSize2)
Definition: giaForce.c:853
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
void Gia_ManCleanMark1(Gia_Man_t *p)
Definition: giaUtil.c:272
int pPlace
Definition: giaForce.c:47
void Frc_ManPrintStats(Frc_Man_t *p)
Definition: giaForce.c:557
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49
void Frc_ManCollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, Vec_Int_t *vVisit)
Definition: giaForce.c:289
Vec_Int_t * Frc_ManCollectCos(Frc_Man_t *p)
Definition: giaForce.c:692
int Frc_ManCrossCut_rec(Frc_Man_t *p, Frc_Obj_t *pObj)
Definition: giaForce.c:604
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static int Frc_ObjSize(Frc_Obj_t *pObj)
Definition: giaForce.c:90
void Frc_ManPlaceDfs_rec(Frc_Man_t *p, Frc_Obj_t *pObj, int *piPlace)
Definition: giaForce.c:798
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static Frc_Obj_t * Frc_ManCi(Frc_Man_t *p, int i)
Definition: giaForce.c:79
void Gia_ManCheckMark1(Gia_Man_t *p)
Definition: giaUtil.c:291
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Frc_ManCiNum(Frc_Man_t *p)
Definition: giaForce.c:71
static int Frc_ManRegNum(Frc_Man_t *p)
Definition: giaForce.c:70
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
unsigned iFanout
Definition: giaForce.c:45
Gia_Man_t * pGia
Definition: giaForce.c:58
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void For_ManFileExperiment()
Definition: giaForce.c:1066
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
void Frc_DumpGraphIntoFile(Frc_Man_t *p)
Definition: giaForce.c:1002
void Frc_ManCollectSuper_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, Vec_Int_t *vVisit)
Definition: giaForce.c:261
int nCutCur
Definition: giaForce.c:66
unsigned fMark0
Definition: giaForce.c:41
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
#define Frc_ManForEachCo(p, pObj, i)
Definition: giaForce.c:105
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Frc_Obj_t * Frc_ObjFanin(Frc_Obj_t *pObj, int i)
Definition: giaForce.c:93
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Counter
typedefABC_NAMESPACE_IMPL_START struct Frc_Obj_t_ Frc_Obj_t
DECLARATIONS ///.
Definition: giaForce.c:36
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
Vec_Int_t * vCis
Definition: giaForce.c:59
static int Frc_ObjIsPo(Frc_Obj_t *pObj)
Definition: giaForce.c:86
#define Frc_ManForEachObjVec(vVec, p, pObj, i)
Definition: giaForce.c:98
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
#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
float fEdgeCenter
Definition: giaForce.c:49
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
int Frc_ObjFanoutsAreCos(Frc_Obj_t *pThis)
Definition: giaForce.c:981
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nRegs
Definition: giaForce.c:62
Vec_Int_t * vCos
Definition: giaForce.c:60
void Frc_ManPlacementRefine(Frc_Man_t *p, int nIters, int fVerbose)
Definition: giaForce.c:886
unsigned fMark0
Definition: gia.h:79
static int Frc_ManPoNum(Frc_Man_t *p)
Definition: giaForce.c:74
#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
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Frc_ManCreateRefsSpecial(Gia_Man_t *p)
Definition: giaForce.c:313
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
int Frc_ManCrossCut(Frc_Man_t *p, Vec_Int_t *vOrder, int fReverse)
Definition: giaForce.c:658
unsigned fCi
Definition: giaForce.c:39
#define Frc_ManForEachObj(p, pObj, i)
Definition: giaForce.c:96
int * Gia_SortFloats(float *pArray, int *pPerm, int nSize)
Definition: giaSort.c:251
static int Frc_ObjIsCi(Frc_Obj_t *pObj)
Definition: giaForce.c:83
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
void Frc_ManStop(Frc_Man_t *p)
Definition: giaForce.c:584
static int Frc_ManPiNum(Frc_Man_t *p)
Definition: giaForce.c:73
#define ABC_PRTn(a, t)
Definition: abc_global.h:222
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Frc_ObjFaninNum(Frc_Obj_t *pObj)
Definition: giaForce.c:91
int nObjs
Definition: giaForce.c:61
static int Frc_ManCoNum(Frc_Man_t *p)
Definition: giaForce.c:72
static int Frc_ObjIsTerm(Frc_Obj_t *pObj)
Definition: giaForce.c:82
static int Frc_ManObjNum(Frc_Man_t *p)
Definition: giaForce.c:75
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Frc_ManPlaceDfs(Frc_Man_t *p, Vec_Int_t *vCoOrder)
Definition: giaForce.c:823
static Frc_Obj_t * Frc_ObjFanout(Frc_Obj_t *pObj, int i)
Definition: giaForce.c:94
void Frc_ManCrossCutTest(Frc_Man_t *p, Vec_Int_t *vOrderInit)
Definition: giaForce.c:714
static int Frc_ObjIsPi(Frc_Obj_t *pObj)
Definition: giaForce.c:85
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
void Frc_ObjAddFanin(Frc_Obj_t *pObj, Frc_Obj_t *pFanin)
FUNCTION DEFINITIONS ///.
Definition: giaForce.c:131
void Frc_ManTransformRefs(Gia_Man_t *p, int *pnObjs, int *pnFanios)
Definition: giaForce.c:359
unsigned fMark1
Definition: giaForce.c:42
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387