60static inline int Supp_SizeType(
int nSize,
int nStepSize ) {
return nSize / nStepSize + ((nSize % nStepSize) > 0); }
61static inline char * Supp_OneNext(
char * pPart ) {
return *((
char **)pPart); }
62static inline void Supp_OneSetNext(
char * pPart,
char * pNext ) { *((
char **)pPart) = pNext; }
84 p->nChunkSize = nChunkSize;
85 p->nStepSize = nStepSize;
86 p->vMemory = Vec_PtrAlloc( 1000 );
87 p->vFree = Vec_PtrAlloc( 1000 );
108 Vec_PtrFree(
p->vMemory );
109 Vec_PtrFree(
p->vFree );
129 Type = Supp_SizeType( nSize,
p->nStepSize );
130 Vec_PtrFillExtra(
p->vFree, Type + 1, NULL );
131 if ( (pMemory = (
char *)Vec_PtrEntry(
p->vFree, Type )) )
133 Vec_PtrWriteEntry(
p->vFree, Type, Supp_OneNext(pMemory) );
136 nSizeReal =
p->nStepSize * Type;
137 if (
p->nFreeSize < nSizeReal )
140 p->nFreeSize =
p->nChunkSize;
141 Vec_PtrPush(
p->vMemory,
p->pFreeBuf );
143 assert(
p->nFreeSize >= nSizeReal );
144 pMemory =
p->pFreeBuf;
145 p->pFreeBuf += nSizeReal;
146 p->nFreeSize -= nSizeReal;
164 Type = Supp_SizeType( nSize,
p->nStepSize );
165 Vec_PtrFillExtra(
p->vFree, Type + 1, NULL );
166 Supp_OneSetNext( pMemory, (
char *)Vec_PtrEntry(
p->vFree, Type) );
167 Vec_PtrWriteEntry(
p->vFree, Type, pMemory );
185 pPart->
nRefs = nRefs;
222 Supp_One_t *
p = Supp_ManFetchEntry( pMan, p1->nOuts + p2->nOuts, nRefs );
223 int * pBeg1 = p1->pOuts;
224 int * pBeg2 = p2->pOuts;
225 int * pBeg =
p->pOuts;
226 int * pEnd1 = p1->pOuts + p1->nOuts;
227 int * pEnd2 = p2->pOuts + p2->nOuts;
228 while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
230 if ( *pBeg1 == *pBeg2 )
231 *pBeg++ = *pBeg1++, pBeg2++;
232 else if ( *pBeg1 < *pBeg2 )
237 while ( pBeg1 < pEnd1 )
239 while ( pBeg2 < pEnd2 )
241 p->nOuts = pBeg -
p->pOuts;
242 assert(
p->nOuts <=
p->nOutsAlloc );
243 assert(
p->nOuts >= p1->nOuts );
244 assert(
p->nOuts >= p2->nOuts );
263 vSupp = Vec_IntAlloc(
p->nOuts );
264 for ( i = 0; i <
p->nOuts; i++ )
265 Vec_IntPush( vSupp,
p->pOuts[i] );
285 assert( Abc_NtkIsStrash(pNtk) );
286 vNodes = Vec_PtrAlloc( Abc_NtkObjNum(pNtk) );
287 Abc_NtkIncrementTravId( pNtk );
290 Abc_NodeSetTravIdCurrent( pObj );
291 Vec_PtrPush( vNodes, pObj );
297 if ( Abc_ObjIsCi(pNext) && !Abc_NodeIsTravIdCurrent(pNext) )
299 Abc_NodeSetTravIdCurrent( pNext );
300 Vec_PtrPush( vNodes, pNext );
303 Vec_PtrPush( vNodes, pObj );
306 if ( Abc_ObjIsCo(pNext) && !Abc_NodeIsTravIdCurrent(pNext) )
308 Abc_NodeSetTravIdCurrent( pNext );
309 Vec_PtrPush( vNodes, pNext );
343 vSupports = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
349 if ( Abc_ObjIsNode(pObj) )
351 pPart0 = (
Supp_One_t *)Abc_ObjFanin0(pObj)->pCopy;
352 pPart1 = (
Supp_One_t *)Abc_ObjFanin1(pObj)->pCopy;
355 if ( --pPart0->
nRefs == 0 )
356 Supp_ManRecycleEntry(
p, pPart0 );
358 if ( --pPart1->
nRefs == 0 )
359 Supp_ManRecycleEntry(
p, pPart1 );
362 if ( Abc_ObjIsCo(pObj) )
364 pPart0 = (
Supp_One_t *)Abc_ObjFanin0(pObj)->pCopy;
366 if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
369 Vec_IntPush( vSupp, (
int)(ABC_PTRINT_T)pObj->
pNext );
370 Vec_PtrPush( vSupports, vSupp );
373 if ( --pPart0->
nRefs == 0 )
374 Supp_ManRecycleEntry(
p, pPart0 );
377 if ( Abc_ObjIsCi(pObj) )
379 if ( Abc_ObjFanoutNum(pObj) )
381 pPart0 = (
Supp_One_t *)Supp_ManFetchEntry(
p, 1, Abc_ObjFanoutNum(pObj) );
389 if ( Abc_ObjFanoutNum(pObj) )
390 pObj->
pCopy = (
Abc_Obj_t *)Supp_ManFetchEntry(
p, 0, Abc_ObjFanoutNum(pObj) );
395 Vec_PtrFree( vNodes );
399 Vec_VecSort( (
Vec_Vec_t *)vSupports, 1 );
435 vSupports = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
438 if ( !Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
443 Vec_IntWriteEntry( vSuppI, k, (
int)(ABC_PTRINT_T)pTemp->
pNext );
444 Vec_IntSort( vSuppI, 0 );
446 Vec_IntPush( vSuppI, i );
448 Vec_PtrPush( vSupports, vSuppI );
454 Vec_VecSort( (
Vec_Vec_t *)vSupports, 1 );
478 int nWords = Abc_BitWordNum(nPis);
484 Abc_InfoSetBit( pBuffer, Entry );
506 Abc_InfoSetBit( pBuffer, Entry );
523 int i, Entry, nCommon = 0;
525 nCommon += Abc_InfoHasBit(pBuffer, Entry);
576 int Attract, Repulse, Value, ValueBest;
577 int i, nCommon, iBest;
595 if ( nCommon == Vec_IntSize(vOne) )
598 if ( nSuppSizeLimit > 0 && Vec_IntSize(vPartSupp) >= 2 * nSuppSizeLimit )
601 Attract = 1000 * nCommon / Vec_IntSize(vOne);
602 if ( Vec_IntSize(vPartSupp) < 100 )
605 Repulse = 1+Abc_Base2Log(Vec_IntSize(vPartSupp)-100);
606 Value = Attract/Repulse;
607 if ( ValueBest < Value )
613 if ( ValueBest < 75 )
632 int i, nOutputs, Counter;
637 nOutputs = Vec_IntSize((
Vec_Int_t *)Vec_PtrEntry(vPartsAll, i));
638 printf(
"%d=(%d,%d) ", i, Vec_IntSize(vOne), nOutputs );
640 if ( i == Vec_PtrSize(vPartsAll) - 1 )
644 printf(
"\nTotal = %d. Outputs = %d.\n", Counter, Abc_NtkCoNum(pNtk) );
660 Vec_Int_t * vOne, * vPart, * vPartSupp, * vTemp;
663 if ( nSuppSizeLimit == 0 )
664 nSuppSizeLimit = 200;
668 vPart = vPartSupp = NULL;
671 if ( Vec_IntSize(vOne) < nSuppSizeLimit )
673 if ( vPartSupp == NULL )
676 vPartSupp = Vec_IntDup(vOne);
677 vPart = (
Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
681 vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
682 Vec_IntFree( vTemp );
683 vPart = Vec_IntTwoMerge( vTemp = vPart, (
Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
684 Vec_IntFree( vTemp );
685 Vec_IntFree( (
Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
687 if ( Vec_IntSize(vPartSupp) < nSuppSizeLimit )
691 vPart = (
Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
693 Vec_PtrWriteEntry( vPartsAll, iPart, vPart );
697 Vec_IntFree( (
Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
698 Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
706 Vec_PtrWriteEntry( vPartsAll, iPart, vPart );
709 assert( vPartSupp != NULL );
710 Vec_IntFree( (
Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
711 Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
715 Vec_PtrShrink( vPartsAll, iPart );
716 Vec_PtrShrink( vPartsAll, iPart );
734 Vec_Ptr_t * vSupps, * vPartsAll, * vPartsAll2, * vPartSuppsAll;
735 Vec_Int_t * vOne, * vPart, * vPartSupp, * vTemp;
736 int i, iPart, iOut, timeFind = 0;
745ABC_PRT(
"Supps", Abc_Clock() - clk );
748 vPartSuppsChar = Vec_PtrAlloc( 1000 );
752 vPartsAll = Vec_PtrAlloc( 256 );
753 vPartSuppsAll = Vec_PtrAlloc( 256 );
757 Extra_ProgressBarUpdate( pProgress, i, NULL );
762 iOut = Vec_IntPop(vOne);
766timeFind += Abc_Clock() - clk2;
770 vPart = Vec_IntAlloc( 32 );
771 Vec_IntPush( vPart, iOut );
773 vPartSupp = Vec_IntDup( vOne );
775 Vec_PtrPush( vPartsAll, vPart );
776 Vec_PtrPush( vPartSuppsAll, vPartSupp );
783 vPart = (
Vec_Int_t *)Vec_PtrEntry( vPartsAll, iPart );
784 Vec_IntPush( vPart, iOut );
786 vPartSupp = (
Vec_Int_t *)Vec_PtrEntry( vPartSuppsAll, iPart );
787 vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
788 Vec_IntFree( vTemp );
790 Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
792 Abc_NtkSuppCharAdd( (
unsigned *)Vec_PtrEntry(vPartSuppsChar, iPart), vOne, Abc_NtkCiNum(pNtk) );
800 Vec_PtrFree( vPartSuppsChar );
805ABC_PRT(
"Parts", Abc_Clock() - clk );
812 Vec_IntPush( vOne, i );
814 Vec_VecSort( (
Vec_Vec_t *)vPartSuppsAll, 1 );
816 vPartsAll2 = Vec_PtrAlloc( 256 );
818 Vec_PtrPush( vPartsAll2, Vec_PtrEntry(vPartsAll, Vec_IntPop(vOne)) );
819 Vec_PtrFree( vPartsAll );
820 vPartsAll = vPartsAll2;
828ABC_PRT(
"Comps", Abc_Clock() - clk );
831 printf(
"Created %d partitions.\n", Vec_PtrSize(vPartsAll) );
836 Vec_VecFree( (
Vec_Vec_t *)vPartSuppsAll );
867 nParts = (Abc_NtkCoNum(pNtk) / nPartSize) + ((Abc_NtkCoNum(pNtk) % nPartSize) > 0);
868 vParts = (
Vec_Ptr_t *)Vec_VecStart( nParts );
870 Vec_IntPush( (
Vec_Int_t *)Vec_PtrEntry(vParts, i / nPartSize), i );
888 Vec_PtrClear( vOutsPtr );
890 Vec_PtrPush( vOutsPtr, Abc_NtkCo(pNtk, Out) );
907 pRepr = (
Abc_Obj_t *)Vec_PtrEntry( vEquiv, pObj->
Id );
908 if ( pRepr == NULL || pRepr == pObj )
926 Abc_Obj_t * pFan = Abc_ObjFanin0( pObj );
928 return Abc_ObjNotCond( pRepr->
pCopy, pRepr->
fPhase ^ pFan->
fPhase ^ (
int)Abc_ObjFaninC1(pObj) );
932 Abc_Obj_t * pFan = Abc_ObjFanin1( pObj );
934 return Abc_ObjNotCond( pRepr->
pCopy, pRepr->
fPhase ^ pFan->
fPhase ^ (
int)Abc_ObjFaninC1(pObj) );
948static inline Hop_Obj_t * Hop_ObjChild0Next(
Abc_Obj_t * pObj ) {
return Hop_NotCond( (
Hop_Obj_t *)Abc_ObjFanin0(pObj)->pNext, Abc_ObjFaninC0(pObj) ); }
949static inline Hop_Obj_t * Hop_ObjChild1Next(
Abc_Obj_t * pObj ) {
return Hop_NotCond( (
Hop_Obj_t *)Abc_ObjFanin1(pObj)->pNext, Abc_ObjFaninC1(pObj) ); }
970 pMan->vObjs = Vec_PtrAlloc( Abc_NtkObjNumMax(pNtk) + 1 );
971 Vec_PtrPush( pMan->vObjs, Hop_ManConst1(pMan) );
993 printf(
"Abc_NtkPartStartHop: HOP manager check has failed.\n" );
1018 assert( Abc_NtkIsStrash(pNtk) );
1024 assert( Abc_NtkIsStrash(pNtkTemp) );
1032 if ( iNodeId == -1 )
1034 printf(
"Cannot find CI node %s in the original network.\n",
Abc_ObjName(pObj) );
1037 pObj->
pCopy = Abc_NtkObj( pNtkNew, iNodeId );
1046 if ( Abc_AigNodeIsChoice(pObj) )
1050 Vec_PtrFree( vNodes );
1056 if ( iNodeId == -1 )
1058 printf(
"Cannot find CO node %s in the original network.\n",
Abc_ObjName(pObj) );
1061 pObj->
pCopy = Abc_NtkObj( pNtkNew, iNodeId );
1076 if ( Abc_ObjFaninNum(pObj->
pCopy) == 0 )
1088 printf(
"Abc_NtkPartStitchChoices: The network check has failed.\n" );
1108 Vec_Ptr_t * vParts, * vFraigs, * vOnePtr;
1110 Abc_Ntk_t * pNtk, * pNtk2, * pNtkAig, * pNtkFraig;
1114 pNtk = (
Abc_Ntk_t *)Vec_PtrEntry( vStore, 0 );
1115 assert( Abc_NtkIsStrash(pNtk) );
1122 vOnePtr = Vec_PtrAlloc( 1000 );
1123 vFraigs = Vec_PtrAlloc( Vec_PtrSize(vParts) );
1135 printf(
"Fraiging part %4d (out of %4d) PI = %5d. PO = %5d. And = %6d. Lev = %4d.\r",
1136 i+1, Vec_PtrSize(vParts), Abc_NtkPiNum(pNtkAig), Abc_NtkPoNum(pNtkAig),
1140 Vec_PtrPush( vFraigs, pNtkFraig );
1152 Vec_PtrFree( vFraigs );
1153 Vec_PtrFree( vOnePtr );
1170 Vec_Ptr_t * vParts, * vFraigs, * vOnePtr;
1177 assert( Abc_NtkIsStrash(pNtk) );
1184 vOnePtr = Vec_PtrAlloc( 1000 );
1185 vFraigs = Vec_PtrAlloc( Vec_PtrSize(vParts) );
1191 Vec_PtrPush( vFraigs, pNtkFraig );
1194 printf(
"Finished part %5d (out of %5d)\r", i+1, Vec_PtrSize(vParts) );
1203 Vec_PtrFree( vFraigs );
1204 Vec_PtrFree( vOnePtr );
1205 ABC_PRT(
"Partitioned fraiging time", Abc_Clock() - clk );
1222 Vec_Int_t * vGains = Vec_IntStartFull( Vec_PtrSize(vWins) );
1231 Abc_Print( 1,
"Something did not work out with the command \"%s\".\n", pScript );
1240 Abc_Print( 1,
"Something did not work out with the command \"%s\".\n", pScript );
1247 if ( Abc_NtkIsMappedLogic(pNew) && Abc_NtkIsMappedLogic(pNtk) )
1251 if ( Before >= After )
1253 Vec_IntWriteEntry( vGains, i, (
int)(Before - After) );
1260 if ( Abc_NtkNodeNum(pNtk) >= Abc_NtkNodeNum(pNew) )
1262 Vec_IntWriteEntry( vGains, i, Abc_NtkNodeNum(pNtk) - Abc_NtkNodeNum(pNew) );
1267 Vec_PtrWriteEntry( vWins, i, pNtk );
1299 char FileName[100], Command[1000], PreCommand[500] = {0};
1301 if ( pLibFileName )
sprintf( PreCommand,
"read_genlib %s; ", pLibFileName );
1302 sprintf( FileName,
"%06x.mm", Rand );
1304 char * pScript = Abc_UtilStrsav( pScript0 );
1305 sprintf( Command,
"./abc -q \"%sread_mm %s; %s; write_mm %s\"", PreCommand[0] ? PreCommand :
"", FileName, pScript, FileName );
1309 if (
system( (
char *)Command ) )
1312 fprintf( stderr,
"The following command has returned non-zero exit status:\n" );
1313 fprintf( stderr,
"\"%s\"\n", (
char *)Command );
1314 fprintf( stderr,
"Sorry for the inconvenience.\n" );
1343 if ( nProcs <= 2 ) {
1346 Vec_Int_t * vGains = Vec_IntStartFull( Vec_PtrSize(vWins) );
1348 Vec_Ptr_t * vData = Vec_PtrAlloc( Vec_PtrSize(vWins) );
1352 pData[i].
pIn = pNtk;
1353 pData[i].
pOut = NULL;
1357 Vec_PtrPush( vData, pData+i );
1362 if ( Abc_NtkIsMappedLogic(pNtk) )
1365 Vec_IntWriteEntry( vGains, i, Abc_NtkNodeNum(pNtk) - Abc_NtkNodeNum(pData[i].pOut) );
1367 Vec_PtrWriteEntry( vWins, i, pData[i].pOut );
1369 Vec_PtrFree( vData );
1387 if ( !Abc_ObjIsNode(pObj) )
1389 if ( Abc_NodeIsTravIdPrevious(pObj) )
1391 if ( Abc_NodeIsTravIdCurrent(pObj) )
1393 Abc_NodeSetTravIdPrevious(pObj);
1398 Abc_NodeSetTravIdCurrent(pObj);
1406 assert(Abc_ObjIsNode(pObj));
1408 Abc_NtkIncrementTravId(
p );
1410 Abc_NodeSetTravIdCurrent(pObj);
1412 Abc_NtkIncrementTravId(
p );
1440 assert( Abc_ObjIsNode(pObj) );
1441 if ( Vec_IntEntry(vMap, Abc_ObjId(pObj)) == -1 )
1450 int iWin = Vec_IntEntry(vMap, Abc_ObjId(pObj));
1458 Abc_NtkPi(pWin, i)->pCopy = pNode->
pCopy;
1464 Vec_PtrFree( vNodes );
1467 pNode->
pCopy = Abc_ObjFanin0(Abc_NtkPo(pWin, i))->
pCopy;
1472 if ( vvIns == NULL ) {
1473 assert( vvOuts == NULL );
1474 assert( Vec_PtrSize(vWins) == 1 );
1478 Vec_Ptr_t * vvInsNew = Vec_PtrAlloc( 10 );
1479 Vec_Ptr_t * vvOutsNew = Vec_PtrAlloc( 10 );
1480 Vec_Ptr_t * vvWinsNew = Vec_PtrAlloc( 10 );
1481 Abc_NtkIncrementTravId(
p );
1483 int i, Gain, iEntry = Vec_IntArgMax(vGains);
1484 if ( iEntry == -1 || Vec_IntEntry(vGains, iEntry) < 0 )
1487 Vec_IntWriteEntry( vGains, iEntry, -1 );
1488 Vec_PtrPush( vvInsNew, Vec_IntDup((
Vec_Int_t *)Vec_PtrEntry(vvIns, iEntry)) );
1489 Vec_PtrPush( vvOutsNew, Vec_IntDup((
Vec_Int_t *)Vec_PtrEntry(vvOuts, iEntry)) );
1499 if ( Abc_NodeIsTravIdCurrent(pNode) )
1501 if ( j < Vec_IntSize(vNodes) )
1502 Vec_IntWriteEntry( vGains, i, -1 );
1508 Vec_PtrFreeFunc( vvInsNew, (
void (*)(
void *)) Vec_IntFree );
1509 Vec_PtrFreeFunc( vvOutsNew, (
void (*)(
void *)) Vec_IntFree );
1510 Vec_PtrFreeFunc( vvWinsNew, (
void (*)(
void *))
Abc_NtkDelete );
1517 assert( Vec_IntSize(vIns) == Abc_NtkPiNum(pTemp) );
1518 assert( Vec_IntSize(vOuts) == Abc_NtkPoNum(pTemp) );
1522 Vec_Int_t * vMap = Vec_IntStartFull( Abc_NtkObjNumMax(
p) ), * vOuts;
1525 assert( Vec_IntEntry(vMap, iNode) == -1 );
1526 Vec_IntWriteEntry( vMap, iNode, i );
1535 Vec_IntFree( vMap );
1554 if ( Abc_NodeIsTravIdCurrent(
p ) )
1556 Abc_NodeSetTravIdCurrent(
p );
1564 if ( Abc_NodeIsTravIdCurrent(
p ) )
1566 Abc_NodeSetTravIdCurrent(
p );
1572 Vec_Int_t * vLevel, * vNodes = Vec_IntAlloc( 100 );
1573 Abc_Obj_t * pObj, * pNext;
int i, k, iLevel;
1575 Vec_IntClear( vLevel );
1577 Abc_NtkIncrementTravId( pNtk );
1583 if ( Abc_ObjIsNode(pNext) && !Abc_NodeIsTravIdCurrent(pNext) && !pNext->
fMarkA ) {
1585 Vec_WecPush( vStore, Abc_ObjLevel(pNext), Abc_ObjId(pNext) );
1588 Abc_NtkIncrementTravId( pNtk );
1590 Abc_NodeSetTravIdCurrent(pObj);
1594 assert( !Abc_NodeIsTravIdCurrent(pObj) );
1598 if ( !Abc_NodeIsTravIdCurrent(pNext) )
1600 if ( k < Abc_ObjFaninNum(pObj) )
1602 Abc_NodeSetTravIdCurrent(pObj);
1603 Vec_IntPush( vNodes, Abc_ObjId(pObj) );
1604 assert( Abc_ObjIsNode(pObj) );
1607 if ( Abc_ObjIsNode(pNext) && !Abc_NodeIsTravIdCurrent(pNext) && !pNext->
fMarkA ) {
1609 assert( Abc_ObjLevel(pNext) > iLevel );
1610 Vec_WecPush( vStore, Abc_ObjLevel(pNext), Abc_ObjId(pNext) );
1613 Vec_IntSort( vNodes, 0 );
1619 Vec_Ptr_t * vvNodes = Vec_PtrAlloc( Vec_PtrSize(vvIns) );
1626 Vec_Int_t * vOuts = Vec_IntAlloc( 100 );
1629 Abc_NtkIncrementTravId( pNtk );
1631 Abc_NodeSetTravIdCurrent(pObj);
1635 if ( !Abc_NodeIsTravIdCurrent(pNext) )
1637 if ( k < Abc_ObjFanoutNum(pObj) )
1638 Vec_IntPush( vOuts, Abc_ObjId(pObj) );
1640 if ( Vec_IntSize(vOuts) == 0 )
1641 printf(
"Window with %d internal nodes has no outputs (are these dangling nodes?).\n", Vec_IntSize(vNodes) );
1647 Vec_Ptr_t * vvOuts = Vec_PtrAlloc( Vec_PtrSize(vvNodes) );
1656 int LevelMin = Abc_ObjLevel(pObj), LevelMax = Level + 1;
1658 if ( Abc_ObjIsNode(pNext) )
1659 LevelMax = Abc_MinInt( LevelMax, Abc_ObjLevel(pNext) );
1660 if ( LevelMin == LevelMax )
continue;
1661 assert( LevelMin < LevelMax );
1671 Abc_NtkIncrementTravId( pNtk );
1673 if ( Abc_ObjLevel(pObj) <= Level )
1676 if ( Abc_ObjLevel(pFanin) <= Level && !Abc_NodeIsTravIdCurrent(pFanin) ) {
1677 Abc_NodeSetTravIdCurrent(pFanin);
1678 Vec_IntPush( vRes, Abc_ObjId(pFanin) );
1682 pFanin = Abc_ObjFanin0(pObj);
1683 if ( Abc_ObjLevel(pFanin) <= Level && !Abc_NodeIsTravIdCurrent(pFanin) && Abc_ObjFaninNum(pFanin) > 0 ) {
1684 Abc_NodeSetTravIdCurrent(pFanin);
1685 Vec_IntPush( vRes, Abc_ObjId(pFanin) );
1688 Vec_IntSort( vRes, 0 );
1695 Vec_Wec_t * vSupps = Vec_WecStart( Vec_IntSize(vBelow) );
1696 Vec_Int_t * vSuppIds = Vec_IntStartFull( Abc_NtkObjNumMax(pNtk)+1 );
1697 Vec_Int_t * vTemp[2] = { Vec_IntAlloc(100), Vec_IntAlloc(100) };
1698 Abc_Obj_t * pObj, * pFanin;
int i, k, Count = 0;
1700 Vec_IntWriteEntry( vSuppIds, Abc_ObjId(pObj), i );
1701 Vec_IntPush( Vec_WecEntry(vSupps, i), Abc_ObjId(pObj) );
1704 if ( Abc_ObjLevel(pObj) <= Level )
1706 Vec_IntClear( vTemp[0] );
1708 int iSuppId = Vec_IntEntry( vSuppIds, Abc_ObjId(pFanin) );
1709 if ( iSuppId == -1 )
1711 Vec_IntTwoMerge2( Vec_WecEntry(vSupps, iSuppId), vTemp[0], vTemp[1] );
1714 if ( k < Abc_ObjFaninNum(pObj) || Vec_IntSize(vTemp[0]) >
nSuppMax ) {
1718 Vec_IntWriteEntry( vSuppIds, Abc_ObjId(pObj), Vec_WecSize(vSupps) );
1719 Vec_IntAppend( Vec_WecPushLevel(vSupps), vTemp[0] );
1722 Abc_NtkIncrementTravId( pNtk );
1724 if ( Abc_ObjLevel(pObj) > Level && Vec_IntEntry(vSuppIds, i) >= 0 && !Abc_NodeIsTravIdCurrent(pObj) ) {
1726 Abc_NodeSetTravIdPrevious(pObj);
1729 vResSupps = Vec_WecAlloc( 100 );
1731 if ( Abc_ObjLevel(pObj) > Level && Vec_IntEntry(vSuppIds, i) >= 0 && !Abc_NodeIsTravIdCurrent(pObj) ) {
1732 Vec_Int_t * vSupp = Vec_WecEntry( vSupps, Vec_IntEntry(vSuppIds, i) );
1733 if ( Vec_IntSize(vSupp) < 4 )
1735 Vec_Int_t * vThis = Vec_WecPushLevel( vResSupps );
1736 Vec_IntGrow( vThis, Vec_IntSize(vSupp) + 1 );
1737 Vec_IntAppend( vThis, vSupp );
1742 Vec_WecFree( vSupps );
1743 Vec_IntFree( vSuppIds );
1744 Vec_IntFree( vBelow );
1745 Vec_IntFree( vTemp[0] );
1746 Vec_IntFree( vTemp[1] );
1754 if ( Vec_IntTwoCountCommon(vLevel, vOne) > 0 )
1755 Vec_IntClear( vLevel );
1756 Vec_WecRemoveEmpty( vSupps );
1765 Abc_NodeSetTravIdPrevious(pObj);
1774 Abc_NodeSetTravIdPrevious(pObj);
1776 Abc_NodeSetTravIdPrevious(pObj);
1781 if ( Abc_NodeIsTravIdCurrent(pObj) )
1783 if ( k < Vec_IntSize(vLevel) )
1784 Vec_IntClear( vLevel );
1786 Vec_WecRemoveEmpty( vSupps );
1793 if ( Vec_IntTwoCountCommon(vLevel, vOne) == Vec_IntSize(vLevel) )
1794 Vec_IntClear( vLevel );
1795 Vec_WecRemoveEmpty( vSupps );
1800 Abc_NtkIncrementTravId( pNtk );
1801 while ( Vec_WecSize(vSupps) > 0 ) {
1802 int i, Item, iRand =
Abc_Random(0) % Vec_WecSize(vSupps);
1803 Vec_Int_t * vLevel, * vLevel2 = Vec_WecEntry( vSupps, iRand );
1804 Vec_Int_t * vCopy = Vec_IntDup( vLevel2 );
1805 if ( Vec_IntSize(vLevel2) ==
nSuppMax ) {
1806 Vec_PtrPush( vRes, vCopy );
1814 int iBest = iRand, nUnion = Vec_IntSize(vCopy);
1816 if ( i == iRand )
continue;
1817 int nCommon = Vec_IntTwoCountCommon(vLevel, vCopy);
1818 int nUnionCur = Vec_IntSize(vLevel) + Vec_IntSize(vCopy) - nCommon;
1819 if ( nUnionCur <=
nSuppMax && nUnion < nUnionCur ) {
1824 vLevel = Vec_WecEntry( vSupps, iBest );
1826 Vec_IntPushUniqueOrder( vCopy, Item );
1827 Vec_PtrPush( vRes, vCopy );
1838 pNew->
pName = Abc_UtilStrsav(
p->pName );
1839 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
1843 pObj->
pCopy = Abc_NtkCreatePi(pNew);
1845 Abc_NtkCreatePo( pNew );
1861 Vec_Ptr_t * vWins = Vec_PtrAlloc( Vec_PtrSize(vvIns) );
1862 assert( Vec_PtrSize(vvIns) == Vec_PtrSize(vvNodes) );
1863 assert( Vec_PtrSize(vvOuts) == Vec_PtrSize(vvNodes) );
1870 Vec_PtrPush( vWins, pNew );
1886 int LevelCut = LevelMax > 8 ? (
Abc_Random(0) % (LevelMax - 4)) : 0;
1889 Vec_Wec_t * vStore = Vec_WecStart( LevelMax+1 );
1895 Vec_WecFree( vSupps );
1896 Vec_WecFree( vStore );
1916 abctime clkStart = Abc_Clock();
int i;
1917 abctime nTimeToStop = TimeOut ? Abc_Clock() + TimeOut * CLOCKS_PER_SEC : 0;
1921 for ( i = 0; i < 10+Seed; i++ )
1924 printf(
"Running %d iterations of the script \"%s\"", nIters, pScript );
1926 printf(
" using %d concurrent threads.\n", nProcs-1 );
1928 printf(
" without concurrency.\n" );
1931 Vec_Ptr_t * vIns = NULL, * vOuts = NULL, * vNodes = NULL;
1932 for ( i = 0; i < nIters; i++ )
1941 printf(
"Iteration %3d : Using %3d -> %3d partitions. Reducing area from %.2f to %.2f. ",
1944 Abc_PrintTime( 0,
"Time", Abc_Clock() - clk );
1948 Vec_IntFreeP( &vGains );
1949 if ( vIns ) Vec_PtrFreeFunc( vIns, (
void (*)(
void *)) Vec_IntFree );
1950 if ( vOuts ) Vec_PtrFreeFunc( vOuts, (
void (*)(
void *)) Vec_IntFree );
1951 if ( vNodes ) Vec_PtrFreeFunc( vNodes, (
void (*)(
void *)) Vec_IntFree );
1952 if ( nTimeToStop && Abc_Clock() > nTimeToStop )
1954 printf(
"Runtime limit (%d sec) is reached after %d iterations.\n", TimeOut, i );
1960 printf(
"Cumulatively reduced area by %.2f %% after %d iterations. ", 100.0*(aBeg - aEnd)/Abc_MaxFloat(aBeg, (
float)1.0), nIters );
1962 Abc_PrintTime( 0,
"Total time", Abc_Clock() - clkStart );
Abc_Ntk_t * Abc_NtkHopRemoveLoops(Abc_Ntk_t *pNtk, Hop_Man_t *pMan)
int Abc_NtkWriteToFile(char *pFileName, Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkReadFromFile(char *pFileName)
void Abc_NtkSuppCharAdd(unsigned *pBuffer, Vec_Int_t *vOne, int nPis)
int Abc_NtkStochProcess1(void *p)
Vec_Ptr_t * Abc_NtkDupWindows(Abc_Ntk_t *pNtk, Vec_Ptr_t *vvIns, Vec_Ptr_t *vvNodes, Vec_Ptr_t *vvOuts)
unsigned * Abc_NtkSuppCharStart(Vec_Int_t *vOne, int nPis)
void Abc_NtKMarkTfiTfo(Vec_Int_t *vOne, Abc_Ntk_t *pNtk)
void Abc_NtkInsertPartitions_rec(Abc_Ntk_t *pNew, Abc_Obj_t *pObj, Vec_Int_t *vMap, Vec_Ptr_t *vvIns, Vec_Ptr_t *vvOuts, Vec_Ptr_t *vWins)
void Abc_NtKSelectRemove3(Vec_Wec_t *vSupps, Vec_Int_t *vOne)
Abc_Ntk_t * Abc_NtkDupWindow(Abc_Ntk_t *p, Vec_Int_t *vIns, Vec_Int_t *vNodes, Vec_Int_t *vOuts)
Vec_Ptr_t * Abc_NtkComputeSupportsSmart(Abc_Ntk_t *pNtk)
char * Supp_ManFetch(Supp_Man_t *p, int nSize)
Supp_Man_t * Supp_ManStart(int nChunkSize, int nStepSize)
FUNCTION DEFINITIONS ///.
Abc_Ntk_t * Abc_NtkPartStitchChoices(Abc_Ntk_t *pNtk, Vec_Ptr_t *vParts)
Supp_One_t * Supp_ManMergeEntry(Supp_Man_t *pMan, Supp_One_t *p1, Supp_One_t *p2, int nRefs)
int Abc_NtkSuppCharCommon(unsigned *pBuffer, Vec_Int_t *vOne)
Vec_Ptr_t * Abc_NtkPartitionNaive(Abc_Ntk_t *pNtk, int nPartSize)
int Abc_NtkPartitionSmartFindPart(Vec_Ptr_t *vPartSuppsAll, Vec_Ptr_t *vPartsAll, Vec_Ptr_t *vPartSuppsChar, int nSuppSizeLimit, Vec_Int_t *vOne)
void Abc_NtkPartitionPrint(Abc_Ntk_t *pNtk, Vec_Ptr_t *vPartsAll, Vec_Ptr_t *vPartSuppsAll)
struct Supp_One_t_ Supp_One_t
Abc_Ntk_t * Abc_NtkInsertPartitions(Abc_Ntk_t *p, Vec_Ptr_t *vvIns, Vec_Ptr_t *vvNodes, Vec_Ptr_t *vvOuts, Vec_Ptr_t *vWins, int fOverlap, Vec_Int_t *vGains)
void Abc_NtkConvertCos(Abc_Ntk_t *pNtk, Vec_Int_t *vOuts, Vec_Ptr_t *vOutsPtr)
void Abc_NtkFraigPartitionedTime(Abc_Ntk_t *pNtk, void *pParams)
Vec_Int_t * Abc_NtkDeriveWinOuts(Abc_Ntk_t *pNtk, Vec_Int_t *vNodes)
Vec_Ptr_t * Abc_NtkDeriveWinOutsAll(Abc_Ntk_t *pNtk, Vec_Ptr_t *vvNodes)
Vec_Ptr_t * Abc_NtkDfsNatural(Abc_Ntk_t *pNtk)
void Abc_NtkPermuteLevel(Abc_Ntk_t *pNtk, int Level)
Abc_Ntk_t * Abc_NtkFraigPartitioned(Vec_Ptr_t *vStore, void *pParams)
void Abc_ObjDfsMark2_rec(Abc_Obj_t *p)
Vec_Int_t * Supp_ManTransferEntry(Supp_One_t *p)
Vec_Int_t * Abc_NtkStochProcess(Vec_Ptr_t *vWins, char *pScript, int nProcs, int TimeSecs, int fVerbose)
Abc_Obj_t * Abc_NtkPartStitchFindRepr_rec(Vec_Ptr_t *vEquiv, Abc_Obj_t *pObj)
int Abc_NtkWindowCheckTopoError(Abc_Ntk_t *p, Vec_Int_t *vIns, Vec_Int_t *vOuts)
void Abc_NtkPartitionCompact(Vec_Ptr_t *vPartsAll, Vec_Ptr_t *vPartSuppsAll, int nSuppSizeLimit)
Abc_Ntk_t * Abc_NtkStochProcessOne(Abc_Ntk_t *p, char *pScript0, int Rand, int TimeSecs)
Vec_Wec_t * Abc_NtkCollectObjectsWithSuppLimit(Abc_Ntk_t *pNtk, int Level, int nSuppMax)
void Abc_NtkCreateNodeMapped(Abc_Ntk_t *pNew, Abc_Obj_t *pObj)
void Supp_ManRecycle(Supp_Man_t *p, char *pMemory, int nSize)
int Abc_NtkWindowCheckTopoError_rec(Abc_Obj_t *pObj)
void Abc_NtKSelectRemove(Vec_Wec_t *vSupps, Vec_Int_t *vOne)
Vec_Ptr_t * Abc_NtkComputeSupportsNaive(Abc_Ntk_t *pNtk)
Vec_Int_t * Abc_NtkDeriveWinNodes(Abc_Ntk_t *pNtk, Vec_Int_t *vIns, Vec_Wec_t *vStore)
Vec_Ptr_t * Abc_NtkDeriveWinInsAll(Vec_Wec_t *vSupps, int nSuppMax, Abc_Ntk_t *pNtk, int fOverlap)
Vec_Int_t * Abc_NtkCollectObjectsPointedTo(Abc_Ntk_t *pNtk, int Level)
Hop_Man_t * Abc_NtkPartStartHop(Abc_Ntk_t *pNtk)
Vec_Ptr_t * Abc_NtkExtractPartitions(Abc_Ntk_t *pNtk, int Iter, int nSuppMax, Vec_Ptr_t **pvIns, Vec_Ptr_t **pvOuts, Vec_Ptr_t **pvNodes, int fOverlap)
void Abc_ObjDfsMark_rec(Abc_Obj_t *p)
Vec_Ptr_t * Abc_NtkPartitionSmart(Abc_Ntk_t *pNtk, int nSuppSizeLimit, int fVerbose)
void Supp_ManStop(Supp_Man_t *p)
void Abc_NtkStochMap(int nSuppMax, int nIters, int TimeOut, int Seed, int fOverlap, int fVerbose, char *pScript, int nProcs)
Vec_Int_t * Abc_NtkStochSynthesis(Vec_Ptr_t *vWins, char *pScript)
Vec_Ptr_t * Abc_NtkDeriveWinNodesAll(Abc_Ntk_t *pNtk, Vec_Ptr_t *vvIns, Vec_Wec_t *vStore)
void Abc_NtKSelectRemove2(Vec_Wec_t *vSupps, Vec_Int_t *vOne, Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkDupDfs(Abc_Ntk_t *pNtk)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
ABC_DLL void Abc_NtkCleanMarkABC(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
#define Abc_AigForEachAnd(pNtk, pNode, i)
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
ABC_DLL double Abc_NtkGetMappedArea(Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
struct Abc_Aig_t_ Abc_Aig_t
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkLevelR(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkFraig(Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
FUNCTION DEFINITIONS ///.
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkCreateConeArray(Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots, int fUseAllCis)
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkAppendToCone(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots)
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_SWAP(Type, a, b)
#define ABC_ALLOC(type, num)
unsigned Abc_Random(int fReset)
void Util_ProcessThreads(int(*pUserFunc)(void *), void *vData, int nProcs, int TimeOut, int fVerbose)
DECLARATIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
ABC_DLL void Abc_FrameSetBatchMode(int Mode)
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
ABC_DLL int Abc_FrameIsBatchMode()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
struct StochSynData_t_ StochSynData_t
typedefABC_NAMESPACE_IMPL_START struct Supp_Man_t_ Supp_Man_t
DECLARATIONS ///.
Hop_Obj_t * Hop_ObjCreatePo(Hop_Man_t *p, Hop_Obj_t *pDriver)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
int Hop_ManCheck(Hop_Man_t *p)
DECLARATIONS ///.
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Hop_Obj_t * Hop_ObjCreatePi(Hop_Man_t *p)
DECLARATIONS ///.
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
struct Hop_Obj_t_ Hop_Obj_t
struct Mio_LibraryStruct_t_ Mio_Library_t
char * Mio_LibraryReadFileName(Mio_Library_t *pLib)
int Nm_ManFindIdByNameTwoTypes(Nm_Man_t *p, char *pName, int Type1, int Type2)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.