abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaDup.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [giaDup.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Scalable AIG package.]
8 
9  Synopsis [Duplication procedures.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: giaDup.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "gia.h"
22 #include "misc/tim/tim.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis [Removes pointers to the unmarked nodes..]
38 
39  Description []
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
47 {
48  Vec_Int_t * vClass;
49  int i, k, iNode, iRepr, iPrev;
50  if ( p->pReprs == NULL )
51  return;
52  assert( pNew->pReprs == NULL && pNew->pNexts == NULL );
53  // start representatives
54  pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pNew) );
55  for ( i = 0; i < Gia_ManObjNum(pNew); i++ )
56  Gia_ObjSetRepr( pNew, i, GIA_VOID );
57  // iterate over constant candidates
58  Gia_ManForEachConst( p, i )
59  Gia_ObjSetRepr( pNew, Abc_Lit2Var(Gia_ManObj(p, i)->Value), 0 );
60  // iterate over class candidates
61  vClass = Vec_IntAlloc( 100 );
62  Gia_ManForEachClass( p, i )
63  {
64  Vec_IntClear( vClass );
65  Gia_ClassForEachObj( p, i, k )
66  Vec_IntPushUnique( vClass, Abc_Lit2Var(Gia_ManObj(p, k)->Value) );
67  assert( Vec_IntSize( vClass ) > 1 );
68  Vec_IntSort( vClass, 0 );
69  iRepr = iPrev = Vec_IntEntry( vClass, 0 );
70  Vec_IntForEachEntryStart( vClass, iNode, k, 1 )
71  {
72  Gia_ObjSetRepr( pNew, iNode, iRepr );
73  assert( iPrev < iNode );
74  iPrev = iNode;
75  }
76  }
77  Vec_IntFree( vClass );
78  pNew->pNexts = Gia_ManDeriveNexts( pNew );
79 }
80 
81 /**Function*************************************************************
82 
83  Synopsis [Remaps combinational inputs when objects are DFS ordered.]
84 
85  Description []
86 
87  SideEffects []
88 
89  SeeAlso []
90 
91 ***********************************************************************/
93 {
94  Gia_Obj_t * pObj, * pObjNew;
95  int i;
96  assert( Vec_IntSize(p->vCis) == Vec_IntSize(pNew->vCis) );
97  Gia_ManForEachCi( p, pObj, i )
98  {
99  assert( Gia_ObjCioId(pObj) == i );
100  pObjNew = Gia_ObjFromLit( pNew, pObj->Value );
101  assert( !Gia_IsComplement(pObjNew) );
102  Vec_IntWriteEntry( pNew->vCis, i, Gia_ObjId(pNew, pObjNew) );
103  Gia_ObjSetCioId( pObjNew, i );
104  }
105 }
106 
107 /**Function*************************************************************
108 
109  Synopsis [Remaps combinational outputs when objects are DFS ordered.]
110 
111  Description []
112 
113  SideEffects []
114 
115  SeeAlso []
116 
117 ***********************************************************************/
119 {
120  Gia_Obj_t * pObj, * pObjNew;
121  int i;
122  assert( Vec_IntSize(p->vCos) == Vec_IntSize(pNew->vCos) );
123  Gia_ManForEachCo( p, pObj, i )
124  {
125  assert( Gia_ObjCioId(pObj) == i );
126  pObjNew = Gia_ObjFromLit( pNew, pObj->Value );
127  assert( !Gia_IsComplement(pObjNew) );
128  Vec_IntWriteEntry( pNew->vCos, i, Gia_ObjId(pNew, pObjNew) );
129  Gia_ObjSetCioId( pObjNew, i );
130  }
131 }
132 
133 /**Function*************************************************************
134 
135  Synopsis [Duplicates the AIG in the DFS order.]
136 
137  Description []
138 
139  SideEffects []
140 
141  SeeAlso []
142 
143 ***********************************************************************/
145 {
146  if ( ~pObj->Value )
147  return pObj->Value;
148  if ( Gia_ObjIsCi(pObj) )
149  return pObj->Value = Gia_ManAppendCi(pNew);
150 // if ( p->pNexts && Gia_ObjNext(p, Gia_ObjId(p, pObj)) )
151 // Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjNextObj(p, Gia_ObjId(p, pObj)) );
152  Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
153  if ( Gia_ObjIsCo(pObj) )
154  return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
155  Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin1(pObj) );
156  return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
157 }
158 
159 /**Function*************************************************************
160 
161  Synopsis [Duplicates AIG while putting objects in the DFS order.]
162 
163  Description []
164 
165  SideEffects []
166 
167  SeeAlso []
168 
169 ***********************************************************************/
171 {
172  Gia_Man_t * pNew;
173  Gia_Obj_t * pObj;
174  int i;
175  Gia_ManFillValue( p );
176  pNew = Gia_ManStart( Gia_ManObjNum(p) );
177  pNew->pName = Abc_UtilStrsav( p->pName );
178  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
179  Gia_ManConst0(p)->Value = 0;
180  Gia_ManForEachCo( p, pObj, i )
181  Gia_ManDupOrderDfs_rec( pNew, p, pObj );
182  Gia_ManForEachCi( p, pObj, i )
183  if ( !~pObj->Value )
184  pObj->Value = Gia_ManAppendCi(pNew);
185  assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(p) );
186  Gia_ManDupRemapCis( pNew, p );
187  Gia_ManDupRemapEquiv( pNew, p );
188  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
189  return pNew;
190 }
191 
192 /**Function*************************************************************
193 
194  Synopsis [Duplicates AIG while putting objects in the DFS order.]
195 
196  Description []
197 
198  SideEffects []
199 
200  SeeAlso []
201 
202 ***********************************************************************/
203 Gia_Man_t * Gia_ManDupOutputGroup( Gia_Man_t * p, int iOutStart, int iOutStop )
204 {
205  Gia_Man_t * pNew;
206  Gia_Obj_t * pObj;
207  int i;
208  Gia_ManFillValue( p );
209  pNew = Gia_ManStart( Gia_ManObjNum(p) );
210  pNew->pName = Abc_UtilStrsav( p->pName );
211  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
212  Gia_ManConst0(p)->Value = 0;
213  for ( i = iOutStart; i < iOutStop; i++ )
214  {
215  pObj = Gia_ManCo( p, i );
216  Gia_ManDupOrderDfs_rec( pNew, p, pObj );
217  }
218  return pNew;
219 }
220 
221 /**Function*************************************************************
222 
223  Synopsis [Duplicates AIG while putting objects in the DFS order.]
224 
225  Description []
226 
227  SideEffects []
228 
229  SeeAlso []
230 
231 ***********************************************************************/
233 {
234  Gia_Man_t * pNew;
235  Gia_Obj_t * pObj;
236  int i;
237  assert( Gia_ManRegNum(p) == 0 );
238  assert( Gia_ManPoNum(p) == Vec_IntSize(vOutPres) );
239  Gia_ManFillValue( p );
240  pNew = Gia_ManStart( Gia_ManObjNum(p) );
241  pNew->pName = Abc_UtilStrsav( p->pName );
242  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
243  Gia_ManConst0(p)->Value = 0;
244  Gia_ManForEachPi( p, pObj, i )
245  pObj->Value = Gia_ManAppendCi(pNew);
246  Gia_ManForEachPo( p, pObj, i )
247  if ( Vec_IntEntry(vOutPres, i) )
248  Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
249  Gia_ManForEachPo( p, pObj, i )
250  if ( Vec_IntEntry(vOutPres, i) )
251  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
252  return pNew;
253 }
254 
255 /**Function*************************************************************
256 
257  Synopsis [Duplicates AIG while putting objects in the DFS order.]
258 
259  Description []
260 
261  SideEffects []
262 
263  SeeAlso []
264 
265 ***********************************************************************/
267 {
268  Gia_Man_t * pNew;
269  Gia_Obj_t * pObj;
270  int i, iOut;
271  assert( Gia_ManRegNum(p) == 0 );
272  assert( Gia_ManPoNum(p) >= Vec_IntSize(vOutsLeft) );
273  Gia_ManFillValue( p );
274  pNew = Gia_ManStart( Gia_ManObjNum(p) );
275  pNew->pName = Abc_UtilStrsav( p->pName );
276  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
277  Gia_ManConst0(p)->Value = 0;
278  Gia_ManForEachPi( p, pObj, i )
279  pObj->Value = Gia_ManAppendCi(pNew);
280  Vec_IntForEachEntry( vOutsLeft, iOut, i )
281  Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(Gia_ManPo(p, iOut)) );
282  Vec_IntForEachEntry( vOutsLeft, iOut, i )
283  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManPo(p, iOut)) );
284  return pNew;
285 }
286 
287 /**Function*************************************************************
288 
289  Synopsis [Duplicates the AIG in the DFS order.]
290 
291  Description []
292 
293  SideEffects []
294 
295  SeeAlso []
296 
297 ***********************************************************************/
299 {
300  Gia_Obj_t * pNext;
301  if ( ~pObj->Value )
302  return;
303  assert( Gia_ObjIsAnd(pObj) );
304  pNext = Gia_ObjNextObj( p, Gia_ObjId(p, pObj) );
305  if ( pNext )
306  Gia_ManDupOrderDfsChoices_rec( pNew, p, pNext );
309  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
310  if ( pNext )
311  {
312  pNew->pNexts[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var( Abc_Lit2Var(pNext->Value) );
313  assert( Abc_Lit2Var(pObj->Value) > Abc_Lit2Var(pNext->Value) );
314  }
315 }
316 
317 /**Function*************************************************************
318 
319  Synopsis [Duplicates AIG while putting objects in the DFS order.]
320 
321  Description []
322 
323  SideEffects []
324 
325  SeeAlso []
326 
327 ***********************************************************************/
329 {
330  Gia_Man_t * pNew;
331  Gia_Obj_t * pObj;
332  int i;
333  assert( p->pReprs && p->pNexts );
334  Gia_ManFillValue( p );
335  pNew = Gia_ManStart( Gia_ManObjNum(p) );
336  pNew->pName = Abc_UtilStrsav( p->pName );
337  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
338  pNew->pNexts = ABC_CALLOC( int, Gia_ManObjNum(p) );
339  Gia_ManConst0(p)->Value = 0;
340  Gia_ManForEachCi( p, pObj, i )
341  pObj->Value = Gia_ManAppendCi(pNew);
342  Gia_ManForEachCo( p, pObj, i )
343  {
345  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
346  }
347  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
348 // Gia_ManDeriveReprs( pNew );
349  return pNew;
350 }
351 
352 /**Function*************************************************************
353 
354  Synopsis [Duplicates AIG while putting objects in the DFS order.]
355 
356  Description []
357 
358  SideEffects []
359 
360  SeeAlso []
361 
362 ***********************************************************************/
364 {
365  Gia_Man_t * pNew;
366  Gia_Obj_t * pObj;
367  int i;
368  Gia_ManFillValue( p );
369  pNew = Gia_ManStart( Gia_ManObjNum(p) );
370  pNew->pName = Abc_UtilStrsav( p->pName );
371  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
372  Gia_ManConst0(p)->Value = 0;
373  Gia_ManForEachCoReverse( p, pObj, i )
374  Gia_ManDupOrderDfs_rec( pNew, p, pObj );
375  Gia_ManForEachCi( p, pObj, i )
376  if ( !~pObj->Value )
377  pObj->Value = Gia_ManAppendCi(pNew);
378  assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(p) );
379  Gia_ManDupRemapCis( pNew, p );
380  Gia_ManDupRemapCos( pNew, p );
381  Gia_ManDupRemapEquiv( pNew, p );
382  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
383  return pNew;
384 }
385 
386 /**Function*************************************************************
387 
388  Synopsis [Duplicates AIG while putting first PIs, then nodes, then POs.]
389 
390  Description []
391 
392  SideEffects []
393 
394  SeeAlso []
395 
396 ***********************************************************************/
398 {
399  Gia_Man_t * pNew;
400  Gia_Obj_t * pObj;
401  int i;
402  pNew = Gia_ManStart( Gia_ManObjNum(p) );
403  pNew->pName = Abc_UtilStrsav( p->pName );
404  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
405  Gia_ManConst0(p)->Value = 0;
406  Gia_ManForEachCi( p, pObj, i )
407  pObj->Value = Gia_ManAppendCi(pNew);
408  Gia_ManForEachAnd( p, pObj, i )
409  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
410  Gia_ManForEachCo( p, pObj, i )
411  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
412  Gia_ManDupRemapEquiv( pNew, p );
413  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
414  assert( Gia_ManIsNormalized(pNew) );
415  return pNew;
416 }
417 
418 /**Function*************************************************************
419 
420  Synopsis [Duplicates AIG while putting first PIs, then nodes, then POs.]
421 
422  Description []
423 
424  SideEffects []
425 
426  SeeAlso []
427 
428 ***********************************************************************/
430 {
431  Gia_Man_t * pNew;
432  Gia_Obj_t * pObj;
433  int i;
434  assert( Gia_ManRegNum(p) == 0 );
435  pNew = Gia_ManStart( Gia_ManObjNum(p) );
436  pNew->pName = Abc_UtilStrsav( p->pName );
437  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
438  Gia_ManConst0(p)->Value = 0;
439  Gia_ManForEachCi( p, pObj, i )
440  pObj->Value = (i < Gia_ManCiNum(p) - nLastPis) ? ~0 : Gia_ManAppendCi(pNew);
441  Gia_ManForEachAnd( p, pObj, i )
442  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
443  Gia_ManForEachCo( p, pObj, i )
444  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
445  return pNew;
446 }
447 
448 /**Function*************************************************************
449 
450  Synopsis [Duplicates AIG while complementing the flops.]
451 
452  Description [The array of initial state contains the init state
453  for each state bit of the flops in the design.]
454 
455  SideEffects []
456 
457  SeeAlso []
458 
459 ***********************************************************************/
460 Gia_Man_t * Gia_ManDupFlip( Gia_Man_t * p, int * pInitState )
461 {
462  Gia_Man_t * pNew;
463  Gia_Obj_t * pObj;
464  int i;
465  pNew = Gia_ManStart( Gia_ManObjNum(p) );
466  pNew->pName = Abc_UtilStrsav( p->pName );
467  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
468  Gia_ManConst0(p)->Value = 0;
469  Gia_ManForEachObj1( p, pObj, i )
470  {
471  if ( Gia_ObjIsAnd(pObj) )
472  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
473  else if ( Gia_ObjIsCi(pObj) )
474  {
475  pObj->Value = Gia_ManAppendCi( pNew );
476  if ( Gia_ObjCioId(pObj) >= Gia_ManPiNum(p) )
477  pObj->Value = Abc_LitNotCond( pObj->Value, Abc_InfoHasBit((unsigned *)pInitState, Gia_ObjCioId(pObj) - Gia_ManPiNum(p)) );
478  }
479  else if ( Gia_ObjIsCo(pObj) )
480  {
481  pObj->Value = Gia_ObjFanin0Copy(pObj);
482  if ( Gia_ObjCioId(pObj) >= Gia_ManPoNum(p) )
483  pObj->Value = Abc_LitNotCond( pObj->Value, Abc_InfoHasBit((unsigned *)pInitState, Gia_ObjCioId(pObj) - Gia_ManPoNum(p)) );
484  pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
485  }
486  }
487  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
488  return pNew;
489 }
490 
491 
492 /**Function*************************************************************
493 
494  Synopsis [Cycles AIG using random input.]
495 
496  Description []
497 
498  SideEffects []
499 
500  SeeAlso []
501 
502 ***********************************************************************/
503 void Gia_ManCycle( Gia_Man_t * p, Abc_Cex_t * pCex, int nFrames )
504 {
505  Gia_Obj_t * pObj, * pObjRi, * pObjRo;
506  int i, k;
507  Gia_ManRandom( 1 );
508  assert( pCex == NULL || nFrames <= pCex->iFrame );
509  // iterate for the given number of frames
510  for ( i = 0; i < nFrames; i++ )
511  {
512  Gia_ManForEachPi( p, pObj, k )
513  pObj->fMark0 = pCex ? Abc_InfoHasBit(pCex->pData, pCex->nRegs+i*pCex->nPis+k) : (1 & Gia_ManRandom(0));
514  Gia_ManForEachAnd( p, pObj, k )
515  pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) &
516  (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
517  Gia_ManForEachCo( p, pObj, k )
518  pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
519  Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
520  pObjRo->fMark0 = pObjRi->fMark0;
521  }
522 }
523 Gia_Man_t * Gia_ManDupCycled( Gia_Man_t * p, Abc_Cex_t * pCex, int nFrames )
524 {
525  Gia_Man_t * pNew;
526  Vec_Bit_t * vInits;
527  Gia_Obj_t * pObj;
528  int i;
530  Gia_ManCycle( p, pCex, nFrames );
531  vInits = Vec_BitAlloc( Gia_ManRegNum(p) );
532  Gia_ManForEachRo( p, pObj, i )
533  Vec_BitPush( vInits, pObj->fMark0 );
534  pNew = Gia_ManDupFlip( p, Vec_BitArray(vInits) );
535  Vec_BitFree( vInits );
537  return pNew;
538 }
539 
540 
541 /**Function*************************************************************
542 
543  Synopsis [Duplicates AIG without any changes.]
544 
545  Description []
546 
547  SideEffects []
548 
549  SeeAlso []
550 
551 ***********************************************************************/
553 {
554  Gia_Man_t * pNew;
555  Gia_Obj_t * pObj;
556  int i;
557  pNew = Gia_ManStart( Gia_ManObjNum(p) );
558  pNew->pName = Abc_UtilStrsav( p->pName );
559  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
560  if ( Gia_ManHasChoices(p) )
561  pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) );
562  Gia_ManConst0(p)->Value = 0;
563  Gia_ManForEachObj1( p, pObj, i )
564  {
565  if ( Gia_ObjIsBuf(pObj) )
566  pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
567  else if ( Gia_ObjIsAnd(pObj) )
568  {
569  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
570  if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
571  pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))->Value);
572  }
573  else if ( Gia_ObjIsCi(pObj) )
574  pObj->Value = Gia_ManAppendCi( pNew );
575  else if ( Gia_ObjIsCo(pObj) )
576  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
577  }
578  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
579  if ( p->pCexSeq )
580  pNew->pCexSeq = Abc_CexDup( p->pCexSeq, Gia_ManRegNum(p) );
581  return pNew;
582 }
584 {
585  Gia_Man_t * pNew = Gia_ManDup(p);
586  Gia_ManTransferMapping( pNew, p );
587  Gia_ManTransferPacking( pNew, p );
588  if ( p->pManTime )
589  pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
590  if ( p->pAigExtra )
591  pNew->pAigExtra = Gia_ManDup( p->pAigExtra );
592  if ( p->nAnd2Delay )
593  pNew->nAnd2Delay = p->nAnd2Delay;
594  return pNew;
595 }
596 
597 /**Function*************************************************************
598 
599  Synopsis [Duplicates AIG without any changes.]
600 
601  Description []
602 
603  SideEffects []
604 
605  SeeAlso []
606 
607 ***********************************************************************/
609 {
610  Gia_Man_t * pNew; int i;
611  pNew = Gia_ManStart( 1 + Gia_ManCiNum(p) + Gia_ManCoNum(p) );
612  pNew->pName = Abc_UtilStrsav( p->pName );
613  for ( i = 0; i < Gia_ManCiNum(p); i++ )
614  Gia_ManAppendCi( pNew );
615  for ( i = 0; i < Gia_ManCoNum(p); i++ )
616  Gia_ManAppendCo( pNew, 0 );
617  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
618  return pNew;
619 }
620 
621 /**Function*************************************************************
622 
623  Synopsis [Duplicates AIG without any changes.]
624 
625  Description []
626 
627  SideEffects []
628 
629  SeeAlso []
630 
631 ***********************************************************************/
633 {
634 // Vec_Int_t * vPiPermInv;
635  Gia_Man_t * pNew;
636  Gia_Obj_t * pObj;
637  int i;
638  assert( Vec_IntSize(vPiPerm) == Gia_ManPiNum(p) );
639  pNew = Gia_ManStart( Gia_ManObjNum(p) );
640  pNew->pName = Abc_UtilStrsav( p->pName );
641  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
642  Gia_ManConst0(p)->Value = 0;
643 // vPiPermInv = Vec_IntInvert( vPiPerm, -1 );
644  Gia_ManForEachPi( p, pObj, i )
645 // Gia_ManPi(p, Vec_IntEntry(vPiPermInv,i))->Value = Gia_ManAppendCi( pNew );
646  Gia_ManPi(p, Vec_IntEntry(vPiPerm,i))->Value = Gia_ManAppendCi( pNew );
647 // Vec_IntFree( vPiPermInv );
648  Gia_ManForEachObj1( p, pObj, i )
649  {
650  if ( Gia_ObjIsAnd(pObj) )
651  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
652  else if ( Gia_ObjIsCi(pObj) )
653  {
654  if ( Gia_ObjIsRo(p, pObj) )
655  pObj->Value = Gia_ManAppendCi( pNew );
656  }
657  else if ( Gia_ObjIsCo(pObj) )
658  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
659  }
660  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
661  return pNew;
662 }
664 {
665  Vec_Int_t * vPermInv;
666  Gia_Man_t * pNew;
667  Gia_Obj_t * pObj;
668  int i;
669  assert( Vec_IntSize(vFfPerm) == Gia_ManRegNum(p) );
670  vPermInv = Vec_IntInvert( vFfPerm, -1 );
671  pNew = Gia_ManStart( Gia_ManObjNum(p) );
672  pNew->pName = Abc_UtilStrsav( p->pName );
673  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
674  Gia_ManConst0(p)->Value = 0;
675  Gia_ManForEachPi( p, pObj, i )
676  pObj->Value = Gia_ManAppendCi(pNew);
677  Gia_ManForEachRo( p, pObj, i )
678  Gia_ManRo(p, Vec_IntEntry(vPermInv, i))->Value = Gia_ManAppendCi(pNew);
679  Gia_ManForEachAnd( p, pObj, i )
680  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
681  Gia_ManForEachPo( p, pObj, i )
682  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
683  Gia_ManForEachRi( p, pObj, i )
684  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy( Gia_ManRi(p, Vec_IntEntry(vPermInv, i)) ) );
685  Vec_IntFree( vPermInv );
686  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
687  return pNew;
688 }
690 {
691  Gia_Man_t * pNew;
692  Gia_Obj_t * pObj;
693  int i, k, Entry;
694  assert( Vec_IntSize(vFfMask) >= Gia_ManRegNum(p) );
695  pNew = Gia_ManStart( Gia_ManObjNum(p) );
696  pNew->pName = Abc_UtilStrsav( p->pName );
697  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
698  Gia_ManConst0(p)->Value = 0;
699  Gia_ManForEachPi( p, pObj, i )
700  pObj->Value = Gia_ManAppendCi(pNew);
701  k = 0;
702  Vec_IntForEachEntry( vFfMask, Entry, i )
703  if ( Entry == -1 )
704  Gia_ManAppendCi(pNew);
705  else
706  Gia_ManRo(p, k++)->Value = Gia_ManAppendCi(pNew);
707  assert( k == Gia_ManRegNum(p) );
708  Gia_ManForEachAnd( p, pObj, i )
709  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
710  Gia_ManForEachPo( p, pObj, i )
711  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
712  k = 0;
713  Vec_IntForEachEntry( vFfMask, Entry, i )
714  if ( Entry == -1 )
715  Gia_ManAppendCo( pNew, 0 );
716  else
717  {
718  pObj = Gia_ManRi( p, k++ );
719  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
720  }
721  assert( k == Gia_ManRegNum(p) );
722  Gia_ManSetRegNum( pNew, Vec_IntSize(vFfMask) );
723  return pNew;
724 }
726 {
727  Vec_Int_t * vPerm = Vec_IntCondense( vFfMask, -1 );
728  Gia_Man_t * pPerm = Gia_ManDupPermFlop( p, vPerm );
729  Gia_Man_t * pSpread = Gia_ManDupSpreadFlop( pPerm, vFfMask );
730  Vec_IntFree( vPerm );
731  Gia_ManStop( pPerm );
732  return pSpread;
733 }
734 
735 /**Function*************************************************************
736 
737  Synopsis [Appends second AIG without any changes.]
738 
739  Description []
740 
741  SideEffects []
742 
743  SeeAlso []
744 
745 ***********************************************************************/
746 void Gia_ManDupAppend( Gia_Man_t * pNew, Gia_Man_t * pTwo )
747 {
748  Gia_Obj_t * pObj;
749  int i;
750  if ( pNew->nRegs > 0 )
751  pNew->nRegs = 0;
752  if ( pNew->pHTable == NULL )
753  Gia_ManHashStart( pNew );
754  Gia_ManConst0(pTwo)->Value = 0;
755  Gia_ManForEachObj1( pTwo, pObj, i )
756  {
757  if ( Gia_ObjIsAnd(pObj) )
758  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
759  else if ( Gia_ObjIsCi(pObj) )
760  pObj->Value = Gia_ManAppendCi( pNew );
761  else if ( Gia_ObjIsCo(pObj) )
762  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
763  }
764 }
766 {
767  Gia_Obj_t * pObj;
768  int i;
769  assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(pTwo) );
770  if ( pNew->pHTable == NULL )
771  Gia_ManHashStart( pNew );
772  Gia_ManConst0(pTwo)->Value = 0;
773  Gia_ManForEachObj1( pTwo, pObj, i )
774  {
775  if ( Gia_ObjIsAnd(pObj) )
776  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
777  else if ( Gia_ObjIsCi(pObj) )
778  pObj->Value = Gia_Obj2Lit( pNew, Gia_ManCi( pNew, Gia_ObjCioId(pObj) ) );
779  else if ( Gia_ObjIsCo(pObj) )
780  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
781  }
782 }
784 {
785  Gia_Man_t * pNew;
786  Gia_Obj_t * pObj;
787  int i;
788  pNew = Gia_ManStart( Gia_ManObjNum(pOne) + Gia_ManObjNum(pTwo) );
789  pNew->pName = Abc_UtilStrsav( pOne->pName );
790  pNew->pSpec = Abc_UtilStrsav( pOne->pSpec );
791  Gia_ManHashAlloc( pNew );
792  Gia_ManConst0(pOne)->Value = 0;
793  Gia_ManForEachObj1( pOne, pObj, i )
794  {
795  if ( Gia_ObjIsAnd(pObj) )
796  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
797  else if ( Gia_ObjIsCi(pObj) )
798  pObj->Value = Gia_ManAppendCi( pNew );
799  }
800  Gia_ManConst0(pTwo)->Value = 0;
801  Gia_ManForEachObj1( pTwo, pObj, i )
802  {
803  if ( Gia_ObjIsAnd(pObj) )
804  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
805  else if ( Gia_ObjIsPi(pTwo, pObj) )
806  pObj->Value = Gia_ManPi(pOne, Gia_ObjCioId(pObj))->Value;
807  else if ( Gia_ObjIsCi(pObj) )
808  pObj->Value = Gia_ManAppendCi( pNew );
809  }
810  Gia_ManHashStop( pNew );
811  // primary outputs
812  Gia_ManForEachPo( pOne, pObj, i )
813  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
814  Gia_ManForEachPo( pTwo, pObj, i )
815  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
816  // flop inputs
817  Gia_ManForEachRi( pOne, pObj, i )
818  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
819  Gia_ManForEachRi( pTwo, pObj, i )
820  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
821  Gia_ManSetRegNum( pNew, Gia_ManRegNum(pOne) + Gia_ManRegNum(pTwo) );
822  return pNew;
823 }
824 
825 /**Function*************************************************************
826 
827  Synopsis [Appends logic cones as additional property outputs.]
828 
829  Description []
830 
831  SideEffects []
832 
833  SeeAlso []
834 
835 ***********************************************************************/
836 Gia_Man_t * Gia_ManDupAppendCones( Gia_Man_t * p, Gia_Man_t ** ppCones, int nCones, int fOnlyRegs )
837 {
838  Gia_Man_t * pNew, * pOne;
839  Gia_Obj_t * pObj;
840  int i, k;
841  pNew = Gia_ManStart( Gia_ManObjNum(p) );
842  pNew->pName = Abc_UtilStrsav( p->pName );
843  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
844  Gia_ManHashAlloc( pNew );
845  Gia_ManConst0(p)->Value = 0;
846  Gia_ManForEachCi( p, pObj, i )
847  pObj->Value = Gia_ManAppendCi( pNew );
848  Gia_ManForEachAnd( p, pObj, i )
849  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
850  Gia_ManForEachPo( p, pObj, i )
851  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
852  for ( k = 0; k < nCones; k++ )
853  {
854  pOne = ppCones[k];
855  assert( Gia_ManPoNum(pOne) == 1 );
856  assert( Gia_ManRegNum(pOne) == 0 );
857  if ( fOnlyRegs )
858  assert( Gia_ManPiNum(pOne) == Gia_ManRegNum(p) );
859  else
860  assert( Gia_ManPiNum(pOne) == Gia_ManCiNum(p) );
861  Gia_ManConst0(pOne)->Value = 0;
862  Gia_ManForEachPi( pOne, pObj, i )
863  pObj->Value = Gia_ManCiLit( pNew, fOnlyRegs ? Gia_ManPiNum(p) + i : i );
864  Gia_ManForEachAnd( pOne, pObj, i )
865  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
866  Gia_ManForEachPo( pOne, pObj, i )
867  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
868  }
869  Gia_ManForEachRi( p, pObj, i )
870  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
871  Gia_ManHashStop( pNew );
872  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
873  pNew = Gia_ManCleanup( pOne = pNew );
874  Gia_ManStop( pOne );
875  return pNew;
876 }
877 
878 
879 /**Function*************************************************************
880 
881  Synopsis [Duplicates while adding self-loops to the registers.]
882 
883  Description []
884 
885  SideEffects []
886 
887  SeeAlso []
888 
889 ***********************************************************************/
891 {
892  Gia_Man_t * pNew, * pTemp;
893  Gia_Obj_t * pObj;
894  int i, iCtrl;
895  pNew = Gia_ManStart( Gia_ManObjNum(p) );
896  pNew->pName = Abc_UtilStrsav( p->pName );
897  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
898  Gia_ManHashAlloc( pNew );
899  Gia_ManFillValue( p );
900  Gia_ManConst0(p)->Value = 0;
901  iCtrl = Gia_ManAppendCi( pNew );
902  Gia_ManForEachCi( p, pObj, i )
903  pObj->Value = Gia_ManAppendCi( pNew );
904  Gia_ManForEachAnd( p, pObj, i )
905  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
906  Gia_ManForEachPo( p, pObj, i )
907  pObj->Value = Gia_ObjFanin0Copy(pObj);
908  Gia_ManForEachRi( p, pObj, i )
909  pObj->Value = Gia_ManHashMux( pNew, iCtrl, Gia_ObjFanin0Copy(pObj), Gia_ObjRiToRo(p, pObj)->Value );
910  Gia_ManForEachCo( p, pObj, i )
911  Gia_ManAppendCo( pNew, pObj->Value );
912  Gia_ManHashStop( pNew );
913  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
914  pNew = Gia_ManCleanup( pTemp = pNew );
915  Gia_ManStop( pTemp );
916  return pNew;
917 }
918 
919 /**Function*************************************************************
920 
921  Synopsis [Duplicates while adding self-loops to the registers.]
922 
923  Description []
924 
925  SideEffects []
926 
927  SeeAlso []
928 
929 ***********************************************************************/
931 {
932  Gia_Man_t * pNew;
933  Gia_Obj_t * pObj;
934  int i, Counter1 = 0, Counter2 = 0;
935  assert( p->vFlopClasses != NULL );
936  pNew = Gia_ManStart( Gia_ManObjNum(p) );
937  pNew->pName = Abc_UtilStrsav( p->pName );
938  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
939  Gia_ManFillValue( p );
940  Gia_ManConst0(p)->Value = 0;
941  Gia_ManForEachPi( p, pObj, i )
942  pObj->Value = Gia_ManAppendCi( pNew );
943  Gia_ManForEachRo( p, pObj, i )
944  if ( Vec_IntEntry(p->vFlopClasses, i) != iClass )
945  pObj->Value = Gia_ManAppendCi( pNew );
946  Gia_ManForEachRo( p, pObj, i )
947  if ( Vec_IntEntry(p->vFlopClasses, i) == iClass )
948  pObj->Value = Gia_ManAppendCi( pNew ), Counter1++;
949  Gia_ManForEachAnd( p, pObj, i )
950  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
951  Gia_ManForEachPo( p, pObj, i )
952  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
953  Gia_ManForEachRi( p, pObj, i )
954  if ( Vec_IntEntry(p->vFlopClasses, i) != iClass )
955  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
956  Gia_ManForEachRi( p, pObj, i )
957  if ( Vec_IntEntry(p->vFlopClasses, i) == iClass )
958  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ), Counter2++;
959  assert( Counter1 == Counter2 );
960  Gia_ManSetRegNum( pNew, Counter1 );
961  return pNew;
962 }
963 
964 /**Function*************************************************************
965 
966  Synopsis [Duplicates AIG without any changes.]
967 
968  Description []
969 
970  SideEffects []
971 
972  SeeAlso []
973 
974 ***********************************************************************/
976 {
977  Gia_Man_t * pNew;
978  Gia_Obj_t * pObj;
979  int i, nRos = 0, nRis = 0;
980  int CountMarked = 0;
981  Gia_ManForEachObj( p, pObj, i )
982  CountMarked += pObj->fMark0;
983  Gia_ManFillValue( p );
984  pNew = Gia_ManStart( Gia_ManObjNum(p) - CountMarked );
985  if ( p->pMuxes )
986  pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
987  pNew->nConstrs = p->nConstrs;
988  pNew->pName = Abc_UtilStrsav( p->pName );
989  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
990  Gia_ManConst0(p)->Value = 0;
991  Gia_ManForEachObj1( p, pObj, i )
992  {
993  if ( pObj->fMark0 )
994  {
995  assert( Gia_ObjIsAnd(pObj) && !Gia_ObjIsBuf(pObj) );
996  pObj->fMark0 = 0;
997  continue;
998  }
999  if ( Gia_ObjIsBuf(pObj) )
1000  pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
1001  else if ( Gia_ObjIsAnd(pObj) )
1002  {
1003  if ( Gia_ObjIsXor(pObj) )
1004  pObj->Value = Gia_ManAppendXorReal( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1005  else if ( Gia_ObjIsMux(p, pObj) )
1006  pObj->Value = Gia_ManAppendMuxReal( pNew, Gia_ObjFanin2Copy(p, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
1007  else
1008  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1009  }
1010  else if ( Gia_ObjIsCi(pObj) )
1011  {
1012  pObj->Value = Gia_ManAppendCi( pNew );
1013  nRos += Gia_ObjIsRo(p, pObj);
1014  }
1015  else if ( Gia_ObjIsCo(pObj) )
1016  {
1017 // Gia_Obj_t * pFanin = Gia_ObjFanin0(pObj);
1018  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1019  nRis += Gia_ObjIsRi(p, pObj);
1020  }
1021  }
1022  assert( pNew->nObjsAlloc == pNew->nObjs );
1023  assert( nRos == nRis );
1024  Gia_ManSetRegNum( pNew, nRos );
1025  if ( p->pReprs && p->pNexts )
1026  {
1027  Gia_Obj_t * pRepr;
1028  pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pNew) );
1029  for ( i = 0; i < Gia_ManObjNum(p); i++ )
1030  Gia_ObjSetRepr( pNew, i, GIA_VOID );
1031  Gia_ManForEachObj1( p, pObj, i )
1032  {
1033  if ( !~pObj->Value )
1034  continue;
1035  pRepr = Gia_ObjReprObj( p, i );
1036  if ( pRepr == NULL )
1037  continue;
1038  if ( !~pRepr->Value )
1039  continue;
1040  assert( !Gia_ObjIsBuf(pObj) );
1041  if ( Abc_Lit2Var(pObj->Value) != Abc_Lit2Var(pRepr->Value) )
1042  Gia_ObjSetRepr( pNew, Abc_Lit2Var(pObj->Value), Abc_Lit2Var(pRepr->Value) );
1043  }
1044  pNew->pNexts = Gia_ManDeriveNexts( pNew );
1045  }
1046  if ( Gia_ManHasChoices(p) )
1047  {
1048  Gia_Obj_t * pSibl;
1049  pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(pNew) );
1050  Gia_ManForEachObj1( p, pObj, i )
1051  {
1052  if ( !~pObj->Value )
1053  continue;
1054  pSibl = Gia_ObjSiblObj( p, i );
1055  if ( pSibl == NULL )
1056  continue;
1057  if ( !~pSibl->Value )
1058  continue;
1059  assert( !Gia_ObjIsBuf(pObj) );
1060  assert( Abc_Lit2Var(pObj->Value) > Abc_Lit2Var(pSibl->Value) );
1061  pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(pSibl->Value);
1062  }
1063  }
1064  return pNew;
1065 }
1066 
1067 /**Function*************************************************************
1068 
1069  Synopsis [Duplicates AIG while creating "parallel" copies.]
1070 
1071  Description []
1072 
1073  SideEffects []
1074 
1075  SeeAlso []
1076 
1077 ***********************************************************************/
1079 {
1080  Gia_Man_t * pNew;
1081  Gia_Obj_t * pObj;
1082  Vec_Int_t * vPis, * vPos, * vRis, * vRos;
1083  int i, t, Entry;
1084  assert( nTimes > 0 );
1085  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1086  pNew->pName = Abc_UtilStrsav( p->pName );
1087  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1088  Gia_ManConst0(p)->Value = 0;
1089  vPis = Vec_IntAlloc( Gia_ManPiNum(p) * nTimes );
1090  vPos = Vec_IntAlloc( Gia_ManPoNum(p) * nTimes );
1091  vRis = Vec_IntAlloc( Gia_ManRegNum(p) * nTimes );
1092  vRos = Vec_IntAlloc( Gia_ManRegNum(p) * nTimes );
1093  for ( t = 0; t < nTimes; t++ )
1094  {
1095  Gia_ManForEachObj1( p, pObj, i )
1096  {
1097  if ( Gia_ObjIsAnd(pObj) )
1098  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1099  else if ( Gia_ObjIsCi(pObj) )
1100  {
1101  pObj->Value = Gia_ManAppendCi( pNew );
1102  if ( Gia_ObjIsPi(p, pObj) )
1103  Vec_IntPush( vPis, Abc_Lit2Var(pObj->Value) );
1104  else
1105  Vec_IntPush( vRos, Abc_Lit2Var(pObj->Value) );
1106  }
1107  else if ( Gia_ObjIsCo(pObj) )
1108  {
1109  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1110  if ( Gia_ObjIsPo(p, pObj) )
1111  Vec_IntPush( vPos, Abc_Lit2Var(pObj->Value) );
1112  else
1113  Vec_IntPush( vRis, Abc_Lit2Var(pObj->Value) );
1114  }
1115  }
1116  }
1117  Vec_IntClear( pNew->vCis );
1118  Vec_IntForEachEntry( vPis, Entry, i )
1119  {
1120  Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCis) );
1121  Vec_IntPush( pNew->vCis, Entry );
1122  }
1123  Vec_IntForEachEntry( vRos, Entry, i )
1124  {
1125  Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCis) );
1126  Vec_IntPush( pNew->vCis, Entry );
1127  }
1128  Vec_IntClear( pNew->vCos );
1129  Vec_IntForEachEntry( vPos, Entry, i )
1130  {
1131  Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCos) );
1132  Vec_IntPush( pNew->vCos, Entry );
1133  }
1134  Vec_IntForEachEntry( vRis, Entry, i )
1135  {
1136  Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCos) );
1137  Vec_IntPush( pNew->vCos, Entry );
1138  }
1139  Vec_IntFree( vPis );
1140  Vec_IntFree( vPos );
1141  Vec_IntFree( vRis );
1142  Vec_IntFree( vRos );
1143  Gia_ManSetRegNum( pNew, nTimes * Gia_ManRegNum(p) );
1144  return pNew;
1145 }
1146 
1147 /**Function*************************************************************
1148 
1149  Synopsis [Duplicates the AIG in the DFS order.]
1150 
1151  Description []
1152 
1153  SideEffects []
1154 
1155  SeeAlso []
1156 
1157 ***********************************************************************/
1159 {
1160  if ( ~pObj->Value )
1161  return pObj->Value;
1162  if ( p->pReprsOld && ~p->pReprsOld[Gia_ObjId(p, pObj)] )
1163  {
1164  Gia_Obj_t * pRepr = Gia_ManObj( p, p->pReprsOld[Gia_ObjId(p, pObj)] );
1165  pRepr->Value = Gia_ManDupDfs2_rec( pNew, p, pRepr );
1166  return pObj->Value = Abc_LitNotCond( pRepr->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) );
1167  }
1168  if ( Gia_ObjIsCi(pObj) )
1169  return pObj->Value = Gia_ManAppendCi(pNew);
1170  Gia_ManDupDfs2_rec( pNew, p, Gia_ObjFanin0(pObj) );
1171  if ( Gia_ObjIsCo(pObj) )
1172  return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1173  Gia_ManDupDfs2_rec( pNew, p, Gia_ObjFanin1(pObj) );
1174  if ( pNew->pHTable )
1175  return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1176  return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1177 }
1178 
1179 /**Function*************************************************************
1180 
1181  Synopsis [Duplicates AIG in the DFS order.]
1182 
1183  Description []
1184 
1185  SideEffects []
1186 
1187  SeeAlso []
1188 
1189 ***********************************************************************/
1191 {
1192  Gia_Man_t * pNew;
1193  Gia_Obj_t * pObj, * pObjNew;
1194  int i;
1195  Gia_ManFillValue( p );
1196  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1197  pNew->pName = Abc_UtilStrsav( p->pName );
1198  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1199  Gia_ManConst0(p)->Value = 0;
1200  Gia_ManForEachCo( p, pObj, i )
1201  Gia_ManDupDfs2_rec( pNew, p, pObj );
1202  Gia_ManForEachCi( p, pObj, i )
1203  if ( ~pObj->Value == 0 )
1204  pObj->Value = Gia_ManAppendCi(pNew);
1205  assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(p) );
1206  // remap combinational inputs
1207  Gia_ManForEachCi( p, pObj, i )
1208  {
1209  pObjNew = Gia_ObjFromLit( pNew, pObj->Value );
1210  assert( !Gia_IsComplement(pObjNew) );
1211  Vec_IntWriteEntry( pNew->vCis, Gia_ObjCioId(pObj), Gia_ObjId(pNew, pObjNew) );
1212  Gia_ObjSetCioId( pObjNew, Gia_ObjCioId(pObj) );
1213  }
1214  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1215  return pNew;
1216 }
1217 
1218 /**Function*************************************************************
1219 
1220  Synopsis [Duplicates the AIG in the DFS order.]
1221 
1222  Description []
1223 
1224  SideEffects []
1225 
1226  SeeAlso []
1227 
1228 ***********************************************************************/
1230 {
1231  if ( ~pObj->Value )
1232  return;
1233  assert( Gia_ObjIsAnd(pObj) );
1234  Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
1235  Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin1(pObj) );
1236  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1237 }
1239 {
1240  Gia_Man_t * pNew;
1241  Gia_Obj_t * pObj;
1242  int i;
1243  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1244  pNew->pName = Abc_UtilStrsav( p->pName );
1245  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1246  Gia_ManFillValue( p );
1247  Gia_ManConst0(p)->Value = 0;
1248  Gia_ManForEachCi( p, pObj, i )
1249  pObj->Value = Gia_ManAppendCi(pNew);
1250  Gia_ManForEachCo( p, pObj, i )
1251  Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
1252  Gia_ManForEachCo( p, pObj, i )
1253  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1254  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1255  pNew->nConstrs = p->nConstrs;
1256  if ( p->pCexSeq )
1257  pNew->pCexSeq = Abc_CexDup( p->pCexSeq, Gia_ManRegNum(p) );
1258  return pNew;
1259 }
1260 
1261 /**Function*************************************************************
1262 
1263  Synopsis [Cofactors w.r.t. a primary input variable.]
1264 
1265  Description []
1266 
1267  SideEffects []
1268 
1269  SeeAlso []
1270 
1271 ***********************************************************************/
1273 {
1274  if ( ~pObj->Value )
1275  return;
1276  assert( Gia_ObjIsAnd(pObj) );
1277  Gia_ManDupCofactorVar_rec( pNew, p, Gia_ObjFanin0(pObj) );
1278  Gia_ManDupCofactorVar_rec( pNew, p, Gia_ObjFanin1(pObj) );
1279  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1280 }
1281 Gia_Man_t * Gia_ManDupCofactorVar( Gia_Man_t * p, int iVar, int Value )
1282 {
1283  Gia_Man_t * pNew, * pTemp;
1284  Gia_Obj_t * pObj;
1285  int i;
1286  assert( iVar >= 0 && iVar < Gia_ManPiNum(p) );
1287  assert( Value == 0 || Value == 1 );
1288  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1289  pNew->pName = Abc_UtilStrsav( p->pName );
1290  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1291  Gia_ManFillValue( p );
1292  Gia_ManConst0(p)->Value = 0;
1293  Gia_ManForEachCi( p, pObj, i )
1294  pObj->Value = Gia_ManAppendCi(pNew);
1295  Gia_ManPi( p, iVar )->Value = Value; // modification!
1296  Gia_ManHashAlloc( pNew );
1297  Gia_ManForEachCo( p, pObj, i )
1298  Gia_ManDupCofactorVar_rec( pNew, p, Gia_ObjFanin0(pObj) );
1299  Gia_ManForEachCo( p, pObj, i )
1300  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1301  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1302  pNew->nConstrs = p->nConstrs;
1303  pNew = Gia_ManCleanup( pTemp = pNew );
1304  Gia_ManStop( pTemp );
1305  return pNew;
1306 }
1307 
1308 /**Function*************************************************************
1309 
1310  Synopsis [Cofactors w.r.t. an internal node.]
1311 
1312  Description []
1313 
1314  SideEffects []
1315 
1316  SeeAlso []
1317 
1318 ***********************************************************************/
1319 Gia_Man_t * Gia_ManDupCofactorObj( Gia_Man_t * p, int iObj, int Value )
1320 {
1321  Gia_Man_t * pNew, * pTemp;
1322  Gia_Obj_t * pObj;
1323  int i, iObjValue = -1;
1324  assert( Gia_ManRegNum(p) == 0 );
1325  assert( iObj > 0 && iObj < Gia_ManObjNum(p) );
1326  assert( Gia_ObjIsCand(Gia_ManObj(p, iObj)) );
1327  assert( Value == 0 || Value == 1 );
1328  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1329  pNew->pName = Abc_UtilStrsav( p->pName );
1330  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1331  Gia_ManConst0(p)->Value = 0;
1332  Gia_ManHashAlloc( pNew );
1333  Gia_ManForEachObj1( p, pObj, i )
1334  {
1335  if ( Gia_ObjIsCi(pObj) )
1336  pObj->Value = Gia_ManAppendCi( pNew );
1337  else if ( Gia_ObjIsAnd(pObj) )
1338  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1339  else if ( Gia_ObjIsCo(pObj) )
1340  pObj->Value = Gia_ManAppendCo( pNew, Gia_ManHashAnd(pNew, Gia_ObjFanin0Copy(pObj), iObjValue) );
1341  if ( i == iObj )
1342  iObjValue = Abc_LitNotCond(pObj->Value, !Value), pObj->Value = Value;
1343  }
1344  pNew = Gia_ManCleanup( pTemp = pNew );
1345  Gia_ManStop( pTemp );
1346  return pNew;
1347 }
1348 
1349 /**Function*************************************************************
1350 
1351  Synopsis [Existentially quantified given variable.]
1352 
1353  Description []
1354 
1355  SideEffects []
1356 
1357  SeeAlso []
1358 
1359 ***********************************************************************/
1361 {
1362  Gia_Man_t * pNew, * pTemp;
1363  Gia_Obj_t * pObj;
1364  int i;
1365  assert( iVar >= 0 && iVar < Gia_ManPiNum(p) );
1366  assert( Gia_ManPoNum(p) == 1 );
1367  assert( Gia_ManRegNum(p) == 0 );
1368  Gia_ManFillValue( p );
1369  // find the cofactoring variable
1370  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1371  pNew->pName = Abc_UtilStrsav( p->pName );
1372  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1373  Gia_ManHashAlloc( pNew );
1374  // compute negative cofactor
1375  Gia_ManConst0(p)->Value = 0;
1376  Gia_ManForEachCi( p, pObj, i )
1377  pObj->Value = Gia_ManAppendCi(pNew);
1378  Gia_ManPi( p, iVar )->Value = Abc_Var2Lit( 0, 0 );
1379  Gia_ManForEachAnd( p, pObj, i )
1380  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1381  Gia_ManForEachPo( p, pObj, i )
1382  pObj->Value = Gia_ObjFanin0Copy(pObj);
1383  // compute the positive cofactor
1384  Gia_ManPi( p, iVar )->Value = Abc_Var2Lit( 0, 1 );
1385  Gia_ManForEachAnd( p, pObj, i )
1386  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1387  // create OR gate
1388  Gia_ManForEachPo( p, pObj, i )
1389  pObj->Value = Gia_ManAppendCo( pNew, Gia_ManHashOr(pNew, Gia_ObjFanin0Copy(pObj), pObj->Value) );
1390  Gia_ManHashStop( pNew );
1391  pNew = Gia_ManCleanup( pTemp = pNew );
1392  Gia_ManStop( pTemp );
1393  return pNew;
1394 }
1395 
1396 /**Function*************************************************************
1397 
1398  Synopsis [Existentially quantifies the given variable.]
1399 
1400  Description []
1401 
1402  SideEffects []
1403 
1404  SeeAlso []
1405 
1406 ***********************************************************************/
1408 {
1409  Gia_Man_t * pNew, * pTemp;
1410  Gia_Obj_t * pObj;
1411  int i;
1412  assert( iVar >= 0 && iVar < Gia_ManPiNum(p) );
1413  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1414  pNew->pName = Abc_UtilStrsav( p->pName );
1415  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1416  Gia_ManFillValue( p );
1417  Gia_ManHashAlloc( pNew );
1418  Gia_ManConst0(p)->Value = 0;
1419  Gia_ManForEachCi( p, pObj, i )
1420  pObj->Value = Gia_ManAppendCi(pNew);
1421  // first part
1422  Gia_ManPi( p, iVar )->Value = 0; // modification!
1423  Gia_ManForEachCo( p, pObj, i )
1424  Gia_ManDupCofactorVar_rec( pNew, p, Gia_ObjFanin0(pObj) );
1425  Gia_ManForEachCo( p, pObj, i )
1426  pObj->Value = Gia_ObjFanin0Copy(pObj);
1427  // second part
1428  Gia_ManPi( p, iVar )->Value = 1; // modification!
1429  Gia_ManForEachAnd( p, pObj, i )
1430  pObj->Value = ~0;
1431  Gia_ManForEachCo( p, pObj, i )
1432  Gia_ManDupCofactorVar_rec( pNew, p, Gia_ObjFanin0(pObj) );
1433  // combination
1434  Gia_ManForEachCo( p, pObj, i )
1435  Gia_ManAppendCo( pNew, Gia_ManHashOr(pNew, Gia_ObjFanin0Copy(pObj), pObj->Value) );
1436  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1437  pNew->nConstrs = p->nConstrs;
1438  pNew = Gia_ManCleanup( pTemp = pNew );
1439  Gia_ManStop( pTemp );
1440  return pNew;
1441 }
1442 
1443 /**Function*************************************************************
1444 
1445  Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
1446 
1447  Description []
1448 
1449  SideEffects []
1450 
1451  SeeAlso []
1452 
1453 ***********************************************************************/
1455 {
1456  Gia_Man_t * pNew;
1457  Gia_Obj_t * pObj;
1458  int i;
1459  Gia_ManFillValue( p );
1460  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1461  pNew->pName = Abc_UtilStrsav( p->pName );
1462  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1463  Gia_ManConst0(p)->Value = 0;
1464  Gia_ManForEachCi( p, pObj, i )
1465  pObj->Value = Gia_ManAppendCi(pNew);
1466  Gia_ManForEachCo( p, pObj, i )
1467  if ( pObj->fMark1 == 0 )
1468  Gia_ManDupDfs_rec( pNew, p, pObj );
1469  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1470  return pNew;
1471 }
1472 
1473 /**Function*************************************************************
1474 
1475  Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
1476 
1477  Description []
1478 
1479  SideEffects []
1480 
1481  SeeAlso []
1482 
1483 ***********************************************************************/
1485 {
1486  Gia_Man_t * pNew;
1487  Gia_Obj_t * pObj;
1488  int i;
1489  assert( Gia_ObjIsCo(pRoot) );
1490  Gia_ManFillValue( p );
1491  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1492  pNew->pName = Abc_UtilStrsav( p->pName );
1493  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1494  Gia_ManConst0(p)->Value = 0;
1495  Gia_ManForEachCi( p, pObj, i )
1496  pObj->Value = Gia_ManAppendCi(pNew);
1497  Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin0(pRoot) );
1498  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pRoot) );
1499  Gia_ManSetRegNum( pNew, 0 );
1500  return pNew;
1501 }
1502 
1503 /**Function*************************************************************
1504 
1505  Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
1506 
1507  Description []
1508 
1509  SideEffects []
1510 
1511  SeeAlso []
1512 
1513 ***********************************************************************/
1515 {
1516  if ( ~pObj->Value )
1517  return;
1518  if ( Gia_ObjIsCi(pObj) )
1519  {
1520  pObj->Value = Gia_ManAppendCi(pNew);
1521  return;
1522  }
1523  assert( Gia_ObjIsAnd(pObj) );
1524  Gia_ManDupDfs3_rec( pNew, p, Gia_ObjFanin0(pObj) );
1525  Gia_ManDupDfs3_rec( pNew, p, Gia_ObjFanin1(pObj) );
1526  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1527 }
1529 {
1530  Gia_Man_t * pNew;
1531  assert( Gia_ObjIsAnd(pRoot) );
1532  Gia_ManFillValue( p );
1533  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1534  pNew->pName = Abc_UtilStrsav( p->pName );
1535  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1536  Gia_ManConst0(p)->Value = 0;
1537  Gia_ManDupDfs3_rec( pNew, p, pRoot );
1538  Gia_ManAppendCo( pNew, pRoot->Value );
1539  return pNew;
1540 }
1541 
1542 /**Function*************************************************************
1543 
1544  Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
1545 
1546  Description []
1547 
1548  SideEffects []
1549 
1550  SeeAlso []
1551 
1552 ***********************************************************************/
1554 {
1555  Gia_Man_t * pNew;
1556  Gia_Obj_t * pObj;
1557  int i, iLit, iLitRes;
1558  Gia_ManFillValue( p );
1559  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1560  pNew->pName = Abc_UtilStrsav( p->pName );
1561  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1562  Gia_ManConst0(p)->Value = 0;
1563  Gia_ManForEachCi( p, pObj, i )
1564  pObj->Value = Gia_ManAppendCi(pNew);
1565  Vec_IntForEachEntry( vLits, iLit, i )
1566  {
1567  iLitRes = Gia_ManDupDfs2_rec( pNew, p, Gia_ManObj(p, Abc_Lit2Var(iLit)) );
1568  Gia_ManAppendCo( pNew, Abc_LitNotCond( iLitRes, Abc_LitIsCompl(iLit)) );
1569  }
1570  Gia_ManSetRegNum( pNew, 0 );
1571  return pNew;
1572 }
1573 
1574 /**Function*************************************************************
1575 
1576  Synopsis [Returns the array of non-const-0 POs of the dual-output miter.]
1577 
1578  Description []
1579 
1580  SideEffects []
1581 
1582  SeeAlso []
1583 
1584 ***********************************************************************/
1586 {
1587  Vec_Int_t * vNonZero;
1588  Gia_Man_t * pTemp, * pNonDual;
1589  Gia_Obj_t * pObj;
1590  int i;
1591  assert( (Gia_ManPoNum(p) & 1) == 0 );
1592  pNonDual = Gia_ManTransformMiter( p );
1593  pNonDual = Gia_ManSeqStructSweep( pTemp = pNonDual, 1, 1, 0 );
1594  Gia_ManStop( pTemp );
1595  assert( Gia_ManPiNum(pNonDual) > 0 );
1596  assert( 2 * Gia_ManPoNum(pNonDual) == Gia_ManPoNum(p) );
1597  // skip PO pairs corresponding to const0 POs of the non-dual miter
1598  vNonZero = Vec_IntAlloc( 100 );
1599  Gia_ManForEachPo( pNonDual, pObj, i )
1600  if ( !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) )
1601  Vec_IntPush( vNonZero, i );
1602  Gia_ManStop( pNonDual );
1603  return vNonZero;
1604 }
1605 
1606 
1607 /**Function*************************************************************
1608 
1609  Synopsis [Returns 1 if PO can be removed.]
1610 
1611  Description []
1612 
1613  SideEffects []
1614 
1615  SeeAlso []
1616 
1617 ***********************************************************************/
1618 int Gia_ManPoIsToRemove( Gia_Man_t * p, Gia_Obj_t * pObj, int Value )
1619 {
1620  assert( Gia_ObjIsCo(pObj) );
1621  if ( Value == -1 )
1622  return Gia_ObjIsConst0(Gia_ObjFanin0(pObj));
1623  assert( Value == 0 || Value == 1 );
1624  return Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) && Value == Gia_ObjFaninC0(pObj);
1625 }
1626 
1627 /**Function*************************************************************
1628 
1629  Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
1630 
1631  Description []
1632 
1633  SideEffects []
1634 
1635  SeeAlso []
1636 
1637 ***********************************************************************/
1638 Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos, int fDualOut, int OutValue )
1639 {
1640  Vec_Int_t * vNonZero = NULL;
1641  Gia_Man_t * pNew, * pTemp;
1642  Gia_Obj_t * pObj;
1643  int i, Entry;
1644  // collect non-zero
1645  if ( fDualOut && fTrimCos )
1646  vNonZero = Gia_ManDupTrimmedNonZero( p );
1647  // start new manager
1648  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1649  pNew->pName = Abc_UtilStrsav( p->pName );
1650  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1651  // check if there are PIs to be added
1652  Gia_ManCreateRefs( p );
1653  Gia_ManForEachPi( p, pObj, i )
1654  if ( !fTrimCis || Gia_ObjRefNum(p, pObj) )
1655  break;
1656  if ( i == Gia_ManPiNum(p) ) // there is no PIs - add dummy PI
1657  Gia_ManAppendCi(pNew);
1658  // add the ROs
1659  Gia_ManFillValue( p );
1660  Gia_ManConst0(p)->Value = 0;
1661  Gia_ManForEachCi( p, pObj, i )
1662  if ( !fTrimCis || Gia_ObjRefNum(p, pObj) || Gia_ObjIsRo(p, pObj) )
1663  pObj->Value = Gia_ManAppendCi(pNew);
1664  Gia_ManForEachAnd( p, pObj, i )
1665  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1666  if ( fDualOut && fTrimCos )
1667  {
1668  Vec_IntForEachEntry( vNonZero, Entry, i )
1669  {
1670  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManPo(p, 2*Entry+0)) );
1671  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManPo(p, 2*Entry+1)) );
1672  }
1673  if ( Gia_ManPoNum(pNew) == 0 ) // nothing - add dummy PO
1674  {
1675 // Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManPo(p, 0)) );
1676 // Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManPo(p, 1)) );
1677  Gia_ManAppendCo( pNew, 0 );
1678  Gia_ManAppendCo( pNew, 0 );
1679  }
1680  Gia_ManForEachRi( p, pObj, i )
1681  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1682  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1683  // cleanup
1684  pNew = Gia_ManSeqStructSweep( pTemp = pNew, 1, 1, 0 );
1685  Gia_ManStop( pTemp );
1686  // trim the PIs
1687 // pNew = Gia_ManDupTrimmed( pTemp = pNew, 1, 0, 0 );
1688 // Gia_ManStop( pTemp );
1689  }
1690  else
1691  {
1692  // check if there are POs to be added
1693  Gia_ManForEachPo( p, pObj, i )
1694  if ( !fTrimCos || !Gia_ManPoIsToRemove(p, pObj, OutValue) )
1695  break;
1696  if ( i == Gia_ManPoNum(p) ) // there is no POs - add dummy PO
1697  Gia_ManAppendCo( pNew, 0 );
1698  Gia_ManForEachCo( p, pObj, i )
1699  if ( !fTrimCos || !Gia_ManPoIsToRemove(p, pObj, OutValue) || Gia_ObjIsRi(p, pObj) )
1700  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1701  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1702  }
1703  Vec_IntFreeP( &vNonZero );
1704  assert( !Gia_ManHasDangling( pNew ) );
1705  return pNew;
1706 }
1707 
1708 /**Function*************************************************************
1709 
1710  Synopsis [Removes POs driven by PIs and PIs without fanout.]
1711 
1712  Description []
1713 
1714  SideEffects []
1715 
1716  SeeAlso []
1717 
1718 ***********************************************************************/
1720 {
1721  Gia_Man_t * pNew;
1722  Gia_Obj_t * pObj;
1723  int i;
1724  // start new manager
1725  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1726  pNew->pName = Abc_UtilStrsav( p->pName );
1727  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1728  // check if there are PIs to be added
1729  Gia_ManCreateRefs( p );
1730  // discount references of POs
1731  Gia_ManForEachPo( p, pObj, i )
1732  Gia_ObjRefFanin0Dec( p, pObj );
1733  // check if PIs are left
1734  Gia_ManForEachPi( p, pObj, i )
1735  if ( Gia_ObjRefNum(p, pObj) )
1736  break;
1737  if ( i == Gia_ManPiNum(p) ) // there is no PIs - add dummy PI
1738  Gia_ManAppendCi(pNew);
1739  // add the ROs
1740  Gia_ManFillValue( p );
1741  Gia_ManConst0(p)->Value = 0;
1742  Gia_ManForEachCi( p, pObj, i )
1743  if ( Gia_ObjRefNum(p, pObj) || Gia_ObjIsRo(p, pObj) )
1744  pObj->Value = Gia_ManAppendCi(pNew);
1745  Gia_ManForEachAnd( p, pObj, i )
1746  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1747  // check if there are POs to be added
1748  Gia_ManForEachPo( p, pObj, i )
1749  if ( !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) && !Gia_ObjIsPi(p, Gia_ObjFanin0(pObj)) )
1750  break;
1751  if ( i == Gia_ManPoNum(p) ) // there is no POs - add dummy PO
1752  Gia_ManAppendCo( pNew, 0 );
1753  Gia_ManForEachCo( p, pObj, i )
1754  if ( (!Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) && !Gia_ObjIsPi(p, Gia_ObjFanin0(pObj))) || Gia_ObjIsRi(p, pObj) )
1755  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1756  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1757  assert( !Gia_ManHasDangling( pNew ) );
1758  return pNew;
1759 }
1760 
1761 /**Function*************************************************************
1762 
1763  Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
1764 
1765  Description []
1766 
1767  SideEffects []
1768 
1769  SeeAlso []
1770 
1771 ***********************************************************************/
1773 {
1774  Gia_Man_t * pTemp, * pNew;
1775  Gia_Obj_t * pObj;
1776  int i;
1777  assert( Gia_ManPoNum(p) == Gia_ManPiNum(p2) );
1778  assert( Gia_ManRegNum(p) == 0 );
1779  assert( Gia_ManRegNum(p2) == 0 );
1780  pNew = Gia_ManStart( Gia_ManObjNum(p)+Gia_ManObjNum(p2) );
1781  pNew->pName = Abc_UtilStrsav( p->pName );
1782  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1783  Gia_ManHashAlloc( pNew );
1784  // dup first AIG
1785  Gia_ManConst0(p)->Value = 0;
1786  Gia_ManForEachCi( p, pObj, i )
1787  pObj->Value = Gia_ManAppendCi(pNew);
1788  Gia_ManForEachAnd( p, pObj, i )
1789  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1790  // dup second AIG
1791  Gia_ManConst0(p2)->Value = 0;
1792  Gia_ManForEachCo( p, pObj, i )
1793  Gia_ManPi(p2, i)->Value = Gia_ObjFanin0Copy(pObj);
1794  Gia_ManForEachAnd( p2, pObj, i )
1795  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1796  Gia_ManForEachCo( p2, pObj, i )
1797  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1798  Gia_ManHashStop( pNew );
1799 // Gia_ManPrintStats( pGiaNew, 0 );
1800  pNew = Gia_ManCleanup( pTemp = pNew );
1801  Gia_ManStop( pTemp );
1802  return pNew;
1803 }
1804 
1805 /**Function*************************************************************
1806 
1807  Synopsis [Duplicates transition relation from p1 and property from p2.]
1808 
1809  Description []
1810 
1811  SideEffects []
1812 
1813  SeeAlso []
1814 
1815 ***********************************************************************/
1817 {
1818  Gia_Man_t * pTemp, * pNew;
1819  Gia_Obj_t * pObj;
1820  int i;
1821  // there is no flops in p2
1822  assert( Gia_ManRegNum(p2) == 0 );
1823  // there is only one PO in p2
1824 // assert( Gia_ManPoNum(p2) == 1 );
1825  // input count of p2 is equal to flop count of p1
1826  assert( Gia_ManPiNum(p2) == Gia_ManRegNum(p1) );
1827 
1828  // start new AIG
1829  pNew = Gia_ManStart( Gia_ManObjNum(p1)+Gia_ManObjNum(p2) );
1830  pNew->pName = Abc_UtilStrsav( p1->pName );
1831  pNew->pSpec = Abc_UtilStrsav( p1->pSpec );
1832  Gia_ManHashAlloc( pNew );
1833  // dup first AIG
1834  Gia_ManConst0(p1)->Value = 0;
1835  Gia_ManForEachCi( p1, pObj, i )
1836  pObj->Value = Gia_ManAppendCi(pNew);
1837  Gia_ManForEachAnd( p1, pObj, i )
1838  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1839  // dup second AIG
1840  Gia_ManConst0(p2)->Value = 0;
1841  Gia_ManForEachPi( p2, pObj, i )
1842  pObj->Value = Gia_ManRo(p1, i)->Value;
1843  Gia_ManForEachAnd( p2, pObj, i )
1844  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1845  // add property output
1846  Gia_ManForEachPo( p2, pObj, i )
1847  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1848  // add flop inputs
1849  Gia_ManForEachRi( p1, pObj, i )
1850  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1851  Gia_ManHashStop( pNew );
1852  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p1) );
1853  pNew = Gia_ManCleanup( pTemp = pNew );
1854  Gia_ManStop( pTemp );
1855  return pNew;
1856 }
1857 
1858 /**Function*************************************************************
1859 
1860  Synopsis [Print representatives.]
1861 
1862  Description []
1863 
1864  SideEffects []
1865 
1866  SeeAlso []
1867 
1868 ***********************************************************************/
1870 {
1871  Gia_Obj_t * pObj;
1872  int i;
1873  Gia_ManForEachObj( p, pObj, i )
1874  if ( ~p->pReprsOld[i] )
1875  printf( "%d->%d ", i, p->pReprs[i].iRepr );
1876  printf( "\n" );
1877 }
1878 
1879 /**Function*************************************************************
1880 
1881  Synopsis [Duplicates AIG in the DFS order.]
1882 
1883  Description []
1884 
1885  SideEffects []
1886 
1887  SeeAlso []
1888 
1889 ***********************************************************************/
1890 Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits )
1891 {
1892  Gia_Man_t * pNew;
1893  Gia_Obj_t * pObj;
1894  int i;
1895  Gia_ManFillValue( p );
1896  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1897  pNew->pName = Abc_UtilStrsav( p->pName );
1898  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1899  Gia_ManConst0(p)->Value = 0;
1900  Gia_ManForEachCi( p, pObj, i )
1901  {
1902  pObj->Value = Gia_ManAppendCi(pNew);
1903  if ( ~pCi2Lit[i] )
1904  pObj->Value = Abc_LitNotCond( Gia_ManObj(p, Abc_Lit2Var(pCi2Lit[i]))->Value, Abc_LitIsCompl(pCi2Lit[i]) );
1905  }
1906  Gia_ManHashAlloc( pNew );
1907  if ( vLits )
1908  {
1909  int iLit, iLitRes;
1910  Vec_IntForEachEntry( vLits, iLit, i )
1911  {
1912  iLitRes = Gia_ManDupDfs2_rec( pNew, p, Gia_ManObj(p, Abc_Lit2Var(iLit)) );
1913  Gia_ManAppendCo( pNew, Abc_LitNotCond( iLitRes, Abc_LitIsCompl(iLit)) );
1914  }
1915  }
1916  else
1917  {
1918  Gia_ManForEachCo( p, pObj, i )
1919  {
1920  Gia_ManDupDfs2_rec( pNew, p, Gia_ObjFanin0(pObj) );
1921  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1922  }
1923  }
1924  Gia_ManHashStop( pNew );
1925  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1926  return pNew;
1927 }
1928 
1929 /**Function*************************************************************
1930 
1931  Synopsis [Duplicates AIG in the DFS order.]
1932 
1933  Description []
1934 
1935  SideEffects []
1936 
1937  SeeAlso []
1938 
1939 ***********************************************************************/
1941 {
1942  Gia_Man_t * pNew, * pTemp;
1943  Gia_Obj_t * pObj;
1944  int i;
1945  assert( p->pReprsOld != NULL );
1946  Gia_ManFillValue( p );
1947  pNew = Gia_ManStart( Gia_ManObjNum(p) );
1948  pNew->pName = Abc_UtilStrsav( p->pName );
1949  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1950  Gia_ManConst0(p)->Value = 0;
1951  Gia_ManForEachCi( p, pObj, i )
1952  pObj->Value = Gia_ManAppendCi(pNew);
1953  Gia_ManHashAlloc( pNew );
1954  Gia_ManForEachCo( p, pObj, i )
1955  Gia_ManDupDfs_rec( pNew, p, pObj );
1956  Gia_ManHashStop( pNew );
1957  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1958  pNew = Gia_ManCleanup( pTemp = pNew );
1959  Gia_ManStop( pTemp );
1960  return pNew;
1961 }
1962 
1963 /**Function*************************************************************
1964 
1965  Synopsis [Detect topmost gate.]
1966 
1967  Description []
1968 
1969  SideEffects []
1970 
1971  SeeAlso []
1972 
1973 ***********************************************************************/
1975 {
1976  Gia_Man_t * pNew;
1977  Gia_Obj_t * pObj;
1978  Vec_Int_t * vFront, * vLeaves;
1979  int i, iLit, iObjId, nCiLits, * pCi2Lit;
1980  char * pVar2Val;
1981  // collect the frontier
1982  vFront = Vec_IntAlloc( 1000 );
1983  vLeaves = Vec_IntAlloc( 1000 );
1984  Gia_ManForEachCo( p, pObj, i )
1985  {
1986  if ( Gia_ObjIsConst0( Gia_ObjFanin0(pObj) ) )
1987  continue;
1988  if ( Gia_ObjFaninC0(pObj) )
1989  Vec_IntPush( vLeaves, Gia_ObjFaninLit0p(p, pObj) );
1990  else
1991  Vec_IntPush( vFront, Gia_ObjFaninId0p(p, pObj) );
1992  }
1993  if ( Vec_IntSize(vFront) == 0 )
1994  {
1995  if ( fVerbose )
1996  printf( "The AIG cannot be decomposed using AND-decomposition.\n" );
1997  Vec_IntFree( vFront );
1998  Vec_IntFree( vLeaves );
1999  return Gia_ManDupNormalize( p );
2000  }
2001  // expand the frontier
2002  Gia_ManForEachObjVec( vFront, p, pObj, i )
2003  {
2004  if ( Gia_ObjIsCi(pObj) )
2005  {
2006  Vec_IntPush( vLeaves, Abc_Var2Lit( Gia_ObjId(p, pObj), 0 ) );
2007  continue;
2008  }
2009  assert( Gia_ObjIsAnd(pObj) );
2010  if ( Gia_ObjFaninC0(pObj) )
2011  Vec_IntPush( vLeaves, Gia_ObjFaninLit0p(p, pObj) );
2012  else
2013  Vec_IntPush( vFront, Gia_ObjFaninId0p(p, pObj) );
2014  if ( Gia_ObjFaninC1(pObj) )
2015  Vec_IntPush( vLeaves, Gia_ObjFaninLit1p(p, pObj) );
2016  else
2017  Vec_IntPush( vFront, Gia_ObjFaninId1p(p, pObj) );
2018  }
2019  Vec_IntFree( vFront );
2020  // sort the literals
2021  nCiLits = 0;
2022  pCi2Lit = ABC_FALLOC( int, Gia_ManObjNum(p) );
2023  pVar2Val = ABC_FALLOC( char, Gia_ManObjNum(p) );
2024  Vec_IntForEachEntry( vLeaves, iLit, i )
2025  {
2026  iObjId = Abc_Lit2Var(iLit);
2027  pObj = Gia_ManObj(p, iObjId);
2028  if ( Gia_ObjIsCi(pObj) )
2029  {
2030  pCi2Lit[Gia_ObjCioId(pObj)] = !Abc_LitIsCompl(iLit);
2031  nCiLits++;
2032  }
2033  if ( pVar2Val[iObjId] != 0 && pVar2Val[iObjId] != 1 )
2034  pVar2Val[iObjId] = Abc_LitIsCompl(iLit);
2035  else if ( pVar2Val[iObjId] != Abc_LitIsCompl(iLit) )
2036  break;
2037  }
2038  if ( i < Vec_IntSize(vLeaves) )
2039  {
2040  printf( "Problem is trivially UNSAT.\n" );
2041  ABC_FREE( pCi2Lit );
2042  ABC_FREE( pVar2Val );
2043  Vec_IntFree( vLeaves );
2044  return Gia_ManDupNormalize( p );
2045  }
2046  // create array of input literals
2047  Vec_IntClear( vLeaves );
2048  Gia_ManForEachObj( p, pObj, i )
2049  if ( !Gia_ObjIsCi(pObj) && (pVar2Val[i] == 0 || pVar2Val[i] == 1) )
2050  Vec_IntPush( vLeaves, Abc_Var2Lit(i, pVar2Val[i]) );
2051  if ( fVerbose )
2052  printf( "Detected %6d AND leaves and %6d CI leaves.\n", Vec_IntSize(vLeaves), nCiLits );
2053  // create the input map
2054  if ( nCiLits == 0 )
2055  pNew = Gia_ManDupDfsLitArray( p, vLeaves );
2056  else
2057  pNew = Gia_ManDupDfsCiMap( p, pCi2Lit, vLeaves );
2058  ABC_FREE( pCi2Lit );
2059  ABC_FREE( pVar2Val );
2060  Vec_IntFree( vLeaves );
2061  return pNew;
2062 }
2063 
2064 /**Function*************************************************************
2065 
2066  Synopsis [Detect topmost gate.]
2067 
2068  Description []
2069 
2070  SideEffects []
2071 
2072  SeeAlso []
2073 
2074 ***********************************************************************/
2075 Gia_Man_t * Gia_ManDupTopAnd( Gia_Man_t * p, int fVerbose )
2076 {
2077  Gia_Man_t * pNew, * pTemp;
2078  int fContinue, iIter = 0;
2079  pNew = Gia_ManDupNormalize( p );
2080  for ( fContinue = 1; fContinue; )
2081  {
2082  pNew = Gia_ManDupTopAnd_iter( pTemp = pNew, fVerbose );
2083  if ( Gia_ManCoNum(pNew) == Gia_ManCoNum(pTemp) && Gia_ManAndNum(pNew) == Gia_ManAndNum(pTemp) )
2084  fContinue = 0;
2085  Gia_ManStop( pTemp );
2086  if ( fVerbose )
2087  {
2088  printf( "Iter %2d : ", ++iIter );
2089  Gia_ManPrintStatsShort( pNew );
2090  }
2091  }
2092  return pNew;
2093 }
2094 
2095 
2096 /**Function*************************************************************
2097 
2098  Synopsis [Duplicates the AIG in the DFS order.]
2099 
2100  Description []
2101 
2102  SideEffects []
2103 
2104  SeeAlso []
2105 
2106 ***********************************************************************/
2108 {
2109  if ( ~pObj->Value )
2110  return pObj->Value;
2111  assert( Gia_ObjIsAnd(pObj) );
2112  Gia_ManMiter_rec( pNew, p, Gia_ObjFanin0(pObj) );
2113  Gia_ManMiter_rec( pNew, p, Gia_ObjFanin1(pObj) );
2114  return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2115 }
2116 
2117 /**Function*************************************************************
2118 
2119  Synopsis [Creates miter of two designs.]
2120 
2121  Description []
2122 
2123  SideEffects []
2124 
2125  SeeAlso []
2126 
2127 ***********************************************************************/
2128 Gia_Man_t * Gia_ManMiter( Gia_Man_t * p0, Gia_Man_t * p1, int nInsDup, int fDualOut, int fSeq, int fImplic, int fVerbose )
2129 {
2130  Gia_Man_t * pNew, * pTemp;
2131  Gia_Obj_t * pObj;
2132  int i, iLit;
2133  if ( fSeq )
2134  {
2135  if ( Gia_ManPiNum(p0) != Gia_ManPiNum(p1) )
2136  {
2137  printf( "Gia_ManMiter(): Designs have different number of PIs.\n" );
2138  return NULL;
2139  }
2140  if ( Gia_ManPoNum(p0) != Gia_ManPoNum(p1) )
2141  {
2142  printf( "Gia_ManMiter(): Designs have different number of POs.\n" );
2143  return NULL;
2144  }
2145  if ( Gia_ManRegNum(p0) == 0 || Gia_ManRegNum(p1) == 0 )
2146  {
2147  printf( "Gia_ManMiter(): At least one of the designs has no registers.\n" );
2148  return NULL;
2149  }
2150  }
2151  else
2152  {
2153  if ( Gia_ManCiNum(p0) != Gia_ManCiNum(p1) )
2154  {
2155  printf( "Gia_ManMiter(): Designs have different number of CIs.\n" );
2156  return NULL;
2157  }
2158  if ( Gia_ManCoNum(p0) != Gia_ManCoNum(p1) )
2159  {
2160  printf( "Gia_ManMiter(): Designs have different number of COs.\n" );
2161  return NULL;
2162  }
2163  }
2164  // start the manager
2165  pNew = Gia_ManStart( Gia_ManObjNum(p0) + Gia_ManObjNum(p1) );
2166  pNew->pName = Abc_UtilStrsav( "miter" );
2167  // map combinational inputs
2168  Gia_ManFillValue( p0 );
2169  Gia_ManFillValue( p1 );
2170  Gia_ManConst0(p0)->Value = 0;
2171  Gia_ManConst0(p1)->Value = 0;
2172  // map internal nodes and outputs
2173  Gia_ManHashAlloc( pNew );
2174  if ( fSeq )
2175  {
2176  // create primary inputs
2177  Gia_ManForEachPi( p0, pObj, i )
2178  pObj->Value = Gia_ManAppendCi( pNew );
2179  Gia_ManForEachPi( p1, pObj, i )
2180  if ( i < Gia_ManPiNum(p1) - nInsDup )
2181  pObj->Value = Gia_ObjToLit( pNew, Gia_ManPi(pNew, i) );
2182  else
2183  pObj->Value = Gia_ManAppendCi( pNew );
2184  // create latch outputs
2185  Gia_ManForEachRo( p0, pObj, i )
2186  pObj->Value = Gia_ManAppendCi( pNew );
2187  Gia_ManForEachRo( p1, pObj, i )
2188  pObj->Value = Gia_ManAppendCi( pNew );
2189  // create primary outputs
2190  Gia_ManForEachPo( p0, pObj, i )
2191  {
2192  Gia_ManMiter_rec( pNew, p0, Gia_ObjFanin0(pObj) );
2193  Gia_ManMiter_rec( pNew, p1, Gia_ObjFanin0(Gia_ManPo(p1,i)) );
2194  if ( fDualOut )
2195  {
2196  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2198  }
2199  else if ( fImplic )
2200  {
2202  Gia_ManAppendCo( pNew, iLit );
2203  }
2204  else
2205  {
2206  iLit = Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(Gia_ManPo(p1,i)) );
2207  Gia_ManAppendCo( pNew, iLit );
2208  }
2209  }
2210  // create register inputs
2211  Gia_ManForEachRi( p0, pObj, i )
2212  {
2213  Gia_ManMiter_rec( pNew, p0, Gia_ObjFanin0(pObj) );
2214  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2215  }
2216  Gia_ManForEachRi( p1, pObj, i )
2217  {
2218  Gia_ManMiter_rec( pNew, p1, Gia_ObjFanin0(pObj) );
2219  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2220  }
2221  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p0) + Gia_ManRegNum(p1) );
2222  }
2223  else
2224  {
2225  // create combinational inputs
2226  Gia_ManForEachCi( p0, pObj, i )
2227  pObj->Value = Gia_ManAppendCi( pNew );
2228  Gia_ManForEachCi( p1, pObj, i )
2229  if ( i < Gia_ManCiNum(p1) - nInsDup )
2230  pObj->Value = Gia_ObjToLit( pNew, Gia_ManCi(pNew, i) );
2231  else
2232  pObj->Value = Gia_ManAppendCi( pNew );
2233  // create combinational outputs
2234  Gia_ManForEachCo( p0, pObj, i )
2235  {
2236  Gia_ManMiter_rec( pNew, p0, Gia_ObjFanin0(pObj) );
2237  Gia_ManMiter_rec( pNew, p1, Gia_ObjFanin0(Gia_ManCo(p1,i)) );
2238  if ( fDualOut )
2239  {
2240  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2242  }
2243  else if ( fImplic )
2244  {
2246  Gia_ManAppendCo( pNew, iLit );
2247  }
2248  else
2249  {
2250  iLit = Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(Gia_ManCo(p1,i)) );
2251  Gia_ManAppendCo( pNew, iLit );
2252  }
2253  }
2254  }
2255  Gia_ManHashStop( pNew );
2256  pNew = Gia_ManCleanup( pTemp = pNew );
2257  Gia_ManStop( pTemp );
2258 
2259  pNew = Gia_ManDupNormalize( pTemp = pNew );
2260  Gia_ManStop( pTemp );
2261  return pNew;
2262 }
2263 
2264 /**Function*************************************************************
2265 
2266  Synopsis [Computes the AND of all POs.]
2267 
2268  Description []
2269 
2270  SideEffects []
2271 
2272  SeeAlso []
2273 
2274 ***********************************************************************/
2275 Gia_Man_t * Gia_ManDupAndOr( Gia_Man_t * p, int nOuts, int fUseOr, int fCompl )
2276 {
2277  Gia_Man_t * pNew, * pTemp;
2278  Gia_Obj_t * pObj;
2279  int i, iResult;
2280  assert( Gia_ManRegNum(p) == 0 );
2281  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2282  pNew->pName = Abc_UtilStrsav( p->pName );
2283  Gia_ManConst0(p)->Value = 0;
2284  Gia_ManHashAlloc( pNew );
2285  Gia_ManForEachPi( p, pObj, i )
2286  pObj->Value = Gia_ManAppendCi( pNew );
2287  Gia_ManForEachAnd( p, pObj, i )
2288  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2289  if ( fUseOr ) // construct OR of all POs
2290  {
2291  iResult = 0;
2292  Gia_ManForEachPo( p, pObj, i )
2293  iResult = Gia_ManHashOr( pNew, iResult, Gia_ObjFanin0Copy(pObj) );
2294  }
2295  else // construct AND of all POs
2296  {
2297  iResult = 1;
2298  Gia_ManForEachPo( p, pObj, i )
2299  iResult = Gia_ManHashAnd( pNew, iResult, Gia_ObjFanin0Copy(pObj) );
2300  }
2301  iResult = Abc_LitNotCond( iResult, (int)(fCompl > 0) );
2302 // Gia_ManForEachPo( p, pObj, i )
2303 // pObj->Value = Gia_ManAppendCo( pNew, iResult );
2304  for ( i = 0; i < nOuts; i++ )
2305  Gia_ManAppendCo( pNew, iResult );
2306  Gia_ManHashStop( pNew );
2307  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2308  pNew = Gia_ManCleanup( pTemp = pNew );
2309  Gia_ManStop( pTemp );
2310  return pNew;
2311 }
2312 
2313 /**Function*************************************************************
2314 
2315  Synopsis [Transforms the circuit into a regular miter.]
2316 
2317  Description []
2318 
2319  SideEffects []
2320 
2321  SeeAlso []
2322 
2323 ***********************************************************************/
2325 {
2326  Gia_Man_t * pNew, * pTemp;
2327  Gia_Obj_t * pObj, * pObj2;
2328  int i, iLit;
2329  assert( (Gia_ManPoNum(p) & 1) == 0 );
2330  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2331  pNew->pName = Abc_UtilStrsav( p->pName );
2332  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2333  Gia_ManConst0(p)->Value = 0;
2334  Gia_ManHashAlloc( pNew );
2335  Gia_ManForEachCi( p, pObj, i )
2336  pObj->Value = Gia_ManAppendCi( pNew );
2337  Gia_ManForEachAnd( p, pObj, i )
2338  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2339  Gia_ManForEachPo( p, pObj, i )
2340  {
2341  pObj2 = Gia_ManPo( p, ++i );
2342  iLit = Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(pObj2) );
2343  Gia_ManAppendCo( pNew, iLit );
2344  }
2345  Gia_ManForEachRi( p, pObj, i )
2346  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2347  Gia_ManHashStop( pNew );
2348  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2349  pNew = Gia_ManCleanup( pTemp = pNew );
2350  Gia_ManStop( pTemp );
2351  return pNew;
2352 }
2354 {
2355  Gia_Man_t * pNew;
2356  Gia_Obj_t * pObj;
2357  int i;
2358  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2359  pNew->pName = Abc_UtilStrsav( p->pName );
2360  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2361  Gia_ManConst0(p)->Value = 0;
2362  Gia_ManHashAlloc( pNew );
2363  Gia_ManForEachCi( p, pObj, i )
2364  pObj->Value = Gia_ManAppendCi( pNew );
2365  Gia_ManForEachAnd( p, pObj, i )
2366  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2367  Gia_ManForEachPo( p, pObj, i )
2368  {
2369  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2370  Gia_ManAppendCo( pNew, 0 );
2371  }
2372  Gia_ManForEachRi( p, pObj, i )
2373  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2374  Gia_ManHashStop( pNew );
2375  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2376  return pNew;
2377 }
2378 
2379 /**Function*************************************************************
2380 
2381  Synopsis [Performs 'zero' and 'undc' operation.]
2382 
2383  Description [The init string specifies 0/1/X for each flop.]
2384 
2385  SideEffects []
2386 
2387  SeeAlso []
2388 
2389 ***********************************************************************/
2390 Gia_Man_t * Gia_ManDupZeroUndc( Gia_Man_t * p, char * pInit, int fVerbose )
2391 {
2392  Gia_Man_t * pNew;
2393  Gia_Obj_t * pObj;
2394  int CountPis = Gia_ManPiNum(p), * pPiLits;
2395  int i, iResetFlop = -1, Count1 = 0;
2396  // map X-valued flops into new PIs
2397  assert( (int)strlen(pInit) == Gia_ManRegNum(p) );
2398  pPiLits = ABC_FALLOC( int, Gia_ManRegNum(p) );
2399  for ( i = 0; i < Gia_ManRegNum(p); i++ )
2400  if ( pInit[i] == 'x' || pInit[i] == 'X' )
2401  pPiLits[i] = CountPis++;
2402  // create new manager
2403  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2404  pNew->pName = Abc_UtilStrsav( p->pName );
2405  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2406  Gia_ManConst0(p)->Value = 0;
2407  // create primary inputs
2408  Gia_ManForEachPi( p, pObj, i )
2409  pObj->Value = Gia_ManAppendCi( pNew );
2410  // create additional primary inputs
2411  for ( i = Gia_ManPiNum(p); i < CountPis; i++ )
2412  Gia_ManAppendCi( pNew );
2413  // create flop outputs
2414  Gia_ManForEachRo( p, pObj, i )
2415  pObj->Value = Gia_ManAppendCi( pNew );
2416  // create reset flop output
2417  if ( CountPis > Gia_ManPiNum(p) )
2418  iResetFlop = Gia_ManAppendCi( pNew );
2419  // update flop outputs
2420  Gia_ManForEachRo( p, pObj, i )
2421  {
2422  if ( pInit[i] == '1' )
2423  pObj->Value = Abc_LitNot(pObj->Value), Count1++;
2424  else if ( pInit[i] == 'x' || pInit[i] == 'X' )
2425  pObj->Value = Gia_ManAppendMux( pNew, iResetFlop, pObj->Value, Gia_Obj2Lit(pNew, Gia_ManPi(pNew, pPiLits[i])) );
2426  else if ( pInit[i] != '0' )
2427  assert( 0 );
2428  }
2429  ABC_FREE( pPiLits );
2430  // build internal nodes
2431  Gia_ManForEachAnd( p, pObj, i )
2432  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2433  // create POs
2434  Gia_ManForEachPo( p, pObj, i )
2435  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2436  // create flop inputs
2437  Gia_ManForEachRi( p, pObj, i )
2438  if ( pInit[i] == '1' )
2439  pObj->Value = Gia_ManAppendCo( pNew, Abc_LitNot(Gia_ObjFanin0Copy(pObj)) );
2440  else
2441  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2442  // create reset flop input
2443  if ( CountPis > Gia_ManPiNum(p) )
2444  Gia_ManAppendCo( pNew, 1 );
2445  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) + (int)(CountPis > Gia_ManPiNum(p)) );
2446  if ( fVerbose )
2447  printf( "Converted %d 1-valued FFs and %d DC-valued FFs.\n", Count1, CountPis-Gia_ManPiNum(p) );
2448  return pNew;
2449 }
2450 
2451 /**Function*************************************************************
2452 
2453  Synopsis [Creates miter of two designs.]
2454 
2455  Description []
2456 
2457  SideEffects []
2458 
2459  SeeAlso []
2460 
2461 ***********************************************************************/
2462 Gia_Man_t * Gia_ManMiter2( Gia_Man_t * pStart, char * pInit, int fVerbose )
2463 {
2464  Vec_Int_t * vCiValues, * vCoValues0, * vCoValues1;
2465  Gia_Man_t * pNew, * pUndc, * pTemp;
2466  Gia_Obj_t * pObj;
2467  char * pInitNew;
2468  int i, k;
2469  // check PI values
2470  for ( i = 0; i < Gia_ManPiNum(pStart); i++ )
2471  assert( pInit[i] == 'x' || pInit[i] == 'X' );
2472  // normalize the manager
2473  pUndc = Gia_ManDupZeroUndc( pStart, pInit + Gia_ManPiNum(pStart), fVerbose );
2474  // create new init string
2475  pInitNew = ABC_ALLOC( char, Gia_ManPiNum(pUndc)+1 );
2476  for ( i = 0; i < Gia_ManPiNum(pStart); i++ )
2477  pInitNew[i] = pInit[i];
2478  for ( i = k = Gia_ManPiNum(pStart); i < Gia_ManCiNum(pStart); i++ )
2479  if ( pInit[i] == 'x' || pInit[i] == 'X' )
2480  pInitNew[k++] = pInit[i];
2481  pInitNew[k] = 0;
2482  assert( k == Gia_ManPiNum(pUndc) );
2483  // derive miter
2484  pNew = Gia_ManStart( Gia_ManObjNum(pUndc) );
2485  pNew->pName = Abc_UtilStrsav( pUndc->pName );
2486  pNew->pSpec = Abc_UtilStrsav( pUndc->pSpec );
2487  Gia_ManConst0(pUndc)->Value = 0;
2488  Gia_ManHashAlloc( pNew );
2489  // add PIs of the first side
2490  Gia_ManForEachPi( pUndc, pObj, i )
2491  pObj->Value = Gia_ManAppendCi( pNew );
2492  // add PIs of the second side
2493  vCiValues = Vec_IntAlloc( Gia_ManPiNum(pUndc) );
2494  Gia_ManForEachPi( pUndc, pObj, i )
2495  if ( pInitNew[i] == 'x' )
2496  Vec_IntPush( vCiValues, Gia_Obj2Lit( pNew, Gia_ManPi(pNew, i) ) );
2497  else if ( pInitNew[i] == 'X' )
2498  Vec_IntPush( vCiValues, Gia_ManAppendCi( pNew ) );
2499  else assert( 0 );
2500  // build flops and internal nodes
2501  Gia_ManForEachRo( pUndc, pObj, i )
2502  pObj->Value = Gia_ManAppendCi( pNew );
2503  Gia_ManForEachAnd( pUndc, pObj, i )
2504  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2505  // collect CO values
2506  vCoValues0 = Vec_IntAlloc( Gia_ManPoNum(pUndc) );
2507  Gia_ManForEachCo( pUndc, pObj, i )
2508  Vec_IntPush( vCoValues0, Gia_ObjFanin0Copy(pObj) );
2509  // build the other side
2510  Gia_ManForEachPi( pUndc, pObj, i )
2511  pObj->Value = Vec_IntEntry( vCiValues, i );
2512  Gia_ManForEachRo( pUndc, pObj, i )
2513  pObj->Value = Gia_ManAppendCi( pNew );
2514  Gia_ManForEachAnd( pUndc, pObj, i )
2515  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2516  // collect CO values
2517  vCoValues1 = Vec_IntAlloc( Gia_ManPoNum(pUndc) );
2518  Gia_ManForEachCo( pUndc, pObj, i )
2519  Vec_IntPush( vCoValues1, Gia_ObjFanin0Copy(pObj) );
2520  // create POs
2521  Gia_ManForEachPo( pUndc, pObj, i )
2522  pObj->Value = Gia_ManAppendCo( pNew, Gia_ManHashXor( pNew, Vec_IntEntry(vCoValues0, i), Vec_IntEntry(vCoValues1, i) ) );
2523  // create flop inputs
2524  Gia_ManForEachRi( pUndc, pObj, i )
2525  pObj->Value = Gia_ManAppendCo( pNew, Vec_IntEntry(vCoValues0, Gia_ManPoNum(pUndc)+i) );
2526  Gia_ManForEachRi( pUndc, pObj, i )
2527  pObj->Value = Gia_ManAppendCo( pNew, Vec_IntEntry(vCoValues1, Gia_ManPoNum(pUndc)+i) );
2528  Vec_IntFree( vCoValues0 );
2529  Vec_IntFree( vCoValues1 );
2530  Vec_IntFree( vCiValues );
2531  ABC_FREE( pInitNew );
2532  // cleanup
2533  Gia_ManHashStop( pNew );
2534  Gia_ManSetRegNum( pNew, 2*Gia_ManRegNum(pUndc) );
2535  Gia_ManStop( pUndc );
2536  pNew = Gia_ManCleanup( pTemp = pNew );
2537  Gia_ManStop( pTemp );
2538  return pNew;
2539 }
2540 
2541 /**Function*************************************************************
2542 
2543  Synopsis [Duplicates the AIG in the DFS order.]
2544 
2545  Description []
2546 
2547  SideEffects []
2548 
2549  SeeAlso []
2550 
2551 ***********************************************************************/
2553 {
2554  if ( ~pObj->Value )
2555  return pObj->Value;
2556  Gia_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin0(pObj) );
2557  if ( Gia_ObjIsCo(pObj) )
2558  return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2559  Gia_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin1(pObj) );
2560  return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2561 }
2562 
2563 /**Function*************************************************************
2564 
2565  Synopsis [Derives the miter of several AIGs for choice computation.]
2566 
2567  Description []
2568 
2569  SideEffects []
2570 
2571  SeeAlso []
2572 
2573 ***********************************************************************/
2575 {
2576  Gia_Man_t * pNew, * pGia, * pGia0;
2577  int i, k, iNode, nNodes;
2578  // make sure they have equal parameters
2579  assert( Vec_PtrSize(vGias) > 0 );
2580  pGia0 = (Gia_Man_t *)Vec_PtrEntry( vGias, 0 );
2581  Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
2582  {
2583  assert( Gia_ManCiNum(pGia) == Gia_ManCiNum(pGia0) );
2584  assert( Gia_ManCoNum(pGia) == Gia_ManCoNum(pGia0) );
2585  assert( Gia_ManRegNum(pGia) == Gia_ManRegNum(pGia0) );
2586  Gia_ManFillValue( pGia );
2587  Gia_ManConst0(pGia)->Value = 0;
2588  }
2589  // start the new manager
2590  pNew = Gia_ManStart( Vec_PtrSize(vGias) * Gia_ManObjNum(pGia0) );
2591  pNew->pName = Abc_UtilStrsav( pGia0->pName );
2592  pNew->pSpec = Abc_UtilStrsav( pGia0->pSpec );
2593  // create new CIs and assign them to the old manager CIs
2594  for ( k = 0; k < Gia_ManCiNum(pGia0); k++ )
2595  {
2596  iNode = Gia_ManAppendCi(pNew);
2597  Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
2598  Gia_ManCi( pGia, k )->Value = iNode;
2599  }
2600  // create internal nodes
2601  Gia_ManHashAlloc( pNew );
2602  for ( k = 0; k < Gia_ManCoNum(pGia0); k++ )
2603  {
2604  Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
2605  Gia_ManChoiceMiter_rec( pNew, pGia, Gia_ManCo( pGia, k ) );
2606  }
2607  Gia_ManHashStop( pNew );
2608  // check the presence of dangling nodes
2609  nNodes = Gia_ManHasDangling( pNew );
2610  assert( nNodes == 0 );
2611  // finalize
2612  Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia0) );
2613  return pNew;
2614 }
2615 
2616 /**Function*************************************************************
2617 
2618  Synopsis [Duplicates AIG while putting first PIs, then nodes, then POs.]
2619 
2620  Description []
2621 
2622  SideEffects []
2623 
2624  SeeAlso []
2625 
2626 ***********************************************************************/
2628 {
2629  Gia_Man_t * pNew;
2630  Gia_Obj_t * pObj;
2631  int i, nConstr = 0;
2632  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2633  pNew->pName = Abc_UtilStrsav( p->pName );
2634  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2635  Gia_ManConst0(p)->Value = 0;
2636  Gia_ManForEachCi( p, pObj, i )
2637  pObj->Value = Gia_ManAppendCi(pNew);
2638  Gia_ManForEachAnd( p, pObj, i )
2639  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2640  Gia_ManForEachPo( p, pObj, i )
2641  if ( Vec_IntEntry(vPoTypes, i) == 0 ) // regular PO
2642  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2643  Gia_ManForEachPo( p, pObj, i )
2644  if ( Vec_IntEntry(vPoTypes, i) == 1 ) // constraint (should be complemented!)
2645  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ^ 1 ), nConstr++;
2646  Gia_ManForEachRi( p, pObj, i )
2647  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2648 // Gia_ManDupRemapEquiv( pNew, p );
2649  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2650  pNew->nConstrs = nConstr;
2651  assert( Gia_ManIsNormalized(pNew) );
2652  return pNew;
2653 }
2654 
2655 /**Function*************************************************************
2656 
2657  Synopsis [Copy an AIG structure related to the selected POs.]
2658 
2659  Description []
2660 
2661  SideEffects []
2662 
2663  SeeAlso []
2664 
2665 ***********************************************************************/
2667 {
2668  Gia_Obj_t * pObj1 = *pp1;
2669  Gia_Obj_t * pObj2 = *pp2;
2670  return Gia_ObjCioId(pObj1) - Gia_ObjCioId(pObj2);
2671 }
2672 void Gia_ManDupCones_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vNodes, Vec_Ptr_t * vRoots )
2673 {
2674  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
2675  return;
2676  Gia_ObjSetTravIdCurrent(p, pObj);
2677  if ( Gia_ObjIsAnd(pObj) )
2678  {
2679  Gia_ManDupCones_rec( p, Gia_ObjFanin0(pObj), vLeaves, vNodes, vRoots );
2680  Gia_ManDupCones_rec( p, Gia_ObjFanin1(pObj), vLeaves, vNodes, vRoots );
2681  Vec_PtrPush( vNodes, pObj );
2682  }
2683  else if ( Gia_ObjIsCo(pObj) )
2684  Gia_ManDupCones_rec( p, Gia_ObjFanin0(pObj), vLeaves, vNodes, vRoots );
2685  else if ( Gia_ObjIsRo(p, pObj) )
2686  Vec_PtrPush( vRoots, Gia_ObjRoToRi(p, pObj) );
2687  else if ( Gia_ObjIsPi(p, pObj) )
2688  Vec_PtrPush( vLeaves, pObj );
2689  else assert( 0 );
2690 }
2691 Gia_Man_t * Gia_ManDupCones( Gia_Man_t * p, int * pPos, int nPos, int fTrimPis )
2692 {
2693  Gia_Man_t * pNew;
2694  Vec_Ptr_t * vLeaves, * vNodes, * vRoots;
2695  Gia_Obj_t * pObj;
2696  int i;
2697 
2698  // collect initial POs
2699  vLeaves = Vec_PtrAlloc( 100 );
2700  vNodes = Vec_PtrAlloc( 100 );
2701  vRoots = Vec_PtrAlloc( 100 );
2702  for ( i = 0; i < nPos; i++ )
2703  Vec_PtrPush( vRoots, Gia_ManPo(p, pPos[i]) );
2704 
2705  // mark internal nodes
2708  Vec_PtrForEachEntry( Gia_Obj_t *, vRoots, pObj, i )
2709  Gia_ManDupCones_rec( p, pObj, vLeaves, vNodes, vRoots );
2710  Vec_PtrSort( vLeaves, (int (*)(void))Gia_ObjCompareByCioId );
2711 
2712  // start the new manager
2713 // Gia_ManFillValue( p );
2714  pNew = Gia_ManStart( Vec_PtrSize(vLeaves) + Vec_PtrSize(vNodes) + Vec_PtrSize(vRoots) + 1);
2715  pNew->pName = Abc_UtilStrsav( p->pName );
2716  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2717  // map the constant node
2718  Gia_ManConst0(p)->Value = 0;
2719  // create PIs
2720  if ( fTrimPis )
2721  {
2722  Vec_PtrForEachEntry( Gia_Obj_t *, vLeaves, pObj, i )
2723  pObj->Value = Gia_ManAppendCi( pNew );
2724  }
2725  else
2726  {
2727  Gia_ManForEachPi( p, pObj, i )
2728  pObj->Value = Gia_ManAppendCi( pNew );
2729  }
2730  // create LOs
2731  Vec_PtrForEachEntryStart( Gia_Obj_t *, vRoots, pObj, i, nPos )
2732  Gia_ObjRiToRo(p, pObj)->Value = Gia_ManAppendCi( pNew );
2733  // create internal nodes
2734  Vec_PtrForEachEntry( Gia_Obj_t *, vNodes, pObj, i )
2735  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2736  // create COs
2737  Vec_PtrForEachEntry( Gia_Obj_t *, vRoots, pObj, i )
2738  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2739  // finalize
2740  Gia_ManSetRegNum( pNew, Vec_PtrSize(vRoots)-nPos );
2741  Vec_PtrFree( vLeaves );
2742  Vec_PtrFree( vNodes );
2743  Vec_PtrFree( vRoots );
2744  return pNew;
2745 
2746 }
2747 
2748 /**Function*************************************************************
2749 
2750  Synopsis [Generates AIG representing 1-hot condition for N inputs.]
2751 
2752  Description [The condition is true of all POs are 0.]
2753 
2754  SideEffects []
2755 
2756  SeeAlso []
2757 
2758 ***********************************************************************/
2759 Gia_Man_t * Gia_ManOneHot( int nSkips, int nVars )
2760 {
2761  Gia_Man_t * p;
2762  int i, b, Shift, iGiaLit, nLogVars = Abc_Base2Log( nVars );
2763  int * pTemp = ABC_CALLOC( int, (1 << nLogVars) );
2764  p = Gia_ManStart( nSkips + 4 * nVars + 1 );
2765  p->pName = Abc_UtilStrsav( "onehot" );
2766  for ( i = 0; i < nSkips; i++ )
2767  Gia_ManAppendCi( p );
2768  for ( i = 0; i < nVars; i++ )
2769  pTemp[i] = Gia_ManAppendCi( p );
2770  Gia_ManHashStart( p );
2771  for ( b = 0; b < nLogVars; b++ )
2772  for ( i = 0, Shift = (1<<b); i < (1 << nLogVars); i += 2*Shift )
2773  {
2774  iGiaLit = Gia_ManHashAnd( p, pTemp[i], pTemp[i + Shift] );
2775  if ( iGiaLit )
2776  Gia_ManAppendCo( p, iGiaLit );
2777  pTemp[i] = Gia_ManHashOr( p, pTemp[i], pTemp[i + Shift] );
2778  }
2779  Gia_ManHashStop( p );
2780  Gia_ManAppendCo( p, Abc_LitNot(pTemp[0]) );
2781  ABC_FREE( pTemp );
2782  assert( Gia_ManObjNum(p) <= nSkips + 4 * nVars + 1 );
2783  return p;
2784 }
2786 {
2787  Gia_Man_t * pOneHot, * pNew = Gia_ManDup( p );
2788  if ( Gia_ManRegNum(pNew) == 0 )
2789  {
2790  Abc_Print( 0, "Appending 1-hotness constraints to the PIs.\n" );
2791  pOneHot = Gia_ManOneHot( 0, Gia_ManCiNum(pNew) );
2792  }
2793  else
2794  pOneHot = Gia_ManOneHot( Gia_ManPiNum(pNew), Gia_ManRegNum(pNew) );
2795  Gia_ManDupAppendShare( pNew, pOneHot );
2796  pNew->nConstrs += Gia_ManPoNum(pOneHot);
2797  Gia_ManStop( pOneHot );
2798  return pNew;
2799 }
2800 
2801 /**Function*************************************************************
2802 
2803  Synopsis [Duplicates the AIG with nodes ordered by level.]
2804 
2805  Description []
2806 
2807  SideEffects []
2808 
2809  SeeAlso []
2810 
2811 ***********************************************************************/
2813 {
2814  Gia_Man_t * pNew;
2815  Gia_Obj_t * pObj;
2816  int i, nLevels = Gia_ManLevelNum( p );
2817  int * pCounts = ABC_CALLOC( int, nLevels + 1 );
2818  int * pNodes = ABC_ALLOC( int, Gia_ManAndNum(p) );
2819  Gia_ManForEachAnd( p, pObj, i )
2820  pCounts[Gia_ObjLevel(p, pObj)]++;
2821  for ( i = 1; i <= nLevels; i++ )
2822  pCounts[i] += pCounts[i-1];
2823  Gia_ManForEachAnd( p, pObj, i )
2824  pNodes[pCounts[Gia_ObjLevel(p, pObj)-1]++] = i;
2825  // duplicate
2826  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2827  pNew->pName = Abc_UtilStrsav( p->pName );
2828  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2829  Gia_ManConst0(p)->Value = 0;
2830  Gia_ManForEachCi( p, pObj, i )
2831  pObj->Value = Gia_ManAppendCi( pNew );
2832  for ( i = 0; i < Gia_ManAndNum(p) && (pObj = Gia_ManObj(p, pNodes[i])); i++ )
2833  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2834  Gia_ManForEachCo( p, pObj, i )
2835  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2836  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
2837  ABC_FREE( pCounts );
2838  ABC_FREE( pNodes );
2839  return pNew;
2840 }
2841 
2842 /**Function*************************************************************
2843 
2844  Synopsis []
2845 
2846  Description []
2847 
2848  SideEffects []
2849 
2850  SeeAlso []
2851 
2852 ***********************************************************************/
2853 Gia_Man_t * Gia_ManDupFromVecs( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAnds, Vec_Int_t * vCos, int nRegs )
2854 {
2855  Gia_Man_t * pNew;
2856  Gia_Obj_t * pObj;
2857  int i;
2858  // start the new manager
2859  pNew = Gia_ManStart( 5000 );
2860  pNew->pName = Abc_UtilStrsav( p->pName );
2861  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2862  // create constant
2863  Gia_ManConst0(p)->Value = 0;
2864  // create PIs
2865  Gia_ManForEachObjVec( vCis, p, pObj, i )
2866  pObj->Value = Gia_ManAppendCi( pNew );
2867  // create internal nodes
2868  Gia_ManForEachObjVec( vAnds, p, pObj, i )
2869  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2870  // create ROs
2871  Gia_ManForEachObjVec( vCos, p, pObj, i )
2872  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
2873  Gia_ManSetRegNum( pNew, nRegs );
2874  return pNew;
2875 }
2876 
2877 /**Function*************************************************************
2878 
2879  Synopsis []
2880 
2881  Description []
2882 
2883  SideEffects []
2884 
2885  SeeAlso []
2886 
2887 ***********************************************************************/
2889 {
2890  Gia_Man_t * pNew;
2891  Gia_Obj_t * pObj;
2892  int i;
2893  // start the new manager
2894  pNew = Gia_ManStart( 5000 );
2895  pNew->pName = Abc_UtilStrsav( p->pName );
2896  // create constant and PIs
2897  Gia_ManConst0(p)->Value = 0;
2898  Gia_ManForEachCi( p, pObj, i )
2899  pObj->Value = Gia_ManAppendCi( pNew );
2900  // create internal nodes
2901  Gia_ManCleanMark01(p);
2902  Gia_ManForEachAnd( p, pObj, i )
2903  if ( Gia_ManSuppSize(p, &i, 1) <= nSuppMax )
2904  {
2905  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2906  pObj->fMark0 = 1;
2907  }
2908  else
2909  {
2910  Gia_ObjFanin0(pObj)->fMark1 = 1;
2911  Gia_ObjFanin1(pObj)->fMark1 = 1;
2912  }
2913  Gia_ManForEachCo( p, pObj, i )
2914  Gia_ObjFanin0(pObj)->fMark1 = 1;
2915  // add POs for the nodes pointed to
2916  Gia_ManForEachAnd( p, pObj, i )
2917  if ( pObj->fMark0 && pObj->fMark1 )
2918  Gia_ManAppendCo( pNew, pObj->Value );
2919  // cleanup and leave
2920  Gia_ManCleanMark01(p);
2921  return pNew;
2922 }
2923 
2924 
2925 /**Function*************************************************************
2926 
2927  Synopsis [Extract constraints.]
2928 
2929  Description []
2930 
2931  SideEffects []
2932 
2933  SeeAlso []
2934 
2935 ***********************************************************************/
2936 void Gia_ManDupWithConstrCollectAnd_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper, int fFirst )
2937 {
2938  if ( (Gia_IsComplement(pObj) || !Gia_ObjIsAnd(pObj)) && !fFirst )
2939  {
2940  Vec_IntPushUnique( vSuper, Gia_ObjToLit(p, pObj) );
2941  return;
2942  }
2943  Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild0(pObj), vSuper, 0 );
2944  Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild1(pObj), vSuper, 0 );
2945 }
2947 {
2948  Vec_Int_t * vSuper;
2949  Gia_Man_t * pNew, * pTemp;
2950  Gia_Obj_t * pObj;
2951  int i, iDriver, iLit, iLitBest = -1, LevelBest = -1;
2952  assert( Gia_ManPoNum(p) == 1 );
2953  assert( Gia_ManRegNum(p) == 0 );
2954  pObj = Gia_ManPo( p, 0 );
2955  if ( Gia_ObjFaninC0(pObj) )
2956  {
2957  printf( "The miter's output is not AND-decomposable.\n" );
2958  return NULL;
2959  }
2960  vSuper = Vec_IntAlloc( 100 );
2961  Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild0(pObj), vSuper, 1 );
2962  assert( Vec_IntSize(vSuper) > 1 );
2963  // find the highest level
2964  Gia_ManLevelNum( p );
2965  Vec_IntForEachEntry( vSuper, iLit, i )
2966  if ( LevelBest < Gia_ObjLevelId(p, Abc_Lit2Var(iLit)) )
2967  LevelBest = Gia_ObjLevelId(p, Abc_Lit2Var(iLit)), iLitBest = iLit;
2968  assert( iLitBest != -1 );
2969  // create new manager
2970  pNew = Gia_ManStart( Gia_ManObjNum(p) );
2971  pNew->pName = Abc_UtilStrsav( p->pName );
2972  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
2973  Gia_ManConst0(p)->Value = 0;
2974  Gia_ManHashAlloc( pNew );
2975  Gia_ManForEachObj1( p, pObj, i )
2976  {
2977  if ( Gia_ObjIsAnd(pObj) )
2978  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
2979  else if ( Gia_ObjIsCi(pObj) )
2980  pObj->Value = Gia_ManAppendCi( pNew );
2981  }
2982  // create AND of nodes
2983  iDriver = -1;
2984  Vec_IntForEachEntry( vSuper, iLit, i )
2985  {
2986  if ( iLit == iLitBest )
2987  continue;
2988  if ( iDriver == -1 )
2989  iDriver = Gia_ObjLitCopy(p, iLit);
2990  else
2991  iDriver = Gia_ManHashAnd( pNew, iDriver, Gia_ObjLitCopy(p, iLit) );
2992  }
2993  // create the main PO
2994  Gia_ManAppendCo( pNew, Gia_ObjLitCopy(p, iLitBest) );
2995  // create the constraint PO
2996  Gia_ManAppendCo( pNew, Abc_LitNot(iDriver) );
2997  pNew->nConstrs = 1;
2998  // rehash
2999  pNew = Gia_ManCleanup( pTemp = pNew );
3000  Gia_ManStop( pTemp );
3001  Vec_IntFree( vSuper );
3002  return pNew;
3003 
3004 }
3005 
3006 /**Function*************************************************************
3007 
3008  Synopsis [Compares two objects by their distance.]
3009 
3010  Description []
3011 
3012  SideEffects []
3013 
3014  SeeAlso []
3015 
3016 ***********************************************************************/
3018 {
3019  int Diff = Gia_Regular(*pp1)->Value - Gia_Regular(*pp2)->Value;
3020  if ( Diff < 0 )
3021  return -1;
3022  if ( Diff > 0 )
3023  return 1;
3024  return 0;
3025 }
3026 
3027 /**Function*************************************************************
3028 
3029  Synopsis [Decomposes the miter outputs.]
3030 
3031  Description []
3032 
3033  SideEffects []
3034 
3035  SeeAlso []
3036 
3037 ***********************************************************************/
3039 {
3040  Vec_Int_t * vSuper;
3041  Vec_Ptr_t * vSuperPtr;
3042  Gia_Man_t * pNew, * pTemp;
3043  Gia_Obj_t * pObj, * pObjPo;
3044  int i, iLit;
3045  assert( Gia_ManPoNum(p) == 1 );
3046  // decompose
3047  pObjPo = Gia_ManPo( p, 0 );
3048  vSuper = Vec_IntAlloc( 100 );
3049  Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjFanin0(pObjPo), vSuper, 1 );
3050  assert( Vec_IntSize(vSuper) > 1 );
3051  // report the result
3052  printf( "The miter is %s-decomposable into %d parts.\n", Gia_ObjFaninC0(pObjPo) ? "OR":"AND", Vec_IntSize(vSuper) );
3053  // create levels
3054  Gia_ManLevelNum( p );
3055  Vec_IntForEachEntry( vSuper, iLit, i )
3056  Gia_ManObj(p, Abc_Lit2Var(iLit))->Value = Gia_ObjLevelId(p, Abc_Lit2Var(iLit));
3057  // create pointer array
3058  vSuperPtr = Vec_PtrAlloc( Vec_IntSize(vSuper) );
3059  Vec_IntForEachEntry( vSuper, iLit, i )
3060  Vec_PtrPush( vSuperPtr, Gia_Lit2Obj(p, iLit) );
3061  Vec_PtrSort( vSuperPtr, (int (*)(void))Gia_ManSortByValue );
3062  // create new manager
3063  pNew = Gia_ManStart( Gia_ManObjNum(p) );
3064  pNew->pName = Abc_UtilStrsav( p->pName );
3065  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
3066  Gia_ManConst0(p)->Value = 0;
3067  Gia_ManHashAlloc( pNew );
3068  Gia_ManForEachCi( p, pObj, i )
3069  pObj->Value = Gia_ManAppendCi( pNew );
3070  Gia_ManForEachAnd( p, pObj, i )
3071  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
3072  // create the outputs
3073  Vec_PtrForEachEntry( Gia_Obj_t *, vSuperPtr, pObj, i )
3074  Gia_ManAppendCo( pNew, Gia_ObjLitCopy(p, Gia_Obj2Lit(p, pObj)) ^ Gia_ObjFaninC0(pObjPo) );
3075  Gia_ManForEachRi( p, pObj, i )
3076  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
3077  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
3078  // rehash
3079  pNew = Gia_ManCleanup( pTemp = pNew );
3080  Gia_ManStop( pTemp );
3081  Vec_IntFree( vSuper );
3082  Vec_PtrFree( vSuperPtr );
3083  return pNew;
3084 }
3085 
3086 /**Function*************************************************************
3087 
3088  Synopsis [Decomposes the miter outputs.]
3089 
3090  Description []
3091 
3092  SideEffects []
3093 
3094  SeeAlso []
3095 
3096 ***********************************************************************/
3098 {
3099  Gia_Man_t * pNew;
3100  Gia_Obj_t * pObj;
3101  int i;
3102  pNew = Gia_ManStart( Gia_ManObjNum(p) );
3103  pNew->pName = Abc_UtilStrsav( p->pName );
3104  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
3105  Gia_ManConst0(p)->Value = 0;
3106  Gia_ManForEachCi( p, pObj, i )
3107  pObj->Value = Gia_ManAppendCi(pNew);
3108  Gia_ManForEachAnd( p, pObj, i )
3109  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
3110  Gia_ManForEachPo( p, pObj, i )
3111  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
3112  Gia_ManForEachAnd( p, pObj, i )
3113  Gia_ManAppendCo( pNew, pObj->Value );
3114  Gia_ManForEachRi( p, pObj, i )
3115  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
3116  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
3117  assert( Gia_ManIsNormalized(pNew) );
3118  return pNew;
3119 }
3120 
3121 ////////////////////////////////////////////////////////////////////////
3122 /// END OF FILE ///
3123 ////////////////////////////////////////////////////////////////////////
3124 
3125 
3127 
int nObjsAlloc
Definition: gia.h:102
static int Gia_ObjFanin2Copy(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:483
static int Gia_ObjToLit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:497
static int Gia_ObjLevelId(Gia_Man_t *p, int Id)
Definition: gia.h:500
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
Gia_Man_t * Gia_ManDupTopAnd(Gia_Man_t *p, int fVerbose)
Definition: giaDup.c:2075
Gia_Man_t * Gia_ManTransformMiter(Gia_Man_t *p)
Definition: giaDup.c:2324
Gia_Man_t * Gia_ManDupPerm(Gia_Man_t *p, Vec_Int_t *vPiPerm)
Definition: giaDup.c:632
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_NAMESPACE_IMPL_START void Gia_ManDupRemapEquiv(Gia_Man_t *pNew, Gia_Man_t *p)
DECLARATIONS ///.
Definition: giaDup.c:46
int Gia_ManPoIsToRemove(Gia_Man_t *p, Gia_Obj_t *pObj, int Value)
Definition: giaDup.c:1618
static int Gia_ManAppendMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
Definition: gia.h:664
Gia_Man_t * Gia_ManDupPermFlopGap(Gia_Man_t *p, Vec_Int_t *vFfMask)
Definition: giaDup.c:725
Gia_Man_t * Gia_ManDupSelectedOutputs(Gia_Man_t *p, Vec_Int_t *vOutsLeft)
Definition: giaDup.c:266
Gia_Man_t * Gia_ManDupDfsCiMap(Gia_Man_t *p, int *pCi2Lit, Vec_Int_t *vLits)
Definition: giaDup.c:1890
static Gia_Obj_t * Gia_ObjSiblObj(Gia_Man_t *p, int Id)
Definition: gia.h:894
int Gia_ManSuppSize(Gia_Man_t *p, int *pNodes, int nNodes)
Definition: giaDfs.c:300
static int Gia_ObjPhaseReal(Gia_Obj_t *pObj)
Definition: gia.h:416
Gia_Man_t * Gia_ManChoiceMiter(Vec_Ptr_t *vGias)
Definition: giaDup.c:2574
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Gia_Man_t * Gia_ManDupTrimmed(Gia_Man_t *p, int fTrimCis, int fTrimCos, int fDualOut, int OutValue)
Definition: giaDup.c:1638
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
Gia_Man_t * Gia_ManDupSliced(Gia_Man_t *p, int nSuppMax)
Definition: giaDup.c:2888
int * pHTable
Definition: gia.h:110
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
Gia_Man_t * pAigExtra
Definition: gia.h:149
int * pNexts
Definition: gia.h:122
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
Gia_Man_t * Gia_ManDupDfs(Gia_Man_t *p)
Definition: giaDup.c:1238
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
int Gia_ObjCompareByCioId(Gia_Obj_t **pp1, Gia_Obj_t **pp2)
Definition: giaDup.c:2666
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Gia_ManDupCofactorVar_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:1272
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
Gia_Man_t * Gia_ManDupSelf(Gia_Man_t *p)
Definition: giaDup.c:890
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
static int Gia_ManCiLit(Gia_Man_t *p, int CiId)
Definition: gia.h:435
static Gia_Obj_t * Gia_ObjFromLit(Gia_Man_t *p, int iLit)
Definition: gia.h:496
static Gia_Obj_t * Gia_ManPo(Gia_Man_t *p, int v)
Definition: gia.h:406
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition: giaDup.c:2691
static int Gia_ObjFaninLit0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:469
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
Definition: gia.h:429
int * pSibls
Definition: gia.h:123
Gia_Man_t * Gia_ManDupOrderDfsReverse(Gia_Man_t *p)
Definition: giaDup.c:363
void Gia_ManDupOrderDfsChoices_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:298
void Gia_ManDupRemapCis(Gia_Man_t *pNew, Gia_Man_t *p)
Definition: giaDup.c:92
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition: giaUtil.c:215
Gia_Man_t * Gia_ManDupOneHot(Gia_Man_t *p)
Definition: giaDup.c:2785
Gia_Man_t * Gia_ManDupMarked(Gia_Man_t *p)
Definition: giaDup.c:975
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static Vec_Int_t * Vec_IntInvert(Vec_Int_t *p, int Fill)
Definition: vecInt.h:1092
Gia_Man_t * Gia_ManDupTopAnd_iter(Gia_Man_t *p, int fVerbose)
Definition: giaDup.c:1974
Gia_Man_t * Gia_ManDupAppendNew(Gia_Man_t *pOne, Gia_Man_t *pTwo)
Definition: giaDup.c:783
Vec_Int_t * vCos
Definition: gia.h:109
int Gia_ManDupOrderDfs_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:144
unsigned * pMuxes
Definition: gia.h:104
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
Gia_Man_t * Gia_ManDupDfsSkip(Gia_Man_t *p)
Definition: giaDup.c:1454
Vec_Int_t * vFlopClasses
Definition: gia.h:140
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Gia_ManPrintStatsShort(Gia_Man_t *p)
Definition: giaMan.c:522
Gia_Man_t * Gia_ManMiter2(Gia_Man_t *pStart, char *pInit, int fVerbose)
Definition: giaDup.c:2462
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
Vec_Int_t * Gia_ManDupTrimmedNonZero(Gia_Man_t *p)
Definition: giaDup.c:1585
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
unsigned fMark1
Definition: gia.h:84
unsigned iRepr
Definition: gia.h:58
int nObjs
Definition: gia.h:101
Gia_Man_t * Gia_ManDupZero(Gia_Man_t *p)
Definition: giaDup.c:608
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int nSuppMax
Definition: llb3Image.c:83
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
Definition: vecInt.h:1293
void Gia_ManPrintRepr(Gia_Man_t *p)
Definition: giaDup.c:1869
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Gia_Man_t * Gia_ManDupOrderAiger(Gia_Man_t *p)
Definition: giaDup.c:397
Definition: gia.h:75
void Gia_ManDupDfs3_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:1514
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition: vecBit.h:42
int Gia_ManHasDangling(Gia_Man_t *p)
Definition: giaUtil.c:1155
static int Gia_ManHasChoices(Gia_Man_t *p)
Definition: gia.h:397
int Gia_ManMiter_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:2107
static int * Vec_BitArray(Vec_Bit_t *p)
Definition: vecBit.h:223
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49
Gia_Man_t * Gia_ManDupCycled(Gia_Man_t *p, Abc_Cex_t *pCex, int nFrames)
Definition: giaDup.c:523
Gia_Man_t * Gia_ManDupLevelized(Gia_Man_t *p)
Definition: giaDup.c:2812
Gia_Man_t * Gia_ManDupDfsCone(Gia_Man_t *p, Gia_Obj_t *pRoot)
Definition: giaDup.c:1484
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
Definition: gia.h:458
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition: gia.h:1042
static void Gia_ObjSetRepr(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:888
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Gia_Man_t * Gia_ManDupWithAttributes(Gia_Man_t *p)
Definition: giaDup.c:583
Gia_Man_t * Gia_ManDupSpreadFlop(Gia_Man_t *p, Vec_Int_t *vFfMask)
Definition: giaDup.c:689
static int Gia_ManAppendMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: gia.h:722
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
Gia_Man_t * Gia_ManDupDfs2(Gia_Man_t *p)
Definition: giaDup.c:1190
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
static int Gia_ObjSibl(Gia_Man_t *p, int Id)
Definition: gia.h:893
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
Definition: gia.h:405
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
Gia_Man_t * Gia_ManDupPermFlop(Gia_Man_t *p, Vec_Int_t *vFfPerm)
Definition: giaDup.c:663
int nConstrs
Definition: gia.h:117
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int Gia_ManChoiceMiter_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:2552
Gia_Man_t * Gia_ManDupFlopClass(Gia_Man_t *p, int iClass)
Definition: giaDup.c:930
int Gia_ManDupDfs2_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:1158
void Gia_ManDupAppendShare(Gia_Man_t *pNew, Gia_Man_t *pTwo)
Definition: giaDup.c:765
Gia_Man_t * Gia_ManDupFromVecs(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, int nRegs)
Definition: giaDup.c:2853
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
#define Gia_ManForEachConst(p, i)
Definition: gia.h:925
Gia_Man_t * Gia_ManDupNormalize(Gia_Man_t *p)
Definition: giaTim.c:134
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
static int Gia_ManAppendBuf(Gia_Man_t *p, int iLit)
Definition: gia.h:694
static int Gia_ObjIsRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:444
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Gia_ObjSetCioId(Gia_Obj_t *pObj, int v)
Definition: gia.h:412
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
Gia_Man_t * Gia_ManDupTrimmed2(Gia_Man_t *p)
Definition: giaDup.c:1719
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
if(last==0)
Definition: sparse_int.h:34
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
Gia_Man_t * Gia_ManDupOrderDfsChoices(Gia_Man_t *p)
Definition: giaDup.c:328
static int Gia_ObjIsXor(Gia_Obj_t *pObj)
Definition: gia.h:423
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
Gia_Man_t * Gia_ManSeqStructSweep(Gia_Man_t *p, int fConst, int fEquiv, int fVerbose)
Definition: giaScl.c:258
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
Gia_Man_t * Gia_ManDupDfsLitArray(Gia_Man_t *p, Vec_Int_t *vLits)
Definition: giaDup.c:1553
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Gia_Man_t * Gia_ManDupExist2(Gia_Man_t *p, int iVar)
Definition: giaDup.c:1407
void * pManTime
Definition: gia.h:165
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
void Gia_ManDupCones_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vNodes, Vec_Ptr_t *vRoots)
Definition: giaDup.c:2672
Gia_Man_t * Gia_ManDupAppendCones(Gia_Man_t *p, Gia_Man_t **ppCones, int nCones, int fOnlyRegs)
Definition: giaDup.c:836
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static Vec_Bit_t * Vec_BitAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecBit.h:80
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static Gia_Obj_t * Gia_ObjNextObj(Gia_Man_t *p, int Id)
Definition: gia.h:911
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int * Gia_ManDeriveNexts(Gia_Man_t *p)
Definition: giaEquiv.c:97
static int Gia_ObjLitCopy(Gia_Man_t *p, int iLit)
Definition: gia.h:479
static int pPerm[13719]
Definition: rwrTemp.c:32
void Gia_ManDupRemapCos(Gia_Man_t *pNew, Gia_Man_t *p)
Definition: giaDup.c:118
Gia_Man_t * Gia_ManDupOrderDfs(Gia_Man_t *p)
Definition: giaDup.c:170
Gia_Man_t * Gia_ManDupCofactorObj(Gia_Man_t *p, int iObj, int Value)
Definition: giaDup.c:1319
Gia_Man_t * Gia_ManOneHot(int nSkips, int nVars)
Definition: giaDup.c:2759
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
Gia_Man_t * Gia_ManDupWithConstraints(Gia_Man_t *p, Vec_Int_t *vPoTypes)
Definition: giaDup.c:2627
#define Gia_ClassForEachObj(p, i, iObj)
Definition: gia.h:931
int nAnd2Delay
Definition: gia.h:173
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Vec_Int_t * vCis
Definition: gia.h:108
Gia_Man_t * Gia_ManDupOntop(Gia_Man_t *p, Gia_Man_t *p2)
Definition: giaDup.c:1772
Gia_Man_t * Gia_ManDupDemiter(Gia_Man_t *p, int fVerbose)
Definition: giaDup.c:3038
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Gia_Obj_t * Gia_ObjReprObj(Gia_Man_t *p, int Id)
Definition: gia.h:886
Gia_Man_t * Gia_ManMiter(Gia_Man_t *p0, Gia_Man_t *p1, int nInsDup, int fDualOut, int fSeq, int fImplic, int fVerbose)
Definition: giaDup.c:2128
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
Gia_Man_t * Gia_ManDupOutputGroup(Gia_Man_t *p, int iOutStart, int iOutStop)
Definition: giaDup.c:203
int Gia_ManSortByValue(Gia_Obj_t **pp1, Gia_Obj_t **pp2)
Definition: giaDup.c:3017
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static void Gia_ObjRefFanin0Dec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:527
#define GIA_VOID
Definition: gia.h:45
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
Definition: gia.h:404
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nRegs
Definition: gia.h:99
Gia_Man_t * Gia_ManDupOuts(Gia_Man_t *p)
Definition: giaDup.c:3097
Gia_Man_t * Gia_ManDupZeroUndc(Gia_Man_t *p, char *pInit, int fVerbose)
Definition: giaDup.c:2390
Gia_Man_t * Gia_ManDupTimes(Gia_Man_t *p, int nTimes)
Definition: giaDup.c:1078
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
unsigned fMark0
Definition: gia.h:79
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Gia_Obj_t * Gia_ObjRiToRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:447
Abc_Cex_t * Abc_CexDup(Abc_Cex_t *p, int nRegsNew)
Definition: utilCex.c:145
void Gia_ManDupDfs_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaDup.c:1229
Definition: gia.h:95
int Gia_ManIsNormalized(Gia_Man_t *p)
Definition: giaTim.c:109
static int Abc_Base2Log(unsigned n)
Definition: abc_global.h:251
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
Gia_Man_t * Gia_ManDupDfsNode(Gia_Man_t *p, Gia_Obj_t *pRoot)
Definition: giaDup.c:1528
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void Gia_ManTransferPacking(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1878
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
static int Gia_ObjIsPo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:442
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define Gia_ManForEachClass(p, i)
Definition: gia.h:927
static void Vec_BitFree(Vec_Bit_t *p)
Definition: vecBit.h:167
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
void Gia_ManTransferMapping(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1855
Gia_Rpr_t * pReprs
Definition: gia.h:121
#define assert(ex)
Definition: util_old.h:213
int strlen()
Gia_Man_t * Gia_ManDupExist(Gia_Man_t *p, int iVar)
Definition: giaDup.c:1360
int Gia_ManLevelNum(Gia_Man_t *p)
Definition: giaUtil.c:505
unsigned Value
Definition: gia.h:87
void Gia_ManCycle(Gia_Man_t *p, Abc_Cex_t *pCex, int nFrames)
Definition: giaDup.c:503
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
Gia_Man_t * Gia_ManDupDfsClasses(Gia_Man_t *p)
Definition: giaDup.c:1940
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
static Gia_Obj_t * Gia_Lit2Obj(Gia_Man_t *p, int iLit)
Definition: gia.h:434
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
#define Gia_ManForEachObj1(p, pObj, i)
Definition: gia.h:986
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
Gia_Man_t * Gia_ManDupFlip(Gia_Man_t *p, int *pInitState)
Definition: giaDup.c:460
static void Vec_BitPush(Vec_Bit_t *p, int Entry)
Definition: vecBit.h:516
Gia_Man_t * Gia_ManDupOutputVec(Gia_Man_t *p, Vec_Int_t *vOutPres)
Definition: giaDup.c:232
void Gia_ManDupAppend(Gia_Man_t *pNew, Gia_Man_t *pTwo)
Definition: giaDup.c:746
static int Gia_ObjFaninLit1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:470
Definition: gia.h:56
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
void Gia_ManDupWithConstrCollectAnd_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, int fFirst)
Definition: giaDup.c:2936
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static Gia_Obj_t * Gia_ManRo(Gia_Man_t *p, int v)
Definition: gia.h:407
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Gia_ManCleanMark01(Gia_Man_t *p)
Definition: giaUtil.c:177
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Gia_Man_t * Gia_ManDupLastPis(Gia_Man_t *p, int nLastPis)
Definition: giaDup.c:429
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ObjIsMux(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:425
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:611
static int Gia_ManAppendXorReal(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:639
Gia_Man_t * Gia_ManDupWithConstr(Gia_Man_t *p)
Definition: giaDup.c:2946
Gia_Man_t * Gia_ManTransformToDual(Gia_Man_t *p)
Definition: giaDup.c:2353
#define Gia_ManForEachCoReverse(p, pObj, i)
Definition: gia.h:1028
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
static Vec_Int_t * Vec_IntCondense(Vec_Int_t *p, int Fill)
Definition: vecInt.h:1116
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int * pReprsOld
Definition: gia.h:120
Gia_Man_t * Gia_ManDupWithNewPo(Gia_Man_t *p1, Gia_Man_t *p2)
Definition: giaDup.c:1816
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
static Gia_Obj_t * Gia_ManRi(Gia_Man_t *p, int v)
Definition: gia.h:408
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ObjIsPi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:441
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
Gia_Man_t * Gia_ManDupCofactorVar(Gia_Man_t *p, int iVar, int Value)
Definition: giaDup.c:1281
Abc_Cex_t * pCexSeq
Definition: gia.h:136
Gia_Man_t * Gia_ManDupAndOr(Gia_Man_t *p, int nOuts, int fUseOr, int fCompl)
Definition: giaDup.c:2275
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387