dchInt.h 7.99 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**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 $]

***********************************************************************/
 
21 22
#ifndef ABC__aig__dch__dchInt_h
#define ABC__aig__dch__dchInt_h
Alan Mishchenko committed
23

24

Alan Mishchenko committed
25 26 27 28
////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////

29 30
#include "aig/aig/aig.h"
#include "sat/bsat/satSolver.h"
Alan Mishchenko committed
31 32 33 34 35 36
#include "dch.h"

////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////

37 38 39 40


ABC_NAMESPACE_HEADER_START

Alan Mishchenko committed
41

Alan Mishchenko committed
42 43 44 45 46 47 48 49 50 51 52 53
////////////////////////////////////////////////////////////////////////
///                         BASIC TYPES                              ///
////////////////////////////////////////////////////////////////////////

// equivalence classes
typedef struct Dch_Cla_t_ Dch_Cla_t;

// choicing manager
typedef struct Dch_Man_t_ Dch_Man_t;
struct Dch_Man_t_
{
    // parameters
Alan Mishchenko committed
54
    Dch_Pars_t *     pPars;          // choicing parameters
Alan Mishchenko committed
55
    // AIGs used in the package
Alan Mishchenko committed
56
//    Vec_Ptr_t *      vAigs;          // user-given AIGs
Alan Mishchenko committed
57 58
    Aig_Man_t *      pAigTotal;      // intermediate AIG
    Aig_Man_t *      pAigFraig;      // final AIG
Alan Mishchenko committed
59
    // equivalence classes
Alan Mishchenko committed
60 61
    Dch_Cla_t *      ppClasses;      // equivalence classes of nodes
    Aig_Obj_t **     pReprsProved;   // equivalences proved
Alan Mishchenko committed
62
    // SAT solving
Alan Mishchenko committed
63 64 65 66 67
    sat_solver *     pSat;           // recyclable SAT solver
    int              nSatVars;       // the counter of SAT variables
    int *            pSatVars;       // mapping of each node into its SAT var
    Vec_Ptr_t *      vUsedNodes;     // nodes whose SAT vars are assigned
    int              nRecycles;      // the number of times SAT solver was recycled
Alan Mishchenko committed
68
    int              nCallsSince;    // the number of calls since the last recycle
Alan Mishchenko committed
69
    Vec_Ptr_t *      vFanins;        // fanins of the CNF node
Alan Mishchenko committed
70 71
    Vec_Ptr_t *      vSimRoots;      // the roots of cand const 1 nodes to simulate
    Vec_Ptr_t *      vSimClasses;    // the roots of cand equiv classes to simulate
Alan Mishchenko committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85
    // solver cone size
    int              nConeThis;
    int              nConeMax;
    // SAT calls statistics
    int              nSatCalls;      // the number of SAT calls
    int              nSatProof;      // the number of proofs
    int              nSatFailsReal;  // the number of timeouts
    int              nSatCallsUnsat; // the number of unsat SAT calls
    int              nSatCallsSat;   // the number of sat SAT calls
    // choice node statistics
    int              nLits;          // the number of lits in the cand equiv classes
    int              nReprs;         // the number of proved equivalent pairs
    int              nEquivs;        // the number of final equivalences
    int              nChoices;       // the number of final choice nodes
Alan Mishchenko committed
86
    // runtime stats
87 88 89 90 91 92 93 94 95
    abctime          timeSimInit;    // simulation and class computation
    abctime          timeSimSat;     // simulation of the counter-examples
    abctime          timeSat;        // solving SAT
    abctime          timeSatSat;     // sat
    abctime          timeSatUnsat;   // unsat
    abctime          timeSatUndec;   // undecided
    abctime          timeChoice;     // choice computation
    abctime          timeOther;      // other runtime
    abctime          timeTotal;      // total runtime
Alan Mishchenko committed
96 97 98 99 100 101
};

////////////////////////////////////////////////////////////////////////
///                      MACRO DEFINITIONS                           ///
////////////////////////////////////////////////////////////////////////

Alan Mishchenko committed
102 103 104
static inline int  Dch_ObjSatNum( Dch_Man_t * p, Aig_Obj_t * pObj )             { return p->pSatVars[pObj->Id]; }
static inline void Dch_ObjSetSatNum( Dch_Man_t * p, Aig_Obj_t * pObj, int Num ) { p->pSatVars[pObj->Id] = Num;  }

