abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fra.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "aig/aig/aig.h"
#include "opt/dar/dar.h"
#include "sat/bsat/satSolver.h"
#include "aig/ioa/ioa.h"

Go to the source code of this file.

Data Structures

struct  Fra_Par_t_
 
struct  Fra_Ssw_t_
 
struct  Fra_Sec_t_
 
struct  Fra_Cla_t_
 
struct  Fra_Sml_t_
 
struct  Fra_Man_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Fra_Par_t_ 
Fra_Par_t
 INCLUDES ///. More...
 
typedef struct Fra_Ssw_t_ Fra_Ssw_t
 
typedef struct Fra_Sec_t_ Fra_Sec_t
 
typedef struct Fra_Man_t_ Fra_Man_t
 
typedef struct Fra_Cla_t_ Fra_Cla_t
 
typedef struct Fra_Sml_t_ Fra_Sml_t
 
typedef struct Fra_Bmc_t_ Fra_Bmc_t
 

Functions

static unsigned * Fra_ObjSim (Fra_Sml_t *p, int Id)
 MACRO DEFINITIONS ///. More...
 
static unsigned Fra_ObjRandomSim ()
 
static Aig_Obj_tFra_ObjFraig (Aig_Obj_t *pObj, int i)
 
static void Fra_ObjSetFraig (Aig_Obj_t *pObj, int i, Aig_Obj_t *pNode)
 
static Vec_Ptr_tFra_ObjFaninVec (Aig_Obj_t *pObj)
 
static void Fra_ObjSetFaninVec (Aig_Obj_t *pObj, Vec_Ptr_t *vFanins)
 
static int Fra_ObjSatNum (Aig_Obj_t *pObj)
 
static void Fra_ObjSetSatNum (Aig_Obj_t *pObj, int Num)
 
static Aig_Obj_tFra_ClassObjRepr (Aig_Obj_t *pObj)
 
static void Fra_ClassObjSetRepr (Aig_Obj_t *pObj, Aig_Obj_t *pNode)
 
static Aig_Obj_tFra_ObjChild0Fra (Aig_Obj_t *pObj, int i)
 
static Aig_Obj_tFra_ObjChild1Fra (Aig_Obj_t *pObj, int i)
 
static int Fra_ImpLeft (int Imp)
 
static int Fra_ImpRight (int Imp)
 
static int Fra_ImpCreate (int Left, int Right)
 
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 ///. More...
 
int Fra_FraigCec (Aig_Man_t **ppAig, int nConfLimit, int fVerbose)
 
int Fra_FraigCecPartitioned (Aig_Man_t *pMan1, Aig_Man_t *pMan2, int nConfLimit, int nPartSize, int fSmart, int fVerbose)
 
int Fra_BmcNodeIsConst (Aig_Obj_t *pObj)
 
