summaryrefslogtreecommitdiffstats
path: root/src/map/cov/covMinMan.c
blob: 12a9e57398509bd125c4d4e3fc4c0a56f48e2d79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
/**CFile****************************************************************

  FileName    [covMinMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Mapping into network of SOPs/ESOPs.]

  Synopsis    [SOP manipulation.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

#include "covInt.h"

ABC_NAMESPACE_IMPL_START


////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

  Synopsis    [Starts the minimization manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Min_Man_t * Min_ManAlloc( int nVars )
{
    Min_Man_t * pMan;
    // start the manager
    pMan = ABC_ALLOC( Min_Man_t, 1 );
    memset( pMan, 0, sizeof(Min_Man_t) );
    pMan->nVars   = nVars;
    pMan->nWords  = Abc_BitWordNum( nVars * 2 );
    pMan->pMemMan = Extra_MmFixedStart( sizeof(Min_Cube_t) + sizeof(unsigned) * (pMan->nWords - 1) );
    // allocate storage for the temporary cover
    pMan->ppStore = ABC_ALLOC( Min_Cube_t *, pMan->nVars + 1 );
    // create tautology cubes
    Min_ManClean( pMan, nVars );
    pMan->pOne0  = Min_CubeAlloc( pMan );
    pMan->pOne1  = Min_CubeAlloc( pMan );
    pMan->pTemp  = Min_CubeAlloc( pMan );
    pMan->pBubble = Min_CubeAlloc( pMan );  pMan->pBubble->uData[0] = 0;
    // create trivial cubes
    Min_ManClean( pMan, 1 );
    pMan->pTriv0[0] = Min_CubeAllocVar( pMan, 0, 0 );
    pMan->pTriv0[1] = Min_CubeAllocVar( pMan, 0, 1 );   
    pMan->pTriv1[0] = Min_CubeAllocVar( pMan, 0, 0 );
    pMan->pTriv1[1] = Min_CubeAllocVar( pMan, 0, 1 );   
    Min_ManClean( pMan, nVars );
    return pMan;
}

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

  Synopsis    [Cleans the minimization manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Min_ManClean( Min_Man_t * p, int nSupp )
{
    // set the size of the cube manager
    p->nVars  = nSupp;
    p->nWords = Abc_BitWordNum(2*nSupp);
    // clean the storage
    memset( p->ppStore, 0, sizeof(Min_Cube_t *) * (nSupp + 1) );
    p->nCubes = 0;
}

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

  Synopsis    [Stops the minimization manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Min_ManFree( Min_Man_t * p )
{
    Extra_MmFixedStop( p->pMemMan );
    ABC_FREE( p->ppStore );
    ABC_FREE( p );
}


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


ABC_NAMESPACE_IMPL_END