abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
absUtil.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [absUtil.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Abstraction package.]
8 
9  Synopsis [Interface to pthreads.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: absUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "abs.h"
22 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// DECLARATIONS ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// FUNCTION DEFINITIONS ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 /**Function*************************************************************
34 
35  Synopsis [This procedure sets default parameters.]
36 
37  Description []
38 
39  SideEffects []
40 
41  SeeAlso []
42 
43 ***********************************************************************/
45 {
46  memset( p, 0, sizeof(Abs_Par_t) );
47  p->nFramesMax = 0; // maximum frames
48  p->nFramesStart = 0; // starting frame
49  p->nFramesPast = 4; // overlap frames
50  p->nConfLimit = 0; // conflict limit
51  p->nLearnedMax = 1000; // max number of learned clauses
52  p->nLearnedStart = 1000; // max number of learned clauses
53  p->nLearnedDelta = 200; // max number of learned clauses
54  p->nLearnedPerce = 70; // max number of learned clauses
55  p->nTimeOut = 0; // timeout in seconds
56  p->nRatioMin = 0; // stop when less than this % of object is abstracted
57  p->nRatioMax = 30; // restart when more than this % of object is abstracted
58  p->fUseTermVars = 0; // use terminal variables
59  p->fUseRollback = 0; // use rollback to the starting number of frames
60  p->fPropFanout = 1; // propagate fanouts during refinement
61  p->fVerbose = 0; // verbose flag
62  p->iFrame = -1; // the number of frames covered
63  p->iFrameProved = -1; // the number of frames proved
64  p->nFramesNoChangeLim = 2; // the number of frames without change to dump abstraction
65 }
66 
67 /**Function*************************************************************
68 
69  Synopsis [Converting VTA vector to GLA vector.]
70 
71  Description []
72 
73  SideEffects []
74 
75  SeeAlso []
76 
77 ***********************************************************************/
79 {
80  Gia_Obj_t * pObj;
81  Vec_Int_t * vGla;
82  int nObjMask, nObjs = Gia_ManObjNum(p);
83  int i, Entry, nFrames = Vec_IntEntry( vVta, 0 );
84  assert( Vec_IntEntry(vVta, nFrames+1) == Vec_IntSize(vVta) );
85  // get the bitmask
86  nObjMask = (1 << Abc_Base2Log(nObjs)) - 1;
87  assert( nObjs <= nObjMask );
88  // go through objects
89  vGla = Vec_IntStart( nObjs );
90  Vec_IntForEachEntryStart( vVta, Entry, i, nFrames+2 )
91  {
92  pObj = Gia_ManObj( p, (Entry & nObjMask) );
93  assert( Gia_ObjIsRo(p, pObj) || Gia_ObjIsAnd(pObj) || Gia_ObjIsConst0(pObj) );
94  Vec_IntAddToEntry( vGla, (Entry & nObjMask), 1 );
95  }
96  Vec_IntWriteEntry( vGla, 0, nFrames );
97  return vGla;
98 }
99 
100 /**Function*************************************************************
101 
102  Synopsis [Converting GLA vector to VTA vector.]
103 
104  Description []
105 
106  SideEffects []
107 
108  SeeAlso []
109 
110 ***********************************************************************/
112 {
113  Vec_Int_t * vVta;
114  int nObjBits, nObjMask, nObjs = Gia_ManObjNum(p);
115  int i, k, j, Entry, Counter, nGlaSize;
116  //. get the GLA size
117  nGlaSize = Vec_IntSum(vGla);
118  // get the bitmask
119  nObjBits = Abc_Base2Log(nObjs);
120  nObjMask = (1 << Abc_Base2Log(nObjs)) - 1;
121  assert( nObjs <= nObjMask );
122  // go through objects
123  vVta = Vec_IntAlloc( 1000 );
124  Vec_IntPush( vVta, nFrames );
125  Counter = nFrames + 2;
126  for ( i = 0; i <= nFrames; i++, Counter += i * nGlaSize )
127  Vec_IntPush( vVta, Counter );
128  for ( i = 0; i < nFrames; i++ )
129  for ( k = 0; k <= i; k++ )
130  Vec_IntForEachEntry( vGla, Entry, j )
131  if ( Entry )
132  Vec_IntPush( vVta, (k << nObjBits) | j );
133  Counter = Vec_IntEntry(vVta, nFrames+1);
134  assert( Vec_IntEntry(vVta, nFrames+1) == Vec_IntSize(vVta) );
135  return vVta;
136 }
137 
138 /**Function*************************************************************
139 
140  Synopsis [Converting GLA vector to FLA vector.]
141 
142  Description []
143 
144  SideEffects []
145 
146  SeeAlso []
147 
148 ***********************************************************************/
150 {
151  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
152  return;
153  Gia_ObjSetTravIdCurrent(p, pObj);
154  Vec_IntWriteEntry( vGla, Gia_ObjId(p, pObj), 1 );
155  if ( Gia_ObjIsRo(p, pObj) )
156  return;
157  assert( Gia_ObjIsAnd(pObj) );
158  Gia_FlaConvertToGla_rec( p, Gia_ObjFanin0(pObj), vGla );
159  Gia_FlaConvertToGla_rec( p, Gia_ObjFanin1(pObj), vGla );
160 }
161 
162 /**Function*************************************************************
163 
164  Synopsis [Converting FLA vector to GLA vector.]
165 
166  Description []
167 
168  SideEffects []
169 
170  SeeAlso []
171 
172 ***********************************************************************/
174 {
175  Vec_Int_t * vGla;
176  Gia_Obj_t * pObj;
177  int i;
178  // mark const0 and relevant CI objects
181  Gia_ManForEachPi( p, pObj, i )
182  Gia_ObjSetTravIdCurrent(p, pObj);
183  Gia_ManForEachRo( p, pObj, i )
184  if ( !Vec_IntEntry(vFla, i) )
185  Gia_ObjSetTravIdCurrent(p, pObj);
186  // label all objects reachable from the PO and selected flops
187  vGla = Vec_IntStart( Gia_ManObjNum(p) );
188  Vec_IntWriteEntry( vGla, 0, 1 );
189  Gia_ManForEachPo( p, pObj, i )
190  Gia_FlaConvertToGla_rec( p, Gia_ObjFanin0(pObj), vGla );
191  Gia_ManForEachRi( p, pObj, i )
192  if ( Vec_IntEntry(vFla, i) )
193  Gia_FlaConvertToGla_rec( p, Gia_ObjFanin0(pObj), vGla );
194  return vGla;
195 }
196 
197 /**Function*************************************************************
198 
199  Synopsis [Converting GLA vector to FLA vector.]
200 
201  Description []
202 
203  SideEffects []
204 
205  SeeAlso []
206 
207 ***********************************************************************/
209 {
210  Vec_Int_t * vFla;
211  Gia_Obj_t * pObj;
212  int i;
213  vFla = Vec_IntStart( Gia_ManRegNum(p) );
214  Gia_ManForEachRo( p, pObj, i )
215  if ( Vec_IntEntry(vGla, Gia_ObjId(p, pObj)) )
216  Vec_IntWriteEntry( vFla, i, 1 );
217  return vFla;
218 }
219 
220 /**Function*************************************************************
221 
222  Synopsis []
223 
224  Description []
225 
226  SideEffects []
227 
228  SeeAlso []
229 
230 ***********************************************************************/
232 {
233  Gia_Obj_t * pObj;
234  int i, Count = 0;
235  Gia_ManForEachRo( p, pObj, i )
236  if ( Vec_IntEntry(vGla, Gia_ObjId(p, pObj)) )
237  Count++;
238  return Count;
239 }
241 {
242  Gia_Obj_t * pObj;
243  int i, Count = 0;
244  Gia_ManForEachAnd( p, pObj, i )
245  if ( Vec_IntEntry(vGla, Gia_ObjId(p, pObj)) )
246  Count++;
247  return Count;
248 }
249 
250 
251 ////////////////////////////////////////////////////////////////////////
252 /// END OF FILE ///
253 ////////////////////////////////////////////////////////////////////////
254 
255 
257 
char * memset()
Vec_Int_t * Gia_GlaConvertToFla(Gia_Man_t *p, Vec_Int_t *vGla)
Definition: absUtil.c:208
int Gia_GlaCountNodes(Gia_Man_t *p, Vec_Int_t *vGla)
Definition: absUtil.c:240
Vec_Int_t * Gia_VtaConvertToGla(Gia_Man_t *p, Vec_Int_t *vVta)
Definition: absUtil.c:78
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_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
Vec_Int_t * Gia_FlaConvertToGla(Gia_Man_t *p, Vec_Int_t *vFla)
Definition: absUtil.c:173
ABC_NAMESPACE_IMPL_START void Abs_ParSetDefaults(Abs_Par_t *p)
DECLARATIONS ///.
Definition: absUtil.c:44
Vec_Int_t * Gia_VtaConvertFromGla(Gia_Man_t *p, Vec_Int_t *vGla, int nFrames)
Definition: absUtil.c:111
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
int Gia_GlaCountFlops(Gia_Man_t *p, Vec_Int_t *vGla)
Definition: absUtil.c:231
int nObjs
Definition: absRefJ.c:100
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 Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
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
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
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
static int Counter
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Vec_IntSum(Vec_Int_t *p)
Definition: vecInt.h:1137
Definition: gia.h:95
static int Abc_Base2Log(unsigned n)
Definition: abc_global.h:251
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
void Gia_FlaConvertToGla_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vGla)
Definition: absUtil.c:149
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
#define assert(ex)
Definition: util_old.h:213
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
typedefABC_NAMESPACE_HEADER_START struct Abs_Par_t_ Abs_Par_t
INCLUDES ///.
Definition: abs.h:46
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387