abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mpmMig.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mpmMig.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Configurable technology mapper.]
8 
9  Synopsis [Internal declarations.]
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.h,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__map__mpm__mig__h
22 #define ABC__map__mpm__mig__h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include "misc/vec/vec.h"
30 
32 
33 ////////////////////////////////////////////////////////////////////////
34 /// PARAMETERS ///
35 ////////////////////////////////////////////////////////////////////////
36 
37 #define MIG_NONE 0x7FFFFFFF
38 //#define MIG_MASK 0x0000FFFF
39 //#define MIG_BASE 16
40 #define MIG_MASK 0x0000FFF
41 #define MIG_BASE 12
42 
43 ////////////////////////////////////////////////////////////////////////
44 /// BASIC TYPES ///
45 ////////////////////////////////////////////////////////////////////////
46 
47 typedef struct Mig_Fan_t_ Mig_Fan_t;
48 struct Mig_Fan_t_
49 {
50  unsigned fCompl : 1; // the complemented attribute
51  unsigned Id : 31; // fanin ID
52 };
53 
54 typedef struct Mig_Obj_t_ Mig_Obj_t;
55 struct Mig_Obj_t_
56 {
57  Mig_Fan_t pFans[4]; // fanins
58 };
59 
60 typedef struct Mig_Man_t_ Mig_Man_t;
61 struct Mig_Man_t_
62 {
63  char * pName; // name
64  int nObjs; // number of objects
65  int nRegs; // number of flops
66  int nChoices; // number of choices
67  Vec_Ptr_t vPages; // memory pages
68  Vec_Int_t vCis; // CI IDs
69  Vec_Int_t vCos; // CO IDs
70  // object iterator
71  Mig_Obj_t * pPage; // current page
72  int iPage; // current page index
73  // attributes
74  int nTravIds; // traversal ID counter
75  Vec_Int_t vTravIds; // traversal IDs
76  Vec_Int_t vLevels; // levels
77  Vec_Int_t vSibls; // choice nodes
78  Vec_Int_t vRefs; // ref counters
79  Vec_Int_t vCopies; // copies
80  void * pMan; // mapping manager
81 };
82 
83 /*
84  Usage of fanin atrributes
85  --------------------------------------------------------------------------------------------------------------
86  Const0 Terminal CI CO Buf Node Node2 Node3 And2 XOR2 MUX MAJ Sentinel
87  --------------------------------------------------------------------------------------------------------------
88  0 - -/fanin0 - fanin0 fanin0 fanin0 fanin0 fanin0 fanin0 fanin1 fanin0 fanin1 -
89  1 - - - - - fanin1 fanin1 fanin1 fanin1 fanin0 fanin1 fanin0 -
90  2 - CIO ID CIO ID CIO ID - -/fanin2 - fanin2 - - fanin2 fanin2 -
91  3 0 ID ID ID ID ID ID ID ID ID ID ID -
92  --------------------------------------------------------------------------------------------------------------
93 
94  One memory page contain 2^MIG_BASE+2 16-byte objects.
95  - the first object contains the pointer to the manager (8 bytes)
96  - the next 2^MIG_BASE are potentially used as objects
97  - the last object is a sentinel to signal the end of the page
98 */
99 
100 static inline int Mig_IdPage( int v ) { return v >> MIG_BASE; }
101 static inline int Mig_IdCell( int v ) { return v & MIG_MASK; }
102 
103 static inline char * Mig_ManName( Mig_Man_t * p ) { return p->pName; }
104 static inline int Mig_ManCiNum( Mig_Man_t * p ) { return Vec_IntSize(&p->vCis); }
105 static inline int Mig_ManCoNum( Mig_Man_t * p ) { return Vec_IntSize(&p->vCos); }
106 static inline int Mig_ManPiNum( Mig_Man_t * p ) { return Vec_IntSize(&p->vCis) - p->nRegs; }
107 static inline int Mig_ManPoNum( Mig_Man_t * p ) { return Vec_IntSize(&p->vCos) - p->nRegs; }
108 static inline int Mig_ManRegNum( Mig_Man_t * p ) { return p->nRegs; }
109 static inline int Mig_ManObjNum( Mig_Man_t * p ) { return p->nObjs; }
110 static inline int Mig_ManNodeNum( Mig_Man_t * p ) { return p->nObjs - Vec_IntSize(&p->vCis) - Vec_IntSize(&p->vCos) - 1; }
111 static inline int Mig_ManCandNum( Mig_Man_t * p ) { return Mig_ManCiNum(p) + Mig_ManNodeNum(p); }
112 static inline int Mig_ManChoiceNum( Mig_Man_t * p ) { return p->nChoices; }
113 static inline void Mig_ManSetRegNum( Mig_Man_t * p, int v ) { p->nRegs = v; }
114 
115 static inline Mig_Obj_t * Mig_ManPage( Mig_Man_t * p, int v ) { return (Mig_Obj_t *)Vec_PtrEntry(&p->vPages, Mig_IdPage(v)); }
116 static inline Mig_Obj_t * Mig_ManObj( Mig_Man_t * p, int v ) { assert(v >= 0 && v < p->nObjs); return Mig_ManPage(p, v) + Mig_IdCell(v); }
117 static inline Mig_Obj_t * Mig_ManCi( Mig_Man_t * p, int v ) { return Mig_ManObj( p, Vec_IntEntry(&p->vCis,v) ); }
118 static inline Mig_Obj_t * Mig_ManCo( Mig_Man_t * p, int v ) { return Mig_ManObj( p, Vec_IntEntry(&p->vCos,v) ); }
119 static inline Mig_Obj_t * Mig_ManPi( Mig_Man_t * p, int v ) { assert( v < Mig_ManPiNum(p) ); return Mig_ManCi( p, v ); }
120 static inline Mig_Obj_t * Mig_ManPo( Mig_Man_t * p, int v ) { assert( v < Mig_ManPoNum(p) ); return Mig_ManCo( p, v ); }
121 static inline Mig_Obj_t * Mig_ManRo( Mig_Man_t * p, int v ) { assert( v < Mig_ManRegNum(p) ); return Mig_ManCi( p, Mig_ManPiNum(p)+v ); }
122 static inline Mig_Obj_t * Mig_ManRi( Mig_Man_t * p, int v ) { assert( v < Mig_ManRegNum(p) ); return Mig_ManCo( p, Mig_ManPoNum(p)+v ); }
123 static inline Mig_Obj_t * Mig_ManConst0( Mig_Man_t * p ) { return Mig_ManObj(p, 0); }
124 
125 static inline int Mig_FanCompl( Mig_Obj_t * p, int i ) { return p->pFans[i].fCompl; }
126 static inline int Mig_FanId( Mig_Obj_t * p, int i ) { return p->pFans[i].Id; }
127 static inline int Mig_FanIsNone( Mig_Obj_t * p, int i ) { return p->pFans[i].Id == MIG_NONE; }
128 static inline int Mig_FanSetCompl( Mig_Obj_t * p, int i, int v ) { assert( !(v >> 1) ); return p->pFans[i].fCompl = v; }
129 static inline int Mig_FanSetId( Mig_Obj_t * p, int i, int v ) { assert(v >= 0 && v < MIG_NONE); return p->pFans[i].Id = v; }
130 
131 static inline int Mig_ObjIsNone( Mig_Obj_t * p ) { return Mig_FanIsNone( p, 3 ); }
132 static inline int Mig_ObjIsConst0( Mig_Obj_t * p ) { return Mig_FanId( p, 3 ) == 0; }
133 static inline int Mig_ObjIsTerm( Mig_Obj_t * p ) { return Mig_FanIsNone( p, 1 ) && !Mig_FanIsNone( p, 2 ); }
134 static inline int Mig_ObjIsCi( Mig_Obj_t * p ) { return Mig_ObjIsTerm(p) && Mig_FanIsNone( p, 0 ); }
135 static inline int Mig_ObjIsCo( Mig_Obj_t * p ) { return Mig_ObjIsTerm(p) && !Mig_FanIsNone( p, 0 ); }
136 static inline int Mig_ObjIsBuf( Mig_Obj_t * p ) { return Mig_FanIsNone( p, 1 ) && Mig_FanIsNone( p, 2 ) && !Mig_FanIsNone( p, 0 ); }
137 static inline int Mig_ObjIsNode( Mig_Obj_t * p ) { return!Mig_FanIsNone( p, 1 ); }
138 static inline int Mig_ObjIsNode2( Mig_Obj_t * p ) { return Mig_ObjIsNode( p ) && Mig_FanIsNone( p, 2 ); }
139 static inline int Mig_ObjIsNode3( Mig_Obj_t * p ) { return Mig_ObjIsNode( p ) && !Mig_FanIsNone( p, 2 ); }
140 static inline int Mig_ObjIsAnd( Mig_Obj_t * p ) { return Mig_ObjIsNode2( p ) && Mig_FanId(p, 0) < Mig_FanId(p, 1); }
141 static inline int Mig_ObjIsXor( Mig_Obj_t * p ) { return Mig_ObjIsNode2( p ) && Mig_FanId(p, 0) > Mig_FanId(p, 1); }
142 static inline int Mig_ObjIsMux( Mig_Obj_t * p ) { return Mig_ObjIsNode3( p ); }
143 static inline int Mig_ObjIsCand( Mig_Obj_t * p ) { return Mig_ObjIsNode(p) || Mig_ObjIsCi(p); }
144 static inline int Mig_ObjNodeType( Mig_Obj_t * p ) { return Mig_ObjIsAnd(p) ? 1 : (Mig_ObjIsXor(p) ? 2 : 3); }
145 
146 static inline int Mig_ObjId( Mig_Obj_t * p ) { return Mig_FanId( p, 3 ); }
147 static inline void Mig_ObjSetId( Mig_Obj_t * p, int v ) { Mig_FanSetId( p, 3, v ); }
148 static inline int Mig_ObjCioId( Mig_Obj_t * p ) { assert( Mig_ObjIsTerm(p) ); return Mig_FanId( p, 2 ); }
149 static inline void Mig_ObjSetCioId( Mig_Obj_t * p, int v ) { assert( Mig_FanIsNone(p, 1) ); Mig_FanSetId( p, 2, v ); }
150 static inline int Mig_ObjPhase( Mig_Obj_t * p ) { return Mig_FanCompl( p, 3 ); }
151 static inline void Mig_ObjSetPhase( Mig_Obj_t * p, int v ) { Mig_FanSetCompl( p, 3, v ); }
152 
153 static inline Mig_Man_t * Mig_ObjMan( Mig_Obj_t * p ) { return *((Mig_Man_t**)(p - Mig_IdCell(Mig_ObjId(p)) - 1)); }
154 //static inline Mig_Obj_t ** Mig_ObjPageP( Mig_Obj_t * p ) { return *((Mig_Obj_t***)(p - Mig_IdCell(Mig_ObjId(p))) - 1);}
155 static inline Mig_Obj_t * Mig_ObjObj( Mig_Obj_t * p, int i ) { return Mig_ManObj( Mig_ObjMan(p), i ); }
156 
157 static inline int Mig_ManIdToCioId( Mig_Man_t * p, int Id ) { return Mig_ObjCioId( Mig_ManObj(p, Id) ); }
158 static inline int Mig_ManCiIdToId( Mig_Man_t * p, int CiId ) { return Mig_ObjId( Mig_ManCi(p, CiId) ); }
159 static inline int Mig_ManCoIdToId( Mig_Man_t * p, int CoId ) { return Mig_ObjId( Mig_ManCo(p, CoId) ); }
160 
161 static inline int Mig_ObjIsPi( Mig_Obj_t * p ) { return Mig_ObjIsCi(p) && Mig_ObjCioId(p) < Mig_ManPiNum(Mig_ObjMan(p)); }
162 static inline int Mig_ObjIsPo( Mig_Obj_t * p ) { return Mig_ObjIsCo(p) && Mig_ObjCioId(p) < Mig_ManPoNum(Mig_ObjMan(p)); }
163 static inline int Mig_ObjIsRo( Mig_Obj_t * p ) { return Mig_ObjIsCi(p) && Mig_ObjCioId(p) >= Mig_ManPiNum(Mig_ObjMan(p)); }
164 static inline int Mig_ObjIsRi( Mig_Obj_t * p ) { return Mig_ObjIsCo(p) && Mig_ObjCioId(p) >= Mig_ManPoNum(Mig_ObjMan(p)); }
165 
166 static inline Mig_Obj_t * Mig_ObjRoToRi( Mig_Obj_t * p ) { Mig_Man_t * pMan = Mig_ObjMan(p); assert( Mig_ObjIsRo(p) ); return Mig_ManCo(pMan, Mig_ManCoNum(pMan) - Mig_ManCiNum(pMan) + Mig_ObjCioId(p)); }
167 static inline Mig_Obj_t * Mig_ObjRiToRo( Mig_Obj_t * p ) { Mig_Man_t * pMan = Mig_ObjMan(p); assert( Mig_ObjIsRi(p) ); return Mig_ManCi(pMan, Mig_ManCiNum(pMan) - Mig_ManCoNum(pMan) + Mig_ObjCioId(p)); }
168 
169 static inline int Mig_ObjHasFanin( Mig_Obj_t * p, int i ) { return i < 3 && Mig_FanId(p, i) != MIG_NONE; }
170 static inline int Mig_ObjFaninId( Mig_Obj_t * p, int i ) { assert( i < 3 && Mig_FanId(p, i) < Mig_ObjId(p) ); return Mig_FanId( p, i ); }
171 static inline int Mig_ObjFaninId0( Mig_Obj_t * p ) { return Mig_FanId( p, 0 ); }
172 static inline int Mig_ObjFaninId1( Mig_Obj_t * p ) { return Mig_FanId( p, 1 ); }
173 static inline int Mig_ObjFaninId2( Mig_Obj_t * p ) { return Mig_FanId( p, 2 ); }
174 static inline Mig_Obj_t * Mig_ObjFanin( Mig_Obj_t * p, int i ) { return Mig_ManObj( Mig_ObjMan(p), Mig_ObjFaninId(p, i) ); }
175 //static inline Mig_Obj_t * Mig_ObjFanin( Mig_Obj_t * p, int i ) { return Mig_ObjPageP(p)[Mig_IdPage(Mig_ObjFaninId(p, i))] + Mig_IdCell(Mig_ObjFaninId(p, i)); }
176 static inline Mig_Obj_t * Mig_ObjFanin0( Mig_Obj_t * p ) { return Mig_FanIsNone(p, 0) ? NULL: Mig_ObjFanin(p, 0); }
177 static inline Mig_Obj_t * Mig_ObjFanin1( Mig_Obj_t * p ) { return Mig_FanIsNone(p, 1) ? NULL: Mig_ObjFanin(p, 1); }
178 static inline Mig_Obj_t * Mig_ObjFanin2( Mig_Obj_t * p ) { return Mig_FanIsNone(p, 2) ? NULL: Mig_ObjFanin(p, 2); }
179 static inline int Mig_ObjFaninC( Mig_Obj_t * p, int i ) { assert( i < 3 ); return Mig_FanCompl(p, i); }
180 static inline int Mig_ObjFaninC0( Mig_Obj_t * p ) { return Mig_FanCompl(p, 0); }
181 static inline int Mig_ObjFaninC1( Mig_Obj_t * p ) { return Mig_FanCompl(p, 1); }
182 static inline int Mig_ObjFaninC2( Mig_Obj_t * p ) { return Mig_FanCompl(p, 2); }
183 static inline int Mig_ObjFaninLit( Mig_Obj_t * p, int i ) { return Abc_Var2Lit( Mig_FanId(p, i), Mig_FanCompl(p, i) ); }
184 static inline void Mig_ObjFlipFaninC( Mig_Obj_t * p, int i ) { Mig_FanSetCompl( p, i, !Mig_FanCompl(p, i) ); }
185 static inline int Mig_ObjWhatFanin( Mig_Obj_t * p, int i ) { if (Mig_FanId(p, 0) == i) return 0; if (Mig_FanId(p, 1) == i) return 1; if (Mig_FanId(p, 2) == i) return 2; return -1; }
186 static inline void Mig_ObjSetFaninLit( Mig_Obj_t * p, int i, int l ) { assert( l >= 0 && (l >> 1) < Mig_ObjId(p) ); Mig_FanSetId(p, i, Abc_Lit2Var(l)); Mig_FanSetCompl(p, i, Abc_LitIsCompl(l)); }
187 
188 static inline int Mig_ObjSiblId( Mig_Obj_t * p ) { return Vec_IntSize(&Mig_ObjMan(p)->vSibls) == 0 ? 0: Vec_IntEntry(&Mig_ObjMan(p)->vSibls, Mig_ObjId(p)); }
189 static inline void Mig_ObjSetSiblId( Mig_Obj_t * p, int s ) { assert( s > 0 && Mig_ObjId(p) > s ); Vec_IntWriteEntry( &Mig_ObjMan(p)->vSibls, Mig_ObjId(p), s ); }
190 static inline Mig_Obj_t * Mig_ObjSibl( Mig_Obj_t * p ) { return Mig_ObjSiblId(p) == 0 ? NULL: Mig_ObjObj(p, Mig_ObjSiblId(p)); }
191 static inline int Mig_ObjRefNum( Mig_Obj_t * p ) { return Vec_IntEntry(&Mig_ObjMan(p)->vRefs, Mig_ObjId(p)); }
192 
193 static inline void Mig_ManCleanCopy( Mig_Man_t * p ) { if ( p->vCopies.pArray == NULL ) Vec_IntFill( &p->vCopies, Mig_ManObjNum(p), -1 ); }
194 static inline int Mig_ObjCopy( Mig_Obj_t * p ) { return Vec_IntSize(&Mig_ObjMan(p)->vCopies) == 0 ? -1: Vec_IntEntry(&Mig_ObjMan(p)->vCopies, Mig_ObjId(p)); }
195 static inline void Mig_ObjSetCopy( Mig_Obj_t * p, int i ) { assert( Vec_IntSize(&Mig_ObjMan(p)->vCopies) != 0 ); Vec_IntWriteEntry(&Mig_ObjMan(p)->vCopies, Mig_ObjId(p), i); }
196 
197 static inline void Mig_ManIncrementTravId( Mig_Man_t * p ) { if ( p->vTravIds.pArray == NULL ) Vec_IntFill( &p->vTravIds, Mig_ManObjNum(p)+500, 0 ); p->nTravIds++; }
198 static inline void Mig_ObjIncrementTravId( Mig_Obj_t * p ) { if ( Mig_ObjMan(p)->vTravIds.pArray == NULL ) Vec_IntFill( &Mig_ObjMan(p)->vTravIds, Mig_ManObjNum(Mig_ObjMan(p))+500, 0 ); Mig_ObjMan(p)->nTravIds++; }
199 static inline void Mig_ObjSetTravIdCurrent( Mig_Obj_t * p ) { Vec_IntSetEntry(&Mig_ObjMan(p)->vTravIds, Mig_ObjId(p), Mig_ObjMan(p)->nTravIds ); }
200 static inline void Mig_ObjSetTravIdPrevious( Mig_Obj_t * p ) { Vec_IntSetEntry(&Mig_ObjMan(p)->vTravIds, Mig_ObjId(p), Mig_ObjMan(p)->nTravIds-1 ); }
201 static inline int Mig_ObjIsTravIdCurrent( Mig_Obj_t * p ) { return (Vec_IntGetEntry(&Mig_ObjMan(p)->vTravIds, Mig_ObjId(p)) == Mig_ObjMan(p)->nTravIds); }
202 static inline int Mig_ObjIsTravIdPrevious( Mig_Obj_t * p ) { return (Vec_IntGetEntry(&Mig_ObjMan(p)->vTravIds, Mig_ObjId(p)) == Mig_ObjMan(p)->nTravIds-1); }
203 static inline void Mig_ObjSetTravIdCurrentId( Mig_Man_t * p, int Id ) { Vec_IntSetEntry(&p->vTravIds, Id, p->nTravIds ); }
204 static inline int Mig_ObjIsTravIdCurrentId( Mig_Man_t * p, int Id ) { return (Vec_IntGetEntry(&p->vTravIds, Id) == p->nTravIds); }
205 
206 /**Function*************************************************************
207 
208  Synopsis []
209 
210  Description []
211 
212  SideEffects []
213 
214  SeeAlso []
215 
216 ***********************************************************************/
217 static inline Mig_Obj_t * Mig_ManAppendObj( Mig_Man_t * p )
218 {
219  Mig_Obj_t * pObj;
220  assert( p->nObjs < MIG_NONE );
221  if ( p->nObjs >= (Vec_PtrSize(&p->vPages) << MIG_BASE) )
222  {
223  Mig_Obj_t * pPage;// int i;
224  assert( p->nObjs == (Vec_PtrSize(&p->vPages) << MIG_BASE) );
225  pPage = ABC_FALLOC( Mig_Obj_t, MIG_MASK + 3 ); // 1 for mask, 1 for prefix, 1 for sentinel
226  *((void **)pPage) = p;
227 // *((void ***)(pPage + 1) - 1) = Vec_PtrArray(&p->vPages);
228  Vec_PtrPush( &p->vPages, pPage + 1 );
229 // if ( *((void ***)(pPage + 1) - 1) != Vec_PtrArray(&p->vPages) )
230 // Vec_PtrForEachEntry( Mig_Obj_t *, &p->vPages, pPage, i )
231 // *((void ***)pPage - 1) = Vec_PtrArray(&p->vPages);
232  }
233  pObj = Mig_ManObj( p, p->nObjs++ );
234  assert( Mig_ObjIsNone(pObj) );
235  Mig_ObjSetId( pObj, p->nObjs-1 );
236  return pObj;
237 }
238 static inline int Mig_ManAppendCi( Mig_Man_t * p )
239 {
240  Mig_Obj_t * pObj = Mig_ManAppendObj( p );
241  Mig_ObjSetCioId( pObj, Vec_IntSize(&p->vCis) );
242  Vec_IntPush( &p->vCis, Mig_ObjId(pObj) );
243  return Mig_ObjId(pObj) << 1;
244 }
245 static inline int Mig_ManAppendCo( Mig_Man_t * p, int iLit0 )
246 {
247  Mig_Obj_t * pObj;
248  assert( !Mig_ObjIsCo(Mig_ManObj(p, Abc_Lit2Var(iLit0))) );
249  pObj = Mig_ManAppendObj( p );
250  Mig_ObjSetFaninLit( pObj, 0, iLit0 );
251  Mig_ObjSetCioId( pObj, Vec_IntSize(&p->vCos) );
252  Vec_IntPush( &p->vCos, Mig_ObjId(pObj) );
253  return Mig_ObjId( pObj ) << 1;
254 }
255 static inline int Mig_ManAppendBuf( Mig_Man_t * p, int iLit0 )
256 {
257  Mig_Obj_t * pObj;
258  pObj = Mig_ManAppendObj( p );
259  Mig_ObjSetFaninLit( pObj, 0, iLit0 );
260  return Mig_ObjId( pObj ) << 1;
261 }
262 static inline int Mig_ManAppendAnd( Mig_Man_t * p, int iLit0, int iLit1 )
263 {
264  Mig_Obj_t * pObj = Mig_ManAppendObj( p );
265  assert( iLit0 != iLit1 );
266  Mig_ObjSetFaninLit( pObj, 0, iLit0 < iLit1 ? iLit0 : iLit1 );
267  Mig_ObjSetFaninLit( pObj, 1, iLit0 < iLit1 ? iLit1 : iLit0 );
268  return Mig_ObjId( pObj ) << 1;
269 }
270 static inline int Mig_ManAppendXor( Mig_Man_t * p, int iLit0, int iLit1 )
271 {
272  Mig_Obj_t * pObj = Mig_ManAppendObj( p );
273  assert( iLit0 != iLit1 );
274  assert( !Abc_LitIsCompl(iLit0) && !Abc_LitIsCompl(iLit1) );
275  Mig_ObjSetFaninLit( pObj, 0, iLit0 < iLit1 ? iLit1 : iLit0 );
276  Mig_ObjSetFaninLit( pObj, 1, iLit0 < iLit1 ? iLit0 : iLit1 );
277  return Mig_ObjId( pObj ) << 1;
278 }
279 static inline int Mig_ManAppendMux( Mig_Man_t * p, int iLit0, int iLit1, int iCtrl )
280 {
281  Mig_Obj_t * pObj = Mig_ManAppendObj( p );
282  assert( iLit0 != iLit1 && iLit0 != iCtrl && iLit1 != iCtrl );
283  assert( !Abc_LitIsCompl(iLit0) || !Abc_LitIsCompl(iLit1) );
284  Mig_ObjSetFaninLit( pObj, 0, iLit0 < iLit1 ? iLit0 : iLit1 );
285  Mig_ObjSetFaninLit( pObj, 1, iLit0 < iLit1 ? iLit1 : iLit0 );
286  Mig_ObjSetFaninLit( pObj, 2, iLit0 < iLit1 ? iCtrl : Abc_LitNot(iCtrl) );
287  return Mig_ObjId( pObj ) << 1;
288 }
289 static inline int Mig_ManAppendMaj( Mig_Man_t * p, int iLit0, int iLit1, int iLit2 )
290 {
291  Mig_Obj_t * pObj = Mig_ManAppendObj( p );
292  assert( iLit0 != iLit1 && iLit0 != iLit2 && iLit1 != iLit2 );
293  Mig_ObjSetFaninLit( pObj, 0, iLit0 < iLit1 ? iLit1 : iLit0 );
294  Mig_ObjSetFaninLit( pObj, 1, iLit0 < iLit1 ? iLit0 : iLit1 );
295  Mig_ObjSetFaninLit( pObj, 2, iLit2 );
296  return Mig_ObjId( pObj ) << 1;
297 }
298 
299 ////////////////////////////////////////////////////////////////////////
300 /// MACRO DEFINITIONS ///
301 ////////////////////////////////////////////////////////////////////////
302 
303 // iterators over objects
304 #define Mig_ManForEachObj( p, pObj ) \
305  for ( p->iPage = 0; p->iPage < Vec_PtrSize(&p->vPages) && \
306  ((p->pPage) = (Mig_Obj_t *)Vec_PtrEntry(&p->vPages, p->iPage)); p->iPage++ ) \
307  for ( pObj = p->pPage; !Mig_ObjIsNone(pObj); pObj++ )
308 #define Mig_ManForEachObj1( p, pObj ) \
309  for ( p->iPage = 0; p->iPage < Vec_PtrSize(&p->vPages) && \
310  ((p->pPage) = (Mig_Obj_t *)Vec_PtrEntry(&p->vPages, p->iPage)); p->iPage++ ) \
311  for ( pObj = p->pPage + (p->iPage == 0); !Mig_ObjIsNone(pObj); pObj++ )
312 #define Mig_ManForEachObjReverse( p, pObj ) \
313  for ( p->iPage = Vec_PtrSize(&p->vPages) - 1; p->iPage >= 0 && \
314  ((p->pPage) = (Mig_Obj_t *)Vec_PtrEntry(&p->vPages, p->iPage)); p->iPage-- ) \
315  for ( pObj = (p->iPage == Vec_PtrSize(&p->vPages) - 1) ? \
316  Mig_ManObj(p, Mig_ManObjNum(p)-1) : p->pPage + MIG_MASK; \
317  pObj - p->pPage >= 0; pObj-- )
318 
319 #define Mig_ManForEachObjVec( vVec, p, pObj, i ) \
320  for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Mig_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
321 
322 #define Mig_ManForEachNode( p, pObj ) \
323  Mig_ManForEachObj( p, pObj ) if ( !Mig_ObjIsNode(pObj) ) {} else
324 #define Mig_ManForEachCand( p, pObj ) \
325  Mig_ManForEachObj( p, pObj ) if ( !Mig_ObjIsCand(pObj) ) {} else
326 
327 #define Mig_ManForEachCi( p, pObj, i ) \
328  for ( i = 0; (i < Vec_IntSize(&p->vCis)) && ((pObj) = Mig_ManCi(p, i)); i++ )
329 #define Mig_ManForEachCo( p, pObj, i ) \
330  for ( i = 0; (i < Vec_IntSize(&p->vCos)) && ((pObj) = Mig_ManCo(p, i)); i++ )
331 
332 // iterators over fanins
333 #define Mig_ObjForEachFaninId( p, iFanin, i ) \
334  for ( i = 0; Mig_ObjHasFanin(p, i) && ((iFanin) = Mig_ObjFaninId(p, i)); i++ )
335 #define Mig_ObjForEachFanin( p, pFanin, i ) \
336  for ( i = 0; Mig_ObjHasFanin(p, i) && ((pFanin) = Mig_ObjFanin(p, i)); i++ )
337 
338 
339 ////////////////////////////////////////////////////////////////////////
340 /// FUNCTION DECLARATIONS ///
341 ////////////////////////////////////////////////////////////////////////
342 
343 /*=== mpmMig.c ===========================================================*/
344 extern Mig_Man_t * Mig_ManStart();
345 extern void Mig_ManStop( Mig_Man_t * p );
346 extern void Mig_ManSetRefs( Mig_Man_t * p );
347 extern int Mig_ManAndNum( Mig_Man_t * p );
348 extern int Mig_ManXorNum( Mig_Man_t * p );
349 extern int Mig_ManMuxNum( Mig_Man_t * p );
350 
352 
353 #endif
354 
355 ////////////////////////////////////////////////////////////////////////
356 /// END OF FILE ///
357 ////////////////////////////////////////////////////////////////////////
358 
static void Mig_ObjSetCioId(Mig_Obj_t *p, int v)
Definition: mpmMig.h:149
static int Mig_ManNodeNum(Mig_Man_t *p)
Definition: mpmMig.h:110
static Mig_Obj_t * Mig_ManPo(Mig_Man_t *p, int v)
Definition: mpmMig.h:120
static int Mig_ObjCopy(Mig_Obj_t *p)
Definition: mpmMig.h:194
static int Mig_ManObjNum(Mig_Man_t *p)
Definition: mpmMig.h:109
static void Mig_ObjSetSiblId(Mig_Obj_t *p, int s)
Definition: mpmMig.h:189
static void Mig_ObjSetId(Mig_Obj_t *p, int v)
Definition: mpmMig.h:147
static int Mig_ManChoiceNum(Mig_Man_t *p)
Definition: mpmMig.h:112
static int Mig_ObjIsMux(Mig_Obj_t *p)
Definition: mpmMig.h:142
static Mig_Man_t * Mig_ObjMan(Mig_Obj_t *p)
Definition: mpmMig.h:153
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Mig_Obj_t * Mig_ManConst0(Mig_Man_t *p)
Definition: mpmMig.h:123
static int Mig_ObjIsAnd(Mig_Obj_t *p)
Definition: mpmMig.h:140
Vec_Int_t vLevels
Definition: mpmMig.h:76
static int Mig_FanId(Mig_Obj_t *p, int i)
Definition: mpmMig.h:126
static void Mig_ObjSetPhase(Mig_Obj_t *p, int v)
Definition: mpmMig.h:151
static Mig_Obj_t * Mig_ManObj(Mig_Man_t *p, int v)
Definition: mpmMig.h:116
static int Mig_ObjIsNode3(Mig_Obj_t *p)
Definition: mpmMig.h:139
Vec_Int_t vCopies
Definition: mpmMig.h:79
Mig_Man_t * Mig_ManStart()
FUNCTION DECLARATIONS ///.
Definition: mpmMig.c:45
static Mig_Obj_t * Mig_ObjFanin(Mig_Obj_t *p, int i)
Definition: mpmMig.h:174
static int Mig_ObjIsNode2(Mig_Obj_t *p)
Definition: mpmMig.h:138
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
unsigned Id
Definition: mpmMig.h:51
static int Mig_ObjIsTerm(Mig_Obj_t *p)
Definition: mpmMig.h:133
static int Mig_ManIdToCioId(Mig_Man_t *p, int Id)
Definition: mpmMig.h:157
#define MIG_NONE
INCLUDES ///.
Definition: mpmMig.h:37
static int Mig_ObjFaninC0(Mig_Obj_t *p)
Definition: mpmMig.h:180
static int Mig_ObjRefNum(Mig_Obj_t *p)
Definition: mpmMig.h:191
static int Mig_IdCell(int v)
Definition: mpmMig.h:101
Vec_Int_t vRefs
Definition: mpmMig.h:78
static int Mig_ObjIsRo(Mig_Obj_t *p)
Definition: mpmMig.h:163
static int Mig_ManAppendXor(Mig_Man_t *p, int iLit0, int iLit1)
Definition: mpmMig.h:270
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Mig_ManCandNum(Mig_Man_t *p)
Definition: mpmMig.h:111
static int Mig_ObjIsNode(Mig_Obj_t *p)
Definition: mpmMig.h:137
static int Mig_ObjIsNone(Mig_Obj_t *p)
Definition: mpmMig.h:131
static int Mig_ManCoNum(Mig_Man_t *p)
Definition: mpmMig.h:105
static int Mig_IdPage(int v)
Definition: mpmMig.h:100
int Mig_ManAndNum(Mig_Man_t *p)
Definition: mpmMig.c:98
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
static int Mig_ObjFaninC(Mig_Obj_t *p, int i)
Definition: mpmMig.h:179
static int Mig_ObjIsRi(Mig_Obj_t *p)
Definition: mpmMig.h:164
static int Mig_ManCoIdToId(Mig_Man_t *p, int CoId)
Definition: mpmMig.h:159
static int Mig_ObjPhase(Mig_Obj_t *p)
Definition: mpmMig.h:150
static int Mig_ManAppendCo(Mig_Man_t *p, int iLit0)
Definition: mpmMig.h:245
static int Vec_IntGetEntry(Vec_Int_t *p, int i)
Definition: bblif.c:401
static Mig_Obj_t * Mig_ManRi(Mig_Man_t *p, int v)
Definition: mpmMig.h:122
static Mig_Obj_t * Mig_ManAppendObj(Mig_Man_t *p)
Definition: mpmMig.h:217
unsigned fCompl
Definition: mpmMig.h:50
static int Mig_ObjIsCi(Mig_Obj_t *p)
Definition: mpmMig.h:134
static Mig_Obj_t * Mig_ObjSibl(Mig_Obj_t *p)
Definition: mpmMig.h:190
int iPage
Definition: mpmMig.h:72
static int Mig_ObjIsTravIdCurrent(Mig_Obj_t *p)
Definition: mpmMig.h:201
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Mig_ObjIsTravIdPrevious(Mig_Obj_t *p)
Definition: mpmMig.h:202
static int Mig_FanIsNone(Mig_Obj_t *p, int i)
Definition: mpmMig.h:127
int nChoices
Definition: mpmMig.h:66
int nObjs
Definition: mpmMig.h:64
void Mig_ManStop(Mig_Man_t *p)
Definition: mpmMig.c:56
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
int Mig_ManXorNum(Mig_Man_t *p)
Definition: mpmMig.c:102
static void Mig_ObjSetFaninLit(Mig_Obj_t *p, int i, int l)
Definition: mpmMig.h:186
static int Mig_ObjCioId(Mig_Obj_t *p)
Definition: mpmMig.h:148
void * pMan
Definition: mpmMig.h:80
static Mig_Obj_t * Mig_ObjRoToRi(Mig_Obj_t *p)
Definition: mpmMig.h:166
static int Mig_ManCiNum(Mig_Man_t *p)
Definition: mpmMig.h:104
static int Mig_ObjIsPi(Mig_Obj_t *p)
Definition: mpmMig.h:161
Mig_Fan_t pFans[4]
Definition: mpmMig.h:57
static int Mig_ObjHasFanin(Mig_Obj_t *p, int i)
Definition: mpmMig.h:169
Vec_Int_t vCis
Definition: mpmMig.h:68
static int Mig_ObjIsConst0(Mig_Obj_t *p)
Definition: mpmMig.h:132
static Mig_Obj_t * Mig_ObjFanin1(Mig_Obj_t *p)
Definition: mpmMig.h:177
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Mig_Obj_t * Mig_ManPi(Mig_Man_t *p, int v)
Definition: mpmMig.h:119
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Mig_ObjIsCand(Mig_Obj_t *p)
Definition: mpmMig.h:143
static int Mig_ObjIsBuf(Mig_Obj_t *p)
Definition: mpmMig.h:136
static int Mig_ObjIsPo(Mig_Obj_t *p)
Definition: mpmMig.h:162
#define MIG_BASE
Definition: mpmMig.h:41
static int Mig_ManAppendBuf(Mig_Man_t *p, int iLit0)
Definition: mpmMig.h:255
static void Mig_ObjSetTravIdCurrent(Mig_Obj_t *p)
Definition: mpmMig.h:199
static Mig_Obj_t * Mig_ManRo(Mig_Man_t *p, int v)
Definition: mpmMig.h:121
static Mig_Obj_t * Mig_ManPage(Mig_Man_t *p, int v)
Definition: mpmMig.h:115
static int Mig_ObjWhatFanin(Mig_Obj_t *p, int i)
Definition: mpmMig.h:185
static void Mig_ManSetRegNum(Mig_Man_t *p, int v)
Definition: mpmMig.h:113
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Mig_ObjFaninId1(Mig_Obj_t *p)
Definition: mpmMig.h:172
static int Mig_ObjFaninId2(Mig_Obj_t *p)
Definition: mpmMig.h:173
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static Mig_Obj_t * Mig_ObjFanin0(Mig_Obj_t *p)
Definition: mpmMig.h:176
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int Mig_ManMuxNum(Mig_Man_t *p)
Definition: mpmMig.c:106
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
static int Mig_ObjIsXor(Mig_Obj_t *p)
Definition: mpmMig.h:141
static int Mig_ManPoNum(Mig_Man_t *p)
Definition: mpmMig.h:107
Vec_Int_t vSibls
Definition: mpmMig.h:77
static int Mig_ManCiIdToId(Mig_Man_t *p, int CiId)
Definition: mpmMig.h:158
static void Mig_ManCleanCopy(Mig_Man_t *p)
Definition: mpmMig.h:193
static int Mig_FanCompl(Mig_Obj_t *p, int i)
Definition: mpmMig.h:125
static int Mig_ObjIsTravIdCurrentId(Mig_Man_t *p, int Id)
Definition: mpmMig.h:204
static Mig_Obj_t * Mig_ObjFanin2(Mig_Obj_t *p)
Definition: mpmMig.h:178
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
static int Mig_ObjSiblId(Mig_Obj_t *p)
Definition: mpmMig.h:188
static int Mig_ObjFaninC1(Mig_Obj_t *p)
Definition: mpmMig.h:181
Vec_Int_t vCos
Definition: mpmMig.h:69
Mig_Obj_t * pPage
Definition: mpmMig.h:71
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Mig_Obj_t * Mig_ManCi(Mig_Man_t *p, int v)
Definition: mpmMig.h:117
int nRegs
Definition: mpmMig.h:65
Vec_Ptr_t vPages
Definition: mpmMig.h:67
char * pName
Definition: mpmMig.h:63
static int Mig_ObjFaninId(Mig_Obj_t *p, int i)
Definition: mpmMig.h:170
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static void Mig_ManIncrementTravId(Mig_Man_t *p)
Definition: mpmMig.h:197
Vec_Int_t vTravIds
Definition: mpmMig.h:75
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Mig_ObjFaninC2(Mig_Obj_t *p)
Definition: mpmMig.h:182
static void Mig_ObjSetCopy(Mig_Obj_t *p, int i)
Definition: mpmMig.h:195
static int Mig_ObjFaninId0(Mig_Obj_t *p)
Definition: mpmMig.h:171
static int Mig_ManAppendMux(Mig_Man_t *p, int iLit0, int iLit1, int iCtrl)
Definition: mpmMig.h:279
void Mig_ManSetRefs(Mig_Man_t *p)
Definition: mpmMig.c:123
static int Mig_FanSetId(Mig_Obj_t *p, int i, int v)
Definition: mpmMig.h:129
static int Mig_FanSetCompl(Mig_Obj_t *p, int i, int v)
Definition: mpmMig.h:128
static int Mig_ManPiNum(Mig_Man_t *p)
Definition: mpmMig.h:106
static int Mig_ManAppendMaj(Mig_Man_t *p, int iLit0, int iLit1, int iLit2)
Definition: mpmMig.h:289
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Mig_ManAppendAnd(Mig_Man_t *p, int iLit0, int iLit1)
Definition: mpmMig.h:262
static Mig_Obj_t * Mig_ObjObj(Mig_Obj_t *p, int i)
Definition: mpmMig.h:155
#define assert(ex)
Definition: util_old.h:213
static void Mig_ObjFlipFaninC(Mig_Obj_t *p, int i)
Definition: mpmMig.h:184
static Mig_Obj_t * Mig_ManCo(Mig_Man_t *p, int v)
Definition: mpmMig.h:118
static int Mig_ManAppendCi(Mig_Man_t *p)
Definition: mpmMig.h:238
static void Mig_ObjSetTravIdCurrentId(Mig_Man_t *p, int Id)
Definition: mpmMig.h:203
static char * Mig_ManName(Mig_Man_t *p)
Definition: mpmMig.h:103
static int Mig_ObjNodeType(Mig_Obj_t *p)
Definition: mpmMig.h:144
#define MIG_MASK
Definition: mpmMig.h:40
static int Mig_ObjIsCo(Mig_Obj_t *p)
Definition: mpmMig.h:135
static Mig_Obj_t * Mig_ObjRiToRo(Mig_Obj_t *p)
Definition: mpmMig.h:167
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
static int Mig_ObjFaninLit(Mig_Obj_t *p, int i)
Definition: mpmMig.h:183
static void Mig_ObjIncrementTravId(Mig_Obj_t *p)
Definition: mpmMig.h:198
int nTravIds
Definition: mpmMig.h:74
static int Mig_ManRegNum(Mig_Man_t *p)
Definition: mpmMig.h:108
static void Mig_ObjSetTravIdPrevious(Mig_Obj_t *p)
Definition: mpmMig.h:200