cecMan.c 8.58 KB
Newer Older
Alan Mishchenko committed
1 2
/**CFile****************************************************************

Alan Mishchenko committed
3
  FileName    [cecMan.c]
Alan Mishchenko committed
4 5 6

  SystemName  [ABC: Logic synthesis and verification system.]

Alan Mishchenko committed
7
  PackageName [Combinational equivalence checking.]
Alan Mishchenko committed
8

Alan Mishchenko committed
9
  Synopsis    [Manager procedures.]
Alan Mishchenko committed
10 11 12 13 14 15 16

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

Alan Mishchenko committed
17
  Revision    [$Id: cecMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Alan Mishchenko committed
18 19 20

***********************************************************************/

Alan Mishchenko committed
21
#include "cecInt.h"
Alan Mishchenko committed
22

23 24 25
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
26 27 28 29 30 31 32 33 34 35
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

Alan Mishchenko committed
36
  Synopsis    [Creates the manager.]
Alan Mishchenko committed
37 38 39 40 41 42 43 44

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
45 46 47 48 49 50 51 52 53 54 55 56 57
Cec_ManSat_t * Cec_ManSatCreate( Gia_Man_t * pAig, Cec_ParSat_t * pPars )
{
    Cec_ManSat_t * p;
    // create interpolation manager
    p = ABC_ALLOC( Cec_ManSat_t, 1 );
    memset( p, 0, sizeof(Cec_ManSat_t) );
    p->pPars        = pPars;
    p->pAig         = pAig;
    // SAT solving
    p->nSatVars     = 1;
    p->pSatVars     = ABC_CALLOC( int, Gia_ManObjNum(pAig) );
    p->vUsedNodes   = Vec_PtrAlloc( 1000 );
    p->vFanins      = Vec_PtrAlloc( 100 );
Alan Mishchenko committed
58 59
    p->vCex         = Vec_IntAlloc( 100 );
    p->vVisits      = Vec_IntAlloc( 100 );
Alan Mishchenko committed
60 61
    return p;
}
Alan Mishchenko committed
62

