30#define SBD_MAX_CUTSIZE 10
31#define SBD_MAX_CUTNUM 501
33#define SBD_CUT_NO_LEAF 0xF
86 int nLutSize,
int nCutSize,
int nCutNum,
int fVerbose )
89 assert( nLutSize <= nCutSize );
94 p->clkStart = Abc_Clock();
95 p->nLutSize = nLutSize;
96 p->nCutSize = nCutSize;
98 p->fVerbose = fVerbose;
100 p->vMirrors = vMirrors;
101 p->vLutLevs = vLutLevs;
104 p->vCut0 = Vec_IntAlloc( 100 );
105 p->vCut = Vec_IntAlloc( 100 );
106 p->vCutTop = Vec_IntAlloc( 100 );
107 p->vCutBot = Vec_IntAlloc( 100 );
112 Vec_IntFree(
p->vCut0 );
113 Vec_IntFree(
p->vCut );
114 Vec_IntFree(
p->vCutTop );
115 Vec_IntFree(
p->vCutBot );
134 if ( Vec_IntEntry(vMirrors, iObj) >= 0 )
135 iObj = Abc_Lit2Var(Vec_IntEntry(vMirrors, iObj));
136 if ( !iObj || Gia_ObjIsTravIdCurrentId(
p, iObj) )
138 Gia_ObjSetTravIdCurrentId(
p, iObj);
139 pObj = Gia_ManObj(
p, iObj );
140 if ( Gia_ObjIsCi(pObj) )
142 assert( Gia_ObjIsAnd(pObj) );
149 int i, Entry, RetValue;
152 Gia_ObjSetTravIdCurrentId(
p, Entry );
155 printf(
"Cut of node %d is not tological\n", iObj );
173 int Lit0m, Lit1m, Fan0, Fan1, iPlace0, iPlace1;
174 int LutLev = Vec_IntEntry( vLutLevs, iObj );
176 if ( Gia_ObjIsCi(pObj) )
178 assert( Gia_ObjIsAnd(pObj) );
179 Lit0m = Vec_IntEntry( vMirrors, Gia_ObjFaninId0(pObj, iObj) );
180 Lit1m = Vec_IntEntry( vMirrors, Gia_ObjFaninId1(pObj, iObj) );
181 Fan0 = Lit0m >= 0 ? Abc_Lit2Var(Lit0m) : Gia_ObjFaninId0(pObj, iObj);
182 Fan1 = Lit1m >= 0 ? Abc_Lit2Var(Lit1m) : Gia_ObjFaninId1(pObj, iObj);
183 iPlace0 = Vec_IntFind( vCut, Fan0 );
184 iPlace1 = Vec_IntFind( vCut, Fan1 );
185 if ( iPlace0 == -1 && iPlace1 == -1 )
187 if ( Vec_IntEntry(vLutLevs, Fan0) > LutLev || Vec_IntEntry(vLutLevs, Fan1) > LutLev )
189 Vec_IntDrop( vCut, iThis );
190 if ( iPlace0 == -1 && Fan0 )
191 Vec_IntPushOrder( vCut, Fan0 );
192 if ( iPlace1 == -1 && Fan1 )
193 Vec_IntPushOrder( vCut, Fan1 );
199 Prev = Vec_IntEntry( vCut, 0 );
212 if ( Sbd_ManCutExpandOne(
p, vMirrors, vLutLevs, vCut, i, Entry ) )
215 while ( i < Vec_IntSize(vCut) );
220 Vec_IntClear( vCutTop );
221 Vec_IntClear( vCutBot );
225 assert( Vec_IntEntry(vMirrors, Entry) == -1 );
226 assert( Vec_IntEntry(vLutLevs, Entry) <= LevStop );
227 if ( Vec_IntEntry(vLutLevs, Entry) == LevStop )
228 Vec_IntPush( vCutTop, Entry );
230 Vec_IntPush( vCutBot, Entry );
238 if ( Vec_IntEntry(vMirrors, iObj) >= 0 )
239 iObj = Abc_Lit2Var(Vec_IntEntry(vMirrors, iObj));
240 if ( !iObj || Gia_ObjIsTravIdCurrentId(
p, iObj) )
242 Gia_ObjSetTravIdCurrentId(
p, iObj);
243 pObj = Gia_ManObj(
p, iObj );
244 if ( Gia_ObjIsCi(pObj) || Vec_IntEntry(vLutLevs, iObj) <= LevStop )
246 Vec_IntPush( vCut, iObj );
247 return Vec_IntEntry(vLutLevs, iObj) <= LevStop;
249 assert( Gia_ObjIsAnd(pObj) );
268 int i, Entry, Lit0m, Lit1m, Fan0, Fan1;
269 int LevStop = Vec_IntEntry(vLutLevs, iObj) - 2;
274 if ( Gia_ObjIsCi(pObj) )
276 assert( Gia_ObjIsAnd(pObj) );
277 assert( Vec_IntEntry(vLutLevs, Entry) == LevStop );
278 Lit0m = Vec_IntEntry( vMirrors, Gia_ObjFaninId0(pObj, Entry) );
279 Lit1m = Vec_IntEntry( vMirrors, Gia_ObjFaninId1(pObj, Entry) );
280 Fan0 = Lit0m >= 0 ? Abc_Lit2Var(Lit0m) : Gia_ObjFaninId0(pObj, Entry);
281 Fan1 = Lit1m >= 0 ? Abc_Lit2Var(Lit1m) : Gia_ObjFaninId1(pObj, Entry);
282 if ( Vec_IntEntry(vLutLevs, Fan0) > LevStop || Vec_IntEntry(vLutLevs, Fan1) > LevStop )
284 assert( Vec_IntEntry(vLutLevs, Fan0) <= LevStop );
285 assert( Vec_IntEntry(vLutLevs, Fan1) <= LevStop );
286 if ( Vec_IntEntry(vLutLevs, Fan0) == LevStop && Vec_IntEntry(vLutLevs, Fan1) == LevStop )
288 Vec_IntRemove( vCut, Entry );
289 if ( Fan0 ) Vec_IntPushUniqueOrder( vCut, Fan0 );
290 if ( Fan1 ) Vec_IntPushUniqueOrder( vCut, Fan1 );
310 int RetValue, LevStop = Vec_IntEntry(
p->vLutLevs, iObj) - 2;
312 Vec_IntClear(
p->vCut );
318 Vec_IntSort(
p->vCut, 0 );
331 if ( Vec_IntSize(
p->vCut) <=
p->nCutSize && Vec_IntSize(
p->vCutTop) <=
p->nLutSize-1 )
335 memcpy( pLeaves, Vec_IntArray(
p->vCut),
sizeof(
int) * Vec_IntSize(
p->vCut) );
336 return Vec_IntSize(
p->vCut);
340 Vec_IntClear(
p->vCut0 );
341 Vec_IntAppend(
p->vCut0,
p->vCut );
342 if ( Vec_IntSize(
p->vCut) <
p->nCutSize &&
Sbd_ManCutReduceTop(
p->pGia,
p->vMirrors, iObj,
p->vLutLevs,
p->vCut,
p->vCutTop,
p->nCutSize ) )
346 assert( Vec_IntSize(
p->vCut) <=
p->nCutSize );
347 if ( Vec_IntSize(
p->vCutTop) <=
p->nLutSize-1 )
350 memcpy( pLeaves, Vec_IntArray(
p->vCut),
sizeof(
int) * Vec_IntSize(
p->vCut) );
351 return Vec_IntSize(
p->vCut);
354 if ( Vec_IntSize(
p->vCut) <
p->nCutSize &&
Sbd_ManCutReduceTop(
p->pGia,
p->vMirrors, iObj,
p->vLutLevs,
p->vCut,
p->vCutTop,
p->nCutSize ) )
358 assert( Vec_IntSize(
p->vCut) <=
p->nCutSize );
359 if ( Vec_IntSize(
p->vCutTop) <=
p->nLutSize-1 )
362 memcpy( pLeaves, Vec_IntArray(
p->vCut),
sizeof(
int) * Vec_IntSize(
p->vCut) );
363 return Vec_IntSize(
p->vCut);
366 if ( Vec_IntSize(
p->vCut) <
p->nCutSize &&
Sbd_ManCutReduceTop(
p->pGia,
p->vMirrors, iObj,
p->vLutLevs,
p->vCut,
p->vCutTop,
p->nCutSize ) )
370 assert( Vec_IntSize(
p->vCut) <=
p->nCutSize );
371 if ( Vec_IntSize(
p->vCutTop) <=
p->nLutSize-1 )
374 memcpy( pLeaves, Vec_IntArray(
p->vCut),
sizeof(
int) * Vec_IntSize(
p->vCut) );
375 return Vec_IntSize(
p->vCut);
378 if ( Vec_IntSize(
p->vCut) <
p->nCutSize &&
Sbd_ManCutReduceTop(
p->pGia,
p->vMirrors, iObj,
p->vLutLevs,
p->vCut,
p->vCutTop,
p->nCutSize ) )
382 assert( Vec_IntSize(
p->vCut) <=
p->nCutSize );
383 if ( Vec_IntSize(
p->vCutTop) <=
p->nLutSize-1 )
386 memcpy( pLeaves, Vec_IntArray(
p->vCut),
sizeof(
int) * Vec_IntSize(
p->vCut) );
387 return Vec_IntSize(
p->vCut);
395 Vec_IntClear(
p->vCut );
401 Vec_IntSort(
p->vCut, 0 );
414 if ( Vec_IntSize(
p->vCut) <=
p->nCutSize && Vec_IntSize(
p->vCutTop) <=
p->nLutSize-1 )
418 memcpy( pLeaves, Vec_IntArray(
p->vCut),
sizeof(
int) * Vec_IntSize(
p->vCut) );
419 return Vec_IntSize(
p->vCut);
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
void Gia_ManIncrementTravId(Gia_Man_t *p)
unsigned __int64 word
DECLARATIONS ///.
int Sbd_ManCutIsTopo(Gia_Man_t *p, Vec_Int_t *vMirrors, Vec_Int_t *vCut, int iObj)
void Sbd_ManCutServerStop(Sbd_Srv_t *p)
int Sbd_ManCutCollect_rec(Gia_Man_t *p, Vec_Int_t *vMirrors, int iObj, int LevStop, Vec_Int_t *vLutLevs, Vec_Int_t *vCut)
void Sbd_ManCutExpand(Gia_Man_t *p, Vec_Int_t *vMirrors, Vec_Int_t *vLutLevs, Vec_Int_t *vCut)
void Vec_IntOrdered(Vec_Int_t *vCut)
int Sbd_ManCutReduceTop(Gia_Man_t *p, Vec_Int_t *vMirrors, int iObj, Vec_Int_t *vLutLevs, Vec_Int_t *vCut, Vec_Int_t *vCutTop, int nCutSize)
int Sbd_ManCutServerFirst(Sbd_Srv_t *p, int iObj, int *pLeaves)
int Sbd_ManCutIsTopo_rec(Gia_Man_t *p, Vec_Int_t *vMirrors, int iObj)
Sbd_Srv_t * Sbd_ManCutServerStart(Gia_Man_t *pGia, Vec_Int_t *vMirrors, Vec_Int_t *vLutLevs, Vec_Int_t *vLevs, Vec_Int_t *vRefs, int nLutSize, int nCutSize, int nCutNum, int fVerbose)
FUNCTION DEFINITIONS ///.
void Sbd_ManCutReload(Vec_Int_t *vMirrors, Vec_Int_t *vLutLevs, int LevStop, Vec_Int_t *vCut, Vec_Int_t *vCutTop, Vec_Int_t *vCutBot)
#define SBD_MAX_CUTSIZE
DECLARATIONS ///.
struct Sbd_Cut_t_ Sbd_Cut_t
struct Sbd_Srv_t_ Sbd_Srv_t
int pLeaves[SBD_MAX_CUTSIZE]
Sbd_Cut_t pCuts[SBD_MAX_CUTNUM]
Sbd_Cut_t * ppCuts[SBD_MAX_CUTNUM]
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)