intUtil.c 3.21 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 22
/**CFile****************************************************************

  FileName    [intUtil.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Interpolation engine.]

  Synopsis    [Various interpolation utilities.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

#include "intInt.h"

23 24 25
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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


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

  Synopsis    [Returns 1 if the property fails in the initial state.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Inter_ManCheckInitialState( Aig_Man_t * p )
{
    Cnf_Dat_t * pCnf;
49
    Aig_Obj_t * pObj;
Alan Mishchenko committed
50
    sat_solver * pSat;
51
    int i, status;
Alan Mishchenko committed
52
    //abctime clk = Abc_Clock();
Alan Mishchenko committed
53
    pCnf = Cnf_Derive( p, Saig_ManRegNum(p) ); 
54
    pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 1 );
Alan Mishchenko committed
55
    if ( pSat == NULL )
56 57
    {
        Cnf_DataFree( pCnf );
Alan Mishchenko committed
58
        return 0;
59
    }
Alan Mishchenko committed
60
    status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
61
    //ABC_PRT( "Time", Abc_Clock() - clk );
62 63 64 65 66
    if ( status == l_True )
    {
        p->pSeqModel = Abc_CexAlloc( Aig_ManRegNum(p), Saig_ManPiNum(p), 1 );
        Saig_ManForEachPi( p, pObj, i )
            if ( sat_solver_var_value( pSat, pCnf->pVarNums[Aig_ObjId(pObj)] ) )
67
                Abc_InfoSetBit( p->pSeqModel->pData, Aig_ManRegNum(p) + i );
68 69 70
    }
    Cnf_DataFree( pCnf );
    sat_solver_delete( pSat );
Alan Mishchenko committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    return status == l_True;
}

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

  Synopsis    [Returns 1 if the property holds in all states.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Inter_ManCheckAllStates( Aig_Man_t * p )
{
    Cnf_Dat_t * pCnf;
    sat_solver * pSat;
    int status;
90
    abctime clk = Abc_Clock();
Alan Mishchenko committed
91
    pCnf = Cnf_Derive( p, Saig_ManRegNum(p) ); 
92
    pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
Alan Mishchenko committed
93 94 95
    Cnf_DataFree( pCnf );
    if ( pSat == NULL )
        return 1;
Alan Mishchenko committed
96
    status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
Alan Mishchenko committed
97
    sat_solver_delete( pSat );
98
    ABC_PRT( "Time", Abc_Clock() - clk );
Alan Mishchenko committed
99 100 101 102 103 104 105 106
    return status == l_False;
}

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


107 108
ABC_NAMESPACE_IMPL_END