Alan Mishchenko committed
63 64
/**Function*************************************************************

Alan Mishchenko committed
65
  Synopsis    [Prints statistics of the manager.]
Alan Mishchenko committed
66 67 68 69 70 71 72 73

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
74
void Cec_ManSatPrintStats( Cec_ManSat_t * p )
Alan Mishchenko committed
75
{
76
    printf( "SAT solver statistics:\n" );
77 78 79 80 81 82
    Abc_Print( 1, "CO = %8d  ", Gia_ManCoNum(p->pAig) );
    Abc_Print( 1, "AND = %8d  ", Gia_ManAndNum(p->pAig) );
    Abc_Print( 1, "Conf = %5d  ", p->pPars->nBTLimit );
    Abc_Print( 1, "MinVar = %5d  ", p->pPars->nSatVarMax );
    Abc_Print( 1, "MinCalls = %5d\n", p->pPars->nCallsRecycle );
    Abc_Print( 1, "Unsat calls %6d  (%6.2f %%)   Ave conf = %8.1f   ", 
Alan Mishchenko committed
83
        p->nSatUnsat, p->nSatTotal? 100.0*p->nSatUnsat/p->nSatTotal : 0.0, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 );
84 85
    Abc_PrintTimeP( 1, "Time", p->timeSatUnsat, p->timeTotal );
    Abc_Print( 1, "Sat   calls %6d  (%6.2f %%)   Ave conf = %8.1f   ", 
Alan Mishchenko committed
86
        p->nSatSat,   p->nSatTotal? 100.0*p->nSatSat/p->nSatTotal : 0.0,   p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 );
87 88
    Abc_PrintTimeP( 1, "Time", p->timeSatSat,   p->timeTotal );
    Abc_Print( 1, "Undef calls %6d  (%6.2f %%)   Ave conf = %8.1f   ", 
Alan Mishchenko committed
89
        p->nSatUndec, p->nSatTotal? 100.0*p->nSatUndec/p->nSatTotal : 0.0, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 );
90 91
    Abc_PrintTimeP( 1, "Time", p->timeSatUndec, p->timeTotal );
    Abc_PrintTime( 1, "Total time", p->timeTotal );
Alan Mishchenko committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
}

/**Function*************************************************************

  Synopsis    [Frees the manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cec_ManSatStop( Cec_ManSat_t * p )
{
    if ( p->pSat )
        sat_solver_delete( p->pSat );
Alan Mishchenko committed
109 110
    Vec_IntFree( p->vCex );
    Vec_IntFree( p->vVisits );
Alan Mishchenko committed
111 112 113
    Vec_PtrFree( p->vUsedNodes );
    Vec_PtrFree( p->vFanins );
    ABC_FREE( p->pSatVars );
Alan Mishchenko committed
114 115 116 117
    ABC_FREE( p );
}


Alan Mishchenko committed
118

Alan Mishchenko committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
/**Function*************************************************************

  Synopsis    [Creates AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Cec_ManPat_t * Cec_ManPatStart()  
{ 
    Cec_ManPat_t * p;
    p = ABC_CALLOC( Cec_ManPat_t, 1 );
    p->vStorage  = Vec_StrAlloc( 1<<20 );
    p->vPattern1 = Vec_IntAlloc( 1000 );
    p->vPattern2 = Vec_IntAlloc( 1000 );
    return p;
}

/**Function*************************************************************

  Synopsis    [Creates AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cec_ManPatPrintStats( Cec_ManPat_t * p )  
{ 
153
    Abc_Print( 1, "Latest: P = %8d.  L = %10d.  Lm = %10d. Ave = %6.1f. MEM =%6.2f MB\n", 
Alan Mishchenko committed
154 155
        p->nPats, p->nPatLits, p->nPatLitsMin, 1.0 * p->nPatLitsMin/p->nPats, 
        1.0*(Vec_StrSize(p->vStorage)-p->iStart)/(1<<20) );
156
    Abc_Print( 1, "Total:  P = %8d.  L = %10d.  Lm = %10d. Ave = %6.1f. MEM =%6.2f MB\n", 
Alan Mishchenko committed
157 158
        p->nPatsAll, p->nPatLitsAll, p->nPatLitsMinAll, 1.0 * p->nPatLitsMinAll/p->nPatsAll, 
        1.0*Vec_StrSize(p->vStorage)/(1<<20) );
159 160 161 162 163 164
    Abc_PrintTimeP( 1, "Finding  ", p->timeFind,   p->timeTotal );
    Abc_PrintTimeP( 1, "Shrinking", p->timeShrink, p->timeTotal );
    Abc_PrintTimeP( 1, "Verifying", p->timeVerify, p->timeTotal );
    Abc_PrintTimeP( 1, "Sorting  ", p->timeSort,   p->timeTotal );
    Abc_PrintTimeP( 1, "Packing  ", p->timePack,   p->timeTotal );
    Abc_PrintTime( 1, "TOTAL    ",  p->timeTotal );
Alan Mishchenko committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
}

/**Function*************************************************************

  Synopsis    [Deletes AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cec_ManPatStop( Cec_ManPat_t * p )  
{
    Vec_StrFree( p->vStorage );
    Vec_IntFree( p->vPattern1 );
    Vec_IntFree( p->vPattern2 );
    ABC_FREE( p );
}

Alan Mishchenko committed
186 187


Alan Mishchenko committed
188 189
/**Function*************************************************************

Alan Mishchenko committed
190
  Synopsis    [Creates AIG.]
Alan Mishchenko committed
191 192 193 194 195 196 197 198

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
199 200 201 202 203 204 205
Cec_ManSim_t * Cec_ManSimStart( Gia_Man_t * pAig, Cec_ParSim_t *  pPars )  
{ 
    Cec_ManSim_t * p;
    p = ABC_ALLOC( Cec_ManSim_t, 1 );
    memset( p, 0, sizeof(Cec_ManSim_t) );
    p->pAig  = pAig;
    p->pPars = pPars;
Alan Mishchenko committed
206
    p->nWords = pPars->nWords;
Alan Mishchenko committed
207 208 209 210 211 212 213 214 215 216 217 218
    p->pSimInfo = ABC_CALLOC( int, Gia_ManObjNum(pAig) );
    p->vClassOld  = Vec_IntAlloc( 1000 );
    p->vClassNew  = Vec_IntAlloc( 1000 );
    p->vClassTemp = Vec_IntAlloc( 1000 );
    p->vRefinedC  = Vec_IntAlloc( 10000 );
    p->vCiSimInfo = Vec_PtrAllocSimInfo( Gia_ManCiNum(p->pAig), pPars->nWords );
    if ( pPars->fCheckMiter || Gia_ManRegNum(p->pAig) )
    {
        p->vCoSimInfo = Vec_PtrAllocSimInfo( Gia_ManCoNum(p->pAig), pPars->nWords );
        Vec_PtrCleanSimInfo( p->vCoSimInfo, 0, pPars->nWords );
    }
    p->iOut = -1;
Alan Mishchenko committed
219 220 221 222 223
    return p;
}

/**Function*************************************************************

Alan Mishchenko committed
224
  Synopsis    [Deletes AIG.]
Alan Mishchenko committed
225 226 227 228 229 230 231 232

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
233
void Cec_ManSimStop( Cec_ManSim_t * p )  
Alan Mishchenko committed
234
{
Alan Mishchenko committed
235 236 237 238 239 240 241 242
    Vec_IntFree( p->vClassOld );
    Vec_IntFree( p->vClassNew );
    Vec_IntFree( p->vClassTemp );
    Vec_IntFree( p->vRefinedC );
    if ( p->vCiSimInfo ) 
        Vec_PtrFree( p->vCiSimInfo );
    if ( p->vCoSimInfo ) 
        Vec_PtrFree( p->vCoSimInfo );
Alan Mishchenko committed
243
    ABC_FREE( p->pScores );
Alan Mishchenko committed
244 245 246 247 248
    ABC_FREE( p->pCexComb );
    ABC_FREE( p->pCexes );
    ABC_FREE( p->pMems );
    ABC_FREE( p->pSimInfo );
    ABC_FREE( p );
Alan Mishchenko committed
249 250
}

Alan Mishchenko committed
251

Alan Mishchenko committed
252 253
/**Function*************************************************************

Alan Mishchenko committed
254
  Synopsis    [Creates AIG.]
Alan Mishchenko committed
255 256 257 258 259 260 261 262

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
Cec_ManFra_t * Cec_ManFraStart( Gia_Man_t * pAig, Cec_ParFra_t *  pPars )  
{ 
    Cec_ManFra_t * p;
    p = ABC_ALLOC( Cec_ManFra_t, 1 );
    memset( p, 0, sizeof(Cec_ManFra_t) );
    p->pAig  = pAig;
    p->pPars = pPars;
    p->vXorNodes  = Vec_IntAlloc( 1000 );
    return p;
}

/**Function*************************************************************

  Synopsis    [Deletes AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cec_ManFraStop( Cec_ManFra_t * p )  
Alan Mishchenko committed
286
{
Alan Mishchenko committed
287
    Vec_IntFree( p->vXorNodes );
Alan Mishchenko committed
288 289
    ABC_FREE( p );
}
Alan Mishchenko committed
290

Alan Mishchenko committed
291

Alan Mishchenko committed
292 293 294 295 296
////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


297 298
ABC_NAMESPACE_IMPL_END