abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sswPairs.c File Reference
#include "sswInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Ssw_MiterStatus (Aig_Man_t *p, int fVerbose)
 DECLARATIONS ///. More...
 
Vec_Int_tSsw_TransferSignalPairs (Aig_Man_t *pMiter, Aig_Man_t *pAig1, Aig_Man_t *pAig2, Vec_Int_t *vIds1, Vec_Int_t *vIds2)
 
Vec_Int_t ** Ssw_TransformPairsIntoTempClasses (Vec_Int_t *vPairs, int nObjNumMax)
 
void Ssw_FreeTempClasses (Vec_Int_t **pvClasses, int nObjNumMax)
 
Aig_Man_tSsw_SignalCorrespondenceWithPairs (Aig_Man_t *pAig1, Aig_Man_t *pAig2, Vec_Int_t *vIds1, Vec_Int_t *vIds2, Ssw_Pars_t *pPars)
 
Aig_Man_tSsw_SignalCorrespondeceTestPairs (Aig_Man_t *pAig)
 
int Ssw_SecWithPairs (Aig_Man_t *pAig1, Aig_Man_t *pAig2, Vec_Int_t *vIds1, Vec_Int_t *vIds2, Ssw_Pars_t *pPars)
 
int Ssw_SecGeneral (Aig_Man_t *pAig1, Aig_Man_t *pAig2, Ssw_Pars_t *pPars)
 
int Ssw_SecGeneralMiter (Aig_Man_t *pMiter, Ssw_Pars_t *pPars)
 

Function Documentation

