summaryrefslogtreecommitdiffstats
path: root/src/aig/gia/giaSupMin.c
blob: 4abaab0fd10c8e09b94420b4639cbb5907c13036 (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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
/**CFile****************************************************************

  FileName    [giaSupMin.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Scalable AIG package.]

  Synopsis    [Support minimization for AIGs with don't-cares.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

#include "gia.h"
#include "kit.h"

ABC_NAMESPACE_IMPL_START


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

// decomposition manager
typedef struct Gia_ManSup_t_ Gia_ManSup_t;
struct Gia_ManSup_t_ 
{
    int             nVarsMax;     // the max number of variables
    int             nWordsMax;    // the max number of words
    Vec_Ptr_t *     vTruthVars;   // elementary truth tables
    Vec_Ptr_t *     vTruthNodes;  // internal truth tables
    // current problem
    Gia_Man_t *     pGia;
    int             iData;
    int             iCare;
    Vec_Int_t *     vConeCare;
    Vec_Int_t *     vConeData;
    unsigned *      pTruthIn;
    unsigned *      pTruthOut;
};

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

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

  Synopsis    [Starts Decmetry manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Gia_ManSup_t * Gia_ManSupStart( int nVarsMax )
{
    Gia_ManSup_t * p;
    assert( nVarsMax <= 20 );
    p = ABC_CALLOC( Gia_ManSup_t, 1 );
    p->nVarsMax    = nVarsMax;
    p->nWordsMax   = Kit_TruthWordNum( p->nVarsMax );
    p->vTruthVars  = Vec_PtrAllocTruthTables( p->nVarsMax );
    p->vTruthNodes = Vec_PtrAllocSimInfo( 512, p->nWordsMax );
    p->vConeCare   = Vec_IntAlloc( 512 );
    p->vConeData   = Vec_IntAlloc( 512 );
    p->pTruthIn    = ABC_ALLOC( unsigned, p->nWordsMax );
    p->pTruthOut   = ABC_ALLOC( unsigned, p->nWordsMax );
    return p;
}

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

  Synopsis    [Stops Decmetry manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManSupStop( Gia_ManSup_t * p )
{
    ABC_FREE( p->pTruthIn );
    ABC_FREE( p->pTruthOut );
    Vec_IntFreeP( &p->vConeCare );
    Vec_IntFreeP( &p->vConeData );
    Vec_PtrFreeP( &p->vTruthVars );
    Vec_PtrFreeP( &p->vTruthNodes );
    ABC_FREE( p );
}

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

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManSupExperimentOne( Gia_ManSup_t * p, Gia_Obj_t * pData, Gia_Obj_t * pCare )
{
    int iData = Gia_ObjId( p->pGia, Gia_Regular(pData) );
    int iCare = Gia_ObjId( p->pGia, Gia_Regular(pCare) );
    if ( !Gia_ObjIsAnd(Gia_Regular(pCare)) )
    {
        Abc_Print( 1, "Enable is not an AND.\n" );
        return;
    }
    Abc_Print( 1, "DataSupp = %6d. DataCone = %6d.   CareSupp = %6d. CareCone = %6d.", 
        Gia_ManSuppSize( p->pGia, &iData, 1 ),
        Gia_ManConeSize( p->pGia, &iData, 1 ),
        Gia_ManSuppSize( p->pGia, &iCare, 1 ),
        Gia_ManConeSize( p->pGia, &iCare, 1 ) );
    Abc_Print( 1, "\n" );
}

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

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManSupExperiment( Gia_Man_t * pGia, Vec_Int_t * vPairs )
{
    Gia_ManSup_t * p;
    Gia_Obj_t * pData, * pCare;
    int i;
    p = Gia_ManSupStart( 16 );
    p->pGia = pGia;
    assert( Vec_IntSize(vPairs) % 2 == 0 );
    for ( i = 0; i < Vec_IntSize(vPairs)/2; i++ )
    {
        Abc_Print( 1, "%6d : ", i );
        pData = Gia_ManPo( pGia, Vec_IntEntry(vPairs, 2*i+0) );
        pCare = Gia_ManPo( pGia, Vec_IntEntry(vPairs, 2*i+1) );
        Gia_ManSupExperimentOne( p, Gia_ObjChild0(pData), Gia_ObjChild0(pCare) );
    }
    Gia_ManSupStop( p );
}

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


ABC_NAMESPACE_IMPL_END