60 Vec_PtrWriteEntry( pNtk->
vAttrs, Attr, NULL );
61 pUserMan = Vec_AttFree( pAttrMan, fFreeMan );
80 Vec_PtrClear( pNtk->
vCis );
81 Vec_PtrClear( pNtk->
vCos );
83 Vec_PtrPush( pNtk->
vCis, pObj );
85 Vec_PtrPush( pNtk->
vCos, pObj );
88 if ( Abc_ObjIsLatch(pObj) )
91 Vec_PtrPush( pNtk->
vCos, pTerm );
93 Vec_PtrPush( pNtk->
vCis, pTerm );
97 if ( !Abc_ObjIsLatch(pObj) )
100 Vec_PtrPush( pNtk->
vCos, pTerm );
102 Vec_PtrPush( pNtk->
vCis, pTerm );
121 assert( Abc_NtkHasSop(pNtk) );
147 word nCubes, nCubePairs = 0;
148 assert( Abc_NtkHasSop(pNtk) );
156 nCubePairs += nCubes * (nCubes - 1) / 2;
158 return (
int)(nCubePairs > (1<<30) ? (1<<30) : nCubePairs);
176 assert( Abc_NtkHasSop(pNtk) );
201 assert( Abc_NtkHasSop(pNtk) );
208 nNodes += 1 + Dec_GraphNodeNum(pFactor);
209 Dec_GraphFree( pFactor );
229 assert( Abc_NtkIsStrash(pNtk) );
232 nNodes += (int)(Abc_ObjFanoutNum(pNode) > 1);
253 assert( Abc_NtkIsBddLogic(pNtk) );
257 if ( Abc_ObjFaninNum(pNode) < 2 )
259 nNodes += pNode->
pData? -1 + Cudd_DagSize( (DdNode *)pNode->
pData ) : 0;
280 assert( Abc_NtkIsAigLogic(pNtk) );
284 if ( Abc_ObjFaninNum(pNode) < 2 )
307 extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
309 DdNode * bCover, * zCover, * bFunc;
310 DdManager * dd = (DdManager *)pNtk->
pManFunc;
312 assert( Abc_NtkIsBddLogic(pNtk) );
316 bFunc = (DdNode *)pNode->
pData;
318 bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover );
321 nClauses += Abc_CountZddCubes( dd, zCover );
322 Cudd_RecursiveDeref( dd, bCover );
323 Cudd_RecursiveDerefZdd( dd, zCover );
325 bCover = Cudd_zddIsop( dd, Cudd_Not(bFunc), Cudd_Not(bFunc), &zCover );
328 nClauses += Abc_CountZddCubes( dd, zCover );
329 Cudd_RecursiveDeref( dd, bCover );
330 Cudd_RecursiveDerefZdd( dd, zCover );
352 assert( Abc_NtkHasMapping(pNtk) );
356 if ( Abc_ObjIsBarBuf(pObj) )
359 if ( pObj->
pData == NULL )
361 printf(
"Node without mapping is encountered.\n" );
388 Counter += pNode->
fExor;
428 Counter += (Abc_ObjFaninNum(pNode) == 1);
448 Counter += (Abc_ObjFaninNum(pNode) > 1);
467 if ( !Abc_NtkIsStrash(pNtk) )
471 Counter += Abc_AigNodeIsChoice( pNode );
489 int i, nFaninsMax = 0;
492 if ( nFaninsMax < Abc_ObjFaninNum(pNode) )
493 nFaninsMax = Abc_ObjFaninNum(pNode);
500 int i, nFaninsMax = 0;
503 if ( nFaninsMax < Abc_ObjFanoutNum(pNode) )
504 nFaninsMax = Abc_ObjFanoutNum(pNode);
525 nFanins += Abc_ObjFaninNum(pNode);
611 if ( Abc_ObjIsNode(pObj) )
612 Counter += (pObj->
pCopy != NULL);
633 vCopies = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
635 Vec_PtrWriteEntry( vCopies, i, pObj->
pCopy );
796 if ( pThis == pFanin )
817 if ( Abc_ObjIsCo(pFanout) )
838 if ( !Abc_ObjIsCo(pFanout) )
863 if ( !Abc_ObjIsCo(pFanout) )
865 if ( Abc_ObjFaninC0(pFanout) )
867 if ( pFanoutCo == NULL )
869 assert( Abc_ObjFaninNum(pFanout) == 1 );
870 assert( Abc_ObjFanin0(pFanout) == pNode );
896 if ( fDuplicate && !Abc_ObjIsCi(pDriver) )
901 if ( Abc_ObjFaninC0(pNodeCo) )
905 Abc_ObjXorFaninC( pNodeCo, 0 );
911 if ( Abc_ObjFaninC0(pNodeCo) )
914 Abc_ObjXorFaninC( pNodeCo, 0 );
921 assert( Abc_ObjFanoutNum(pDriverNew) == 1 );
924 if ( Abc_ObjFanoutNum(pDriver) == 0 )
946 assert( Abc_NtkIsLogic(pNtk) );
947 Abc_NtkIncrementTravId( pNtk );
951 pDriver = Abc_ObjFanin0(pNode);
952 if ( Abc_ObjFaninC0(pNode) )
958 if ( !Abc_NodeIsTravIdCurrent(pDriver) )
961 Abc_NodeSetTravIdCurrent(pDriver);
990 int i, nDupGates = 0;
991 assert( Abc_NtkIsLogic(pNtk) );
992 Abc_NtkIncrementTravId( pNtk );
996 pDriver = Abc_ObjFanin0(pNode);
997 if ( Abc_ObjFaninC0(pNode) )
1011 if ( !Abc_NodeIsTravIdCurrent(pDriver) )
1014 Abc_NodeSetTravIdCurrent(pDriver);
1043 int nObjs = Abc_NtkObjNumMax(pNtk);
1044 unsigned * pType =
ABC_CALLOC(
unsigned, nObjs );
1046 int i, Counts[4] = {0}, Consts[2] = {0}, Inputs[2] = {0};
1050 if ( Abc_ObjFaninId0(pNode) == 0 )
1051 Consts[Abc_ObjFaninC0(pNode)]++;
1052 if ( Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
1053 Inputs[Abc_ObjFaninC0(pNode)]++;
1054 pType[Abc_ObjFaninId0(pNode)] |= (1 << Abc_ObjFaninC0(pNode));
1057 for ( i = 0; i < nObjs; i++ )
1059 for ( i = 0; i < 4; i++ )
1060 printf(
"%d = %d ", i, Counts[i] );
1061 for ( i = 0; i < 2; i++ )
1062 printf(
"c%d = %d ", i, Consts[i] );
1063 for ( i = 0; i < 2; i++ )
1064 printf(
"i%d = %d ", i, Inputs[i] );
1082 int fAddBuffers = 1;
1084 Abc_Obj_t * pNode, * pDriver, * pDriverNew, * pFanin;
1085 int i, k, LevelMax,
nTotal = 0;
1086 assert( Abc_NtkIsLogic(pNtk) );
1093 pDriver = Abc_ObjFanin0(pNode);
1097 if ( Abc_ObjFaninC0(pNode) )
1098 Abc_ObjXorFaninC( pNode, 0 );
1100 if ( Abc_ObjFanoutNum(pDriver) == 0 )
1105 vDrivers = Vec_PtrAlloc( 100 );
1106 Abc_NtkIncrementTravId( pNtk );
1109 if ( !Abc_ObjFaninC0(pNode) )
1111 pDriver = Abc_ObjFanin0(pNode);
1112 if ( Abc_NodeIsTravIdCurrent(pDriver) )
1114 Abc_NodeSetTravIdCurrent(pDriver);
1115 Vec_PtrPush( vDrivers, pDriver );
1118 if ( Vec_PtrSize(vDrivers) > 0 )
1120 int nDupGates = 0, nDupInvs = 0, nDupChange = 0;
1121 Vec_Ptr_t * vFanouts = Vec_PtrAlloc( 100 );
1124 int fHasDir = 0, fHasInv = 0, fHasOther = 0;
1127 if ( !Abc_ObjIsCo(pNode) )
1129 assert( !Abc_ObjFaninC0(pNode) );
1133 if ( Abc_ObjFaninC0(pNode) )
1139 if ( Abc_ObjIsCi(pDriver) || fHasDir || (fHasOther && Abc_NtkHasMapping(pNtk)) )
1142 if ( fDuplicate && Abc_ObjIsNode(pDriver) && Abc_ObjLevel(pDriver) == LevelMax )
1156 Vec_PtrClear( vFanouts );
1158 if ( Abc_ObjIsCo(pNode) && Abc_ObjFaninC0(pNode) )
1159 Vec_PtrPush( vFanouts, pNode );
1160 assert( Vec_PtrSize(vFanouts) > 0 );
1163 Abc_ObjXorFaninC( pNode, 0 );
1165 assert( Abc_ObjIsCi(pDriver) || Abc_ObjFanoutNum(pDriver) > 0 );
1171 assert( Abc_ObjIsNode(pDriver) );
1175 if ( Abc_ObjIsCo(pNode) )
1177 assert( Abc_ObjFaninC0(pNode) );
1178 Abc_ObjXorFaninC( pNode, 0 );
1180 else if ( Abc_ObjIsNode(pNode) )
1187 Vec_PtrFree( vFanouts );
1190 nTotal += nDupInvs + nDupGates;
1192 Vec_PtrFree( vDrivers );
1195 vCoTerms = Vec_PtrAlloc( 100 );
1196 Abc_NtkIncrementTravId( pNtk );
1206 pDriver = Abc_ObjFanin0(pNode);
1209 Vec_PtrPush( vCoTerms, pNode );
1213 if ( !Abc_NodeIsTravIdCurrent(pDriver) )
1216 Abc_NodeSetTravIdCurrent(pDriver);
1222 Vec_PtrPush( vCoTerms, pNode );
1227 if ( Vec_PtrSize(vCoTerms) > 0 )
1229 int nDupBufs = 0, nDupGates = 0;
1232 pDriver = Abc_ObjFanin0(pNode);
1234 if ( fDuplicate && Abc_ObjIsNode(pDriver) && (Abc_NtkHasMapping(pNtk) || Abc_ObjLevel(pDriver) == LevelMax) )
1249 assert( Abc_ObjIsCi(pDriver) || Abc_ObjFanoutNum(pDriver) > 0 );
1252 nTotal += nDupBufs + nDupGates;
1254 Vec_PtrFree( vCoTerms );
1273 if ( Vec_PtrPushUnique(
p, pNode) )
1276 for ( i =
p->nSize-1; i > 0; i-- )
1280 if ( Abc_ObjRegular(pNode1)->Level <= Abc_ObjRegular(pNode2)->Level )
1282 p->pArray[i ] = pNode2;
1283 p->pArray[i-1] = pNode1;
1304 assert( !Abc_ObjIsComplement(pNode) );
1306 if ( !Abc_AigNodeIsAnd(pNode) )
1309 if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
1312 pNode0 = Abc_ObjFanin0(pNode);
1313 pNode1 = Abc_ObjFanin1(pNode);
1315 if ( Abc_ObjFaninNum(pNode0) != 2 || Abc_ObjFaninNum(pNode1) != 2 )
1318 assert( Abc_ObjFaninId0(pNode0) != Abc_ObjFaninId1(pNode1) ||
1319 Abc_ObjFaninId0(pNode1) != Abc_ObjFaninId1(pNode0) );
1321 if ( Abc_ObjFaninId0(pNode0) != Abc_ObjFaninId0(pNode1) ||
1322 Abc_ObjFaninId1(pNode0) != Abc_ObjFaninId1(pNode1) )
1325 if ( Abc_ObjFaninC0(pNode0) == Abc_ObjFaninC0(pNode1) ||
1326 Abc_ObjFaninC1(pNode0) == Abc_ObjFaninC1(pNode1) )
1346 assert( !Abc_ObjIsComplement(pNode) );
1348 if ( !Abc_AigNodeIsAnd(pNode) )
1351 if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
1354 pNode0 = Abc_ObjFanin0(pNode);
1355 pNode1 = Abc_ObjFanin1(pNode);
1357 if ( !Abc_AigNodeIsAnd(pNode0) || !Abc_AigNodeIsAnd(pNode1) )
1360 return (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
1361 (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1))) ||
1362 (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
1363 (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)));
1402 assert( !Abc_ObjIsComplement(pNode) );
1404 if ( Abc_ObjFanoutNum(pNode) != 2 )
1407 pNode0 = Abc_ObjFanout( pNode, 0 );
1408 pNode1 = Abc_ObjFanout( pNode, 1 );
1410 if ( Abc_ObjFanoutNum(pNode0) != 1 || Abc_ObjFanoutNum(pNode1) != 1 )
1413 return Abc_ObjFanout0(pNode0) == Abc_ObjFanout0(pNode1);
1433 assert( !Abc_ObjIsComplement(pNode) );
1436 pNode0 = Abc_ObjFanin0(pNode);
1437 pNode1 = Abc_ObjFanin1(pNode);
1440 if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
1443 if ( Abc_ObjFaninC0(pNode0) )
1445 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));
1446 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));
1447 return Abc_ObjChild0(pNode1);
1451 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));
1452 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));
1453 return Abc_ObjChild0(pNode0);
1457 else if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
1460 if ( Abc_ObjFaninC0(pNode0) )
1462 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));
1463 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));
1464 return Abc_ObjChild1(pNode1);
1468 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));
1469 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));
1470 return Abc_ObjChild0(pNode0);
1474 else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
1477 if ( Abc_ObjFaninC1(pNode0) )
1479 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));
1480 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));
1481 return Abc_ObjChild0(pNode1);
1485 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));
1486 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));
1487 return Abc_ObjChild1(pNode0);
1491 else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
1494 if ( Abc_ObjFaninC1(pNode0) )
1496 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));
1497 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));
1498 return Abc_ObjChild1(pNode1);
1502 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));
1503 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));
1504 return Abc_ObjChild1(pNode0);
1523 Abc_Ntk_t ** ppNtk1,
Abc_Ntk_t ** ppNtk2,
int * pfDelete1,
int * pfDelete2,
int fCheck )
1535 fprintf( pErr,
"Empty current network.\n" );
1538 if ( pNtk->
pSpec == NULL )
1540 fprintf( pErr,
"The external spec is not given.\n" );
1543 pFile = fopen( pNtk->
pSpec,
"r" );
1544 if ( pFile == NULL )
1546 fprintf( pErr,
"Cannot open the external spec file \"%s\".\n", pNtk->
pSpec );
1553 if ( pNtk2 == NULL )
1562 fprintf( pErr,
"Empty current network.\n" );
1567 if ( pNtk2 == NULL )
1575 if ( pNtk1 == NULL )
1578 if ( pNtk2 == NULL )
1588 fprintf( pErr,
"Wrong number of arguments.\n" );
1593 if ( !Abc_NtkIsStrash(pNtk1) )
1601 if ( !Abc_NtkIsStrash(pNtk2) )
1631 Vec_PtrClear(vNodes);
1633 Vec_PtrPush( vNodes, pFanin );
1651 Vec_PtrClear(vNodes);
1653 Vec_PtrPush( vNodes, pFanout );
1672 vLatches = Vec_PtrAlloc( 10 );
1674 Vec_PtrPush( vLatches, pObj );
1691 int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
1696 Diff = Abc_ObjRegular(*pp1)->Id - Abc_ObjRegular(*pp2)->Id;
1717 int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
1722 Diff = Abc_ObjRegular(*pp1)->Id - Abc_ObjRegular(*pp2)->Id;
1746 vFanNums = Vec_IntAlloc( 0 );
1747 Vec_IntFill( vFanNums, Abc_NtkObjNumMax(pNtk), -1 );
1749 if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
1750 Vec_IntWriteEntry( vFanNums, i, Abc_ObjFanoutNum(pObj) );
1770 vNodes = Vec_PtrAlloc( 100 );
1772 Vec_PtrPush( vNodes, pNode );
1792 vCiIds = Vec_IntAlloc( Abc_NtkCiNum(pNtk) );
1794 Vec_IntPush( vCiIds, pObj->
Id );
1815 assert( Abc_NtkIsStrash(pNtk) );
1818 vObjsNew = Vec_PtrAlloc( pNtk->
nObjs );
1822 Vec_PtrPush( vObjsNew, pConst1 );
1826 pNode->
Id = Vec_PtrSize( vObjsNew );
1827 Vec_PtrPush( vObjsNew, pNode );
1832 pNode->
Id = Vec_PtrSize( vObjsNew );
1833 Vec_PtrPush( vObjsNew, pNode );
1838 pNode->
Id = Vec_PtrSize( vObjsNew );
1839 Vec_PtrPush( vObjsNew, pNode );
1842 pTemp->
Id = Vec_PtrSize( vObjsNew );
1843 Vec_PtrPush( vObjsNew, pTemp );
1847 pTemp->
Id = Vec_PtrSize( vObjsNew );
1848 Vec_PtrPush( vObjsNew, pTemp );
1855 if ( pNode == pConst1 )
1857 pNode->
Id = Vec_PtrSize( vObjsNew );
1858 Vec_PtrPush( vObjsNew, pNode );
1860 Vec_PtrFree( vNodes );
1873 Vec_PtrFree( pNtk->
vObjs );
1874 pNtk->
vObjs = vObjsNew;
1967 if ( !Abc_ObjIsNet(pObj) )
1983static inline int Abc_ObjCrossCutInc(
Abc_Obj_t * pObj )
1986 int Value = (int)(ABC_PTRINT_T)pObj->
pCopy;
1988 return (
int)(ABC_PTRINT_T)pObj->
pCopy == Abc_ObjFanoutNum(pObj);
2007 if ( Abc_ObjIsCi(pObj) )
2010 if ( Abc_NodeIsTravIdCurrent( pObj ) )
2011 return Abc_ObjCrossCutInc( pObj );
2012 Abc_NodeSetTravIdCurrent( pObj );
2014 if ( !Abc_ObjIsCi(pObj) )
2020 pFanin = Abc_ObjFanin( pObj, Abc_ObjFaninNum(pObj) - 1 - i );
2032 if ( *pnCutSizeMax < *pnCutSize )
2033 *pnCutSizeMax = *pnCutSize;
2034 (*pnCutSize) -= nDecrem;
2035 return Abc_ObjCrossCutInc( pObj );
2052 int nCutSize = 0, nCutSizeMax = 0;
2055 Abc_NtkIncrementTravId( pNtk );
2062 printf(
"Max cross cut size = %6d. Ratio = %6.2f %%\n", nCutSizeMax, 100.0 * nCutSizeMax/Abc_NtkObjNum(pNtk) );
2082 pFile = fopen(
"4varfs.txt",
"w" );
2083 for ( i = 1; i < (1<<16)-1; i++ )
2085 fprintf( pFile,
"read_truth " );
2087 fprintf( pFile,
"; clp; st; w 1.blif; map; cec 1.blif\n" );
2108 if ( pSupps[*pNum1] > pSupps[*pNum2] )
2110 if ( pSupps[*pNum1] < pSupps[*pNum2] )
2128 Vec_Ptr_t * vSupp, * vNodes, * vReverse;
2130 int Iter, i, k, Counter, CounterCos, CounterCosNew;
2134 pPerms =
ABC_ALLOC(
int, Abc_NtkCoNum(pNtk) );
2135 pSupps =
ABC_ALLOC(
int, Abc_NtkCoNum(pNtk) );
2140 pSupps[i] = Vec_PtrSize(vSupp);
2141 Vec_PtrFree( vSupp );
2143 qsort( (
void *)pPerms, (
size_t)Abc_NtkCoNum(pNtk),
sizeof(
int), (
int (*)(
const void *,
const void *))
Abc_NtkCompareConesCompare );
2149 pObj = Abc_NtkCo( pNtk, pPerms[i] );
2159 for ( k = 1; k < Vec_PtrSize(vReverse) - 1; k++ )
2162 CounterCos = CounterCosNew = 0;
2165 assert( Abc_ObjIsCo(pTemp) );
2167 if ( pTemp->
fMarkA == 0 )
2172 printf(
"%4d CO %5d : Supp = %5d. Lev = %3d. Cone = %5d. Rev = %5d. COs = %3d (%3d).\n",
2173 Iter, pPerms[i], Vec_PtrSize(vSupp), Abc_ObjLevel(Abc_ObjFanin0(pObj)), Vec_PtrSize(vNodes), Counter, CounterCos, CounterCosNew );
2175 if ( Vec_PtrSize(vSupp) < 10 )
2178 Vec_PtrFree( vSupp );
2179 Vec_PtrFree( vNodes );
2180 Vec_PtrFree( vReverse );
2185 Vec_PtrFree( vSupp );
2186 Vec_PtrFree( vNodes );
2187 Vec_PtrFree( vReverse );
2213 assert( Abc_NtkIsStrash(pNtk) );
2216 if ( !Abc_AigNodeIsChoice(pObj) )
2220 nNodesOld = Vec_PtrSize(vSupp);
2221 Vec_PtrFree( vSupp );
2226 if ( nNodesOld != Vec_PtrSize(vSupp) )
2227 printf(
"Choice orig = %3d Choice new = %3d\n", nNodesOld, Vec_PtrSize(vSupp) );
2228 Vec_PtrFree( vSupp );
2248 if ( Abc_NtkConstrNum(pNtk) == 0 )
2252 if ( i >= Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk) )
2253 Abc_ObjXorFaninC( pObj, 0 );
2273 printf(
"%c=%d ",
'a'+i, pObj->
Level );
2294 if ( pFanout != pNode && pFanout->
Level >= pNode->
Level )
2314 if ( pFanout != pNode && pFanout->
Level > pNode->
Level )
2333 assert( Level - 1 >= Abc_ObjLevel(pFanin) );
2334 pBuffer = (
Abc_Obj_t *)Vec_PtrEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level );
2335 if ( pBuffer == NULL )
2337 if ( Level - 1 == Abc_ObjLevel(pFanin) )
2342 Vec_PtrWriteEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level, pBuffer );
2353 pObj->
Level = nLevelMax + 1;
2357 assert( nLevelMax < (1<<18) );
2360 pObj->
Level = (1<<18);
2369 for ( Iter = 0; Iter < nImprove; Iter++ )
2371 int Counter = 0, TotalGain = 0;
2382 if ( k < Abc_ObjFaninNum(pObj) )
2386 if ( CountGain >= 0 )
2390 TotalGain += CountGain;
2394 printf(
"Shifted %5d nodes down with total gain %5d.\n", Counter, TotalGain );
2398 Vec_PtrFree( vNodes );
2404 for ( Iter = 0; Iter < nImprove; Iter++ )
2406 int Counter = 0, TotalGain = 0;
2417 if ( k < Abc_ObjFanoutNum(pObj) )
2421 if ( CountGain >= 0 )
2425 TotalGain += CountGain;
2429 printf(
"Shifted %5d nodes up with total gain %5d.\n", Counter, TotalGain );
2433 Vec_PtrFree( vNodes );
2435 vBuffs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) * (nLevelMax + 1) );
2438 if ( i == Vec_PtrSize(vBuffs) / (nLevelMax + 1) )
2440 if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsCo(pObj) )
2444 assert( Abc_ObjLevel(pObj) - 1 >= Abc_ObjLevel(pFanin) );
2445 if ( Abc_ObjLevel(pObj) - 1 == Abc_ObjLevel(pFanin) )
2451 Vec_PtrFree( vBuffs );
2465 if ( Abc_NtkNodeNum(pNtkD) < Abc_NtkNodeNum(pNtkR) )
2490 static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
2493 float DelayMax, Delays[15] = {0};
2494 int nFaninMax, i, k;
2497 assert( nFaninMax > 1 && nFaninMax < 15 );
2498 for ( i = 0; i <= nFaninMax; i++ )
2499 Delays[i] = GateDelays[i]/GateDelays[nFaninMax];
2510 pObj->
dTemp += Delays[Abc_ObjFaninNum(pObj)];
2512 Vec_PtrFree( vNodes );
2516 DelayMax = Abc_MaxFloat( DelayMax, Abc_ObjFanin0(pObj)->dTemp );
2534 Abc_Obj_t * pNodeOr, * pNodeNew, * pFanin;
2535 char * pCube, * pSop = (
char *)pNodeOld->
pData;
2536 int v, Value, nVars = Abc_ObjFaninNum(pNodeOld), nFanins;
2547 pNodeOr = Abc_NtkCreateNode( pNtkNew );
2557 if ( Value ==
'0' || Value ==
'1' )
2567 pNodeNew = Abc_NtkCreateNode( pNtkNew );
2572 if ( Value !=
'0' && Value !=
'1' )
2586 pNodeOld->
pCopy = pNodeOr;
2594 assert( Abc_NtkIsSopLogic(pNtk) );
2601 Vec_PtrFree( vNodes );
2606 printf(
"Abc_NtkSopToCubes: The network check has failed.\n" );
2624static inline int Abc_NtkTopoHasBeg(
Abc_Obj_t *
p ) {
return Vec_IntEntry(
p->pNtk->vTopo, 2*Abc_ObjId(
p) ); }
2625static inline int Abc_NtkTopoHasEnd(
Abc_Obj_t *
p ) {
return Vec_IntEntry(
p->pNtk->vTopo, 2*Abc_ObjId(
p)+1); }
2627static inline void Abc_NtkTopoSetBeg(
Abc_Obj_t *
p ) { Vec_IntWriteEntry(
p->pNtk->vTopo, 2*Abc_ObjId(
p) , Vec_IntSize(
p->pNtk->vTopo)); }
2628static inline void Abc_NtkTopoSetEnd(
Abc_Obj_t *
p ) { Vec_IntWriteEntry(
p->pNtk->vTopo, 2*Abc_ObjId(
p)+1, Vec_IntSize(
p->pNtk->vTopo)); }
2634 if ( Abc_NodeIsTravIdCurrent( pObj ) )
2636 Abc_NodeSetTravIdCurrent( pObj );
2637 if ( Abc_ObjIsPo(pObj) )
2639 Vec_IntPush( pObj->
pNtk->
vTopo, Abc_ObjId(pObj) );
2642 assert( Abc_ObjIsNode(pObj) );
2645 Abc_NtkTopoSetBeg( pObj );
2648 if ( !Abc_NtkTopoHasBeg(pNext) )
2650 assert( !Abc_NtkTopoHasEnd(pNext) );
2656 if ( pNext != pPivot )
2660 Abc_NtkTopoSetEnd( pObj );
2662 Vec_IntPush( pObj->
pNtk->
vTopo, Abc_ObjId(pObj) );
2669 p->vTopo = Vec_IntAlloc( 10 * Abc_NtkObjNumMax(
p) );
2670 Vec_IntFill(
p->vTopo, 2 * Abc_NtkObjNumMax(
p), 0 );
2673 if ( Abc_NtkTopoHasBeg(pObj) )
2675 Abc_NtkIncrementTravId(
p );
2678 printf(
"Nodes = %d. Size = %d. Ratio = %f.\n",
2679 Abc_NtkNodeNum(
p), Vec_IntSize(
p->vTopo), 1.0*Vec_IntSize(
p->vTopo)/Abc_NtkNodeNum(
p) );
2686 if ( Abc_NodeIsTravIdCurrent( pObj ) )
2688 Abc_NodeSetTravIdCurrent( pObj );
2691 Vec_IntPush( vVisited, Abc_ObjId(pObj) );
2712 Vec_IntFreeP( &
p->vTopo );
2713 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
2716 vVisited = Vec_IntAlloc( 1000 );
2719 Vec_IntClear( vVisited );
2720 Abc_NtkIncrementTravId(
p );
2723 Vec_IntFree( vVisited );
2724 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
2767 for ( i = 0; i < nInputs; i++ )
2768 Abc_NtkCreatePi( pNtkSop );
2769 for ( i = 0; i < nOutputs; i++ )
2770 Abc_NtkCreatePo( pNtkSop );
2774 for ( i = 0; i < nOutputs; i++ )
2776 pNode = Abc_NtkCreateNode( pNtkSop );
2785 fprintf( stdout,
"Abc_NtkFromPla(): Network check has failed.\n" );
2797 char * pPlas[2] = {
"1000 1\n",
"0110 1\n0011 1\n" };
2818 Abc_Obj_t * pObj, * pFanin, * pObjNew, * pObjNewRoot;
2819 int i, k, j, nCubes, nCubesThis, nSplits;
2820 char * pSopStr, * pSopStr2, * pTempSop, Symb;
2823 assert( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsNetlist(pNtk) );
2830 assert( Abc_ObjIsNode(pObj) );
2833 if ( nCubes <= nCubesMax )
2839 nSplits = (nCubes / nCubesMax) + (
int)(nCubes % nCubesMax > 0);
2840 pSopStr = (
char *)pObjNewRoot->
pData;
2847 pTempSop = (
char *)pObj->
pData; pObj->
pData = (
char *)
"?";
2848 for ( j = 0; j < nSplits; j++ )
2857 nCubesThis = (j < nCubes / nCubesMax) ? nCubesMax : nCubes % nCubesMax;
2858 pSopStr2 = pSopStr + (Abc_ObjFaninNum(pObj) + 3) * nCubesThis;
2859 Symb = *pSopStr2; *pSopStr2 = 0;
2865 pObj->
pData = pTempSop;
2866 pObj->
pCopy = pObjNewRoot;
2868 Vec_PtrFree( vNodes );
2872 fprintf( stdout,
"Abc_NtkDup(): Network check has failed.\n" );
2873 pNtk->
pCopy = pNtkNew;
2891 int i, k, Counter = 0;
2892 Abc_NtkIncrementTravId( pNtk );
2894 Abc_NodeSetTravIdCurrent(pObj);
2899 if ( !Abc_NodeIsTravIdCurrent(pFanin) )
2901 if ( k != Abc_ObjFaninNum(pObj) )
2903 if ( Counter++ == 0 )
2904 printf(
"Node %d is out of topo order.\n", Abc_ObjId(pObj) );
2906 Abc_NodeSetTravIdCurrent(pObj);
2909 printf(
"Topological order does not hold for %d internal nodes.\n", Counter );
2910 return (
int)(Counter == 0);
2929 assert( Vec_IntSize(pNtk->
vPhases) == Abc_NtkObjNumMax(pNtk) );
2931 pNtkNew->
vPhases = Vec_IntStart( Abc_NtkObjNumMax(pNtkNew) );
2952 Abc_Obj_t * pObj, * pFanin, * pObjNew, * pOutputNew;
2953 Vec_Ptr_t * vFanins = Vec_PtrAlloc( 100 );
2954 int i, k, Id, Value;
2963 if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
2979 if ( pObj->
pCopy == NULL && !Abc_ObjIsPo(pObj) )
2983 if ( !Abc_ObjIsPo(pObj) && !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
2991 pObjNew = Abc_NtkObj( pNtk, Id )->
pCopy;
2994 if ( pOutputNew == NULL )
2995 pOutputNew = pObjNew;
2998 Vec_PtrFillTwo( vFanins, 2, pOutputNew, pObjNew );
3002 Vec_PtrFree( vFanins );
3007 assert( Abc_NtkPoNum(pNtkNew) == 1 );
3008 assert( Abc_NtkCiNum(pNtkNew) == Abc_NtkCiNum(pNtk) );
3009 assert( Abc_NtkLatchNum(pNtkNew) == Abc_NtkLatchNum(pNtk) );
3031 Abc_Ntk_t * pMonitor, * pStrashed, * pResult;
3033 int fLatchConst = 1;
3034 int fLatchEqual = 1;
3036 int fUseMvSweep = 0;
3037 int nFramesSymb = 1;
3038 int nFramesSatur = 512;
3040 int fVeryVerbose = 0;
3043 assert( Abc_NtkLatchNum(
p) > 0 );
3044 assert( Vec_IntSize(vNodeIds) > 0 );
3045 assert( Vec_IntSize(vNodeIds) == Vec_IntSize(vNodeValues) );
3052 pResult =
Abc_NtkDarLatchSweep( pStrashed, fLatchConst, fLatchEqual, fSaveNames, fUseMvSweep, nFramesSymb, nFramesSatur, fVerbose, fVeryVerbose );
3071 Vec_Int_t * vNodeIds = Vec_IntAlloc( 100 );
3072 Vec_Int_t * vNodeValues = Vec_IntAlloc( 100 );
3075 Vec_IntPush( vNodeIds, 90 );
3076 Vec_IntPush( vNodeIds, 80 );
3077 Vec_IntPush( vNodeIds, 100 );
3079 Vec_IntPush( vNodeValues, 1 );
3080 Vec_IntPush( vNodeValues, 0 );
3081 Vec_IntPush( vNodeValues, 1 );
3085 Vec_IntFree( vNodeIds );
3086 Vec_IntFree( vNodeValues );
3124 int i, k, iNode = 0;
3131 vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) );
3133 pObj->
iTemp = iNode++;
3136 Vec_Int_t * vNode = Vec_WecEntry(vRes, iNode);
3138 Vec_IntPush( vNode, iNode );
3140 Vec_IntPush( vNode, pFanin->
iTemp );
3141 pObj->
iTemp = iNode++;
3144 Vec_IntPushTwo( Vec_WecEntry(vRes, iNode++),
ABC_OPER_BIT_BUF, Abc_ObjFanin0(pObj)->iTemp );
3145 assert( Vec_WecSize(vRes) == iNode );
3154 int i, k, iNode = 0;
3160 vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) );
3162 pObj->
iTemp = iNode++;
3165 Vec_Int_t * vNode = Vec_WecEntry(vRes, iNode);
3167 Vec_IntPush( vNode, iNode );
3169 Vec_IntPush( vNode, pFanin->
iTemp );
3170 pObj->
iTemp = iNode++;
3173 Vec_IntPushTwo( Vec_WecEntry(vRes, iNode++),
ABC_OPER_BIT_BUF, Abc_ObjFanin0(pObj)->iTemp );
3174 assert( Vec_WecSize(vRes) == iNode );
3181 Vec_PtrPush( vGias,
p );
3183 Vec_PtrFree( vGias );
3204 if ( Abc_NodeIsTravIdCurrent(pNode) || Abc_ObjFaninNum(pNode) == 0 || Abc_ObjIsCi(pNode) )
3205 return pNode->
iTemp;
3206 assert( Abc_ObjIsNode( pNode ) );
3207 Abc_NodeSetTravIdCurrent( pNode );
3210 iLit0 = Abc_LitNotCond( iLit0, Abc_ObjFaninC0(pNode) );
3211 iLit1 = Abc_LitNotCond( iLit1, Abc_ObjFaninC1(pNode) );
3219 assert( Abc_NtkIsStrash(pNtk) );
3230 pNode->
iTemp = Gia_ManAppendCi(pNew);
3232 Abc_NtkIncrementTravId( pNtk );
3236 iLit = Abc_LitNotCond( iLit, Abc_ObjFaninC0(pNode) );
3237 Gia_ManAppendCo( pNew, iLit );
3251 pNew->
pName = Abc_UtilStrsav(
"top" );
3253 assert( pSop[1] ==
'0' || pSop[1] ==
'1' );
3254 Gia_ManAppendCo( pNew, pSop[1] ==
'1' );
3257 vSops = Vec_PtrAlloc( 1 );
3258 Vec_PtrPush( vSops, pSop );
3260 Vec_PtrFree( vSops );
3283static int s_ArraySize = 145;
3284static int s_ArrayData[290] = {
3286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3287 10, 6, 14, 12, 10, 2, 22, 20, 2, 24, 16, 4, 28, 18, 16, 10, 8, 4, 34, 32, 30, 36, 38, 26, 16, 6, 36, 20, 44, 42, 46, 40, 42, 44, 14, 6, 52, 34, 32, 54, 56, 50, 58, 48, 32, 24, 20, 2, 12, 6, 66, 34, 68, 64, 62, 70, 28, 68, 74, 72, 76, 58, 70, 62, 80, 78, 68, 28, 84, 74, 4, 2, 88, 20, 64, 90, 92, 86, 66, 32, 18, 96, 98, 56, 100, 94, 52, 36, 104, 38, 90, 42, 36, 2, 108, 110, 112, 106, 114, 100, 102, 116, 118, 82, 116, 60, 120, 122, 124, 60, 118, 60, 102, 82, 128, 130, 132, 82, 134, 126, 82, 116, 122, 138, 122, 118, 142, 140, 60, 102, 130, 146, 130, 118, 150, 148, 152, 144, 154, 136, 18, 156, 144, 126, 68, 160, 32, 136, 164, 162, 166, 158, 28, 160, 70, 126, 90, 144, 174, 172, 176, 170, 152, 134, 36, 180, 2, 134, 184, 182, 186, 178, 188, 168, 64, 144, 164, 158, 194, 192, 96, 156, 44, 154, 200, 170, 202, 198, 204, 176, 206, 196, 204, 168, 62, 126, 212, 186, 24, 134, 108, 152, 218, 192, 220, 216, 222, 214, 224, 210, 220, 194, 110, 152, 30, 180, 232, 230, 184, 172, 236, 234, 238, 228, 234, 182, 242, 220, 244, 168, 42, 154, 248, 202, 54, 136, 252, 164, 254, 214, 256, 250, 218, 194, 252, 198, 262, 242, 264, 260, 232, 220, 268, 262, 270, 168,
3288 191, 191, 209, 209, 226, 226, 240, 240, 246, 246, 259, 259, 267, 267, 272, 272,
3293 for ( i = 1; i < s_ArraySize; i++ )
3294 if ( s_ArrayData[2*i] || s_ArrayData[2*i+1] )
3296 for ( ; i < s_ArraySize; i++ )
3297 if ( s_ArrayData[2*i] < 2 && s_ArrayData[2*i+1] < 2 )
3303 Vec_Ptr_t * vNodes = Vec_PtrAlloc( s_ArraySize );
int i, nPos = 0;
3307 Vec_PtrPush( vNodes, pObjNew );
3308 for ( i = 1; i < s_ArraySize; i++ )
3309 if ( !s_ArrayData[2*i] && !s_ArrayData[2*i+1] )
3310 Vec_PtrPush( vNodes, Abc_NtkCreatePi(pNtkNew) );
3313 for ( ; i < s_ArraySize; i++ )
3316 if ( s_ArrayData[2*i] > s_ArrayData[2*i+1] )
3318 else if ( s_ArrayData[2*i] < s_ArrayData[2*i+1] )
3322 pObjNew = Abc_NtkCreateNode( pNtkNew );
3327 pObjNew->
pData = pSop;
3328 Vec_PtrPush( vNodes, pObjNew );
3330 for ( ; i < s_ArraySize; i++ )
3333 assert( s_ArrayData[2*i] == s_ArrayData[2*i+1] );
3334 pObjNew = Abc_NtkCreateNode( pNtkNew );
3336 if ( Abc_LitIsCompl(s_ArrayData[2*i]) )
3340 pObjNew->
pData = pSop;
3341 Vec_PtrPush( vNodes, pObjNew );
3344 for ( i = 0; i < nPos; i++ )
3346 Vec_PtrFree( vNodes );
3352 Abc_Print( 1,
"Abc_NtkFromArray(): Network check has failed.\n" );
3374 printf(
"%4d", Entry );
3380 for ( k = 0; pGPC[k] !=
':' && i+k < Vec_IntSize(vRanks); k++ ) {
3381 if ( Abc_TtReadHexDigit(pGPC[k]) == 0 )
3383 Cur = Vec_IntEntry(vRanks, i+k) / Abc_TtReadHexDigit(pGPC[k]);
3391 int k;
char * pOut =
strstr(pGPC,
":");
3392 assert( pOut && pOut[0] ==
':' );
3394 Vec_IntAddToEntry( vLevel, i, nGpcs );
3395 for ( k = 0; pGPC[k] !=
':'; k++ )
3396 Vec_IntAddToEntry( vRank, i+k, -nGpcs * Abc_TtReadHexDigit(pGPC[k]) );
3397 for ( k = 0; pOut[k] !=
':'; k++ )
3398 Vec_IntAddToEntry( vRank2, i+k, nGpcs * Abc_TtReadHexDigit(pOut[k]) );
3402 char * pOut =
strstr(pGPC,
":");
3403 char * pLut =
strstr(pOut+1,
":");
3404 return atoi(pLut+1);
3411 Counter += Vec_IntSum(vVec);
3416 char * pOut, * pLut, ** pRes =
ABC_ALLOC(
char *, nGPCs );
3418 for ( i = 0; i < nGPCs; i++ ) {
3419 pRes[i] = Abc_UtilStrsav(pGPCs[i]);
3420 pOut =
strstr(pRes[i],
":");
3421 nLength = (int)(pOut-pRes[i]);
3422 for ( k = 0; k < nLength/2; k++ )
3423 ABC_SWAP(
char, pRes[i][k], pRes[i][nLength-1-k] )
3424 pLut =
strstr(pOut+1,
":");
3425 nLength = (int)(pLut-pOut-1);
3426 for ( k = 0; k < nLength/2; k++ )
3427 ABC_SWAP(
char, pOut[1+k], pOut[1+nLength-1-k] )
3433 int RetValue = 0, k, Sum[2] = {0};
3434 char * pOut =
strstr(pGPC,
":");
3435 for ( k = 0; pGPC[k] !=
':'; k++ )
3436 Sum[0] += (1 << k) * Abc_TtReadHexDigit(pGPC[k]);
3437 for ( k = 0; pOut[1+k] !=
':'; k++ )
3438 Sum[1] += (1 << k) * Abc_TtReadHexDigit(pOut[1+k]);
3440 if ( Sum[0]+1 > (1 << Abc_Base2Log(Sum[1]+1)) )
3441 printf(
"The largest value of GPC inputs (%d) exceeds the capacity of outputs (%d) for GPC %s.\n", Sum[0], Sum[1], pGPC0 );
3442 else if ( Sum[1]+1 > (1 << Abc_Base2Log(Sum[0]+1)) )
3443 printf(
"The largest value of GPC outputs (%d) exceeds the capacity of inputs (%d) for GPC %s.\n", Sum[1], Sum[0], pGPC0 );
3448void Abc_NtkATMap(
int nXVars,
int nYVars,
int nAdder,
char ** pGPCs0,
int nGPCs,
int fReturn,
int fVerbose )
3450 abctime clkStart = Abc_Clock();
3452 int i, nGPCluts[100] = {0};
3453 for ( i = 0; i < nGPCs; i++ )
3456 for ( i = 0; i < nGPCs; i++ )
3458 int x, n, Entry, iLevel = 0, Sum = 0, nGpcs = 0, nBits, fFinished, nRcaLuts = 0, nLuts = 0;
3459 for ( x = 0; x < nXVars; x++ )
3460 Sum += (1 << x) * nYVars;
3461 nBits = Abc_Base2Log( Sum+1 );
3462 printf(
"Rectangular adder tree (X=%d Y=%d Sum=%d Out=%d) mapped with", nXVars, nYVars, Sum, nBits );
3463 for ( i = 0; i < nGPCs; i++ )
3464 printf(
" GPC%d=%s", i, pGPCs0[i] );
3467 Vec_Int_t * vRank[3] = { Vec_IntAlloc(100), Vec_IntAlloc(100), Vec_IntAlloc(100) };
3469 for ( i = 0; i < nGPCs; i++ )
3470 vGPCs[i] = Vec_WecAlloc(100);
3471 Vec_IntFill( vRank[0], nBits, 0 );
3472 for ( x = 0; x < nXVars; x++ )
3473 Vec_IntAddToEntry( vRank[0], x, nYVars );
3475 printf(
"Ranks: " );
3476 for ( i = nBits-1; i >= 0; i-- )
3479 for ( i = nBits-1; i >= 0; i-- )
3481 printf(
" LUT6\n" );
3483 for ( n = 0; n < nGPCs; n++ )
3484 for ( i = 0, fFinished = 0; !fFinished; i++ )
3487 vLevel = Vec_WecPushLevel( vGPCs[n] );
3488 Vec_IntFill( vLevel, nBits, 0 );
3489 Vec_IntFill( vRank[1], nBits, 0 );
3490 Vec_IntClear( vRank[2] );
3491 Vec_IntAppend( vRank[2], vRank[0] );
3493 if ( Vec_IntFindMax(vRank[0]) > nAdder ) {
3494 for ( x = 0; x < nBits; x++ )
3497 nLuts += Vec_IntSum(vLevel) * nGPCluts[n];
3499 Vec_IntAddToEntry( vRank[0], x, Entry );
3501 if ( fVerbose && (fAdded || Vec_IntFindMax(vRank[2]) <= nAdder ) ) {
3502 printf(
"Lev%02d: ", iLevel++ );
3505 printf(
" GPC%d: ", n );
3507 printf(
" %4d", Vec_IntSum(vLevel) * nGPCluts[n] );
3509 else if ( Vec_IntFindMax(vRank[2]) <= nAdder ) {
3510 printf(
" ADD%d: ", nAdder );
3511 for ( x = 0; x < nBits; x++ )
3512 if ( Vec_IntEntry(vRank[2], x) > 1 )
3514 for ( i = nBits-1; i >= x; i-- )
3516 for ( ; i >= 0; i-- )
3518 printf(
" %4d", (nBits-x)*(nAdder == 4 ? 2 : 1) );
3528 else if ( Vec_IntFindMax(vRank[2]) <= nAdder ) {
3533 if ( Vec_IntFindMax(vRank[0]) > nAdder )
3534 printf(
"Synthesis of the adder tree is incomplete. Try using the full adder \"3:11:1\" as the last GPC.\n" );
3535 else if ( fVerbose && Vec_IntFindMax(vRank[0]) <= nAdder ) {
3536 printf(
"Lev%02d: ", iLevel++ );
3537 for ( i = nBits-1; i >= 0; i-- )
3541 printf(
"Statistics: " );
3542 for ( n = 0; n < nGPCs; n++ )
3543 printf(
"GPC%d = %d. ", n, Vec_WecSum(vGPCs[n]) );
3544 for ( x = 0; x < nBits; x++ )
3545 if ( Vec_IntEntry(vRank[0], x) > 1 )
3547 nRcaLuts = (nBits-x)*(nAdder == 4 ? 2 : 1);
3548 printf(
"ADD%d = %d. ", nAdder, nRcaLuts );
3549 printf(
"Total LUT count = %d. ", nLuts+nRcaLuts );
3550 for ( i = 0; i < 3; i++ )
3551 Vec_IntFree( vRank[i] );
3552 for ( i = 0; i < nGPCs; i++ )
3553 Vec_WecFree( vGPCs[i] );
3555 for ( i = 0; i < nGPCs; i++ )
3558 Abc_PrintTime( 0,
"Total time", Abc_Clock() - clkStart );
void Abc_NtkFxuFreeInfo(Fxu_Data_t *p)
void Abc_NtkSetDefaultFxParams(Fxu_Data_t *p)
FUNCTION DEFINITIONS ///.
int Abc_NtkFastExtract(Abc_Ntk_t *pNtk, Fxu_Data_t *p)
void Abc_NtkCompareCones(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkCreatePropertyMonitor(Abc_Ntk_t *p, Vec_Int_t *vNodeIds, Vec_Int_t *vNodeValues)
Abc_Obj_t * Abc_NodeHasUniqueCoFanout(Abc_Obj_t *pNode)
int Abc_NtkGetBddNodeNum(Abc_Ntk_t *pNtk)
Abc_Obj_t * Abc_NodeFindNonCoFanout(Abc_Obj_t *pNode)
void Abc_NtkCompareSupports(Abc_Ntk_t *pNtk)
int Abc_NtkAddBuffsEval(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
int Abc_ObjPointerCompare(void **pp1, void **pp2)
int Abc_NodeCompareLevelsDecrease(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Vec_Wec_t * Abc_SopSynthesize(Vec_Ptr_t *vSops)
Gia_Man_t * Abc_GiaSynthesizeInter(Gia_Man_t *p)
int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
void Abc_NtkCleanMarkB(Abc_Ntk_t *pNtk)
void Abc_NtkCleanNext_rec(Abc_Ntk_t *pNtk)
void Abc_NtkATMap(int nXVars, int nYVars, int nAdder, char **pGPCs0, int nGPCs, int fReturn, int fVerbose)
void Abc_NtkFromPlaTest()
Abc_Ntk_t * Abc_NtkCreatePropertyMonitorTest(Abc_Ntk_t *p)
Abc_Ntk_t * Abc_NtkSopToCubes(Abc_Ntk_t *pNtk, int fXor)
void Abc_NtkTransferPhases(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk)
void Abc_NtkReverse_rec(Abc_Obj_t *pObj, Vec_Int_t *vVisited)
Abc_Obj_t * Abc_NtkAddBuffsOne(Vec_Ptr_t *vBuffs, Abc_Obj_t *pFanin, int Level, int nLevelMax)
void Abc_NtkCleanMarkA(Abc_Ntk_t *pNtk)
void Abc_NtkCleanNext(Abc_Ntk_t *pNtk)
int Abc_NtkCompareConesCompare(int *pNum1, int *pNum2)
void Abc_PrintAT(Vec_Int_t *vRanks)
int Abc_NtkClpOneGia_rec(Gia_Man_t *pNew, Abc_Obj_t *pNode)
double Abc_NtkGetMappedArea(Abc_Ntk_t *pNtk)
int Abc_NtkLogicHasSimpleCos(Abc_Ntk_t *pNtk)
int Abc_NtkPrepareTwoNtks(FILE *pErr, Abc_Ntk_t *pNtk, char **argv, int argc, Abc_Ntk_t **ppNtk1, Abc_Ntk_t **ppNtk2, int *pfDelete1, int *pfDelete2, int fCheck)
Vec_Ptr_t * Abc_NtkCollectLatches(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkFromPla(char **pPlas, int nInputs, int nOutputs)
void Abc_VecObjPushUniqueOrderByLevel(Vec_Ptr_t *p, Abc_Obj_t *pNode)
int Abc_NtkCrossCut_rec(Abc_Obj_t *pObj, int *pnCutSize, int *pnCutSizeMax)
int Abc_NtkGetLitFactNum(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkDeriveWithOnePo(Abc_Ntk_t *pNtk, Vec_Int_t *vNodeIds, Vec_Int_t *vNodeValues)
float Abc_NtkComputeDelay(Abc_Ntk_t *pNtk)
int Abc_NtkGetClauseNum(Abc_Ntk_t *pNtk)
void Abc_NtkCleanMarkC(Abc_Ntk_t *pNtk)
void Abc_NtkLoadCopy(Abc_Ntk_t *pNtk, Vec_Ptr_t *vCopies)
int Abc_NtkGetLitNum(Abc_Ntk_t *pNtk)
int Abc_NtkCountMuxes(Abc_Ntk_t *pNtk)
Vec_Ptr_t * Abc_NtkSaveCopy(Abc_Ntk_t *pNtk)
int Abc_NtkLogicMakeSimpleCos2(Abc_Ntk_t *pNtk, int fDuplicate)
Vec_Wec_t * Abc_GiaSynthesize(Vec_Ptr_t *vGias, Gia_Man_t *pMulti)
int Abc_NtkGetLargeNodeNum(Abc_Ntk_t *pNtk)
int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
void Abc_NodeCollectFanins(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Abc_Ntk_t * Abc_NtkSplitSop(Abc_Ntk_t *pNtk, int nCubesMax, int fVerbose)
int Abc_NtkGetMultiRefNum(Abc_Ntk_t *pNtk)
int Abc_NtkGetCubeNum(Abc_Ntk_t *pNtk)
void Abc_NtkCleanData(Abc_Ntk_t *pNtk)
int Abc_NtkIsTopo(Abc_Ntk_t *pNtk)
Gia_Man_t * Abc_SopSynthesizeOne(char *pSop, int fClp)
Abc_Obj_t * Abc_NodeFindCoFanout(Abc_Obj_t *pNode)
int Abc_NodeIsMuxControlType(Abc_Obj_t *pNode)
int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
int Abc_NtkCrossCut(Abc_Ntk_t *pNtk)
void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
int Abc_NtkGetAigNodeNum(Abc_Ntk_t *pNtk)
int Abc_NtkGetFanoutMax(Abc_Ntk_t *pNtk)
void Abc_NtkCleanCopy_rec(Abc_Ntk_t *pNtk)
void Abc_NtkFixCoDriverProblem(Abc_Obj_t *pDriver, Abc_Obj_t *pNodeCo, int fDuplicate)
void Abc_NtkReverseTopoOrderTest(Abc_Ntk_t *p)
void Abc_NtkUpdateGpcPattern(Vec_Int_t *vRank, int i, char *pGPC, int nGpcs, Vec_Int_t *vRank2, Vec_Int_t *vLevel)
Vec_Ptr_t * Abc_NtkCollectObjects(Abc_Ntk_t *pNtk)
int Abc_NtkGetGpcLutCount(char *pGPC)
void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
char ** Abc_NtkTransformGPCs(char **pGPCs, int nGPCs)
int Abc_NtkGetMuxNum(Abc_Ntk_t *pNtk)
int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
int Abc_GateToType(Abc_Obj_t *pObj)
int Abc_NtkGetCubePairNum(Abc_Ntk_t *pNtk)
void Abc_NtkDetectMatching(Abc_Ntk_t *pNtk)
void Abc_NtkReverseTopoOrder_rec(Abc_Obj_t *pObj, int fThisIsPivot)
Gia_Man_t * Abc_NtkStrashToGia(Abc_Ntk_t *pNtk)
void Abc_NtkLogicMakeSimpleCosTest(Abc_Ntk_t *pNtk, int fDuplicate)
int Abc_NtkAddBuffsEval2(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
void Abc_NodeSopToCubes(Abc_Obj_t *pNodeOld, Abc_Ntk_t *pNtkNew, int fXor)
int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Vec_Int_t * Abc_NtkGetCiIds(Abc_Ntk_t *pNtk)
int Abc_NodeCompareLevelsIncrease(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
ABC_NAMESPACE_IMPL_START void * Abc_NtkAttrFree(Abc_Ntk_t *pNtk, int Attr, int fFreeMan)
DECLARATIONS ///.
Abc_Ntk_t * Abc_NtkAddBuffsInt(Abc_Ntk_t *pNtkInit, int fReverse, int nImprove, int fVerbose)
int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
int Abc_NtkCheckGpc(char *pGPC, char *pGPC0)
void Abc_NtkReverseTopoOrder(Abc_Ntk_t *p)
Abc_Ntk_t * Abc_NtkFromArray()
void Abc_NtkTransferCopy(Abc_Ntk_t *pNtk)
int Abc_NtkGetExorNum(Abc_Ntk_t *pNtk)
int Abc_NtkCountCopy(Abc_Ntk_t *pNtk)
Abc_Obj_t * Abc_NodeRecognizeMux(Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
void Abc_NtkPrintCiLevels(Abc_Ntk_t *pNtk)
int Abc_NtkHasConstNode()
void Abc_NtkFillTemp(Abc_Ntk_t *pNtk)
int Abc_NtkGetTotalFanins(Abc_Ntk_t *pNtk)
void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
int Abc_NtkMatchGpcPattern(Vec_Int_t *vRanks, int i, char *pGPC)
void Abc_NtkCleanMarkAB(Abc_Ntk_t *pNtk)
Vec_Int_t * Abc_NtkFanoutCounts(Abc_Ntk_t *pNtk)
int Abc_NtkGetBufNum(Abc_Ntk_t *pNtk)
void Abc_NtkCleanMarkABC(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkAddBuffs(Abc_Ntk_t *pNtkInit, int fDirect, int fReverse, int nImprove, int fVerbose)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromGias(char *pName, Vec_Ptr_t *vGias, Gia_Man_t *pMulti)
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_NodeComplementInput(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
ABC_DLL char * Abc_SopCreateXorSpecial(Mem_Flex_t *pMan, int nVars)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_AigRehash(Abc_Aig_t *pMan)
#define Abc_AigForEachAnd(pNtk, pNode, i)
ABC_DLL Abc_Ntk_t * Abc_NtkDarLatchSweep(Abc_Ntk_t *pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fUseMvSweep, int nFramesSymb, int nFramesSatur, int fVerbose, int fVeryVerbose)
#define Abc_NtkForEachPo(pNtk, pPo, i)
ABC_DLL Abc_Obj_t * Abc_NtkFetchTwinNode(Abc_Obj_t *pNode)
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
ABC_DLL void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
ABC_DLL Gia_Man_t * Abc_NtkClpGia(Abc_Ntk_t *pNtk)
ABC_DLL Vec_Ptr_t * Abc_NtkDfsReverseNodesContained(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
ABC_DLL char * Abc_SopCreateInv(Mem_Flex_t *pMan)
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
ABC_DLL void Abc_SopComplement(char *pSop)
ABC_DLL void Abc_NodeComplement(Abc_Obj_t *pNode)
#define Abc_CubeForEachVar(pCube, Value, 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 char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
ABC_DLL int Abc_NodeIsConst0(Abc_Obj_t *pNode)
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
ABC_DLL int Abc_SopGetLitNum(char *pSop)
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromSops(char *pName, Vec_Ptr_t *vSops)
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeAnd(Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
ABC_DLL void Abc_SopComplementVar(char *pSop, int iVar)
#define Abc_SopForEachCube(pSop, nFanins, pCube)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
ABC_DLL int Abc_SopGetVarNum(char *pSop)
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkCreateObj(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
ABC_DLL Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
ABC_DLL int Abc_SopIsComplement(char *pSop)
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
ABC_DLL char * Abc_SopCreateXor(Mem_Flex_t *pMan, int nVars)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
ABC_DLL char * Abc_SopCreateConst0(Mem_Flex_t *pMan)
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
#define Abc_NtkForEachBox(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_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_SopCreateBuf(Mem_Flex_t *pMan)
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)
ABC_DLL Abc_Obj_t * Abc_NtkDupBox(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
#define ABC_SWAP(Type, a, b)
#define ABC_ALLOC(type, num)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
int nTotal
DECLARATIONS ///.
ABC_DLL Abc_Frame_t * Abc_FrameReadGlobalFrame()
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)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
struct Dec_Graph_t_ Dec_Graph_t
typedefABC_NAMESPACE_HEADER_START struct FxuDataStruct Fxu_Data_t
INCLUDES ///.
void Gia_ManStop(Gia_Man_t *p)
void Gia_ManHashStart(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
int Hop_DagSize(Hop_Obj_t *pObj)
struct Hop_Obj_t_ Hop_Obj_t
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
void Io_WriteBlifLogic(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
FUNCTION DEFINITIONS ///.
Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
unsigned __int64 word
DECLARATIONS ///.
double Mio_GateReadArea(Mio_Gate_t *pGate)
char * Mio_GateReadName(Mio_Gate_t *pGate)
struct Mio_GateStruct_t_ Mio_Gate_t
struct Mem_Flex_t_ Mem_Flex_t
struct Vec_Att_t_ Vec_Att_t
BASIC TYPES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryTwo(vVec1, vVec2, Entry1, Entry2, i)
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.