abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mpmMig.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mpmMig.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Configurable technology mapper.]
8 
9  Synopsis [Subject graph data structure.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 1, 2013.]
16 
17  Revision [$Id: mpmMig.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "mpmInt.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  Mig_Man_t * p;
48  assert( sizeof(Mig_Obj_t) >= 16 );
49  assert( (1 << MIG_BASE) == MIG_MASK + 1 );
50  p = ABC_CALLOC( Mig_Man_t, 1 );
51  Vec_IntGrow( &p->vCis, 1024 );
52  Vec_IntGrow( &p->vCos, 1024 );
53  Mig_ManAppendObj( p ); // const0
54  return p;
55 }
57 {
58  if ( 0 )
59  printf( "Subject graph uses %d pages of %d objects with %d entries. Total memory = %.2f MB.\n",
60  Vec_PtrSize(&p->vPages), MIG_MASK + 1, p->nObjs,
61  1.0 * Vec_PtrSize(&p->vPages) * (MIG_MASK + 1) * 16 / (1 << 20) );
62  // attributes
63  ABC_FREE( p->vTravIds.pArray );
64  ABC_FREE( p->vCopies.pArray );
65  ABC_FREE( p->vLevels.pArray );
66  ABC_FREE( p->vRefs.pArray );
67  ABC_FREE( p->vSibls.pArray );
68  // pages
70  --p->pPage, ABC_FREE( p->pPage );
71  // objects
72  ABC_FREE( p->vPages.pArray );
73  ABC_FREE( p->vCis.pArray );
74  ABC_FREE( p->vCos.pArray );
75  ABC_FREE( p->pName );
76  ABC_FREE( p );
77 }
78 
79 /**Function*************************************************************
80 
81  Synopsis []
82 
83  Description []
84 
85  SideEffects []
86 
87  SeeAlso []
88 
89 ***********************************************************************/
90 int Mig_ManTypeNum( Mig_Man_t * p, int Type )
91 {
92  Mig_Obj_t * pObj;
93  int Counter = 0;
94  Mig_ManForEachNode( p, pObj )
95  Counter += (Mig_ObjNodeType(pObj) == Type);
96  return Counter;
97 }
99 {
100  return Mig_ManTypeNum(p, 1);
101 }
103 {
104  return Mig_ManTypeNum(p, 2);
105 }
107 {
108  return Mig_ManTypeNum(p, 3);
109 }
110 
111 
112 /**Function*************************************************************
113 
114  Synopsis []
115 
116  Description []
117 
118  SideEffects []
119 
120  SeeAlso []
121 
122 ***********************************************************************/
124 {
125  Mig_Obj_t * pObj;
126  int i, iFanin;
127  // increment references
128  Vec_IntFill( &p->vRefs, Mig_ManObjNum(p), 0 );
129  Mig_ManForEachObj( p, pObj )
130  {
131  Mig_ObjForEachFaninId( pObj, iFanin, i )
132  Vec_IntAddToEntry( &p->vRefs, iFanin, 1 );
133  if ( Mig_ObjSiblId(pObj) )
134  Vec_IntAddToEntry( &p->vRefs, Mig_ObjSiblId(pObj), 1 );
135  }
136 }
137 
138 /**Function*************************************************************
139 
140  Synopsis []
141 
142  Description []
143 
144  SideEffects []
145 
146  SeeAlso []
147 
148 ***********************************************************************/
150 {
151  if ( pObj == NULL )
152  return 0;
153  if ( Mig_ObjIsTravIdCurrent(pObj) )
154  return 0;
156  if ( Mig_ObjIsCi(pObj) )
157  return 1;
158  assert( Mig_ObjIsNode(pObj) );
159  return Mig_ManSuppSize_rec( Mig_ObjFanin0(pObj) ) +
162 }
163 int Mig_ManSuppSize2_rec( Mig_Man_t * p, int iObj )
164 {
165  Mig_Obj_t * pObj;
166  if ( iObj == MIG_NONE )
167  return 0;
168  if ( Mig_ObjIsTravIdCurrentId(p, iObj) )
169  return 0;
170  Mig_ObjSetTravIdCurrentId(p, iObj);
171  pObj = Mig_ManObj( p, iObj );
172  if ( Mig_ObjIsCi(pObj) )
173  return 1;
174  assert( Mig_ObjIsNode(pObj) );
175  return Mig_ManSuppSize2_rec( p, Mig_ObjFaninId0(pObj) ) +
178 }
180 {
181  Mig_ObjIncrementTravId( pObj );
182 // return Mig_ManSuppSize_rec( pObj );
183  return Mig_ManSuppSize2_rec( Mig_ObjMan(pObj), Mig_ObjId(pObj) );
184 }
186 {
187  Mig_Obj_t * pObj;
188  int Counter = 0;
189  abctime clk = Abc_Clock();
190  Mig_ManForEachObj( p, pObj )
191  if ( Mig_ObjIsNode(pObj) )
192  Counter += (Mig_ManSuppSizeOne(pObj) <= 16);
193  printf( "Nodes with small support %d (out of %d)\n", Counter, Mig_ManNodeNum(p) );
194  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
195  return Counter;
196 }
197 
198 ////////////////////////////////////////////////////////////////////////
199 /// END OF FILE ///
200 ////////////////////////////////////////////////////////////////////////
201 
202 
204 
#define Mig_ManForEachNode(p, pObj)
Definition: mpmMig.h:322
static int Mig_ManNodeNum(Mig_Man_t *p)
Definition: mpmMig.h:110
static int Mig_ManObjNum(Mig_Man_t *p)
Definition: mpmMig.h:109
static Mig_Man_t * Mig_ObjMan(Mig_Obj_t *p)
Definition: mpmMig.h:153
Vec_Int_t vLevels
Definition: mpmMig.h:76
static Mig_Obj_t * Mig_ManObj(Mig_Man_t *p, int v)
Definition: mpmMig.h:116
Vec_Int_t vCopies
Definition: mpmMig.h:79
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define MIG_NONE
INCLUDES ///.
Definition: mpmMig.h:37
Vec_Int_t vRefs
Definition: mpmMig.h:78
static int Mig_ObjIsNode(Mig_Obj_t *p)
Definition: mpmMig.h:137
#define Mig_ManForEachObj(p, pObj)
MACRO DEFINITIONS ///.
Definition: mpmMig.h:304
static Mig_Obj_t * Mig_ManAppendObj(Mig_Man_t *p)
Definition: mpmMig.h:217
static int Mig_ObjIsCi(Mig_Obj_t *p)
Definition: mpmMig.h:134
int iPage
Definition: mpmMig.h:72
static int Mig_ObjIsTravIdCurrent(Mig_Obj_t *p)
Definition: mpmMig.h:201
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Mig_ManSetRefs(Mig_Man_t *p)
Definition: mpmMig.c:123
int nObjs
Definition: mpmMig.h:64
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
Vec_Int_t vCis
Definition: mpmMig.h:68
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static Mig_Obj_t * Mig_ObjFanin1(Mig_Obj_t *p)
Definition: mpmMig.h:177
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
#define MIG_BASE
Definition: mpmMig.h:41
static void Mig_ObjSetTravIdCurrent(Mig_Obj_t *p)
Definition: mpmMig.h:199
void Mig_ManStop(Mig_Man_t *p)
Definition: mpmMig.c:56
int Mig_ManXorNum(Mig_Man_t *p)
Definition: mpmMig.c:102
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Mig_ObjFaninId1(Mig_Obj_t *p)
Definition: mpmMig.h:172
static int Mig_ObjFaninId2(Mig_Obj_t *p)
Definition: mpmMig.h:173
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
#define Mig_ObjForEachFaninId(p, iFanin, i)
Definition: mpmMig.h:333
static Mig_Obj_t * Mig_ObjFanin0(Mig_Obj_t *p)
Definition: mpmMig.h:176
static int Counter
Vec_Int_t vSibls
Definition: mpmMig.h:77
static int Mig_ObjIsTravIdCurrentId(Mig_Man_t *p, int Id)
Definition: mpmMig.h:204
int Mig_ManSuppSizeTest(Mig_Man_t *p)
Definition: mpmMig.c:185
static Mig_Obj_t * Mig_ObjFanin2(Mig_Obj_t *p)
Definition: mpmMig.h:178
static int Mig_ObjSiblId(Mig_Obj_t *p)
Definition: mpmMig.h:188
Vec_Int_t vCos
Definition: mpmMig.h:69
Mig_Obj_t * pPage
Definition: mpmMig.h:71
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Vec_Ptr_t vPages
Definition: mpmMig.h:67
char * pName
Definition: mpmMig.h:63
Vec_Int_t vTravIds
Definition: mpmMig.h:75
static int Mig_ObjFaninId0(Mig_Obj_t *p)
Definition: mpmMig.h:171
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Mig_ManTypeNum(Mig_Man_t *p, int Type)
Definition: mpmMig.c:90
int Mig_ManSuppSize_rec(Mig_Obj_t *pObj)
Definition: mpmMig.c:149
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int Mig_ManMuxNum(Mig_Man_t *p)
Definition: mpmMig.c:106
ABC_NAMESPACE_IMPL_START Mig_Man_t * Mig_ManStart()
DECLARATIONS ///.
Definition: mpmMig.c:45
int Mig_ManSuppSize2_rec(Mig_Man_t *p, int iObj)
Definition: mpmMig.c:163
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Mig_ObjSetTravIdCurrentId(Mig_Man_t *p, int Id)
Definition: mpmMig.h:203
static int Mig_ObjNodeType(Mig_Obj_t *p)
Definition: mpmMig.h:144
#define MIG_MASK
Definition: mpmMig.h:40
int Mig_ManSuppSizeOne(Mig_Obj_t *pObj)
Definition: mpmMig.c:179
int Mig_ManAndNum(Mig_Man_t *p)
Definition: mpmMig.c:98
static void Mig_ObjIncrementTravId(Mig_Obj_t *p)
Definition: mpmMig.h:198