cgtMan.c 5.08 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    [cgtMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Clock gating package.]

  Synopsis    [Manipulation of clock gating manager.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

#include "cgtInt.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 49 50 51 52
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

  Synopsis    [Creates the manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Cgt_Man_t * Cgt_ManCreate( Aig_Man_t * pAig, Aig_Man_t * pCare, Cgt_Par_t * pPars )
{
    Cgt_Man_t * p;
    // prepare the sequential AIG
    assert( Saig_ManRegNum(pAig) > 0 );
    Aig_ManFanoutStart( pAig );
    Aig_ManSetPioNumbers( pAig );
    // create interpolation manager
Alan Mishchenko committed
53
    p = ABC_ALLOC( Cgt_Man_t, 1 ); 
Alan Mishchenko committed
54 55 56 57 58
    memset( p, 0, sizeof(Cgt_Man_t) );
    p->pPars      = pPars;
    p->pAig       = pAig;
    p->vGatesAll  = Vec_VecStart( Saig_ManRegNum(pAig) );
    p->vFanout    = Vec_PtrAlloc( 1000 );
Alan Mishchenko committed
59
    p->vVisited   = Vec_PtrAlloc( 1000 );
Alan Mishchenko committed
60
    p->nPattWords = 16;
Alan Mishchenko committed
61 62 63 64 65 66 67 68 69 70 71
    if ( pCare == NULL )
        return p;
    // check out the constraints
    if ( Aig_ManPiNum(pCare) != Aig_ManPiNum(pAig) )
    {
        printf( "The PI count of care (%d) and AIG (%d) differ. Careset is not used.\n", 
            Aig_ManPiNum(pCare), Aig_ManPiNum(pAig) );
        return p;
    }
    p->pCare = pCare;
    p->vSuppsInv = (Vec_Vec_t *)Aig_ManSupportsInverse( p->pCare );
Alan Mishchenko committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    return p;
}

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

  Synopsis    [Creates the manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cgt_ManClean( Cgt_Man_t * p )
{
    if ( p->pPart )
    {
        Aig_ManStop( p->pPart );
        p->pPart = NULL;
    }
    if ( p->pCnf )
    {
        Cnf_DataFree( p->pCnf );
        p->pCnf = NULL;
    }
    if ( p->pSat )
    {
        sat_solver_delete( p->pSat );
        p->pSat = NULL;
    }
    if ( p->vPatts )
    {
        Vec_PtrFree( p->vPatts );
        p->vPatts = NULL;
    }
}


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

  Synopsis    [Prints stats of the manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cgt_ManPrintStats( Cgt_Man_t * p )
{
Alan Mishchenko committed
124 125 126 127 128
    printf( "Params: LevMax = %d. CandMax = %d. OdcMax = %d. ConfMax = %d. VarMin = %d. FlopMin = %d.\n", 
        p->pPars->nLevelMax, p->pPars->nCandMax, p->pPars->nOdcMax, 
        p->pPars->nConfMax, p->pPars->nVarsMin, p->pPars->nFlopsMin );
    printf( "SAT   : Calls = %d. Unsat = %d. Sat = %d. Fails = %d.  Recycles = %d.  ", 
        p->nCalls, p->nCallsUnsat, p->nCallsSat, p->nCallsUndec, p->nRecycles );
Alan Mishchenko committed
129
    ABC_PRT( "Time", p->timeTotal );
Alan Mishchenko committed
130
/*
Alan Mishchenko committed
131
    p->timeOther = p->timeTotal-p->timeAig-p->timePrepare-p->timeSat-p->timeDecision;
Alan Mishchenko committed
132 133 134 135 136 137 138 139
    ABC_PRTP( "AIG        ", p->timeAig,       p->timeTotal );
    ABC_PRTP( "Prepare    ", p->timePrepare,   p->timeTotal );
    ABC_PRTP( "SAT solving", p->timeSat,       p->timeTotal );
    ABC_PRTP( "  unsat    ", p->timeSatUnsat,  p->timeTotal );
    ABC_PRTP( "  sat      ", p->timeSatSat,    p->timeTotal );
    ABC_PRTP( "  undecided", p->timeSatUndec,  p->timeTotal );
    ABC_PRTP( "Other      ", p->timeOther,     p->timeTotal );
    ABC_PRTP( "TOTAL      ", p->timeTotal,     p->timeTotal );
Alan Mishchenko committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
*/
}

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

  Synopsis    [Frees the manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Cgt_ManStop( Cgt_Man_t * p )
{
    if ( p->pPars->fVerbose )
        Cgt_ManPrintStats( p );
    if ( p->pFrame )
        Aig_ManStop( p->pFrame );
    Cgt_ManClean( p );
    Vec_PtrFree( p->vFanout );
Alan Mishchenko committed
162 163 164 165 166 167 168
    Vec_PtrFree( p->vVisited );
    if ( p->vGates )
        Vec_PtrFree( p->vGates );
    if ( p->vGatesAll )
        Vec_VecFree( p->vGatesAll );
    if ( p->vSuppsInv )
        Vec_VecFree( p->vSuppsInv );
Alan Mishchenko committed
169
    ABC_FREE( p );
Alan Mishchenko committed
170 171 172 173 174 175 176 177
}


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


178 179
ABC_NAMESPACE_IMPL_END