void Ssw_FreeTempClasses ( Vec_Int_t **  pvClasses,
int  nObjNumMax 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file sswPairs.c.

253 {
254  int i;
255  for ( i = 0; i < nObjNumMax; i++ )
256  if ( pvClasses[i] )
257  Vec_IntFree( pvClasses[i] );
258  ABC_FREE( pvClasses );
259 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_NAMESPACE_IMPL_START int Ssw_MiterStatus ( Aig_Man_t p,
int  fVerbose 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [sswPairs.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Inductive prover with constraints.]

Synopsis [Calls to the SAT solver.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 1, 2008.]

Revision [

Id:
sswPairs.c,v 1.00 2008/09/01 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Reports the status of the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file sswPairs.c.

46 {
47  Aig_Obj_t * pObj, * pChild;
48  int i, CountConst0 = 0, CountNonConst0 = 0, CountUndecided = 0;
49 // if ( p->pData )
50 // return 0;
51  Saig_ManForEachPo( p, pObj, i )
52  {
53  pChild = Aig_ObjChild0(pObj);
54  // check if the output is constant 0
55  if ( pChild == Aig_ManConst0(p) )
56  {
57  CountConst0++;
58  continue;
59  }
60  // check if the output is constant 1
61  if ( pChild == Aig_ManConst1(p) )
62  {
63  CountNonConst0++;
64  continue;
65  }
66  // check if the output is a primary input
67  if ( p->nRegs == 0 && Aig_ObjIsCi(Aig_Regular(pChild)) )
68  {
69  CountNonConst0++;
70  continue;
71  }
72  // check if the output can be not constant 0
73  if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) )
74  {
75  CountNonConst0++;
76  continue;
77  }
78  CountUndecided++;
79  }
80 
81  if ( fVerbose )
82  {
83  Abc_Print( 1, "Miter has %d outputs. ", Saig_ManPoNum(p) );
84  Abc_Print( 1, "Const0 = %d. ", CountConst0 );
85  Abc_Print( 1, "NonConst0 = %d. ", CountNonConst0 );
86  Abc_Print( 1, "Undecided = %d. ", CountUndecided );
87  Abc_Print( 1, "\n" );
88  }
89 
90  if ( CountNonConst0 )
91  return 0;
92  if ( CountUndecided )
93  return -1;
94  return 1;
95 }
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
Definition: aig.h:69
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Ssw_SecGeneral ( Aig_Man_t pAig1,
Aig_Man_t pAig2,
Ssw_Pars_t pPars 
)

Function*************************************************************

Synopsis [Runs inductive SEC for the miter of two AIGs.]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file sswPairs.c.

416 {
417  Aig_Man_t * pAigRes, * pMiter;
418  int RetValue;
419  abctime clk = Abc_Clock();
420  // try the new AIGs
421  Abc_Print( 1, "Performing general verification without node pairs.\n" );
422  pMiter = Saig_ManCreateMiter( pAig1, pAig2, 0 );
423  Aig_ManCleanup( pMiter );
424  pAigRes = Ssw_SignalCorrespondence( pMiter, pPars );
425  Aig_ManStop( pMiter );
426  // report the results
427  RetValue = Ssw_MiterStatus( pAigRes, 1 );
428  if ( RetValue == 1 )
429  Abc_Print( 1, "Verification successful. " );
430  else if ( RetValue == 0 )
431  Abc_Print( 1, "Verification failed with a counter-example. " );
432  else
433  Abc_Print( 1, "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
434  Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig1) + Aig_ManRegNum(pAig2) );
435  ABC_PRT( "Time", Abc_Clock() - clk );
436  // cleanup
437  Aig_ManStop( pAigRes );
438  return RetValue;
439 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
Definition: sswCore.c:414
static abctime Abc_Clock()
Definition: abc_global.h:279
Aig_Man_t * Saig_ManCreateMiter(Aig_Man_t *p1, Aig_Man_t *p2, int Oper)
Definition: saigMiter.c:100
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_NAMESPACE_IMPL_START int Ssw_MiterStatus(Aig_Man_t *p, int fVerbose)
DECLARATIONS ///.
Definition: sswPairs.c:45
ABC_INT64_T abctime
Definition: abc_global.h:278
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
int Ssw_SecGeneralMiter ( Aig_Man_t pMiter,
Ssw_Pars_t pPars 
)

Function*************************************************************

Synopsis [Runs inductive SEC for the miter of two AIGs.]

Description []

SideEffects []

SeeAlso []

Definition at line 452 of file sswPairs.c.

453 {
454  Aig_Man_t * pAigRes;
455  int RetValue;
456  abctime clk = Abc_Clock();
457  // try the new AIGs
458 // Abc_Print( 1, "Performing general verification without node pairs.\n" );
459  pAigRes = Ssw_SignalCorrespondence( pMiter, pPars );
460  // report the results
461  RetValue = Ssw_MiterStatus( pAigRes, 1 );
462  if ( RetValue == 1 )
463  Abc_Print( 1, "Verification successful. " );
464  else if ( RetValue == 0 )
465  Abc_Print( 1, "Verification failed with a counter-example. " );
466  else
467  Abc_Print( 1, "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
468  Aig_ManRegNum(pAigRes), Aig_ManRegNum(pMiter) );
469  ABC_PRT( "Time", Abc_Clock() - clk );
470  // cleanup
471  Aig_ManStop( pAigRes );
472  return RetValue;
473 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
Definition: sswCore.c:414
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_NAMESPACE_IMPL_START int Ssw_MiterStatus(Aig_Man_t *p, int fVerbose)
DECLARATIONS ///.
Definition: sswPairs.c:45
ABC_INT64_T abctime
Definition: abc_global.h:278
int Ssw_SecWithPairs ( Aig_Man_t pAig1,
Aig_Man_t pAig2,
Vec_Int_t vIds1,
Vec_Int_t vIds2,
Ssw_Pars_t pPars 
)

Function*************************************************************

Synopsis [Runs inductive SEC for the miter of two AIGs with node pairs defined.]

Description []

SideEffects []

SeeAlso []

Definition at line 380 of file sswPairs.c.

381 {
382  Aig_Man_t * pAigRes;
383  int RetValue;
384  abctime clk = Abc_Clock();
385  assert( vIds1 != NULL && vIds2 != NULL );
386  // try the new AIGs
387  Abc_Print( 1, "Performing specialized verification with node pairs.\n" );
388  pAigRes = Ssw_SignalCorrespondenceWithPairs( pAig1, pAig2, vIds1, vIds2, pPars );
389  // report the results
390  RetValue = Ssw_MiterStatus( pAigRes, 1 );
391  if ( RetValue == 1 )
392  Abc_Print( 1, "Verification successful. " );
393  else if ( RetValue == 0 )
394  Abc_Print( 1, "Verification failed with a counter-example. " );
395  else
396  Abc_Print( 1, "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
397  Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig1) + Aig_ManRegNum(pAig2) );
398  ABC_PRT( "Time", Abc_Clock() - clk );
399  // cleanup
400  Aig_ManStop( pAigRes );
401  return RetValue;
402 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
Aig_Man_t * Ssw_SignalCorrespondenceWithPairs(Aig_Man_t *pAig1, Aig_Man_t *pAig2, Vec_Int_t *vIds1, Vec_Int_t *vIds2, Ssw_Pars_t *pPars)
Definition: sswPairs.c:272
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_NAMESPACE_IMPL_START int Ssw_MiterStatus(Aig_Man_t *p, int fVerbose)
DECLARATIONS ///.
Definition: sswPairs.c:45
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
Aig_Man_t* Ssw_SignalCorrespondeceTestPairs ( Aig_Man_t pAig)

Function*************************************************************

Synopsis [Runs inductive SEC for the miter of two AIGs with node pairs defined.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file sswPairs.c.

318 {
319  Aig_Man_t * pAigNew, * pAigRes;
320  Ssw_Pars_t Pars, * pPars = &Pars;
321  Vec_Int_t * vIds1, * vIds2;
322  Aig_Obj_t * pObj, * pRepr;
323  int RetValue, i;
324  abctime clk = Abc_Clock();
325  Ssw_ManSetDefaultParams( pPars );
326  pPars->fVerbose = 1;
327  pAigNew = Ssw_SignalCorrespondence( pAig, pPars );
328  // record pairs of equivalent nodes
329  vIds1 = Vec_IntAlloc( Aig_ManObjNumMax(pAig) );
330  vIds2 = Vec_IntAlloc( Aig_ManObjNumMax(pAig) );
331  Aig_ManForEachObj( pAig, pObj, i )
332  {
333  pRepr = Aig_Regular((Aig_Obj_t *)pObj->pData);
334  if ( pRepr == NULL )
335  continue;
336  if ( Aig_ManObj(pAigNew, pRepr->Id) == NULL )
337  continue;
338 /*
339  if ( Aig_ObjIsNode(pObj) )
340  Abc_Print( 1, "n " );
341  else if ( Saig_ObjIsPi(pAig, pObj) )
342  Abc_Print( 1, "pi " );
343  else if ( Saig_ObjIsLo(pAig, pObj) )
344  Abc_Print( 1, "lo " );
345 */
346  Vec_IntPush( vIds1, Aig_ObjId(pObj) );
347  Vec_IntPush( vIds2, Aig_ObjId(pRepr) );
348  }
349  Abc_Print( 1, "Recorded %d pairs (before: %d after: %d).\n", Vec_IntSize(vIds1), Aig_ManObjNumMax(pAig), Aig_ManObjNumMax(pAigNew) );
350  // try the new AIGs
351  pAigRes = Ssw_SignalCorrespondenceWithPairs( pAig, pAigNew, vIds1, vIds2, pPars );
352  Vec_IntFree( vIds1 );
353  Vec_IntFree( vIds2 );
354  // report the results
355  RetValue = Ssw_MiterStatus( pAigRes, 1 );
356  if ( RetValue == 1 )
357  Abc_Print( 1, "Verification successful. " );
358  else if ( RetValue == 0 )
359  Abc_Print( 1, "Verification failed with the counter-example. " );
360  else
361  Abc_Print( 1, "Verification UNDECIDED. Remaining registers %d (total %d). ",
362  Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig) + Aig_ManRegNum(pAigNew) );
363  ABC_PRT( "Time", Abc_Clock() - clk );
364  // cleanup
365  Aig_ManStop( pAigNew );
366  return pAigRes;
367 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
void * pData
Definition: aig.h:87
typedefABC_NAMESPACE_HEADER_START struct Ssw_Pars_t_ Ssw_Pars_t
INCLUDES ///.
Definition: ssw.h:40
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
Definition: sswCore.c:414
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static abctime Abc_Clock()
Definition: abc_global.h:279
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Ssw_ManSetDefaultParams(Ssw_Pars_t *p)
DECLARATIONS ///.
Definition: sswCore.c:45
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
Aig_Man_t * Ssw_SignalCorrespondenceWithPairs(Aig_Man_t *pAig1, Aig_Man_t *pAig2, Vec_Int_t *vIds1, Vec_Int_t *vIds2, Ssw_Pars_t *pPars)
Definition: sswPairs.c:272
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_NAMESPACE_IMPL_START int Ssw_MiterStatus(Aig_Man_t *p, int fVerbose)
DECLARATIONS ///.
Definition: sswPairs.c:45
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
int Id
Definition: aig.h:85
Aig_Man_t* Ssw_SignalCorrespondenceWithPairs ( Aig_Man_t pAig1,
Aig_Man_t pAig2,
Vec_Int_t vIds1,
Vec_Int_t vIds2,
Ssw_Pars_t pPars 
)

Function*************************************************************

Synopsis [Performs signal correspondence for the miter of two AIGs with node pairs defined.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file sswPairs.c.

273 {
274  Ssw_Man_t * p;
275  Aig_Man_t * pAigNew, * pMiter;
276  Ssw_Pars_t Pars;
277  Vec_Int_t * vPairs;
278  Vec_Int_t ** pvClasses;
279  assert( Vec_IntSize(vIds1) == Vec_IntSize(vIds2) );
280  // create sequential miter
281  pMiter = Saig_ManCreateMiter( pAig1, pAig2, 0 );
282  Aig_ManCleanup( pMiter );
283  // transfer information to the miter
284  vPairs = Ssw_TransferSignalPairs( pMiter, pAig1, pAig2, vIds1, vIds2 );
285  // create representation of the classes
286  pvClasses = Ssw_TransformPairsIntoTempClasses( vPairs, Aig_ManObjNumMax(pMiter) );
287  Vec_IntFree( vPairs );
288  // if parameters are not given, create them
289  if ( pPars == NULL )
290  Ssw_ManSetDefaultParams( pPars = &Pars );
291  // start the induction manager
292  p = Ssw_ManCreate( pMiter, pPars );
293  // create equivalence classes using these IDs
294  p->ppClasses = Ssw_ClassesPreparePairs( pMiter, pvClasses );
295  p->pSml = Ssw_SmlStart( pMiter, 0, p->nFrames + p->pPars->nFramesAddSim, 1 );
296  Ssw_ClassesSetData( p->ppClasses, p->pSml, (unsigned(*)(void *,Aig_Obj_t *))Ssw_SmlObjHashWord, (int(*)(void *,Aig_Obj_t *))Ssw_SmlObjIsConstWord, (int(*)(void *,Aig_Obj_t *,Aig_Obj_t *))Ssw_SmlObjsAreEqualWord );
297  // perform refinement of classes
298  pAigNew = Ssw_SignalCorrespondenceRefine( p );
299  // cleanup
300  Ssw_FreeTempClasses( pvClasses, Aig_ManObjNumMax(pMiter) );
301  Ssw_ManStop( p );
302  Aig_ManStop( pMiter );
303  return pAigNew;
304 }
void Ssw_ManStop(Ssw_Man_t *p)
Definition: sswMan.c:189
unsigned Ssw_SmlObjHashWord(Ssw_Sml_t *p, Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: sswSim.c:63
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Vec_Int_t ** Ssw_TransformPairsIntoTempClasses(Vec_Int_t *vPairs, int nObjNumMax)
Definition: sswPairs.c:149
typedefABC_NAMESPACE_HEADER_START struct Ssw_Pars_t_ Ssw_Pars_t
INCLUDES ///.
Definition: ssw.h:40
typedefABC_NAMESPACE_HEADER_START struct Ssw_Man_t_ Ssw_Man_t
INCLUDES ///.
Definition: sswInt.h:47
Ssw_Cla_t * Ssw_ClassesPreparePairs(Aig_Man_t *pAig, Vec_Int_t **pvClasses)
Definition: sswClass.c:862
int Ssw_SmlObjIsConstWord(Ssw_Sml_t *p, Aig_Obj_t *pObj)
Definition: sswSim.c:102
Ssw_Man_t * Ssw_ManCreate(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
DECLARATIONS ///.
Definition: sswMan.c:45
Aig_Man_t * Saig_ManCreateMiter(Aig_Man_t *p1, Aig_Man_t *p2, int Oper)
Definition: saigMiter.c:100
int Ssw_SmlObjsAreEqualWord(Ssw_Sml_t *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: sswSim.c:124
void Ssw_ClassesSetData(Ssw_Cla_t *p, void *pManData, unsigned(*pFuncNodeHash)(void *, Aig_Obj_t *), int(*pFuncNodeIsConst)(void *, Aig_Obj_t *), int(*pFuncNodesAreEqual)(void *, Aig_Obj_t *, Aig_Obj_t *))
Definition: sswClass.c:167
void Ssw_ManSetDefaultParams(Ssw_Pars_t *p)
DECLARATIONS ///.
Definition: sswCore.c:45
Aig_Man_t * Ssw_SignalCorrespondenceRefine(Ssw_Man_t *p)
Definition: sswCore.c:234
Definition: aig.h:69
void Ssw_FreeTempClasses(Vec_Int_t **pvClasses, int nObjNumMax)
Definition: sswPairs.c:252
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
Ssw_Sml_t * Ssw_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: sswSim.c:1148
Vec_Int_t * Ssw_TransferSignalPairs(Aig_Man_t *pMiter, Aig_Man_t *pAig1, Aig_Man_t *pAig2, Vec_Int_t *vIds1, Vec_Int_t *vIds2)
Definition: sswPairs.c:108
Vec_Int_t* Ssw_TransferSignalPairs ( Aig_Man_t pMiter,
Aig_Man_t pAig1,
Aig_Man_t pAig2,
Vec_Int_t vIds1,
Vec_Int_t vIds2 
)

Function*************************************************************

Synopsis [Transfer equivalent pairs to the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file sswPairs.c.

109 {
110  Vec_Int_t * vIds;
111  Aig_Obj_t * pObj1, * pObj2;
112  Aig_Obj_t * pObj1m, * pObj2m;
113  int i;
114  vIds = Vec_IntAlloc( 2 * Vec_IntSize(vIds1) );
115  for ( i = 0; i < Vec_IntSize(vIds1); i++ )
116  {
117  pObj1 = Aig_ManObj( pAig1, Vec_IntEntry(vIds1, i) );
118  pObj2 = Aig_ManObj( pAig2, Vec_IntEntry(vIds2, i) );
119  pObj1m = Aig_Regular((Aig_Obj_t *)pObj1->pData);
120  pObj2m = Aig_Regular((Aig_Obj_t *)pObj2->pData);
121  assert( pObj1m && pObj2m );
122  if ( pObj1m == pObj2m )
123  continue;
124  if ( pObj1m->Id < pObj2m->Id )
125  {
126  Vec_IntPush( vIds, pObj1m->Id );
127  Vec_IntPush( vIds, pObj2m->Id );
128  }
129  else
130  {
131  Vec_IntPush( vIds, pObj2m->Id );
132  Vec_IntPush( vIds, pObj1m->Id );
133  }
134  }
135  return vIds;
136 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
Vec_Int_t** Ssw_TransformPairsIntoTempClasses ( Vec_Int_t vPairs,
int  nObjNumMax 
)

Function*************************************************************

Synopsis [Transform pairs into class representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file sswPairs.c.

150 {
151  Vec_Int_t ** pvClasses; // vector of classes
152  int * pReprs; // mapping nodes into their representatives
153  int Entry, idObj, idRepr, idReprObj, idReprRepr, i;
154  // allocate data-structures
155  pvClasses = ABC_CALLOC( Vec_Int_t *, nObjNumMax );
156  pReprs = ABC_ALLOC( int, nObjNumMax );
157  for ( i = 0; i < nObjNumMax; i++ )
158  pReprs[i] = -1;
159  // consider pairs
160  for ( i = 0; i < Vec_IntSize(vPairs); i += 2 )
161  {
162  // get both objects
163  idRepr = Vec_IntEntry( vPairs, i );
164  idObj = Vec_IntEntry( vPairs, i+1 );
165  assert( idObj > 0 );
166  assert( (pReprs[idRepr] == -1) || (pvClasses[pReprs[idRepr]] != NULL) );
167  assert( (pReprs[idObj] == -1) || (pvClasses[pReprs[idObj] ] != NULL) );
168  // get representatives of both objects
169  idReprRepr = pReprs[idRepr];
170  idReprObj = pReprs[idObj];
171  // check different situations
172  if ( idReprRepr == -1 && idReprObj == -1 )
173  { // they do not have classes
174  // create a class
175  pvClasses[idRepr] = Vec_IntAlloc( 4 );
176  Vec_IntPush( pvClasses[idRepr], idRepr );
177  Vec_IntPush( pvClasses[idRepr], idObj );
178  pReprs[ idRepr ] = idRepr;
179  pReprs[ idObj ] = idRepr;
180  }
181  else if ( idReprRepr >= 0 && idReprObj == -1 )
182  { // representative has a class
183  // add iObj to the same class
184  Vec_IntPushUniqueOrder( pvClasses[idReprRepr], idObj );
185  pReprs[ idObj ] = idReprRepr;
186  }
187  else if ( idReprRepr == -1 && idReprObj >= 0 )
188  { // object has a class
189  assert( idReprObj != idRepr );
190  if ( idReprObj < idRepr )
191  { // add idRepr to the same class
192  Vec_IntPushUniqueOrder( pvClasses[idReprObj], idRepr );
193  pReprs[ idRepr ] = idReprObj;
194  }
195  else // if ( idReprObj > idRepr )
196  { // make idRepr new representative
197  Vec_IntPushFirst( pvClasses[idReprObj], idRepr );
198  pvClasses[idRepr] = pvClasses[idReprObj];
199  pvClasses[idReprObj] = NULL;
200  // set correct representatives of each node
201  Vec_IntForEachEntry( pvClasses[idRepr], Entry, i )
202  pReprs[ Entry ] = idRepr;
203  }
204  }
205  else // if ( idReprRepr >= 0 && idReprObj >= 0 )
206  { // both have classes
207  if ( idReprRepr == idReprObj )
208  { // the classes are the same
209  // nothing to do
210  }
211  else
212  { // the classes are different
213  // find the repr of the new class
214  if ( idReprRepr < idReprObj )
215  {
216  Vec_IntForEachEntry( pvClasses[idReprObj], Entry, i )
217  {
218  Vec_IntPushUniqueOrder( pvClasses[idReprRepr], Entry );
219  pReprs[ Entry ] = idReprRepr;
220  }
221  Vec_IntFree( pvClasses[idReprObj] );
222  pvClasses[idReprObj] = NULL;
223  }
224  else // if ( idReprRepr > idReprObj )
225  {
226  Vec_IntForEachEntry( pvClasses[idReprRepr], Entry, i )
227  {
228  Vec_IntPushUniqueOrder( pvClasses[idReprObj], Entry );
229  pReprs[ Entry ] = idReprObj;
230  }
231  Vec_IntFree( pvClasses[idReprRepr] );
232  pvClasses[idReprRepr] = NULL;
233  }
234  }
235  }
236  }
237  ABC_FREE( pReprs );
238  return pvClasses;
239 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Vec_IntPushFirst(Vec_Int_t *p, int Entry)
Definition: vecInt.h:724
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Vec_IntPushUniqueOrder(Vec_Int_t *p, int Entry)
Definition: vecInt.h:811
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54