31 #define LMS_VAR_MAX 16 // LMS_VAR_MAX >= 6
32 #define LMS_MAX_WORD (1<<(LMS_VAR_MAX-6))
120 for ( v = 0; v < nVars; v++ )
129 for ( v = 0; v < nVars; v++ )
137 for ( v = 0; v < nVars; v++ )
145 for ( v = 0; v < nVars; v++ )
153 printf(
"Delay profile = {" );
154 for ( v = 0; v < nVars; v++ )
250 printf(
"%6d : ", i );
332 for ( i = 0; i < nVars; i++ )
339 int i, Index, Prev = -1;
351 assert( Index == Prev || Index == Prev + 1 );
410 if ( p->
pGia == NULL )
423 CountersS[(int)
Vec_StrEntry(vSupps, Entry)] += Next - Entry;
427 printf(
"Inputs = %2d. Funcs = %8d. Subgrs = %8d. Ratio = %6.2f.\n", i, Counters[i], CountersS[i], 1.0*CountersS[i]/Counters[i] );
432 int CountDsdNpn[3] = {0};
433 int CountDsdAll[3] = {0};
434 int CountStepNpn[3] = {0};
435 int CountStepAll[3] = {0};
441 printf(
"Cuts = %10d. ", p->
nTried );
457 if ( nNonDecSize == 0 )
460 CountDsdAll[0] +=
Freq;
462 else if ( nNonDecSize < nSuppSize )
465 CountDsdAll[1] +=
Freq;
470 CountDsdAll[2] +=
Freq;
473 if ( nNonDecSize == 0 )
476 CountStepAll[0] +=
Freq;
485 CountStepAll[1] +=
Freq;
491 CountStepAll[2] +=
Freq;
504 printf(
"Full = %6.2f %% ", 100.0 * CountDsdAll[0] / p->
nTried );
505 printf(
"Part = %6.2f %% ", 100.0 * CountDsdAll[1] / p->
nTried );
506 printf(
"None = %6.2f %% ", 100.0 * CountDsdAll[2] / p->
nTried );
518 printf(
"Full = %6.2f %% ", 100.0 * CountStepAll[0] / p->
nTried );
519 printf(
"1stp = %6.2f %% ", 100.0 * CountStepAll[1] / p->
nTried );
520 printf(
"Comp = %6.2f %% ", 100.0 * CountStepAll[2] / p->
nTried );
527 printf(
"Library with %d vars has %d classes and %d AIG subgraphs with %d AND nodes.\n",
574 unsigned uCanonPhase;
576 int i, k, Index, iFanin0, iFanin1, nLeaves;
577 Gia_Obj_t * pObjPo, * pDriver, * pTemp = NULL;
582 printf(
"The number of Library inputs (%d) differs from the number of Gia inputs (%d).\n",
Gia_ManCiNum(pLib),
Gia_ManCiNum(pGia) );
606 #ifdef LMS_USE_OLD_FORM
619 for ( i = 0; i < nLeaves; i++ )
655 printf(
"Truth table verification has failed.\n" );
695 unsigned uCanonPhase;
696 int i, Index, iFanin0, iFanin1, fHole;
720 #ifdef LMS_USE_OLD_FORM
729 if ( p->
pGia == NULL )
760 for ( i = 0; i < nLeaves; i++ )
840 printf(
"Performing recoding structures with choices.\n" );
895 for ( i = 0; i < nLeaves; i++ )
897 pLeaf =
If_ManObj(p, (pCut)->pLeaves[(
int)pCanonPerm[i]]);
906 int i, * pTruthId, iFirstPo, iFirstPoNext, iBestPo;
918 for ( i = 0; i < nLeaves; i++ )
926 for ( i = 0; i < nLeaves; i++ )
936 #ifdef LMS_USE_OLD_FORM
946 if ( *pTruthId == -1 )
963 for ( i = iFirstPo; i < iFirstPoNext; i++ )
967 if ( iBestPo == -1 || BestDelay > Delay || (BestDelay == Delay && BestArea > Area) )
980 for ( i = 0; i < nLeaves; i++ )
981 pPerm[(
int)pCanonPerm[i]] =
Lms_DelayGet(DelayProfile, i);
984 int Max = 0, Two = 0, pTimes[16];
985 for ( i = 0; i < nLeaves; i++ )
990 if ( pTimes[i] != Max )
992 if ( Two + 2 < Max && Max + 3 < BestDelay )
995 printf(
"%3d ", pTimes[i] );
998 printf(
"-> %3d ", BestDelay );
1008 unsigned uCanonPhase;
1035 unsigned uCanonPhase;
1044 if ( uSupport == 0 )
1066 for ( i = 0; i < nLeaves; i++ )
1084 pHopObj =
Hop_And(pMan, pFan0, pFan1);
1109 unsigned uCanonPhase;
1110 int iFan0, iFan1, iGiaObj;
1119 if ( uSupport == 0 )
1142 for (i = 0; i < nLeaves; i++)
1206 int i, Entry, * pPlace, SumTotal = 0;
1212 SumTotal += Entry + 1;
1237 int i, k, EntryI, EntryK;
1283 int i, Entry, Prev = -1, Next;
1342 int i, Entry, nVars = p->
nVars;
1344 if ( nEntries == 0 )
1346 printf(
"There is not truth tables.\n" );
1349 pFile = fopen( pFileName,
"wb" );
1350 if ( pFile == NULL )
1352 printf(
"The file cannot be opened.\n" );
1367 fwrite( pTruth, 1,
sizeof(
word) * p->
nWords, pFile );
1371 fprintf( pFile,
" " );
1374 fprintf( pFile,
"%s\n", pBuffer );
1397 return s_pMan3 != NULL;
1402 printf(
"Before normalizing: Library has %d classes and %d AIG subgraphs with %d AND nodes.\n",
1405 printf(
"After normalizing: Library has %d classes and %d AIG subgraphs with %d AND nodes.\n",
1409 return s_pMan3->
pGia;
1417 assert( s_pMan3 == NULL );
1418 s_pMan3 =
Lms_ManStart( p, nVars, nCuts, fFuncOnly, fVerbose );
1423 assert( s_pMan3 != NULL );
static void Gia_ManPatchCoDriver(Gia_Man_t *p, int iCoIndex, int iLit0)
Vec_Int_t * Lms_GiaFindNonRedundantCos(Lms_Man_t *p)
static int * Vec_IntArray(Vec_Int_t *p)
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
int Lms_ObjAreaUnmark_rec(Gia_Obj_t *pObj)
static void Abc_TtStretch5(unsigned *pInOut, int nVarS, int nVarB)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static int Abc_TtSuppFindFirst(int Supp)
static If_Obj_t * If_ManObj(If_Man_t *p, int i)
void Gia_ObjCollectInternal(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Abc_TtSupport(word *t, int nVars)
void Gia_ManStop(Gia_Man_t *p)
void Abc_NtkRecLibMerge3(Gia_Man_t *pLib)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
#define Gia_ManForEachCo(p, pObj, i)
static int Gia_ManPoNum(Gia_Man_t *p)
void If_CutTraverse(If_Man_t *p, If_Obj_t *pRoot, If_Cut_t *pCut, Vec_Ptr_t *vNodes)
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
static int Lms_DelayGet(word D, int v)
FUNCTION DEFINITIONS ///.
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Lms_ManPrintFreqStats(Lms_Man_t *p)
int Abc_NtkRecIsRunning3()
static int Abc_TtSuppIsMinBase(int Supp)
static int Gia_ObjFaninLit0p(Gia_Man_t *p, Gia_Obj_t *pObj)
static int If_ObjIsAnd(If_Obj_t *pObj)
static int Gia_ObjNum(Gia_Man_t *p, Gia_Obj_t *pObj)
static void Vec_MemHashAlloc(Vec_Mem_t *p, int nTableSize)
#define Vec_MemForEachEntry(p, pEntry, i)
MACRO DEFINITIONS ///.
static int Abc_Truth6WordNum(int nVars)
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
static int If_CutLeaveNum(If_Cut_t *pCut)
Hop_Obj_t * Abc_RecToHop3(Hop_Man_t *pMan, If_Man_t *pIfMan, If_Cut_t *pCut, If_Obj_t *pIfObj)
static int Gia_ManAppendCi(Gia_Man_t *p)
word pTemp2[LMS_MAX_WORD]
static int If_ObjFaninC0(If_Obj_t *pObj)
static int Abc_Var2Lit(int Var, int fCompl)
static char * If_CutPerm(If_Cut_t *pCut)
Abc_Ntk_t * Abc_NtkIf(Abc_Ntk_t *pNtk, If_Par_t *pPars)
typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
DECLARATIONS ///.
int Abc_RecToGia3(Gia_Man_t *pMan, If_Man_t *pIfMan, If_Cut_t *pCut, Vec_Int_t *vLeaves, int fHash)
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
int Abc_NtkRecTruthCompare(int *p1, int *p2)
static int Vec_MemEntryNum(Vec_Mem_t *p)
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static int Gia_WordCountOnes(unsigned uWord)
static word Lms_DelayMax(word D1, word D2, int nVars)
int Lms_ObjArea(Gia_Obj_t *pObj)
static int If_ObjIsCi(If_Obj_t *pObj)
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
void Abc_NtkRecStart3(Gia_Man_t *p, int nVars, int nCuts, int fFuncOnly, int fVerbose)
static Vec_Str_t * Vec_StrAlloc(int nCap)
Vec_Str_t * Lms_GiaAreas(Gia_Man_t *p)
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
static void Vec_StrPush(Vec_Str_t *p, char Entry)
static Vec_Int_t * Vec_IntStartNatural(int nSize)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void Vec_WrdFreeP(Vec_Wrd_t **p)
int(* pFuncUser)(If_Man_t *, If_Obj_t *, If_Cut_t *)
static Vec_Int_t * Vec_IntStartFull(int nSize)
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
void Lms_GiaProfilesPrint(Gia_Man_t *p)
static int Abc_LitNotCond(int Lit, int c)
void Lms_GiaPrintSubgraph(Gia_Man_t *p, Gia_Obj_t *pObj)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
void Gia_ManStopP(Gia_Man_t **p)
static void Lms_DelaySet(word *pD, int v, int d)
static int If_CutTruthIsCompl(If_Cut_t *pCut)
word * Gia_ObjComputeTruthTable(Gia_Man_t *p, Gia_Obj_t *pObj)
static int If_CutComputeDelay(If_Man_t *p, If_Cut_t *pCut, char *pCanonPerm, word DelayProfile)
#define ABC_PRTP(a, t, T)
word pTemp1[LMS_MAX_WORD]
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static int If_CutFindBestStruct(If_Man_t *pIfMan, If_Cut_t *pCut, char *pCanonPerm, unsigned *puCanonPhase, int *pBestPo)
static int If_ObjFaninC1(If_Obj_t *pObj)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
static Vec_Mem_t * Vec_MemAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Gia_ManAndNum(Gia_Man_t *p)
static int Abc_MinInt(int a, int b)
static Vec_Int_t * Vec_IntStart(int nSize)
int Abc_NtkRecInputNum3()
static char Vec_StrEntry(Vec_Str_t *p, int i)
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Abc_NtkRecPs3(int fPrintLib)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
static void Vec_StrFree(Vec_Str_t *p)
static int Vec_IntFindMin(Vec_Int_t *p)
static void Lms_DelayPrint(word D, int nVars)
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Vec_IntFindMax(Vec_Int_t *p)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Vec_WrdFree(Vec_Wrd_t *p)
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
void Gia_ManHashStart(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
void Lms_ManStop(Lms_Man_t *p)
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
static void Vec_IntFreeP(Vec_Int_t **p)
Vec_Int_t * Lms_GiaCollectUsefulCos(Lms_Man_t *p)
unsigned Kit_TruthSemiCanonicize(unsigned *pInOut, unsigned *pAux, int nVars, char *pCanonPerm)
static void Vec_MemFree(Vec_Mem_t *p)
Vec_Int_t * Lms_GiaCountTruths(Lms_Man_t *p)
void Lms_ManPrepare(Lms_Man_t *p)
static int Lms_DelayEqual(word D1, word D2, int nVars)
int If_CutDelayRecCost3(If_Man_t *pIfMan, If_Cut_t *pCut, If_Obj_t *pObj)
void Lms_GiaNormalize(Lms_Man_t *p)
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
int Abc_NtkRecAddCut3(If_Man_t *pIfMan, If_Obj_t *pRoot, If_Cut_t *pCut)
static int Vec_StrSize(Vec_Str_t *p)
static int Gia_ManCiNum(Gia_Man_t *p)
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
static int Vec_IntSize(Vec_Int_t *p)
void Lms_ManPrintFuncStats(Lms_Man_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static word Lms_DelayInit(int v)
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Gia_Man_t * Gia_ManCleanupOutputs(Gia_Man_t *p, int nOutputs)
Lms_Man_t * Lms_ManStart(Gia_Man_t *pGia, int nVars, int nCuts, int fFuncOnly, int fVerbose)
void Lms_ManPrint(Lms_Man_t *p)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
static int Abc_Lit2Var(int Lit)
#define ABC_CALLOC(type, num)
static int Abc_TtSupportSize(word *t, int nVars)
unsigned Abc_TtCanonicize(word *pTruth, int nVars, char *pCanonPerm)
FUNCTION DECLARATIONS ///.
static void Vec_PtrFreeP(Vec_Ptr_t **p)
static int Abc_TtSuppOnlyOne(int Supp)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
static Lms_Man_t * s_pMan3
#define ABC_INFINITY
MACRO DEFINITIONS ///.
static void Vec_MemHashFree(Vec_Mem_t *p)
void Lms_ObjAreaMark_rec(Gia_Obj_t *pObj)
static void Vec_PtrClear(Vec_Ptr_t *p)
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
#define Gia_ManForEachObj1(p, pObj, i)
static int Lms_DelayDom(word D1, word D2, int nVars)
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
static void Vec_IntFree(Vec_Int_t *p)
static int Gia_ManPiNum(Gia_Man_t *p)
void Lms_GiaPrintSubgraph_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
static void Vec_IntClear(Vec_Int_t *p)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
char * Abc_UtilStrsav(char *s)
#define Gia_ManForEachPo(p, pObj, i)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Gia_Man_t * Abc_NtkRecGetGia3()
static int * Vec_MemHashLookup(Vec_Mem_t *p, word *pEntry)
int Dau_DsdCheck1Step(void *p, word *pTruth, int nVarsInit, int *pVarLevels)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Vec_Wrd_t * Lms_GiaDelays(Gia_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
static int Gia_ObjCioId(Gia_Obj_t *pObj)
static int Gia_ManObjNum(Gia_Man_t *p)
void Abc_NtkRecDumpTt3(char *pFileName, int fBinary)
static void Vec_StrFreeP(Vec_Str_t **p)
void Abc_NtkRecAdd3(Abc_Ntk_t *pNtk, int fUseSOPB)
Vec_Str_t * Lms_GiaSuppSizes(Gia_Man_t *p)
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
static int Gia_ManCoNum(Gia_Man_t *p)
static word Lms_DelayDecrement(word D1, int nVars)