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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Fra_SmlCountOnesOne (Fra_Sml_t *p, int Node)
 DECLARATIONS ///. More...
 
static int * Fra_SmlCountOnes (Fra_Sml_t *p)
 
static int Sml_NodeCheckImp (Fra_Sml_t *p, int Left, int Right)
 
static int Sml_NodeNotImpWeight (Fra_Sml_t *p, int Left, int Right)
 
static void Sml_NodeSaveNotImpPatterns (Fra_Sml_t *p, int Left, int Right, unsigned *pResult)
 
Vec_Ptr_tFra_SmlSortUsingOnes (Fra_Sml_t *p, int fLatchCorr)
 
Vec_Int_tFra_SmlSelectMaxCost (Vec_Int_t *vImps, int *pCosts, int nCostMax, int nImpLimit, int *pCostRange)
 
int Sml_CompareMaxId (unsigned short *pImp1, unsigned short *pImp2)
 
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)
 

Function Documentation

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
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
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
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
static int* Fra_SmlCountOnes ( Fra_Sml_t p)
inlinestatic

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

Synopsis [Counts the number of 1s in each siminfo of each node.]

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file fraImp.c.

67 {
68  Aig_Obj_t * pObj;
69  int i, * pnBits;
70  pnBits = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) );
71  memset( pnBits, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) );
72  Aig_ManForEachObj( p->pAig, pObj, i )
73  pnBits[i] = Fra_SmlCountOnesOne( p, i );
74  return pnBits;
75 }
char * memset()
Aig_Man_t * pAig
Definition: fra.h:173
static ABC_NAMESPACE_IMPL_START int Fra_SmlCountOnesOne(Fra_Sml_t *p, int Node)
DECLARATIONS ///.
Definition: fraImp.c:45
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static ABC_NAMESPACE_IMPL_START int Fra_SmlCountOnesOne ( Fra_Sml_t p,
int  Node 
)
inlinestatic

DECLARATIONS ///.

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

