abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dchInt.h File Reference
#include "aig/aig/aig.h"
#include "sat/bsat/satSolver.h"
#include "dch.h"

Go to the source code of this file.

Data Structures

struct  Dch_Man_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Dch_Cla_t_ 
Dch_Cla_t
 INCLUDES ///. More...
 
typedef struct Dch_Man_t_ Dch_Man_t
 

Functions

static int Dch_ObjSatNum (Dch_Man_t *p, Aig_Obj_t *pObj)
 MACRO DEFINITIONS ///. More...
 
static void Dch_ObjSetSatNum (Dch_Man_t *p, Aig_Obj_t *pObj, int Num)
 
static Aig_Obj_tDch_ObjFraig (Aig_Obj_t *pObj)
 
static void Dch_ObjSetFraig (Aig_Obj_t *pObj, Aig_Obj_t *pNode)
 
static int Dch_ObjIsConst1Cand (Aig_Man_t *pAig, Aig_Obj_t *pObj)
 
static void Dch_ObjSetConst1Cand (Aig_Man_t *pAig, Aig_Obj_t *pObj)
 
int Dch_DeriveChoiceCountReprs (Aig_Man_t *pAig)
 FUNCTION DECLARATIONS ///. More...
 
int Dch_DeriveChoiceCountEquivs (Aig_Man_t *pAig)
 
Aig_Man_tDch_DeriveChoiceAig (Aig_Man_t *pAig, int fSkipRedSupps)
 
Dch_Cla_tDch_ClassesStart (Aig_Man_t *pAig)
 
void Dch_ClassesSetData (Dch_Cla_t *p, void *pManData, unsigned(*pFuncNodeHash)(void *, Aig_Obj_t *), int(*pFuncNodeIsConst)(void *, Aig_Obj_t *), int(*pFuncNodesAreEqual)(void *, Aig_Obj_t *, Aig_Obj_t *))
 
void Dch_ClassesStop (Dch_Cla_t *p)
 
int Dch_ClassesLitNum (Dch_Cla_t *p)
 
Aig_Obj_t ** Dch_ClassesReadClass (Dch_Cla_t *p, Aig_Obj_t *pRepr, int *pnSize)
 
void Dch_ClassesPrint (Dch_Cla_t *p, int fVeryVerbose)
 
void Dch_ClassesPrepare (Dch_Cla_t *p, int fLatchCorr, int nMaxLevs)
 
int Dch_ClassesRefine (Dch_Cla_t *p)
 
int Dch_ClassesRefineOneClass (Dch_Cla_t *p, Aig_Obj_t *pRepr, int fRecursive)
 
void Dch_ClassesCollectOneClass (Dch_Cla_t *p, Aig_Obj_t *pRepr, Vec_Ptr_t *vRoots)
 
void Dch_ClassesCollectConst1Group (Dch_Cla_t *p, Aig_Obj_t *pObj, int nNodes, Vec_Ptr_t *vRoots)
 