int Fra_BmcNodesAreEqual (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
 FUNCTION DEFINITIONS ///. More...
 
void Fra_BmcStop (Fra_Bmc_t *p)
 
void Fra_BmcPerform (Fra_Man_t *p, int nPref, int nDepth)
 
void Fra_BmcPerformSimple (Aig_Man_t *pAig, int nFrames, int nBTLimit, int fRewrite, int fVerbose)
 
Fra_Cla_tFra_ClassesStart (Aig_Man_t *pAig)
 FUNCTION DEFINITIONS ///. More...
 
void Fra_ClassesStop (Fra_Cla_t *p)
 
void Fra_ClassesCopyReprs (Fra_Cla_t *p, Vec_Ptr_t *vFailed)
 
void Fra_ClassesPrint (Fra_Cla_t *p, int fVeryVerbose)
 
void Fra_ClassesPrepare (Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
 
int Fra_ClassesRefine (Fra_Cla_t *p)
 
int Fra_ClassesRefine1 (Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
 
int Fra_ClassesCountLits (Fra_Cla_t *p)
 
int Fra_ClassesCountPairs (Fra_Cla_t *p)
 
void Fra_ClassesTest (Fra_Cla_t *p, int Id1, int Id2)
 
void Fra_ClassesLatchCorr (Fra_Man_t *p)
 
void Fra_ClassesPostprocess (Fra_Cla_t *p)
 
void Fra_ClassesSelectRepr (Fra_Cla_t *p)
 
Aig_Man_tFra_ClassesDeriveAig (Fra_Cla_t *p, int nFramesK)
 
void Fra_CnfNodeAddToSolver (Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
 
void Fra_FraigSweep (Fra_Man_t *pManAig)
 
int Fra_FraigMiterStatus (Aig_Man_t *p)
 DECLARATIONS ///. More...
 
int Fra_FraigMiterAssertedOutput (Aig_Man_t *p)
 
Aig_Man_tFra_FraigPerform (Aig_Man_t *pManAig, Fra_Par_t *pPars)
 
Aig_Man_tFra_FraigChoice (Aig_Man_t *pManAig, int nConfMax, int nLevelMax)
 
Aig_Man_tFra_FraigEquivence (Aig_Man_t *pManAig, int nConfMax, int fProve)
 
Vec_Int_tFra_OneHotCompute (Fra_Man_t *p, Fra_Sml_t *pSim)
 
void Fra_OneHotAssume (Fra_Man_t *p, Vec_Int_t *vOneHots)
 
void Fra_OneHotCheck (Fra_Man_t *p, Vec_Int_t *vOneHots)
 
int Fra_OneHotRefineUsingCex (Fra_Man_t *p, Vec_Int_t *vOneHots)
 
int Fra_OneHotCount (Fra_Man_t *p, Vec_Int_t *vOneHots)
 
void Fra_OneHotEstimateCoverage (Fra_Man_t *p, Vec_Int_t *vOneHots)
 
Aig_Man_tFra_OneHotCreateExdc (Fra_Man_t *p, Vec_Int_t *vOneHots)
 
void Fra_OneHotAddKnownConstraint (Fra_Man_t *p, Vec_Ptr_t *vOnehots)
 
Vec_Int_tFra_ImpDerive (Fra_Man_t *p, int nImpMaxLimit, int nImpUseLimit, int fLatchCorr)
 
void Fra_ImpAddToSolver (Fra_Man_t *p, Vec_Int_t *vImps, int *pSatVarNums)
 
int Fra_ImpCheckForNode (Fra_Man_t *p, Vec_Int_t *vImps, Aig_Obj_t *pNode, int Pos)
 
int Fra_ImpRefineUsingCex (Fra_Man_t *p, Vec_Int_t *vImps)
 
void Fra_ImpCompactArray (Vec_Int_t *vImps)
 
double Fra_ImpComputeStateSpaceRatio (Fra_Man_t *p)
 
int Fra_ImpVerifyUsingSimulation (Fra_Man_t *p)
 
void Fra_ImpRecordInManager (Fra_Man_t *p, Aig_Man_t *pNew)
 
Aig_Man_tFra_FraigInduction (Aig_Man_t *p, Fra_Ssw_t *pPars)
 
int Fra_InvariantVerify (Aig_Man_t *p, int nFrames, Vec_Int_t *vClauses, Vec_Int_t *vLits)
 DECLARATIONS ///. More...
 
Aig_Man_tFra_FraigLatchCorrespondence (Aig_Man_t *pAig, int nFramesP, int nConfMax, int fProve, int fVerbose, int *pnIter, float TimeLimit)
 
void Fra_ParamsDefault (Fra_Par_t *pParams)
 DECLARATIONS ///. More...
 
void Fra_ParamsDefaultSeq (Fra_Par_t *pParams)
 
Fra_Man_tFra_ManStart (Aig_Man_t *pManAig, Fra_Par_t *pParams)
 
void Fra_ManClean (Fra_Man_t *p, int nNodesMax)
 
Aig_Man_tFra_ManPrepareComb (Fra_Man_t *p)
 
void Fra_ManFinalizeComb (Fra_Man_t *p)
 
void Fra_ManStop (Fra_Man_t *p)
 
void Fra_ManPrint (Fra_Man_t *p)
 
int Fra_NodesAreEquiv (Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
 FUNCTION DEFINITIONS ///. More...
 
int Fra_NodesAreImp (Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
 
int Fra_NodesAreClause (Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
 
int Fra_NodeIsConst (Fra_Man_t *p, Aig_Obj_t *pNew)
 
void Fra_SecSetDefaultParams (Fra_Sec_t *p)
 DECLARATIONS ///. More...
 
int Fra_FraigSec (Aig_Man_t *p, Fra_Sec_t *pParSec, Aig_Man_t **ppResult)
 
int Fra_SmlNodeHash (Aig_Obj_t *pObj, int nTableSize)
 DECLARATIONS ///. More...
 
int Fra_SmlNodeIsConst (Aig_Obj_t *pObj)
 
int Fra_SmlNodesAreEqual (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
 
int Fra_SmlNodeNotEquWeight (Fra_Sml_t *p, int Left, int Right)
 
int Fra_SmlNodeCountOnes (Fra_Sml_t *p, Aig_Obj_t *pObj)
 
int Fra_SmlCheckOutput (Fra_Man_t *p)
 
void Fra_SmlSavePattern (Fra_Man_t *p)
 
void Fra_SmlSimulate (Fra_Man_t *p, int fInit)
 
void Fra_SmlResimulate (Fra_Man_t *p)
 
Fra_Sml_tFra_SmlStart (Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
 
void Fra_SmlStop (Fra_Sml_t *p)
 
Fra_Sml_tFra_SmlSimulateComb (Aig_Man_t *pAig, int nWords, int fCheckMiter)
 
Fra_Sml_tFra_SmlSimulateCombGiven (Aig_Man_t *pAig, char *pFileName, int fCheckMiter, int fVerbose)
 
Fra_Sml_tFra_SmlSimulateSeq (Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
 
Abc_Cex_tFra_SmlGetCounterExample (Fra_Sml_t *p)
 
Abc_Cex_tFra_SmlCopyCounterExample (Aig_Man_t *pAig, Aig_Man_t *pFrames, int *pModel)
 

Typedef Documentation

typedef struct Fra_Bmc_t_ Fra_Bmc_t

Definition at line 59 of file fra.h.

typedef struct Fra_Cla_t_ Fra_Cla_t

Definition at line 57 of file fra.h.

typedef struct Fra_Man_t_ Fra_Man_t

Definition at line 56 of file fra.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t

INCLUDES ///.

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

FileName [fra.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [[New FRAIG package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fra.h,v 1.00 2007/06/30 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 53 of file fra.h.

typedef struct Fra_Sec_t_ Fra_Sec_t

Definition at line 55 of file fra.h.

typedef struct Fra_Sml_t_ Fra_Sml_t

Definition at line 58 of file fra.h.

typedef struct Fra_Ssw_t_ Fra_Ssw_t

Definition at line 54 of file fra.h.

Function Documentation

int Fra_BmcNodeIsConst ( Aig_Obj_t pObj)

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

Synopsis [Returns 1 if the node is costant.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file fraBmc.c.

104 {
105  Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
106  return Fra_BmcNodesAreEqual( pObj, Aig_ManConst1(p->pManAig) );
107 }
Aig_Man_t * pManAig
Definition: fra.h:191
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
int Fra_BmcNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
FUNCTION DEFINITIONS ///.
Definition: fraBmc.c:72
int Fra_BmcNodesAreEqual ( Aig_Obj_t pObj0,
Aig_Obj_t pObj1 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Returns 1 if the nodes are equivalent.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file fraBmc.c.

73 {
74  Fra_Man_t * p = (Fra_Man_t *)pObj0->pData;
75  Aig_Obj_t * pObjFrames0, * pObjFrames1;
76  Aig_Obj_t * pObjFraig0, * pObjFraig1;
77  int i;
78  for ( i = p->pBmc->nPref; i < p->pBmc->nFramesAll; i++ )
79  {
80  pObjFrames0 = Aig_Regular( Bmc_ObjFrames(pObj0, i) );
81  pObjFrames1 = Aig_Regular( Bmc_ObjFrames(pObj1, i) );
82  if ( pObjFrames0 == pObjFrames1 )
83  continue;
84  pObjFraig0 = Aig_Regular( Bmc_ObjFraig(pObjFrames0) );
85  pObjFraig1 = Aig_Regular( Bmc_ObjFraig(pObjFrames1) );
86  if ( pObjFraig0 != pObjFraig1 )
87  return 0;
88  }
89  return 1;
90 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
for(p=first;p->value< newval;p=p->next)
Fra_Bmc_t * pBmc
Definition: fra.h:202
static Aig_Obj_t * Bmc_ObjFrames(Aig_Obj_t *pObj, int i)
Definition: fraBmc.c:48
Definition: aig.h:69
static Aig_Obj_t * Bmc_ObjFraig(Aig_Obj_t *pObj)
Definition: fraBmc.c:51
int nPref
Definition: fraBmc.c:34
void Fra_BmcPerform ( Fra_Man_t p,
int  nPref,
int  nDepth 
)

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

Synopsis [Performs BMC for the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file fraBmc.c.

312 {
313  Aig_Obj_t * pObj;
314  int i, nImpsOld = 0;
315  abctime clk = Abc_Clock();
316  assert( p->pBmc == NULL );
317  // derive and fraig the frames
318  p->pBmc = Fra_BmcStart( p->pManAig, nPref, nDepth );
319  p->pBmc->pAigFrames = Fra_BmcFrames( p->pBmc, 0 );
320  // if implications are present, configure the AIG manager to check them
321  if ( p->pCla->vImps )
322  {
323  p->pBmc->pAigFrames->pImpFunc = (void (*) (void*, void*))Fra_BmcFilterImplications;
324  p->pBmc->pAigFrames->pImpData = p->pBmc;
325  p->pBmc->vImps = p->pCla->vImps;
326  nImpsOld = Vec_IntSize(p->pCla->vImps);
327  }
328  p->pBmc->pAigFraig = Fra_FraigEquivence( p->pBmc->pAigFrames, 1000000, 0 );
329  p->pBmc->pObjToFraig = p->pBmc->pAigFrames->pObjCopies;
330  p->pBmc->pAigFrames->pObjCopies = NULL;
331  // annotate frames nodes with pointers to the manager
332  Aig_ManForEachObj( p->pBmc->pAigFrames, pObj, i )
333  pObj->pData = p;
334  // report the results
335  if ( p->pPars->fVerbose )
336  {
337  printf( "Original AIG = %d. Init %d frames = %d. Fraig = %d. ",
338  Aig_ManNodeNum(p->pBmc->pAig), p->pBmc->nFramesAll,
339  Aig_ManNodeNum(p->pBmc->pAigFrames), Aig_ManNodeNum(p->pBmc->pAigFraig) );
340  ABC_PRT( "Time", Abc_Clock() - clk );
341  printf( "Before BMC: " );
342 // Fra_ClassesPrint( p->pCla, 0 );
343  printf( "Const = %5d. Class = %5d. Lit = %5d. ",
344  Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla) );
345  if ( p->pCla->vImps )
346  printf( "Imp = %5d. ", nImpsOld );
347  printf( "\n" );
348  }
349  // refine the classes
350  p->pCla->pFuncNodeIsConst = Fra_BmcNodeIsConst;
351  p->pCla->pFuncNodesAreEqual = Fra_BmcNodesAreEqual;
352  Fra_ClassesRefine( p->pCla );
353  Fra_ClassesRefine1( p->pCla, 1, NULL );
354  p->pCla->pFuncNodeIsConst = Fra_SmlNodeIsConst;
355  p->pCla->pFuncNodesAreEqual = Fra_SmlNodesAreEqual;
356  // report the results
357  if ( p->pPars->fVerbose )
358  {
359  printf( "After BMC: " );
360 // Fra_ClassesPrint( p->pCla, 0 );
361  printf( "Const = %5d. Class = %5d. Lit = %5d. ",
362  Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla) );
363  if ( p->pCla->vImps )
364  printf( "Imp = %5d. ", Vec_IntSize(p->pCla->vImps) );
365  printf( "\n" );
366  }
367  // free the BMC manager
368  Fra_BmcStop( p->pBmc );
369  p->pBmc = NULL;
370 }
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition: fraClass.c:527
Aig_Man_t * pManAig
Definition: fra.h:191
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
Definition: fraSim.c:86
Vec_Int_t * vImps
Definition: fraBmc.c:38
Fra_Cla_t * pCla
Definition: fra.h:198
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
void Fra_BmcFilterImplications(Fra_Man_t *p, Fra_Bmc_t *pBmc)
Definition: fraBmc.c:121
Aig_Man_t * Fra_BmcFrames(Fra_Bmc_t *p, int fKeepPos)
Definition: fraBmc.c:237
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Fra_Bmc_t * pBmc
Definition: fra.h:202
int Fra_BmcNodeIsConst(Aig_Obj_t *pObj)
Definition: fraBmc.c:103
Aig_Man_t * pAigFraig
Definition: fraBmc.c:42
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
Vec_Int_t * vImps
Definition: fra.h:163
Aig_Obj_t ** pObjToFraig
Definition: fraBmc.c:45
void Fra_BmcStop(Fra_Bmc_t *p)
Definition: fraBmc.c:216
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Fra_Bmc_t * Fra_BmcStart(Aig_Man_t *pAig, int nPref, int nDepth)
Definition: fraBmc.c:191
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int Fra_SmlNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: fraSim.c:109
Aig_Man_t * pAigFrames
Definition: fraBmc.c:41
#define assert(ex)
Definition: util_old.h:213
int Fra_BmcNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
FUNCTION DEFINITIONS ///.
Definition: fraBmc.c:72
ABC_INT64_T abctime
Definition: abc_global.h:278
void Fra_BmcPerformSimple ( Aig_Man_t pAig,
int  nFrames,
int  nBTLimit,
int  fRewrite,
int  fVerbose 
)

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

Synopsis [Performs BMC for the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 383 of file fraBmc.c.

384 {
385  extern Fra_Man_t * Fra_LcrAigPrepare( Aig_Man_t * pAig );
386  Fra_Man_t * pTemp;
387  Fra_Bmc_t * pBmc;
388  Aig_Man_t * pAigTemp;
389  abctime clk;
390  int iOutput;
391  // derive and fraig the frames
392  clk = Abc_Clock();
393  pBmc = Fra_BmcStart( pAig, 0, nFrames );
394  pTemp = Fra_LcrAigPrepare( pAig );
395  pTemp->pBmc = pBmc;
396  pBmc->pAigFrames = Fra_BmcFrames( pBmc, 1 );
397  if ( fVerbose )
398  {
399  printf( "AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d.\n",
400  Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig), Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig), Aig_ManRegNum(pAig),
401  Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
402  printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
403  nFrames, Aig_ManCiNum(pBmc->pAigFrames), Aig_ManCoNum(pBmc->pAigFrames),
405  ABC_PRT( "Time", Abc_Clock() - clk );
406  }
407  if ( fRewrite )
408  {
409  clk = Abc_Clock();
410  pBmc->pAigFrames = Dar_ManRwsat( pAigTemp = pBmc->pAigFrames, 1, 0 );
411  Aig_ManStop( pAigTemp );
412  if ( fVerbose )
413  {
414  printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
416  ABC_PRT( "Time", Abc_Clock() - clk );
417  }
418  }
419  clk = Abc_Clock();
420  iOutput = Fra_FraigMiterAssertedOutput( pBmc->pAigFrames );
421  if ( iOutput >= 0 )
422  pAig->pSeqModel = Abc_CexMakeTriv( Aig_ManRegNum(pAig), Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig), Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig), iOutput );
423  else
424  {
425  pBmc->pAigFraig = Fra_FraigEquivence( pBmc->pAigFrames, nBTLimit, 1 );
426  iOutput = Fra_FraigMiterAssertedOutput( pBmc->pAigFraig );
427  if ( pBmc->pAigFraig->pData )
428  {
429  pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pBmc->pAigFrames, (int *)pBmc->pAigFraig->pData );
430  ABC_FREE( pBmc->pAigFraig->pData );
431  }
432  else if ( iOutput >= 0 )
433  pAig->pSeqModel = Abc_CexMakeTriv( Aig_ManRegNum(pAig), Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig), Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig), iOutput );
434  }
435  if ( fVerbose )
436  {
437  printf( "Fraiged init frames: Node = %6d. Lev = %5d. ",
438  pBmc->pAigFraig? Aig_ManNodeNum(pBmc->pAigFraig) : -1,
439  pBmc->pAigFraig? Aig_ManLevelNum(pBmc->pAigFraig) : -1 );
440  ABC_PRT( "Time", Abc_Clock() - clk );
441  }
442  Fra_BmcStop( pBmc );
443  ABC_FREE( pTemp );
444 }
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 * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
Aig_Man_t * Fra_BmcFrames(Fra_Bmc_t *p, int fKeepPos)
Definition: fraBmc.c:237
Abc_Cex_t * Fra_SmlCopyCounterExample(Aig_Man_t *pAig, Aig_Man_t *pFrames, int *pModel)
Definition: fraSim.c:1117
static abctime Abc_Clock()
Definition: abc_global.h:279
DECLARATIONS ///.
Definition: fraBmc.c:31
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
Definition: darScript.c:71
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Fra_Bmc_t * pBmc
Definition: fra.h:202
Abc_Cex_t * Abc_CexMakeTriv(int nRegs, int nTruePis, int nTruePos, int iFrameOut)
Definition: utilCex.c:85
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
Fra_Man_t * Fra_LcrAigPrepare(Aig_Man_t *pAig)
Definition: fraLcr.c:158
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Aig_Man_t * pAigFraig
Definition: fraBmc.c:42
int Fra_FraigMiterAssertedOutput(Aig_Man_t *p)
Definition: fraCore.c:125
int Aig_ManLevelNum(Aig_Man_t *p)
Definition: aigDfs.c:486
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fra_BmcStop(Fra_Bmc_t *p)
Definition: fraBmc.c:216
Fra_Bmc_t * Fra_BmcStart(Aig_Man_t *pAig, int nPref, int nDepth)
Definition: fraBmc.c:191
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Aig_Man_t * pAigFrames
Definition: fraBmc.c:41
ABC_INT64_T abctime
Definition: abc_global.h:278
void Fra_BmcStop ( Fra_Bmc_t p)

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

Synopsis [Stops the BMC manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 216 of file fraBmc.c.

217 {
218  Aig_ManStop( p->pAigFrames );
219  if ( p->pAigFraig )
220  Aig_ManStop( p->pAigFraig );
221  ABC_FREE( p->pObjToFrames );
222  ABC_FREE( p->pObjToFraig );
223  ABC_FREE( p );
224 }
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Aig_Man_t * pAigFraig
Definition: fraBmc.c:42
Aig_Obj_t ** pObjToFraig
Definition: fraBmc.c:45
#define ABC_FREE(obj)
Definition: abc_global.h:232
Aig_Obj_t ** pObjToFrames
Definition: fraBmc.c:44
Aig_Man_t * pAigFrames
Definition: fraBmc.c:41
void Fra_ClassesCopyReprs ( Fra_Cla_t p,
Vec_Ptr_t vFailed 
)

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file fraClass.c.

115 {
116  Aig_Obj_t * pObj;
117  int i;
119  memmove( p->pAig->pReprs, p->pMemRepr, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p->pAig) );
120  if ( Vec_PtrSize(p->vClasses1) == 0 && Vec_PtrSize(p->vClasses) == 0 )
121  {
122  Aig_ManForEachObj( p->pAig, pObj, i )
123  {
124  if ( p->pAig->pReprs[i] != NULL )
125  printf( "Classes are not cleared!\n" );
126  assert( p->pAig->pReprs[i] == NULL );
127  }
128  }
129  if ( vFailed )
130  Vec_PtrForEachEntry( Aig_Obj_t *, vFailed, pObj, i )
131  p->pAig->pReprs[pObj->Id] = NULL;
132 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
char * memmove()
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition: aigRepr.c:45
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Aig_Man_t * pAig
Definition: fra.h:152
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesCountLits ( Fra_Cla_t p)

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

Synopsis [Count the number of literals.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file fraClass.c.

165 {
166  Aig_Obj_t ** pClass;
167  int i, nNodes, nLits = 0;
168  nLits = Vec_PtrSize( p->vClasses1 );
169  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
170  {
171  nNodes = Fra_ClassCount( pClass );
172  assert( nNodes > 1 );
173  nLits += nNodes - 1;
174  }
175  return nLits;
176 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Fra_ClassCount(Aig_Obj_t **pClass)
Definition: fraClass.c:145
Definition: aig.h:69
Vec_Ptr_t * vClasses1
Definition: fra.h:155
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesCountPairs ( Fra_Cla_t p)

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

Synopsis [Count the number of pairs.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file fraClass.c.

190 {
191  Aig_Obj_t ** pClass;
192  int i, nNodes, nPairs = 0;
193  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
194  {
195  nNodes = Fra_ClassCount( pClass );
196  assert( nNodes > 1 );
197  nPairs += nNodes * (nNodes - 1) / 2;
198  }
199  return nPairs;
200 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
int Fra_ClassCount(Aig_Obj_t **pClass)
Definition: fraClass.c:145
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Aig_Man_t* Fra_ClassesDeriveAig ( Fra_Cla_t p,
int  nFramesK 
)

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

Synopsis [Derives AIG for the partitioned problem.]

Description []

SideEffects []

SeeAlso []

Definition at line 796 of file fraClass.c.

797 {
798  Aig_Man_t * pManFraig;
799  Aig_Obj_t * pObj, * pObjNew;
800  Aig_Obj_t ** pLatches, ** ppEquivs;
801  int i, k, f, nFramesAll = nFramesK + 1;
802  assert( Aig_ManRegNum(p->pAig) > 0 );
804  assert( nFramesK > 0 );
805  // start the fraig package
806  pManFraig = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * nFramesAll );
807  pManFraig->pName = Abc_UtilStrsav( p->pAig->pName );
808  pManFraig->pSpec = Abc_UtilStrsav( p->pAig->pSpec );
809  // allocate place for the node mapping
810  ppEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
811  Fra_ObjSetEqu( ppEquivs, Aig_ManConst1(p->pAig), Aig_ManConst1(pManFraig) );
812  // create latches for the first frame
813  Aig_ManForEachLoSeq( p->pAig, pObj, i )
814  Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreateCi(pManFraig) );
815  // add timeframes
816  pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
817  for ( f = 0; f < nFramesAll; f++ )
818  {
819  // create PIs for this frame
820  Aig_ManForEachPiSeq( p->pAig, pObj, i )
821  Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreateCi(pManFraig) );
822  // set the constraints on the latch outputs
823  Aig_ManForEachLoSeq( p->pAig, pObj, i )
824  Fra_ClassesDeriveNode( pManFraig, pObj, ppEquivs );
825  // add internal nodes of this frame
826  Aig_ManForEachNode( p->pAig, pObj, i )
827  {
828  pObjNew = Aig_And( pManFraig, Fra_ObjChild0Equ(ppEquivs, pObj), Fra_ObjChild1Equ(ppEquivs, pObj) );
829  Fra_ObjSetEqu( ppEquivs, pObj, pObjNew );
830  Fra_ClassesDeriveNode( pManFraig, pObj, ppEquivs );
831  }
832  if ( f == nFramesAll - 1 )
833  break;
834  if ( f == nFramesAll - 2 )
835  pManFraig->nAsserts = Aig_ManCoNum(pManFraig);
836  // save the latch input values
837  k = 0;
838  Aig_ManForEachLiSeq( p->pAig, pObj, i )
839  pLatches[k++] = Fra_ObjChild0Equ( ppEquivs, pObj );
840  // insert them to the latch output values
841  k = 0;
842  Aig_ManForEachLoSeq( p->pAig, pObj, i )
843  Fra_ObjSetEqu( ppEquivs, pObj, pLatches[k++] );
844  }
845  ABC_FREE( pLatches );
846  ABC_FREE( ppEquivs );
847  // mark the asserts
848  assert( Aig_ManCoNum(pManFraig) % nFramesAll == 0 );
849 printf( "Assert miters = %6d. Output miters = %6d.\n",
850  pManFraig->nAsserts, Aig_ManCoNum(pManFraig) - pManFraig->nAsserts );
851  // remove dangling nodes
852  Aig_ManCleanup( pManFraig );
853  return pManFraig;
854 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
#define Assert(cond, msg)
Definition: zutil.h:268
static Aig_Obj_t * Fra_ObjChild0Equ(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:746
static Aig_Obj_t * Fra_ObjChild1Equ(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:747
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
for(p=first;p->value< newval;p=p->next)
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static void Fra_ClassesDeriveNode(Aig_Man_t *pManFraig, Aig_Obj_t *pObj, Aig_Obj_t **ppEquivs)
Definition: fraClass.c:760
static void Fra_ObjSetEqu(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fraClass.c:744
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAig
Definition: fra.h:152
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
#define assert(ex)
Definition: util_old.h:213
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition: aig.h:447
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
void Fra_ClassesLatchCorr ( Fra_Man_t p)

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

Synopsis [Creates latch correspondence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file fraClass.c.

616 {
617  Aig_Obj_t * pObj;
618  int i, nEntries = 0;
619  Vec_PtrClear( p->pCla->vClasses1 );
620  Aig_ManForEachLoSeq( p->pManAig, pObj, i )
621  {
622  Vec_PtrPush( p->pCla->vClasses1, pObj );
624  }
625  // allocate room for classes
626  p->pCla->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) );
627  p->pCla->pMemClassesFree = p->pCla->pMemClasses + 2*nEntries;
628 }
Aig_Obj_t ** pMemClassesFree
Definition: fra.h:158
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: aig.h:69
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Fra_ClassesPostprocess ( Fra_Cla_t p)

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

Synopsis [Postprocesses the classes by removing half of the less useful.]

Description []

SideEffects []

SeeAlso []

Definition at line 641 of file fraClass.c.

642 {
643  int Ratio = 2;
644  Fra_Sml_t * pComb;
645  Aig_Obj_t * pObj, * pRepr, ** ppClass;
646  int * pWeights, WeightMax = 0, i, k, c;
647  // perform combinational simulation
648  pComb = Fra_SmlSimulateComb( p->pAig, 32, 0 );
649  // compute the weight of each node in the classes
650  pWeights = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) );
651  memset( pWeights, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) );
652  Aig_ManForEachObj( p->pAig, pObj, i )
653  {
654  pRepr = Fra_ClassObjRepr( pObj );
655  if ( pRepr == NULL )
656  continue;
657  pWeights[i] = Fra_SmlNodeNotEquWeight( pComb, pRepr->Id, pObj->Id );
658  WeightMax = Abc_MaxInt( WeightMax, pWeights[i] );
659  }
660  Fra_SmlStop( pComb );
661  printf( "Before: Const = %6d. Class = %6d. ", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
662  // remove nodes from classes whose weight is less than WeightMax/Ratio
663  k = 0;
664  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
665  {
666  if ( pWeights[pObj->Id] >= WeightMax/Ratio )
667  Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
668  else
669  Fra_ClassObjSetRepr( pObj, NULL );
670  }
671  Vec_PtrShrink( p->vClasses1, k );
672  // in each class, compact the nodes
673  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
674  {
675  k = 1;
676  for ( c = 1; ppClass[c]; c++ )
677  {
678  if ( pWeights[ppClass[c]->Id] >= WeightMax/Ratio )
679  ppClass[k++] = ppClass[c];
680  else
681  Fra_ClassObjSetRepr( ppClass[c], NULL );
682  }
683  ppClass[k] = NULL;
684  }
685  // remove classes with only repr
686  k = 0;
687  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
688  if ( ppClass[1] != NULL )
689  Vec_PtrWriteEntry( p->vClasses, k++, ppClass );
690  Vec_PtrShrink( p->vClasses, k );
691  printf( "After: Const = %6d. Class = %6d. \n", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
692  ABC_FREE( pWeights );
693 }
char * memset()
Vec_Ptr_t * vClasses
Definition: fra.h:154
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Definition: fraSim.c:856
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Aig_Man_t * pAig
Definition: fra.h:152
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Aig_Obj_t * Fra_ClassObjRepr(Aig_Obj_t *pObj)
Definition: fra.h:269
int Fra_SmlNodeNotEquWeight(Fra_Sml_t *p, int Left, int Right)
Definition: fraSim.c:133
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
int Id
Definition: aig.h:85
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
void Fra_ClassesPrepare ( Fra_Cla_t p,
int  fLatchCorr,
int  nMaxLevs 
)

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

Synopsis [Creates initial simulation classes.]

Description [Assumes that simulation info is assigned.]

SideEffects []

SeeAlso []

Definition at line 276 of file fraClass.c.

277 {
278  Aig_Obj_t ** ppTable, ** ppNexts;
279  Aig_Obj_t * pObj, * pTemp;
280  int i, k, nTableSize, nEntries, nNodes, iEntry;
281 
282  // allocate the hash table hashing simulation info into nodes
283  nTableSize = Abc_PrimeCudd( Aig_ManObjNumMax(p->pAig) );
284  ppTable = ABC_FALLOC( Aig_Obj_t *, nTableSize );
285  ppNexts = ABC_FALLOC( Aig_Obj_t *, nTableSize );
286  memset( ppTable, 0, sizeof(Aig_Obj_t *) * nTableSize );
287 
288  // add all the nodes to the hash table
289  Vec_PtrClear( p->vClasses1 );
290  Aig_ManForEachObj( p->pAig, pObj, i )
291  {
292  if ( fLatchCorr )
293  {
294  if ( !Aig_ObjIsCi(pObj) )
295  continue;
296  }
297  else
298  {
299  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
300  continue;
301  // skip the node with more that the given number of levels
302  if ( nMaxLevs && (int)pObj->Level > nMaxLevs )
303  continue;
304  }
305  // hash the node by its simulation info
306  iEntry = p->pFuncNodeHash( pObj, nTableSize );
307  // check if the node belongs to the class of constant 1
308  if ( p->pFuncNodeIsConst( pObj ) )
309  {
310  Vec_PtrPush( p->vClasses1, pObj );
312  continue;
313  }
314  // add the node to the class
315  if ( ppTable[iEntry] == NULL )
316  {
317  ppTable[iEntry] = pObj;
318  Fra_ObjSetNext( ppNexts, pObj, pObj );
319  }
320  else
321  {
322  Fra_ObjSetNext( ppNexts, pObj, Fra_ObjNext(ppNexts,ppTable[iEntry]) );
323  Fra_ObjSetNext( ppNexts, ppTable[iEntry], pObj );
324  }
325  }
326 
327  // count the total number of nodes in the non-trivial classes
328  // mark the representative nodes of each equivalence class
329  nEntries = 0;
330  for ( i = 0; i < nTableSize; i++ )
331  if ( ppTable[i] && ppTable[i] != Fra_ObjNext(ppNexts, ppTable[i]) )
332  {
333  for ( pTemp = Fra_ObjNext(ppNexts, ppTable[i]), k = 1;
334  pTemp != ppTable[i];
335  pTemp = Fra_ObjNext(ppNexts, pTemp), k++ );
336  assert( k > 1 );
337  nEntries += k;
338  // mark the node
339  assert( ppTable[i]->fMarkA == 0 );
340  ppTable[i]->fMarkA = 1;
341  }
342 
343  // allocate room for classes
344  p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
345  p->pMemClassesFree = p->pMemClasses + 2*nEntries;
346 
347  // copy the entries into storage in the topological order
348  Vec_PtrClear( p->vClasses );
349  nEntries = 0;
350  Aig_ManForEachObj( p->pAig, pObj, i )
351  {
352  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
353  continue;
354  // skip the nodes that are not representatives of non-trivial classes
355  if ( pObj->fMarkA == 0 )
356  continue;
357  pObj->fMarkA = 0;
358  // add the class of nodes
359  Vec_PtrPush( p->vClasses, p->pMemClasses + 2*nEntries );
360  // count the number of entries in this class
361  for ( pTemp = Fra_ObjNext(ppNexts, pObj), k = 1;
362  pTemp != pObj;
363  pTemp = Fra_ObjNext(ppNexts, pTemp), k++ );
364  nNodes = k;
365  assert( nNodes > 1 );
366  // add the nodes to the class in the topological order
367  p->pMemClasses[2*nEntries] = pObj;
368  for ( pTemp = Fra_ObjNext(ppNexts, pObj), k = 1;
369  pTemp != pObj;
370  pTemp = Fra_ObjNext(ppNexts, pTemp), k++ )
371  {
372  p->pMemClasses[2*nEntries+nNodes-k] = pTemp;
373  Fra_ClassObjSetRepr( pTemp, pObj );
374  }
375  // add as many empty entries
376  p->pMemClasses[2*nEntries + nNodes] = NULL;
377  // increment the number of entries
378  nEntries += k;
379  }
380  ABC_FREE( ppTable );
381  ABC_FREE( ppNexts );
382  // now it is time to refine the classes
383  Fra_ClassesRefine( p );
384 // Fra_ClassesPrint( p, 0 );
385 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
unsigned Level
Definition: aig.h:82
Aig_Obj_t ** pMemClassesFree
Definition: fra.h:158
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int fMarkA
Definition: aig.h:79
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Fra_ObjSetNext(Aig_Obj_t **ppNexts, Aig_Obj_t *pObj, Aig_Obj_t *pNext)
Definition: fraClass.c:43
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
Definition: aig.h:69
int(* pFuncNodeIsConst)(Aig_Obj_t *)
Definition: fra.h:166
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static ABC_NAMESPACE_IMPL_START Aig_Obj_t * Fra_ObjNext(Aig_Obj_t **ppNexts, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: fraClass.c:42
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Aig_Man_t * pAig
Definition: fra.h:152
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int(* pFuncNodeHash)(Aig_Obj_t *, int)
Definition: fra.h:165
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
void Fra_ClassesPrint ( Fra_Cla_t p,
int  fVeryVerbose 
)

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file fraClass.c.

237 {
238  Aig_Obj_t ** pClass;
239  Aig_Obj_t * pObj;
240  int i;
241 
242  printf( "Const = %5d. Class = %5d. Lit = %5d. ",
244  if ( p->vImps && Vec_IntSize(p->vImps) > 0 )
245  printf( "Imp = %5d. ", Vec_IntSize(p->vImps) );
246  printf( "\n" );
247 
248  if ( fVeryVerbose )
249  {
250  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
251  assert( Fra_ClassObjRepr(pObj) == Aig_ManConst1(p->pAig) );
252  printf( "Constants { " );
253  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
254  printf( "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
255  printf( "}\n" );
256  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
257  {
258  printf( "%3d (%3d) : ", i, Fra_ClassCount(pClass) );
259  Fra_PrintClass( p, pClass );
260  }
261  printf( "\n" );
262  }
263 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
Definition: aig.h:69
Vec_Int_t * vImps
Definition: fra.h:163
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Aig_Obj_t * Fra_ClassObjRepr(Aig_Obj_t *pObj)
Definition: fra.h:269
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesRefine ( Fra_Cla_t p)

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

Synopsis [Refines the classes after simulation.]

Description [Assumes that simulation info is assigned. Returns the number of classes refined.]

SideEffects []

SeeAlso []

Definition at line 493 of file fraClass.c.

494 {
495  Vec_Ptr_t * vTemp;
496  Aig_Obj_t ** pClass;
497  int i, nRefis;
498  // refine the classes
499  nRefis = 0;
501  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
502  {
503  // add the class to the new array
504  assert( pClass[0] != NULL );
505  Vec_PtrPush( p->vClassesTemp, pClass );
506  // refine the class iteratively
507  nRefis += Fra_RefineClassLastIter( p, p->vClassesTemp );
508  }
509  // exchange the class representation
510  vTemp = p->vClassesTemp;
511  p->vClassesTemp = p->vClasses;
512  p->vClasses = vTemp;
513  return nRefis;
514 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int Fra_RefineClassLastIter(Fra_Cla_t *p, Vec_Ptr_t *vClasses)
Definition: fraClass.c:457
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Vec_Ptr_t * vClassesTemp
Definition: fra.h:156
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesRefine1 ( Fra_Cla_t p,
int  fRefineNewClass,
int *  pSkipped 
)

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

Synopsis [Refines constant 1 equivalence class.]

Description []

SideEffects []

SeeAlso []

Definition at line 527 of file fraClass.c.

528 {
529  Aig_Obj_t * pObj, ** ppClass;
530  int i, k, nRefis = 1;
531  // check if there is anything to refine
532  if ( Vec_PtrSize(p->vClasses1) == 0 )
533  return 0;
534  // make sure constant 1 class contains only non-constant nodes
536  // collect all the nodes to be refined
537  k = 0;
538  Vec_PtrClear( p->vClassNew );
539  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
540  {
541  if ( p->pFuncNodeIsConst( pObj ) )
542  Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
543  else
544  Vec_PtrPush( p->vClassNew, pObj );
545  }
546  Vec_PtrShrink( p->vClasses1, k );
547  if ( Vec_PtrSize(p->vClassNew) == 0 )
548  return 0;
549 /*
550  printf( "Refined const-1 class: {" );
551  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
552  printf( " %d", pObj->Id );
553  printf( " }\n" );
554 */
555  if ( Vec_PtrSize(p->vClassNew) == 1 )
556  {
558  return 1;
559  }
560  // create a new class composed of these nodes
561  ppClass = p->pMemClassesFree;
562  p->pMemClassesFree += 2 * Vec_PtrSize(p->vClassNew);
563  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
564  {
565  ppClass[i] = pObj;
566  ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
567  Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
568  }
569  assert( ppClass[0] != NULL );
570  Vec_PtrPush( p->vClasses, ppClass );
571  // iteratively refine this class
572  if ( fRefineNewClass )
573  nRefis += Fra_RefineClassLastIter( p, p->vClasses );
574  else if ( pSkipped )
575  (*pSkipped)++;
576  return nRefis;
577 }
Aig_Obj_t ** pMemClassesFree
Definition: fra.h:158
int Fra_RefineClassLastIter(Fra_Cla_t *p, Vec_Ptr_t *vClasses)
Definition: fraClass.c:457
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: aig.h:69
int(* pFuncNodeIsConst)(Aig_Obj_t *)
Definition: fra.h:166
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Aig_Man_t * pAig
Definition: fra.h:152
Vec_Ptr_t * vClassNew
Definition: fra.h:160
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
void Fra_ClassesSelectRepr ( Fra_Cla_t p)

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

Synopsis [Postprocesses the classes by selecting representative lowest in top order.]

Description []

SideEffects []

SeeAlso []

Definition at line 706 of file fraClass.c.

707 {
708  Aig_Obj_t ** pClass, * pNodeMin;
709  int i, c, cMinSupp, nSuppSizeMin, nSuppSizeCur;
710  // reassign representatives in each class
711  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
712  {
713  // collect support sizes and find the min-support node
714  cMinSupp = -1;
715  pNodeMin = NULL;
716  nSuppSizeMin = ABC_INFINITY;
717  for ( c = 0; pClass[c]; c++ )
718  {
719  nSuppSizeCur = Aig_SupportSize( p->pAig, pClass[c] );
720 // nSuppSizeCur = 1;
721  if ( nSuppSizeMin > nSuppSizeCur ||
722  (nSuppSizeMin == nSuppSizeCur && pNodeMin->Level > pClass[c]->Level) )
723  {
724  nSuppSizeMin = nSuppSizeCur;
725  pNodeMin = pClass[c];
726  cMinSupp = c;
727  }
728  }
729  // skip the case when the repr did not change
730  if ( cMinSupp == 0 )
731  continue;
732  // make the new node the representative of the class
733  pClass[cMinSupp] = pClass[0];
734  pClass[0] = pNodeMin;
735  // set the representative
736  for ( c = 0; pClass[c]; c++ )
737  Fra_ClassObjSetRepr( pClass[c], c? pClass[0] : NULL );
738  }
739 }
unsigned Level
Definition: aig.h:82
Vec_Ptr_t * vClasses
Definition: fra.h:154
int Aig_SupportSize(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigDfs.c:758
Definition: aig.h:69
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Aig_Man_t * pAig
Definition: fra.h:152
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Fra_Cla_t* Fra_ClassesStart ( Aig_Man_t pAig)

FUNCTION DEFINITIONS ///.

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 60 of file fraClass.c.

61 {
62  Fra_Cla_t * p;
63  p = ABC_ALLOC( Fra_Cla_t, 1 );
64  memset( p, 0, sizeof(Fra_Cla_t) );
65  p->pAig = pAig;
67  memset( p->pMemRepr, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) );
68  p->vClasses = Vec_PtrAlloc( 100 );
69  p->vClasses1 = Vec_PtrAlloc( 100 );
70  p->vClassesTemp = Vec_PtrAlloc( 100 );
71  p->vClassOld = Vec_PtrAlloc( 100 );
72  p->vClassNew = Vec_PtrAlloc( 100 );
76  return p;
77 }
char * memset()
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
Definition: fraSim.c:86
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vClasses
Definition: fra.h:154
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Ptr_t * vClassesTemp
Definition: fra.h:156
int(* pFuncNodesAreEqual)(Aig_Obj_t *, Aig_Obj_t *)
Definition: fra.h:167
Vec_Ptr_t * vClassOld
Definition: fra.h:159
Definition: aig.h:69
int(* pFuncNodeIsConst)(Aig_Obj_t *)
Definition: fra.h:166
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
Vec_Ptr_t * vClasses1
Definition: fra.h:155
int Fra_SmlNodeHash(Aig_Obj_t *pObj, int nTableSize)
DECLARATIONS ///.
Definition: fraSim.c:46
Aig_Man_t * pAig
Definition: fra.h:152
Vec_Ptr_t * vClassNew
Definition: fra.h:160
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Fra_SmlNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: fraSim.c:109
int(* pFuncNodeHash)(Aig_Obj_t *, int)
Definition: fra.h:165
void Fra_ClassesStop ( Fra_Cla_t p)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file fraClass.c.

91 {
92  ABC_FREE( p->pMemClasses );
93  ABC_FREE( p->pMemRepr );
94  if ( p->vClassesTemp ) Vec_PtrFree( p->vClassesTemp );
95  if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
96  if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
97  if ( p->vClasses1 ) Vec_PtrFree( p->vClasses1 );
98  if ( p->vClasses ) Vec_PtrFree( p->vClasses );
99  if ( p->vImps ) Vec_IntFree( p->vImps );
100  ABC_FREE( p );
101 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
Vec_Ptr_t * vClassesTemp
Definition: fra.h:156
Vec_Ptr_t * vClassOld
Definition: fra.h:159
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
Vec_Int_t * vImps
Definition: fra.h:163
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Vec_Ptr_t * vClassNew
Definition: fra.h:160
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Fra_ClassesTest ( Fra_Cla_t p,
int  Id1,
int  Id2 
)

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

Synopsis [Starts representation of equivalence classes with one class.]

Description []

SideEffects []

SeeAlso []

Definition at line 590 of file fraClass.c.

591 {
592  Aig_Obj_t ** pClass;
593  p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 4 );
594  pClass = p->pMemClasses;
595  assert( Id1 < Id2 );
596  pClass[0] = Aig_ManObj( p->pAig, Id1 );
597  pClass[1] = Aig_ManObj( p->pAig, Id2 );
598  pClass[2] = NULL;
599  pClass[3] = NULL;
600  Fra_ClassObjSetRepr( pClass[1], pClass[0] );
601  Vec_PtrPush( p->vClasses, pClass );
602 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
Definition: aig.h:69
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Aig_Man_t * pAig
Definition: fra.h:152
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t* Fra_ClassObjRepr ( Aig_Obj_t pObj)
inlinestatic

Definition at line 269 of file fra.h.

269 { return ((Fra_Man_t *)pObj->pData)->pCla->pMemRepr[pObj->Id]; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static void Fra_ClassObjSetRepr ( Aig_Obj_t pObj,
Aig_Obj_t pNode 
)
inlinestatic

Definition at line 270 of file fra.h.

270 { ((Fra_Man_t *)pObj->pData)->pCla->pMemRepr[pObj->Id] = pNode; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
void Fra_CnfNodeAddToSolver ( Fra_Man_t p,
Aig_Obj_t pOld,
Aig_Obj_t pNew 
)

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

Synopsis [Updates the solver clause database.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file fraCnf.c.

239 {
240  Vec_Ptr_t * vFrontier, * vFanins;
241  Aig_Obj_t * pNode, * pFanin;
242  int i, k, fUseMuxes = 1;
243  assert( pOld || pNew );
244  // quit if CNF is ready
245  if ( (!pOld || Fra_ObjFaninVec(pOld)) && (!pNew || Fra_ObjFaninVec(pNew)) )
246  return;
247  // start the frontier
248  vFrontier = Vec_PtrAlloc( 100 );
249  if ( pOld ) Fra_ObjAddToFrontier( p, pOld, vFrontier );
250  if ( pNew ) Fra_ObjAddToFrontier( p, pNew, vFrontier );
251  // explore nodes in the frontier
252  Vec_PtrForEachEntry( Aig_Obj_t *, vFrontier, pNode, i )
253  {
254  // create the supergate
255  assert( Fra_ObjSatNum(pNode) );
256  assert( Fra_ObjFaninVec(pNode) == NULL );
257  if ( fUseMuxes && Aig_ObjIsMuxType(pNode) )
258  {
259  vFanins = Vec_PtrAlloc( 4 );
260  Vec_PtrPushUnique( vFanins, Aig_ObjFanin0( Aig_ObjFanin0(pNode) ) );
261  Vec_PtrPushUnique( vFanins, Aig_ObjFanin0( Aig_ObjFanin1(pNode) ) );
262  Vec_PtrPushUnique( vFanins, Aig_ObjFanin1( Aig_ObjFanin0(pNode) ) );
263  Vec_PtrPushUnique( vFanins, Aig_ObjFanin1( Aig_ObjFanin1(pNode) ) );
264  Vec_PtrForEachEntry( Aig_Obj_t *, vFanins, pFanin, k )
265  Fra_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
266  Fra_AddClausesMux( p, pNode );
267  }
268  else
269  {
270  vFanins = Fra_CollectSuper( pNode, fUseMuxes );
271  Vec_PtrForEachEntry( Aig_Obj_t *, vFanins, pFanin, k )
272  Fra_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
273  Fra_AddClausesSuper( p, pNode, vFanins );
274  }
275  assert( Vec_PtrSize(vFanins) > 1 );
276  Fra_ObjSetFaninVec( pNode, vFanins );
277  }
278  Vec_PtrFree( vFrontier );
279 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static void Fra_ObjSetFaninVec(Aig_Obj_t *pObj, Vec_Ptr_t *vFanins)
Definition: fra.h:264
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Fra_ObjAddToFrontier(Fra_Man_t *p, Aig_Obj_t *pObj, Vec_Ptr_t *vFrontier)
Definition: fraCnf.c:213
void Fra_AddClausesSuper(Fra_Man_t *p, Aig_Obj_t *pNode, Vec_Ptr_t *vSuper)
Definition: fraCnf.c:129
else
Definition: sparse_int.h:55
Definition: aig.h:69
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Aig_ObjIsMuxType(Aig_Obj_t *pObj)
Definition: aigUtil.c:307
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Ptr_t * Fra_CollectSuper(Aig_Obj_t *pObj, int fUseMuxes)
Definition: fraCnf.c:192
ABC_NAMESPACE_IMPL_START void Fra_AddClausesMux(Fra_Man_t *p, Aig_Obj_t *pNode)
DECLARATIONS ///.
Definition: fraCnf.c:46
static Vec_Ptr_t * Fra_ObjFaninVec(Aig_Obj_t *pObj)
Definition: fra.h:263
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Fra_FraigCec ( Aig_Man_t **  ppAig,
int  nConfLimit,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file fraCec.c.

321 {
322  int nBTLimitStart = 300; // starting SAT run
323  int nBTLimitFirst = 2; // first fraiging iteration
324  int nBTLimitLast = nConfLimit; // the last-gasp SAT run
325 
326  Fra_Par_t Params, * pParams = &Params;
327  Aig_Man_t * pAig = *ppAig, * pTemp;
328  int i, RetValue;
329  abctime clk;
330 
331  // report the original miter
332  if ( fVerbose )
333  {
334  printf( "Original miter: Nodes = %6d.\n", Aig_ManNodeNum(pAig) );
335  }
336  RetValue = Fra_FraigMiterStatus( pAig );
337 // assert( RetValue == -1 );
338  if ( RetValue == 0 )
339  {
340  pAig->pData = ABC_ALLOC( int, Aig_ManCiNum(pAig) );
341  memset( pAig->pData, 0, sizeof(int) * Aig_ManCiNum(pAig) );
342  return RetValue;
343  }
344 
345  // if SAT only, solve without iteration
346 clk = Abc_Clock();
347  RetValue = Fra_FraigSat( pAig, (ABC_INT64_T)2*nBTLimitStart, (ABC_INT64_T)0, 0, 0, 0, 1, 0, 0, 0 );
348  if ( fVerbose )
349  {
350  printf( "Initial SAT: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
351 ABC_PRT( "Time", Abc_Clock() - clk );
352  }
353  if ( RetValue >= 0 )
354  return RetValue;
355 
356  // duplicate the AIG
357 clk = Abc_Clock();
358  pAig = Dar_ManRwsat( pTemp = pAig, 1, 0 );
359  Aig_ManStop( pTemp );
360  if ( fVerbose )
361  {
362  printf( "Rewriting: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
363 ABC_PRT( "Time", Abc_Clock() - clk );
364  }
365 
366  // perform the loop
367  Fra_ParamsDefault( pParams );
368  pParams->nBTLimitNode = nBTLimitFirst;
369  pParams->nBTLimitMiter = nBTLimitStart;
370  pParams->fDontShowBar = 1;
371  pParams->fProve = 1;
372  for ( i = 0; i < 6; i++ )
373  {
374 //printf( "Running fraiging with %d BTnode and %d BTmiter.\n", pParams->nBTLimitNode, pParams->nBTLimitMiter );
375  // try XOR balancing
376  if ( Aig_ManCountXors(pAig) * 30 > Aig_ManNodeNum(pAig) + 300 )
377  {
378 clk = Abc_Clock();
379  pAig = Dar_ManBalanceXor( pTemp = pAig, 1, 0, 0 );
380  Aig_ManStop( pTemp );
381  if ( fVerbose )
382  {
383  printf( "Balance-X: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
384 ABC_PRT( "Time", Abc_Clock() - clk );
385  }
386  }
387 
388  // run fraiging
389 clk = Abc_Clock();
390  pAig = Fra_FraigPerform( pTemp = pAig, pParams );
391  Aig_ManStop( pTemp );
392  if ( fVerbose )
393  {
394  printf( "Fraiging (i=%d): Nodes = %6d. ", i+1, Aig_ManNodeNum(pAig) );
395 ABC_PRT( "Time", Abc_Clock() - clk );
396  }
397 
398  // check the miter status
399  RetValue = Fra_FraigMiterStatus( pAig );
400  if ( RetValue >= 0 )
401  break;
402 
403  // perform rewriting
404 clk = Abc_Clock();
405  pAig = Dar_ManRewriteDefault( pTemp = pAig );
406  Aig_ManStop( pTemp );
407  if ( fVerbose )
408  {
409  printf( "Rewriting: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
410 ABC_PRT( "Time", Abc_Clock() - clk );
411  }
412 
413  // check the miter status
414  RetValue = Fra_FraigMiterStatus( pAig );
415  if ( RetValue >= 0 )
416  break;
417  // try simulation
418 
419  // set the parameters for the next run
420  pParams->nBTLimitNode = 8 * pParams->nBTLimitNode;
421  pParams->nBTLimitMiter = 2 * pParams->nBTLimitMiter;
422  }
423 
424  // if still unsolved try last gasp
425  if ( RetValue == -1 )
426  {
427 clk = Abc_Clock();
428  RetValue = Fra_FraigSat( pAig, (ABC_INT64_T)nBTLimitLast, (ABC_INT64_T)0, 0, 0, 0, 1, 0, 0, 0 );
429  if ( fVerbose )
430  {
431  printf( "Final SAT: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
432 ABC_PRT( "Time", Abc_Clock() - clk );
433  }
434  }
435 
436  *ppAig = pAig;
437  return RetValue;
438 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Man_t * Dar_ManBalanceXor(Aig_Man_t *pAig, int fExor, int fUpdateLevel, int fVerbose)
Definition: darBalance.c:687
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int Aig_ManCountXors(Aig_Man_t *p)
Definition: fraCec.c:298
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
ABC_NAMESPACE_IMPL_START 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)
DECLARATIONS ///.
Definition: fraCec.c:47
static abctime Abc_Clock()
Definition: abc_global.h:279
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
Definition: darScript.c:71
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
void Fra_ParamsDefault(Fra_Par_t *pParams)
DECLARATIONS ///.
Definition: fraMan.c:45
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Aig_Man_t * Dar_ManRewriteDefault(Aig_Man_t *pAig)
DECLARATIONS ///.
Definition: darScript.c:48
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Aig_Man_t * Fra_FraigPerform(Aig_Man_t *pManAig, Fra_Par_t *pPars)
Definition: fraCore.c:375
int Fra_FraigMiterStatus(Aig_Man_t *p)
DECLARATIONS ///.
Definition: fraCore.c:62
ABC_INT64_T abctime
Definition: abc_global.h:278
int Fra_FraigCecPartitioned ( Aig_Man_t pMan1,
Aig_Man_t pMan2,
int  nConfLimit,
int  nPartSize,
int  fSmart,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 451 of file fraCec.c.

452 {
453  Aig_Man_t * pAig;
454  Vec_Ptr_t * vParts;
455  int i, RetValue = 1, nOutputs;
456  // create partitions
457  vParts = Aig_ManMiterPartitioned( pMan1, pMan2, nPartSize, fSmart );
458  // solve the partitions
459  nOutputs = -1;
460  Vec_PtrForEachEntry( Aig_Man_t *, vParts, pAig, i )
461  {
462  nOutputs++;
463  if ( fVerbose )
464  {
465  printf( "Verifying part %4d (out of %4d) PI = %5d. PO = %5d. And = %6d. Lev = %4d.\r",
466  i+1, Vec_PtrSize(vParts), Aig_ManCiNum(pAig), Aig_ManCoNum(pAig),
467  Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
468  fflush( stdout );
469  }
470  RetValue = Fra_FraigMiterStatus( pAig );
471  if ( RetValue == 1 )
472  continue;
473  if ( RetValue == 0 )
474  break;
475  RetValue = Fra_FraigCec( &pAig, nConfLimit, 0 );
476  Vec_PtrWriteEntry( vParts, i, pAig );
477  if ( RetValue == 1 )
478  continue;
479  if ( RetValue == 0 )
480  break;
481  break;
482  }
483  // clear the result
484  if ( fVerbose )
485  {
486  printf( " \r" );
487  fflush( stdout );
488  }
489  // report the timeout
490  if ( RetValue == -1 )
491  {
492  printf( "Timed out after verifying %d partitions (out of %d).\n", nOutputs, Vec_PtrSize(vParts) );
493  fflush( stdout );
494  }
495  // free intermediate results
496  Vec_PtrForEachEntry( Aig_Man_t *, vParts, pAig, i )
497  Aig_ManStop( pAig );
498  Vec_PtrFree( vParts );
499  return RetValue;
500 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
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 int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
int Fra_FraigCec(Aig_Man_t **ppAig, int nConfLimit, int fVerbose)
Definition: fraCec.c:320
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
int Aig_ManLevelNum(Aig_Man_t *p)
Definition: aigDfs.c:486
Vec_Ptr_t * Aig_ManMiterPartitioned(Aig_Man_t *p1, Aig_Man_t *p2, int nPartSize, int fSmart)
Definition: aigPart.c:1189
int Fra_FraigMiterStatus(Aig_Man_t *p)
DECLARATIONS ///.
Definition: fraCore.c:62
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Aig_Man_t* Fra_FraigChoice ( Aig_Man_t pManAig,
int  nConfMax,
int  nLevelMax 
)

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

Synopsis [Performs choicing of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file fraCore.c.

443 {
444  Fra_Par_t Pars, * pPars = &Pars;
445  Fra_ParamsDefault( pPars );
446  pPars->nBTLimitNode = nConfMax;
447  pPars->fChoicing = 1;
448  pPars->fDoSparse = 1;
449  pPars->fSpeculate = 0;
450  pPars->fProve = 0;
451  pPars->fVerbose = 0;
452  pPars->fDontShowBar = 1;
453  pPars->nLevelMax = nLevelMax;
454  return Fra_FraigPerform( pManAig, pPars );
455 }
Aig_Man_t * Fra_FraigPerform(Aig_Man_t *pManAig, Fra_Par_t *pPars)
Definition: fraCore.c:375
void Fra_ParamsDefault(Fra_Par_t *pParams)
DECLARATIONS ///.
Definition: fraMan.c:45
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
Aig_Man_t* Fra_FraigEquivence ( Aig_Man_t pManAig,
int  nConfMax,
int  fProve 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 468 of file fraCore.c.

469 {
470  Aig_Man_t * pFraig;
471  Fra_Par_t Pars, * pPars = &Pars;
472  Fra_ParamsDefault( pPars );
473  pPars->nBTLimitNode = nConfMax;
474  pPars->fChoicing = 0;
475  pPars->fDoSparse = 1;
476  pPars->fSpeculate = 0;
477  pPars->fProve = fProve;
478  pPars->fVerbose = 0;
479  pPars->fDontShowBar = 1;
480  pFraig = Fra_FraigPerform( pManAig, pPars );
481  return pFraig;
482 }
Aig_Man_t * Fra_FraigPerform(Aig_Man_t *pManAig, Fra_Par_t *pPars)
Definition: fraCore.c:375
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Fra_ParamsDefault(Fra_Par_t *pParams)
DECLARATIONS ///.
Definition: fraMan.c:45
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
Aig_Man_t* Fra_FraigInduction ( Aig_Man_t pManAig,
Fra_Ssw_t pParams 
)

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

Synopsis [Performs sequential SAT sweeping.]

Description []

SideEffects []

SeeAlso []

Definition at line 344 of file fraInd.c.

345 {
346  int fUseSimpleCnf = 0;
347  int fUseOldSimulation = 0;
348  // other paramaters affecting performance
349  // - presence of FRAIGing in Abc_NtkDarSeqSweep()
350  // - using distance-1 patterns in Fra_SmlAssignDist1()
351  // - the number of simulation patterns
352  // - the number of BMC frames
353 
354  Fra_Man_t * p;
355  Fra_Par_t Pars, * pPars = &Pars;
356  Aig_Obj_t * pObj;
357  Cnf_Dat_t * pCnf;
358  Aig_Man_t * pManAigNew = NULL;
359  int nNodesBeg, nRegsBeg;
360  int nIter = -1; // Suppress "might be used uninitialized"
361  int i;
362  abctime clk = Abc_Clock(), clk2;
363  abctime TimeToStop = pParams->TimeLimit ? pParams->TimeLimit * CLOCKS_PER_SEC + Abc_Clock() : 0;
364 
365  if ( Aig_ManNodeNum(pManAig) == 0 )
366  {
367  pParams->nIters = 0;
368  // Ntl_ManFinalize() needs the following to satisfy an assertion
369  Aig_ManReprStart(pManAig,Aig_ManObjNumMax(pManAig));
370  return Aig_ManDupOrdered(pManAig);
371  }
372  assert( Aig_ManRegNum(pManAig) > 0 );
373  assert( pParams->nFramesK > 0 );
374 //Aig_ManShow( pManAig, 0, NULL );
375 
376  if ( pParams->fWriteImps && pParams->nPartSize > 0 )
377  {
378  pParams->nPartSize = 0;
379  printf( "Partitioning was disabled to allow implication writing.\n" );
380  }
381  // perform partitioning
382  if ( (pParams->nPartSize > 0 && pParams->nPartSize < Aig_ManRegNum(pManAig))
383  || (pManAig->vClockDoms && Vec_VecSize(pManAig->vClockDoms) > 0) )
384  return Fra_FraigInductionPart( pManAig, pParams );
385 
386  nNodesBeg = Aig_ManNodeNum(pManAig);
387  nRegsBeg = Aig_ManRegNum(pManAig);
388 
389  // enhance the AIG by adding timeframes
390 // Fra_FramesAddMore( pManAig, 3 );
391 
392  // get parameters
393  Fra_ParamsDefaultSeq( pPars );
394  pPars->nFramesP = pParams->nFramesP;
395  pPars->nFramesK = pParams->nFramesK;
396  pPars->nMaxImps = pParams->nMaxImps;
397  pPars->nMaxLevs = pParams->nMaxLevs;
398  pPars->fVerbose = pParams->fVerbose;
399  pPars->fRewrite = pParams->fRewrite;
400  pPars->fLatchCorr = pParams->fLatchCorr;
401  pPars->fUseImps = pParams->fUseImps;
402  pPars->fWriteImps = pParams->fWriteImps;
403  pPars->fUse1Hot = pParams->fUse1Hot;
404 
405  assert( !(pPars->nFramesP > 0 && pPars->fUse1Hot) );
406  assert( !(pPars->nFramesK > 1 && pPars->fUse1Hot) );
407 
408  // start the fraig manager for this run
409  p = Fra_ManStart( pManAig, pPars );
410  p->pPars->nBTLimitNode = 0;
411  // derive and refine e-classes using K initialized frames
412  if ( fUseOldSimulation )
413  {
414  if ( pPars->nFramesP > 0 )
415  {
416  pPars->nFramesP = 0;
417  printf( "Fra_FraigInduction(): Prefix cannot be used.\n" );
418  }
419  p->pSml = Fra_SmlStart( pManAig, 0, pPars->nFramesK + 1, pPars->nSimWords );
420  Fra_SmlSimulate( p, 1 );
421  }
422  else
423  {
424  // bug: r iscas/blif/s5378.blif ; st; ssw -v
425  // bug: r iscas/blif/s1238.blif ; st; ssw -v
426  // refine the classes with more simulation rounds
427 if ( pPars->fVerbose )
428 printf( "Simulating %d AIG nodes for %d cycles ... ", Aig_ManNodeNum(pManAig), pPars->nFramesP + 32 );
429  p->pSml = Fra_SmlSimulateSeq( pManAig, pPars->nFramesP, 32, 1, 1 ); //pPars->nFramesK + 1, 1 );
430 if ( pPars->fVerbose )
431 {
432 ABC_PRT( "Time", Abc_Clock() - clk );
433 }
434  Fra_ClassesPrepare( p->pCla, p->pPars->fLatchCorr, p->pPars->nMaxLevs );
435 // Fra_ClassesPostprocess( p->pCla );
436  // compute one-hotness conditions
437  if ( p->pPars->fUse1Hot )
438  p->vOneHots = Fra_OneHotCompute( p, p->pSml );
439  // allocate new simulation manager for simulating counter-examples
440  Fra_SmlStop( p->pSml );
441  p->pSml = Fra_SmlStart( pManAig, 0, pPars->nFramesK + 1, pPars->nSimWords );
442  }
443 
444  // select the most expressive implications
445  if ( pPars->fUseImps )
446  p->pCla->vImps = Fra_ImpDerive( p, 5000000, pPars->nMaxImps, pPars->fLatchCorr );
447 
448  if ( pParams->TimeLimit != 0.0 && Abc_Clock() > TimeToStop )
449  {
450  if ( !pParams->fSilent )
451  printf( "Fra_FraigInduction(): Runtime limit exceeded.\n" );
452  goto finish;
453  }
454 
455  // perform BMC (for the min number of frames)
456  Fra_BmcPerform( p, pPars->nFramesP, pPars->nFramesK+1 ); // +1 is needed to prevent non-refinement
457 //Fra_ClassesPrint( p->pCla, 1 );
458 // if ( p->vCex == NULL )
459 // p->vCex = Vec_IntAlloc( 1000 );
460 
462  p->nNodesBeg = nNodesBeg; // Aig_ManNodeNum(pManAig);
463  p->nRegsBeg = nRegsBeg; // Aig_ManRegNum(pManAig);
464 
465  // dump AIG of the timeframes
466 // pManAigNew = Fra_ClassesDeriveAig( p->pCla, pPars->nFramesK );
467 // Aig_ManDumpBlif( pManAigNew, "frame_aig.blif", NULL, NULL );
468 // Fra_ManPartitionTest2( pManAigNew );
469 // Aig_ManStop( pManAigNew );
470 
471  // iterate the inductive case
472  p->pCla->fRefinement = 1;
473  for ( nIter = 0; p->pCla->fRefinement; nIter++ )
474  {
475  int nLitsOld = Fra_ClassesCountLits(p->pCla);
476  int nImpsOld = p->pCla->vImps? Vec_IntSize(p->pCla->vImps) : 0;
477  int nHotsOld = p->vOneHots? Fra_OneHotCount(p, p->vOneHots) : 0;
478  abctime clk3 = Abc_Clock();
479 
480  if ( pParams->TimeLimit != 0.0 && Abc_Clock() > TimeToStop )
481  {
482  if ( !pParams->fSilent )
483  printf( "Fra_FraigInduction(): Runtime limit exceeded.\n" );
484  goto finish;
485  }
486 
487  // mark the classes as non-refined
488  p->pCla->fRefinement = 0;
489  // derive non-init K-timeframes while implementing e-classes
490 clk2 = Abc_Clock();
492 p->timeTrav += Abc_Clock() - clk2;
493 //Aig_ManDumpBlif( p->pManFraig, "testaig.blif", NULL, NULL );
494 
495  // perform AIG rewriting
496  if ( p->pPars->fRewrite )
498 
499  // convert the manager to SAT solver (the last nLatches outputs are inputs)
500  if ( fUseSimpleCnf || pPars->fUseImps )
502  else
503  pCnf = Cnf_Derive( p->pManFraig, Aig_ManRegNum(p->pManFraig) );
504 // Cnf_DataTranformPolarity( pCnf, 0 );
505 //Cnf_DataWriteIntoFile( pCnf, "temp.cnf", 1 );
506 
507  p->pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
508  p->nSatVars = pCnf->nVars;
509  assert( p->pSat != NULL );
510  if ( p->pSat == NULL )
511  printf( "Fra_FraigInduction(): Computed CNF is not valid.\n" );
512  if ( pPars->fUseImps )
513  {
514  Fra_ImpAddToSolver( p, p->pCla->vImps, pCnf->pVarNums );
515  if ( p->pSat == NULL )
516  printf( "Fra_FraigInduction(): Adding implicationsn to CNF led to a conflict.\n" );
517  }
518 
519  // set the pointers to the manager
520  Aig_ManForEachObj( p->pManFraig, pObj, i )
521  pObj->pData = p;
522 
523  // prepare solver for fraiging the last timeframe
524  Fra_ManClean( p, Aig_ManObjNumMax(p->pManFraig) + Aig_ManNodeNum(p->pManAig) );
525 
526  // transfer PI/LO variable numbers
527  Aig_ManForEachObj( p->pManFraig, pObj, i )
528  {
529  if ( pCnf->pVarNums[pObj->Id] == -1 )
530  continue;
531  Fra_ObjSetSatNum( pObj, pCnf->pVarNums[pObj->Id] );
532  Fra_ObjSetFaninVec( pObj, (Vec_Ptr_t *)1 );
533  }
534  Cnf_DataFree( pCnf );
535 
536  // add one-hotness clauses
537  if ( p->pPars->fUse1Hot )
538  Fra_OneHotAssume( p, p->vOneHots );
539 // if ( p->pManAig->vOnehots )
540 // Fra_OneHotAddKnownConstraint( p, p->pManAig->vOnehots );
541 
542  // report the intermediate results
543  if ( pPars->fVerbose )
544  {
545  printf( "%3d : C = %6d. Cl = %6d. L = %6d. LR = %6d. ",
546  nIter, Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses),
547  Fra_ClassesCountLits(p->pCla), p->pManFraig->nAsserts );
548  if ( p->pCla->vImps )
549  printf( "I = %6d. ", Vec_IntSize(p->pCla->vImps) );
550  if ( p->pPars->fUse1Hot )
551  printf( "1h = %6d. ", Fra_OneHotCount(p, p->vOneHots) );
552  printf( "NR = %6d. ", Aig_ManNodeNum(p->pManFraig) );
553 // printf( "\n" );
554  }
555 
556  // perform sweeping
557  p->nSatCallsRecent = 0;
558  p->nSatCallsSkipped = 0;
559 clk2 = Abc_Clock();
560  if ( p->pPars->fUse1Hot )
561  Fra_OneHotCheck( p, p->vOneHots );
562  Fra_FraigSweep( p );
563  if ( pPars->fVerbose )
564  {
565  ABC_PRT( "T", Abc_Clock() - clk3 );
566  }
567 
568 // Sat_SolverPrintStats( stdout, p->pSat );
569  // remove FRAIG and SAT solver
570  Aig_ManStop( p->pManFraig ); p->pManFraig = NULL;
571 // printf( "Vars = %d. Clauses = %d. Learnts = %d.\n", p->pSat->size, p->pSat->clauses.size, p->pSat->learnts.size );
572  sat_solver_delete( p->pSat ); p->pSat = NULL;
573  memset( p->pMemFraig, 0, sizeof(Aig_Obj_t *) * p->nSizeAlloc * p->nFramesAll );
574 // printf( "Recent SAT called = %d. Skipped = %d.\n", p->nSatCallsRecent, p->nSatCallsSkipped );
575  assert( p->vTimeouts == NULL );
576  if ( p->vTimeouts )
577  printf( "Fra_FraigInduction(): SAT solver timed out!\n" );
578  // check if refinement has happened
579 // p->pCla->fRefinement = (int)(nLitsOld != Fra_ClassesCountLits(p->pCla));
580  if ( p->pCla->fRefinement &&
581  nLitsOld == Fra_ClassesCountLits(p->pCla) &&
582  nImpsOld == (p->pCla->vImps? Vec_IntSize(p->pCla->vImps) : 0) &&
583  nHotsOld == (p->vOneHots? Fra_OneHotCount(p, p->vOneHots) : 0) )
584  {
585  printf( "Fra_FraigInduction(): Internal error. The result may not verify.\n" );
586  break;
587  }
588  }
589 /*
590  // verify implications using simulation
591  if ( p->pCla->vImps && Vec_IntSize(p->pCla->vImps) )
592  {
593  int Temp;
594  abctime clk = Abc_Clock();
595  if ( Temp = Fra_ImpVerifyUsingSimulation( p ) )
596  printf( "Implications failing the simulation test = %d (out of %d). ", Temp, Vec_IntSize(p->pCla->vImps) );
597  else
598  printf( "All %d implications have passed the simulation test. ", Vec_IntSize(p->pCla->vImps) );
599  ABC_PRT( "Time", Abc_Clock() - clk );
600  }
601 */
602 
603  // move the classes into representatives and reduce AIG
604 clk2 = Abc_Clock();
605  if ( p->pPars->fWriteImps && p->vOneHots && Fra_OneHotCount(p, p->vOneHots) )
606  {
607  extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
608  Aig_Man_t * pNew;
609  char * pFileName = Ioa_FileNameGenericAppend( p->pManAig->pName, "_care.aig" );
610  printf( "Care one-hotness clauses will be written into file \"%s\".\n", pFileName );
611  pManAigNew = Aig_ManDupOrdered( pManAig );
612  pNew = Fra_OneHotCreateExdc( p, p->vOneHots );
613  Ioa_WriteAiger( pNew, pFileName, 0, 1 );
614  Aig_ManStop( pNew );
615  }
616  else
617  {
618  // Fra_ClassesPrint( p->pCla, 1 );
619  Fra_ClassesSelectRepr( p->pCla );
620  Fra_ClassesCopyReprs( p->pCla, p->vTimeouts );
621  pManAigNew = Aig_ManDupRepr( pManAig, 0 );
622  }
623  // add implications to the manager
624 // if ( fWriteImps && p->pCla->vImps && Vec_IntSize(p->pCla->vImps) )
625 // Fra_ImpRecordInManager( p, pManAigNew );
626  // cleanup the new manager
627  Aig_ManSeqCleanup( pManAigNew );
628  // remove pointers to the dead nodes
629 // Aig_ManForEachObj( pManAig, pObj, i )
630 // if ( pObj->pData && Aig_ObjIsNone(pObj->pData) )
631 // pObj->pData = NULL;
632 // Aig_ManCountMergeRegs( pManAigNew );
633 p->timeTrav += Abc_Clock() - clk2;
634 p->timeTotal = Abc_Clock() - clk;
635  // get the final stats
636  p->nLitsEnd = Fra_ClassesCountLits( p->pCla );
637  p->nNodesEnd = Aig_ManNodeNum(pManAigNew);
638  p->nRegsEnd = Aig_ManRegNum(pManAigNew);
639  // free the manager
640 finish:
641  Fra_ManStop( p );
642  // check the output
643 // if ( Aig_ManCoNum(pManAigNew) - Aig_ManRegNum(pManAigNew) == 1 )
644 // if ( Aig_ObjChild0( Aig_ManCo(pManAigNew,0) ) == Aig_ManConst0(pManAigNew) )
645 // printf( "Proved output constant 0.\n" );
646  pParams->nIters = nIter;
647  return pManAigNew;
648 }
char * memset()
int fSilent
Definition: fra.h:108
int fRewrite
Definition: fra.h:102
int fUse1Hot
Definition: fra.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int fRefinement
Definition: fra.h:162
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition: cnfCore.c:165
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
Fra_Man_t * Fra_ManStart(Aig_Man_t *pManAig, Fra_Par_t *pParams)
Definition: fraMan.c:104
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Definition: fraSim.c:1021
int Aig_ManSeqCleanup(Aig_Man_t *p)
Definition: aigScl.c:158
Fra_Cla_t * pCla
Definition: fra.h:198
int nRegsBeg
Definition: fra.h:226
Fra_Par_t * pPars
Definition: fra.h:189
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
sat_solver * pSat
Definition: fra.h:210
Fra_Sml_t * pSml
Definition: fra.h:200
Aig_Man_t * Aig_ManDupOrdered(Aig_Man_t *p)
Definition: aigDup.c:277
int nVars
Definition: cnf.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Vec_Int_t * vOneHots
Definition: fra.h:208
float TimeLimit
Definition: fra.h:110
abctime timeTrav
Definition: fra.h:241
static void Fra_ObjSetFaninVec(Aig_Obj_t *pObj, Vec_Ptr_t *vFanins)
Definition: fra.h:264
int * pVarNums
Definition: cnf.h:63
int nSatVars
Definition: fra.h:211
int nNodesBeg
Definition: fra.h:224
Vec_Int_t * Fra_ImpDerive(Fra_Man_t *p, int nImpMaxLimit, int nImpUseLimit, int fLatchCorr)
Definition: fraImp.c:321
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: cnf.h:56
void Fra_ManClean(Fra_Man_t *p, int nNodesMax)
Definition: fraMan.c:145
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
void Fra_ParamsDefaultSeq(Fra_Par_t *pParams)
Definition: fraMan.c:75
Vec_Int_t * Fra_OneHotCompute(Fra_Man_t *p, Fra_Sml_t *pSim)
Definition: fraHot.c:134
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: fraSim.c:813
char * Ioa_FileNameGenericAppend(char *pBase, char *pSuffix)
Definition: ioaUtil.c:93
void Fra_ClassesPrepare(Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
Definition: fraClass.c:276
Aig_Man_t * pManFraig
Definition: fra.h:192
int nFramesP
Definition: fra.h:96
void Fra_FraigSweep(Fra_Man_t *pManAig)
Definition: fraCore.c:310
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition: aigRepr.c:45
int fWriteImps
Definition: fra.h:105
static void Fra_ObjSetSatNum(Aig_Obj_t *pObj, int Num)
Definition: fra.h:267
void Fra_BmcPerform(Fra_Man_t *p, int nPref, int nDepth)
Definition: fraBmc.c:311
void Fra_ImpAddToSolver(Fra_Man_t *p, Vec_Int_t *vImps, int *pSatVarNums)
Definition: fraImp.c:428
Definition: aig.h:69
int nFramesK
Definition: fra.h:97
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
Definition: ioaWriteAig.c:446
int nMaxImps
Definition: fra.h:98
Aig_Man_t * Aig_ManDupRepr(Aig_Man_t *p, int fOrdered)
Definition: aigRepr.c:267
Vec_Int_t * vImps
Definition: fra.h:163
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
Aig_Man_t * Fra_FraigInductionPart(Aig_Man_t *pAig, Fra_Ssw_t *pPars)
Definition: fraInd.c:253
ABC_NAMESPACE_IMPL_START void Fra_FraigInductionRewrite(Fra_Man_t *p)
DECLARATIONS ///.
Definition: fraInd.c:48
int nPartSize
Definition: fra.h:94
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fra_SmlSimulate(Fra_Man_t *p, int fInit)
Definition: fraSim.c:738
void Fra_ClassesSelectRepr(Fra_Cla_t *p)
Definition: fraClass.c:706
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition: cnfMan.c:463
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
Cnf_Dat_t * Cnf_DeriveSimple(Aig_Man_t *p, int nOutputs)
Definition: cnfWrite.c:587
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
void Fra_ManStop(Fra_Man_t *p)
Definition: fraMan.c:240
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int Fra_OneHotCount(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:303
void Fra_ClassesCopyReprs(Fra_Cla_t *p, Vec_Ptr_t *vFailed)
Definition: fraClass.c:114
int fUseImps
Definition: fra.h:101
static int Vec_VecSize(Vec_Vec_t *p)
Definition: vecVec.h:222
int fLatchCorr
Definition: fra.h:104
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
int nIters
Definition: fra.h:109
void Fra_OneHotCheck(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:229
#define assert(ex)
Definition: util_old.h:213
Aig_Man_t * Fra_OneHotCreateExdc(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:398
int fVerbose
Definition: fra.h:107
ABC_INT64_T abctime
Definition: abc_global.h:278
Aig_Man_t * Fra_FramesWithClasses(Fra_Man_t *p)
Definition: fraInd.c:130
int nMaxLevs
Definition: fra.h:99
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
int nLitsBeg
Definition: fra.h:222
void Fra_OneHotAssume(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:191
Aig_Man_t* Fra_FraigLatchCorrespondence ( Aig_Man_t pAig,
int  nFramesP,
int  nConfMax,
int  fProve,
int  fVerbose,
int *  pnIter,
float  TimeLimit 
)

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

Synopsis [Performs choicing of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 531 of file fraLcr.c.

532 {
533  int nPartSize = 200;
534  int fReprSelect = 0;
535  Fra_Lcr_t * p;
536  Fra_Sml_t * pSml;
537  Fra_Man_t * pTemp;
538  Aig_Man_t * pAigPart, * pAigTemp, * pAigNew = NULL;
539  Vec_Int_t * vPart;
540  int i, nIter;
541  abctime timeSim, clk2, clk3, clk = Abc_Clock();
542  abctime TimeToStop = TimeLimit ? TimeLimit * CLOCKS_PER_SEC + Abc_Clock() : 0;
543  if ( Aig_ManNodeNum(pAig) == 0 )
544  {
545  if ( pnIter ) *pnIter = 0;
546  // Ntl_ManFinalize() requires the following to satisfy an assertion.
548  return Aig_ManDupOrdered(pAig);
549  }
550  assert( Aig_ManRegNum(pAig) > 0 );
551 
552  // simulate the AIG
553 clk2 = Abc_Clock();
554 if ( fVerbose )
555 printf( "Simulating AIG with %d nodes for %d cycles ... ", Aig_ManNodeNum(pAig), nFramesP + 32 );
556  pSml = Fra_SmlSimulateSeq( pAig, nFramesP, 32, 1, 1 );
557 if ( fVerbose )
558 {
559 ABC_PRT( "Time", Abc_Clock() - clk2 );
560 }
561 timeSim = Abc_Clock() - clk2;
562 
563  // check if simulation discovered non-constant-0 POs
564  if ( fProve && pSml->fNonConstOut )
565  {
566  pAig->pSeqModel = Fra_SmlGetCounterExample( pSml );
567  Fra_SmlStop( pSml );
568  return NULL;
569  }
570 
571  // start the manager
572  p = Lcr_ManAlloc( pAig );
573  p->nFramesP = nFramesP;
574  p->fVerbose = fVerbose;
575  p->timeSim += timeSim;
576 
577  pTemp = Fra_LcrAigPrepare( pAig );
578  pTemp->pBmc = (Fra_Bmc_t *)p;
579  pTemp->pSml = pSml;
580 
581  // get preliminary info about equivalence classes
582  pTemp->pCla = p->pCla = Fra_ClassesStart( p->pAig );
583  Fra_ClassesPrepare( p->pCla, 1, 0 );
584  p->pCla->pFuncNodeIsConst = Fra_LcrNodeIsConst;
585  p->pCla->pFuncNodesAreEqual = Fra_LcrNodesAreEqual;
586  Fra_SmlStop( pTemp->pSml );
587 
588  // partition the AIG for latch correspondence computation
589 clk2 = Abc_Clock();
590 if ( fVerbose )
591 printf( "Partitioning AIG ... " );
592  pAigPart = Fra_LcrDeriveAigForPartitioning( p );
593  p->vParts = (Vec_Ptr_t *)Aig_ManPartitionSmart( pAigPart, nPartSize, 0, NULL );
594  Fra_LcrRemapPartitions( p->vParts, p->pCla, p->pInToOutPart, p->pInToOutNum );
595  Aig_ManStop( pAigPart );
596 if ( fVerbose )
597 {
598 ABC_PRT( "Time", Abc_Clock() - clk2 );
599 p->timePart += Abc_Clock() - clk2;
600 }
601 
602  // get the initial stats
603  p->nLitsBeg = Fra_ClassesCountLits( p->pCla );
604  p->nNodesBeg = Aig_ManNodeNum(p->pAig);
605  p->nRegsBeg = Aig_ManRegNum(p->pAig);
606 
607  // perforn interative reduction of the partitions
608  p->fRefining = 1;
609  for ( nIter = 0; p->fRefining; nIter++ )
610  {
611  p->fRefining = 0;
612  clk3 = Abc_Clock();
613  // derive AIGs for each partition
614  Fra_ClassNodesMark( p );
615  Vec_PtrClear( p->vFraigs );
616  Vec_PtrForEachEntry( Vec_Int_t *, p->vParts, vPart, i )
617  {
618  if ( TimeLimit != 0.0 && Abc_Clock() > TimeToStop )
619  {
620  Vec_PtrForEachEntry( Aig_Man_t *, p->vFraigs, pAigPart, i )
621  Aig_ManStop( pAigPart );
622  Aig_ManCleanMarkA( pAig );
623  Aig_ManCleanMarkB( pAig );
624  printf( "Fra_FraigLatchCorrespondence(): Runtime limit exceeded.\n" );
625  goto finish;
626  }
627 clk2 = Abc_Clock();
628  pAigPart = Fra_LcrCreatePart( p, vPart );
629 p->timeTrav += Abc_Clock() - clk2;
630 clk2 = Abc_Clock();
631  pAigTemp = Fra_FraigEquivence( pAigPart, nConfMax, 0 );
632 p->timeFraig += Abc_Clock() - clk2;
633  Vec_PtrPush( p->vFraigs, pAigTemp );
634 /*
635  {
636  char Name[1000];
637  sprintf( Name, "part%04d.blif", i );
638  Aig_ManDumpBlif( pAigPart, Name, NULL, NULL );
639  }
640 printf( "Finished part %4d (out of %4d). ", i, Vec_PtrSize(p->vParts) );
641 ABC_PRT( "Time", Abc_Clock() - clk3 );
642 */
643 
644  Aig_ManStop( pAigPart );
645  }
647  // report the intermediate results
648  if ( fVerbose )
649  {
650  printf( "%3d : Const = %6d. Class = %6d. L = %6d. Part = %3d. ",
651  nIter, Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses),
652  Fra_ClassesCountLits(p->pCla), Vec_PtrSize(p->vParts) );
653  ABC_PRT( "T", Abc_Clock() - clk3 );
654  }
655  // refine the classes
656  Fra_LcrAigPrepareTwo( p->pAig, pTemp );
657  if ( Fra_ClassesRefine( p->pCla ) )
658  p->fRefining = 1;
659  if ( Fra_ClassesRefine1( p->pCla, 0, NULL ) )
660  p->fRefining = 1;
661  // clean the fraigs
662  Vec_PtrForEachEntry( Aig_Man_t *, p->vFraigs, pAigPart, i )
663  Aig_ManStop( pAigPart );
664 
665  // repartition if needed
666  if ( 1 )
667  {
668 clk2 = Abc_Clock();
669  Vec_VecFree( (Vec_Vec_t *)p->vParts );
670  pAigPart = Fra_LcrDeriveAigForPartitioning( p );
671  p->vParts = (Vec_Ptr_t *)Aig_ManPartitionSmart( pAigPart, nPartSize, 0, NULL );
672  Fra_LcrRemapPartitions( p->vParts, p->pCla, p->pInToOutPart, p->pInToOutNum );
673  Aig_ManStop( pAigPart );
674 p->timePart += Abc_Clock() - clk2;
675  }
676  }
677  p->nIters = nIter;
678 
679  // move the classes into representatives and reduce AIG
680 clk2 = Abc_Clock();
681 // Fra_ClassesPrint( p->pCla, 1 );
682  if ( fReprSelect )
683  Fra_ClassesSelectRepr( p->pCla );
684  Fra_ClassesCopyReprs( p->pCla, NULL );
685  pAigNew = Aig_ManDupRepr( p->pAig, 0 );
686  Aig_ManSeqCleanup( pAigNew );
687 // Aig_ManCountMergeRegs( pAigNew );
688 p->timeUpdate += Abc_Clock() - clk2;
689 p->timeTotal = Abc_Clock() - clk;
690  // get the final stats
691  p->nLitsEnd = Fra_ClassesCountLits( p->pCla );
692  p->nNodesEnd = Aig_ManNodeNum(pAigNew);
693  p->nRegsEnd = Aig_ManRegNum(pAigNew);
694 finish:
695  ABC_FREE( pTemp );
696  Lcr_ManFree( p );
697  if ( pnIter ) *pnIter = nIter;
698  return pAigNew;
699 }
typedefABC_NAMESPACE_IMPL_START struct Fra_Lcr_t_ Fra_Lcr_t
DECLARATIONS ///.
Definition: fraLcr.c:30
int fNonConstOut
Definition: fra.h:179
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition: fraClass.c:527
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * Fra_LcrCreatePart(Fra_Lcr_t *p, Vec_Int_t *vPart)
Definition: fraLcr.c:429
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
Vec_Ptr_t * Aig_ManPartitionSmart(Aig_Man_t *p, int nPartSizeLimit, int fVerbose, Vec_Ptr_t **pvPartSupps)
Definition: aigPart.c:686
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
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Definition: fraSim.c:1021
int Aig_ManSeqCleanup(Aig_Man_t *p)
Definition: aigScl.c:158
Fra_Cla_t * Fra_ClassesStart(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: fraClass.c:60
Fra_Cla_t * pCla
Definition: fra.h:198
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
Fra_Sml_t * pSml
Definition: fra.h:200
Aig_Man_t * Aig_ManDupOrdered(Aig_Man_t *p)
Definition: aigDup.c:277
void Aig_ManCleanMarkB(Aig_Man_t *p)
Definition: aigUtil.c:167
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Fra_LcrAigPrepareTwo(Aig_Man_t *pAig, Fra_Man_t *p)
Definition: fraLcr.c:182
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
DECLARATIONS ///.
Definition: fraBmc.c:31
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Fra_Bmc_t * pBmc
Definition: fra.h:202
void Fra_ClassNodesMark(Fra_Lcr_t *p)
Definition: fraLcr.c:465
void Fra_ClassesPrepare(Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
Definition: fraClass.c:276
Abc_Cex_t * Fra_SmlGetCounterExample(Fra_Sml_t *p)
Definition: fraSim.c:1043
void Lcr_ManFree(Fra_Lcr_t *p)
Definition: fraLcr.c:131
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition: aigRepr.c:45
int Fra_LcrNodeIsConst(Aig_Obj_t *pObj)
Definition: fraLcr.c:239
Fra_Man_t * Fra_LcrAigPrepare(Aig_Man_t *pAig)
Definition: fraLcr.c:158
if(last==0)
Definition: sparse_int.h:34
Aig_Man_t * Aig_ManDupRepr(Aig_Man_t *p, int fOrdered)
Definition: aigRepr.c:267
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int Fra_LcrNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: fraLcr.c:201
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fra_ClassesSelectRepr(Fra_Cla_t *p)
Definition: fraClass.c:706
Aig_Man_t * Fra_LcrDeriveAigForPartitioning(Fra_Lcr_t *pLcr)
Definition: fraLcr.c:296
void Fra_ClassNodesUnmark(Fra_Lcr_t *p)
Definition: fraLcr.c:498
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Fra_ClassesCopyReprs(Fra_Cla_t *p, Vec_Ptr_t *vFailed)
Definition: fraClass.c:114
void Aig_ManCleanMarkA(Aig_Man_t *p)
Definition: aigUtil.c:148
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
Fra_Lcr_t * Lcr_ManAlloc(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: fraLcr.c:80
Aig_Man_t * Fra_FraigLatchCorrespondence(Aig_Man_t *pAig, int nFramesP, int nConfMax, int fProve, int fVerbose, int *pnIter, float TimeLimit)
Definition: fraLcr.c:531
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
void Fra_LcrRemapPartitions(Vec_Ptr_t *vParts, Fra_Cla_t *pCla, int *pInToOutPart, int *pInToOutNum)
Definition: fraLcr.c:347
int Fra_FraigMiterAssertedOutput ( Aig_Man_t p)

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

Synopsis [Reports the status of the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file fraCore.c.

126 {
127  Aig_Obj_t * pObj, * pChild;
128  int i;
129  Aig_ManForEachPoSeq( p, pObj, i )
130  {
131  pChild = Aig_ObjChild0(pObj);
132  // check if the output is constant 0
133  if ( pChild == Aig_ManConst0(p) )
134  continue;
135  // check if the output is constant 1
136  if ( pChild == Aig_ManConst1(p) )
137  return i;
138  // check if the output can be not constant 0
139  if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) )
140  return i;
141  }
142  return -1;
143 }
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 Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition: aig.h:444
int Fra_FraigMiterStatus ( Aig_Man_t p)

DECLARATIONS ///.

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

FileName [fraCore.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraCore.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

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

Synopsis [Reports the status of the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file fraCore.c.

63 {
64  Aig_Obj_t * pObj, * pChild;
65  int i, CountConst0 = 0, CountNonConst0 = 0, CountUndecided = 0;
66  if ( p->pData )
67  return 0;
68  Aig_ManForEachPoSeq( p, pObj, i )
69  {
70  pChild = Aig_ObjChild0(pObj);
71  // check if the output is constant 0
72  if ( pChild == Aig_ManConst0(p) )
73  {
74  CountConst0++;
75  continue;
76  }
77  // check if the output is constant 1
78  if ( pChild == Aig_ManConst1(p) )
79  {
80  CountNonConst0++;
81  continue;
82  }
83  // check if the output is a primary input
84  if ( Aig_ObjIsCi(Aig_Regular(pChild)) && Aig_ObjCioId(Aig_Regular(pChild)) < p->nTruePis )
85  {
86  CountNonConst0++;
87  continue;
88  }
89  // check if the output can be not constant 0
90  if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) )
91  {
92  CountNonConst0++;
93  continue;
94  }
95  CountUndecided++;
96  }
97 /*
98  if ( p->pParams->fVerbose )
99  {
100  printf( "Miter has %d outputs. ", Aig_ManCoNum(p->pManAig) );
101  printf( "Const0 = %d. ", CountConst0 );
102  printf( "NonConst0 = %d. ", CountNonConst0 );
103  printf( "Undecided = %d. ", CountUndecided );
104  printf( "\n" );
105  }
106 */
107  if ( CountNonConst0 )
108  return 0;
109  if ( CountUndecided )
110  return -1;
111  return 1;
112 }
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 Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition: aig.h:444
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
static int Aig_ObjCioId(Aig_Obj_t *pObj)
Definition: aig.h:285
Aig_Man_t* Fra_FraigPerform ( Aig_Man_t pManAig,
Fra_Par_t pPars 
)

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

Synopsis [Performs fraiging of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 375 of file fraCore.c.

376 {
377  Fra_Man_t * p;
378  Aig_Man_t * pManAigNew;
379  abctime clk;
380  if ( Aig_ManNodeNum(pManAig) == 0 )
381  return Aig_ManDupOrdered(pManAig);
382 clk = Abc_Clock();
383  p = Fra_ManStart( pManAig, pPars );
384  p->pManFraig = Fra_ManPrepareComb( p );
385  p->pSml = Fra_SmlStart( pManAig, 0, 1, pPars->nSimWords );
386  Fra_SmlSimulate( p, 0 );
387 // if ( p->pPars->fChoicing )
388 // Aig_ManReprStart( p->pManFraig, Aig_ManObjNumMax(p->pManAig) );
389  // collect initial states
391  p->nNodesBeg = Aig_ManNodeNum(pManAig);
392  p->nRegsBeg = Aig_ManRegNum(pManAig);
393  // perform fraig sweep
394 if ( p->pPars->fVerbose )
395 Fra_ClassesPrint( p->pCla, 1 );
396  Fra_FraigSweep( p );
397  // call back the procedure to check implications
398  if ( pManAig->pImpFunc )
399  pManAig->pImpFunc( p, pManAig->pImpData );
400  // no need to filter one-hot clauses because they satisfy base case by construction
401  // finalize the fraiged manager
402  Fra_ManFinalizeComb( p );
403  if ( p->pPars->fChoicing )
404  {
405 abctime clk2 = Abc_Clock();
407  pManAigNew = Aig_ManDupRepr( p->pManAig, 1 );
408  Aig_ManReprStart( pManAigNew, Aig_ManObjNumMax(pManAigNew) );
409  Aig_ManTransferRepr( pManAigNew, p->pManAig );
410  Aig_ManMarkValidChoices( pManAigNew );
411  Aig_ManStop( p->pManFraig );
412  p->pManFraig = NULL;
413 p->timeTrav += Abc_Clock() - clk2;
414  }
415  else
416  {
419  pManAigNew = p->pManFraig;
420  p->pManFraig = NULL;
421  }
422 p->timeTotal = Abc_Clock() - clk;
423  // collect final stats
425  p->nNodesEnd = Aig_ManNodeNum(pManAigNew);
426  p->nRegsEnd = Aig_ManRegNum(pManAigNew);
427  Fra_ManStop( p );
428  return pManAigNew;
429 }
Aig_Man_t * pManAig
Definition: fra.h:191
void Fra_ManFinalizeComb(Fra_Man_t *p)
Definition: fraMan.c:217
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
Fra_Man_t * Fra_ManStart(Aig_Man_t *pManAig, Fra_Par_t *pParams)
Definition: fraMan.c:104
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Fra_Cla_t * pCla
Definition: fra.h:198
int nRegsBeg
Definition: fra.h:226
Fra_Par_t * pPars
Definition: fra.h:189
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
Fra_Sml_t * pSml
Definition: fra.h:200
Aig_Man_t * Aig_ManDupOrdered(Aig_Man_t *p)
Definition: aigDup.c:277
abctime timeTrav
Definition: fra.h:241
int nLitsEnd
Definition: fra.h:223
int nRegsEnd
Definition: fra.h:227
int nNodesBeg
Definition: fra.h:224
void Fra_FraigSweep(Fra_Man_t *p)
Definition: fraCore.c:310
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
abctime timeTotal
Definition: fra.h:248
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: fraSim.c:813
Aig_Man_t * pManFraig
Definition: fra.h:192
Vec_Ptr_t * vTimeouts
Definition: fra.h:218
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition: aigRepr.c:45
Aig_Man_t * Fra_ManPrepareComb(Fra_Man_t *p)
Definition: fraMan.c:176
void Fra_ClassesPrint(Fra_Cla_t *p, int fVeryVerbose)
Definition: fraClass.c:236
void Aig_ManMarkValidChoices(Aig_Man_t *p)
Definition: aigRepr.c:481
Aig_Man_t * Aig_ManDupRepr(Aig_Man_t *p, int fOrdered)
Definition: aigRepr.c:267
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int nNodesEnd
Definition: fra.h:225
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fra_SmlSimulate(Fra_Man_t *p, int fInit)
Definition: fraSim.c:738
void Fra_ManStop(Fra_Man_t *p)
Definition: fraMan.c:240
void Fra_ClassesCopyReprs(Fra_Cla_t *p, Vec_Ptr_t *vFailed)
Definition: fraClass.c:114
void Aig_ManTransferRepr(Aig_Man_t *pNew, Aig_Man_t *p)
Definition: aigRepr.c:211
ABC_INT64_T abctime
Definition: abc_global.h:278
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
int nLitsBeg
Definition: fra.h:222
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 ///.

FUNCTION DECLARATIONS ///

ITERATORS ///.

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

FileName [fraCec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [CEC engined based on fraiging.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraCec.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file fraCec.c.

48 {
49  if ( fNewSolver )
50  {
51  extern void * Cnf_DataWriteIntoSolver2( Cnf_Dat_t * p, int nFrames, int fInit );
52  extern int Cnf_DataWriteOrClause2( void * pSat, Cnf_Dat_t * pCnf );
53 
54  sat_solver2 * pSat;
55  Cnf_Dat_t * pCnf;
56  int status, RetValue;
57  abctime clk = Abc_Clock();
58  Vec_Int_t * vCiIds;
59 
60  assert( Aig_ManRegNum(pMan) == 0 );
61  pMan->pData = NULL;
62 
63  // derive CNF
64  pCnf = Cnf_Derive( pMan, Aig_ManCoNum(pMan) );
65  // pCnf = Cnf_DeriveSimple( pMan, Aig_ManCoNum(pMan) );
66 
67  if ( fFlipBits )
68  Cnf_DataTranformPolarity( pCnf, 0 );
69 
70  if ( fVerbose )
71  {
72  printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
73  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
74  }
75 
76  // convert into SAT solver
77  pSat = (sat_solver2 *)Cnf_DataWriteIntoSolver2( pCnf, 1, 0 );
78  if ( pSat == NULL )
79  {
80  Cnf_DataFree( pCnf );
81  return 1;
82  }
83 
84  if ( fAndOuts )
85  {
86  // assert each output independently
87  if ( !Cnf_DataWriteAndClauses( pSat, pCnf ) )
88  {
89  sat_solver2_delete( pSat );
90  Cnf_DataFree( pCnf );
91  return 1;
92  }
93  }
94  else
95  {
96  // add the OR clause for the outputs
97  if ( !Cnf_DataWriteOrClause2( pSat, pCnf ) )
98  {
99  sat_solver2_delete( pSat );
100  Cnf_DataFree( pCnf );
101  return 1;
102  }
103  }
104  vCiIds = Cnf_DataCollectPiSatNums( pCnf, pMan );
105  Cnf_DataFree( pCnf );
106 
107 
108  printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver2_nvars(pSat), sat_solver2_nclauses(pSat) );
109  ABC_PRT( "Time", Abc_Clock() - clk );
110 
111  // simplify the problem
112  clk = Abc_Clock();
113  status = sat_solver2_simplify(pSat);
114 // printf( "Simplified the problem to %d variables and %d clauses. ", sat_solver2_nvars(pSat), sat_solver2_nclauses(pSat) );
115 // ABC_PRT( "Time", Abc_Clock() - clk );
116  if ( status == 0 )
117  {
118  Vec_IntFree( vCiIds );
119  sat_solver2_delete( pSat );
120  // printf( "The problem is UNSATISFIABLE after simplification.\n" );
121  return 1;
122  }
123 
124  // solve the miter
125  clk = Abc_Clock();
126  if ( fVerbose )
127  pSat->verbosity = 1;
128  status = sat_solver2_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, (ABC_INT64_T)0, (ABC_INT64_T)0 );
129  if ( status == l_Undef )
130  {
131  // printf( "The problem timed out.\n" );
132  RetValue = -1;
133  }
134  else if ( status == l_True )
135  {
136  // printf( "The problem is SATISFIABLE.\n" );
137  RetValue = 0;
138  }
139  else if ( status == l_False )
140  {
141  // printf( "The problem is UNSATISFIABLE.\n" );
142  RetValue = 1;
143  }
144  else
145  assert( 0 );
146 
147  // Abc_Print( 1, "The number of conflicts = %6d. ", (int)pSat->stats.conflicts );
148  // Abc_PrintTime( 1, "Solving time", Abc_Clock() - clk );
149 
150  // if the problem is SAT, get the counterexample
151  if ( status == l_True )
152  {
153  pMan->pData = Sat_Solver2GetModel( pSat, vCiIds->pArray, vCiIds->nSize );
154  }
155  // free the sat_solver2
156  if ( fVerbose )
157  Sat_Solver2PrintStats( stdout, pSat );
158  //sat_solver2_store_write( pSat, "trace.cnf" );
159  //sat_solver2_store_free( pSat );
160  sat_solver2_delete( pSat );
161  Vec_IntFree( vCiIds );
162  return RetValue;
163  }
164  else
165  {
166  sat_solver * pSat;
167  Cnf_Dat_t * pCnf;
168  int status, RetValue;
169  abctime clk = Abc_Clock();
170  Vec_Int_t * vCiIds;
171 
172  assert( Aig_ManRegNum(pMan) == 0 );
173  pMan->pData = NULL;
174 
175  // derive CNF
176  pCnf = Cnf_Derive( pMan, Aig_ManCoNum(pMan) );
177  // pCnf = Cnf_DeriveSimple( pMan, Aig_ManCoNum(pMan) );
178 
179  if ( fFlipBits )
180  Cnf_DataTranformPolarity( pCnf, 0 );
181 
182  if ( fVerbose )
183  {
184  printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
185  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
186  }
187 
188  // convert into SAT solver
189  pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
190  if ( pSat == NULL )
191  {
192  Cnf_DataFree( pCnf );
193  return 1;
194  }
195 
196  if ( nLearnedStart )
197  pSat->nLearntStart = nLearnedStart;
198  if ( nLearnedDelta )
199  pSat->nLearntDelta = nLearnedDelta;
200  if ( nLearnedPerce )
201  pSat->nLearntRatio = nLearnedPerce;
202  if ( fVerbose )
203  pSat->fVerbose = fVerbose;
204 
205  if ( fAndOuts )
206  {
207  // assert each output independently
208  if ( !Cnf_DataWriteAndClauses( pSat, pCnf ) )
209  {
210  sat_solver_delete( pSat );
211  Cnf_DataFree( pCnf );
212  return 1;
213  }
214  }
215  else
216  {
217  // add the OR clause for the outputs
218  if ( !Cnf_DataWriteOrClause( pSat, pCnf ) )
219  {
220  sat_solver_delete( pSat );
221  Cnf_DataFree( pCnf );
222  return 1;
223  }
224  }
225  vCiIds = Cnf_DataCollectPiSatNums( pCnf, pMan );
226  Cnf_DataFree( pCnf );
227 
228 
229  // printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
230  // ABC_PRT( "Time", Abc_Clock() - clk );
231 
232  // simplify the problem
233  clk = Abc_Clock();
234  status = sat_solver_simplify(pSat);
235  // printf( "Simplified the problem to %d variables and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
236  // ABC_PRT( "Time", Abc_Clock() - clk );
237  if ( status == 0 )
238  {
239  Vec_IntFree( vCiIds );
240  sat_solver_delete( pSat );
241  // printf( "The problem is UNSATISFIABLE after simplification.\n" );
242  return 1;
243  }
244 
245  // solve the miter
246  clk = Abc_Clock();
247 // if ( fVerbose )
248 // pSat->verbosity = 1;
249  status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, (ABC_INT64_T)0, (ABC_INT64_T)0 );
250  if ( status == l_Undef )
251  {
252  // printf( "The problem timed out.\n" );
253  RetValue = -1;
254  }
255  else if ( status == l_True )
256  {
257  // printf( "The problem is SATISFIABLE.\n" );
258  RetValue = 0;
259  }
260  else if ( status == l_False )
261  {
262  // printf( "The problem is UNSATISFIABLE.\n" );
263  RetValue = 1;
264  }
265  else
266  assert( 0 );
267 
268  // Abc_Print( 1, "The number of conflicts = %6d. ", (int)pSat->stats.conflicts );
269  // Abc_PrintTime( 1, "Solving time", Abc_Clock() - clk );
270 
271  // if the problem is SAT, get the counterexample
272  if ( status == l_True )
273  {
274  pMan->pData = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
275  }
276  // free the sat_solver
277  if ( fVerbose )
278  Sat_SolverPrintStats( stdout, pSat );
279  //sat_solver_store_write( pSat, "trace.cnf" );
280  //sat_solver_store_free( pSat );
281  sat_solver_delete( pSat );
282  Vec_IntFree( vCiIds );
283  return RetValue;
284  }
285 }
static int sat_solver2_nclauses(sat_solver2 *s)
Definition: satSolver2.h:195
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition: cnfCore.c:165
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
#define l_Undef
Definition: SolverTypes.h:86
int Cnf_DataWriteOrClause(void *pSat, Cnf_Dat_t *pCnf)
Definition: cnfMan.c:571
int nClauses
Definition: cnf.h:61
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
void sat_solver2_delete(sat_solver2 *s)
Definition: satSolver2.c:1225
int nVars
Definition: cnf.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
void Cnf_DataTranformPolarity(Cnf_Dat_t *pCnf, int fTransformPos)
Definition: cnfMan.c:652
#define l_True
Definition: SolverTypes.h:84
void Sat_Solver2PrintStats(FILE *pFile, sat_solver2 *p)
Definition: satUtil.c:210
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: cnf.h:56
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
int nLearntDelta
Definition: satSolver.h:159
void * Cnf_DataWriteIntoSolver2(Cnf_Dat_t *p, int nFrames, int fInit)
Definition: cnfMan.c:479
int sat_solver2_simplify(sat_solver2 *s)
Definition: satSolver2.c:996
Vec_Int_t * Cnf_DataCollectPiSatNums(Cnf_Dat_t *pCnf, Aig_Man_t *p)
Definition: cnfMan.c:104
int Cnf_DataWriteAndClauses(void *p, Cnf_Dat_t *pCnf)
Definition: cnfMan.c:627
int nLearntRatio
Definition: satSolver.h:160
int Cnf_DataWriteOrClause2(void *p, Cnf_Dat_t *pCnf)
Definition: cnfMan.c:599
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
int nLearntStart
Definition: satSolver.h:158
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition: cnfMan.c:463
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static int sat_solver2_nvars(sat_solver2 *s)
Definition: satSolver2.h:190
#define l_False
Definition: SolverTypes.h:85
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
int sat_solver2_solve(sat_solver2 *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver2.c:1835
int * Sat_Solver2GetModel(sat_solver2 *p, int *pVars, int nVars)
Definition: satUtil.c:287
#define assert(ex)
Definition: util_old.h:213
void Sat_SolverPrintStats(FILE *pFile, sat_solver *p)
Definition: satUtil.c:188
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
int nLiterals
Definition: cnf.h:60
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
Definition: satUtil.c:266
int Fra_FraigSec ( Aig_Man_t p,
Fra_Sec_t pParSec,
Aig_Man_t **  ppResult 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file fraSec.c.

96 {
97  Ssw_Pars_t Pars2, * pPars2 = &Pars2;
98  Fra_Ssw_t Pars, * pPars = &Pars;
99  Fra_Sml_t * pSml;
100  Aig_Man_t * pNew, * pTemp;
101  int nFrames, RetValue, nIter;
102  abctime clk, clkTotal = Abc_Clock();
103  int TimeOut = 0;
104  int fLatchCorr = 0;
105  float TimeLeft = 0.0;
106  pParSec->nSMnumber = -1;
107 
108  // try the miter before solving
109  pNew = Aig_ManDupSimple( p );
110  RetValue = Fra_FraigMiterStatus( pNew );
111  if ( RetValue >= 0 )
112  goto finish;
113 
114  // prepare parameters
115  memset( pPars, 0, sizeof(Fra_Ssw_t) );
116  pPars->fLatchCorr = fLatchCorr;
117  pPars->fVerbose = pParSec->fVeryVerbose;
118  if ( pParSec->fVerbose )
119  {
120  printf( "Original miter: Latches = %5d. Nodes = %6d.\n",
121  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
122  }
123 //Aig_ManDumpBlif( pNew, "after.blif", NULL, NULL );
124 
125  // perform sequential cleanup
126 clk = Abc_Clock();
127  if ( pNew->nRegs )
128  pNew = Aig_ManReduceLaches( pNew, 0 );
129  if ( pNew->nRegs )
130  pNew = Aig_ManConstReduce( pNew, 0, -1, -1, 0, 0 );
131  if ( pParSec->fVerbose )
132  {
133  printf( "Sequential cleanup: Latches = %5d. Nodes = %6d. ",
134  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
135 ABC_PRT( "Time", Abc_Clock() - clk );
136  }
137  RetValue = Fra_FraigMiterStatus( pNew );
138  if ( RetValue >= 0 )
139  goto finish;
140 
141  // perform phase abstraction
142 clk = Abc_Clock();
143  if ( pParSec->fPhaseAbstract )
144  {
145  extern Aig_Man_t * Saig_ManPhaseAbstractAuto( Aig_Man_t * p, int fVerbose );
146  pNew->nTruePis = Aig_ManCiNum(pNew) - Aig_ManRegNum(pNew);
147  pNew->nTruePos = Aig_ManCoNum(pNew) - Aig_ManRegNum(pNew);
148  pNew = Saig_ManPhaseAbstractAuto( pTemp = pNew, 0 );
149  Aig_ManStop( pTemp );
150  if ( pParSec->fVerbose )
151  {
152  printf( "Phase abstraction: Latches = %5d. Nodes = %6d. ",
153  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
154 ABC_PRT( "Time", Abc_Clock() - clk );
155  }
156  }
157 
158  // perform forward retiming
159  if ( pParSec->fRetimeFirst && pNew->nRegs )
160  {
161 clk = Abc_Clock();
162 // pNew = Rtm_ManRetime( pTemp = pNew, 1, 1000, 0 );
163  pNew = Saig_ManRetimeForward( pTemp = pNew, 100, 0 );
164  Aig_ManStop( pTemp );
165  if ( pParSec->fVerbose )
166  {
167  printf( "Forward retiming: Latches = %5d. Nodes = %6d. ",
168  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
169 ABC_PRT( "Time", Abc_Clock() - clk );
170  }
171  }
172 
173  // run latch correspondence
174 clk = Abc_Clock();
175  if ( pNew->nRegs )
176  {
177  pNew = Aig_ManDupOrdered( pTemp = pNew );
178 // pNew = Aig_ManDupDfs( pTemp = pNew );
179  Aig_ManStop( pTemp );
180 /*
181  if ( RetValue == -1 && pParSec->TimeLimit )
182  {
183  TimeLeft = (float)pParSec->TimeLimit - ((float)(Abc_Clock()-clkTotal)/(float)(CLOCKS_PER_SEC));
184  TimeLeft = Abc_MaxInt( TimeLeft, 0.0 );
185  if ( TimeLeft == 0.0 )
186  {
187  if ( !pParSec->fSilent )
188  printf( "Runtime limit exceeded.\n" );
189  RetValue = -1;
190  TimeOut = 1;
191  goto finish;
192  }
193  }
194 */
195 
196 // pNew = Fra_FraigLatchCorrespondence( pTemp = pNew, 0, 1000, 1, pParSec->fVeryVerbose, &nIter, TimeLeft );
197 //Aig_ManDumpBlif( pNew, "ex.blif", NULL, NULL );
199  pNew = Ssw_LatchCorrespondence( pTemp = pNew, pPars2 );
200  nIter = pPars2->nIters;
201 
202  // prepare parameters for scorr
203  Ssw_ManSetDefaultParams( pPars2 );
204 
205  if ( pTemp->pSeqModel )
206  {
207  if ( !Saig_ManVerifyCex( pTemp, pTemp->pSeqModel ) )
208  printf( "Fra_FraigSec(): Counter-example verification has FAILED.\n" );
209  if ( Saig_ManPiNum(p) != Saig_ManPiNum(pTemp) )
210  printf( "The counter-example is invalid because of phase abstraction.\n" );
211  else
212  {
213  ABC_FREE( p->pSeqModel );
214  p->pSeqModel = Abc_CexDup( pTemp->pSeqModel, Aig_ManRegNum(p) );
215  ABC_FREE( pTemp->pSeqModel );
216  }
217  }
218  if ( pNew == NULL )
219  {
220  if ( p->pSeqModel )
221  {
222  RetValue = 0;
223  if ( !pParSec->fSilent )
224  {
225  printf( "Networks are NOT EQUIVALENT after simulation. " );
226 ABC_PRT( "Time", Abc_Clock() - clkTotal );
227  }
228  if ( pParSec->fReportSolution && !pParSec->fRecursive )
229  {
230  printf( "SOLUTION: FAIL " );
231 ABC_PRT( "Time", Abc_Clock() - clkTotal );
232  }
233  Aig_ManStop( pTemp );
234  return RetValue;
235  }
236  pNew = pTemp;
237  RetValue = -1;
238  TimeOut = 1;
239  goto finish;
240  }
241  Aig_ManStop( pTemp );
242 
243  if ( pParSec->fVerbose )
244  {
245  printf( "Latch-corr (I=%3d): Latches = %5d. Nodes = %6d. ",
246  nIter, Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
247 ABC_PRT( "Time", Abc_Clock() - clk );
248  }
249  }
250 /*
251  if ( RetValue == -1 && pParSec->TimeLimit )
252  {
253  TimeLeft = (float)pParSec->TimeLimit - ((float)(Abc_Clock()-clkTotal)/(float)(CLOCKS_PER_SEC));
254  TimeLeft = Abc_MaxInt( TimeLeft, 0.0 );
255  if ( TimeLeft == 0.0 )
256  {
257  if ( !pParSec->fSilent )
258  printf( "Runtime limit exceeded.\n" );
259  RetValue = -1;
260  TimeOut = 1;
261  goto finish;
262  }
263  }
264 */
265  // perform fraiging
266  if ( pParSec->fFraiging )
267  {
268 clk = Abc_Clock();
269  pNew = Fra_FraigEquivence( pTemp = pNew, 100, 0 );
270  Aig_ManStop( pTemp );
271  if ( pParSec->fVerbose )
272  {
273  printf( "Fraiging: Latches = %5d. Nodes = %6d. ",
274  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
275 ABC_PRT( "Time", Abc_Clock() - clk );
276  }
277  }
278 
279  if ( pNew->nRegs == 0 )
280  RetValue = Fra_FraigCec( &pNew, 100000, 0 );
281 
282  RetValue = Fra_FraigMiterStatus( pNew );
283  if ( RetValue >= 0 )
284  goto finish;
285 /*
286  if ( RetValue == -1 && pParSec->TimeLimit )
287  {
288  TimeLeft = (float)pParSec->TimeLimit - ((float)(Abc_Clock()-clkTotal)/(float)(CLOCKS_PER_SEC));
289  TimeLeft = Abc_MaxInt( TimeLeft, 0.0 );
290  if ( TimeLeft == 0.0 )
291  {
292  if ( !pParSec->fSilent )
293  printf( "Runtime limit exceeded.\n" );
294  RetValue = -1;
295  TimeOut = 1;
296  goto finish;
297  }
298  }
299 */
300  // perform min-area retiming
301  if ( pParSec->fRetimeRegs && pNew->nRegs )
302  {
303 // extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
304 clk = Abc_Clock();
305  pNew->nTruePis = Aig_ManCiNum(pNew) - Aig_ManRegNum(pNew);
306  pNew->nTruePos = Aig_ManCoNum(pNew) - Aig_ManRegNum(pNew);
307 // pNew = Rtm_ManRetime( pTemp = pNew, 1, 1000, 0 );
308  pNew = Saig_ManRetimeMinArea( pTemp = pNew, 1000, 0, 0, 1, 0 );
309  Aig_ManStop( pTemp );
310  pNew = Aig_ManDupOrdered( pTemp = pNew );
311  Aig_ManStop( pTemp );
312  if ( pParSec->fVerbose )
313  {
314  printf( "Min-reg retiming: Latches = %5d. Nodes = %6d. ",
315  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
316 ABC_PRT( "Time", Abc_Clock() - clk );
317  }
318  }
319 
320  // perform seq sweeping while increasing the number of frames
321  RetValue = Fra_FraigMiterStatus( pNew );
322  if ( RetValue == -1 && pParSec->fInduction )
323  for ( nFrames = 1; nFrames <= pParSec->nFramesMax; nFrames *= 2 )
324  {
325 /*
326  if ( RetValue == -1 && pParSec->TimeLimit )
327  {
328  TimeLeft = (float)pParSec->TimeLimit - ((float)(Abc_Clock()-clkTotal)/(float)(CLOCKS_PER_SEC));
329  TimeLeft = Abc_MaxInt( TimeLeft, 0.0 );
330  if ( TimeLeft == 0.0 )
331  {
332  if ( !pParSec->fSilent )
333  printf( "Runtime limit exceeded.\n" );
334  RetValue = -1;
335  TimeOut = 1;
336  goto finish;
337  }
338  }
339 */
340 
341 clk = Abc_Clock();
342  pPars->nFramesK = nFrames;
343  pPars->TimeLimit = TimeLeft;
344  pPars->fSilent = pParSec->fSilent;
345 // pNew = Fra_FraigInduction( pTemp = pNew, pPars );
346 
347  pPars2->nFramesK = nFrames;
348  pPars2->nBTLimit = pParSec->nBTLimit;
349  pPars2->nBTLimitGlobal = pParSec->nBTLimitGlobal;
350 // pPars2->nBTLimit = 1000 * nFrames;
351 
352  if ( RetValue == -1 && pPars2->nConflicts > pPars2->nBTLimitGlobal )
353  {
354  if ( !pParSec->fSilent )
355  printf( "Global conflict limit (%d) exceeded.\n", pPars2->nBTLimitGlobal );
356  RetValue = -1;
357  TimeOut = 1;
358  goto finish;
359  }
360 
361  Aig_ManSetRegNum( pNew, pNew->nRegs );
362 // pNew = Ssw_SignalCorrespondence( pTemp = pNew, pPars2 );
363  if ( Aig_ManRegNum(pNew) > 0 )
364  pNew = Ssw_SignalCorrespondence( pTemp = pNew, pPars2 );
365  else
366  pNew = Aig_ManDupSimpleDfs( pTemp = pNew );
367 
368  if ( pNew == NULL )
369  {
370  pNew = pTemp;
371  RetValue = -1;
372  TimeOut = 1;
373  goto finish;
374  }
375 
376 // printf( "Total conflicts = %d.\n", pPars2->nConflicts );
377 
378  Aig_ManStop( pTemp );
379  RetValue = Fra_FraigMiterStatus( pNew );
380  if ( pParSec->fVerbose )
381  {
382  printf( "K-step (K=%2d,I=%3d): Latches = %5d. Nodes = %6d. ",
383  nFrames, pPars2->nIters, Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
384 ABC_PRT( "Time", Abc_Clock() - clk );
385  }
386  if ( RetValue != -1 )
387  break;
388 
389  // perform retiming
390 // if ( pParSec->fRetimeFirst && pNew->nRegs )
391  if ( pNew->nRegs )
392  {
393 // extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
394 clk = Abc_Clock();
395  pNew->nTruePis = Aig_ManCiNum(pNew) - Aig_ManRegNum(pNew);
396  pNew->nTruePos = Aig_ManCoNum(pNew) - Aig_ManRegNum(pNew);
397 // pNew = Rtm_ManRetime( pTemp = pNew, 1, 1000, 0 );
398  pNew = Saig_ManRetimeMinArea( pTemp = pNew, 1000, 0, 0, 1, 0 );
399  Aig_ManStop( pTemp );
400  pNew = Aig_ManDupOrdered( pTemp = pNew );
401  Aig_ManStop( pTemp );
402  if ( pParSec->fVerbose )
403  {
404  printf( "Min-reg retiming: Latches = %5d. Nodes = %6d. ",
405  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
406 ABC_PRT( "Time", Abc_Clock() - clk );
407  }
408  }
409 
410  if ( pNew->nRegs )
411  pNew = Aig_ManConstReduce( pNew, 0, -1, -1, 0, 0 );
412 
413  // perform rewriting
414 clk = Abc_Clock();
415  pNew = Aig_ManDupOrdered( pTemp = pNew );
416  Aig_ManStop( pTemp );
417 // pNew = Dar_ManRewriteDefault( pTemp = pNew );
418  pNew = Dar_ManCompress2( pTemp = pNew, 1, 0, 1, 0, 0 );
419  Aig_ManStop( pTemp );
420  if ( pParSec->fVerbose )
421  {
422  printf( "Rewriting: Latches = %5d. Nodes = %6d. ",
423  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
424 ABC_PRT( "Time", Abc_Clock() - clk );
425  }
426 
427  // perform sequential simulation
428  if ( pNew->nRegs )
429  {
430 clk = Abc_Clock();
431  pSml = Fra_SmlSimulateSeq( pNew, 0, 128 * nFrames, 1 + 16/(1+Aig_ManNodeNum(pNew)/1000), 1 );
432  if ( pParSec->fVerbose )
433  {
434  printf( "Seq simulation : Latches = %5d. Nodes = %6d. ",
435  Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
436 ABC_PRT( "Time", Abc_Clock() - clk );
437  }
438  if ( pSml->fNonConstOut )
439  {
440  pNew->pSeqModel = Fra_SmlGetCounterExample( pSml );
441  // transfer to the original manager
442  if ( Saig_ManPiNum(p) != Saig_ManPiNum(pNew) )
443  printf( "The counter-example is invalid because of phase abstraction.\n" );
444  else
445  {
446  ABC_FREE( p->pSeqModel );
447  p->pSeqModel = Abc_CexDup( pNew->pSeqModel, Aig_ManRegNum(p) );
448  ABC_FREE( pNew->pSeqModel );
449  }
450 
451  Fra_SmlStop( pSml );
452  Aig_ManStop( pNew );
453  RetValue = 0;
454  if ( !pParSec->fSilent )
455  {
456  printf( "Networks are NOT EQUIVALENT after simulation. " );
457 ABC_PRT( "Time", Abc_Clock() - clkTotal );
458  }
459  if ( pParSec->fReportSolution && !pParSec->fRecursive )
460  {
461  printf( "SOLUTION: FAIL " );
462 ABC_PRT( "Time", Abc_Clock() - clkTotal );
463  }
464  return RetValue;
465  }
466  Fra_SmlStop( pSml );
467  }
468  }
469 
470  // get the miter status
471  RetValue = Fra_FraigMiterStatus( pNew );
472 
473  // try interplation
474 clk = Abc_Clock();
475  Aig_ManSetRegNum( pNew, Aig_ManRegNum(pNew) );
476  if ( pParSec->fInterpolation && RetValue == -1 && Aig_ManRegNum(pNew) > 0 )
477  {
478  Inter_ManParams_t Pars, * pPars = &Pars;
479  int Depth;
480  ABC_FREE( pNew->pSeqModel );
481  Inter_ManSetDefaultParams( pPars );
482 // pPars->nBTLimit = 100;
483  pPars->nBTLimit = pParSec->nBTLimitInter;
484  pPars->fVerbose = pParSec->fVeryVerbose;
485  if ( Saig_ManPoNum(pNew) == 1 )
486  {
487  RetValue = Inter_ManPerformInterpolation( pNew, pPars, &Depth );
488  }
489  else if ( pParSec->fInterSeparate )
490  {
491  Abc_Cex_t * pCex = NULL;
492  Aig_Man_t * pTemp, * pAux;
493  Aig_Obj_t * pObjPo;
494  int i, Counter = 0;
495  Saig_ManForEachPo( pNew, pObjPo, i )
496  {
497  if ( Aig_ObjFanin0(pObjPo) == Aig_ManConst1(pNew) )
498  continue;
499  if ( pPars->fVerbose )
500  printf( "Solving output %2d (out of %2d):\n", i, Saig_ManPoNum(pNew) );
501  pTemp = Aig_ManDupOneOutput( pNew, i, 1 );
502  pTemp = Aig_ManScl( pAux = pTemp, 1, 1, 0, -1, -1, 0, 0 );
503  Aig_ManStop( pAux );
504  if ( Saig_ManRegNum(pTemp) > 0 )
505  {
506  RetValue = Inter_ManPerformInterpolation( pTemp, pPars, &Depth );
507  if ( pTemp->pSeqModel )
508  {
509  pCex = p->pSeqModel = Abc_CexDup( pTemp->pSeqModel, Aig_ManRegNum(p) );
510  pCex->iPo = i;
511  Aig_ManStop( pTemp );
512  break;
513  }
514  // if solved, remove the output
515  if ( RetValue == 1 )
516  {
517  Aig_ObjPatchFanin0( pNew, pObjPo, Aig_ManConst0(pNew) );
518  // printf( "Output %3d : Solved ", i );
519  }
520  else
521  {
522  Counter++;
523  // printf( "Output %3d : Undec ", i );
524  }
525  }
526  else
527  Counter++;
528 // Aig_ManPrintStats( pTemp );
529  Aig_ManStop( pTemp );
530  printf( "Solving output %3d (out of %3d) using interpolation.\r", i, Saig_ManPoNum(pNew) );
531  }
532  Aig_ManCleanup( pNew );
533  if ( pCex == NULL )
534  {
535  printf( "Interpolation left %d (out of %d) outputs unsolved \n", Counter, Saig_ManPoNum(pNew) );
536  if ( Counter )
537  RetValue = -1;
538  }
539  pNew = Aig_ManDupUnsolvedOutputs( pTemp = pNew, 1 );
540  Aig_ManStop( pTemp );
541  pNew = Aig_ManScl( pTemp = pNew, 1, 1, 0, -1, -1, 0, 0 );
542  Aig_ManStop( pTemp );
543  }
544  else
545  {
546  Aig_Man_t * pNewOrpos = Saig_ManDupOrpos( pNew );
547  RetValue = Inter_ManPerformInterpolation( pNewOrpos, pPars, &Depth );
548  if ( pNewOrpos->pSeqModel )
549  {
550  Abc_Cex_t * pCex;
551  pCex = pNew->pSeqModel = pNewOrpos->pSeqModel; pNewOrpos->pSeqModel = NULL;
552  pCex->iPo = Saig_ManFindFailedPoCex( pNew, pNew->pSeqModel );
553  }
554  Aig_ManStop( pNewOrpos );
555  }
556 
557  if ( pParSec->fVerbose )
558  {
559  if ( RetValue == 1 )
560  printf( "Property proved using interpolation. " );
561  else if ( RetValue == 0 )
562  printf( "Property DISPROVED in frame %d using interpolation. ", Depth );
563  else if ( RetValue == -1 )
564  printf( "Property UNDECIDED after interpolation. " );
565  else
566  assert( 0 );
567 ABC_PRT( "Time", Abc_Clock() - clk );
568  }
569  }
570 
571  // try reachability analysis
572  if ( pParSec->fReachability && RetValue == -1 && Aig_ManRegNum(pNew) > 0 && Aig_ManRegNum(pNew) < pParSec->nBddVarsMax )
573  {
574  Saig_ParBbr_t Pars, * pPars = &Pars;
575  Bbr_ManSetDefaultParams( pPars );
576  pPars->TimeLimit = 0;
577  pPars->nBddMax = pParSec->nBddMax;
578  pPars->nIterMax = pParSec->nBddIterMax;
579  pPars->fPartition = 1;
580  pPars->fReorder = 1;
581  pPars->fReorderImage = 1;
582  pPars->fVerbose = 0;
583  pPars->fSilent = pParSec->fSilent;
584  pNew->nTruePis = Aig_ManCiNum(pNew) - Aig_ManRegNum(pNew);
585  pNew->nTruePos = Aig_ManCoNum(pNew) - Aig_ManRegNum(pNew);
586  RetValue = Aig_ManVerifyUsingBdds( pNew, pPars );
587  }
588 
589  // try PDR
590  if ( pParSec->fUsePdr && RetValue == -1 && Aig_ManRegNum(pNew) > 0 )
591  {
592  Pdr_Par_t Pars, * pPars = &Pars;
593  Pdr_ManSetDefaultParams( pPars );
594  pPars->nTimeOut = pParSec->nPdrTimeout;
595  pPars->fVerbose = pParSec->fVerbose;
596  if ( pParSec->fVerbose )
597  printf( "Running property directed reachability...\n" );
598  RetValue = Pdr_ManSolve( pNew, pPars );
599  if ( pNew->pSeqModel )
600  pNew->pSeqModel->iPo = Saig_ManFindFailedPoCex( pNew, pNew->pSeqModel );
601  }
602 
603 finish:
604  // report the miter
605  if ( RetValue == 1 )
606  {
607  if ( !pParSec->fSilent )
608  {
609  printf( "Networks are equivalent. " );
610 ABC_PRT( "Time", Abc_Clock() - clkTotal );
611  }
612  if ( pParSec->fReportSolution && !pParSec->fRecursive )
613  {
614  printf( "SOLUTION: PASS " );
615 ABC_PRT( "Time", Abc_Clock() - clkTotal );
616  }
617  }
618  else if ( RetValue == 0 )
619  {
620  if ( pNew->pSeqModel == NULL )
621  {
622  int i;
623  // if the CEX is not derives, it is because tricial CEX should be assumed
624  pNew->pSeqModel = Abc_CexAlloc( Aig_ManRegNum(pNew), pNew->nTruePis, 1 );
625  // if the CEX does not work, we need to change PIs to 1 because
626  // the only way it can happen is when a PO is equal to a PI...
627  if ( Saig_ManFindFailedPoCex( pNew, pNew->pSeqModel ) == -1 )
628  for ( i = 0; i < pNew->nTruePis; i++ )
629  Abc_InfoSetBit( pNew->pSeqModel->pData, i );
630  }
631  if ( !pParSec->fSilent )
632  {
633  printf( "Networks are NOT EQUIVALENT. " );
634 ABC_PRT( "Time", Abc_Clock() - clkTotal );
635  }
636  if ( pParSec->fReportSolution && !pParSec->fRecursive )
637  {
638  printf( "SOLUTION: FAIL " );
639 ABC_PRT( "Time", Abc_Clock() - clkTotal );
640  }
641  }
642  else
643  {
644  ///////////////////////////////////
645  // save intermediate result
646  extern void Abc_FrameSetSave1( void * pAig );
648  ///////////////////////////////////
649  if ( !pParSec->fSilent )
650  {
651  printf( "Networks are UNDECIDED. " );
652 ABC_PRT( "Time", Abc_Clock() - clkTotal );
653  }
654  if ( pParSec->fReportSolution && !pParSec->fRecursive )
655  {
656  printf( "SOLUTION: UNDECIDED " );
657 ABC_PRT( "Time", Abc_Clock() - clkTotal );
658  }
659  if ( !TimeOut && !pParSec->fSilent )
660  {
661  static int Counter = 1;
662  char pFileName[1000];
663  pParSec->nSMnumber = Counter;
664  sprintf( pFileName, "sm%02d.aig", Counter++ );
665  Ioa_WriteAiger( pNew, pFileName, 0, 0 );
666  printf( "The unsolved reduced miter is written into file \"%s\".\n", pFileName );
667  }
668  }
669  if ( pNew->pSeqModel )
670  {
671  if ( Saig_ManPiNum(p) != Saig_ManPiNum(pNew) )
672  printf( "The counter-example is invalid because of phase abstraction.\n" );
673  else
674  {
675  ABC_FREE( p->pSeqModel );
676  p->pSeqModel = Abc_CexDup( pNew->pSeqModel, Aig_ManRegNum(p) );
677  ABC_FREE( pNew->pSeqModel );
678  }
679  }
680  if ( ppResult != NULL )
681  *ppResult = Aig_ManDupSimpleDfs( pNew );
682  if ( pNew )
683  Aig_ManStop( pNew );
684  return RetValue;
685 }
char * memset()
int fSilent
Definition: fra.h:108
int fNonConstOut
Definition: fra.h:179
int fReorder
Definition: saig.h:60
void Bbr_ManSetDefaultParams(Saig_ParBbr_t *p)
FUNCTION DEFINITIONS ///.
Definition: bbrReach.c:49
int fFraiging
Definition: fra.h:129
int fPartition
Definition: saig.h:59
int fInterSeparate
Definition: fra.h:132
int nBddMax
Definition: fra.h:123
int fInduction
Definition: fra.h:130
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
Aig_Man_t * Saig_ManRetimeMinArea(Aig_Man_t *p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose)
Definition: saigRetMin.c:623
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
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
void Pdr_ManSetDefaultParams(Pdr_Par_t *pPars)
MACRO DEFINITIONS ///.
Definition: pdrCore.c:48
typedefABC_NAMESPACE_HEADER_START struct Pdr_Par_t_ Pdr_Par_t
INCLUDES ///.
Definition: pdr.h:40
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Definition: fraSim.c:1021
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition: utilCex.c:51
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
int nBddMax
Definition: saig.h:57
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition: saigDup.c:279
typedefABC_NAMESPACE_HEADER_START struct Ssw_Pars_t_ Ssw_Pars_t
INCLUDES ///.
Definition: ssw.h:40
Aig_Man_t * Aig_ManDupOrdered(Aig_Man_t *p)
Definition: aigDup.c:277
int fReachability
Definition: fra.h:133
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
int nBddIterMax
Definition: fra.h:124
float TimeLimit
Definition: fra.h:110
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
Definition: sswCore.c:414
int nFramesMax
Definition: fra.h:118
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
static abctime Abc_Clock()
Definition: abc_global.h:279
int fRecursive
Definition: fra.h:145
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
int nIterMax
Definition: saig.h:58
Aig_Man_t * Saig_ManRetimeForward(Aig_Man_t *p, int nMaxIters, int fVerbose)
Definition: saigRetFwd.c:213
int fVerbose
Definition: fra.h:139
int fRetimeRegs
Definition: fra.h:128
int fVeryVerbose
Definition: fra.h:140
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
Abc_Cex_t * Fra_SmlGetCounterExample(Fra_Sml_t *p)
Definition: fraSim.c:1043
Aig_Man_t * Ssw_LatchCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
Definition: sswCore.c:521
Aig_Man_t * Aig_ManReduceLaches(Aig_Man_t *p, int fVerbose)
Definition: aigScl.c:455
int TimeLimit
Definition: saig.h:56
void Aig_ObjPatchFanin0(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFaninNew)
Definition: aigObj.c:282
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
int fUsePdr
Definition: fra.h:137
Aig_Man_t * Aig_ManScl(Aig_Man_t *pAig, int fLatchConst, int fLatchEqual, int fUseMvSweep, int nFramesSymb, int nFramesSatur, int fVerbose, int fVeryVerbose)
Definition: aigScl.c:650
Aig_Man_t * Dar_ManCompress2(Aig_Man_t *pAig, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose)
Definition: darScript.c:235
int Inter_ManPerformInterpolation(Aig_Man_t *pAig, Inter_ManParams_t *pPars, int *piFrame)
Definition: intCore.c:79
void Ssw_ManSetDefaultParams(Ssw_Pars_t *p)
DECLARATIONS ///.
Definition: sswCore.c:45
Aig_Man_t * Aig_ManConstReduce(Aig_Man_t *p, int fUseMvSweep, int nFramesSymb, int nFramesSatur, int fVerbose, int fVeryVerbose)
Definition: aigTsim.c:498
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
void Inter_ManSetDefaultParams(Inter_ManParams_t *p)
MACRO DEFINITIONS ///.
Definition: intCore.c:46
int fReorderImage
Definition: saig.h:61
Definition: fra.h:92
Definition: aig.h:69
char * sprintf()
static int Counter
int nFramesK
Definition: fra.h:97
int nBTLimitGlobal
Definition: fra.h:120
Aig_Man_t * Aig_ManDupSimpleDfs(Aig_Man_t *p)
Definition: aigDup.c:184
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
Definition: ioaWriteAig.c:446
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
int fPhaseAbstract
Definition: fra.h:126
int nSMnumber
Definition: fra.h:143
Aig_Man_t * Saig_ManDupOrpos(Aig_Man_t *p)
DECLARATIONS ///.
Definition: saigDup.c:45
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
int nBddVarsMax
Definition: fra.h:122
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
Aig_Man_t * Aig_ManDupUnsolvedOutputs(Aig_Man_t *p, int fAddRegs)
Definition: aigDup.c:1199
int nBTLimit
Definition: fra.h:119
void Abc_FrameSetSave1(void *pAig)
Definition: mainFrame.c:632
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
int Pdr_ManSolve(Aig_Man_t *p, Pdr_Par_t *pPars)
Definition: pdrCore.c:886
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
Aig_Man_t * Aig_ManDupOneOutput(Aig_Man_t *p, int iPoNum, int fAddRegs)
Definition: aigDup.c:1152
int fInterpolation
Definition: fra.h:131
#define ABC_FREE(obj)
Definition: abc_global.h:232
Abc_Cex_t * Abc_CexDup(Abc_Cex_t *p, int nRegsNew)
Definition: utilCex.c:145
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int nBTLimitInter
Definition: fra.h:121
int fReportSolution
Definition: fra.h:146
int fLatchCorr
Definition: fra.h:104
int Fra_FraigCec(Aig_Man_t **ppAig, int nConfLimit, int fVerbose)
Definition: fraCec.c:320
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
#define assert(ex)
Definition: util_old.h:213
int nPdrTimeout
Definition: fra.h:125
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
int fSilent
Definition: saig.h:63
int Fra_FraigMiterStatus(Aig_Man_t *p)
DECLARATIONS ///.
Definition: fraCore.c:62
void Ssw_ManSetDefaultParamsLcorr(Ssw_Pars_t *p)
Definition: sswCore.c:92
int fVerbose
Definition: fra.h:107
ABC_INT64_T abctime
Definition: abc_global.h:278
int fRetimeFirst
Definition: fra.h:127
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
Aig_Man_t * Aig_ManDupSimple(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigDup.c:46
int Saig_ManFindFailedPoCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition: saigDup.c:434
int fSilent
Definition: fra.h:138
typedefABC_NAMESPACE_HEADER_START struct Inter_ManParams_t_ Inter_ManParams_t
INCLUDES ///.
Definition: int.h:48
Aig_Man_t * Saig_ManPhaseAbstractAuto(Aig_Man_t *p, int fVerbose)
Definition: saigPhase.c:965
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
int Aig_ManVerifyUsingBdds(Aig_Man_t *p, Saig_ParBbr_t *pPars)
Definition: bbrReach.c:544
int fVerbose
Definition: saig.h:62
static int Depth
Definition: dsdProc.c:56
void Fra_FraigSweep ( Fra_Man_t p)

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

Synopsis [Performs fraiging for the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 310 of file fraCore.c.

311 {
312 // Bar_Progress_t * pProgress = NULL;
313  Aig_Obj_t * pObj, * pObjNew;
314  int i, Pos = 0;
315  int nBTracksOld;
316  // fraig latch outputs
317  Aig_ManForEachLoSeq( p->pManAig, pObj, i )
318  {
319  Fra_FraigNode( p, pObj );
320  if ( p->pPars->fUseImps )
321  Pos = Fra_ImpCheckForNode( p, p->pCla->vImps, pObj, Pos );
322  }
323  if ( p->pPars->fLatchCorr )
324  return;
325  // fraig internal nodes
326 // if ( !p->pPars->fDontShowBar )
327 // pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pManAig) );
328  nBTracksOld = p->pPars->nBTLimitNode;
329  Aig_ManForEachNode( p->pManAig, pObj, i )
330  {
331 // if ( pProgress )
332 // Bar_ProgressUpdate( pProgress, i, NULL );
333  // derive and remember the new fraig node
334  pObjNew = Aig_And( p->pManFraig, Fra_ObjChild0Fra(pObj,p->pPars->nFramesK), Fra_ObjChild1Fra(pObj,p->pPars->nFramesK) );
335  Fra_ObjSetFraig( pObj, p->pPars->nFramesK, pObjNew );
336  Aig_Regular(pObjNew)->pData = p;
337  // quit if simulation detected a counter-example for a PO
338  if ( p->pManFraig->pData )
339  continue;
340 // if ( Aig_SupportSize(p->pManAig,pObj) > 16 )
341 // continue;
342  // perform fraiging
343  if ( p->pPars->nLevelMax && (int)pObj->Level > p->pPars->nLevelMax )
344  p->pPars->nBTLimitNode = 5;
345  Fra_FraigNode( p, pObj );
346  if ( p->pPars->nLevelMax && (int)pObj->Level > p->pPars->nLevelMax )
347  p->pPars->nBTLimitNode = nBTracksOld;
348  // check implications
349  if ( p->pPars->fUseImps )
350  Pos = Fra_ImpCheckForNode( p, p->pCla->vImps, pObj, Pos );
351  }
352 // if ( pProgress )
353 // Bar_ProgressStop( pProgress );
354  // try to prove the outputs of the miter
356 // Fra_MiterStatus( p->pManFraig );
357 // if ( p->pPars->fProve && p->pManFraig->pData == NULL )
358 // Fra_MiterProve( p );
359  // compress implications after processing all of them
360  if ( p->pPars->fUseImps )
362 }
unsigned Level
Definition: aig.h:82
Aig_Man_t * pManAig
Definition: fra.h:191
void Fra_ImpCompactArray(Vec_Int_t *vImps)
Definition: fraImp.c:607
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
ush Pos
Definition: deflate.h:88
void * pData
Definition: aig.h:87
static Aig_Obj_t * Fra_ObjChild0Fra(Aig_Obj_t *pObj, int i)
Definition: fra.h:272
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static void Fra_ObjSetFraig(Aig_Obj_t *pObj, int i, Aig_Obj_t *pNode)
Definition: fra.h:261
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
Aig_Man_t * pManFraig
Definition: fra.h:192
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
int Fra_ImpCheckForNode(Fra_Man_t *p, Vec_Int_t *vImps, Aig_Obj_t *pNode, int Pos)
Definition: fraImp.c:503
Definition: aig.h:69
Vec_Int_t * vImps
Definition: fra.h:163
int nNodesMiter
Definition: fra.h:221
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
static Aig_Obj_t * Fra_ObjChild1Fra(Aig_Obj_t *pObj, int i)
Definition: fra.h:273
static void Fra_FraigNode(Fra_Man_t *p, Aig_Obj_t *pObj)
Definition: fraCore.c:234
void Fra_ImpAddToSolver ( Fra_Man_t p,
Vec_Int_t vImps,
int *  pSatVarNums 
)

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

Synopsis [Add implication clauses to the SAT solver.]

Description [Note that implications should be checked in the first frame!]

SideEffects []

SeeAlso []

Definition at line 428 of file fraImp.c.

429 {
430  sat_solver * pSat = p->pSat;
431  Aig_Obj_t * pLeft, * pRight;
432  Aig_Obj_t * pLeftF, * pRightF;
433  int pLits[2], Imp, Left, Right, i, f, status;
434  int fComplL, fComplR;
435  Vec_IntForEachEntry( vImps, Imp, i )
436  {
437  // get the corresponding nodes
438  pLeft = Aig_ManObj( p->pManAig, Fra_ImpLeft(Imp) );
439  pRight = Aig_ManObj( p->pManAig, Fra_ImpRight(Imp) );
440  // check if all the nodes are present
441  for ( f = 0; f < p->pPars->nFramesK; f++ )
442  {
443  // map these info fraig
444  pLeftF = Fra_ObjFraig( pLeft, f );
445  pRightF = Fra_ObjFraig( pRight, f );
446  if ( Aig_ObjIsNone(Aig_Regular(pLeftF)) || Aig_ObjIsNone(Aig_Regular(pRightF)) )
447  {
448  Vec_IntWriteEntry( vImps, i, 0 );
449  break;
450  }
451  }
452  if ( f < p->pPars->nFramesK )
453  continue;
454  // add constraints in each timeframe
455  for ( f = 0; f < p->pPars->nFramesK; f++ )
456  {
457  // map these info fraig
458  pLeftF = Fra_ObjFraig( pLeft, f );
459  pRightF = Fra_ObjFraig( pRight, f );
460  // get the corresponding SAT numbers
461  Left = pSatVarNums[ Aig_Regular(pLeftF)->Id ];
462  Right = pSatVarNums[ Aig_Regular(pRightF)->Id ];
463  assert( Left > 0 && Left < p->nSatVars );
464  assert( Right > 0 && Right < p->nSatVars );
465  // get the complemented attributes
466  fComplL = pLeft->fPhase ^ Aig_IsComplement(pLeftF);
467  fComplR = pRight->fPhase ^ Aig_IsComplement(pRightF);
468  // get the constraint
469  // L => R L' v R (complement = L & R')
470  pLits[0] = 2 * Left + !fComplL;
471  pLits[1] = 2 * Right + fComplR;
472  // add constraint to solver
473  if ( !sat_solver_addclause( pSat, pLits, pLits + 2 ) )
474  {
475  sat_solver_delete( pSat );
476  p->pSat = NULL;
477  return;
478  }
479  }
480  }
481  status = sat_solver_simplify(pSat);
482  if ( status == 0 )
483  {
484  sat_solver_delete( pSat );
485  p->pSat = NULL;
486  }
487 // printf( "Total imps = %d. ", Vec_IntSize(vImps) );
488  Fra_ImpCompactArray( vImps );
489 // printf( "Valid imps = %d. \n", Vec_IntSize(vImps) );
490 }
Aig_Man_t * pManAig
Definition: fra.h:191
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
Fra_Par_t * pPars
Definition: fra.h:189
sat_solver * pSat
Definition: fra.h:210
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
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_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Aig_Obj_t * Fra_ObjFraig(Aig_Obj_t *pObj, int i)
Definition: fra.h:260
static int Aig_ObjIsNone(Aig_Obj_t *pObj)
Definition: aig.h:273
Definition: aig.h:69
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
unsigned int fPhase
Definition: aig.h:78
static int Fra_ImpRight(int Imp)
Definition: fra.h:276
static int Fra_ImpLeft(int Imp)
Definition: fra.h:275
#define assert(ex)
Definition: util_old.h:213
void Fra_ImpCompactArray(Vec_Int_t *vImps)
Definition: fraImp.c:607
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Id
Definition: aig.h:85
int Fra_ImpCheckForNode ( Fra_Man_t p,
Vec_Int_t vImps,
Aig_Obj_t pNode,
int  Pos 
)

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

Synopsis [Check implications for the node (if they are present).]

Description [Returns the new position in the array.]

SideEffects []

SeeAlso []

Definition at line 503 of file fraImp.c.

504 {
505  Aig_Obj_t * pLeft, * pRight;
506  Aig_Obj_t * pLeftF, * pRightF;
507  int i, Imp, Left, Right, Max, RetValue;
508  int fComplL, fComplR;
509  Vec_IntForEachEntryStart( vImps, Imp, i, Pos )
510  {
511  if ( Imp == 0 )
512  continue;
513  Left = Fra_ImpLeft(Imp);
514  Right = Fra_ImpRight(Imp);
515  Max = Abc_MaxInt( Left, Right );
516  assert( Max >= pNode->Id );
517  if ( Max > pNode->Id )
518  return i;
519  // get the corresponding nodes
520  pLeft = Aig_ManObj( p->pManAig, Left );
521  pRight = Aig_ManObj( p->pManAig, Right );
522  // get the corresponding FRAIG nodes
523  pLeftF = Fra_ObjFraig( pLeft, p->pPars->nFramesK );
524  pRightF = Fra_ObjFraig( pRight, p->pPars->nFramesK );
525  // get the complemented attributes
526  fComplL = pLeft->fPhase ^ Aig_IsComplement(pLeftF);
527  fComplR = pRight->fPhase ^ Aig_IsComplement(pRightF);
528  // check equality
529  if ( Aig_Regular(pLeftF) == Aig_Regular(pRightF) )
530  {
531  if ( fComplL == fComplR ) // x => x - always true
532  continue;
533  assert( fComplL != fComplR );
534  // consider 4 possibilities:
535  // NOT(1) => 1 or 0 => 1 - always true
536  // 1 => NOT(1) or 1 => 0 - never true
537  // NOT(x) => x or x - not always true
538  // x => NOT(x) or NOT(x) - not always true
539  if ( Aig_ObjIsConst1(Aig_Regular(pLeftF)) && fComplL ) // proved implication
540  continue;
541  // disproved implication
542  p->pCla->fRefinement = 1;
543  Vec_IntWriteEntry( vImps, i, 0 );
544  continue;
545  }
546  // check the implication
547  // - if true, a clause is added
548  // - if false, a cex is simulated
549  // make sure the implication is refined
550  RetValue = Fra_NodesAreImp( p, Aig_Regular(pLeftF), Aig_Regular(pRightF), fComplL, fComplR );
551  if ( RetValue != 1 )
552  {
553  p->pCla->fRefinement = 1;
554  if ( RetValue == 0 )
555  Fra_SmlResimulate( p );
556  if ( Vec_IntEntry(vImps, i) != 0 )
557  printf( "Fra_ImpCheckForNode(): Implication is not refined!\n" );
558  assert( Vec_IntEntry(vImps, i) == 0 );
559  }
560  }
561  return i;
562 }
Aig_Man_t * pManAig
Definition: fra.h:191
int fRefinement
Definition: fra.h:162
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
ush Pos
Definition: deflate.h:88
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_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Aig_Obj_t * Fra_ObjFraig(Aig_Obj_t *pObj, int i)
Definition: fra.h:260
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
void Fra_SmlResimulate(Fra_Man_t *p)
Definition: fraSim.c:703
unsigned int fPhase
Definition: aig.h:78
static int Fra_ImpRight(int Imp)
Definition: fra.h:276
static int Fra_ImpLeft(int Imp)
Definition: fra.h:275
int Fra_NodesAreImp(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
Definition: fraSat.c:209
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
void Fra_ImpCompactArray ( Vec_Int_t vImps)

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

Synopsis [Removes empty implications.]

Description []

SideEffects []

SeeAlso []

Definition at line 607 of file fraImp.c.

608 {
609  int i, k, Imp;
610  k = 0;
611  Vec_IntForEachEntry( vImps, Imp, i )
612  if ( Imp )
613  Vec_IntWriteEntry( vImps, k++, Imp );
614  Vec_IntShrink( vImps, k );
615 }
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
double Fra_ImpComputeStateSpaceRatio ( Fra_Man_t p)

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

Synopsis [Determines the ratio of the state space by computed implications.]

Description []

SideEffects []

SeeAlso []

Definition at line 628 of file fraImp.c.

629 {
630  int nSimWords = 64;
631  Fra_Sml_t * pComb;
632  unsigned * pResult;
633  double Ratio = 0.0;
634  int Left, Right, Imp, i;
635  if ( p->pCla->vImps == NULL || Vec_IntSize(p->pCla->vImps) == 0 )
636  return Ratio;
637  // simulate the AIG manager with combinational patterns
638  pComb = Fra_SmlSimulateComb( p->pManAig, nSimWords, 0 );
639  // go through the implications and collect where they do not hold
640  pResult = Fra_ObjSim( pComb, 0 );
641  assert( pResult[0] == 0 );
642  Vec_IntForEachEntry( p->pCla->vImps, Imp, i )
643  {
644  Left = Fra_ImpLeft(Imp);
645  Right = Fra_ImpRight(Imp);
646  Sml_NodeSaveNotImpPatterns( pComb, Left, Right, pResult );
647  }
648  // count the number of ones in this area
649  Ratio = 100.0 * Fra_SmlCountOnesOne( pComb, 0 ) / (32*(pComb->nWordsTotal-pComb->nWordsPref));
650  Fra_SmlStop( pComb );
651  return Ratio;
652 }
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
static void Sml_NodeSaveNotImpPatterns(Fra_Sml_t *p, int Left, int Right, unsigned *pResult)
Definition: fraImp.c:133
static ABC_NAMESPACE_IMPL_START int Fra_SmlCountOnesOne(Fra_Sml_t *p, int Node)
DECLARATIONS ///.
Definition: fraImp.c:45
int nWordsTotal
Definition: fra.h:177
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Definition: fraSim.c:856
Vec_Int_t * vImps
Definition: fra.h:163
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Fra_ImpRight(int Imp)
Definition: fra.h:276
static int Fra_ImpLeft(int Imp)
Definition: fra.h:275
#define assert(ex)
Definition: util_old.h:213
int nWordsPref
Definition: fra.h:178
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
static int Fra_ImpCreate ( int  Left,
int  Right 
)
inlinestatic

Definition at line 277 of file fra.h.

277 { return (Right << 16) | Left; }
Vec_Int_t* Fra_ImpDerive ( Fra_Man_t p,
int  nImpMaxLimit,
int  nImpUseLimit,
int  fLatchCorr 
)

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

Synopsis [Derives implication candidates.]

Description [Implication candidates have the property that (1) they hold using sequential simulation information (2) they do not hold using combinational simulation information (3) they have as high expressive power as possible (heuristically) that is, they are easy to disprove combinationally meaning they cover relatively larger sequential subspace.]

SideEffects []

SeeAlso []

Definition at line 321 of file fraImp.c.

322 {
323  int nSimWords = 64;
324  Fra_Sml_t * pSeq, * pComb;
325  Vec_Int_t * vImps, * vTemp;
326  Vec_Ptr_t * vNodes;
327  int * pImpCosts, * pNodesI, * pNodesK;
328  int nImpsTotal = 0, nImpsTried = 0, nImpsNonSeq = 0, nImpsComb = 0, nImpsCollected = 0;
329  int CostMin = ABC_INFINITY, CostMax = 0;
330  int i, k, Imp, CostRange;
331  abctime clk = Abc_Clock();
332  assert( Aig_ManObjNumMax(p->pManAig) < (1 << 15) );
333  assert( nImpMaxLimit > 0 && nImpUseLimit > 0 && nImpUseLimit <= nImpMaxLimit );
334  // normalize both managers
335  pComb = Fra_SmlSimulateComb( p->pManAig, nSimWords, 0 );
336  pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nSimWords, 1, 1 );
337  // get the nodes sorted by the number of 1s
338  vNodes = Fra_SmlSortUsingOnes( pSeq, fLatchCorr );
339  // count the total number of implications
340  for ( k = nSimWords * 32; k > 0; k-- )
341  for ( i = k - 1; i > 0; i-- )
342  for ( pNodesI = (int *)Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
343  for ( pNodesK = (int *)Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
344  nImpsTotal++;
345 
346  // compute implications and their costs
347  pImpCosts = ABC_ALLOC( int, nImpMaxLimit );
348  vImps = Vec_IntAlloc( nImpMaxLimit );
349  for ( k = pSeq->nWordsTotal * 32; k > 0; k-- )
350  for ( i = k - 1; i > 0; i-- )
351  {
352  // HERE WE ARE MISSING SOME POTENTIAL IMPLICATIONS (with complement!)
353 
354  for ( pNodesI = (int *)Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
355  for ( pNodesK = (int *)Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
356  {
357  nImpsTried++;
358  if ( !Sml_NodeCheckImp(pSeq, *pNodesI, *pNodesK) )
359  {
360  nImpsNonSeq++;
361  continue;
362  }
363  if ( Sml_NodeCheckImp(pComb, *pNodesI, *pNodesK) )
364  {
365  nImpsComb++;
366  continue;
367  }
368  nImpsCollected++;
369  Imp = Fra_ImpCreate( *pNodesI, *pNodesK );
370  pImpCosts[ Vec_IntSize(vImps) ] = Sml_NodeNotImpWeight(pComb, *pNodesI, *pNodesK);
371  CostMin = Abc_MinInt( CostMin, pImpCosts[ Vec_IntSize(vImps) ] );
372  CostMax = Abc_MaxInt( CostMax, pImpCosts[ Vec_IntSize(vImps) ] );
373  Vec_IntPush( vImps, Imp );
374  if ( Vec_IntSize(vImps) == nImpMaxLimit )
375  goto finish;
376  }
377  }
378 finish:
379  Fra_SmlStop( pComb );
380  Fra_SmlStop( pSeq );
381 
382  // select implications with the highest cost
383  CostRange = CostMin;
384  if ( Vec_IntSize(vImps) > nImpUseLimit )
385  {
386  vImps = Fra_SmlSelectMaxCost( vTemp = vImps, pImpCosts, nSimWords * 32, nImpUseLimit, &CostRange );
387  Vec_IntFree( vTemp );
388  }
389 
390  // dealloc
391  ABC_FREE( pImpCosts );
392  {
393  void * pTemp = Vec_PtrEntry(vNodes, 0);
394  ABC_FREE( pTemp );
395  }
396  Vec_PtrFree( vNodes );
397  // reorder implications topologically
398  qsort( (void *)Vec_IntArray(vImps), Vec_IntSize(vImps), sizeof(int),
399  (int (*)(const void *, const void *)) Sml_CompareMaxId );
400 if ( p->pPars->fVerbose )
401 {
402 printf( "Implications: All = %d. Try = %d. NonSeq = %d. Comb = %d. Res = %d.\n",
403  nImpsTotal, nImpsTried, nImpsNonSeq, nImpsComb, nImpsCollected );
404 printf( "Implication weight: Min = %d. Pivot = %d. Max = %d. ",
405  CostMin, CostRange, CostMax );
406 ABC_PRT( "Time", Abc_Clock() - clk );
407 }
408  return vImps;
409 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * pManAig
Definition: fra.h:191
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Definition: fraSim.c:1021
Fra_Par_t * pPars
Definition: fra.h:189
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nWordsTotal
Definition: fra.h:177
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int Sml_CompareMaxId(unsigned short *pImp1, unsigned short *pImp2)
Definition: fraImp.c:294
static int Sml_NodeNotImpWeight(Fra_Sml_t *p, int Left, int Right)
Definition: fraImp.c:111
Vec_Ptr_t * Fra_SmlSortUsingOnes(Fra_Sml_t *p, int fLatchCorr)
Definition: fraImp.c:154
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Definition: fraSim.c:856
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Int_t * Fra_SmlSelectMaxCost(Vec_Int_t *vImps, int *pCosts, int nCostMax, int nImpLimit, int *pCostRange)
Definition: fraImp.c:244
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static int Fra_ImpCreate(int Left, int Right)
Definition: fra.h:277
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Sml_NodeCheckImp(Fra_Sml_t *p, int Left, int Right)
Definition: fraImp.c:88
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Fra_ImpLeft ( int  Imp)
inlinestatic

Definition at line 275 of file fra.h.

275 { return Imp & 0xFFFF; }
void Fra_ImpRecordInManager ( Fra_Man_t p,
Aig_Man_t pNew 
)

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

Synopsis [Record proven implications in the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 705 of file fraImp.c.

706 {
707  Aig_Obj_t * pLeft, * pRight, * pMiter;
708  int nPosOld, Imp, i;
709  if ( p->pCla->vImps == NULL || Vec_IntSize(p->pCla->vImps) == 0 )
710  return;
711  // go through the implication
712  nPosOld = Aig_ManCoNum(pNew);
713  Vec_IntForEachEntry( p->pCla->vImps, Imp, i )
714  {
715  pLeft = Aig_ManObj( p->pManAig, Fra_ImpLeft(Imp) );
716  pRight = Aig_ManObj( p->pManAig, Fra_ImpRight(Imp) );
717  // record the implication: L' + R
718  pMiter = Aig_Or( pNew,
719  Aig_NotCond((Aig_Obj_t *)pLeft->pData, !pLeft->fPhase),
720  Aig_NotCond((Aig_Obj_t *)pRight->pData, pRight->fPhase) );
721  Aig_ObjCreateCo( pNew, pMiter );
722  }
723  pNew->nAsserts = Aig_ManCoNum(pNew) - nPosOld;
724 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:259
Definition: aig.h:69
Vec_Int_t * vImps
Definition: fra.h:163
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned int fPhase
Definition: aig.h:78
static int Fra_ImpRight(int Imp)
Definition: fra.h:276
static int Fra_ImpLeft(int Imp)
Definition: fra.h:275
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Fra_ImpRefineUsingCex ( Fra_Man_t p,
Vec_Int_t vImps 
)

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

Synopsis [Removes those implications that no longer hold.]

Description [Returns 1 if refinement has happened.]

SideEffects []

SeeAlso []

Definition at line 575 of file fraImp.c.

576 {
577  Aig_Obj_t * pLeft, * pRight;
578  int Imp, i, RetValue = 0;
579  Vec_IntForEachEntry( vImps, Imp, i )
580  {
581  if ( Imp == 0 )
582  continue;
583  // get the corresponding nodes
584  pLeft = Aig_ManObj( p->pManAig, Fra_ImpLeft(Imp) );
585  pRight = Aig_ManObj( p->pManAig, Fra_ImpRight(Imp) );
586  // check if implication holds using this simulation info
587  if ( !Sml_NodeCheckImp(p->pSml, pLeft->Id, pRight->Id) )
588  {
589  Vec_IntWriteEntry( vImps, i, 0 );
590  RetValue = 1;
591  }
592  }
593  return RetValue;
594 }
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Sml_t * pSml
Definition: fra.h:200
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Definition: aig.h:69
static int Fra_ImpRight(int Imp)
Definition: fra.h:276
static int Fra_ImpLeft(int Imp)
Definition: fra.h:275
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Id
Definition: aig.h:85
static int Sml_NodeCheckImp(Fra_Sml_t *p, int Left, int Right)
Definition: fraImp.c:88
static int Fra_ImpRight ( int  Imp)
inlinestatic

Definition at line 276 of file fra.h.

276 { return Imp >> 16; }
int Fra_ImpVerifyUsingSimulation ( Fra_Man_t p)

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

Synopsis [Returns the number of failed implications.]

Description []

SideEffects []

SeeAlso []

Definition at line 665 of file fraImp.c.

666 {
667  int nFrames = 2000;
668  int nSimWords = 8;
669  Fra_Sml_t * pSeq;
670  char * pfFails;
671  int Left, Right, Imp, i, Counter;
672  if ( p->pCla->vImps == NULL || Vec_IntSize(p->pCla->vImps) == 0 )
673  return 0;
674  // simulate the AIG manager with combinational patterns
675  pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nFrames, nSimWords, 1 );
676  // go through the implications and check how many of them do not hold
677  pfFails = ABC_ALLOC( char, Vec_IntSize(p->pCla->vImps) );
678  memset( pfFails, 0, sizeof(char) * Vec_IntSize(p->pCla->vImps) );
679  Vec_IntForEachEntry( p->pCla->vImps, Imp, i )
680  {
681  Left = Fra_ImpLeft(Imp);
682  Right = Fra_ImpRight(Imp);
683  pfFails[i] = !Sml_NodeCheckImp( pSeq, Left, Right );
684  }
685  // count how many has failed
686  Counter = 0;
687  for ( i = 0; i < Vec_IntSize(p->pCla->vImps); i++ )
688  Counter += pfFails[i];
689  ABC_FREE( pfFails );
690  Fra_SmlStop( pSeq );
691  return Counter;
692 }
char * memset()
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Definition: fraSim.c:1021
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Counter
Vec_Int_t * vImps
Definition: fra.h:163
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Fra_ImpRight(int Imp)
Definition: fra.h:276
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Fra_ImpLeft(int Imp)
Definition: fra.h:275
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Sml_NodeCheckImp(Fra_Sml_t *p, int Left, int Right)
Definition: fraImp.c:88
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
int Fra_InvariantVerify ( Aig_Man_t pAig,
int  nFrames,
Vec_Int_t vClauses,
Vec_Int_t vLits 
)

DECLARATIONS ///.

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

FileName [fraIndVer.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [Verification of the inductive invariant.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraIndVer.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

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

Synopsis [Verifies the inductive invariant.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file fraIndVer.c.

47 {
48  Cnf_Dat_t * pCnf;
49  sat_solver * pSat;
50  int * pStart;
51  int RetValue, Beg, End, i, k;
52  int CounterBase = 0, CounterInd = 0;
53  abctime clk = Abc_Clock();
54 
55  if ( nFrames != 1 )
56  {
57  printf( "Invariant verification: Can only verify for K = 1\n" );
58  return 1;
59  }
60 
61  // derive CNF
62  pCnf = Cnf_DeriveSimple( pAig, Aig_ManCoNum(pAig) );
63 /*
64  // add the property
65  {
66  Aig_Obj_t * pObj;
67  int Lits[1];
68 
69  pObj = Aig_ManCo( pAig, 0 );
70  Lits[0] = toLitCond( pCnf->pVarNums[pObj->Id], 1 );
71 
72  Vec_IntPush( vLits, Lits[0] );
73  Vec_IntPush( vClauses, Vec_IntSize(vLits) );
74  printf( "Added the target property to the set of clauses to be inductively checked.\n" );
75  }
76 */
77  // derive initialized frames for the base case
78  pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, nFrames, 1 );
79  // check clauses in the base case
80  Beg = 0;
81  pStart = Vec_IntArray( vLits );
82  Vec_IntForEachEntry( vClauses, End, i )
83  {
84  // complement the literals
85  for ( k = Beg; k < End; k++ )
86  pStart[k] = lit_neg(pStart[k]);
87  RetValue = sat_solver_solve( pSat, pStart + Beg, pStart + End, 0, 0, 0, 0 );
88  for ( k = Beg; k < End; k++ )
89  pStart[k] = lit_neg(pStart[k]);
90  Beg = End;
91  if ( RetValue == l_False )
92  continue;
93 // printf( "Clause %d failed the base case.\n", i );
94  CounterBase++;
95  }
96  sat_solver_delete( pSat );
97 
98  // derive initialized frames for the base case
99  pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, nFrames + 1, 0 );
100  assert( pSat->size == 2 * pCnf->nVars );
101  // add clauses to the first frame
102  Beg = 0;
103  pStart = Vec_IntArray( vLits );
104  Vec_IntForEachEntry( vClauses, End, i )
105  {
106  RetValue = sat_solver_addclause( pSat, pStart + Beg, pStart + End );
107  Beg = End;
108  if ( RetValue == 0 )
109  {
110  Cnf_DataFree( pCnf );
111  sat_solver_delete( pSat );
112  printf( "Invariant verification: SAT solver is unsat after adding a clause.\n" );
113  return 0;
114  }
115  }
116  // simplify the solver
117  if ( pSat->qtail != pSat->qhead )
118  {
119  RetValue = sat_solver_simplify(pSat);
120  assert( RetValue != 0 );
121  assert( pSat->qtail == pSat->qhead );
122  }
123 
124  // check clauses in the base case
125  Beg = 0;
126  pStart = Vec_IntArray( vLits );
127  Vec_IntForEachEntry( vClauses, End, i )
128  {
129  // complement the literals
130  for ( k = Beg; k < End; k++ )
131  {
132  pStart[k] += 2 * pCnf->nVars;
133  pStart[k] = lit_neg(pStart[k]);
134  }
135  RetValue = sat_solver_solve( pSat, pStart + Beg, pStart + End, 0, 0, 0, 0 );
136  for ( k = Beg; k < End; k++ )
137  {
138  pStart[k] = lit_neg(pStart[k]);
139  pStart[k] -= 2 * pCnf->nVars;
140  }
141  Beg = End;
142  if ( RetValue == l_False )
143  continue;
144 // printf( "Clause %d failed the inductive case.\n", i );
145  CounterInd++;
146  }
147  sat_solver_delete( pSat );
148  Cnf_DataFree( pCnf );
149  if ( CounterBase )
150  printf( "Invariant verification: %d clauses (out of %d) FAILED the base case.\n", CounterBase, Vec_IntSize(vClauses) );
151  if ( CounterInd )
152  printf( "Invariant verification: %d clauses (out of %d) FAILED the inductive case.\n", CounterInd, Vec_IntSize(vClauses) );
153  if ( CounterBase || CounterInd )
154  return 0;
155  printf( "Invariant verification: %d clauses verified correctly. ", Vec_IntSize(vClauses) );
156  ABC_PRT( "Time", Abc_Clock() - clk );
157  return 1;
158 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
int nVars
Definition: cnf.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: cnf.h:56
static lit lit_neg(lit l)
Definition: satVec.h:144
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition: cnfMan.c:463
Cnf_Dat_t * Cnf_DeriveSimple(Aig_Man_t *p, int nOutputs)
Definition: cnfWrite.c:587
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define l_False
Definition: SolverTypes.h:85
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Fra_ManClean ( Fra_Man_t p,
int  nNodesMax 
)

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

Synopsis [Starts the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file fraMan.c.

146 {
147  int i;
148  // remove old arrays
149  for ( i = 0; i < p->nMemAlloc; i++ )
150  if ( p->pMemFanins[i] && p->pMemFanins[i] != (void *)1 )
151  Vec_PtrFree( p->pMemFanins[i] );
152  // realloc for the new size
153  if ( p->nMemAlloc < nNodesMax )
154  {
155  int nMemAllocNew = nNodesMax + 5000;
156  p->pMemFanins = ABC_REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew );
157  p->pMemSatNums = ABC_REALLOC( int, p->pMemSatNums, nMemAllocNew );
158  p->nMemAlloc = nMemAllocNew;
159  }
160  // prepare for the new run
161  memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
162  memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
163 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int * pMemSatNums
Definition: fra.h:216
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
Vec_Ptr_t ** pMemFanins
Definition: fra.h:215
int nMemAlloc
Definition: fra.h:217
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Fra_ManFinalizeComb ( Fra_Man_t p)

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

Synopsis [Finalizes the combinational miter after fraiging.]

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file fraMan.c.

218 {
219  Aig_Obj_t * pObj;
220  int i;
221  // add the POs
222  Aig_ManForEachCo( p->pManAig, pObj, i )
223  Aig_ObjCreateCo( p->pManFraig, Fra_ObjChild0Fra(pObj,0) );
224  // postprocess
225  Aig_ManCleanMarkB( p->pManFraig );
226 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
Aig_Man_t * pManAig
Definition: fra.h:191
void Aig_ManCleanMarkB(Aig_Man_t *p)
Definition: aigUtil.c:167
static Aig_Obj_t * Fra_ObjChild0Fra(Aig_Obj_t *pObj, int i)
Definition: fra.h:272
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
Definition: aig.h:69
Aig_Man_t* Fra_ManPrepareComb ( Fra_Man_t p)

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

Synopsis [Prepares the new manager to begin fraiging.]

Description []

SideEffects []

SeeAlso []

Definition at line 176 of file fraMan.c.

177 {
178  Aig_Man_t * pManFraig;
179  Aig_Obj_t * pObj;
180  int i;
181  assert( p->pManFraig == NULL );
182  // start the fraig package
183  pManFraig = Aig_ManStart( Aig_ManObjNumMax(p->pManAig) );
184  pManFraig->pName = Abc_UtilStrsav( p->pManAig->pName );
185  pManFraig->pSpec = Abc_UtilStrsav( p->pManAig->pSpec );
186  pManFraig->nRegs = p->pManAig->nRegs;
187  pManFraig->nAsserts = p->pManAig->nAsserts;
188  // set the pointers to the available fraig nodes
189  Fra_ObjSetFraig( Aig_ManConst1(p->pManAig), 0, Aig_ManConst1(pManFraig) );
190  Aig_ManForEachCi( p->pManAig, pObj, i )
191  Fra_ObjSetFraig( pObj, 0, Aig_ObjCreateCi(pManFraig) );
192  // set the pointers to the manager
193  Aig_ManForEachObj( pManFraig, pObj, i )
194  pObj->pData = p;
195  // allocate memory for mapping FRAIG nodes into SAT numbers and fanins
196  p->nMemAlloc = p->nSizeAlloc;
197  p->pMemFanins = ABC_ALLOC( Vec_Ptr_t *, p->nMemAlloc );
198  memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
199  p->pMemSatNums = ABC_ALLOC( int, p->nMemAlloc );
200  memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
201  // make sure the satisfying assignment is node assigned
202  assert( pManFraig->pData == NULL );
203  return pManFraig;
204 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * pManAig
Definition: fra.h:191
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Fra_ObjSetFraig(Aig_Obj_t *pObj, int i, Aig_Obj_t *pNode)
Definition: fra.h:261
Aig_Man_t * pManFraig
Definition: fra.h:192
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void Fra_ManPrint ( Fra_Man_t p)

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

Synopsis [Prints stats for the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file fraMan.c.

279 {
280  double nMemory = 1.0*Aig_ManObjNumMax(p->pManAig)*(p->pSml->nWordsTotal*sizeof(unsigned)+6*sizeof(void*))/(1<<20);
281  printf( "SimWord = %d. Round = %d. Mem = %0.2f MB. LitBeg = %d. LitEnd = %d. (%6.2f %%).\n",
282  p->pPars->nSimWords, p->pSml->nSimRounds, nMemory, p->nLitsBeg, p->nLitsEnd, 100.0*p->nLitsEnd/(p->nLitsBeg?p->nLitsBeg:1) );
283  printf( "Proof = %d. Cex = %d. Fail = %d. FailReal = %d. C-lim = %d. ImpRatio = %6.2f %%\n",
284  p->nSatProof, p->nSatCallsSat, p->nSatFails, p->nSatFailsReal, p->pPars->nBTLimitNode, Fra_ImpComputeStateSpaceRatio(p) );
285  printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
286  p->nNodesBeg, p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/(p->nNodesBeg?p->nNodesBeg:1),
287  p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) );
288  if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat );
289  if ( p->pPars->fUse1Hot ) Fra_OneHotEstimateCoverage( p, p->vOneHots );
290  ABC_PRT( "AIG simulation ", p->pSml->timeSim );
291  ABC_PRT( "AIG traversal ", p->timeTrav );
292  if ( p->timeRwr )
293  {
294  ABC_PRT( "AIG rewriting ", p->timeRwr );
295  }
296  ABC_PRT( "SAT solving ", p->timeSat );
297  ABC_PRT( " Unsat ", p->timeSatUnsat );
298  ABC_PRT( " Sat ", p->timeSatSat );
299  ABC_PRT( " Fail ", p->timeSatFail );
300  ABC_PRT( "Class refining ", p->timeRef );
301  ABC_PRT( "TOTAL RUNTIME ", p->timeTotal );
302  if ( p->time1 ) { ABC_PRT( "time1 ", p->time1 ); }
303  if ( p->nSpeculs )
304  printf( "Speculations = %d.\n", p->nSpeculs );
305  fflush( stdout );
306 }
int nSatProof
Definition: fra.h:231
Aig_Man_t * pManAig
Definition: fra.h:191
abctime timeSatSat
Definition: fra.h:245
void Fra_OneHotEstimateCoverage(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:328
int timeSim
Definition: fra.h:181
int nRegsBeg
Definition: fra.h:226
Fra_Par_t * pPars
Definition: fra.h:189
sat_solver * pSat
Definition: fra.h:210
abctime time1
Definition: fra.h:249
Fra_Sml_t * pSml
Definition: fra.h:200
Vec_Int_t * vOneHots
Definition: fra.h:208
abctime timeRwr
Definition: fra.h:242
abctime timeTrav
Definition: fra.h:241
int nLitsEnd
Definition: fra.h:223
abctime timeSat
Definition: fra.h:243
int nRegsEnd
Definition: fra.h:227
int nSpeculs
Definition: fra.h:234
int nNodesBeg
Definition: fra.h:224
int nWordsTotal
Definition: fra.h:177
abctime timeTotal
Definition: fra.h:248
abctime timeSatFail
Definition: fra.h:246
int nSatFails
Definition: fra.h:232
abctime timeSatUnsat
Definition: fra.h:244
int nSatFailsReal
Definition: fra.h:233
double Fra_ImpComputeStateSpaceRatio(Fra_Man_t *p)
Definition: fraImp.c:628
abctime timeRef
Definition: fra.h:247
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int nNodesEnd
Definition: fra.h:225
int nSimRounds
Definition: fra.h:180
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Sat_SolverPrintStats(FILE *pFile, sat_solver *p)
Definition: satUtil.c:188
int nSatCallsSat
Definition: fra.h:229
int nLitsBeg
Definition: fra.h:222
Fra_Man_t* Fra_ManStart ( Aig_Man_t pManAig,
Fra_Par_t pPars 
)

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

Synopsis [Starts the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file fraMan.c.

105 {
106  Fra_Man_t * p;
107  Aig_Obj_t * pObj;
108  int i;
109  // allocate the fraiging manager
110  p = ABC_ALLOC( Fra_Man_t, 1 );
111  memset( p, 0, sizeof(Fra_Man_t) );
112  p->pPars = pPars;
113  p->pManAig = pManAig;
114  p->nSizeAlloc = Aig_ManObjNumMax( pManAig );
115  p->nFramesAll = pPars->nFramesK + 1;
116  // allocate storage for sim pattern
117  p->nPatWords = Abc_BitWordNum( (Aig_ManCiNum(pManAig) - Aig_ManRegNum(pManAig)) * p->nFramesAll + Aig_ManRegNum(pManAig) );
118  p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords );
119  p->vPiVars = Vec_PtrAlloc( 100 );
120  // equivalence classes
121  p->pCla = Fra_ClassesStart( pManAig );
122  // allocate other members
124  memset( p->pMemFraig, 0, sizeof(Aig_Obj_t *) * p->nSizeAlloc * p->nFramesAll );
125  // set random number generator
126 // srand( 0xABCABC );
127  Aig_ManRandom(1);
128  // set the pointer to the manager
129  Aig_ManForEachObj( p->pManAig, pObj, i )
130  pObj->pData = p;
131  return p;
132 }
char * memset()
Aig_Man_t * pManAig
Definition: fra.h:191
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Fra_Cla_t * Fra_ClassesStart(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: fraClass.c:60
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
int nFramesAll
Definition: fra.h:194
unsigned * pPatWords
Definition: fra.h:205
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int nSizeAlloc
Definition: fra.h:196
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Aig_Obj_t ** pMemFraig
Definition: fra.h:195
int nPatWords
Definition: fra.h:204
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
Vec_Ptr_t * vPiVars
Definition: fra.h:212
void Fra_ManStop ( Fra_Man_t p)

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

Synopsis [Stops the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file fraMan.c.

241 {
242  if ( p->pPars->fVerbose )
243  Fra_ManPrint( p );
244  // save mapping from original nodes into FRAIG nodes
245  if ( p->pManAig )
246  {
247  if ( p->pManAig->pObjCopies )
248  ABC_FREE( p->pManAig->pObjCopies );
249  p->pManAig->pObjCopies = p->pMemFraig;
250  p->pMemFraig = NULL;
251  }
252  Fra_ManClean( p, 0 );
253  if ( p->vTimeouts ) Vec_PtrFree( p->vTimeouts );
254  if ( p->vPiVars ) Vec_PtrFree( p->vPiVars );
255  if ( p->pSat ) sat_solver_delete( p->pSat );
256  if ( p->pCla ) Fra_ClassesStop( p->pCla );
257  if ( p->pSml ) Fra_SmlStop( p->pSml );
258  if ( p->vCex ) Vec_IntFree( p->vCex );
259  if ( p->vOneHots ) Vec_IntFree( p->vOneHots );
260  ABC_FREE( p->pMemFraig );
261  ABC_FREE( p->pMemFanins );
262  ABC_FREE( p->pMemSatNums );
263  ABC_FREE( p->pPatWords );
264  ABC_FREE( p );
265 }
void Fra_ManPrint(Fra_Man_t *p)
Definition: fraMan.c:278
int * pMemSatNums
Definition: fra.h:216
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
sat_solver * pSat
Definition: fra.h:210
Fra_Sml_t * pSml
Definition: fra.h:200
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Vec_Int_t * vOneHots
Definition: fra.h:208
Vec_Ptr_t ** pMemFanins
Definition: fra.h:215
unsigned * pPatWords
Definition: fra.h:205
Vec_Ptr_t * vTimeouts
Definition: fra.h:218
void Fra_ManClean(Fra_Man_t *p, int nNodesMax)
Definition: fraMan.c:145
Vec_Int_t * vCex
Definition: fra.h:206
void Fra_ClassesStop(Fra_Cla_t *p)
Definition: fraClass.c:90
#define ABC_FREE(obj)
Definition: abc_global.h:232
Aig_Obj_t ** pMemFraig
Definition: fra.h:195
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Ptr_t * vPiVars
Definition: fra.h:212
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Fra_NodeIsConst ( Fra_Man_t p,
Aig_Obj_t pNew 
)

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

Synopsis [Runs equivalence test for one node.]

Description [Returns the fraiged node.]

SideEffects []

SeeAlso []

Definition at line 425 of file fraSat.c.

426 {
427  int pLits[2], RetValue1, RetValue;
428  abctime clk;
429 
430  // make sure the nodes are not complemented
431  assert( !Aig_IsComplement(pNew) );
432  assert( pNew != p->pManFraig->pConst1 );
433  p->nSatCalls++;
434 
435  // make sure the solver is allocated and has enough variables
436  if ( p->pSat == NULL )
437  {
438  p->pSat = sat_solver_new();
439  p->nSatVars = 1;
440  sat_solver_setnvars( p->pSat, 1000 );
441  // var 0 is reserved for const1 node - add the clause
442  pLits[0] = toLit( 0 );
443  sat_solver_addclause( p->pSat, pLits, pLits + 1 );
444  }
445 
446  // if the nodes do not have SAT variables, allocate them
447  Fra_CnfNodeAddToSolver( p, NULL, pNew );
448 
449  // prepare variable activity
450  if ( p->pPars->fConeBias )
451  Fra_SetActivityFactors( p, NULL, pNew );
452 
453  // solve under assumptions
454 clk = Abc_Clock();
455  pLits[0] = toLitCond( Fra_ObjSatNum(pNew), pNew->fPhase );
456  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 1,
457  (ABC_INT64_T)p->pPars->nBTLimitMiter, (ABC_INT64_T)0,
459 p->timeSat += Abc_Clock() - clk;
460  if ( RetValue1 == l_False )
461  {
462 p->timeSatUnsat += Abc_Clock() - clk;
463  pLits[0] = lit_neg( pLits[0] );
464  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 1 );
465  assert( RetValue );
466  // continue solving the other implication
467  p->nSatCallsUnsat++;
468  }
469  else if ( RetValue1 == l_True )
470  {
471 p->timeSatSat += Abc_Clock() - clk;
472  if ( p->pPatWords )
473  Fra_SmlSavePattern( p );
474  p->nSatCallsSat++;
475  return 0;
476  }
477  else // if ( RetValue1 == l_Undef )
478  {
479 p->timeSatFail += Abc_Clock() - clk;
480  // mark the node as the failed node
481  pNew->fMarkB = 1;
482  p->nSatFailsReal++;
483  return -1;
484  }
485 
486  // return SAT proof
487  p->nSatProof++;
488  return 1;
489 }
static ABC_NAMESPACE_IMPL_START int Fra_SetActivityFactors(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
DECLARATIONS ///.
Definition: fraSat.c:540
int nSatProof
Definition: fra.h:231
ABC_INT64_T nInsLimitGlobal
Definition: fra.h:214
int nSatCallsUnsat
Definition: fra.h:230
abctime timeSatSat
Definition: fra.h:245
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
unsigned int fMarkB
Definition: aig.h:80
Fra_Par_t * pPars
Definition: fra.h:189
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
sat_solver * pSat
Definition: fra.h:210
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
ABC_INT64_T nBTLimitGlobal
Definition: fra.h:213
abctime timeSat
Definition: fra.h:243
#define l_True
Definition: SolverTypes.h:84
int nSatVars
Definition: fra.h:211
static abctime Abc_Clock()
Definition: abc_global.h:279
void Fra_CnfNodeAddToSolver(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
Definition: fraCnf.c:238
unsigned * pPatWords
Definition: fra.h:205
static lit lit_neg(lit l)
Definition: satVec.h:144
Aig_Man_t * pManFraig
Definition: fra.h:192
int nSatCalls
Definition: fra.h:228
static lit toLit(int v)
Definition: satVec.h:142
static lit toLitCond(int v, int c)
Definition: satVec.h:143
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
abctime timeSatFail
Definition: fra.h:246
abctime timeSatUnsat
Definition: fra.h:244
int nSatFailsReal
Definition: fra.h:233
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
unsigned int fPhase
Definition: aig.h:78
#define l_False
Definition: SolverTypes.h:85
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int nSatCallsSat
Definition: fra.h:229
void Fra_SmlSavePattern(Fra_Man_t *p)
Definition: fraSim.c:241
int Fra_NodesAreClause ( Fra_Man_t p,
Aig_Obj_t pOld,
Aig_Obj_t pNew,
int  fComplL,
int  fComplR 
)

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

Synopsis [Runs the result of test for pObj => pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file fraSat.c.

318 {
319  int pLits[4], RetValue, RetValue1, nBTLimit;
320  abctime clk;//, clk2 = Abc_Clock();
321  int status;
322 
323  // make sure the nodes are not complemented
324  assert( !Aig_IsComplement(pNew) );
325  assert( !Aig_IsComplement(pOld) );
326  assert( pNew != pOld );
327 
328  // if at least one of the nodes is a failed node, perform adjustments:
329  // if the backtrack limit is small, simply skip this node
330  // if the backtrack limit is > 10, take the quare root of the limit
331  nBTLimit = p->pPars->nBTLimitNode;
332 /*
333  if ( !p->pPars->fSpeculate && p->pPars->nFramesK == 0 && (nBTLimit > 0 && (pOld->fMarkB || pNew->fMarkB)) )
334  {
335  p->nSatFails++;
336  // fail immediately
337 // return -1;
338  if ( nBTLimit <= 10 )
339  return -1;
340  nBTLimit = (int)pow(nBTLimit, 0.7);
341  }
342 */
343  p->nSatCalls++;
344 
345  // make sure the solver is allocated and has enough variables
346  if ( p->pSat == NULL )
347  {
348  p->pSat = sat_solver_new();
349  p->nSatVars = 1;
350  sat_solver_setnvars( p->pSat, 1000 );
351  // var 0 is reserved for const1 node - add the clause
352  pLits[0] = toLit( 0 );
353  sat_solver_addclause( p->pSat, pLits, pLits + 1 );
354  }
355 
356  // if the nodes do not have SAT variables, allocate them
357  Fra_CnfNodeAddToSolver( p, pOld, pNew );
358 
359  if ( p->pSat->qtail != p->pSat->qhead )
360  {
361  status = sat_solver_simplify(p->pSat);
362  assert( status != 0 );
363  assert( p->pSat->qtail == p->pSat->qhead );
364  }
365 
366  // prepare variable activity
367  if ( p->pPars->fConeBias )
368  Fra_SetActivityFactors( p, pOld, pNew );
369 
370  // solve under assumptions
371  // A = 1; B = 0 OR A = 1; B = 1
372 clk = Abc_Clock();
373 // pLits[0] = toLitCond( Fra_ObjSatNum(pOld), 0 );
374 // pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase );
375  pLits[0] = toLitCond( Fra_ObjSatNum(pOld), !fComplL );
376  pLits[1] = toLitCond( Fra_ObjSatNum(pNew), !fComplR );
377 //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
378  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
379  (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
381 p->timeSat += Abc_Clock() - clk;
382  if ( RetValue1 == l_False )
383  {
384 p->timeSatUnsat += Abc_Clock() - clk;
385  pLits[0] = lit_neg( pLits[0] );
386  pLits[1] = lit_neg( pLits[1] );
387  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
388  assert( RetValue );
389  // continue solving the other implication
390  p->nSatCallsUnsat++;
391  }
392  else if ( RetValue1 == l_True )
393  {
394 p->timeSatSat += Abc_Clock() - clk;
395  Fra_SmlSavePattern( p );
396  p->nSatCallsSat++;
397  return 0;
398  }
399  else // if ( RetValue1 == l_Undef )
400  {
401 p->timeSatFail += Abc_Clock() - clk;
402  // mark the node as the failed node
403  if ( pOld != p->pManFraig->pConst1 )
404  pOld->fMarkB = 1;
405  pNew->fMarkB = 1;
406  p->nSatFailsReal++;
407  return -1;
408  }
409  // return SAT proof
410  p->nSatProof++;
411  return 1;
412 }
static ABC_NAMESPACE_IMPL_START int Fra_SetActivityFactors(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
DECLARATIONS ///.
Definition: fraSat.c:540
int nSatProof
Definition: fra.h:231
ABC_INT64_T nInsLimitGlobal
Definition: fra.h:214
int nSatCallsUnsat
Definition: fra.h:230
abctime timeSatSat
Definition: fra.h:245
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
unsigned int fMarkB
Definition: aig.h:80
Fra_Par_t * pPars
Definition: fra.h:189
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
sat_solver * pSat
Definition: fra.h:210
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
ABC_INT64_T nBTLimitGlobal
Definition: fra.h:213
abctime timeSat
Definition: fra.h:243
#define l_True
Definition: SolverTypes.h:84
int nSatVars
Definition: fra.h:211
static abctime Abc_Clock()
Definition: abc_global.h:279
void Fra_CnfNodeAddToSolver(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
Definition: fraCnf.c:238
static lit lit_neg(lit l)
Definition: satVec.h:144
Aig_Man_t * pManFraig
Definition: fra.h:192
int nSatCalls
Definition: fra.h:228
static lit toLit(int v)
Definition: satVec.h:142
static lit toLitCond(int v, int c)
Definition: satVec.h:143
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
abctime timeSatFail
Definition: fra.h:246
abctime timeSatUnsat
Definition: fra.h:244
int nSatFailsReal
Definition: fra.h:233
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
#define l_False
Definition: SolverTypes.h:85
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int nSatCallsSat
Definition: fra.h:229
void Fra_SmlSavePattern(Fra_Man_t *p)
Definition: fraSim.c:241
int Fra_NodesAreEquiv ( Fra_Man_t p,
Aig_Obj_t pOld,
Aig_Obj_t pNew 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Runs equivalence test for the two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file fraSat.c.

49 {
50  int pLits[4], RetValue, RetValue1, nBTLimit;
51  abctime clk;//, clk2 = Abc_Clock();
52  int status;
53 
54  // make sure the nodes are not complemented
55  assert( !Aig_IsComplement(pNew) );
56  assert( !Aig_IsComplement(pOld) );
57  assert( pNew != pOld );
58 
59  // if at least one of the nodes is a failed node, perform adjustments:
60  // if the backtrack limit is small, simply skip this node
61  // if the backtrack limit is > 10, take the quare root of the limit
62  nBTLimit = p->pPars->nBTLimitNode;
63  if ( !p->pPars->fSpeculate && p->pPars->nFramesK == 0 && (nBTLimit > 0 && (pOld->fMarkB || pNew->fMarkB)) )
64  {
65  p->nSatFails++;
66  // fail immediately
67 // return -1;
68  if ( nBTLimit <= 10 )
69  return -1;
70  nBTLimit = (int)pow(nBTLimit, 0.7);
71  }
72 
73  p->nSatCalls++;
74  p->nSatCallsRecent++;
75 
76  // make sure the solver is allocated and has enough variables
77  if ( p->pSat == NULL )
78  {
79  p->pSat = sat_solver_new();
80  p->nSatVars = 1;
81  sat_solver_setnvars( p->pSat, 1000 );
82  // var 0 is reserved for const1 node - add the clause
83  pLits[0] = toLit( 0 );
84  sat_solver_addclause( p->pSat, pLits, pLits + 1 );
85  }
86 
87  // if the nodes do not have SAT variables, allocate them
88  Fra_CnfNodeAddToSolver( p, pOld, pNew );
89 
90  if ( p->pSat->qtail != p->pSat->qhead )
91  {
92  status = sat_solver_simplify(p->pSat);
93  assert( status != 0 );
94  assert( p->pSat->qtail == p->pSat->qhead );
95  }
96 
97  // prepare variable activity
98  if ( p->pPars->fConeBias )
99  Fra_SetActivityFactors( p, pOld, pNew );
100 
101  // solve under assumptions
102  // A = 1; B = 0 OR A = 1; B = 1
103 clk = Abc_Clock();
104  pLits[0] = toLitCond( Fra_ObjSatNum(pOld), 0 );
105  pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase );
106 //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
107  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
108  (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
110 p->timeSat += Abc_Clock() - clk;
111  if ( RetValue1 == l_False )
112  {
113 p->timeSatUnsat += Abc_Clock() - clk;
114  pLits[0] = lit_neg( pLits[0] );
115  pLits[1] = lit_neg( pLits[1] );
116  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
117  assert( RetValue );
118  // continue solving the other implication
119  p->nSatCallsUnsat++;
120  }
121  else if ( RetValue1 == l_True )
122  {
123 p->timeSatSat += Abc_Clock() - clk;
124  Fra_SmlSavePattern( p );
125  p->nSatCallsSat++;
126  return 0;
127  }
128  else // if ( RetValue1 == l_Undef )
129  {
130 p->timeSatFail += Abc_Clock() - clk;
131  // mark the node as the failed node
132  if ( pOld != p->pManFraig->pConst1 )
133  pOld->fMarkB = 1;
134  pNew->fMarkB = 1;
135  p->nSatFailsReal++;
136  return -1;
137  }
138 
139  // if the old node was constant 0, we already know the answer
140  if ( pOld == p->pManFraig->pConst1 )
141  {
142  p->nSatProof++;
143  return 1;
144  }
145 
146  // solve under assumptions
147  // A = 0; B = 1 OR A = 0; B = 0
148 clk = Abc_Clock();
149  pLits[0] = toLitCond( Fra_ObjSatNum(pOld), 1 );
150  pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase ^ pNew->fPhase );
151  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
152  (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
154 p->timeSat += Abc_Clock() - clk;
155  if ( RetValue1 == l_False )
156  {
157 p->timeSatUnsat += Abc_Clock() - clk;
158  pLits[0] = lit_neg( pLits[0] );
159  pLits[1] = lit_neg( pLits[1] );
160  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
161  assert( RetValue );
162  p->nSatCallsUnsat++;
163  }
164  else if ( RetValue1 == l_True )
165  {
166 p->timeSatSat += Abc_Clock() - clk;
167  Fra_SmlSavePattern( p );
168  p->nSatCallsSat++;
169  return 0;
170  }
171  else // if ( RetValue1 == l_Undef )
172  {
173 p->timeSatFail += Abc_Clock() - clk;
174  // mark the node as the failed node
175  pOld->fMarkB = 1;
176  pNew->fMarkB = 1;
177  p->nSatFailsReal++;
178  return -1;
179  }
180 /*
181  // check BDD proof
182  {
183  int RetVal;
184  ABC_PRT( "Sat", Abc_Clock() - clk2 );
185  clk2 = Abc_Clock();
186  RetVal = Fra_NodesAreEquivBdd( pOld, pNew );
187 // printf( "%d ", RetVal );
188  assert( RetVal );
189  ABC_PRT( "Bdd", Abc_Clock() - clk2 );
190  printf( "\n" );
191  }
192 */
193  // return SAT proof
194  p->nSatProof++;
195  return 1;
196 }
static ABC_NAMESPACE_IMPL_START int Fra_SetActivityFactors(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
DECLARATIONS ///.
Definition: fraSat.c:540
int nSatProof
Definition: fra.h:231
ABC_INT64_T nInsLimitGlobal
Definition: fra.h:214
int nSatCallsUnsat
Definition: fra.h:230
abctime timeSatSat
Definition: fra.h:245
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
unsigned int fMarkB
Definition: aig.h:80
Fra_Par_t * pPars
Definition: fra.h:189
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
sat_solver * pSat
Definition: fra.h:210
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
ABC_INT64_T nBTLimitGlobal
Definition: fra.h:213
abctime timeSat
Definition: fra.h:243
#define l_True
Definition: SolverTypes.h:84
int nSatVars
Definition: fra.h:211
static abctime Abc_Clock()
Definition: abc_global.h:279
void Fra_CnfNodeAddToSolver(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
Definition: fraCnf.c:238
static lit lit_neg(lit l)
Definition: satVec.h:144
Aig_Man_t * pManFraig
Definition: fra.h:192
int nSatCalls
Definition: fra.h:228
static lit toLit(int v)
Definition: satVec.h:142
static lit toLitCond(int v, int c)
Definition: satVec.h:143
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
abctime timeSatFail
Definition: fra.h:246
int nSatFails
Definition: fra.h:232
abctime timeSatUnsat
Definition: fra.h:244
int nSatFailsReal
Definition: fra.h:233
int nSatCallsRecent
Definition: fra.h:237
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
unsigned int fPhase
Definition: aig.h:78
#define l_False
Definition: SolverTypes.h:85
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int nSatCallsSat
Definition: fra.h:229
void Fra_SmlSavePattern(Fra_Man_t *p)
Definition: fraSim.c:241
int Fra_NodesAreImp ( Fra_Man_t p,
Aig_Obj_t pOld,
Aig_Obj_t pNew,
int  fComplL,
int  fComplR 
)

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

Synopsis [Runs the result of test for pObj => pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 209 of file fraSat.c.

210 {
211  int pLits[4], RetValue, RetValue1, nBTLimit;
212  abctime clk;//, clk2 = Abc_Clock();
213  int status;
214 
215  // make sure the nodes are not complemented
216  assert( !Aig_IsComplement(pNew) );
217  assert( !Aig_IsComplement(pOld) );
218  assert( pNew != pOld );
219 
220  // if at least one of the nodes is a failed node, perform adjustments:
221  // if the backtrack limit is small, simply skip this node
222  // if the backtrack limit is > 10, take the quare root of the limit
223  nBTLimit = p->pPars->nBTLimitNode;
224 /*
225  if ( !p->pPars->fSpeculate && p->pPars->nFramesK == 0 && (nBTLimit > 0 && (pOld->fMarkB || pNew->fMarkB)) )
226  {
227  p->nSatFails++;
228  // fail immediately
229 // return -1;
230  if ( nBTLimit <= 10 )
231  return -1;
232  nBTLimit = (int)pow(nBTLimit, 0.7);
233  }
234 */
235  p->nSatCalls++;
236 
237  // make sure the solver is allocated and has enough variables
238  if ( p->pSat == NULL )
239  {
240  p->pSat = sat_solver_new();
241  p->nSatVars = 1;
242  sat_solver_setnvars( p->pSat, 1000 );
243  // var 0 is reserved for const1 node - add the clause
244  pLits[0] = toLit( 0 );
245  sat_solver_addclause( p->pSat, pLits, pLits + 1 );
246  }
247 
248  // if the nodes do not have SAT variables, allocate them
249  Fra_CnfNodeAddToSolver( p, pOld, pNew );
250 
251  if ( p->pSat->qtail != p->pSat->qhead )
252  {
253  status = sat_solver_simplify(p->pSat);
254  assert( status != 0 );
255  assert( p->pSat->qtail == p->pSat->qhead );
256  }
257 
258  // prepare variable activity
259  if ( p->pPars->fConeBias )
260  Fra_SetActivityFactors( p, pOld, pNew );
261 
262  // solve under assumptions
263  // A = 1; B = 0 OR A = 1; B = 1
264 clk = Abc_Clock();
265 // pLits[0] = toLitCond( Fra_ObjSatNum(pOld), 0 );
266 // pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase );
267  pLits[0] = toLitCond( Fra_ObjSatNum(pOld), fComplL );
268  pLits[1] = toLitCond( Fra_ObjSatNum(pNew), !fComplR );
269 //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
270  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
271  (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
273 p->timeSat += Abc_Clock() - clk;
274  if ( RetValue1 == l_False )
275  {
276 p->timeSatUnsat += Abc_Clock() - clk;
277  pLits[0] = lit_neg( pLits[0] );
278  pLits[1] = lit_neg( pLits[1] );
279  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
280  assert( RetValue );
281  // continue solving the other implication
282  p->nSatCallsUnsat++;
283  }
284  else if ( RetValue1 == l_True )
285  {
286 p->timeSatSat += Abc_Clock() - clk;
287  Fra_SmlSavePattern( p );
288  p->nSatCallsSat++;
289  return 0;
290  }
291  else // if ( RetValue1 == l_Undef )
292  {
293 p->timeSatFail += Abc_Clock() - clk;
294  // mark the node as the failed node
295  if ( pOld != p->pManFraig->pConst1 )
296  pOld->fMarkB = 1;
297  pNew->fMarkB = 1;
298  p->nSatFailsReal++;
299  return -1;
300  }
301  // return SAT proof
302  p->nSatProof++;
303  return 1;
304 }
static ABC_NAMESPACE_IMPL_START int Fra_SetActivityFactors(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
DECLARATIONS ///.
Definition: fraSat.c:540
int nSatProof
Definition: fra.h:231
ABC_INT64_T nInsLimitGlobal
Definition: fra.h:214
int nSatCallsUnsat
Definition: fra.h:230
abctime timeSatSat
Definition: fra.h:245
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
unsigned int fMarkB
Definition: aig.h:80
Fra_Par_t * pPars
Definition: fra.h:189
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
sat_solver * pSat
Definition: fra.h:210
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
ABC_INT64_T nBTLimitGlobal
Definition: fra.h:213
abctime timeSat
Definition: fra.h:243
#define l_True
Definition: SolverTypes.h:84
int nSatVars
Definition: fra.h:211
static abctime Abc_Clock()
Definition: abc_global.h:279
void Fra_CnfNodeAddToSolver(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
Definition: fraCnf.c:238
static lit lit_neg(lit l)
Definition: satVec.h:144
Aig_Man_t * pManFraig
Definition: fra.h:192
int nSatCalls
Definition: fra.h:228
static lit toLit(int v)
Definition: satVec.h:142
static lit toLitCond(int v, int c)
Definition: satVec.h:143
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
abctime timeSatFail
Definition: fra.h:246
abctime timeSatUnsat
Definition: fra.h:244
int nSatFailsReal
Definition: fra.h:233
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
#define l_False
Definition: SolverTypes.h:85
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int nSatCallsSat
Definition: fra.h:229
void Fra_SmlSavePattern(Fra_Man_t *p)
Definition: fraSim.c:241
static Aig_Obj_t* Fra_ObjChild0Fra ( Aig_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 272 of file fra.h.

272 { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Fra_ObjFraig(Aig_ObjFanin0(pObj),i), Aig_ObjFaninC0(pObj)) : NULL; }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Fra_ObjFraig(Aig_Obj_t *pObj, int i)
Definition: fra.h:260
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Aig_Obj_t* Fra_ObjChild1Fra ( Aig_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 273 of file fra.h.

273 { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Fra_ObjFraig(Aig_ObjFanin1(pObj),i), Aig_ObjFaninC1(pObj)) : NULL; }
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static Aig_Obj_t * Fra_ObjFraig(Aig_Obj_t *pObj, int i)
Definition: fra.h:260
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Vec_Ptr_t* Fra_ObjFaninVec ( Aig_Obj_t pObj)
inlinestatic

Definition at line 263 of file fra.h.

263 { return ((Fra_Man_t *)pObj->pData)->pMemFanins[pObj->Id]; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static Aig_Obj_t* Fra_ObjFraig ( Aig_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 260 of file fra.h.

260 { return ((Fra_Man_t *)pObj->pData)->pMemFraig[((Fra_Man_t *)pObj->pData)->nFramesAll*pObj->Id + i]; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static unsigned Fra_ObjRandomSim ( )
inlinestatic

Definition at line 258 of file fra.h.

258 { return Aig_ManRandom(0); }
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
static int Fra_ObjSatNum ( Aig_Obj_t pObj)
inlinestatic

Definition at line 266 of file fra.h.

266 { return ((Fra_Man_t *)pObj->pData)->pMemSatNums[pObj->Id]; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static void Fra_ObjSetFaninVec ( Aig_Obj_t pObj,
Vec_Ptr_t vFanins 
)
inlinestatic

Definition at line 264 of file fra.h.

264 { ((Fra_Man_t *)pObj->pData)->pMemFanins[pObj->Id] = vFanins; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static void Fra_ObjSetFraig ( Aig_Obj_t pObj,
int  i,
Aig_Obj_t pNode 
)
inlinestatic

Definition at line 261 of file fra.h.

261 { ((Fra_Man_t *)pObj->pData)->pMemFraig[((Fra_Man_t *)pObj->pData)->nFramesAll*pObj->Id + i] = pNode; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static void Fra_ObjSetSatNum ( Aig_Obj_t pObj,
int  Num 
)
inlinestatic

Definition at line 267 of file fra.h.

267 { ((Fra_Man_t *)pObj->pData)->pMemSatNums[pObj->Id] = Num; }
void * pData
Definition: aig.h:87
int Id
Definition: aig.h:85
static unsigned* Fra_ObjSim ( Fra_Sml_t p,
int  Id 
)
inlinestatic

MACRO DEFINITIONS ///.

Definition at line 257 of file fra.h.

257 { return p->pData + p->nWordsTotal * Id; }
int nWordsTotal
Definition: fra.h:177
unsigned pData[0]
Definition: fra.h:182
void Fra_OneHotAddKnownConstraint ( Fra_Man_t p,
Vec_Ptr_t vOnehots 
)

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

Synopsis [Assumes one-hot implications in the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 439 of file fraHot.c.

440 {
441  Vec_Int_t * vGroup;
442  Aig_Obj_t * pObj1, * pObj2;
443  int k, i, j, Out1, Out2, pLits[2];
444  //
445  // these constrants should be added to different timeframes!
446  // (also note that PIs follow first - then registers)
447  //
448  Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vGroup, k )
449  {
450  Vec_IntForEachEntry( vGroup, Out1, i )
451  Vec_IntForEachEntryStart( vGroup, Out2, j, i+1 )
452  {
453  pObj1 = Aig_ManCi( p->pManFraig, Out1 );
454  pObj2 = Aig_ManCi( p->pManFraig, Out2 );
455  pLits[0] = toLitCond( Fra_ObjSatNum(pObj1), 1 );
456  pLits[1] = toLitCond( Fra_ObjSatNum(pObj2), 1 );
457  // add constraint to solver
458  if ( !sat_solver_addclause( p->pSat, pLits, pLits + 2 ) )
459  {
460  printf( "Fra_OneHotAddKnownConstraint(): Adding clause makes SAT solver unsat.\n" );
461  sat_solver_delete( p->pSat );
462  p->pSat = NULL;
463  return;
464  }
465  }
466  }
467 }
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
sat_solver * pSat
Definition: fra.h:210
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Aig_Man_t * pManFraig
Definition: fra.h:192
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static lit toLitCond(int v, int c)
Definition: satVec.h:143
Definition: aig.h:69
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Fra_OneHotAssume ( Fra_Man_t p,
Vec_Int_t vOneHots 
)

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

Synopsis [Assumes one-hot implications in the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file fraHot.c.

192 {
193  Aig_Obj_t * pObj1, * pObj2;
194  int i, Out1, Out2, pLits[2];
195  int nPiNum = Aig_ManCiNum(p->pManFraig) - Aig_ManRegNum(p->pManFraig);
196  assert( p->pPars->nFramesK == 1 ); // add to only one frame
197  for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
198  {
199  Out1 = Vec_IntEntry( vOneHots, i );
200  Out2 = Vec_IntEntry( vOneHots, i+1 );
201  if ( Out1 == 0 && Out2 == 0 )
202  continue;
203  pObj1 = Aig_ManCi( p->pManFraig, nPiNum + Fra_LitReg(Out1) );
204  pObj2 = Aig_ManCi( p->pManFraig, nPiNum + Fra_LitReg(Out2) );
205  pLits[0] = toLitCond( Fra_ObjSatNum(pObj1), Fra_LitSign(Out1) );
206  pLits[1] = toLitCond( Fra_ObjSatNum(pObj2), Fra_LitSign(Out2) );
207  // add constraint to solver
208  if ( !sat_solver_addclause( p->pSat, pLits, pLits + 2 ) )
209  {
210  printf( "Fra_OneHotAssume(): Adding clause makes SAT solver unsat.\n" );
211  sat_solver_delete( p->pSat );
212  p->pSat = NULL;
213  return;
214  }
215  }
216 }
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
Fra_Par_t * pPars
Definition: fra.h:189
sat_solver * pSat
Definition: fra.h:210
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Aig_Man_t * pManFraig
Definition: fra.h:192
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static lit toLitCond(int v, int c)
Definition: satVec.h:143
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Fra_LitReg(int n)
Definition: fraHot.c:31
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
#define assert(ex)
Definition: util_old.h:213
static int Fra_LitSign(int n)
Definition: fraHot.c:32
void Fra_OneHotCheck ( Fra_Man_t p,
Vec_Int_t vOneHots 
)

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

Synopsis [Checks one-hot implications.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file fraHot.c.

230 {
231  Aig_Obj_t * pObj1, * pObj2;
232  int RetValue, i, Out1, Out2;
233  int nTruePos = Aig_ManCoNum(p->pManFraig) - Aig_ManRegNum(p->pManFraig);
234  for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
235  {
236  Out1 = Vec_IntEntry( vOneHots, i );
237  Out2 = Vec_IntEntry( vOneHots, i+1 );
238  if ( Out1 == 0 && Out2 == 0 )
239  continue;
240  pObj1 = Aig_ManCo( p->pManFraig, nTruePos + Fra_LitReg(Out1) );
241  pObj2 = Aig_ManCo( p->pManFraig, nTruePos + Fra_LitReg(Out2) );
242  RetValue = Fra_NodesAreClause( p, pObj1, pObj2, Fra_LitSign(Out1), Fra_LitSign(Out2) );
243  if ( RetValue != 1 )
244  {
245  p->pCla->fRefinement = 1;
246  if ( RetValue == 0 )
247  Fra_SmlResimulate( p );
248  if ( Vec_IntEntry(vOneHots, i) != 0 )
249  printf( "Fra_OneHotCheck(): Clause is not refined!\n" );
250  assert( Vec_IntEntry(vOneHots, i) == 0 );
251  }
252  }
253 }
int fRefinement
Definition: fra.h:162
Fra_Cla_t * pCla
Definition: fra.h:198
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
Aig_Man_t * pManFraig
Definition: fra.h:192
int Fra_NodesAreClause(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
Definition: fraSat.c:317
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Fra_LitReg(int n)
Definition: fraHot.c:31
Definition: aig.h:69
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fra_SmlResimulate(Fra_Man_t *p)
Definition: fraSim.c:703
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static int Fra_LitSign(int n)
Definition: fraHot.c:32
Vec_Int_t* Fra_OneHotCompute ( Fra_Man_t p,
Fra_Sml_t pSim 
)

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

Synopsis [Computes one-hot implications.]

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file fraHot.c.

135 {
136  int fSkipConstEqu = 1;
137  Vec_Int_t * vOneHots;
138  Aig_Obj_t * pObj1, * pObj2;
139  int i, k;
140  int nTruePis = Aig_ManCiNum(pSim->pAig) - Aig_ManRegNum(pSim->pAig);
141  assert( pSim->pAig == p->pManAig );
142  vOneHots = Vec_IntAlloc( 100 );
143  Aig_ManForEachLoSeq( pSim->pAig, pObj1, i )
144  {
145  if ( fSkipConstEqu && Fra_OneHotNodeIsConst(pSim, pObj1) )
146  continue;
147  assert( i-nTruePis >= 0 );
148 // Aig_ManForEachLoSeq( pSim->pAig, pObj2, k )
149 // Vec_PtrForEachEntryStart( Aig_Obj_t *, pSim->pAig->vPis, pObj2, k, Aig_ManCiNum(p)-Aig_ManRegNum(p) )
150  Vec_PtrForEachEntryStart( Aig_Obj_t *, pSim->pAig->vCis, pObj2, k, i+1 )
151  {
152  if ( fSkipConstEqu && Fra_OneHotNodeIsConst(pSim, pObj2) )
153  continue;
154  if ( fSkipConstEqu && Fra_OneHotNodesAreEqual( pSim, pObj1, pObj2 ) )
155  continue;
156  assert( k-nTruePis >= 0 );
157  if ( Fra_OneHotNodesAreClause( pSim, pObj1, pObj2, 1, 1 ) )
158  {
159  Vec_IntPush( vOneHots, Fra_RegToLit(i-nTruePis, 1) );
160  Vec_IntPush( vOneHots, Fra_RegToLit(k-nTruePis, 1) );
161  continue;
162  }
163  if ( Fra_OneHotNodesAreClause( pSim, pObj1, pObj2, 0, 1 ) )
164  {
165  Vec_IntPush( vOneHots, Fra_RegToLit(i-nTruePis, 0) );
166  Vec_IntPush( vOneHots, Fra_RegToLit(k-nTruePis, 1) );
167  continue;
168  }
169  if ( Fra_OneHotNodesAreClause( pSim, pObj1, pObj2, 1, 0 ) )
170  {
171  Vec_IntPush( vOneHots, Fra_RegToLit(i-nTruePis, 1) );
172  Vec_IntPush( vOneHots, Fra_RegToLit(k-nTruePis, 0) );
173  continue;
174  }
175  }
176  }
177  return vOneHots;
178 }
Aig_Man_t * pManAig
Definition: fra.h:191
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
Aig_Man_t * pAig
Definition: fra.h:173
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Fra_OneHotNodesAreClause(Fra_Sml_t *pSeq, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2, int fCompl1, int fCompl2)
Definition: fraHot.c:94
static ABC_NAMESPACE_IMPL_START int Fra_RegToLit(int n, int c)
DECLARATIONS ///.
Definition: fraHot.c:30
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int Fra_OneHotNodesAreEqual(Fra_Sml_t *pSeq, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: fraHot.c:71
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
#define assert(ex)
Definition: util_old.h:213
int Fra_OneHotNodeIsConst(Fra_Sml_t *pSeq, Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: fraHot.c:49
int Fra_OneHotCount ( Fra_Man_t p,
Vec_Int_t vOneHots 
)

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

Synopsis [Removes those implications that no longer hold.]

Description [Returns 1 if refinement has happened.]

SideEffects []

SeeAlso []

Definition at line 303 of file fraHot.c.

304 {
305  int i, Out1, Out2, Counter = 0;
306  for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
307  {
308  Out1 = Vec_IntEntry( vOneHots, i );
309  Out2 = Vec_IntEntry( vOneHots, i+1 );
310  if ( Out1 == 0 && Out2 == 0 )
311  continue;
312  Counter++;
313  }
314  return Counter;
315 }
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Counter
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Aig_Man_t* Fra_OneHotCreateExdc ( Fra_Man_t p,
Vec_Int_t vOneHots 
)

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

Synopsis [Creates one-hotness EXDC.]

Description []

SideEffects []

SeeAlso []

Definition at line 398 of file fraHot.c.

399 {
400  Aig_Man_t * pNew;
401  Aig_Obj_t * pObj1, * pObj2, * pObj;
402  int i, Out1, Out2, nTruePis;
403  pNew = Aig_ManStart( Vec_IntSize(vOneHots)/2 );
404 // for ( i = 0; i < Aig_ManRegNum(p->pManAig); i++ )
405 // Aig_ObjCreateCi(pNew);
406  Aig_ManForEachCi( p->pManAig, pObj, i )
407  Aig_ObjCreateCi(pNew);
408  nTruePis = Aig_ManCiNum(p->pManAig) - Aig_ManRegNum(p->pManAig);
409  for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
410  {
411  Out1 = Vec_IntEntry( vOneHots, i );
412  Out2 = Vec_IntEntry( vOneHots, i+1 );
413  if ( Out1 == 0 && Out2 == 0 )
414  continue;
415  pObj1 = Aig_ManCi( pNew, nTruePis + Fra_LitReg(Out1) );
416  pObj2 = Aig_ManCi( pNew, nTruePis + Fra_LitReg(Out2) );
417  pObj1 = Aig_NotCond( pObj1, Fra_LitSign(Out1) );
418  pObj2 = Aig_NotCond( pObj2, Fra_LitSign(Out2) );
419  pObj = Aig_Or( pNew, pObj1, pObj2 );
420  Aig_ObjCreateCo( pNew, pObj );
421  }
422  Aig_ManCleanup(pNew);
423 // printf( "Created AIG with %d nodes and %d outputs.\n", Aig_ManNodeNum(pNew), Aig_ManCoNum(pNew) );
424  return pNew;
425 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
Aig_Man_t * pManAig
Definition: fra.h:191
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
for(p=first;p->value< newval;p=p->next)
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Fra_LitReg(int n)
Definition: fraHot.c:31
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:259
Definition: aig.h:69
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
static int Fra_LitSign(int n)
Definition: fraHot.c:32
void Fra_OneHotEstimateCoverage ( Fra_Man_t p,
Vec_Int_t vOneHots 
)

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

Synopsis [Estimates the coverage of state space by clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 328 of file fraHot.c.

329 {
330  int nSimWords = (1<<14);
331  int nRegs = Aig_ManRegNum(p->pManAig);
332  Vec_Ptr_t * vSimInfo;
333  unsigned * pSim1, * pSim2, * pSimTot;
334  int i, w, Out1, Out2, nCovered, Counter = 0;
335  abctime clk = Abc_Clock();
336 
337  // generate random sim-info at register outputs
338  vSimInfo = Vec_PtrAllocSimInfo( nRegs + 1, nSimWords );
339 // srand( 0xAABBAABB );
340  Aig_ManRandom(1);
341  for ( i = 0; i < nRegs; i++ )
342  {
343  pSim1 = (unsigned *)Vec_PtrEntry( vSimInfo, i );
344  for ( w = 0; w < nSimWords; w++ )
345  pSim1[w] = Fra_ObjRandomSim();
346  }
347  pSimTot = (unsigned *)Vec_PtrEntry( vSimInfo, nRegs );
348 
349  // collect simulation info
350  memset( pSimTot, 0, sizeof(unsigned) * nSimWords );
351  for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
352  {
353  Out1 = Vec_IntEntry( vOneHots, i );
354  Out2 = Vec_IntEntry( vOneHots, i+1 );
355  if ( Out1 == 0 && Out2 == 0 )
356  continue;
357 //printf( "(%c%d,%c%d) ",
358 //Fra_LitSign(Out1)? '-': '+', Fra_LitReg(Out1),
359 //Fra_LitSign(Out2)? '-': '+', Fra_LitReg(Out2) );
360  Counter++;
361  pSim1 = (unsigned *)Vec_PtrEntry( vSimInfo, Fra_LitReg(Out1) );
362  pSim2 = (unsigned *)Vec_PtrEntry( vSimInfo, Fra_LitReg(Out2) );
363  if ( Fra_LitSign(Out1) && Fra_LitSign(Out2) )
364  for ( w = 0; w < nSimWords; w++ )
365  pSimTot[w] |= pSim1[w] & pSim2[w];
366  else if ( Fra_LitSign(Out1) )
367  for ( w = 0; w < nSimWords; w++ )
368  pSimTot[w] |= pSim1[w] & ~pSim2[w];
369  else if ( Fra_LitSign(Out2) )
370  for ( w = 0; w < nSimWords; w++ )
371  pSimTot[w] |= ~pSim1[w] & pSim2[w];
372  else
373  assert( 0 );
374  }
375 //printf( "\n" );
376  // count the total number of patterns contained in the don't-care
377  nCovered = 0;
378  for ( w = 0; w < nSimWords; w++ )
379  nCovered += Aig_WordCountOnes( pSimTot[w] );
380  Vec_PtrFree( vSimInfo );
381  // print the result
382  printf( "Care states ratio = %f. ", 1.0 * (nSimWords * 32 - nCovered) / (nSimWords * 32) );
383  printf( "(%d out of %d patterns) ", nSimWords * 32 - nCovered, nSimWords * 32 );
384  ABC_PRT( "Time", Abc_Clock() - clk );
385 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * pManAig
Definition: fra.h:191
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Aig_WordCountOnes(unsigned uWord)
Definition: aig.h:229
static unsigned Fra_ObjRandomSim()
Definition: fra.h:258
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Fra_LitReg(int n)
Definition: fraHot.c:31
static int Counter
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
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 ABC_PRT(a, t)
Definition: abc_global.h:220
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Fra_LitSign(int n)
Definition: fraHot.c:32
static Vec_Ptr_t * Vec_PtrAllocSimInfo(int nEntries, int nWords)
Definition: vecPtr.h:929
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Fra_OneHotRefineUsingCex ( Fra_Man_t p,
Vec_Int_t vOneHots 
)

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

Synopsis [Removes those implications that no longer hold.]

Description [Returns 1 if refinement has happened.]

SideEffects []

SeeAlso []

Definition at line 266 of file fraHot.c.

267 {
268  Aig_Obj_t * pObj1, * pObj2;
269  int i, Out1, Out2, RetValue = 0;
270  int nPiNum = Aig_ManCiNum(p->pManAig) - Aig_ManRegNum(p->pManAig);
271  assert( p->pSml->pAig == p->pManAig );
272  for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
273  {
274  Out1 = Vec_IntEntry( vOneHots, i );
275  Out2 = Vec_IntEntry( vOneHots, i+1 );
276  if ( Out1 == 0 && Out2 == 0 )
277  continue;
278  // get the corresponding nodes
279  pObj1 = Aig_ManCi( p->pManAig, nPiNum + Fra_LitReg(Out1) );
280  pObj2 = Aig_ManCi( p->pManAig, nPiNum + Fra_LitReg(Out2) );
281  // check if implication holds using this simulation info
282  if ( !Fra_OneHotNodesAreClause( p->pSml, pObj1, pObj2, Fra_LitSign(Out1), Fra_LitSign(Out2) ) )
283  {
284  Vec_IntWriteEntry( vOneHots, i, 0 );
285  Vec_IntWriteEntry( vOneHots, i+1, 0 );
286  RetValue = 1;
287  }
288  }
289  return RetValue;
290 }
Aig_Man_t * pManAig
Definition: fra.h:191
Aig_Man_t * pAig
Definition: fra.h:173
Fra_Sml_t * pSml
Definition: fra.h:200
int Fra_OneHotNodesAreClause(Fra_Sml_t *pSeq, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2, int fCompl1, int fCompl2)
Definition: fraHot.c:94
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Fra_LitReg(int n)
Definition: fraHot.c:31
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
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 assert(ex)
Definition: util_old.h:213
static int Fra_LitSign(int n)
Definition: fraHot.c:32
void Fra_ParamsDefault ( Fra_Par_t pPars)

DECLARATIONS ///.

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

FileName [fraMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [Starts the FRAIG manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraMan.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

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

Synopsis [Sets the default solving parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file fraMan.c.

46 {
47  memset( pPars, 0, sizeof(Fra_Par_t) );
48  pPars->nSimWords = 32; // the number of words in the simulation info
49  pPars->dSimSatur = 0.005; // the ratio of refined classes when saturation is reached
50  pPars->fPatScores = 0; // enables simulation pattern scoring
51  pPars->MaxScore = 25; // max score after which resimulation is used
52  pPars->fDoSparse = 1; // skips sparse functions
53 // pPars->dActConeRatio = 0.05; // the ratio of cone to be bumped
54 // pPars->dActConeBumpMax = 5.0; // the largest bump of activity
55  pPars->dActConeRatio = 0.3; // the ratio of cone to be bumped
56  pPars->dActConeBumpMax = 10.0; // the largest bump of activity
57  pPars->nBTLimitNode = 100; // conflict limit at a node
58  pPars->nBTLimitMiter = 500000; // conflict limit at an output
59  pPars->nFramesK = 0; // the number of timeframes to unroll
60  pPars->fConeBias = 1;
61  pPars->fRewrite = 0;
62 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
void Fra_ParamsDefaultSeq ( Fra_Par_t pPars)

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

Synopsis [Sets the default solving parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file fraMan.c.

76 {
77  memset( pPars, 0, sizeof(Fra_Par_t) );
78  pPars->nSimWords = 1; // the number of words in the simulation info
79  pPars->dSimSatur = 0.005; // the ratio of refined classes when saturation is reached
80  pPars->fPatScores = 0; // enables simulation pattern scoring
81  pPars->MaxScore = 25; // max score after which resimulation is used
82  pPars->fDoSparse = 1; // skips sparse functions
83  pPars->dActConeRatio = 0.3; // the ratio of cone to be bumped
84  pPars->dActConeBumpMax = 10.0; // the largest bump of activity
85  pPars->nBTLimitNode = 10000000; // conflict limit at a node
86  pPars->nBTLimitMiter = 500000; // conflict limit at an output
87  pPars->nFramesK = 1; // the number of timeframes to unroll
88  pPars->fConeBias = 0;
89  pPars->fRewrite = 0;
90  pPars->fLatchCorr = 0;
91 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
void Fra_SecSetDefaultParams ( Fra_Sec_t p)

DECLARATIONS ///.

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

FileName [fraSec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [Performs SEC based on seq sweeping.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraSec.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file fraSec.c.

52 {
53  memset( p, 0, sizeof(Fra_Sec_t) );
54  p->fTryComb = 1; // try CEC call as a preprocessing step
55  p->fTryBmc = 1; // try BMC call as a preprocessing step
56  p->nFramesMax = 4; // the max number of frames used for induction
57  p->nBTLimit = 1000; // conflict limit at a node during induction
58  p->nBTLimitGlobal = 5000000; // global conflict limit during induction
59  p->nBTLimitInter = 10000; // conflict limit during interpolation
60  p->nBddVarsMax = 150; // the limit on the number of registers in BDD reachability
61  p->nBddMax = 50000; // the limit on the number of BDD nodes
62  p->nBddIterMax = 1000000; // the limit on the number of BDD iterations
63  p->fPhaseAbstract = 0; // enables phase abstraction
64  p->fRetimeFirst = 1; // enables most-forward retiming at the beginning
65  p->fRetimeRegs = 1; // enables min-register retiming at the beginning
66  p->fFraiging = 1; // enables fraiging at the beginning
67  p->fInduction = 1; // enables the use of induction (signal correspondence)
68  p->fInterpolation = 1; // enables interpolation
69  p->fInterSeparate = 0; // enables interpolation for each outputs separately
70  p->fReachability = 1; // enables BDD based reachability
71  p->fReorderImage = 1; // enables variable reordering during image computation
72  p->fStopOnFirstFail = 1; // enables stopping after first output of a miter has failed to prove
73  p->fUseNewProver = 0; // enables new prover
74  p->fUsePdr = 1; // enables PDR
75  p->nPdrTimeout = 60; // enabled PDR timeout
76  p->fSilent = 0; // disables all output
77  p->fVerbose = 0; // enables verbose reporting of statistics
78  p->fVeryVerbose = 0; // enables very verbose reporting
79  p->TimeLimit = 0; // enables the timeout
80  // internal parameters
81  p->fReportSolution = 0; // enables specialized format for reporting solution
82 }
char * memset()
int fFraiging
Definition: fra.h:129
int TimeLimit
Definition: fra.h:141
int fInterSeparate
Definition: fra.h:132
int fInduction
Definition: fra.h:130
int nBddMax
Definition: fra.h:123
int fUseNewProver
Definition: fra.h:136
int fReachability
Definition: fra.h:133
int nBddIterMax
Definition: fra.h:124
int nFramesMax
Definition: fra.h:118
int fReorderImage
Definition: fra.h:134
int fVerbose
Definition: fra.h:139
int fRetimeRegs
Definition: fra.h:128
int fVeryVerbose
Definition: fra.h:140
int fUsePdr
Definition: fra.h:137
int nBTLimitGlobal
Definition: fra.h:120
int fPhaseAbstract
Definition: fra.h:126
int fTryBmc
Definition: fra.h:117
int nBddVarsMax
Definition: fra.h:122
int nBTLimit
Definition: fra.h:119
int fTryComb
Definition: fra.h:116
int fInterpolation
Definition: fra.h:131
int nBTLimitInter
Definition: fra.h:121
int fReportSolution
Definition: fra.h:146
int fStopOnFirstFail
Definition: fra.h:135
int nPdrTimeout
Definition: fra.h:125
int fRetimeFirst
Definition: fra.h:127
int fSilent
Definition: fra.h:138
int Fra_SmlCheckOutput ( Fra_Man_t p)

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

Synopsis [Returns 1 if the one of the output is already non-constant 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 326 of file fraSim.c.

327 {
328  Aig_Obj_t * pObj;
329  int i;
330  // make sure the reference simulation pattern does not detect the bug
331  pObj = Aig_ManCo( p->pManAig, 0 );
332  assert( Aig_ObjFanin0(pObj)->fPhase == (unsigned)Aig_ObjFaninC0(pObj) );
333  Aig_ManForEachCo( p->pManAig, pObj, i )
334  {
335  if ( !Fra_SmlNodeIsConst( Aig_ObjFanin0(pObj) ) )
336  {
337  // create the counter-example from this pattern
339  return 1;
340  }
341  }
342  return 0;
343 }
Aig_Man_t * pManAig
Definition: fra.h:191
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
Definition: fraSim.c:86
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
Definition: aig.h:69
void Fra_SmlCheckOutputSavePattern(Fra_Man_t *p, Aig_Obj_t *pObjPo)
Definition: fraSim.c:281
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define assert(ex)
Definition: util_old.h:213
Abc_Cex_t* Fra_SmlCopyCounterExample ( Aig_Man_t pAig,
Aig_Man_t pFrames,
int *  pModel 
)

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

Synopsis [Generates seq counter-example from the combinational one.]

Description []

SideEffects []

SeeAlso []

Definition at line 1117 of file fraSim.c.

1118 {
1119  Abc_Cex_t * pCex;
1120  Aig_Obj_t * pObj;
1121  int i, nFrames, nTruePis, nTruePos, iPo, iFrame;
1122  // get the number of frames
1123  assert( Aig_ManRegNum(pAig) > 0 );
1124  assert( Aig_ManRegNum(pFrames) == 0 );
1125  nTruePis = Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig);
1126  nTruePos = Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig);
1127  nFrames = Aig_ManCiNum(pFrames) / nTruePis;
1128  assert( nTruePis * nFrames == Aig_ManCiNum(pFrames) );
1129  assert( nTruePos * nFrames == Aig_ManCoNum(pFrames) );
1130  // find the PO that failed
1131  iPo = -1;
1132  iFrame = -1;
1133  Aig_ManForEachCo( pFrames, pObj, i )
1134  if ( pObj->Id == pModel[Aig_ManCiNum(pFrames)] )
1135  {
1136  iPo = i % nTruePos;
1137  iFrame = i / nTruePos;
1138  break;
1139  }
1140  assert( iPo >= 0 );
1141  // allocate the counter example
1142  pCex = Abc_CexAlloc( Aig_ManRegNum(pAig), nTruePis, iFrame + 1 );
1143  pCex->iPo = iPo;
1144  pCex->iFrame = iFrame;
1145 
1146  // copy the bit data
1147  for ( i = 0; i < Aig_ManCiNum(pFrames); i++ )
1148  {
1149  if ( pModel[i] )
1150  Abc_InfoSetBit( pCex->pData, pCex->nRegs + i );
1151  if ( pCex->nRegs + i == pCex->nBits - 1 )
1152  break;
1153  }
1154 
1155  // verify the counter example
1156  if ( !Saig_ManVerifyCex( pAig, pCex ) )
1157  {
1158  printf( "Fra_SmlGetCounterExample(): Counter-example is invalid.\n" );
1159  Abc_CexFree( pCex );
1160  pCex = NULL;
1161  }
1162  return pCex;
1163 
1164 }
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition: utilCex.c:51
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition: saigDup.c:279
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
void Abc_CexFree(Abc_Cex_t *p)
Definition: utilCex.c:371
Abc_Cex_t* Fra_SmlGetCounterExample ( Fra_Sml_t p)

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

Synopsis [Creates sequential counter-example from the simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 1043 of file fraSim.c.

1044 {
1045  Abc_Cex_t * pCex;
1046  Aig_Obj_t * pObj;
1047  unsigned * pSims;
1048  int iPo, iFrame, iBit, i, k;
1049 
1050  // make sure the simulation manager has it
1051  assert( p->fNonConstOut );
1052 
1053  // find the first output that failed
1054  iPo = -1;
1055  iBit = -1;
1056  iFrame = -1;
1057  Aig_ManForEachPoSeq( p->pAig, pObj, iPo )
1058  {
1059  if ( Fra_SmlNodeIsZero(p, pObj) )
1060  continue;
1061  pSims = Fra_ObjSim( p, pObj->Id );
1062  for ( i = p->nWordsPref; i < p->nWordsTotal; i++ )
1063  if ( pSims[i] )
1064  {
1065  iFrame = i / p->nWordsFrame;
1066  iBit = 32 * (i % p->nWordsFrame) + Aig_WordFindFirstBit( pSims[i] );
1067  break;
1068  }
1069  break;
1070  }
1071  assert( iPo < Aig_ManCoNum(p->pAig)-Aig_ManRegNum(p->pAig) );
1072  assert( iFrame < p->nFrames );
1073  assert( iBit < 32 * p->nWordsFrame );
1074 
1075  // allocate the counter example
1076  pCex = Abc_CexAlloc( Aig_ManRegNum(p->pAig), Aig_ManCiNum(p->pAig) - Aig_ManRegNum(p->pAig), iFrame + 1 );
1077  pCex->iPo = iPo;
1078  pCex->iFrame = iFrame;
1079 
1080  // copy the bit data
1081  Aig_ManForEachLoSeq( p->pAig, pObj, k )
1082  {
1083  pSims = Fra_ObjSim( p, pObj->Id );
1084  if ( Abc_InfoHasBit( pSims, iBit ) )
1085  Abc_InfoSetBit( pCex->pData, k );
1086  }
1087  for ( i = 0; i <= iFrame; i++ )
1088  {
1089  Aig_ManForEachPiSeq( p->pAig, pObj, k )
1090  {
1091  pSims = Fra_ObjSim( p, pObj->Id );
1092  if ( Abc_InfoHasBit( pSims, 32 * p->nWordsFrame * i + iBit ) )
1093  Abc_InfoSetBit( pCex->pData, pCex->nRegs + pCex->nPis * i + k );
1094  }
1095  }
1096  // verify the counter example
1097  if ( !Saig_ManVerifyCex( p->pAig, pCex ) )
1098  {
1099  printf( "Fra_SmlGetCounterExample(): Counter-example is invalid.\n" );
1100  Abc_CexFree( pCex );
1101  pCex = NULL;
1102  }
1103  return pCex;
1104 }
int fNonConstOut
Definition: fra.h:179
Aig_Man_t * pAig
Definition: fra.h:173
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition: utilCex.c:51
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition: saigDup.c:279
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_WordFindFirstBit(unsigned uWord)
Definition: aig.h:237
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
int nWordsFrame
Definition: fra.h:176
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
int nWordsPref
Definition: fra.h:178
void Abc_CexFree(Abc_Cex_t *p)
Definition: utilCex.c:371
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition: aig.h:444
int Id
Definition: aig.h:85
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
int Fra_SmlNodeIsZero(Fra_Sml_t *p, Aig_Obj_t *pObj)
Definition: fraSim.c:155
int Fra_SmlNodeCountOnes ( Fra_Sml_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Counts the number of one's in the patten of the output.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file fraSim.c.

178 {
179  unsigned * pSims;
180  int i, Counter = 0;
181  pSims = Fra_ObjSim(p, pObj->Id);
182  for ( i = 0; i < p->nWordsTotal; i++ )
183  Counter += Aig_WordCountOnes( pSims[i] );
184  return Counter;
185 }
int nWordsTotal
Definition: fra.h:177
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
static int Aig_WordCountOnes(unsigned uWord)
Definition: aig.h:229
static int Counter
int Id
Definition: aig.h:85
int Fra_SmlNodeHash ( Aig_Obj_t pObj,
int  nTableSize 
)

DECLARATIONS ///.

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

FileName [fraSim.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraSim.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

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

Synopsis [Computes hash value of the node using its simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file fraSim.c.

47 {
48  Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
49  static int s_FPrimes[128] = {
50  1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
51  1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
52  2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
53  2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
54  3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
55  3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
56  4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
57  4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
58  5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
59  6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
60  6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
61  7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
62  8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
63  };
64  unsigned * pSims;
65  unsigned uHash;
66  int i;
67 // assert( p->pSml->nWordsTotal <= 128 );
68  uHash = 0;
69  pSims = Fra_ObjSim(p->pSml, pObj->Id);
70  for ( i = p->pSml->nWordsPref; i < p->pSml->nWordsTotal; i++ )
71  uHash ^= pSims[i] * s_FPrimes[i & 0x7F];
72  return uHash % nTableSize;
73 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: aig.h:87
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
int Id
Definition: aig.h:85
int Fra_SmlNodeIsConst ( Aig_Obj_t pObj)

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

Synopsis [Returns 1 if simulation info is composed of all zeros.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file fraSim.c.

87 {
88  Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
89  unsigned * pSims;
90  int i;
91  pSims = Fra_ObjSim(p->pSml, pObj->Id);
92  for ( i = p->pSml->nWordsPref; i < p->pSml->nWordsTotal; i++ )
93  if ( pSims[i] )
94  return 0;
95  return 1;
96 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: aig.h:87
Fra_Sml_t * pSml
Definition: fra.h:200
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
int nWordsPref
Definition: fra.h:178
int Id
Definition: aig.h:85
int Fra_SmlNodeNotEquWeight ( Fra_Sml_t p,
int  Left,
int  Right 
)

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

Synopsis [Counts the number of 1s in the XOR of simulation data.]

Description []

SideEffects []

SeeAlso []

Definition at line 133 of file fraSim.c.

134 {
135  unsigned * pSimL, * pSimR;
136  int k, Counter = 0;
137  pSimL = Fra_ObjSim( p, Left );
138  pSimR = Fra_ObjSim( p, Right );
139  for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
140  Counter += Aig_WordCountOnes( pSimL[k] ^ pSimR[k] );
141  return Counter;
142 }
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
static int Aig_WordCountOnes(unsigned uWord)
Definition: aig.h:229
static int Counter
int nWordsPref
Definition: fra.h:178
int Fra_SmlNodesAreEqual ( Aig_Obj_t pObj0,
Aig_Obj_t pObj1 
)

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

Synopsis [Returns 1 if simulation infos are equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file fraSim.c.

110 {
111  Fra_Man_t * p = (Fra_Man_t *)pObj0->pData;
112  unsigned * pSims0, * pSims1;
113  int i;
114  pSims0 = Fra_ObjSim(p->pSml, pObj0->Id);
115  pSims1 = Fra_ObjSim(p->pSml, pObj1->Id);
116  for ( i = p->pSml->nWordsPref; i < p->pSml->nWordsTotal; i++ )
117  if ( pSims0[i] != pSims1[i] )
118  return 0;
119  return 1;
120 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: aig.h:87
Fra_Sml_t * pSml
Definition: fra.h:200
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
int nWordsPref
Definition: fra.h:178
int Id
Definition: aig.h:85
void Fra_SmlResimulate ( Fra_Man_t p)

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

Synopsis [Resimulates fraiging manager after finding a counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 703 of file fraSim.c.

704 {
705  int nChanges;
706  abctime clk;
708  Fra_SmlSimulateOne( p->pSml );
709 // if ( p->pPars->fPatScores )
710 // Fra_CleanPatScores( p );
711  if ( p->pPars->fProve && Fra_SmlCheckOutput(p) )
712  return;
713 clk = Abc_Clock();
714  nChanges = Fra_ClassesRefine( p->pCla );
715  nChanges += Fra_ClassesRefine1( p->pCla, 1, NULL );
716  if ( p->pCla->vImps )
717  nChanges += Fra_ImpRefineUsingCex( p, p->pCla->vImps );
718  if ( p->vOneHots )
719  nChanges += Fra_OneHotRefineUsingCex( p, p->vOneHots );
720 p->timeRef += Abc_Clock() - clk;
721  if ( !p->pPars->nFramesK && nChanges < 1 )
722  printf( "Error: A counter-example did not refine classes!\n" );
723 // assert( nChanges >= 1 );
724 //printf( "Refined classes = %5d. Changes = %4d.\n", Vec_PtrSize(p->vClasses), nChanges );
725 }
int Fra_ImpRefineUsingCex(Fra_Man_t *p, Vec_Int_t *vImps)
Definition: fraImp.c:575
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition: fraClass.c:527
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
Fra_Sml_t * pSml
Definition: fra.h:200
Vec_Int_t * vOneHots
Definition: fra.h:208
static abctime Abc_Clock()
Definition: abc_global.h:279
void Fra_SmlSimulateOne(Fra_Sml_t *p)
Definition: fraSim.c:663
unsigned * pPatWords
Definition: fra.h:205
int Fra_SmlCheckOutput(Fra_Man_t *p)
Definition: fraSim.c:326
int Fra_OneHotRefineUsingCex(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:266
abctime timeRef
Definition: fra.h:247
void Fra_SmlAssignDist1(Fra_Sml_t *p, unsigned *pPat)
Definition: fraSim.c:433
Vec_Int_t * vImps
Definition: fra.h:163
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
ABC_INT64_T abctime
Definition: abc_global.h:278
void Fra_SmlSavePattern ( Fra_Man_t p)

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

Synopsis [Copy pattern from the solver into the internal storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file fraSim.c.

242 {
243  Aig_Obj_t * pObj;
244  int i;
245  memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
246  Aig_ManForEachCi( p->pManFraig, pObj, i )
247 // if ( p->pSat->model.ptr[Fra_ObjSatNum(pObj)] == l_True )
248  if ( sat_solver_var_value(p->pSat, Fra_ObjSatNum(pObj)) )
249  Abc_InfoSetBit( p->pPatWords, i );
250 
251  if ( p->vCex )
252  {
253  Vec_IntClear( p->vCex );
254  for ( i = 0; i < Aig_ManCiNum(p->pManAig) - Aig_ManRegNum(p->pManAig); i++ )
255  Vec_IntPush( p->vCex, Abc_InfoHasBit( p->pPatWords, i ) );
256  for ( i = Aig_ManCiNum(p->pManFraig) - Aig_ManRegNum(p->pManFraig); i < Aig_ManCiNum(p->pManFraig); i++ )
257  Vec_IntPush( p->vCex, Abc_InfoHasBit( p->pPatWords, i ) );
258  }
259 
260 /*
261  printf( "Pattern: " );
262  Aig_ManForEachCi( p->pManFraig, pObj, i )
263  printf( "%d", Abc_InfoHasBit( p->pPatWords, i ) );
264  printf( "\n" );
265 */
266 }
char * memset()
Aig_Man_t * pManAig
Definition: fra.h:191
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
unsigned * pPatWords
Definition: fra.h:205
Aig_Man_t * pManFraig
Definition: fra.h:192
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Vec_Int_t * vCex
Definition: fra.h:206
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
int nPatWords
Definition: fra.h:204
static int Fra_ObjSatNum(Aig_Obj_t *pObj)
Definition: fra.h:266
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Fra_SmlSimulate ( Fra_Man_t p,
int  fInit 
)

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

Synopsis [Performs simulation of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 738 of file fraSim.c.

739 {
740  int fVerbose = 0;
741  int nChanges, nClasses;
742  abctime clk;
743  assert( !fInit || Aig_ManRegNum(p->pManAig) );
744  // start the classes
745  Fra_SmlInitialize( p->pSml, fInit );
746  Fra_SmlSimulateOne( p->pSml );
747  if ( p->pPars->fProve && Fra_SmlCheckOutput(p) )
748  return;
749  Fra_ClassesPrepare( p->pCla, p->pPars->fLatchCorr, 0 );
750 // Fra_ClassesPrint( p->pCla, 0 );
751 if ( fVerbose )
752 printf( "Starting classes = %5d. Lits = %6d.\n", Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla) );
753 
754 //return;
755 
756  // refine classes by walking 0/1 patterns
757  Fra_SmlSavePattern0( p, fInit );
759  Fra_SmlSimulateOne( p->pSml );
760  if ( p->pPars->fProve && Fra_SmlCheckOutput(p) )
761  return;
762 clk = Abc_Clock();
763  nChanges = Fra_ClassesRefine( p->pCla );
764  nChanges += Fra_ClassesRefine1( p->pCla, 1, NULL );
765 p->timeRef += Abc_Clock() - clk;
766 if ( fVerbose )
767 printf( "Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(p->pCla->vClasses), nChanges, Fra_ClassesCountLits(p->pCla) );
768  Fra_SmlSavePattern1( p, fInit );
770  Fra_SmlSimulateOne( p->pSml );
771  if ( p->pPars->fProve && Fra_SmlCheckOutput(p) )
772  return;
773 clk = Abc_Clock();
774  nChanges = Fra_ClassesRefine( p->pCla );
775  nChanges += Fra_ClassesRefine1( p->pCla, 1, NULL );
776 p->timeRef += Abc_Clock() - clk;
777 
778 if ( fVerbose )
779 printf( "Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(p->pCla->vClasses), nChanges, Fra_ClassesCountLits(p->pCla) );
780  // refine classes by random simulation
781  do {
782  Fra_SmlInitialize( p->pSml, fInit );
783  Fra_SmlSimulateOne( p->pSml );
784  nClasses = Vec_PtrSize(p->pCla->vClasses);
785  if ( p->pPars->fProve && Fra_SmlCheckOutput(p) )
786  return;
787 clk = Abc_Clock();
788  nChanges = Fra_ClassesRefine( p->pCla );
789  nChanges += Fra_ClassesRefine1( p->pCla, 1, NULL );
790 p->timeRef += Abc_Clock() - clk;
791 if ( fVerbose )
792 printf( "Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(p->pCla->vClasses), nChanges, Fra_ClassesCountLits(p->pCla) );
793  } while ( (double)nChanges / nClasses > p->pPars->dSimSatur );
794 
795 // if ( p->pPars->fVerbose )
796 // printf( "Consts = %6d. Classes = %6d. Literals = %6d.\n",
797 // Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla) );
798 // Fra_ClassesPrint( p->pCla, 0 );
799 }
void Fra_SmlInitialize(Fra_Sml_t *p, int fInit)
Definition: fraSim.c:400
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition: fraClass.c:527
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
Vec_Ptr_t * vClasses
Definition: fra.h:154
Fra_Par_t * pPars
Definition: fra.h:189
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
Fra_Sml_t * pSml
Definition: fra.h:200
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Fra_SmlSimulateOne(Fra_Sml_t *p)
Definition: fraSim.c:663
unsigned * pPatWords
Definition: fra.h:205
void Fra_ClassesPrepare(Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
Definition: fraClass.c:276
int Fra_SmlCheckOutput(Fra_Man_t *p)
Definition: fraSim.c:326
abctime timeRef
Definition: fra.h:247
void Fra_SmlAssignDist1(Fra_Sml_t *p, unsigned *pPat)
Definition: fraSim.c:433
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
void Fra_SmlSavePattern1(Fra_Man_t *p, int fInit)
Definition: fraSim.c:216
void Fra_SmlSavePattern0(Fra_Man_t *p, int fInit)
Definition: fraSim.c:200
Fra_Sml_t* Fra_SmlSimulateComb ( Aig_Man_t pAig,
int  nWords,
int  fCheckMiter 
)

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

Synopsis [Performs simulation of the uninitialized circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 856 of file fraSim.c.

857 {
858  Fra_Sml_t * p;
859  p = Fra_SmlStart( pAig, 0, 1, nWords );
860  Fra_SmlInitialize( p, 0 );
861  Fra_SmlSimulateOne( p );
862  if ( fCheckMiter )
864  return p;
865 }
int fNonConstOut
Definition: fra.h:179
void Fra_SmlInitialize(Fra_Sml_t *p, int fInit)
Definition: fraSim.c:400
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Fra_SmlSimulateOne(Fra_Sml_t *p)
Definition: fraSim.c:663
int nWords
Definition: abcNpn.c:127
int Fra_SmlCheckNonConstOutputs(Fra_Sml_t *p)
Definition: fraSim.c:642
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: fraSim.c:813
Fra_Sml_t* Fra_SmlSimulateCombGiven ( Aig_Man_t pAig,
char *  pFileName,
int  fCheckMiter,
int  fVerbose 
)

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

Synopsis [Assigns simulation patters derived from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 981 of file fraSim.c.

982 {
983  Vec_Str_t * vSimInfo;
984  Fra_Sml_t * p;
985  int nPatterns;
986  assert( Aig_ManRegNum(pAig) == 0 );
987  // read comb patterns from file
988  vSimInfo = Fra_SmlSimulateReadFile( pFileName );
989  if ( vSimInfo == NULL )
990  return NULL;
991  if ( Vec_StrSize(vSimInfo) % Aig_ManCiNum(pAig) != 0 )
992  {
993  printf( "File \"%s\": The number of binary digits (%d) is not divisible by the number of primary inputs (%d).\n",
994  pFileName, Vec_StrSize(vSimInfo), Aig_ManCiNum(pAig) );
995  Vec_StrFree( vSimInfo );
996  return NULL;
997  }
998  p = Fra_SmlStart( pAig, 0, 1, Abc_BitWordNum(Vec_StrSize(vSimInfo) / Aig_ManCiNum(pAig)) );
999  Fra_SmlInitializeGiven( p, vSimInfo );
1000  nPatterns = Vec_StrSize(vSimInfo) / Aig_ManCiNum(pAig);
1001  Vec_StrFree( vSimInfo );
1002  Fra_SmlSimulateOne( p );
1003  if ( fCheckMiter )
1005  if ( fVerbose )
1006  Fra_SmlPrintOutputs( p, nPatterns );
1007  return p;
1008 }
int fNonConstOut
Definition: fra.h:179
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Fra_SmlSimulateOne(Fra_Sml_t *p)
Definition: fraSim.c:663
void Fra_SmlInitializeGiven(Fra_Sml_t *p, Vec_Str_t *vSimInfo)
Definition: fraSim.c:917
int Fra_SmlCheckNonConstOutputs(Fra_Sml_t *p)
Definition: fraSim.c:642
Vec_Str_t * Fra_SmlSimulateReadFile(char *pFileName)
Definition: fraSim.c:879
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
void Fra_SmlPrintOutputs(Fra_Sml_t *p, int nPatterns)
Definition: fraSim.c:954
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
#define assert(ex)
Definition: util_old.h:213
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: fraSim.c:813
Fra_Sml_t* Fra_SmlSimulateSeq ( Aig_Man_t pAig,
int  nPref,
int  nFrames,
int  nWords,
int  fCheckMiter 
)

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

Synopsis [Performs simulation of the initialized circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 1021 of file fraSim.c.

1022 {
1023  Fra_Sml_t * p;
1024  p = Fra_SmlStart( pAig, nPref, nFrames, nWords );
1025  Fra_SmlInitialize( p, 1 );
1026  Fra_SmlSimulateOne( p );
1027  if ( fCheckMiter )
1029  return p;
1030 }
int fNonConstOut
Definition: fra.h:179
void Fra_SmlInitialize(Fra_Sml_t *p, int fInit)
Definition: fraSim.c:400
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Fra_SmlSimulateOne(Fra_Sml_t *p)
Definition: fraSim.c:663
int nWords
Definition: abcNpn.c:127
int Fra_SmlCheckNonConstOutputs(Fra_Sml_t *p)
Definition: fraSim.c:642
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: fraSim.c:813
Fra_Sml_t* Fra_SmlStart ( Aig_Man_t pAig,
int  nPref,
int  nFrames,
int  nWordsFrame 
)

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

Synopsis [Allocates simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 813 of file fraSim.c.

814 {
815  Fra_Sml_t * p;
816  p = (Fra_Sml_t *)ABC_ALLOC( char, sizeof(Fra_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame );
817  memset( p, 0, sizeof(Fra_Sml_t) + sizeof(unsigned) * (nPref + nFrames) * nWordsFrame );
818  p->pAig = pAig;
819  p->nPref = nPref;
820  p->nFrames = nPref + nFrames;
821  p->nWordsFrame = nWordsFrame;
822  p->nWordsTotal = (nPref + nFrames) * nWordsFrame;
823  p->nWordsPref = nPref * nWordsFrame;
824  // constant 1 is initialized to 0 because we store values modulus phase (pObj->fPhase)
825  return p;
826 }
char * memset()
int nFrames
Definition: fra.h:175
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_Man_t * pAig
Definition: fra.h:173
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nWordsTotal
Definition: fra.h:177
int nWordsFrame
Definition: fra.h:176
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int nWordsPref
Definition: fra.h:178
int nPref
Definition: fra.h:174
void Fra_SmlStop ( Fra_Sml_t p)

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

Synopsis [Deallocates simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 839 of file fraSim.c.

840 {
841  ABC_FREE( p );
842 }
#define ABC_FREE(obj)
Definition: abc_global.h:232