abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dchMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [dchMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Choice computation for tech-mapping.]
8 
9  Synopsis [Calls to the SAT solver.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 29, 2008.]
16 
17  Revision [$Id: dchMan.c,v 1.00 2008/07/29 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "dchInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Creates the manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
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 }
65 
66 /**Function*************************************************************
67 
68  Synopsis [Prints stats of the manager.]
69 
70  Description []
71 
72  SideEffects []
73 
74  SeeAlso []
75 
76 ***********************************************************************/
78 {
79  int nNodeNum = Aig_ManNodeNum(p->pAigTotal) / 3;
80  Abc_Print( 1, "Parameters: Sim words = %d. Conf limit = %d. SAT var max = %d.\n",
81  p->pPars->nWords, p->pPars->nBTLimit, p->pPars->nSatVarMax );
82  Abc_Print( 1, "AIG nodes : Total = %6d. Dangling = %6d. Main = %6d. (%6.2f %%)\n",
84  Aig_ManNodeNum(p->pAigTotal)-nNodeNum,
85  nNodeNum,
86  100.0 * nNodeNum/Aig_ManNodeNum(p->pAigTotal) );
87  Abc_Print( 1, "SAT solver: Vars = %d. Max cone = %d. Recycles = %d.\n",
88  p->nSatVars, p->nConeMax, p->nRecycles );
89  Abc_Print( 1, "SAT calls : All = %6d. Unsat = %6d. Sat = %6d. Fail = %6d.\n",
91  p->nSatCallsSat, p->nSatFailsReal );
92  Abc_Print( 1, "Choices : Lits = %6d. Reprs = %5d. Equivs = %5d. Choices = %5d.\n",
93  p->nLits, p->nReprs, p->nEquivs, p->nChoices );
94  Abc_Print( 1, "Choicing runtime statistics:\n" );
96  Abc_PrintTimeP( 1, "Sim init ", p->timeSimInit, p->timeTotal );
97  Abc_PrintTimeP( 1, "Sim SAT ", p->timeSimSat, p->timeTotal );
98  Abc_PrintTimeP( 1, "SAT solving", p->timeSat, p->timeTotal );
99  Abc_PrintTimeP( 1, " sat ", p->timeSatSat, p->timeTotal );
100  Abc_PrintTimeP( 1, " unsat ", p->timeSatUnsat, p->timeTotal );
101  Abc_PrintTimeP( 1, " undecided", p->timeSatUndec, p->timeTotal );
102  Abc_PrintTimeP( 1, "Choice ", p->timeChoice, p->timeTotal );
103  Abc_PrintTimeP( 1, "Other ", p->timeOther, p->timeTotal );
104  Abc_PrintTimeP( 1, "TOTAL ", p->timeTotal, p->timeTotal );
105  if ( p->pPars->timeSynth )
106  {
107  Abc_PrintTime( 1, "Synthesis ", p->pPars->timeSynth );
108  }
109 }
110 
111 /**Function*************************************************************
112 
113  Synopsis [Frees the manager.]
114 
115  Description []
116 
117  SideEffects []
118 
119  SeeAlso []
120 
121 ***********************************************************************/
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 }
141 
142 /**Function*************************************************************
143 
144  Synopsis [Recycles the SAT solver.]
145 
146  Description []
147 
148  SideEffects []
149 
150  SeeAlso []
151 
152 ***********************************************************************/
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 );
177 
178  p->nRecycles++;
179  p->nCallsSince = 0;
180 }
181 
182 
183 
184 
185 ////////////////////////////////////////////////////////////////////////
186 /// END OF FILE ///
187 ////////////////////////////////////////////////////////////////////////
188 
189 
191 
char * memset()
void Dch_ManStop(Dch_Man_t *p)
Definition: dchMan.c:122
void Dch_ManPrintStats(Dch_Man_t *p)
Definition: dchMan.c:77
abctime timeOther
Definition: dchInt.h:94
int nReprs
Definition: dchInt.h:83
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
int nSatVars
Definition: dchInt.h:64
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
abctime timeSimSat
Definition: dchInt.h:88
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int nSatCallsSat
Definition: dchInt.h:80
Aig_Man_t * pAigFraig
Definition: dchInt.h:58
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
abctime timeSatUnsat
Definition: dchInt.h:91
void Dch_ClassesStop(Dch_Cla_t *p)
Definition: dchClass.c:185
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nCallsSince
Definition: dchInt.h:68
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
void Dch_ManSatSolverRecycle(Dch_Man_t *p)
Definition: dchMan.c:153
typedefABC_NAMESPACE_HEADER_START struct Dch_Pars_t_ Dch_Pars_t
INCLUDES ///.
Definition: dch.h:43
static void Abc_PrintTimeP(int level, const char *pStr, abctime time, abctime Time)
Definition: abc_global.h:372
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: aigFanout.c:56
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition: aigFanout.c:89
static lit lit_neg(lit l)
Definition: satVec.h:144
int nLits
Definition: dchInt.h:82
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int * pSatVars
Definition: dchInt.h:65
abctime timeChoice
Definition: dchInt.h:93
Vec_Ptr_t * vSimClasses
Definition: dchInt.h:71
static lit toLit(int v)
Definition: satVec.h:142
int nConeMax
Definition: dchInt.h:74
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Dch_Cla_t * ppClasses
Definition: dchInt.h:60
Definition: aig.h:69
abctime timeSat
Definition: dchInt.h:89
ABC_NAMESPACE_IMPL_START Dch_Man_t * Dch_ManCreate(Aig_Man_t *pAig, Dch_Pars_t *pPars)
DECLARATIONS ///.
Definition: dchMan.c:45
int nEquivs
Definition: dchInt.h:84
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
abctime timeSatSat
Definition: dchInt.h:90
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
abctime timeTotal
Definition: dchInt.h:95
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Vec_Ptr_t * vUsedNodes
Definition: dchInt.h:66
sat_solver * pSat
Definition: dchInt.h:63
abctime timeSatUndec
Definition: dchInt.h:92
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
int nSatCalls
Definition: dchInt.h:76
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Ptr_t * vFanins
Definition: dchInt.h:69
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
abctime timeSimInit
Definition: dchInt.h:87
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Dch_Pars_t * pPars
Definition: dchInt.h:54
int nChoices
Definition: dchInt.h:85
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
int nSatFailsReal
Definition: dchInt.h:78
Aig_Obj_t ** pReprsProved
Definition: dchInt.h:61
int nRecycles
Definition: dchInt.h:67
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223