int Dch_ClassesRefineConst1Group (Dch_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
 
void Dch_CnfNodeAddToSolver (Dch_Man_t *p, Aig_Obj_t *pObj)
 
Dch_Man_tDch_ManCreate (Aig_Man_t *pAig, Dch_Pars_t *pPars)
 DECLARATIONS ///. More...
 
void Dch_ManStop (Dch_Man_t *p)
 
void Dch_ManSatSolverRecycle (Dch_Man_t *p)
 
int Dch_NodesAreEquiv (Dch_Man_t *p, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2)
 DECLARATIONS ///. More...
 
Dch_Cla_tDch_CreateCandEquivClasses (Aig_Man_t *pAig, int nWords, int fVerbose)
 
void Dch_ManResimulateCex (Dch_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
 
void Dch_ManResimulateCex2 (Dch_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
 
void Dch_ManSweep (Dch_Man_t *p)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Dch_Cla_t_ Dch_Cla_t

INCLUDES ///.

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

FileName [dchInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Choice computation for tech-mapping.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 29, 2008.]

Revision [

Id:
dchInt.h,v 1.00 2008/07/29 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 47 of file dchInt.h.

typedef struct Dch_Man_t_ Dch_Man_t

Definition at line 50 of file dchInt.h.

Function Documentation

void Dch_ClassesCollectConst1Group ( Dch_Cla_t p,
Aig_Obj_t pObj,
int  nNodes,
Vec_Ptr_t vRoots 
)

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

Synopsis [Returns equivalence class of the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 546 of file dchClass.c.

547 {
548  int i, Limit;
549  Vec_PtrClear( vRoots );
550  Limit = Abc_MinInt( pObj->Id + nNodes, Aig_ManObjNumMax(p->pAig) );
551  for ( i = pObj->Id; i < Limit; i++ )
552  {
553  pObj = Aig_ManObj( p->pAig, i );
554  if ( pObj && Dch_ObjIsConst1Cand( p->pAig, pObj ) )
555  Vec_PtrPush( vRoots, pObj );
556  }
557 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Dch_ObjIsConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
Definition: dchInt.h:108
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
int Id
Definition: aig.h:85
void Dch_ClassesCollectOneClass ( Dch_Cla_t p,
Aig_Obj_t pRepr,
Vec_Ptr_t vRoots 
)

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

Synopsis [Returns equivalence class of the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 525 of file dchClass.c.

526 {
527  Aig_Obj_t * pObj;
528  int i;
529  Vec_PtrClear( vRoots );
530  Dch_ClassForEachNode( p, pRepr, pObj, i )
531  Vec_PtrPush( vRoots, pObj );
532  assert( Vec_PtrSize(vRoots) > 1 );
533 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
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
#define Dch_ClassForEachNode(p, pRepr, pNode, i)
Definition: dchClass.c:71
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
int Dch_ClassesLitNum ( Dch_Cla_t p)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file dchClass.c.

207 {
208  return p->nLits;
209 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Dch_ClassesPrepare ( Dch_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 336 of file dchClass.c.

337 {
338  Aig_Obj_t ** ppTable, ** ppNexts, ** ppClassNew;
339  Aig_Obj_t * pObj, * pTemp, * pRepr;
340  int i, k, nTableSize, nNodes, iEntry, nEntries, nEntries2;
341 
342  // allocate the hash table hashing simulation info into nodes
343  nTableSize = Abc_PrimeCudd( Aig_ManObjNumMax(p->pAig)/4 );
344  ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
345  ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
346 
347  // add all the nodes to the hash table
348  nEntries = 0;
349  Aig_ManForEachObj( p->pAig, pObj, i )
350  {
351  if ( fLatchCorr )
352  {
353  if ( !Aig_ObjIsCi(pObj) )
354  continue;
355  }
356  else
357  {
358  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
359  continue;
360  // skip the node with more that the given number of levels
361  if ( nMaxLevs && (int)pObj->Level >= nMaxLevs )
362  continue;
363  }
364  // check if the node belongs to the class of constant 1
365  if ( p->pFuncNodeIsConst( p->pManData, pObj ) )
366  {
367  Dch_ObjSetConst1Cand( p->pAig, pObj );
368  p->nCands1++;
369  continue;
370  }
371  // hash the node by its simulation info
372  iEntry = p->pFuncNodeHash( p->pManData, pObj ) % nTableSize;
373  // add the node to the class
374  if ( ppTable[iEntry] == NULL )
375  ppTable[iEntry] = pObj;
376  else
377  {
378  // set the representative of this node
379  pRepr = ppTable[iEntry];
380  Aig_ObjSetRepr( p->pAig, pObj, pRepr );
381  // add node to the table
382  if ( Dch_ObjNext( ppNexts, pRepr ) == NULL )
383  { // this will be the second entry
384  p->pClassSizes[pRepr->Id]++;
385  nEntries++;
386  }
387  // add the entry to the list
388  Dch_ObjSetNext( ppNexts, pObj, Dch_ObjNext( ppNexts, pRepr ) );
389  Dch_ObjSetNext( ppNexts, pRepr, pObj );
390  p->pClassSizes[pRepr->Id]++;
391  nEntries++;
392  }
393  }
394 
395  // allocate room for classes
396  p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, nEntries + p->nCands1 );
397  p->pMemClassesFree = p->pMemClasses + nEntries;
398 
399  // copy the entries into storage in the topological order
400  nEntries2 = 0;
401  Aig_ManForEachObj( p->pAig, pObj, i )
402  {
403  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
404  continue;
405  nNodes = p->pClassSizes[pObj->Id];
406  // skip the nodes that are not representatives of non-trivial classes
407  if ( nNodes == 0 )
408  continue;
409  assert( nNodes > 1 );
410  // add the nodes to the class in the topological order
411  ppClassNew = p->pMemClasses + nEntries2;
412  ppClassNew[0] = pObj;
413  for ( pTemp = Dch_ObjNext(ppNexts, pObj), k = 1; pTemp;
414  pTemp = Dch_ObjNext(ppNexts, pTemp), k++ )
415  {
416  ppClassNew[nNodes-k] = pTemp;
417  }
418  // add the class of nodes
419  p->pClassSizes[pObj->Id] = 0;
420  Dch_ObjAddClass( p, pObj, ppClassNew, nNodes );
421  // increment the number of entries
422  nEntries2 += nNodes;
423  }
424  assert( nEntries == nEntries2 );
425  ABC_FREE( ppTable );
426  ABC_FREE( ppNexts );
427  // now it is time to refine the classes
428  Dch_ClassesRefine( p );
429  Dch_ClassesCheck( p );
430 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
unsigned Level
Definition: aig.h:82
Aig_Man_t * pAig
Definition: llb3Image.c:49
static void Dch_ObjSetConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
Definition: dchInt.h:112
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Dch_ObjAddClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, Aig_Obj_t **pClass, int nSize)
FUNCTION DEFINITIONS ///.
Definition: dchClass.c:90
static Aig_Obj_t * Dch_ObjNext(Aig_Obj_t **ppNexts, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: dchClass.c:63
int Dch_ClassesRefine(Dch_Cla_t *p)
Definition: dchClass.c:504
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static void Aig_ObjSetRepr(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
Definition: aig.h:331
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
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Dch_ClassesCheck(Dch_Cla_t *p)
Definition: dchClass.c:241
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Dch_ObjSetNext(Aig_Obj_t **ppNexts, Aig_Obj_t *pObj, Aig_Obj_t *pNext)
Definition: dchClass.c:64
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Id
Definition: aig.h:85
void Dch_ClassesPrint ( Dch_Cla_t p,
int  fVeryVerbose 
)

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 303 of file dchClass.c.

304 {
305  Aig_Obj_t ** ppClass;
306  Aig_Obj_t * pObj;
307  int i;
308  Abc_Print( 1, "Equivalence classes: Const1 = %5d. Class = %5d. Lit = %5d.\n",
309  p->nCands1, p->nClasses, p->nLits );
310  if ( !fVeryVerbose )
311  return;
312  Abc_Print( 1, "Constants { " );
313  Aig_ManForEachObj( p->pAig, pObj, i )
314  if ( Dch_ObjIsConst1Cand( p->pAig, pObj ) )
315  Abc_Print( 1, "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
316  Abc_Print( 1, "}\n" );
317  Dch_ManForEachClass( p, ppClass, i )
318  {
319  Abc_Print( 1, "%3d (%3d) : ", i, p->pClassSizes[i] );
320  Dch_ClassesPrintOne( p, ppClass[0] );
321  }
322  Abc_Print( 1, "\n" );
323 }
#define Dch_ManForEachClass(p, ppClass, i)
Definition: dchClass.c:67
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Dch_ObjIsConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
Definition: dchInt.h:108
int Aig_SupportSize(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigDfs.c:758
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Dch_ClassesPrintOne(Dch_Cla_t *p, Aig_Obj_t *pRepr)
Definition: dchClass.c:282
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
Aig_Obj_t** Dch_ClassesReadClass ( Dch_Cla_t p,
Aig_Obj_t pRepr,
int *  pnSize 
)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 222 of file dchClass.c.

223 {
224  assert( p->pId2Class[pRepr->Id] != NULL );
225  assert( p->pClassSizes[pRepr->Id] > 1 );
226  *pnSize = p->pClassSizes[pRepr->Id];
227  return p->pId2Class[pRepr->Id];
228 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
int Dch_ClassesRefine ( Dch_Cla_t p)

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

Synopsis [Refines the classes after simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 504 of file dchClass.c.

505 {
506  Aig_Obj_t ** ppClass;
507  int i, nRefis = 0;
508  Dch_ManForEachClass( p, ppClass, i )
509  nRefis += Dch_ClassesRefineOneClass( p, ppClass[0], 0 );
510  return nRefis;
511 }
#define Dch_ManForEachClass(p, ppClass, i)
Definition: dchClass.c:67
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
Definition: aig.h:69
int Dch_ClassesRefineConst1Group ( Dch_Cla_t p,
Vec_Ptr_t vRoots,
int  fRecursive 
)

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

Synopsis [Refine the group of constant 1 nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 570 of file dchClass.c.

571 {
572  Aig_Obj_t * pObj, * pReprNew, ** ppClassNew;
573  int i;
574  if ( Vec_PtrSize(vRoots) == 0 )
575  return 0;
576  // collect the nodes to be refined
577  Vec_PtrClear( p->vClassNew );
578  Vec_PtrForEachEntry( Aig_Obj_t *, vRoots, pObj, i )
579  if ( !p->pFuncNodeIsConst( p->pManData, pObj ) )
580  Vec_PtrPush( p->vClassNew, pObj );
581  // check if there is a new class
582  if ( Vec_PtrSize(p->vClassNew) == 0 )
583  return 0;
584  p->nCands1 -= Vec_PtrSize(p->vClassNew);
585  pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
586  Aig_ObjSetRepr( p->pAig, pReprNew, NULL );
587  if ( Vec_PtrSize(p->vClassNew) == 1 )
588  return 1;
589  // create a new class composed of these nodes
590  ppClassNew = p->pMemClassesFree;
591  p->pMemClassesFree += Vec_PtrSize(p->vClassNew);
592  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
593  {
594  ppClassNew[i] = pObj;
595  Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
596  }
597  Dch_ObjAddClass( p, pReprNew, ppClassNew, Vec_PtrSize(p->vClassNew) );
598  // refine them recursively
599  if ( fRecursive )
600  return 1 + Dch_ClassesRefineOneClass( p, pReprNew, 1 );
601  return 1;
602 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Dch_ObjAddClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, Aig_Obj_t **pClass, int nSize)
FUNCTION DEFINITIONS ///.
Definition: dchClass.c:90
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
static void Aig_ObjSetRepr(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
Definition: aig.h:331
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
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 Dch_ClassesRefineOneClass ( Dch_Cla_t p,
Aig_Obj_t pReprOld,
int  fRecursive 
)

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

Synopsis [Iteratively refines the classes after simulation.]

Description [Returns the number of refinements performed.]

SideEffects []

SeeAlso []

Definition at line 443 of file dchClass.c.

444 {
445  Aig_Obj_t ** pClassOld, ** pClassNew;
446  Aig_Obj_t * pObj, * pReprNew;
447  int i;
448 
449  // split the class
450  Vec_PtrClear( p->vClassOld );
451  Vec_PtrClear( p->vClassNew );
452  Dch_ClassForEachNode( p, pReprOld, pObj, i )
453  if ( p->pFuncNodesAreEqual(p->pManData, pReprOld, pObj) )
454  Vec_PtrPush( p->vClassOld, pObj );
455  else
456  Vec_PtrPush( p->vClassNew, pObj );
457  // check if splitting happened
458  if ( Vec_PtrSize(p->vClassNew) == 0 )
459  return 0;
460 
461  // get the new representative
462  pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
463  assert( Vec_PtrSize(p->vClassOld) > 0 );
464  assert( Vec_PtrSize(p->vClassNew) > 0 );
465 
466  // create old class
467  pClassOld = Dch_ObjRemoveClass( p, pReprOld );
468  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
469  {
470  pClassOld[i] = pObj;
471  Aig_ObjSetRepr( p->pAig, pObj, i? pReprOld : NULL );
472  }
473  // create new class
474  pClassNew = pClassOld + i;
475  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
476  {
477  pClassNew[i] = pObj;
478  Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
479  }
480 
481  // put classes back
482  if ( Vec_PtrSize(p->vClassOld) > 1 )
483  Dch_ObjAddClass( p, pReprOld, pClassOld, Vec_PtrSize(p->vClassOld) );
484  if ( Vec_PtrSize(p->vClassNew) > 1 )
485  Dch_ObjAddClass( p, pReprNew, pClassNew, Vec_PtrSize(p->vClassNew) );
486 
487  // check if the class should be recursively refined
488  if ( fRecursive && Vec_PtrSize(p->vClassNew) > 1 )
489  return 1 + Dch_ClassesRefineOneClass( p, pReprNew, 1 );
490  return 1;
491 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Aig_Obj_t ** Dch_ObjRemoveClass(Dch_Cla_t *p, Aig_Obj_t *pRepr)
Definition: dchClass.c:112
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Dch_ObjAddClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, Aig_Obj_t **pClass, int nSize)
FUNCTION DEFINITIONS ///.
Definition: dchClass.c:90
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
static void Aig_ObjSetRepr(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
Definition: aig.h:331
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
#define Dch_ClassForEachNode(p, pRepr, pNode, i)
Definition: dchClass.c:71
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Definition: aig.h:69
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#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
void Dch_ClassesSetData ( Dch_Cla_t p,
void *  pManData,
unsigned(*)(void *, Aig_Obj_t *)  pFuncNodeHash,
int(*)(void *, Aig_Obj_t *)  pFuncNodeIsConst,
int(*)(void *, Aig_Obj_t *, Aig_Obj_t *)  pFuncNodesAreEqual 
)

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file dchClass.c.

167 {
168  p->pManData = pManData;
169  p->pFuncNodeHash = pFuncNodeHash;
170  p->pFuncNodeIsConst = pFuncNodeIsConst;
171  p->pFuncNodesAreEqual = pFuncNodesAreEqual;
172 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Dch_Cla_t* Dch_ClassesStart ( Aig_Man_t pAig)

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 137 of file dchClass.c.

138 {
139  Dch_Cla_t * p;
140  p = ABC_ALLOC( Dch_Cla_t, 1 );
141  memset( p, 0, sizeof(Dch_Cla_t) );
142  p->pAig = pAig;
143  p->pId2Class = ABC_CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) );
144  p->pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) );
145  p->vClassOld = Vec_PtrAlloc( 100 );
146  p->vClassNew = Vec_PtrAlloc( 100 );
147  assert( pAig->pReprs == NULL );
148  Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
149  return p;
150 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
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
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Dch_Cla_t_ Dch_Cla_t
INCLUDES ///.
Definition: dchInt.h:47
void Dch_ClassesStop ( Dch_Cla_t p)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file dchClass.c.

186 {
187  if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
188  if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
189  ABC_FREE( p->pId2Class );
190  ABC_FREE( p->pClassSizes );
191  ABC_FREE( p->pMemClasses );
192  ABC_FREE( p );
193 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Dch_CnfNodeAddToSolver ( Dch_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Updates the solver clause database.]

Description []

SideEffects []

SeeAlso []

Definition at line 287 of file dchCnf.c.

288 {
289  Vec_Ptr_t * vFrontier;
290  Aig_Obj_t * pNode, * pFanin;
291  int i, k, fUseMuxes = 1;
292  // quit if CNF is ready
293  if ( Dch_ObjSatNum(p,pObj) )
294  return;
295  // start the frontier
296  vFrontier = Vec_PtrAlloc( 100 );
297  Dch_ObjAddToFrontier( p, pObj, vFrontier );
298  // explore nodes in the frontier
299  Vec_PtrForEachEntry( Aig_Obj_t *, vFrontier, pNode, i )
300  {
301  // create the supergate
302  assert( Dch_ObjSatNum(p,pNode) );
303  if ( fUseMuxes && Aig_ObjIsMuxType(pNode) )
304  {
305  Vec_PtrClear( p->vFanins );
310  Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanins, pFanin, k )
311  Dch_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
312  Dch_AddClausesMux( p, pNode );
313  }
314  else
315  {
316  Dch_CollectSuper( pNode, fUseMuxes, p->vFanins );
317  Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanins, pFanin, k )
318  Dch_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
319  Dch_AddClausesSuper( p, pNode, p->vFanins );
320  }
321  assert( Vec_PtrSize(p->vFanins) > 1 );
322  }
323  Vec_PtrFree( vFrontier );
324 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Dch_ObjAddToFrontier(Dch_Man_t *p, Aig_Obj_t *pObj, Vec_Ptr_t *vFrontier)
Definition: dchCnf.c:262
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
void Dch_CollectSuper(Aig_Obj_t *pObj, int fUseMuxes, Vec_Ptr_t *vSuper)
Definition: dchCnf.c:243
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
else
Definition: sparse_int.h:55
void Dch_AddClausesSuper(Dch_Man_t *p, Aig_Obj_t *pNode, Vec_Ptr_t *vSuper)
Definition: dchCnf.c:164
Definition: aig.h:69
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Ptr_t * vFanins
Definition: dchInt.h:69
int Aig_ObjIsMuxType(Aig_Obj_t *pObj)
Definition: aigUtil.c:307
#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_NAMESPACE_IMPL_START void Dch_AddClausesMux(Dch_Man_t *p, Aig_Obj_t *pNode)
DECLARATIONS ///.
Definition: dchCnf.c:45
static int Dch_ObjSatNum(Dch_Man_t *p, Aig_Obj_t *pObj)
MACRO DEFINITIONS ///.
Definition: dchInt.h:102
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Dch_Cla_t* Dch_CreateCandEquivClasses ( Aig_Man_t pAig,
int  nWords,
int  fVerbose 
)

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

Synopsis [Derives candidate equivalence classes of AIG nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file dchSim.c.

265 {
266  Dch_Cla_t * pClasses;
267  Vec_Ptr_t * vSims;
268  int i;
269  // allocate simulation information
270  vSims = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(pAig), nWords );
271  // run random simulation from the primary inputs
272  Dch_PerformRandomSimulation( pAig, vSims );
273  // start storage for equivalence classes
274  pClasses = Dch_ClassesStart( pAig );
276  // hash nodes by sim info
277  Dch_ClassesPrepare( pClasses, 0, 0 );
278  // iterate random simulation
279  for ( i = 0; i < 7; i++ )
280  {
281  Dch_PerformRandomSimulation( pAig, vSims );
282  Dch_ClassesRefine( pClasses );
283  }
284  // clean up and return
285  Vec_PtrFree( vSims );
286  // prepare class refinement procedures
288  return pClasses;
289 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int Dch_NodesAreEqualCex(void *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: dchSim.c:70
int Dch_NodeIsConstCex(void *p, Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: dchSim.c:54
int Dch_ClassesRefine(Dch_Cla_t *p)
Definition: dchClass.c:504
unsigned Dch_NodeHash(void *p, Aig_Obj_t *pObj)
Definition: dchSim.c:86
int nWords
Definition: abcNpn.c:127
int Dch_NodesAreEqual(void *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: dchSim.c:167
void Dch_ClassesSetData(Dch_Cla_t *p, void *pManData, unsigned(*pFuncNodeHash)(void *, Aig_Obj_t *), int(*pFuncNodeIsConst)(void *, Aig_Obj_t *), int(*pFuncNodesAreEqual)(void *, Aig_Obj_t *, Aig_Obj_t *))
Definition: dchClass.c:163
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
void Dch_ClassesPrepare(Dch_Cla_t *p, int fLatchCorr, int nMaxLevs)
Definition: dchClass.c:336
int Dch_NodeIsConst(void *p, Aig_Obj_t *pObj)
Definition: dchSim.c:134
Dch_Cla_t * Dch_ClassesStart(Aig_Man_t *pAig)
Definition: dchClass.c:137
void Dch_PerformRandomSimulation(Aig_Man_t *pAig, Vec_Ptr_t *vSims)
Definition: dchSim.c:201
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
typedefABC_NAMESPACE_HEADER_START struct Dch_Cla_t_ Dch_Cla_t
INCLUDES ///.
Definition: dchInt.h:47
Aig_Man_t* Dch_DeriveChoiceAig ( Aig_Man_t pAig,
int  fSkipRedSupps 
)

Definition at line 517 of file dchChoice.c.

518 {
519  int fCheck = 0;
520  Aig_Man_t * pChoices, * pTemp;
521  // verify
522  if ( fCheck )
523  Aig_ManCheckReprs( pAig );
524  // compute choices
525  pChoices = Dch_DeriveChoiceAigInt( pAig, fSkipRedSupps );
526  ABC_FREE( pChoices->pReprs );
527  // verify
528  if ( fCheck )
529  Dch_CheckChoices( pChoices, fSkipRedSupps );
530  // find correct topo order with choices
531  pChoices = Aig_ManDupDfs( pTemp = pChoices );
532  Aig_ManStop( pTemp );
533  // verify
534  if ( fCheck )
535  Dch_CheckChoices( pChoices, fSkipRedSupps );
536  return pChoices;
537 }
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 * Aig_ManDupDfs(Aig_Man_t *p)
Definition: aigDup.c:563
void Aig_ManCheckReprs(Aig_Man_t *p)
Definition: dchChoice.c:163
void Dch_CheckChoices(Aig_Man_t *p, int fSkipRedSupps)
Definition: dchChoice.c:206
#define ABC_FREE(obj)
Definition: abc_global.h:232
Aig_Man_t * Dch_DeriveChoiceAigInt(Aig_Man_t *pAig, int fSkipRedSupps)
Definition: dchChoice.c:494
int Dch_DeriveChoiceCountEquivs ( Aig_Man_t pAig)

Definition at line 89 of file dchChoice.c.

90 {
91  Aig_Obj_t * pObj, * pEquiv;
92  int i, nEquivs = 0;
93  Aig_ManForEachObj( pAig, pObj, i )
94  {
95  pEquiv = Aig_ObjEquiv( pAig, pObj );
96  if ( pEquiv == NULL )
97  continue;
98  assert( pEquiv->Id < pObj->Id );
99  nEquivs++;
100  }
101  return nEquivs;
102 }
static Aig_Obj_t * Aig_ObjEquiv(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:328
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
int Dch_DeriveChoiceCountReprs ( Aig_Man_t pAig)

FUNCTION DECLARATIONS ///.

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

Synopsis [Counts the number of representatives.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file dchChoice.c.

76 {
77  Aig_Obj_t * pObj, * pRepr;
78  int i, nReprs = 0;
79  Aig_ManForEachObj( pAig, pObj, i )
80  {
81  pRepr = Aig_ObjRepr( pAig, pObj );
82  if ( pRepr == NULL )
83  continue;
84  assert( pRepr->Id < pObj->Id );
85  nReprs++;
86  }
87  return nReprs;
88 }
static Aig_Obj_t * Aig_ObjRepr(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:330
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
Dch_Man_t* Dch_ManCreate ( Aig_Man_t pAig,
Dch_Pars_t pPars 
)

DECLARATIONS ///.

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

FileName [dchMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Choice computation for tech-mapping.]

Synopsis [Calls to the SAT solver.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 29, 2008.]

Revision [

Id:
dchMan.c,v 1.00 2008/07/29 00:00:00 alanmi Exp

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

Synopsis [Creates the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file dchMan.c.

46 {
47  Dch_Man_t * p;
48  // create interpolation manager
49  p = ABC_ALLOC( Dch_Man_t, 1 );
50  memset( p, 0, sizeof(Dch_Man_t) );
51  p->pPars = pPars;
52  p->pAigTotal = pAig; //Dch_DeriveTotalAig( vAigs );
54  // SAT solving
55  p->nSatVars = 1;
57  p->vUsedNodes = Vec_PtrAlloc( 1000 );
58  p->vFanins = Vec_PtrAlloc( 100 );
59  p->vSimRoots = Vec_PtrAlloc( 1000 );
60  p->vSimClasses = Vec_PtrAlloc( 1000 );
61  // equivalences proved
63  return p;
64 }
char * memset()
int nSatVars
Definition: dchInt.h:64
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: aigFanout.c:56
int * pSatVars
Definition: dchInt.h:65
Vec_Ptr_t * vSimClasses
Definition: dchInt.h:71
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
Vec_Ptr_t * vUsedNodes
Definition: dchInt.h:66
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Ptr_t * vFanins
Definition: dchInt.h:69
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
Dch_Pars_t * pPars
Definition: dchInt.h:54
Aig_Obj_t ** pReprsProved
Definition: dchInt.h:61
void Dch_ManResimulateCex ( Dch_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pRepr 
)

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

Synopsis [Handle the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file dchSimSat.c.

178 {
179  Aig_Obj_t * pRoot, ** ppClass;
180  int i, k, nSize, RetValue1, RetValue2;
181  abctime clk = Abc_Clock();
182  // get the equivalence classes
183  Dch_ManCollectTfoCands( p, pObj, pRepr );
184  // resimulate the cone of influence of the solved nodes
185  p->nConeThis = 0;
188  Dch_ManResimulateSolved_rec( p, pObj );
189  Dch_ManResimulateSolved_rec( p, pRepr );
190  p->nConeMax = Abc_MaxInt( p->nConeMax, p->nConeThis );
191  // resimulate the cone of influence of the other nodes
192  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimRoots, pRoot, i )
193  Dch_ManResimulateOther_rec( p, pRoot );
194  // refine these nodes
195  RetValue1 = Dch_ClassesRefineConst1Group( p->ppClasses, p->vSimRoots, 0 );
196  // resimulate the cone of influence of the cand classes
197  RetValue2 = 0;
198  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimClasses, pRoot, i )
199  {
200  ppClass = Dch_ClassesReadClass( p->ppClasses, pRoot, &nSize );
201  for ( k = 0; k < nSize; k++ )
202  Dch_ManResimulateOther_rec( p, ppClass[k] );
203  // refine this class
204  RetValue2 += Dch_ClassesRefineOneClass( p->ppClasses, pRoot, 0 );
205  }
206  // make sure refinement happened
207  if ( Aig_ObjIsConst1(pRepr) )
208  assert( RetValue1 );
209  else
210  assert( RetValue2 );
211 p->timeSimSat += Abc_Clock() - clk;
212 }
void Dch_ManCollectTfoCands(Dch_Man_t *p, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2)
Definition: dchSimSat.c:84
void Dch_ManResimulateSolved_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:111
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
int nConeThis
Definition: dchInt.h:73
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
int Dch_ClassesRefineConst1Group(Dch_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
Definition: dchClass.c:570
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
int nConeMax
Definition: dchInt.h:74
void Dch_ManResimulateOther_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:149
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
Aig_Obj_t ** Dch_ClassesReadClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, int *pnSize)
Definition: dchClass.c:222
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
void Dch_ManResimulateCex2 ( Dch_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pRepr 
)

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

Synopsis [Handle the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file dchSimSat.c.

226 {
227  Aig_Obj_t * pRoot;
228  int i, RetValue;
229  abctime clk = Abc_Clock();
230  // get the equivalence class
231  if ( Dch_ObjIsConst1Cand(p->pAigTotal, pObj) )
233  else
235  // resimulate the cone of influence of the solved nodes
236  p->nConeThis = 0;
239  Dch_ManResimulateSolved_rec( p, pObj );
240  Dch_ManResimulateSolved_rec( p, pRepr );
241  p->nConeMax = Abc_MaxInt( p->nConeMax, p->nConeThis );
242  // resimulate the cone of influence of the other nodes
243  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimRoots, pRoot, i )
244  Dch_ManResimulateOther_rec( p, pRoot );
245  // refine this class
246  if ( Dch_ObjIsConst1Cand(p->pAigTotal, pObj) )
247  RetValue = Dch_ClassesRefineConst1Group( p->ppClasses, p->vSimRoots, 0 );
248  else
249  RetValue = Dch_ClassesRefineOneClass( p->ppClasses, pRepr, 0 );
250  assert( RetValue );
251 p->timeSimSat += Abc_Clock() - clk;
252 }
static int Dch_ObjIsConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
Definition: dchInt.h:108
void Dch_ManResimulateSolved_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:111
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
int nConeThis
Definition: dchInt.h:73
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
int Dch_ClassesRefineConst1Group(Dch_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
Definition: dchClass.c:570
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
void Dch_ClassesCollectConst1Group(Dch_Cla_t *p, Aig_Obj_t *pObj, int nNodes, Vec_Ptr_t *vRoots)
Definition: dchClass.c:546
int nConeMax
Definition: dchInt.h:74
Dch_Cla_t * ppClasses
Definition: dchInt.h:60
if(last==0)
Definition: sparse_int.h:34
void Dch_ManResimulateOther_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:149
else
Definition: sparse_int.h:55
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
#define assert(ex)
Definition: util_old.h:213
void Dch_ClassesCollectOneClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, Vec_Ptr_t *vRoots)
Definition: dchClass.c:525
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
void Dch_ManSatSolverRecycle ( Dch_Man_t p)

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

Synopsis [Recycles the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file dchMan.c.

154 {
155  int Lit;
156  if ( p->pSat )
157  {
158  Aig_Obj_t * pObj;
159  int i;
160  Vec_PtrForEachEntry( Aig_Obj_t *, p->vUsedNodes, pObj, i )
161  Dch_ObjSetSatNum( p, pObj, 0 );
162  Vec_PtrClear( p->vUsedNodes );
163 // memset( p->pSatVars, 0, sizeof(int) * Aig_ManObjNumMax(p->pAigTotal) );
164  sat_solver_delete( p->pSat );
165  }
166  p->pSat = sat_solver_new();
167  sat_solver_setnvars( p->pSat, 1000 );
168  // var 0 is not used
169  // var 1 is reserved for const1 node - add the clause
170  p->nSatVars = 1;
171 // p->nSatVars = 0;
172  Lit = toLit( p->nSatVars );
173  if ( p->pPars->fPolarFlip )
174  Lit = lit_neg( Lit );
175  sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
176  Dch_ObjSetSatNum( p, Aig_ManConst1(p->pAigFraig), p->nSatVars++ );
177 
178  p->nRecycles++;
179  p->nCallsSince = 0;
180 }
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static lit lit_neg(lit l)
Definition: satVec.h:144
static lit toLit(int v)
Definition: satVec.h:142
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vUsedNodes
Definition: dchInt.h:66
sat_solver * pSat
Definition: dchInt.h:63
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
static void Dch_ObjSetSatNum(Dch_Man_t *p, Aig_Obj_t *pObj, int Num)
Definition: dchInt.h:103
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Dch_ManStop ( Dch_Man_t p)

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

Synopsis [Frees the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 122 of file dchMan.c.

123 {
125  if ( p->pPars->fVerbose )
126  Dch_ManPrintStats( p );
127  if ( p->pAigFraig )
128  Aig_ManStop( p->pAigFraig );
129  if ( p->ppClasses )
131  if ( p->pSat )
132  sat_solver_delete( p->pSat );
133  Vec_PtrFree( p->vUsedNodes );
134  Vec_PtrFree( p->vFanins );
135  Vec_PtrFree( p->vSimRoots );
136  Vec_PtrFree( p->vSimClasses );
137  ABC_FREE( p->pReprsProved );
138  ABC_FREE( p->pSatVars );
139  ABC_FREE( p );
140 }
void Dch_ManPrintStats(Dch_Man_t *p)
Definition: dchMan.c:77
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Aig_Man_t * pAigFraig
Definition: dchInt.h:58
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
void Dch_ClassesStop(Dch_Cla_t *p)
Definition: dchClass.c:185
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition: aigFanout.c:89
int * pSatVars
Definition: dchInt.h:65
Vec_Ptr_t * vSimClasses
Definition: dchInt.h:71
Dch_Cla_t * ppClasses
Definition: dchInt.h:60
Vec_Ptr_t * vUsedNodes
Definition: dchInt.h:66
sat_solver * pSat
Definition: dchInt.h:63
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Ptr_t * vFanins
Definition: dchInt.h:69
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
Dch_Pars_t * pPars
Definition: dchInt.h:54
Aig_Obj_t ** pReprsProved
Definition: dchInt.h:61
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Dch_ManSweep ( Dch_Man_t p)

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

Synopsis [Performs fraiging for the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file dchSweep.c.

107 {
108  Bar_Progress_t * pProgress = NULL;
109  Aig_Obj_t * pObj, * pObjNew;
110  int i;
111  // map constants and PIs
115  Aig_ManForEachCi( p->pAigTotal, pObj, i )
116  pObj->pData = Aig_ObjCreateCi( p->pAigFraig );
117  // sweep internal nodes
118  pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAigTotal) );
119  Aig_ManForEachNode( p->pAigTotal, pObj, i )
120  {
121  Bar_ProgressUpdate( pProgress, i, NULL );
122  if ( Dch_ObjFraig(Aig_ObjFanin0(pObj)) == NULL ||
123  Dch_ObjFraig(Aig_ObjFanin1(pObj)) == NULL )
124  continue;
125  pObjNew = Aig_And( p->pAigFraig, Dch_ObjChild0Fra(pObj), Dch_ObjChild1Fra(pObj) );
126  if ( pObjNew == NULL )
127  continue;
128  Dch_ObjSetFraig( pObj, pObjNew );
129  Dch_ManSweepNode( p, pObj );
130  }
131  Bar_ProgressStop( pProgress );
132  // update the representatives of the nodes (makes classes invalid)
133  ABC_FREE( p->pAigTotal->pReprs );
134  p->pAigTotal->pReprs = p->pReprsProved;
135  p->pReprsProved = NULL;
136  // clean the mark
138 }
void * pData
Definition: aig.h:87
Aig_Man_t * pAigFraig
Definition: dchInt.h:58
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static Aig_Obj_t * Dch_ObjChild1Fra(Aig_Obj_t *pObj)
Definition: dchSweep.c:32
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
void Dch_ManSweepNode(Dch_Man_t *p, Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: dchSweep.c:49
void Aig_ManCleanMarkB(Aig_Man_t *p)
Definition: aigUtil.c:167
#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
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static void Bar_ProgressUpdate(Bar_Progress_t *p, int nItemsCur, char *pString)
Definition: bar.h:63
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static Aig_Obj_t * Dch_ObjFraig(Aig_Obj_t *pObj)
Definition: dchInt.h:105
static void Dch_ObjSetFraig(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: dchInt.h:106
Definition: aig.h:69
DECLARATIONS ///.
Definition: bar.c:36
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 ABC_FREE(obj)
Definition: abc_global.h:232
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
static ABC_NAMESPACE_IMPL_START Aig_Obj_t * Dch_ObjChild0Fra(Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: dchSweep.c:31
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
void Bar_ProgressStop(Bar_Progress_t *p)
Definition: bar.c:126
Bar_Progress_t * Bar_ProgressStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition: bar.c:66
Aig_Obj_t ** pReprsProved
Definition: dchInt.h:61
int Dch_NodesAreEquiv ( Dch_Man_t p,
Aig_Obj_t pOld,
Aig_Obj_t pNew 
)

DECLARATIONS ///.

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

FileName [dchSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Choice computation for tech-mapping.]

Synopsis [Calls to the SAT solver.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 29, 2008.]

Revision [

Id:
dchSat.c,v 1.00 2008/07/29 00:00:00 alanmi Exp

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

Synopsis [Runs equivalence test for the two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file dchSat.c.

46 {
47  int nBTLimit = p->pPars->nBTLimit;
48  int pLits[2], RetValue, RetValue1, status;
49  abctime clk;
50  p->nSatCalls++;
51 
52  // sanity checks
53  assert( !Aig_IsComplement(pNew) );
54  assert( !Aig_IsComplement(pOld) );
55  assert( pNew != pOld );
56 
57  p->nCallsSince++; // experiment with this!!!
58 
59  // check if SAT solver needs recycling
60  if ( p->pSat == NULL ||
61  (p->pPars->nSatVarMax &&
62  p->nSatVars > p->pPars->nSatVarMax &&
63  p->nCallsSince > p->pPars->nCallsRecycle) )
65 
66  // if the nodes do not have SAT variables, allocate them
67  Dch_CnfNodeAddToSolver( p, pOld );
68  Dch_CnfNodeAddToSolver( p, pNew );
69 
70  // propage unit clauses
71  if ( p->pSat->qtail != p->pSat->qhead )
72  {
73  status = sat_solver_simplify(p->pSat);
74  assert( status != 0 );
75  assert( p->pSat->qtail == p->pSat->qhead );
76  }
77 
78  // solve under assumptions
79  // A = 1; B = 0 OR A = 1; B = 1
80  pLits[0] = toLitCond( Dch_ObjSatNum(p,pOld), 0 );
81  pLits[1] = toLitCond( Dch_ObjSatNum(p,pNew), pOld->fPhase == pNew->fPhase );
82  if ( p->pPars->fPolarFlip )
83  {
84  if ( pOld->fPhase ) pLits[0] = lit_neg( pLits[0] );
85  if ( pNew->fPhase ) pLits[1] = lit_neg( pLits[1] );
86  }
87 //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
88 clk = Abc_Clock();
89  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
90  (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
91 p->timeSat += Abc_Clock() - clk;
92  if ( RetValue1 == l_False )
93  {
94 p->timeSatUnsat += Abc_Clock() - clk;
95  pLits[0] = lit_neg( pLits[0] );
96  pLits[1] = lit_neg( pLits[1] );
97  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
98  assert( RetValue );
99  p->nSatCallsUnsat++;
100  }
101  else if ( RetValue1 == l_True )
102  {
103 p->timeSatSat += Abc_Clock() - clk;
104  p->nSatCallsSat++;
105  return 0;
106  }
107  else // if ( RetValue1 == l_Undef )
108  {
109 p->timeSatUndec += Abc_Clock() - clk;
110  p->nSatFailsReal++;
111  return -1;
112  }
113 
114  // if the old node was constant 0, we already know the answer
115  if ( pOld == Aig_ManConst1(p->pAigFraig) )
116  {
117  p->nSatProof++;
118  return 1;
119  }
120 
121  // solve under assumptions
122  // A = 0; B = 1 OR A = 0; B = 0
123  pLits[0] = toLitCond( Dch_ObjSatNum(p,pOld), 1 );
124  pLits[1] = toLitCond( Dch_ObjSatNum(p,pNew), pOld->fPhase ^ pNew->fPhase );
125  if ( p->pPars->fPolarFlip )
126  {
127  if ( pOld->fPhase ) pLits[0] = lit_neg( pLits[0] );
128  if ( pNew->fPhase ) pLits[1] = lit_neg( pLits[1] );
129  }
130 clk = Abc_Clock();
131  RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
132  (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
133 p->timeSat += Abc_Clock() - clk;
134  if ( RetValue1 == l_False )
135  {
136 p->timeSatUnsat += Abc_Clock() - clk;
137  pLits[0] = lit_neg( pLits[0] );
138  pLits[1] = lit_neg( pLits[1] );
139  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
140  assert( RetValue );
141  p->nSatCallsUnsat++;
142  }
143  else if ( RetValue1 == l_True )
144  {
145 p->timeSatSat += Abc_Clock() - clk;
146  p->nSatCallsSat++;
147  return 0;
148  }
149  else // if ( RetValue1 == l_Undef )
150  {
151 p->timeSatUndec += Abc_Clock() - clk;
152  p->nSatFailsReal++;
153  return -1;
154  }
155  // return SAT proof
156  p->nSatProof++;
157  return 1;
158 }
int nSatVars
Definition: dchInt.h:64
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
void Dch_ManSatSolverRecycle(Dch_Man_t *p)
Definition: dchMan.c:153
int nSatCallsSat
Definition: dchInt.h:80
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
Aig_Man_t * pAigFraig
Definition: dchInt.h:58
abctime timeSatUnsat
Definition: dchInt.h:91
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
#define l_True
Definition: SolverTypes.h:84
int nCallsSince
Definition: dchInt.h:68
static abctime Abc_Clock()
Definition: abc_global.h:279
static lit lit_neg(lit l)
Definition: satVec.h:144
int nSatProof
Definition: dchInt.h:77
static lit toLitCond(int v, int c)
Definition: satVec.h:143
abctime timeSat
Definition: dchInt.h:89
abctime timeSatSat
Definition: dchInt.h:90
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
sat_solver * pSat
Definition: dchInt.h:63
abctime timeSatUndec
Definition: dchInt.h:92
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
int nSatCalls
Definition: dchInt.h:76
unsigned int fPhase
Definition: aig.h:78
#define l_False
Definition: SolverTypes.h:85
int nSatCallsUnsat
Definition: dchInt.h:79
#define assert(ex)
Definition: util_old.h:213
Dch_Pars_t * pPars
Definition: dchInt.h:54
void Dch_CnfNodeAddToSolver(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchCnf.c:287
ABC_INT64_T abctime
Definition: abc_global.h:278
int nSatFailsReal
Definition: dchInt.h:78
static int Dch_ObjSatNum(Dch_Man_t *p, Aig_Obj_t *pObj)
MACRO DEFINITIONS ///.
Definition: dchInt.h:102
static Aig_Obj_t* Dch_ObjFraig ( Aig_Obj_t pObj)
inlinestatic

Definition at line 105 of file dchInt.h.

105 { return (Aig_Obj_t *)pObj->pData; }
void * pData
Definition: aig.h:87
Definition: aig.h:69
static int Dch_ObjIsConst1Cand ( Aig_Man_t pAig,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 108 of file dchInt.h.

109 {
110  return Aig_ObjRepr(pAig, pObj) == Aig_ManConst1(pAig);
111 }
static Aig_Obj_t * Aig_ObjRepr(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:330
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Dch_ObjSatNum ( Dch_Man_t p,
Aig_Obj_t pObj 
)
inlinestatic

MACRO DEFINITIONS ///.

Definition at line 102 of file dchInt.h.

102 { return p->pSatVars[pObj->Id]; }
int * pSatVars
Definition: dchInt.h:65
int Id
Definition: aig.h:85
static void Dch_ObjSetConst1Cand ( Aig_Man_t pAig,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 112 of file dchInt.h.

113 {
114  assert( !Dch_ObjIsConst1Cand( pAig, pObj ) );
115  Aig_ObjSetRepr( pAig, pObj, Aig_ManConst1(pAig) );
116 }
static int Dch_ObjIsConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
Definition: dchInt.h:108
static void Aig_ObjSetRepr(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
Definition: aig.h:331
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define assert(ex)
Definition: util_old.h:213
static void Dch_ObjSetFraig ( Aig_Obj_t pObj,
Aig_Obj_t pNode 
)
inlinestatic

Definition at line 106 of file dchInt.h.

106 { pObj->pData = pNode; }
void * pData
Definition: aig.h:87
static void Dch_ObjSetSatNum ( Dch_Man_t p,
Aig_Obj_t pObj,
int  Num 
)
inlinestatic

Definition at line 103 of file dchInt.h.

103 { p->pSatVars[pObj->Id] = Num; }
int * pSatVars
Definition: dchInt.h:65
int Id
Definition: aig.h:85