33#define DAU_DSD_MAX_VAR 12
35static int m_Calls = 0;
36static int m_NonDsd = 0;
37static int m_Non1Step = 0;
59 if ( Func == ~(
word)0 )
64 assert( Func == s_Truths6[0] || Func == s_Truths6Neg[0] );
65 return Abc_LitNotCond( pFanins[0], (
int)(Func == s_Truths6Neg[0]) );
67 if ( !Abc_Tt6HasVar(Func, nVars) )
94 return Abc_LitNotCond( pLits[**
p -
'a'], fCompl );
97 char * q = pStr + pMatches[ *
p - pStr ];
99 assert( **
p ==
'(' && *q ==
')' );
100 for ( (*
p)++; *
p < q; (*p)++ )
106 return Abc_LitNotCond( Res, fCompl );
110 char * q = pStr + pMatches[ *
p - pStr ];
112 assert( **
p ==
'[' && *q ==
']' );
113 for ( (*
p)++; *
p < q; (*p)++ )
122 return Abc_LitNotCond( Res, fCompl );
127 int Temp[3], * pTemp = Temp, Res;
130 char * q = pStr + pMatches[ *
p - pStr ];
136 q2 = pStr + pMatches[ *
p - pStr ];
137 assert( **
p ==
'{' && *q2 ==
'}' );
138 for ( nVars = 0, (*
p)++; *
p < q2; (*p)++, nVars++ )
147 q = pStr + pMatches[ *
p - pStr ];
148 assert( **
p ==
'<' && *q ==
'>' );
151 for ( ; pOld < q; pOld++ )
152 if ( *pOld >=
'a' && *pOld <=
'z' )
153 assert( *pOld -
'a' < nVars );
155 for ( (*
p)++; *
p < q; (*p)++ )
157 assert( pTemp == Temp + 3 );
161 char * q = pStr + pMatches[ ++(*p) - pStr ];
162 assert( **
p ==
'{' && *q ==
'}' );
169 return Abc_LitNotCond( Res, fCompl );
171 if ( (**
p >=
'A' && **
p <=
'F') || (**
p >=
'0' && **
p <=
'9') )
176 int i, nVars = Abc_TtReadHex( pFunc, *
p );
177 *
p += Abc_TtHexDigitNum( nVars );
178 q = pStr + pMatches[ *
p - pStr ];
179 assert( **
p ==
'{' && *q ==
'}' );
180 for ( i = 0, (*
p)++; *
p < q; (*p)++, i++ )
185 vLeaves.nCap = nVars;
186 vLeaves.nSize = nVars;
187 vLeaves.pArray = Fanins;
188 Res =
Kit_TruthToGia( pGia, (
unsigned *)pFunc, nVars, vCover, &vLeaves, 1 );
190 return Abc_LitNotCond( Res, fCompl );
198 if ( *
p ==
'0' && *(
p+1) == 0 )
200 else if ( *
p ==
'1' && *(
p+1) == 0 )
225 for ( i = nFans; i > 0; i-- )
227 if ( Gia_ObjLevelId(pGia, Abc_Lit2Var(pFans[i])) <= Gia_ObjLevelId(pGia, Abc_Lit2Var(pFans[i-1])) )
229 ABC_SWAP(
int, pFans[i], pFans[i-1] );
235 int iFan0, iFan1, iFan;
239 iFan0 = pFans[--nFans];
240 iFan1 = pFans[--nFans];
241 if ( Vec_IntSize(&pGia->
vHTable) == 0 )
244 iFan = Gia_ManAppendAnd2( pGia, iFan0, iFan1 );
247 int fCompl = Abc_LitIsCompl(iFan0) ^ Abc_LitIsCompl(iFan1);
248 iFan = Gia_ManAppendXorReal( pGia, Abc_LitRegular(iFan0), Abc_LitRegular(iFan1) );
249 iFan = Abc_LitNotCond( iFan, fCompl );
252 iFan = Gia_ManAppendXor2( pGia, iFan0, iFan1 );
263 pObj = Gia_ManObj(pGia, Abc_Lit2Var(iFan));
264 if ( Gia_ObjIsAnd(pObj) )
267 Gia_ObjSetAndLevel( pGia, pObj );
269 Gia_ObjSetXorLevel( pGia, pObj );
272 if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
273 Gia_ObjSetAndLevel( pGia, Gia_ObjFanin0(pObj) );
274 if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
275 Gia_ObjSetAndLevel( pGia, Gia_ObjFanin1(pObj) );
276 Gia_ObjSetAndLevel( pGia, pObj );
288 return Abc_LitNotCond( pLits[**
p -
'a'], fCompl );
291 char * q = pStr + pMatches[ *
p - pStr ];
293 assert( **
p ==
'(' && *q ==
')' );
294 for ( (*
p)++; *
p < q; (*p)++ )
301 return Abc_LitNotCond( Fan, fCompl );
305 char * q = pStr + pMatches[ *
p - pStr ];
307 assert( **
p ==
'[' && *q ==
']' );
308 for ( (*
p)++; *
p < q; (*p)++ )
315 return Abc_LitNotCond( Fan, fCompl );
321 int Temp[3], * pTemp = Temp, Res;
324 char * q = pStr + pMatches[ *
p - pStr ];
330 q2 = pStr + pMatches[ *
p - pStr ];
331 assert( **
p ==
'{' && *q2 ==
'}' );
332 for ( nVars = 0, (*
p)++; *
p < q2; (*p)++, nVars++ )
341 q = pStr + pMatches[ *
p - pStr ];
342 assert( **
p ==
'<' && *q ==
'>' );
345 for ( ; pOld < q; pOld++ )
346 if ( *pOld >=
'a' && *pOld <=
'z' )
347 assert( *pOld -
'a' < nVars );
349 for ( (*
p)++; *
p < q; (*p)++ )
351 assert( pTemp == Temp + 3 );
355 char * q = pStr + pMatches[ ++(*p) - pStr ];
356 assert( **
p ==
'{' && *q ==
'}' );
359 if ( Vec_IntSize(&pGia->
vHTable) == 0 )
362 Res = Gia_ManAppendMux( pGia, Temp[0], Temp[1], Temp[2] );
364 Res = Gia_ManAppendMux2( pGia, Temp[0], Temp[1], Temp[2] );
373 pObj = Gia_ManObj(pGia, Abc_Lit2Var(Res));
374 if ( Gia_ObjIsAnd(pObj) )
377 Gia_ObjSetMuxLevel( pGia, pObj );
380 if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
381 Gia_ObjSetAndLevel( pGia, Gia_ObjFanin0(pObj) );
382 if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
383 Gia_ObjSetAndLevel( pGia, Gia_ObjFanin1(pObj) );
384 Gia_ObjSetAndLevel( pGia, pObj );
387 return Abc_LitNotCond( Res, fCompl );
389 if ( (**
p >=
'A' && **
p <=
'F') || (**
p >=
'0' && **
p <=
'9') )
394 int i, nVars = Abc_TtReadHex( pFunc, *
p );
395 *
p += Abc_TtHexDigitNum( nVars );
396 q = pStr + pMatches[ *
p - pStr ];
397 assert( **
p ==
'{' && *q ==
'}' );
398 for ( i = 0, (*
p)++; *
p < q; (*p)++, i++ )
402 vLeaves.nCap = nVars;
403 vLeaves.nSize = nVars;
404 vLeaves.pArray = Fanins;
405 nObjOld = Gia_ManObjNum(pGia);
406 Res =
Kit_TruthToGia( pGia, (
unsigned *)pFunc, nVars, vCover, &vLeaves, Vec_IntSize(&pGia->
vHTable) != 0 );
409 for ( i = nObjOld; i < Gia_ManObjNum(pGia); i++ )
410 Gia_ObjSetGateLevel( pGia, Gia_ManObj(pGia, i) );
412 return Abc_LitNotCond( Res, fCompl );
420 if ( *
p ==
'0' && *(
p+1) == 0 )
422 else if ( *
p ==
'1' && *(
p+1) == 0 )
444 int fDelayBalance = 1;
449 Abc_TtCopy( pTruthCopy, pTruth, Abc_TtWordNum(Vec_IntSize(vLeaves)), 0 );
452 if ( Vec_IntSize(vLeaves) == 0 )
453 return (
int)(pTruth[0] & 1);
454 if ( Vec_IntSize(vLeaves) == 1 )
455 return Abc_LitNotCond( Vec_IntEntry(vLeaves, 0), (
int)(pTruth[0] & 1) );
457 if ( fDelayBalance && fUseMuxes )
461 pVarLevels[i] = Gia_ObjLevelId( pGia, Abc_Lit2Var(iLit) );
462 nSizeNonDec =
Dau_DsdDecomposeLevel( pTruthCopy, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd, pVarLevels );
465 nSizeNonDec =
Dau_DsdDecompose( pTruthCopy, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd );
469 if ( fDelayBalance && pGia->
vLevels )
470 return Dau_DsdToGia( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
472 return Dau_DsdToGia2( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
488 printf(
"Calls = %d. NonDSD = %d. Non1Step = %d.\n", m_Calls, m_NonDsd, m_Non1Step );
489 m_Calls = m_NonDsd = m_Non1Step = 0;
509 int k, i, iLut, iVar;
511 assert( Gia_ManHasMapping(
p) );
514 pNew->
pName = Abc_UtilStrsav(
p->pName );
515 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
516 pNew->
vLevels = Vec_IntStart( 6*Gia_ManObjNum(
p)/5 + 100 );
521 Gia_ManConst0(
p)->Value = 0;
523 pObj->
Value = Gia_ManAppendCi(pNew);
525 vLeaves = Vec_IntAlloc( 16 );
526 vCover = Vec_IntAlloc( 1 << 16 );
531 if ( Gia_ObjIsBuf(pObj) )
533 pObj->
Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
536 if ( !Gia_ObjIsLut(
p, iLut) )
539 Vec_IntClear( vLeaves );
541 Vec_IntPush( vLeaves, iVar );
544 Vec_IntClear( vLeaves );
546 Vec_IntPush( vLeaves, Gia_ManObj(
p, iVar)->Value );
551 pObj->
Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
554 Vec_IntFree( vLeaves );
555 Vec_IntFree( vCover );
#define ABC_SWAP(Type, a, b)
#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 ///.
int Dau_DsdToGia2(Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
void Dau_DsdAddToArray(Gia_Man_t *pGia, int *pFans, int nFans, int iFan)
int Dsm_ManTruthToGia(void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
int Dau_DsdBalance(Gia_Man_t *pGia, int *pFans, int nFans, int fAnd)
int Dau_DsdToGia_rec(Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
void Dsm_ManReportStats()
int Dau_DsdToGia2_rec(Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
int Dau_DsdToGiaCompose_rec(Gia_Man_t *pGia, word Func, int *pFanins, int nVars)
FUNCTION DEFINITIONS ///.
void * Dsm_ManDeriveGia(void *pGia, int fUseMuxes)
int Dau_DsdToGia(Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
int Dau_DsdDecomposeLevel(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes, int *pVarLevels)
int * Dau_DsdComputeMatches(char *p)
void Gia_ManStop(Gia_Man_t *p)
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
void Gia_ManHashStart(Gia_Man_t *p)
#define Gia_ManForEachAnd(p, pObj, i)
int Gia_ManHashMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
#define Gia_LutForEachFanin(p, i, iFan, k)
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManFillValue(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
int Gia_ManLutSizeMax(Gia_Man_t *p)
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
int Gia_ManHashXorReal(Gia_Man_t *p, int iLit0, int iLit1)
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
void Gia_ManHashStop(Gia_Man_t *p)
unsigned __int64 word
DECLARATIONS ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.