abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
int2Util.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [int2Util.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Interpolation engine.]
8 
9  Synopsis [Various utilities.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - Dec 1, 2013.]
16 
17  Revision [$Id: int2Util.c,v 1.00 2013/12/01 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "int2Int.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis []
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  Vec_Int_t * vCoPres, * vMap;
48  vCoPres = Vec_IntAlloc( 100 );
49  if ( vSop == NULL )
50  Vec_IntPush( vCoPres, 0 );
51  else
52  {
53  int i, k, Limit;
54  vMap = Vec_IntStart( nRegs );
55  Vec_IntForEachEntryStart( vSop, Limit, i, 1 )
56  {
57  for ( k = 0; k < Limit; k++ )
58  {
59  i++;
60  assert( Vec_IntEntry(vSop, i + k) < 2 * nRegs );
61  Vec_IntWriteEntry( vMap, Abc_Lit2Var(Vec_IntEntry(vSop, i + k)), 1 );
62  }
63  }
64  Vec_IntForEachEntry( vMap, Limit, i )
65  if ( Limit )
66  Vec_IntPush( vCoPres, i+1 );
67  Vec_IntFree( vMap );
68  }
69  return vCoPres;
70 }
71 
73 {
74  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
75  return;
76  Gia_ObjSetTravIdCurrent(p, pObj);
77  if ( Gia_ObjIsCi(pObj) )
78  return;
79  assert( Gia_ObjIsAnd(pObj) );
80  Int2_ManCollectInternal_rec( p, Gia_ObjFanin0(pObj), vNodes );
81  Int2_ManCollectInternal_rec( p, Gia_ObjFanin1(pObj), vNodes );
82  Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
83 }
85 {
86  Vec_Int_t * vNodes;
87  Gia_Obj_t * pObj;
88  int i, Entry;
91  Gia_ManForEachCi( p, pObj, i )
92  Gia_ObjSetTravIdCurrent(p, pObj);
93  vNodes = Vec_IntAlloc( 1000 );
94  Vec_IntForEachEntry( vCoPres, Entry, i )
95  Int2_ManCollectInternal_rec( p, Gia_ObjFanin0(Gia_ManCo(p, Entry)), vNodes );
96  return vNodes;
97 }
99 {
100  Vec_Int_t * vCoPres, * vNodes;
101  Gia_Man_t * pNew, * pTemp;
102  Gia_Obj_t * pObj;
103  int i, k, Entry, Limit;
104  int Lit, Cube, Sop;
105  assert( Gia_ManPoNum(p) == 1 );
106  // collect COs and ANDs
107  vCoPres = Int2_ManComputeCoPres( vSop, Gia_ManRegNum(p) );
108  vNodes = Int2_ManCollectInternal( p, vCoPres );
109  // create new manager
110  pNew = Gia_ManStart( Gia_ManObjNum(p) );
111  pNew->pName = Abc_UtilStrsav( p->pName );
112  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
113  Gia_ManConst0(p)->Value = 0;
114  Gia_ManForEachCi( p, pObj, i )
115  pObj->Value = Gia_ManAppendCi(pNew);
116  Gia_ManHashAlloc( pNew );
117  Gia_ManForEachObjVec( vNodes, p, pObj, i )
118  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
119  Vec_IntForEachEntry( vCoPres, Entry, i )
120  {
121  pObj = Gia_ManCo(p, Entry);
122  pObj->Value = Gia_ObjFanin0Copy( pObj );
123  }
124  // create additional cubes
125  Sop = 0;
126  Vec_IntForEachEntryStart( vSop, Limit, i, 1 )
127  {
128  Cube = 1;
129  for ( k = 0; k < Limit; k++ )
130  {
131  i++;
132  Lit = Vec_IntEntry( vSop, i + k );
133  pObj = Gia_ManRi( p, Abc_Lit2Var(Lit) );
134  Cube = Gia_ManHashAnd( pNew, Cube, Abc_LitNotCond(pObj->Value, Abc_LitIsCompl(Lit)) );
135  }
136  Sop = Gia_ManHashOr( pNew, Sop, Cube );
137  }
138  Gia_ManAppendCo( pNew, Sop );
139  Gia_ManHashStop( pNew );
140  // cleanup
141  pNew = Gia_ManCleanup( pTemp = pNew );
142  Gia_ManStop( pTemp );
143  return pNew;
144 }
145 
146 ////////////////////////////////////////////////////////////////////////
147 /// END OF FILE ///
148 ////////////////////////////////////////////////////////////////////////
149 
150 
152 
Vec_Int_t * Int2_ManCollectInternal(Gia_Man_t *p, Vec_Int_t *vCoPres)
Definition: int2Util.c:84
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
void Int2_ManCollectInternal_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vNodes)
Definition: int2Util.c:72
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
Definition: gia.h:404
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
ABC_NAMESPACE_IMPL_START Vec_Int_t * Int2_ManComputeCoPres(Vec_Int_t *vSop, int nRegs)
DECLARATIONS ///.
Definition: int2Util.c:45
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:611
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static Gia_Obj_t * Gia_ManRi(Gia_Man_t *p, int v)
Definition: gia.h:408
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
Gia_Man_t * Int2_ManProbToGia(Gia_Man_t *p, Vec_Int_t *vSop)
Definition: int2Util.c:98
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387