intMan.c 4.68 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 21
/**CFile****************************************************************

  FileName    [intMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Interpolation engine.]

  Synopsis    [Interpolation manager procedures.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

  Revision    [$Id: intMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

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

#include "intInt.h"
22
#include "aig/ioa/ioa.h"
Alan Mishchenko committed
23

24 25 26
ABC_NAMESPACE_IMPL_START


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

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

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

Alan Mishchenko committed
37
  Synopsis    [Creates the interpolation manager.]
Alan Mishchenko committed
38 39 40 41 42 43 44 45 46 47 48 49

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Inter_Man_t * Inter_ManCreate( Aig_Man_t * pAig, Inter_ManParams_t * pPars )
{
    Inter_Man_t * p;
    // create interpolation manager
Alan Mishchenko committed
50
    p = ABC_ALLOC( Inter_Man_t, 1 );
Alan Mishchenko committed
51 52 53 54
    memset( p, 0, sizeof(Inter_Man_t) );
    p->vVarsAB = Vec_IntAlloc( Aig_ManRegNum(pAig) );
    p->nConfLimit = pPars->nBTLimit;
    p->fVerbose = pPars->fVerbose;
55
    p->pFileName = pPars->pFileName;
56 57 58
    p->pAig = pAig;
    if ( pPars->fDropInvar )
        p->vInters = Vec_PtrAlloc( 100 );
Alan Mishchenko committed
59 60 61 62 63
    return p;
}

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

Alan Mishchenko committed
64
  Synopsis    [Cleans the interpolation manager.]
Alan Mishchenko committed
65 66 67 68 69 70 71 72 73 74

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Inter_ManClean( Inter_Man_t * p )
{
75 76 77 78 79 80 81 82
    if ( p->vInters )
    {
        Aig_Man_t * pMan;
        int i;
        Vec_PtrForEachEntry( Aig_Man_t *, p->vInters, pMan, i )
            Aig_ManStop( pMan );
        Vec_PtrClear( p->vInters );
    }
Alan Mishchenko committed
83 84 85 86 87 88 89 90 91 92 93 94
    if ( p->pCnfInter )
        Cnf_DataFree( p->pCnfInter );
    if ( p->pCnfFrames )
        Cnf_DataFree( p->pCnfFrames );
    if ( p->pInter )
        Aig_ManStop( p->pInter );
    if ( p->pFrames )
        Aig_ManStop( p->pFrames );
}

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

95 96 97 98 99 100 101 102 103 104 105
  Synopsis    [Writes interpolant into a file.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Inter_ManInterDump( Inter_Man_t * p, int fProved )
{
Alan Mishchenko committed
106
    char * pFileName = p->pFileName ? p->pFileName : (char *)"invar.aig";
107 108
    Aig_Man_t * pMan;
    pMan = Aig_ManDupArray( p->vInters );
109
    Ioa_WriteAiger( pMan, pFileName, 0, 0 );
110 111
    Aig_ManStop( pMan );
    if ( fProved )
112
        printf( "Inductive invariant is dumped into file \"%s\".\n", pFileName );
113
    else
114
        printf( "Interpolants are dumped into file \"%s\".\n", pFileName );
115 116 117 118
}

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

Alan Mishchenko committed
119 120 121 122 123 124 125 126 127
  Synopsis    [Frees the interpolation manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
128
void Inter_ManStop( Inter_Man_t * p, int fProved )
Alan Mishchenko committed
129 130 131 132 133
{
    if ( p->fVerbose )
    {
        p->timeOther = p->timeTotal-p->timeRwr-p->timeCnf-p->timeSat-p->timeInt-p->timeEqu;
        printf( "Runtime statistics:\n" );
Alan Mishchenko committed
134 135 136 137 138 139 140
        ABC_PRTP( "Rewriting  ", p->timeRwr,   p->timeTotal );
        ABC_PRTP( "CNF mapping", p->timeCnf,   p->timeTotal );
        ABC_PRTP( "SAT solving", p->timeSat,   p->timeTotal );
        ABC_PRTP( "Interpol   ", p->timeInt,   p->timeTotal );
        ABC_PRTP( "Containment", p->timeEqu,   p->timeTotal );
        ABC_PRTP( "Other      ", p->timeOther, p->timeTotal );
        ABC_PRTP( "TOTAL      ", p->timeTotal, p->timeTotal );
Alan Mishchenko committed
141 142
    }

143 144 145
    if ( p->vInters )
        Inter_ManInterDump( p, fProved );

Alan Mishchenko committed
146 147 148 149 150 151
    if ( p->pCnfAig )
        Cnf_DataFree( p->pCnfAig );
    if ( p->pAigTrans )
        Aig_ManStop( p->pAigTrans );
    if ( p->pInterNew )
        Aig_ManStop( p->pInterNew );
152 153 154
    Inter_ManClean( p );
    Vec_PtrFreeP( &p->vInters );
    Vec_IntFreeP( &p->vVarsAB );
Alan Mishchenko committed
155
    ABC_FREE( p );
Alan Mishchenko committed
156 157 158 159 160 161 162 163
}


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


164 165
ABC_NAMESPACE_IMPL_END