105
static inline Aig_Obj_t * Dch_ObjFraig( Aig_Obj_t * pObj )                       { return (Aig_Obj_t *)pObj->pData;  }
Alan Mishchenko committed
106 107
static inline void        Dch_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { pObj->pData = pNode; }

Alan Mishchenko committed
108 109 110 111 112 113 114 115 116 117
static inline int  Dch_ObjIsConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj ) 
{
    return Aig_ObjRepr(pAig, pObj) == Aig_ManConst1(pAig);
}
static inline void Dch_ObjSetConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj ) 
{
    assert( !Dch_ObjIsConst1Cand( pAig, pObj ) );
    Aig_ObjSetRepr( pAig, pObj, Aig_ManConst1(pAig) );
}

Alan Mishchenko committed
118 119 120 121
////////////////////////////////////////////////////////////////////////
///                    FUNCTION DECLARATIONS                         ///
////////////////////////////////////////////////////////////////////////

Alan Mishchenko committed
122 123 124 125
/*=== dchAig.c ===================================================*/
/*=== dchChoice.c ===================================================*/
extern int           Dch_DeriveChoiceCountReprs( Aig_Man_t * pAig );
extern int           Dch_DeriveChoiceCountEquivs( Aig_Man_t * pAig );
126
extern Aig_Man_t *   Dch_DeriveChoiceAig( Aig_Man_t * pAig, int fSkipRedSupps );
Alan Mishchenko committed
127 128 129 130 131 132 133 134
/*=== dchClass.c =================================================*/
extern Dch_Cla_t *   Dch_ClassesStart( Aig_Man_t * pAig );
extern 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 *) );
extern void          Dch_ClassesStop( Dch_Cla_t * p );
extern int           Dch_ClassesLitNum( Dch_Cla_t * p );
Alan Mishchenko committed
135
extern Aig_Obj_t **  Dch_ClassesReadClass( Dch_Cla_t * p, Aig_Obj_t * pRepr, int * pnSize );
Alan Mishchenko committed
136 137 138 139 140 141 142 143 144 145
extern void          Dch_ClassesPrint( Dch_Cla_t * p, int fVeryVerbose );
extern void          Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs );
extern int           Dch_ClassesRefine( Dch_Cla_t * p );
extern int           Dch_ClassesRefineOneClass( Dch_Cla_t * p, Aig_Obj_t * pRepr, int fRecursive );
extern void          Dch_ClassesCollectOneClass( Dch_Cla_t * p, Aig_Obj_t * pRepr, Vec_Ptr_t * vRoots );
extern void          Dch_ClassesCollectConst1Group( Dch_Cla_t * p, Aig_Obj_t * pObj, int nNodes, Vec_Ptr_t * vRoots );
extern int           Dch_ClassesRefineConst1Group( Dch_Cla_t * p, Vec_Ptr_t * vRoots, int fRecursive );
/*=== dchCnf.c ===================================================*/
extern void          Dch_CnfNodeAddToSolver( Dch_Man_t * p, Aig_Obj_t * pObj );
/*=== dchMan.c ===================================================*/
Alan Mishchenko committed
146
extern Dch_Man_t *   Dch_ManCreate( Aig_Man_t * pAig, Dch_Pars_t * pPars );
Alan Mishchenko committed
147 148 149 150 151 152
extern void          Dch_ManStop( Dch_Man_t * p );
extern void          Dch_ManSatSolverRecycle( Dch_Man_t * p );
/*=== dchSat.c ===================================================*/
extern int           Dch_NodesAreEquiv( Dch_Man_t * p, Aig_Obj_t * pObj1, Aig_Obj_t * pObj2 );
/*=== dchSim.c ===================================================*/
extern Dch_Cla_t *   Dch_CreateCandEquivClasses( Aig_Man_t * pAig, int nWords, int fVerbose );
Alan Mishchenko committed
153 154 155 156
/*=== dchSimSat.c ===================================================*/
extern void          Dch_ManResimulateCex( Dch_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pRepr );
extern void          Dch_ManResimulateCex2( Dch_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pRepr );
/*=== dchSweep.c ===================================================*/
Alan Mishchenko committed
157
extern void          Dch_ManSweep( Dch_Man_t * p );
Alan Mishchenko committed
158

159 160 161 162 163


ABC_NAMESPACE_HEADER_END


Alan Mishchenko committed
164 165 166 167 168 169 170

#endif

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////