abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcIvy.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcIvy.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Strashing of the current network.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcIvy.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "bool/dec/dec.h"
23 #include "proof/fra/fra.h"
24 #include "aig/ivy/ivy.h"
25 #include "proof/fraig/fraig.h"
26 #include "map/mio/mio.h"
27 #include "aig/aig/aig.h"
28 #include "misc/extra/extraBdd.h"
29 
31 
32 extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
33 extern void Aig_ManStop( Aig_Man_t * pMan );
34 //extern int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fNewSolver, int fVerbose );
35 extern Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph );
36 extern void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs );
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// DECLARATIONS ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 static Abc_Ntk_t * Abc_NtkFromIvy( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan );
43 static Abc_Ntk_t * Abc_NtkFromIvySeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig );
44 static Ivy_Man_t * Abc_NtkToIvy( Abc_Ntk_t * pNtkOld );
45 
46 static void Abc_NtkStrashPerformAig( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan );
47 static Ivy_Obj_t * Abc_NodeStrashAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode );
48 static Ivy_Obj_t * Abc_NodeStrashAigSopAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop );
49 static Ivy_Obj_t * Abc_NodeStrashAigExorAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop );
50 static Ivy_Obj_t * Abc_NodeStrashAigFactorAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop );
51 
52 typedef int Abc_Edge_t;
53 static inline Abc_Edge_t Abc_EdgeCreate( int Id, int fCompl ) { return (Id << 1) | fCompl; }
54 static inline int Abc_EdgeId( Abc_Edge_t Edge ) { return Edge >> 1; }
55 static inline int Abc_EdgeIsComplement( Abc_Edge_t Edge ) { return Edge & 1; }
56 static inline Abc_Edge_t Abc_EdgeRegular( Abc_Edge_t Edge ) { return (Edge >> 1) << 1; }
57 static inline Abc_Edge_t Abc_EdgeNot( Abc_Edge_t Edge ) { return Edge ^ 1; }
58 static inline Abc_Edge_t Abc_EdgeNotCond( Abc_Edge_t Edge, int fCond ) { return Edge ^ fCond; }
59 static inline Abc_Edge_t Abc_EdgeFromNode( Abc_Obj_t * pNode ) { return Abc_EdgeCreate( Abc_ObjRegular(pNode)->Id, Abc_ObjIsComplement(pNode) ); }
60 static inline Abc_Obj_t * Abc_EdgeToNode( Abc_Ntk_t * p, Abc_Edge_t Edge ) { return Abc_ObjNotCond( Abc_NtkObj(p, Abc_EdgeId(Edge)), Abc_EdgeIsComplement(Edge) ); }
61 
62 static inline Abc_Obj_t * Abc_ObjFanin0Ivy( Abc_Ntk_t * p, Ivy_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_EdgeToNode(p, Ivy_ObjFanin0(pObj)->TravId), Ivy_ObjFaninC0(pObj) ); }
63 static inline Abc_Obj_t * Abc_ObjFanin1Ivy( Abc_Ntk_t * p, Ivy_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_EdgeToNode(p, Ivy_ObjFanin1(pObj)->TravId), Ivy_ObjFaninC1(pObj) ); }
64 
65 static Vec_Int_t * Abc_NtkCollectLatchValuesIvy( Abc_Ntk_t * pNtk, int fUseDcs );
66 
67 extern int timeRetime;
68 
69 ////////////////////////////////////////////////////////////////////////
70 /// FUNCTION DEFINITIONS ///
71 ////////////////////////////////////////////////////////////////////////
72 
73 /**Function*************************************************************
74 
75  Synopsis [Prepares the IVY package.]
76 
77  Description []
78 
79  SideEffects []
80 
81  SeeAlso []
82 
83 ***********************************************************************/
84 Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc )
85 {
86  Ivy_Man_t * pMan;
87 //timeRetime = Abc_Clock();
88  assert( !Abc_NtkIsNetlist(pNtk) );
89  if ( Abc_NtkIsBddLogic(pNtk) )
90  {
91  if ( !Abc_NtkBddToSop(pNtk, 0) )
92  {
93  printf( "Abc_NtkIvyBefore(): Converting to SOPs has failed.\n" );
94  return NULL;
95  }
96  }
97  if ( fSeq && Abc_NtkCountSelfFeedLatches(pNtk) )
98  {
99  printf( "Warning: The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtk) );
100 // return NULL;
101  }
102  // print warning about choice nodes
103  if ( Abc_NtkGetChoiceNum( pNtk ) )
104  printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" );
105  // convert to the AIG manager
106  pMan = Abc_NtkToIvy( pNtk );
107  if ( !Ivy_ManCheck( pMan ) )
108  {
109  printf( "AIG check has failed.\n" );
110  Ivy_ManStop( pMan );
111  return NULL;
112  }
113 // Ivy_ManPrintStats( pMan );
114  if ( fSeq )
115  {
116  int nLatches = Abc_NtkLatchNum(pNtk);
117  Vec_Int_t * vInit = Abc_NtkCollectLatchValuesIvy( pNtk, fUseDc );
118  Ivy_ManMakeSeq( pMan, nLatches, vInit->pArray );
119  Vec_IntFree( vInit );
120 // Ivy_ManPrintStats( pMan );
121  }
122 //timeRetime = Abc_Clock() - timeRetime;
123  return pMan;
124 }
125 
126 /**Function*************************************************************
127 
128  Synopsis [Prepares the IVY package.]
129 
130  Description []
131 
132  SideEffects []
133 
134  SeeAlso []
135 
136 ***********************************************************************/
137 Abc_Ntk_t * Abc_NtkIvyAfter( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan, int fSeq, int fHaig )
138 {
139  Abc_Ntk_t * pNtkAig;
140  int nNodes, fCleanup = 1;
141  // convert from the AIG manager
142  if ( fSeq )
143  pNtkAig = Abc_NtkFromIvySeq( pNtk, pMan, fHaig );
144  else
145  pNtkAig = Abc_NtkFromIvy( pNtk, pMan );
146  // report the cleanup results
147  if ( !fHaig && fCleanup && (nNodes = Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc)) )
148  printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes );
149  // duplicate EXDC
150  if ( pNtk->pExdc )
151  pNtkAig->pExdc = Abc_NtkDup( pNtk->pExdc );
152  // make sure everything is okay
153  if ( !Abc_NtkCheck( pNtkAig ) )
154  {
155  printf( "Abc_NtkStrash: The network check has failed.\n" );
156  Abc_NtkDelete( pNtkAig );
157  return NULL;
158  }
159  return pNtkAig;
160 }
161 
162 /**Function*************************************************************
163 
164  Synopsis [Gives the current ABC network to AIG manager for processing.]
165 
166  Description []
167 
168  SideEffects []
169 
170  SeeAlso []
171 
172 ***********************************************************************/
174 {
175  Abc_Ntk_t * pNtkAig;
176  Ivy_Man_t * pMan;
177  pMan = Abc_NtkIvyBefore( pNtk, 1, 0 );
178  if ( pMan == NULL )
179  return NULL;
180  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 1, 0 );
181  Ivy_ManStop( pMan );
182  return pNtkAig;
183 }
184 
185 /**Function*************************************************************
186 
187  Synopsis [Gives the current ABC network to AIG manager for processing.]
188 
189  Description []
190 
191  SideEffects []
192 
193  SeeAlso []
194 
195 ***********************************************************************/
196 Abc_Ntk_t * Abc_NtkIvyHaig( Abc_Ntk_t * pNtk, int nIters, int fUseZeroCost, int fVerbose )
197 {
198  Abc_Ntk_t * pNtkAig;
199  Ivy_Man_t * pMan;
200  abctime clk;
201 // int i;
202 /*
203 extern int nMoves;
204 extern int nMovesS;
205 extern int nClauses;
206 extern int timeInv;
207 
208 nMoves = 0;
209 nMovesS = 0;
210 nClauses = 0;
211 timeInv = 0;
212 */
213  pMan = Abc_NtkIvyBefore( pNtk, 1, 1 );
214  if ( pMan == NULL )
215  return NULL;
216 //timeRetime = Abc_Clock();
217 
218 clk = Abc_Clock();
219  Ivy_ManHaigStart( pMan, fVerbose );
220 // Ivy_ManRewriteSeq( pMan, 0, 0 );
221 // for ( i = 0; i < nIters; i++ )
222 // Ivy_ManRewriteSeq( pMan, fUseZeroCost, 0 );
223 
224 //printf( "%d ", Ivy_ManNodeNum(pMan) );
225  Ivy_ManRewriteSeq( pMan, 0, 0 );
226  Ivy_ManRewriteSeq( pMan, 0, 0 );
227  Ivy_ManRewriteSeq( pMan, 1, 0 );
228 //printf( "%d ", Ivy_ManNodeNum(pMan) );
229 //printf( "%d ", Ivy_ManNodeNum(pMan->pHaig) );
230 //ABC_PRT( " ", Abc_Clock() - clk );
231 //printf( "\n" );
232 /*
233  printf( "Moves = %d. ", nMoves );
234  printf( "MovesS = %d. ", nMovesS );
235  printf( "Clauses = %d. ", nClauses );
236  ABC_PRT( "Time", timeInv );
237 */
238 // Ivy_ManRewriteSeq( pMan, 1, 0 );
239 //printf( "Haig size = %d.\n", Ivy_ManNodeNum(pMan->pHaig) );
240 // Ivy_ManHaigPostprocess( pMan, fVerbose );
241 //timeRetime = Abc_Clock() - timeRetime;
242 
243  // write working AIG into the current network
244 // pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 1, 0 );
245  // write HAIG into the current network
246  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan->pHaig, 1, 1 );
247 
248  Ivy_ManHaigStop( pMan );
249  Ivy_ManStop( pMan );
250  return pNtkAig;
251 }
252 
253 /**Function*************************************************************
254 
255  Synopsis [Gives the current ABC network to AIG manager for processing.]
256 
257  Description []
258 
259  SideEffects []
260 
261  SeeAlso []
262 
263 ***********************************************************************/
264 void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs )
265 {
266  Ivy_Man_t * pMan;
267  pMan = Abc_NtkIvyBefore( pNtk, 1, 0 );
268  if ( pMan == NULL )
269  return;
270  Ivy_CutComputeAll( pMan, nInputs );
271  Ivy_ManStop( pMan );
272 }
273 
274 /**Function*************************************************************
275 
276  Synopsis [Gives the current ABC network to AIG manager for processing.]
277 
278  Description []
279 
280  SideEffects []
281 
282  SeeAlso []
283 
284 ***********************************************************************/
285 Abc_Ntk_t * Abc_NtkIvyRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeroCost, int fVerbose )
286 {
287  Abc_Ntk_t * pNtkAig;
288  Ivy_Man_t * pMan;
289  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
290  if ( pMan == NULL )
291  return NULL;
292 //timeRetime = Abc_Clock();
293  Ivy_ManRewritePre( pMan, fUpdateLevel, fUseZeroCost, fVerbose );
294 //timeRetime = Abc_Clock() - timeRetime;
295  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
296  Ivy_ManStop( pMan );
297  return pNtkAig;
298 }
299 
300 /**Function*************************************************************
301 
302  Synopsis [Gives the current ABC network to AIG manager for processing.]
303 
304  Description []
305 
306  SideEffects []
307 
308  SeeAlso []
309 
310 ***********************************************************************/
311 Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbose )
312 {
313  Abc_Ntk_t * pNtkAig;
314  Ivy_Man_t * pMan;
315  pMan = Abc_NtkIvyBefore( pNtk, 1, 1 );
316  if ( pMan == NULL )
317  return NULL;
318 //timeRetime = Abc_Clock();
319  Ivy_ManRewriteSeq( pMan, fUseZeroCost, fVerbose );
320 //timeRetime = Abc_Clock() - timeRetime;
321 // Ivy_ManRewriteSeq( pMan, 1, 0 );
322 // Ivy_ManRewriteSeq( pMan, 1, 0 );
323  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 1, 0 );
324  Ivy_ManStop( pMan );
325  return pNtkAig;
326 }
327 
328 /**Function*************************************************************
329 
330  Synopsis [Gives the current ABC network to AIG manager for processing.]
331 
332  Description []
333 
334  SideEffects []
335 
336  SeeAlso []
337 
338 ***********************************************************************/
339 Abc_Ntk_t * Abc_NtkIvyResyn0( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose )
340 {
341  Abc_Ntk_t * pNtkAig;
342  Ivy_Man_t * pMan, * pTemp;
343  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
344  if ( pMan == NULL )
345  return NULL;
346  pMan = Ivy_ManResyn0( pTemp = pMan, fUpdateLevel, fVerbose );
347  Ivy_ManStop( pTemp );
348  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
349  Ivy_ManStop( pMan );
350  return pNtkAig;
351 }
352 
353 /**Function*************************************************************
354 
355  Synopsis [Gives the current ABC network to AIG manager for processing.]
356 
357  Description []
358 
359  SideEffects []
360 
361  SeeAlso []
362 
363 ***********************************************************************/
364 Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose )
365 {
366  Abc_Ntk_t * pNtkAig;
367  Ivy_Man_t * pMan, * pTemp;
368  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
369  if ( pMan == NULL )
370  return NULL;
371  pMan = Ivy_ManResyn( pTemp = pMan, fUpdateLevel, fVerbose );
372  Ivy_ManStop( pTemp );
373  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
374  Ivy_ManStop( pMan );
375  return pNtkAig;
376 }
377 
378 /**Function*************************************************************
379 
380  Synopsis [Gives the current ABC network to AIG manager for processing.]
381 
382  Description []
383 
384  SideEffects []
385 
386  SeeAlso []
387 
388 ***********************************************************************/
389 Abc_Ntk_t * Abc_NtkIvySat( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose )
390 {
391  Ivy_FraigParams_t Params, * pParams = &Params;
392  Abc_Ntk_t * pNtkAig;
393  Ivy_Man_t * pMan, * pTemp;
394  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
395  if ( pMan == NULL )
396  return NULL;
397  Ivy_FraigParamsDefault( pParams );
398  pParams->nBTLimitMiter = nConfLimit;
399  pParams->fVerbose = fVerbose;
400 // pMan = Ivy_FraigPerform( pTemp = pMan, pParams );
401  pMan = Ivy_FraigMiter( pTemp = pMan, pParams );
402  Ivy_ManStop( pTemp );
403  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
404  Ivy_ManStop( pMan );
405  return pNtkAig;
406 }
407 
408 /**Function*************************************************************
409 
410  Synopsis [Sets the final nodes to point to the original nodes.]
411 
412  Description []
413 
414  SideEffects []
415 
416  SeeAlso []
417 
418 ***********************************************************************/
419 void Abc_NtkTransferPointers( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig )
420 {
421  Abc_Obj_t * pObj;
422  Ivy_Obj_t * pObjIvy, * pObjFraig;
423  int i;
424  pObj = Abc_AigConst1(pNtk);
425  pObj->pCopy = Abc_AigConst1(pNtkAig);
426  Abc_NtkForEachCi( pNtk, pObj, i )
427  pObj->pCopy = Abc_NtkCi(pNtkAig, i);
428  Abc_NtkForEachCo( pNtk, pObj, i )
429  pObj->pCopy = Abc_NtkCo(pNtkAig, i);
430  Abc_NtkForEachLatch( pNtk, pObj, i )
431  pObj->pCopy = Abc_NtkBox(pNtkAig, i);
432  Abc_NtkForEachNode( pNtk, pObj, i )
433  {
434  pObjIvy = (Ivy_Obj_t *)pObj->pCopy;
435  if ( pObjIvy == NULL )
436  continue;
437  pObjFraig = Ivy_ObjEquiv( pObjIvy );
438  if ( pObjFraig == NULL )
439  continue;
440  pObj->pCopy = Abc_EdgeToNode( pNtkAig, Ivy_Regular(pObjFraig)->TravId );
441  pObj->pCopy = Abc_ObjNotCond( pObj->pCopy, Ivy_IsComplement(pObjFraig) );
442  }
443 }
444 
445 /**Function*************************************************************
446 
447  Synopsis [Gives the current ABC network to AIG manager for processing.]
448 
449  Description []
450 
451  SideEffects []
452 
453  SeeAlso []
454 
455 ***********************************************************************/
456 Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose )
457 {
458  Ivy_FraigParams_t Params, * pParams = &Params;
459  Abc_Ntk_t * pNtkAig;
460  Ivy_Man_t * pMan, * pTemp;
461  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
462  if ( pMan == NULL )
463  return NULL;
464  Ivy_FraigParamsDefault( pParams );
465  pParams->nBTLimitNode = nConfLimit;
466  pParams->fVerbose = fVerbose;
467  pParams->fProve = fProve;
468  pParams->fDoSparse = fDoSparse;
469  pMan = Ivy_FraigPerform( pTemp = pMan, pParams );
470  // transfer the pointers
471  if ( fTransfer == 1 )
472  {
473  Vec_Ptr_t * vCopies;
474  vCopies = Abc_NtkSaveCopy( pNtk );
475  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
476  Abc_NtkLoadCopy( pNtk, vCopies );
477  Vec_PtrFree( vCopies );
478  Abc_NtkTransferPointers( pNtk, pNtkAig );
479  }
480  else
481  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
482  Ivy_ManStop( pTemp );
483  Ivy_ManStop( pMan );
484  return pNtkAig;
485 }
486 
487 /**Function*************************************************************
488 
489  Synopsis [Gives the current ABC network to AIG manager for processing.]
490 
491  Description []
492 
493  SideEffects []
494 
495  SeeAlso []
496 
497 ***********************************************************************/
498 int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars )
499 {
500  Prove_Params_t * pParams = (Prove_Params_t *)pPars;
501  Abc_Ntk_t * pNtk = *ppNtk, * pNtkTemp;
502  Abc_Obj_t * pObj, * pFanin;
503  Ivy_Man_t * pMan;
504  Aig_Man_t * pMan2;
505  int RetValue;
506  assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
507  // experiment with various parameters settings
508 // pParams->fUseBdds = 1;
509 // pParams->fBddReorder = 1;
510 // pParams->nTotalBacktrackLimit = 10000;
511 
512  // strash the network if it is not strashed already
513  if ( !Abc_NtkIsStrash(pNtk) )
514  {
515  pNtk = Abc_NtkStrash( pNtkTemp = pNtk, 0, 1, 0 );
516  Abc_NtkDelete( pNtkTemp );
517  }
518 
519  // check the case when the 0000 simulation pattern detect the bug
520  pObj = Abc_NtkPo(pNtk,0);
521  pFanin = Abc_ObjFanin0(pObj);
522  if ( Abc_ObjFanin0(pObj)->fPhase != (unsigned)Abc_ObjFaninC0(pObj) )
523  {
524  pNtk->pModel = ABC_CALLOC( int, Abc_NtkCiNum(pNtk) );
525  return 0;
526  }
527 
528  // changed in "src\sat\fraig\fraigMan.c"
529  // pParams->nMiteringLimitStart = 300; // starting mitering limit
530  // to be
531  // pParams->nMiteringLimitStart = 5000; // starting mitering limit
532 
533  // if SAT only, solve without iteration
534 // RetValue = Abc_NtkMiterSat( pNtk, 2*(ABC_INT64_T)pParams->nMiteringLimitStart, (ABC_INT64_T)0, 0, NULL, NULL );
535  pMan2 = Abc_NtkToDar( pNtk, 0, 0 );
536  RetValue = Fra_FraigSat( pMan2, (ABC_INT64_T)pParams->nMiteringLimitStart, (ABC_INT64_T)0, 0, 0, 0, 1, 0, 0, 0 );
537  pNtk->pModel = (int *)pMan2->pData, pMan2->pData = NULL;
538  Aig_ManStop( pMan2 );
539 // pNtk->pModel = Aig_ManReleaseData( pMan2 );
540  if ( RetValue >= 0 )
541  return RetValue;
542 
543  // apply AIG rewriting
544  if ( pParams->fUseRewriting && Abc_NtkNodeNum(pNtk) > 500 )
545  {
546 // abctime clk = Abc_Clock();
547 //printf( "Before rwsat = %d. ", Abc_NtkNodeNum(pNtk) );
548  pParams->fUseRewriting = 0;
549  pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );
550  Abc_NtkDelete( pNtkTemp );
551  Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
552  pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );
553  Abc_NtkDelete( pNtkTemp );
554  Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
555  Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
556 //printf( "After rwsat = %d. ", Abc_NtkNodeNum(pNtk) );
557 //ABC_PRT( "Time", Abc_Clock() - clk );
558  }
559 
560  // convert ABC network into IVY network
561  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
562 
563  // solve the CEC problem
564  RetValue = Ivy_FraigProve( &pMan, pParams );
565 // RetValue = -1;
566 
567  // convert IVY network into ABC network
568  pNtk = Abc_NtkIvyAfter( pNtkTemp = pNtk, pMan, 0, 0 );
569  Abc_NtkDelete( pNtkTemp );
570  // transfer model if given
571  pNtk->pModel = (int *)pMan->pData; pMan->pData = NULL;
572  Ivy_ManStop( pMan );
573 
574  // try to prove it using brute force SAT with good CNF encoding
575  if ( RetValue < 0 )
576  {
577  pMan2 = Abc_NtkToDar( pNtk, 0, 0 );
578  // dump the miter before entering high-effort solving
579  if ( pParams->fVerbose )
580  {
581  char pFileName[100];
582  sprintf( pFileName, "cecmiter.aig" );
583  Ioa_WriteAiger( pMan2, pFileName, 0, 0 );
584  printf( "Intermediate reduced miter is written into file \"%s\".\n", pFileName );
585  }
586  RetValue = Fra_FraigSat( pMan2, pParams->nMiteringLimitLast, 0, 0, 0, 0, 0, 0, 0, pParams->fVerbose );
587  pNtk->pModel = (int *)pMan2->pData, pMan2->pData = NULL;
588  Aig_ManStop( pMan2 );
589  }
590 
591  // try to prove it using brute force BDDs
592  if ( RetValue < 0 && pParams->fUseBdds )
593  {
594  if ( pParams->fVerbose )
595  {
596  printf( "Attempting BDDs with node limit %d ...\n", pParams->nBddSizeLimit );
597  fflush( stdout );
598  }
599  pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0 );
600  if ( pNtk )
601  {
602  Abc_NtkDelete( pNtkTemp );
603  RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero((DdManager *)pNtk->pManFunc)) );
604  }
605  else
606  pNtk = pNtkTemp;
607  }
608 
609  // return the result
610  *ppNtk = pNtk;
611  return RetValue;
612 }
613 
614 /**Function*************************************************************
615 
616  Synopsis [Gives the current ABC network to AIG manager for processing.]
617 
618  Description []
619 
620  SideEffects []
621 
622  SeeAlso []
623 
624 ***********************************************************************/
626 {
627 // Abc_Ntk_t * pNtkAig;
628  Ivy_Man_t * pMan;//, * pTemp;
629 // int fCleanup = 1;
630 // int nNodes;
631 // int nLatches = Abc_NtkLatchNum(pNtk);
632  Vec_Int_t * vInit = Abc_NtkCollectLatchValuesIvy( pNtk, 0 );
633 
634  assert( !Abc_NtkIsNetlist(pNtk) );
635  if ( Abc_NtkIsBddLogic(pNtk) )
636  {
637  if ( !Abc_NtkBddToSop(pNtk, 0) )
638  {
639  Vec_IntFree( vInit );
640  printf( "Abc_NtkIvy(): Converting to SOPs has failed.\n" );
641  return NULL;
642  }
643  }
644  if ( Abc_NtkCountSelfFeedLatches(pNtk) )
645  {
646  printf( "Warning: The network has %d self-feeding latches. Quitting.\n", Abc_NtkCountSelfFeedLatches(pNtk) );
647  return NULL;
648  }
649 
650  // print warning about choice nodes
651  if ( Abc_NtkGetChoiceNum( pNtk ) )
652  printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" );
653 
654  // convert to the AIG manager
655  pMan = Abc_NtkToIvy( pNtk );
656  if ( !Ivy_ManCheck( pMan ) )
657  {
658  Vec_IntFree( vInit );
659  printf( "AIG check has failed.\n" );
660  Ivy_ManStop( pMan );
661  return NULL;
662  }
663 
664 // Ivy_MffcTest( pMan );
665 // Ivy_ManPrintStats( pMan );
666 
667 // pMan = Ivy_ManBalance( pTemp = pMan, 1 );
668 // Ivy_ManStop( pTemp );
669 
670 // Ivy_ManSeqRewrite( pMan, 0, 0 );
671 // Ivy_ManTestCutsAlg( pMan );
672 // Ivy_ManTestCutsBool( pMan );
673 // Ivy_ManRewriteAlg( pMan, 1, 1 );
674 
675 // pMan = Ivy_ManResyn( pTemp = pMan, 1, 0 );
676 // Ivy_ManStop( pTemp );
677 
678 // Ivy_ManTestCutsAll( pMan );
679 // Ivy_ManTestCutsTravAll( pMan );
680 
681 // Ivy_ManPrintStats( pMan );
682 
683 // Ivy_ManPrintStats( pMan );
684 // Ivy_ManRewritePre( pMan, 1, 0, 0 );
685 // Ivy_ManPrintStats( pMan );
686 // printf( "\n" );
687 
688 // Ivy_ManPrintStats( pMan );
689 // Ivy_ManMakeSeq( pMan, nLatches, pInit );
690 // Ivy_ManPrintStats( pMan );
691 
692 // Ivy_ManRequiredLevels( pMan );
693 
694 // Ivy_FastMapPerform( pMan, 8 );
695  Ivy_ManStop( pMan );
696  return NULL;
697 
698 
699 /*
700  // convert from the AIG manager
701  pNtkAig = Abc_NtkFromIvy( pNtk, pMan );
702 // pNtkAig = Abc_NtkFromIvySeq( pNtk, pMan );
703  Ivy_ManStop( pMan );
704 
705  // report the cleanup results
706  if ( fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
707  printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes );
708  // duplicate EXDC
709  if ( pNtk->pExdc )
710  pNtkAig->pExdc = Abc_NtkDup( pNtk->pExdc );
711  // make sure everything is okay
712  if ( !Abc_NtkCheck( pNtkAig ) )
713  {
714  ABC_FREE( pInit );
715  printf( "Abc_NtkStrash: The network check has failed.\n" );
716  Abc_NtkDelete( pNtkAig );
717  return NULL;
718  }
719 
720  ABC_FREE( pInit );
721  return pNtkAig;
722 */
723 }
724 
725 
726 
727 /**Function*************************************************************
728 
729  Synopsis [Converts the network from the AIG manager into ABC.]
730 
731  Description []
732 
733  SideEffects []
734 
735  SeeAlso []
736 
737 ***********************************************************************/
739 {
740  Vec_Int_t * vNodes;
741  Abc_Ntk_t * pNtk;
742  Abc_Obj_t * pObj, * pObjNew, * pFaninNew, * pFaninNew0, * pFaninNew1;
743  Ivy_Obj_t * pNode;
744  int i;
745  // perform strashing
746  pNtk = Abc_NtkStartFrom( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
747  // transfer the pointers to the basic nodes
749  Abc_NtkForEachCi( pNtkOld, pObj, i )
750  Ivy_ManPi(pMan, i)->TravId = Abc_EdgeFromNode( pObj->pCopy );
751  // rebuild the AIG
752  vNodes = Ivy_ManDfs( pMan );
753  Ivy_ManForEachNodeVec( pMan, vNodes, pNode, i )
754  {
755  // add the first fanin
756  pFaninNew0 = Abc_ObjFanin0Ivy( pNtk, pNode );
757  if ( Ivy_ObjIsBuf(pNode) )
758  {
759  pNode->TravId = Abc_EdgeFromNode( pFaninNew0 );
760  continue;
761  }
762  // add the second fanin
763  pFaninNew1 = Abc_ObjFanin1Ivy( pNtk, pNode );
764  // create the new node
765  if ( Ivy_ObjIsExor(pNode) )
766  pObjNew = Abc_AigXor( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
767  else
768  pObjNew = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
769  pNode->TravId = Abc_EdgeFromNode( pObjNew );
770  }
771  // connect the PO nodes
772  Abc_NtkForEachCo( pNtkOld, pObj, i )
773  {
774  pFaninNew = Abc_ObjFanin0Ivy( pNtk, Ivy_ManPo(pMan, i) );
775  Abc_ObjAddFanin( pObj->pCopy, pFaninNew );
776  }
777  Vec_IntFree( vNodes );
778  if ( !Abc_NtkCheck( pNtk ) )
779  fprintf( stdout, "Abc_NtkFromIvy(): Network check has failed.\n" );
780  return pNtk;
781 }
782 
783 /**Function*************************************************************
784 
785  Synopsis [Converts the network from the AIG manager into ABC.]
786 
787  Description []
788 
789  SideEffects []
790 
791  SeeAlso []
792 
793 ***********************************************************************/
794 Abc_Ntk_t * Abc_NtkFromIvySeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig )
795 {
796  Vec_Int_t * vNodes, * vLatches;
797  Abc_Ntk_t * pNtk;
798  Abc_Obj_t * pObj, * pObjNew, * pFaninNew, * pFaninNew0, * pFaninNew1;
799  Ivy_Obj_t * pNode, * pTemp;
800  int i;
801 // assert( Ivy_ManLatchNum(pMan) > 0 );
802  // perform strashing
804  // transfer the pointers to the basic nodes
806  Abc_NtkForEachPi( pNtkOld, pObj, i )
807  Ivy_ManPi(pMan, i)->TravId = Abc_EdgeFromNode( pObj->pCopy );
808  // create latches of the new network
809  vNodes = Ivy_ManDfsSeq( pMan, &vLatches );
810  Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i )
811  {
812  pObjNew = Abc_NtkCreateLatch( pNtk );
813  pFaninNew0 = Abc_NtkCreateBi( pNtk );
814  pFaninNew1 = Abc_NtkCreateBo( pNtk );
815  Abc_ObjAddFanin( pObjNew, pFaninNew0 );
816  Abc_ObjAddFanin( pFaninNew1, pObjNew );
817  if ( fHaig || Ivy_ObjInit(pNode) == IVY_INIT_DC )
818  Abc_LatchSetInitDc( pObjNew );
819  else if ( Ivy_ObjInit(pNode) == IVY_INIT_1 )
820  Abc_LatchSetInit1( pObjNew );
821  else if ( Ivy_ObjInit(pNode) == IVY_INIT_0 )
822  Abc_LatchSetInit0( pObjNew );
823  else assert( 0 );
824  pNode->TravId = Abc_EdgeFromNode( pFaninNew1 );
825  }
826  Abc_NtkAddDummyBoxNames( pNtk );
827  // rebuild the AIG
828  Ivy_ManForEachNodeVec( pMan, vNodes, pNode, i )
829  {
830  // add the first fanin
831  pFaninNew0 = Abc_ObjFanin0Ivy( pNtk, pNode );
832  if ( Ivy_ObjIsBuf(pNode) )
833  {
834  pNode->TravId = Abc_EdgeFromNode( pFaninNew0 );
835  continue;
836  }
837  // add the second fanin
838  pFaninNew1 = Abc_ObjFanin1Ivy( pNtk, pNode );
839  // create the new node
840  if ( Ivy_ObjIsExor(pNode) )
841  pObjNew = Abc_AigXor( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
842  else
843  pObjNew = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
844  pNode->TravId = Abc_EdgeFromNode( pObjNew );
845  // process the choice nodes
846  if ( fHaig && pNode->pEquiv && Ivy_ObjRefs(pNode) > 0 )
847  {
848  pFaninNew = Abc_EdgeToNode( pNtk, pNode->TravId );
849 // pFaninNew->fPhase = 0;
850  assert( !Ivy_IsComplement(pNode->pEquiv) );
851  for ( pTemp = pNode->pEquiv; pTemp != pNode; pTemp = Ivy_Regular(pTemp->pEquiv) )
852  {
853  pFaninNew1 = Abc_EdgeToNode( pNtk, pTemp->TravId );
854 // pFaninNew1->fPhase = Ivy_IsComplement( pTemp->pEquiv );
855  pFaninNew->pData = pFaninNew1;
856  pFaninNew = pFaninNew1;
857  }
858  pFaninNew->pData = NULL;
859 // printf( "Writing choice node %d.\n", pNode->Id );
860  }
861  }
862  // connect the PO nodes
863  Abc_NtkForEachPo( pNtkOld, pObj, i )
864  {
865  pFaninNew = Abc_ObjFanin0Ivy( pNtk, Ivy_ManPo(pMan, i) );
866  Abc_ObjAddFanin( pObj->pCopy, pFaninNew );
867  }
868  // connect the latches
869  Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i )
870  {
871  pFaninNew = Abc_ObjFanin0Ivy( pNtk, pNode );
872  Abc_ObjAddFanin( Abc_ObjFanin0(Abc_NtkBox(pNtk, i)), pFaninNew );
873  }
874  Vec_IntFree( vLatches );
875  Vec_IntFree( vNodes );
876  if ( !Abc_NtkCheck( pNtk ) )
877  fprintf( stdout, "Abc_NtkFromIvySeq(): Network check has failed.\n" );
878  return pNtk;
879 }
880 
881 /**Function*************************************************************
882 
883  Synopsis [Converts the network from the AIG manager into ABC.]
884 
885  Description []
886 
887  SideEffects []
888 
889  SeeAlso []
890 
891 ***********************************************************************/
893 {
894  Ivy_Man_t * pMan;
895  Abc_Obj_t * pObj;
896  Ivy_Obj_t * pFanin;
897  int i;
898  // create the manager
899  assert( Abc_NtkHasSop(pNtkOld) || Abc_NtkIsStrash(pNtkOld) );
900  pMan = Ivy_ManStart();
901  // create the PIs
902  if ( Abc_NtkIsStrash(pNtkOld) )
903  Abc_AigConst1(pNtkOld)->pCopy = (Abc_Obj_t *)Ivy_ManConst1(pMan);
904  Abc_NtkForEachCi( pNtkOld, pObj, i )
905  pObj->pCopy = (Abc_Obj_t *)Ivy_ObjCreatePi(pMan);
906  // perform the conversion of the internal nodes
907  Abc_NtkStrashPerformAig( pNtkOld, pMan );
908  // create the POs
909  Abc_NtkForEachCo( pNtkOld, pObj, i )
910  {
911  pFanin = (Ivy_Obj_t *)Abc_ObjFanin0(pObj)->pCopy;
912  pFanin = Ivy_NotCond( pFanin, Abc_ObjFaninC0(pObj) );
913  Ivy_ObjCreatePo( pMan, pFanin );
914  }
915  Ivy_ManCleanup( pMan );
916  return pMan;
917 }
918 
919 /**Function*************************************************************
920 
921  Synopsis [Prepares the network for strashing.]
922 
923  Description []
924 
925  SideEffects []
926 
927  SeeAlso []
928 
929 ***********************************************************************/
931 {
932 // ProgressBar * pProgress;
933  Vec_Ptr_t * vNodes;
934  Abc_Obj_t * pNode;
935  int i;
936  vNodes = Abc_NtkDfs( pNtk, 0 );
937 // pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
938  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
939  {
940 // Extra_ProgressBarUpdate( pProgress, i, NULL );
941  pNode->pCopy = (Abc_Obj_t *)Abc_NodeStrashAig( pMan, pNode );
942  }
943 // Extra_ProgressBarStop( pProgress );
944  Vec_PtrFree( vNodes );
945 }
946 
947 /**Function*************************************************************
948 
949  Synopsis [Strashes one logic node.]
950 
951  Description []
952 
953  SideEffects []
954 
955  SeeAlso []
956 
957 ***********************************************************************/
959 {
960  int fUseFactor = 1;
961  char * pSop;
962  Ivy_Obj_t * pFanin0, * pFanin1;
963 
964  assert( Abc_ObjIsNode(pNode) );
965 
966  // consider the case when the graph is an AIG
967  if ( Abc_NtkIsStrash(pNode->pNtk) )
968  {
969  if ( Abc_AigNodeIsConst(pNode) )
970  return Ivy_ManConst1(pMan);
971  pFanin0 = (Ivy_Obj_t *)Abc_ObjFanin0(pNode)->pCopy;
972  pFanin0 = Ivy_NotCond( pFanin0, Abc_ObjFaninC0(pNode) );
973  pFanin1 = (Ivy_Obj_t *)Abc_ObjFanin1(pNode)->pCopy;
974  pFanin1 = Ivy_NotCond( pFanin1, Abc_ObjFaninC1(pNode) );
975  return Ivy_And( pMan, pFanin0, pFanin1 );
976  }
977 
978  // get the SOP of the node
979  if ( Abc_NtkHasMapping(pNode->pNtk) )
980  pSop = Mio_GateReadSop((Mio_Gate_t *)pNode->pData);
981  else
982  pSop = (char *)pNode->pData;
983 
984  // consider the constant node
985  if ( Abc_NodeIsConst(pNode) )
986  return Ivy_NotCond( Ivy_ManConst1(pMan), Abc_SopIsConst0(pSop) );
987 
988  // decide when to use factoring
989  if ( fUseFactor && Abc_ObjFaninNum(pNode) > 2 && Abc_SopGetCubeNum(pSop) > 1 && !Abc_SopIsExorType(pSop) )
990  return Abc_NodeStrashAigFactorAig( pMan, pNode, pSop );
991  return Abc_NodeStrashAigSopAig( pMan, pNode, pSop );
992 }
993 
994 /**Function*************************************************************
995 
996  Synopsis [Strashes one logic node using its SOP.]
997 
998  Description []
999 
1000  SideEffects []
1001 
1002  SeeAlso []
1003 
1004 ***********************************************************************/
1005 Ivy_Obj_t * Abc_NodeStrashAigSopAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop )
1006 {
1007  Abc_Obj_t * pFanin;
1008  Ivy_Obj_t * pAnd, * pSum;
1009  char * pCube;
1010  int i, nFanins;
1011  int fExor = Abc_SopIsExorType(pSop);
1012 
1013  // get the number of node's fanins
1014  nFanins = Abc_ObjFaninNum( pNode );
1015  assert( nFanins == Abc_SopGetVarNum(pSop) );
1016  // go through the cubes of the node's SOP
1017  pSum = Ivy_Not( Ivy_ManConst1(pMan) );
1018  Abc_SopForEachCube( pSop, nFanins, pCube )
1019  {
1020  // create the AND of literals
1021  pAnd = Ivy_ManConst1(pMan);
1022  Abc_ObjForEachFanin( pNode, pFanin, i ) // pFanin can be a net
1023  {
1024  if ( pCube[i] == '1' )
1025  pAnd = Ivy_And( pMan, pAnd, (Ivy_Obj_t *)pFanin->pCopy );
1026  else if ( pCube[i] == '0' )
1027  pAnd = Ivy_And( pMan, pAnd, Ivy_Not((Ivy_Obj_t *)pFanin->pCopy) );
1028  }
1029  // add to the sum of cubes
1030  if ( fExor )
1031  pSum = Ivy_Exor( pMan, pSum, pAnd );
1032  else
1033  pSum = Ivy_Or( pMan, pSum, pAnd );
1034  }
1035  // decide whether to complement the result
1036  if ( Abc_SopIsComplement(pSop) )
1037  pSum = Ivy_Not(pSum);
1038  return pSum;
1039 }
1040 
1041 /**Function*************************************************************
1042 
1043  Synopsis [Strashed n-input XOR function.]
1044 
1045  Description []
1046 
1047  SideEffects []
1048 
1049  SeeAlso []
1050 
1051 ***********************************************************************/
1052 Ivy_Obj_t * Abc_NodeStrashAigExorAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop )
1053 {
1054  Abc_Obj_t * pFanin;
1055  Ivy_Obj_t * pSum;
1056  int i, nFanins;
1057  // get the number of node's fanins
1058  nFanins = Abc_ObjFaninNum( pNode );
1059  assert( nFanins == Abc_SopGetVarNum(pSop) );
1060  // go through the cubes of the node's SOP
1061  pSum = Ivy_Not( Ivy_ManConst1(pMan) );
1062  for ( i = 0; i < nFanins; i++ )
1063  {
1064  pFanin = Abc_ObjFanin( pNode, i );
1065  pSum = Ivy_Exor( pMan, pSum, (Ivy_Obj_t *)pFanin->pCopy );
1066  }
1067  if ( Abc_SopIsComplement(pSop) )
1068  pSum = Ivy_Not(pSum);
1069  return pSum;
1070 }
1071 
1072 /**Function*************************************************************
1073 
1074  Synopsis [Strashes one logic node using its SOP.]
1075 
1076  Description []
1077 
1078  SideEffects []
1079 
1080  SeeAlso []
1081 
1082 ***********************************************************************/
1083 Ivy_Obj_t * Abc_NodeStrashAigFactorAig( Ivy_Man_t * pMan, Abc_Obj_t * pRoot, char * pSop )
1084 {
1085  Dec_Graph_t * pFForm;
1086  Dec_Node_t * pNode;
1087  Ivy_Obj_t * pAnd;
1088  int i;
1089 
1090 // extern Ivy_Obj_t * Dec_GraphToNetworkAig( Ivy_Man_t * pMan, Dec_Graph_t * pGraph );
1091 
1092 // assert( 0 );
1093 
1094  // perform factoring
1095  pFForm = Dec_Factor( pSop );
1096  // collect the fanins
1097  Dec_GraphForEachLeaf( pFForm, pNode, i )
1098  pNode->pFunc = Abc_ObjFanin(pRoot,i)->pCopy;
1099  // perform strashing
1100 // pAnd = Dec_GraphToNetworkAig( pMan, pFForm );
1101  pAnd = Dec_GraphToNetworkIvy( pMan, pFForm );
1102 // pAnd = NULL;
1103 
1104  Dec_GraphFree( pFForm );
1105  return pAnd;
1106 }
1107 
1108 /**Function*************************************************************
1109 
1110  Synopsis [Strashes one logic node using its SOP.]
1111 
1112  Description []
1113 
1114  SideEffects []
1115 
1116  SeeAlso []
1117 
1118 ***********************************************************************/
1120 {
1121  Abc_Obj_t * pLatch;
1122  Vec_Int_t * vArray;
1123  int i;
1124  vArray = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
1125  Abc_NtkForEachLatch( pNtk, pLatch, i )
1126  {
1127  if ( fUseDcs || Abc_LatchIsInitDc(pLatch) )
1128  Vec_IntPush( vArray, IVY_INIT_DC );
1129  else if ( Abc_LatchIsInit1(pLatch) )
1130  Vec_IntPush( vArray, IVY_INIT_1 );
1131  else if ( Abc_LatchIsInit0(pLatch) )
1132  Vec_IntPush( vArray, IVY_INIT_0 );
1133  else assert( 0 );
1134  }
1135  return vArray;
1136 }
1137 
1138 ////////////////////////////////////////////////////////////////////////
1139 /// END OF FILE ///
1140 ////////////////////////////////////////////////////////////////////////
1141 
1142 
1144 
int TravId
Definition: ivy.h:76
static Abc_Edge_t Abc_EdgeNot(Abc_Edge_t Edge)
Definition: abcIvy.c:57
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
ABC_NAMESPACE_IMPL_START Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
DECLARATIONS ///.
Definition: abcDar.c:233
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
Definition: ivy.h:68
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
static Ivy_Obj_t * Ivy_ManConst1(Ivy_Man_t *p)
Definition: ivy.h:199
static int Abc_EdgeId(Abc_Edge_t Edge)
Definition: abcIvy.c:54
static Abc_Obj_t * Abc_EdgeToNode(Abc_Ntk_t *p, Abc_Edge_t Edge)
Definition: abcIvy.c:60
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
Abc_Ntk_t * Abc_NtkIvyFraig(Abc_Ntk_t *pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose)
Definition: abcIvy.c:456
static Abc_Edge_t Abc_EdgeFromNode(Abc_Obj_t *pNode)
Definition: abcIvy.c:59
static Ivy_Obj_t * Ivy_ManPi(Ivy_Man_t *p, int i)
Definition: ivy.h:201
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Abc_Ntk_t * Abc_NtkIvyRewriteSeq(Abc_Ntk_t *pNtk, int fUseZeroCost, int fVerbose)
Definition: abcIvy.c:311
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Abc_Edge_t Abc_EdgeCreate(int Id, int fCompl)
Definition: abcIvy.c:53
Abc_Ntk_t * pExdc
Definition: abc.h:201
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
void Abc_NtkIvyCuts(Abc_Ntk_t *pNtk, int nInputs)
Definition: abcIvy.c:264
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition: abc.h:531
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
Ivy_Obj_t * Dec_GraphToNetworkIvy(Ivy_Man_t *pMan, Dec_Graph_t *pGraph)
Definition: decAbc.c:329
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition: abcSop.c:489
Abc_Ntk_t * Abc_NtkIvyRewrite(Abc_Ntk_t *pNtk, int fUpdateLevel, int fUseZeroCost, int fVerbose)
Definition: abcIvy.c:285
int timeRetime
DECLARATIONS ///.
Definition: retCore.c:30
Vec_Int_t * Ivy_ManDfs(Ivy_Man_t *p)
Definition: ivyDfs.c:87
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
void Ivy_FraigParamsDefault(Ivy_FraigParams_t *pParams)
FUNCTION DEFINITIONS ///.
Definition: ivyFraig.c:225
Ivy_Obj_t * Ivy_Exor(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:113
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
Abc_Ntk_t * Abc_NtkIvyStrash(Abc_Ntk_t *pNtk)
Definition: abcIvy.c:173
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
int nBTLimitNode
Definition: ivy.h:143
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
void Ivy_ManMakeSeq(Ivy_Man_t *p, int nLatches, int *pInits)
Definition: ivyMan.c:482
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
Definition: decFactor.c:55
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static void Abc_NtkStrashPerformAig(Abc_Ntk_t *pNtk, Ivy_Man_t *pMan)
Definition: abcIvy.c:930
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
ABC_DLL int Abc_SopIsExorType(char *pSop)
Definition: abcSop.c:802
static abctime Abc_Clock()
Definition: abc_global.h:279
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
int Abc_Edge_t
Definition: abcIvy.c:52
int Ivy_FraigProve(Ivy_Man_t **ppManAig, void *pPars)
Definition: ivyFraig.c:255
static void Abc_LatchSetInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:420
Ivy_Man_t * Ivy_FraigMiter(Ivy_Man_t *pManAig, Ivy_FraigParams_t *pParams)
Definition: ivyFraig.c:480
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
Ivy_Man_t * Ivy_ManStart()
DECLARATIONS ///.
Definition: ivyMan.c:45
void Ivy_ManStop(Ivy_Man_t *p)
Definition: ivyMan.c:238
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int Abc_NtkIvyProve(Abc_Ntk_t **ppNtk, void *pPars)
Definition: abcIvy.c:498
void Aig_ManStop(Aig_Man_t *pMan)
Definition: aigMan.c:187
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
int * pModel
Definition: abc.h:198
Ivy_Obj_t * Ivy_Or(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:142
Vec_Int_t * Ivy_ManDfsSeq(Ivy_Man_t *p, Vec_Int_t **pvLatches)
Definition: ivyDfs.c:121
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:735
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
static int Abc_EdgeIsComplement(Abc_Edge_t Edge)
Definition: abcIvy.c:55
ABC_DLL Abc_Ntk_t * Abc_NtkCollapse(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: abcCollapse.c:49
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static Ivy_Obj_t * Abc_NodeStrashAigFactorAig(Ivy_Man_t *pMan, Abc_Obj_t *pNode, char *pSop)
Definition: abcIvy.c:1083
Abc_Ntk_t * Abc_NtkIvySat(Abc_Ntk_t *pNtk, int nConfLimit, int fVerbose)
Definition: abcIvy.c:389
Ivy_Obj_t * Ivy_ObjCreatePo(Ivy_Man_t *p, Ivy_Obj_t *pDriver)
Definition: ivyObj.c:61
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
static Ivy_Obj_t * Abc_NodeStrashAigSopAig(Ivy_Man_t *pMan, Abc_Obj_t *pNode, char *pSop)
Definition: abcIvy.c:1005
Ivy_Man_t * Ivy_ManResyn(Ivy_Man_t *p, int fUpdateLevel, int fVerbose)
Definition: ivyResyn.c:86
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition: abcAig.c:194
static Abc_Ntk_t * Abc_NtkFromIvySeq(Abc_Ntk_t *pNtkOld, Ivy_Man_t *pMan, int fHaig)
Definition: abcIvy.c:794
ABC_DLL int Abc_NtkRewrite(Abc_Ntk_t *pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable)
FUNCTION DEFINITIONS ///.
Definition: abcRewrite.c:61
static int Ivy_ObjFaninC1(Ivy_Obj_t *pObj)
Definition: ivy.h:270
static Abc_Obj_t * Abc_ObjFanin0Ivy(Abc_Ntk_t *p, Ivy_Obj_t *pObj)
Definition: abcIvy.c:62
static int Ivy_ObjRefs(Ivy_Obj_t *pObj)
Definition: ivy.h:264
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
ABC_DLL int Abc_NtkRefactor(Abc_Ntk_t *pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: abcRefactor.c:89
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
if(last==0)
Definition: sparse_int.h:34
int Ivy_ManRewriteSeq(Ivy_Man_t *p, int fUseZeroCost, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: ivySeq.c:63
static Vec_Int_t * Abc_NtkCollectLatchValuesIvy(Abc_Ntk_t *pNtk, int fUseDcs)
Definition: abcIvy.c:1119
Definition: ivy.h:73
ABC_DLL void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:418
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
Definition: ivy.h:193
static Abc_Obj_t * Abc_ObjFanin1Ivy(Abc_Ntk_t *p, Ivy_Obj_t *pObj)
Definition: abcIvy.c:63
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
ABC_DLL int Abc_SopIsConst0(char *pSop)
Definition: abcSop.c:676
char * sprintf()
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
static Ivy_Man_t * Abc_NtkToIvy(Abc_Ntk_t *pNtkOld)
Definition: abcIvy.c:892
static Abc_Edge_t Abc_EdgeNotCond(Abc_Edge_t Edge, int fCond)
Definition: abcIvy.c:58
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
Definition: ioaWriteAig.c:446
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static Abc_Obj_t * Abc_NtkBox(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:319
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition: ivy.h:46
void Ivy_ManHaigStart(Ivy_Man_t *p, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: ivyHaig.c:94
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void Abc_LatchSetInit1(Abc_Obj_t *pLatch)
Definition: abc.h:419
void * pFunc
Definition: dec.h:56
static Ivy_Obj_t * Abc_NodeStrashAigExorAig(Ivy_Man_t *pMan, Abc_Obj_t *pNode, char *pSop)
Definition: abcIvy.c:1052
void Ivy_ManHaigStop(Ivy_Man_t *p)
Definition: ivyHaig.c:159
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
Abc_Ntk_t * Abc_NtkIvyResyn(Abc_Ntk_t *pNtk, int fUpdateLevel, int fVerbose)
Definition: abcIvy.c:364
void Abc_NtkTransferPointers(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkAig)
Definition: abcIvy.c:419
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Ivy_ObjIsExor(Ivy_Obj_t *pObj)
Definition: ivy.h:243
Ivy_Man_t * Abc_NtkIvyBefore(Abc_Ntk_t *pNtk, int fSeq, int fUseDc)
FUNCTION DEFINITIONS ///.
Definition: abcIvy.c:84
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static Abc_Edge_t Abc_EdgeRegular(Abc_Edge_t Edge)
Definition: abcIvy.c:56
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:359
#define Dec_GraphForEachLeaf(pGraph, pLeaf, i)
ITERATORS ///.
Definition: dec.h:98
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL Abc_Ntk_t * Abc_NtkStartFromNoLatches(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:248
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:265
ABC_DLL Vec_Ptr_t * Abc_NtkSaveCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:595
static Ivy_Obj_t * Ivy_Not(Ivy_Obj_t *p)
Definition: ivy.h:194
static Ivy_Obj_t * Ivy_NotCond(Ivy_Obj_t *p, int c)
Definition: ivy.h:195
#define Ivy_ManForEachNodeVec(p, vIds, pObj, i)
Definition: ivy.h:408
ABC_DLL Abc_Ntk_t * Abc_NtkBalance(Abc_Ntk_t *pNtk, int fDuplicate, int fSelective, int fUpdateLevel)
FUNCTION DEFINITIONS ///.
Definition: abcBalance.c:53
static int Ivy_ObjIsBuf(Ivy_Obj_t *pObj)
Definition: ivy.h:244
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
static void Dec_GraphFree(Dec_Graph_t *pGraph)
Definition: dec.h:307
Ivy_Man_t * Ivy_FraigPerform(Ivy_Man_t *pManAig, Ivy_FraigParams_t *pParams)
Definition: ivyFraig.c:451
Definition: ivy.h:67
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
Ivy_Man_t * Ivy_ManResyn0(Ivy_Man_t *p, int fUpdateLevel, int fVerbose)
DECLARATIONS ///.
Definition: ivyResyn.c:45
Ivy_Obj_t * Ivy_ObjCreatePi(Ivy_Man_t *p)
DECLARATIONS ///.
Definition: ivyObj.c:45
static Abc_Ntk_t * Abc_NtkFromIvy(Abc_Ntk_t *pNtkOld, Ivy_Man_t *pMan)
DECLARATIONS ///.
Definition: abcIvy.c:738
int Ivy_ManRewritePre(Ivy_Man_t *p, int fUpdateLevel, int fUseZeroCost, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: ivyRwr.c:55
static Ivy_Obj_t * Ivy_ManPo(Ivy_Man_t *p, int i)
Definition: ivy.h:202
static Ivy_Obj_t * Ivy_ObjEquiv(Ivy_Obj_t *pObj)
Definition: ivy.h:277
void * pData
Definition: abc.h:145
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
void Ivy_CutComputeAll(Ivy_Man_t *p, int nInputs)
Definition: ivySeq.c:1108
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
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
ABC_DLL void Abc_NtkLoadCopy(Abc_Ntk_t *pNtk, Vec_Ptr_t *vCopies)
Definition: abcUtil.c:617
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
ABC_INT64_T abctime
Definition: abc_global.h:278
Abc_Ntk_t * Abc_NtkIvy(Abc_Ntk_t *pNtk)
Definition: abcIvy.c:625
ABC_DLL int Abc_NtkCountSelfFeedLatches(Abc_Ntk_t *pNtk)
Definition: abcLatch.c:89
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition: abcSop.c:655
Abc_Ntk_t * Abc_NtkIvyHaig(Abc_Ntk_t *pNtk, int nIters, int fUseZeroCost, int fVerbose)
Definition: abcIvy.c:196
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition: mioApi.c:153
static int Ivy_ObjFaninC0(Ivy_Obj_t *pObj)
Definition: ivy.h:269
static Ivy_Init_t Ivy_ObjInit(Ivy_Obj_t *pObj)
Definition: ivy.h:232
Abc_Ntk_t * Abc_NtkIvyAfter(Abc_Ntk_t *pNtk, Ivy_Man_t *pMan, int fSeq, int fHaig)
Definition: abcIvy.c:137
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition: ivyOper.c:84
int Ivy_ManCheck(Ivy_Man_t *p)
DECLARATIONS ///.
Definition: ivyCheck.c:45
int Ivy_ManCleanup(Ivy_Man_t *p)
Definition: ivyMan.c:265
int Fra_FraigSat(Aig_Man_t *pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fFlipBits, int fAndOuts, int fNewSolver, int fVerbose)
ITERATORS ///.
Definition: fraCec.c:47
static Ivy_Obj_t * Abc_NodeStrashAig(Ivy_Man_t *pMan, Abc_Obj_t *pNode)
Definition: abcIvy.c:958
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
int nBTLimitMiter
Definition: ivy.h:144
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Ivy_Obj_t * pEquiv
Definition: ivy.h:93
Abc_Ntk_t * Abc_NtkIvyResyn0(Abc_Ntk_t *pNtk, int fUpdateLevel, int fVerbose)
Definition: abcIvy.c:339