FileName [fraImp.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [Detecting and proving implications.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Counts the number of 1s in each siminfo of each node.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file fraImp.c.

46 {
47  unsigned * pSim;
48  int k, Counter = 0;
49  pSim = Fra_ObjSim( p, Node );
50  for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
51  Counter += Aig_WordCountOnes( pSim[k] );
52  return Counter;
53 }
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
Vec_Int_t* Fra_SmlSelectMaxCost ( Vec_Int_t vImps,
int *  pCosts,
int  nCostMax,
int  nImpLimit,
int *  pCostRange 
)

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

Synopsis [Returns the array of implications with the highest cost.]

Description []

SideEffects []

SeeAlso []

Definition at line 244 of file fraImp.c.

245 {
246  Vec_Int_t * vImpsNew;
247  int * pCostCount, nImpCount, Imp, i, c;
248  assert( Vec_IntSize(vImps) >= nImpLimit );
249  // count how many implications have each cost
250  pCostCount = ABC_ALLOC( int, nCostMax + 1 );
251  memset( pCostCount, 0, sizeof(int) * (nCostMax + 1) );
252  for ( i = 0; i < Vec_IntSize(vImps); i++ )
253  {
254  assert( pCosts[i] <= nCostMax );
255  pCostCount[ pCosts[i] ]++;
256  }
257  assert( pCostCount[0] == 0 );
258  // select the bound on the cost (above this bound, implication will be included)
259  nImpCount = 0;
260  for ( c = nCostMax; c > 0; c-- )
261  {
262  nImpCount += pCostCount[c];
263  if ( nImpCount >= nImpLimit )
264  break;
265  }
266 // printf( "Cost range >= %d.\n", c );
267  // collect implications with the given costs
268  vImpsNew = Vec_IntAlloc( nImpLimit );
269  Vec_IntForEachEntry( vImps, Imp, i )
270  {
271  if ( pCosts[i] < c )
272  continue;
273  Vec_IntPush( vImpsNew, Imp );
274  if ( Vec_IntSize( vImpsNew ) == nImpLimit )
275  break;
276  }
277  ABC_FREE( pCostCount );
278  if ( pCostRange )
279  *pCostRange = c;
280  return vImpsNew;
281 }
char * memset()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Vec_Ptr_t* Fra_SmlSortUsingOnes ( Fra_Sml_t p,
int  fLatchCorr 
)

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

Synopsis [Returns the array of nodes sorted by the number of 1s.]

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file fraImp.c.

155 {
156  Aig_Obj_t * pObj;
157  Vec_Ptr_t * vNodes;
158  int i, nNodes, nTotal, nBits, * pnNodes, * pnBits, * pMemory;
159  assert( p->nWordsTotal > 0 );
160  // count 1s in each node's siminfo
161  pnBits = Fra_SmlCountOnes( p );
162  // count number of nodes having that many 1s
163  nNodes = 0;
164  nBits = p->nWordsTotal * 32;
165  pnNodes = ABC_ALLOC( int, nBits + 1 );
166  memset( pnNodes, 0, sizeof(int) * (nBits + 1) );
167  Aig_ManForEachObj( p->pAig, pObj, i )
168  {
169  if ( i == 0 ) continue;
170  // skip non-PI and non-internal nodes
171  if ( fLatchCorr )
172  {
173  if ( !Aig_ObjIsCi(pObj) )
174  continue;
175  }
176  else
177  {
178  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
179  continue;
180  }
181  // skip nodes participating in the classes
182 // if ( Fra_ClassObjRepr(pObj) )
183 // continue;
184  assert( pnBits[i] <= nBits ); // "<" because of normalized info
185  pnNodes[pnBits[i]]++;
186  nNodes++;
187  }
188  // allocate memory for all the nodes
189  pMemory = ABC_ALLOC( int, nNodes + nBits + 1 );
190  // markup the memory for each node
191  vNodes = Vec_PtrAlloc( nBits + 1 );
192  Vec_PtrPush( vNodes, pMemory );
193  for ( i = 1; i <= nBits; i++ )
194  {
195  pMemory += pnNodes[i-1] + 1;
196  Vec_PtrPush( vNodes, pMemory );
197  }
198  // add the nodes
199  memset( pnNodes, 0, sizeof(int) * (nBits + 1) );
200  Aig_ManForEachObj( p->pAig, pObj, i )
201  {
202  if ( i == 0 ) continue;
203  // skip non-PI and non-internal nodes
204  if ( fLatchCorr )
205  {
206  if ( !Aig_ObjIsCi(pObj) )
207  continue;
208  }
209  else
210  {
211  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
212  continue;
213  }
214  // skip nodes participating in the classes
215 // if ( Fra_ClassObjRepr(pObj) )
216 // continue;
217  pMemory = (int *)Vec_PtrEntry( vNodes, pnBits[i] );
218  pMemory[ pnNodes[pnBits[i]]++ ] = i;
219  }
220  // add 0s in the end
221  nTotal = 0;
222  Vec_PtrForEachEntry( int *, vNodes, pMemory, i )
223  {
224  pMemory[ pnNodes[i]++ ] = 0;
225  nTotal += pnNodes[i];
226  }
227  assert( nTotal == nNodes + nBits + 1 );
228  ABC_FREE( pnNodes );
229  ABC_FREE( pnBits );
230  return vNodes;
231 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int * Fra_SmlCountOnes(Fra_Sml_t *p)
Definition: fraImp.c:66
Aig_Man_t * pAig
Definition: fra.h:173
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nWordsTotal
Definition: fra.h:177
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
Definition: aig.h:69
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
int Sml_CompareMaxId ( unsigned short *  pImp1,
unsigned short *  pImp2 
)

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

Synopsis [Compares two implications using their largest ID.]

Description []

SideEffects []

SeeAlso []

Definition at line 294 of file fraImp.c.

295 {
296  int Max1 = Abc_MaxInt( pImp1[0], pImp1[1] );
297  int Max2 = Abc_MaxInt( pImp2[0], pImp2[1] );
298  if ( Max1 < Max2 )
299  return -1;
300  if ( Max1 > Max2 )
301  return 1;
302  return 0;
303 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Sml_NodeCheckImp ( Fra_Sml_t p,
int  Left,
int  Right 
)
inlinestatic

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

Synopsis [Returns 1 if implications holds.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file fraImp.c.

89 {
90  unsigned * pSimL, * pSimR;
91  int k;
92  pSimL = Fra_ObjSim( p, Left );
93  pSimR = Fra_ObjSim( p, Right );
94  for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
95  if ( pSimL[k] & ~pSimR[k] )
96  return 0;
97  return 1;
98 }
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
int nWordsPref
Definition: fra.h:178
static int Sml_NodeNotImpWeight ( Fra_Sml_t p,
int  Left,
int  Right 
)
inlinestatic

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

Synopsis [Counts the number of 1s in the complement of the implication.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file fraImp.c.

112 {
113  unsigned * pSimL, * pSimR;
114  int k, Counter = 0;
115  pSimL = Fra_ObjSim( p, Left );
116  pSimR = Fra_ObjSim( p, Right );
117  for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
118  Counter += Aig_WordCountOnes( pSimL[k] & ~pSimR[k] );
119  return Counter;
120 }
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
static void Sml_NodeSaveNotImpPatterns ( Fra_Sml_t p,
int  Left,
int  Right,
unsigned *  pResult 
)
inlinestatic

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

Synopsis [Computes the complement of the implication.]

Description []

SideEffects []

SeeAlso []

Definition at line 133 of file fraImp.c.

134 {
135  unsigned * pSimL, * pSimR;
136  int k;
137  pSimL = Fra_ObjSim( p, Left );
138  pSimR = Fra_ObjSim( p, Right );
139  for ( k = p->nWordsPref; k < p->nWordsTotal; k++ )
140  pResult[k] |= pSimL[k] & ~pSimR[k];
141 }
static unsigned * Fra_ObjSim(Fra_Sml_t *p, int Id)
MACRO DEFINITIONS ///.
Definition: fra.h:257
int nWordsPref
Definition: fra.h:178