32 #define Dtc_ForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += pCut[0] + 1 )
33 #define Dtc_ForEachFadd( vFadds, i ) for ( i = 0; i < Vec_IntSize(vFadds)/5; i++ )
54 int i, k, curCi, curCo, nBoxIns, nBoxOuts;
59 for ( i = 0; i < nBoxes; i++ )
63 printf(
"Box %4d [%d x %d] : ", i, nBoxIns, nBoxOuts );
64 printf(
"Input obj IDs = " );
65 for ( k = 0; k < nBoxIns; k++ )
70 printf(
" Output obj IDs = " );
71 for ( k = 0; k < nBoxOuts; k++ )
100 for ( k = 0; k <= pCut1[0]; k++ )
102 for ( i = 1; i <= pCut0[0]; i++ )
104 for ( k = 1; k <= pCut1[0]; k++ )
105 if ( pCut0[i] == pCut1[k] )
111 pCut[1+pCut[0]++] = pCut0[i];
113 assert( pCut[0] == 2 || pCut[0] == 3 );
114 if ( pCut[1] > pCut[2] )
116 assert( pCut[1] < pCut[2] );
119 if ( pCut[2] > pCut[3] )
121 if ( pCut[1] > pCut[2] )
123 assert( pCut[1] < pCut[2] );
124 assert( pCut[2] < pCut[3] );
133 for ( k = 0; k <= pCut[0]; k++ )
134 if ( pCut[k] != pCutNew[k] )
163 unsigned Truth,
Truths[3] = { 0xAA, 0xCC, 0xF0 };
int i;
164 for ( i = 1; i <= pCut[0]; i++ )
170 if ( Truth == 0x96 || Truth == 0x69 )
172 if ( Truth == 0xE8 || Truth == 0xD4 || Truth == 0xB2 || Truth == 0x71 ||
173 Truth == 0x17 || Truth == 0x2B || Truth == 0x4D || Truth == 0x8E )
180 int i, k, c, Type, * pCut0, * pCut1, pCut[4];
191 for ( c = 0; c <= pCut[0]; c++ )
198 vTemp = Type == 1 ? vCutsXor : vCutsMaj;
199 for ( c = 1; c <= pCut[0]; c++ )
207 int * pList0, * pList1, i, nCuts = 0;
231 printf(
"Nodes = %d. Cuts = %d. Cuts/Node = %.2f. Ints/Node = %.2f.\n",
235 *pvCutsXor = vCutsXor;
236 *pvCutsMaj = vCutsMaj;
247 while ( pCuts0 < pLimit0 && pCuts1 < pLimit1 )
249 for ( i = 0; i < 3; i++ )
250 if ( pCuts0[i] != pCuts1[i] )
254 for ( i = 0; i < 4; i++ )
260 else if ( pCuts0[i] < pCuts1[i] )
262 else if ( pCuts0[i] > pCuts1[i] )
273 printf(
"%6d : ", i );
285 if ( pCut0[0] < pCut1[0] )
return -1;
286 if ( pCut0[0] > pCut1[0] )
return 1;
287 if ( pCut0[1] < pCut1[1] )
return -1;
288 if ( pCut0[1] > pCut1[1] )
return 1;
289 if ( pCut0[2] < pCut1[2] )
return -1;
290 if ( pCut0[2] > pCut1[2] )
return 1;
295 if ( pCut0[4] < pCut1[4] )
return -1;
296 if ( pCut0[4] > pCut1[4] )
return 1;
302 Vec_Int_t * vCutsXor, * vCutsMaj, * vFadds;
357 else if ( iLen == iLen2 )
381 for ( iFadd = iFaddTop; iFadd >= 0 &&
440 int i, k, iFadd, Count = 0;
446 printf(
"Chain %4d : %4d ", i,
Vec_IntSize(vChain) );
449 printf(
"%d(%d) ", iFadd,
Vec_IntEntry(vFadds, 5*iFadd+4) );
464 printf(
"Total chains = %d. Total full-adders = %d.\n",
Vec_WecSize(vChains), Count );
470 int i, k, iFadd = -1;
501 int i, k, Type,
Truth, pCut[4] = {3};
506 for ( k = 0; k < 3; k++ )
519 int i, Total = nIns * nOuts;
520 float * pDelayTable =
ABC_ALLOC(
float, Total + 3 );
522 pDelayTable[1] = nIns;
523 pDelayTable[2] = nOuts;
524 for ( i = 0; i < Total; i++ )
525 pDelayTable[i+3] = 1;
535 pMan =
Tim_ManStart( nPis + nOuts * nBoxes, nPos + nIns * nBoxes );
539 for ( i = 0; i < nBoxes; i++ )
554 int i, k, pInLits[16], pOutLits[16];
555 assert( nIns < 16 && nOuts < 16 );
556 for ( i = 0; i < nIns; i++ )
560 for ( i = 0; i < nBoxes; i++ )
561 for ( k = 0; k < nOuts; k++ )
568 int i, k, iFadd, iCiLit, pLits[3];
572 for ( k = 0; k < 3; k++ )
574 if ( i && !k )
continue;
584 for ( k = 0; k < 3; k++ )
587 pLits[k] = (!k && iCiLit) ? iCiLit : pObj->
Value;
593 if ( iMajTruth == 0x4D )
594 pLits[0] =
Abc_LitNot(pLits[0]), iMajTruth = 0x8E, iXorTruth = 0xFF & ~iXorTruth;
595 else if ( iMajTruth == 0xD4 )
596 pLits[0] =
Abc_LitNot(pLits[0]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
597 else if ( iMajTruth == 0x2B )
598 pLits[1] =
Abc_LitNot(pLits[1]), iMajTruth = 0x8E, iXorTruth = 0xFF & ~iXorTruth;
599 else if ( iMajTruth == 0xB2 )
600 pLits[1] =
Abc_LitNot(pLits[1]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
601 if ( iMajTruth == 0x8E )
602 pLits[2] =
Abc_LitNot(pLits[2]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
603 else if ( iMajTruth == 0x71 )
604 pLits[2] =
Abc_LitNot(pLits[2]), iMajTruth = 0x17, iXorTruth = 0xFF & ~iXorTruth;
605 else assert( iMajTruth == 0xE8 || iMajTruth == 0x17 );
609 for ( k = 0; k < 3; k++ )
611 iXorTruth = 0xFF & ~iXorTruth;
612 iMajTruth = 0xFF & ~iMajTruth;
616 for ( k = 0; k < 3; k++ )
619 assert( iXorTruth == 0x96 || iXorTruth == 0x69 );
623 assert( iMajTruth == 0xE8 || iMajTruth == 0x17 );
629 pObj->
Value = iCiLit;
655 Vec_Int_t * vFadds, * vMap, * vMap2Chain, * vTruths, * vChain;
661 printf(
"Currently natural carry-chains cannot be detected when boxes are present.\n" );
701 Gia_ManDupFadd( pNew, p, vChain, vFadds, vMap, vChains, vMap2Chain, vTruths );
710 printf(
"Warning: Sequential design is coverted into combinational one by adding white boxes.\n" );
773 int i, nRealPis, nRealPos;
824 int iCiLit, iOtherLit, iLit0, iLit1, iLit2;
828 assert( iCiLit >= 0 && iOtherLit >= 0 );
841 if ( vCarries && pObj->
fPhase )
902 int i, k, iBox, iBoxOutId, Delay, Delay0, Delay1, DelayMax = 0, nBoxes = 0;
908 if ( fIgnoreBoxDelays )
915 iBox = iBoxOutId / 2;
919 for ( k = 0; k < 3; k++ )
936 DelayMax =
Abc_MaxInt( DelayMax, pDelays[i] );
944 Delay =
Abc_MaxInt( Delay0 + DelayC, Delay1 + 100 );
949 Delay =
Abc_MaxInt( Delay1 + DelayC, Delay0 + 100 );
953 Delay =
Abc_MaxInt( Delay0 + 100, Delay1 + 100 );
970 int i, iMax = -1, DelayMax = 0;
975 if ( DelayMax > pDelays[i] )
977 DelayMax = pDelays[i];
1057 int i, RetValue, nBoxes, MaxDelay, nPaths = 0;
1065 printf(
"Running path detection: BoxDelay = %d, PathMin = %d, PathMax = %d, PathLimit = %d.\n", DelayC, nPathMin, nPathMax, nPathLimit );
1066 for ( i = 0; i < nPathLimit; i++ )
1070 if ( RetValue == -1 )
1072 nPaths += (RetValue > 0);
1074 printf(
"Iter %5d : Paths = %2d. Boxes = %2d. Total boxes = %6d. Max delay = %5d.\n", i, nPaths, RetValue, nBoxes, MaxDelay );
1092 Gia_ManIteratePaths( p, DelayC, nPathMin, nPathMax, nPathLimit, fIgnoreBoxDelays, fVerbose );
int Gia_ManFindChains_rec(Gia_Man_t *p, int iMaj, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Int_t *vLength)
static int * Vec_IntArray(Vec_Int_t *p)
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManCreateRefs(Gia_Man_t *p)
int Tim_ManCoNum(Tim_Man_t *p)
void Gia_ManCleanPhase(Gia_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
int Gia_ObjFanin1CopyCarry(Vec_Int_t *vCarries, Gia_Obj_t *pObj, int Id)
Vec_Int_t * Dtc_ManFindCommonCuts(Gia_Man_t *p, Vec_Int_t *vCutsXor, Vec_Int_t *vCutsMaj)
Gia_Man_t * Gia_ManDupWithNaturalBoxes(Gia_Man_t *p, int nFaddMin, int fVerbose)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
static int Gia_ManAppendXor(Gia_Man_t *p, int iLit0, int iLit1)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
#define Dtc_ForEachCut(pList, pCut, i)
DECLARATIONS ///.
Gia_Man_t * Gia_ManDupWithArtificalFaddBoxes(Gia_Man_t *p, int fUseFanout)
#define Gia_ManForEachCo(p, pObj, i)
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
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 ///.
static void Vec_WecFree(Vec_Wec_t *p)
static int Gia_ManAppendCi(Gia_Man_t *p)
void Gia_ManCleanValue(Gia_Man_t *p)
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
static int Abc_Var2Lit(int Var, int fCompl)
int Gia_ObjFanin0CopyCarry(Vec_Int_t *vCarries, Gia_Obj_t *pObj, int Id)
static int Gia_ObjIsUsed(Gia_Obj_t *pObj)
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Vec_Int_t * Gia_ManCollectTruthTables(Gia_Man_t *p, Vec_Int_t *vFadds)
Vec_Int_t * Gia_ManFindMapping(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains)
#define ABC_ALLOC(type, num)
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
void Gia_ManCollectOneChain(Gia_Man_t *p, Vec_Int_t *vFadds, int iFaddTop, Vec_Int_t *vMap, Vec_Int_t *vChain)
void Gia_ManDupFadd(Gia_Man_t *pNew, Gia_Man_t *p, Vec_Int_t *vChain, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains, Vec_Int_t *vMap2Chain, Vec_Int_t *vTruths)
int Dtc_ManCompare(int *pCut0, int *pCut1)
static void Vec_BitWriteEntry(Vec_Bit_t *p, int i, int Entry)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
int Dtc_ManCutCheckEqual(Vec_Int_t *vCuts, int *pCutNew)
static Vec_Int_t * Vec_IntStartFull(int nSize)
static int * Vec_IntLimit(Vec_Int_t *p)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
static void Vec_IntReverseOrder(Vec_Int_t *p)
Gia_Man_t * Gia_ManGenerateExtraAig(int nBoxes, int nIns, int nOuts)
static int Abc_LitNotCond(int Lit, int c)
static int Vec_WecSize(Vec_Wec_t *p)
#define ABC_SWAP(Type, a, b)
void Gia_ManFindChains(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap)
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
int Gia_ManHasDangling(Gia_Man_t *p)
int Tim_ManPiNum(Tim_Man_t *p)
Vec_Wec_t * Gia_ManCollectTopmost(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, int nFaddMin)
void Tim_ManCreateBox(Tim_Man_t *p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable)
ITERATORS ///.
#define Gia_ManForEachCi(p, pObj, i)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static int Gia_ManAndNum(Gia_Man_t *p)
static Vec_Int_t * Vec_IntStart(int nSize)
static int Abc_LitIsCompl(int Lit)
static Vec_Bit_t * Vec_BitStart(int nSize)
void Dtc_ManPrintFadds(Vec_Int_t *vFadds)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Dtc_ObjCleanTruth_rec(Gia_Obj_t *pObj)
float * Gia_ManGenerateDelayTableFloat(int nIns, int nOuts)
void Gia_ManPrintChains(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains)
int Gia_ManBoxNum(Gia_Man_t *p)
DECLARATIONS ///.
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
#define Dtc_ForEachFadd(vFadds, i)
int Gia_ManFindAnnotatedDelay(Gia_Man_t *p, int DelayC, int *pnBoxes, int fIgnoreBoxDelays)
void Dtc_ManCutMerge(Gia_Man_t *p, int iObj, int *pList0, int *pList1, Vec_Int_t *vCuts, Vec_Int_t *vCutsXor, Vec_Int_t *vCutsMaj)
static int Vec_IntEntry(Vec_Int_t *p, int i)
Vec_Int_t * Gia_ManDetectFullAdders(Gia_Man_t *p, int fVerbose)
#define ABC_NAMESPACE_IMPL_END
int Tim_ManCiNum(Tim_Man_t *p)
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
#define Gia_ManForEachAnd(p, pObj, i)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Tim_Man_t * Tim_ManStart(int nCis, int nCos)
DECLARATIONS ///.
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManDupWithFaddBoxes_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains, Vec_Int_t *vMap2Chain, Vec_Int_t *vTruths)
void Dtc_ManComputeCuts(Gia_Man_t *p, Vec_Int_t **pvCutsXor, Vec_Int_t **pvCutsMaj, int fVerbose)
void Gia_ManFillValue(Gia_Man_t *p)
int Tim_ManBoxNum(Tim_Man_t *p)
int Dtc_ObjComputeTruth_rec(Gia_Obj_t *pObj)
static void Vec_IntFreeP(Vec_Int_t **p)
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
static int Gia_ObjIsTravIdCurrentId(Gia_Man_t *p, int Id)
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_START
int Dtc_ManCompare2(int *pCut0, int *pCut1)
Vec_Int_t * Gia_ManCreateMap(Gia_Man_t *p, Vec_Int_t *vFadds)
static int Gia_ManCiNum(Gia_Man_t *p)
static int Vec_IntEntryLast(Vec_Int_t *p)
static int Abc_LitNot(int Lit)
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
static void Gia_ObjRefFanin0Dec(Gia_Man_t *p, Gia_Obj_t *pObj)
void Tim_ManSetDelayTables(Tim_Man_t *p, Vec_Ptr_t *vDelayTables)
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
static int Vec_IntSize(Vec_Int_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
int Gia_ManFindPath(Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, Vec_Int_t *vPath)
Gia_Man_t * Gia_ManDupWithArtificalFaddBoxesTest(Gia_Man_t *p)
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
int Gia_ManIteratePaths(Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fIgnoreBoxDelays, int fVerbose)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Gia_Man_t * Gia_ManDupWithArtificialBoxes(Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fUseFanout, int fIgnoreBoxDelays, int fVerbose)
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
static int Vec_BitEntry(Vec_Bit_t *p, int i)
static int Gia_ManAppendMaj(Gia_Man_t *p, int iData0, int iData1, int iData2)
static int Abc_Lit2Var(int Lit)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
static void Vec_BitFree(Vec_Bit_t *p)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
#define Gia_ManForEachObj1(p, pObj, i)
void Gia_ManIncrementTravId(Gia_Man_t *p)
void Gia_ManMarkWithTravId_rec(Gia_Man_t *p, int Id)
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
static void Vec_IntFree(Vec_Int_t *p)
int Dtc_ManCutMergeOne(int *pCut0, int *pCut1, int *pCut)
static void Vec_IntClear(Vec_Int_t *p)
void Gia_ManCleanMark01(Gia_Man_t *p)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
static void Gia_ObjSetTravIdCurrentId(Gia_Man_t *p, int Id)
char * Abc_UtilStrsav(char *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
static void Gia_ObjRefFanin1Dec(Gia_Man_t *p, Gia_Obj_t *pObj)
Tim_Man_t * Gia_ManGenerateTim(int nPis, int nPos, int nBoxes, int nIns, int nOuts)
int Tim_ManPoNum(Tim_Man_t *p)
static int Gia_ObjCioId(Gia_Obj_t *pObj)
static int Gia_ManObjNum(Gia_Man_t *p)
void Gia_ManIllustrateBoxes(Gia_Man_t *p)
FUNCTION DEFINITIONS ///.
int Gia_ManFindChainStart(Gia_Man_t *p)
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
static int Gia_ManCoNum(Gia_Man_t *p)
int Dtc_ObjComputeTruth(Gia_Man_t *p, int iObj, int *pCut, int *pTruth)
static int Gia_ManRegNum(Gia_Man_t *p)