00001
00021 #include "abc.h"
00022 #include "abcInt.h"
00023 #include "main.h"
00024 #include "mio.h"
00025
00029
00033
00045 Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type )
00046 {
00047 Abc_Obj_t * pObj;
00048 if ( pNtk->pMmObj )
00049 pObj = (Abc_Obj_t *)Extra_MmFixedEntryFetch( pNtk->pMmObj );
00050 else
00051 pObj = (Abc_Obj_t *)ALLOC( Abc_Obj_t, 1 );
00052 memset( pObj, 0, sizeof(Abc_Obj_t) );
00053 pObj->pNtk = pNtk;
00054 pObj->Type = Type;
00055 pObj->Id = -1;
00056 return pObj;
00057 }
00058
00070 void Abc_ObjRecycle( Abc_Obj_t * pObj )
00071 {
00072 Abc_Ntk_t * pNtk = pObj->pNtk;
00073 int LargePiece = (4 << ABC_NUM_STEPS);
00074
00075 if ( pNtk->pMmStep && pObj->vFanouts.nCap * 4 > LargePiece )
00076 FREE( pObj->vFanouts.pArray );
00077 if ( pNtk->pMmStep == NULL )
00078 {
00079 FREE( pObj->vFanouts.pArray );
00080 FREE( pObj->vFanins.pArray );
00081 }
00082
00083 memset( pObj, 0, sizeof(Abc_Obj_t) );
00084
00085 if ( pNtk->pMmObj )
00086 Extra_MmFixedEntryRecycle( pNtk->pMmObj, (char *)pObj );
00087 else
00088 free( pObj );
00089 }
00090
00102 Abc_Obj_t * Abc_NtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type )
00103 {
00104 Abc_Obj_t * pObj;
00105
00106 pObj = Abc_ObjAlloc( pNtk, Type );
00107 pObj->Id = pNtk->vObjs->nSize;
00108 Vec_PtrPush( pNtk->vObjs, pObj );
00109 pNtk->nObjCounts[Type]++;
00110 pNtk->nObjs++;
00111
00112 switch (Type)
00113 {
00114 case ABC_OBJ_NONE:
00115 assert(0);
00116 break;
00117 case ABC_OBJ_CONST1:
00118 assert(0);
00119 break;
00120 case ABC_OBJ_PIO:
00121 assert(0);
00122 break;
00123 case ABC_OBJ_PI:
00124 Vec_PtrPush( pNtk->vPis, pObj );
00125 Vec_PtrPush( pNtk->vCis, pObj );
00126 break;
00127 case ABC_OBJ_PO:
00128 Vec_PtrPush( pNtk->vPos, pObj );
00129 Vec_PtrPush( pNtk->vCos, pObj );
00130 break;
00131 case ABC_OBJ_BI:
00132 if ( pNtk->vCos ) Vec_PtrPush( pNtk->vCos, pObj );
00133 break;
00134 case ABC_OBJ_BO:
00135 if ( pNtk->vCis ) Vec_PtrPush( pNtk->vCis, pObj );
00136 break;
00137 case ABC_OBJ_ASSERT:
00138 Vec_PtrPush( pNtk->vAsserts, pObj );
00139 Vec_PtrPush( pNtk->vCos, pObj );
00140 break;
00141 case ABC_OBJ_NET:
00142 case ABC_OBJ_NODE:
00143 break;
00144 case ABC_OBJ_LATCH:
00145 pObj->pData = (void *)ABC_INIT_NONE;
00146 case ABC_OBJ_WHITEBOX:
00147 case ABC_OBJ_BLACKBOX:
00148 if ( pNtk->vBoxes ) Vec_PtrPush( pNtk->vBoxes, pObj );
00149 break;
00150 default:
00151 assert(0);
00152 break;
00153 }
00154 return pObj;
00155 }
00156
00168 void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
00169 {
00170 Abc_Ntk_t * pNtk = pObj->pNtk;
00171 Vec_Ptr_t * vNodes;
00172 int i;
00173 assert( !Abc_ObjIsComplement(pObj) );
00174
00175 if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
00176 Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
00177
00178 vNodes = Vec_PtrAlloc( 100 );
00179 Abc_NodeCollectFanouts( pObj, vNodes );
00180 for ( i = 0; i < vNodes->nSize; i++ )
00181 Abc_ObjDeleteFanin( vNodes->pArray[i], pObj );
00182 Abc_NodeCollectFanins( pObj, vNodes );
00183 for ( i = 0; i < vNodes->nSize; i++ )
00184 Abc_ObjDeleteFanin( pObj, vNodes->pArray[i] );
00185 Vec_PtrFree( vNodes );
00186
00187 Vec_PtrWriteEntry( pNtk->vObjs, pObj->Id, NULL );
00188 pObj->Id = (1<<26)-1;
00189 pNtk->nObjCounts[pObj->Type]--;
00190 pNtk->nObjs--;
00191
00192 switch (pObj->Type)
00193 {
00194 case ABC_OBJ_NONE:
00195 assert(0);
00196 break;
00197 case ABC_OBJ_CONST1:
00198 assert(0);
00199 break;
00200 case ABC_OBJ_PIO:
00201 assert(0);
00202 break;
00203 case ABC_OBJ_PI:
00204 Vec_PtrRemove( pNtk->vPis, pObj );
00205 Vec_PtrRemove( pNtk->vCis, pObj );
00206 break;
00207 case ABC_OBJ_PO:
00208 Vec_PtrRemove( pNtk->vPos, pObj );
00209 Vec_PtrRemove( pNtk->vCos, pObj );
00210 break;
00211 case ABC_OBJ_BI:
00212 if ( pNtk->vCos ) Vec_PtrRemove( pNtk->vCos, pObj );
00213 break;
00214 case ABC_OBJ_BO:
00215 if ( pNtk->vCis ) Vec_PtrRemove( pNtk->vCis, pObj );
00216 break;
00217 case ABC_OBJ_ASSERT:
00218 Vec_PtrRemove( pNtk->vAsserts, pObj );
00219 Vec_PtrRemove( pNtk->vCos, pObj );
00220 break;
00221 case ABC_OBJ_NET:
00222 break;
00223 case ABC_OBJ_NODE:
00224 if ( Abc_NtkHasBdd(pNtk) )
00225 Cudd_RecursiveDeref( pNtk->pManFunc, pObj->pData );
00226 pObj->pData = NULL;
00227 break;
00228 case ABC_OBJ_LATCH:
00229 case ABC_OBJ_WHITEBOX:
00230 case ABC_OBJ_BLACKBOX:
00231 if ( pNtk->vBoxes ) Vec_PtrRemove( pNtk->vBoxes, pObj );
00232 break;
00233 default:
00234 assert(0);
00235 break;
00236 }
00237
00238 Abc_ObjRecycle( pObj );
00239 }
00240
00252 void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj, int fOnlyNodes )
00253 {
00254 Vec_Ptr_t * vNodes;
00255 int i;
00256 assert( !Abc_ObjIsComplement(pObj) );
00257 assert( !Abc_ObjIsPi(pObj) );
00258 assert( Abc_ObjFanoutNum(pObj) == 0 );
00259
00260 vNodes = Vec_PtrAlloc( 100 );
00261 Abc_NodeCollectFanins( pObj, vNodes );
00262 Abc_NtkDeleteObj( pObj );
00263 if ( fOnlyNodes )
00264 {
00265 Vec_PtrForEachEntry( vNodes, pObj, i )
00266 if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
00267 Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
00268 }
00269 else
00270 {
00271 Vec_PtrForEachEntry( vNodes, pObj, i )
00272 if ( !Abc_ObjIsPi(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
00273 Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
00274 }
00275 Vec_PtrFree( vNodes );
00276 }
00277
00289 void Abc_NtkDeleteAll_rec( Abc_Obj_t * pObj )
00290 {
00291 Vec_Ptr_t * vNodes;
00292 int i;
00293 assert( !Abc_ObjIsComplement(pObj) );
00294 assert( Abc_ObjFanoutNum(pObj) == 0 );
00295
00296 vNodes = Vec_PtrAlloc( 100 );
00297 Abc_NodeCollectFanins( pObj, vNodes );
00298 Abc_NtkDeleteObj( pObj );
00299 Vec_PtrForEachEntry( vNodes, pObj, i )
00300 if ( !Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
00301 Abc_NtkDeleteAll_rec( pObj );
00302 Vec_PtrFree( vNodes );
00303 }
00304
00316 Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName )
00317 {
00318 Abc_Obj_t * pObjNew;
00319
00320 pObjNew = Abc_NtkCreateObj( pNtkNew, pObj->Type );
00321
00322 if ( fCopyName )
00323 {
00324 if ( Abc_ObjIsCi(pObj) )
00325 {
00326 if ( !Abc_NtkIsNetlist(pNtkNew) )
00327 Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
00328 }
00329 else if ( Abc_ObjIsCo(pObj) )
00330 {
00331 if ( !Abc_NtkIsNetlist(pNtkNew) )
00332 {
00333 if ( Abc_ObjIsPo(pObj) )
00334 Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
00335 else
00336 {
00337 assert( Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) );
00338 Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
00339 }
00340 }
00341 }
00342 else if ( Abc_ObjIsBox(pObj) || Abc_ObjIsNet(pObj) )
00343 Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
00344 }
00345
00346 if ( Abc_ObjIsNode(pObj) )
00347 {
00348 if ( pNtkNew->ntkFunc == pObj->pNtk->ntkFunc )
00349 {
00350 if ( Abc_NtkIsStrash(pNtkNew) )
00351 {}
00352 else if ( Abc_NtkHasSop(pNtkNew) || Abc_NtkHasBlifMv(pNtkNew) )
00353 pObjNew->pData = Abc_SopRegister( pNtkNew->pManFunc, pObj->pData );
00354 else if ( Abc_NtkHasBdd(pNtkNew) )
00355 pObjNew->pData = Cudd_bddTransfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData), Cudd_Ref(pObjNew->pData);
00356 else if ( Abc_NtkHasAig(pNtkNew) )
00357 pObjNew->pData = Hop_Transfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj));
00358 else if ( Abc_NtkHasMapping(pNtkNew) )
00359 pObjNew->pData = pObj->pData;
00360 else assert( 0 );
00361 }
00362 }
00363 else if ( Abc_ObjIsNet(pObj) )
00364 {
00365 }
00366 else if ( Abc_ObjIsLatch(pObj) )
00367 pObjNew->pData = pObj->pData;
00368
00369
00370
00371 pObj->pCopy = pObjNew;
00372 return pObjNew;
00373 }
00374
00386 Abc_Obj_t * Abc_NtkDupBox( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pBox, int fCopyName )
00387 {
00388 Abc_Obj_t * pTerm, * pBoxNew;
00389 int i;
00390 assert( Abc_ObjIsBox(pBox) );
00391
00392 pBoxNew = Abc_NtkDupObj( pNtkNew, pBox, fCopyName );
00393
00394 Abc_ObjForEachFanin( pBox, pTerm, i )
00395 Abc_ObjAddFanin( pBoxNew, Abc_NtkDupObj(pNtkNew, pTerm, fCopyName) );
00396
00397 Abc_ObjForEachFanout( pBox, pTerm, i )
00398 Abc_ObjAddFanin( Abc_NtkDupObj(pNtkNew, pTerm, fCopyName), pBoxNew );
00399 return pBoxNew;
00400 }
00401
00413 Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj )
00414 {
00415 Abc_Obj_t * pClone, * pFanin;
00416 int i;
00417 pClone = Abc_NtkCreateObj( pObj->pNtk, pObj->Type );
00418 Abc_ObjForEachFanin( pObj, pFanin, i )
00419 Abc_ObjAddFanin( pClone, pFanin );
00420 return pClone;
00421 }
00422
00423
00435 Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
00436 {
00437 Abc_Obj_t * pObj;
00438 int Num;
00439
00440 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
00441 if ( Num >= 0 )
00442 return Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
00443 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
00444 if ( Num >= 0 )
00445 return Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
00446 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NODE );
00447 if ( Num >= 0 )
00448 return Abc_NtkObj( pNtk, Num );
00449
00450 if ( pName[0] != 'n' )
00451 {
00452 printf( "Name \"%s\" is not found among CO or node names (internal names often look as \"n<num>\").\n", pName );
00453 return NULL;
00454 }
00455 Num = atoi( pName + 1 );
00456 if ( Num < 0 || Num >= Abc_NtkObjNumMax(pNtk) )
00457 {
00458 printf( "The node \"%s\" with ID %d is not in the current network.\n", pName, Num );
00459 return NULL;
00460 }
00461 pObj = Abc_NtkObj( pNtk, Num );
00462 if ( pObj == NULL )
00463 {
00464 printf( "The node \"%s\" with ID %d has been removed from the current network.\n", pName, Num );
00465 return NULL;
00466 }
00467 if ( !Abc_ObjIsNode(pObj) )
00468 {
00469 printf( "Object with ID %d is not a node.\n", Num );
00470 return NULL;
00471 }
00472 return pObj;
00473 }
00474
00486 Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName )
00487 {
00488 Abc_Obj_t * pNet;
00489 int ObjId;
00490 assert( Abc_NtkIsNetlist(pNtk) );
00491 ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NET );
00492 if ( ObjId == -1 )
00493 return NULL;
00494 pNet = Abc_NtkObj( pNtk, ObjId );
00495 return pNet;
00496 }
00497
00509 Abc_Obj_t * Abc_NtkFindCi( Abc_Ntk_t * pNtk, char * pName )
00510 {
00511 int Num;
00512 assert( !Abc_NtkIsNetlist(pNtk) );
00513 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PI );
00514 if ( Num >= 0 )
00515 return Abc_NtkObj( pNtk, Num );
00516 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
00517 if ( Num >= 0 )
00518 return Abc_NtkObj( pNtk, Num );
00519 return NULL;
00520 }
00521
00533 Abc_Obj_t * Abc_NtkFindCo( Abc_Ntk_t * pNtk, char * pName )
00534 {
00535 int Num;
00536 assert( !Abc_NtkIsNetlist(pNtk) );
00537 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
00538 if ( Num >= 0 )
00539 return Abc_NtkObj( pNtk, Num );
00540 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
00541 if ( Num >= 0 )
00542 return Abc_NtkObj( pNtk, Num );
00543 return NULL;
00544 }
00545
00546
00558 Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName )
00559 {
00560 Abc_Obj_t * pNet;
00561 assert( Abc_NtkIsNetlist(pNtk) );
00562 if ( pName && (pNet = Abc_NtkFindNet( pNtk, pName )) )
00563 return pNet;
00564
00565
00566 pNet = Abc_NtkCreateNet( pNtk );
00567 if ( pName )
00568 Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pNet->Type, pName, NULL );
00569 return pNet;
00570 }
00571
00583 Abc_Obj_t * Abc_NtkCreateNodeConst0( Abc_Ntk_t * pNtk )
00584 {
00585 Abc_Obj_t * pNode;
00586 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00587 pNode = Abc_NtkCreateNode( pNtk );
00588 if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
00589 pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 0\n" );
00590 else if ( Abc_NtkHasBdd(pNtk) )
00591 pNode->pData = Cudd_ReadLogicZero(pNtk->pManFunc), Cudd_Ref( pNode->pData );
00592 else if ( Abc_NtkHasAig(pNtk) )
00593 pNode->pData = Hop_ManConst0(pNtk->pManFunc);
00594 else if ( Abc_NtkHasMapping(pNtk) )
00595 pNode->pData = Mio_LibraryReadConst0(Abc_FrameReadLibGen());
00596 else if ( !Abc_NtkHasBlackbox(pNtk) )
00597 assert( 0 );
00598 return pNode;
00599 }
00600
00612 Abc_Obj_t * Abc_NtkCreateNodeConst1( Abc_Ntk_t * pNtk )
00613 {
00614 Abc_Obj_t * pNode;
00615 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00616 pNode = Abc_NtkCreateNode( pNtk );
00617 if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
00618 pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 1\n" );
00619 else if ( Abc_NtkHasBdd(pNtk) )
00620 pNode->pData = Cudd_ReadOne(pNtk->pManFunc), Cudd_Ref( pNode->pData );
00621 else if ( Abc_NtkHasAig(pNtk) )
00622 pNode->pData = Hop_ManConst1(pNtk->pManFunc);
00623 else if ( Abc_NtkHasMapping(pNtk) )
00624 pNode->pData = Mio_LibraryReadConst1(Abc_FrameReadLibGen());
00625 else if ( !Abc_NtkHasBlackbox(pNtk) )
00626 assert( 0 );
00627 return pNode;
00628 }
00629
00641 Abc_Obj_t * Abc_NtkCreateNodeInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin )
00642 {
00643 Abc_Obj_t * pNode;
00644 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00645 pNode = Abc_NtkCreateNode( pNtk );
00646 if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
00647 if ( Abc_NtkHasSop(pNtk) )
00648 pNode->pData = Abc_SopRegister( pNtk->pManFunc, "0 1\n" );
00649 else if ( Abc_NtkHasBdd(pNtk) )
00650 pNode->pData = Cudd_Not(Cudd_bddIthVar(pNtk->pManFunc,0)), Cudd_Ref( pNode->pData );
00651 else if ( Abc_NtkHasAig(pNtk) )
00652 pNode->pData = Hop_Not(Hop_IthVar(pNtk->pManFunc,0));
00653 else if ( Abc_NtkHasMapping(pNtk) )
00654 pNode->pData = Mio_LibraryReadInv(Abc_FrameReadLibGen());
00655 else
00656 assert( 0 );
00657 return pNode;
00658 }
00659
00671 Abc_Obj_t * Abc_NtkCreateNodeBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin )
00672 {
00673 Abc_Obj_t * pNode;
00674 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00675 pNode = Abc_NtkCreateNode( pNtk );
00676 if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
00677 if ( Abc_NtkHasSop(pNtk) )
00678 pNode->pData = Abc_SopRegister( pNtk->pManFunc, "1 1\n" );
00679 else if ( Abc_NtkHasBdd(pNtk) )
00680 pNode->pData = Cudd_bddIthVar(pNtk->pManFunc,0), Cudd_Ref( pNode->pData );
00681 else if ( Abc_NtkHasAig(pNtk) )
00682 pNode->pData = Hop_IthVar(pNtk->pManFunc,0);
00683 else if ( Abc_NtkHasMapping(pNtk) )
00684 pNode->pData = Mio_LibraryReadBuf(Abc_FrameReadLibGen());
00685 else
00686 assert( 0 );
00687 return pNode;
00688 }
00689
00701 Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
00702 {
00703 Abc_Obj_t * pNode;
00704 int i;
00705 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00706 pNode = Abc_NtkCreateNode( pNtk );
00707 for ( i = 0; i < vFanins->nSize; i++ )
00708 Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
00709 if ( Abc_NtkHasSop(pNtk) )
00710 pNode->pData = Abc_SopCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
00711 else if ( Abc_NtkHasBdd(pNtk) )
00712 pNode->pData = Extra_bddCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
00713 else if ( Abc_NtkHasAig(pNtk) )
00714 pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) );
00715 else
00716 assert( 0 );
00717 return pNode;
00718 }
00719
00731 Abc_Obj_t * Abc_NtkCreateNodeOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
00732 {
00733 Abc_Obj_t * pNode;
00734 int i;
00735 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00736 pNode = Abc_NtkCreateNode( pNtk );
00737 for ( i = 0; i < vFanins->nSize; i++ )
00738 Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
00739 if ( Abc_NtkHasSop(pNtk) )
00740 pNode->pData = Abc_SopCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
00741 else if ( Abc_NtkHasBdd(pNtk) )
00742 pNode->pData = Extra_bddCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
00743 else if ( Abc_NtkHasAig(pNtk) )
00744 pNode->pData = Hop_CreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) );
00745 else
00746 assert( 0 );
00747 return pNode;
00748 }
00749
00761 Abc_Obj_t * Abc_NtkCreateNodeExor( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
00762 {
00763 Abc_Obj_t * pNode;
00764 int i;
00765 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00766 pNode = Abc_NtkCreateNode( pNtk );
00767 for ( i = 0; i < vFanins->nSize; i++ )
00768 Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
00769 if ( Abc_NtkHasSop(pNtk) )
00770 pNode->pData = Abc_SopCreateXorSpecial( pNtk->pManFunc, Vec_PtrSize(vFanins) );
00771 else if ( Abc_NtkHasBdd(pNtk) )
00772 pNode->pData = Extra_bddCreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
00773 else if ( Abc_NtkHasAig(pNtk) )
00774 pNode->pData = Hop_CreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) );
00775 else
00776 assert( 0 );
00777 return pNode;
00778 }
00779
00791 Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 )
00792 {
00793 Abc_Obj_t * pNode;
00794 assert( Abc_NtkIsLogic(pNtk) );
00795 pNode = Abc_NtkCreateNode( pNtk );
00796 Abc_ObjAddFanin( pNode, pNodeC );
00797 Abc_ObjAddFanin( pNode, pNode1 );
00798 Abc_ObjAddFanin( pNode, pNode0 );
00799 if ( Abc_NtkHasSop(pNtk) )
00800 pNode->pData = Abc_SopRegister( pNtk->pManFunc, "11- 1\n0-1 1\n" );
00801 else if ( Abc_NtkHasBdd(pNtk) )
00802 pNode->pData = Cudd_bddIte(pNtk->pManFunc,Cudd_bddIthVar(pNtk->pManFunc,0),Cudd_bddIthVar(pNtk->pManFunc,1),Cudd_bddIthVar(pNtk->pManFunc,2)), Cudd_Ref( pNode->pData );
00803 else if ( Abc_NtkHasAig(pNtk) )
00804 pNode->pData = Hop_Mux(pNtk->pManFunc,Hop_IthVar(pNtk->pManFunc,0),Hop_IthVar(pNtk->pManFunc,1),Hop_IthVar(pNtk->pManFunc,2));
00805 else
00806 assert( 0 );
00807 return pNode;
00808 }
00809
00810
00822 bool Abc_NodeIsConst( Abc_Obj_t * pNode )
00823 {
00824 assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
00825 return Abc_ObjIsNode(pNode) && Abc_ObjFaninNum(pNode) == 0;
00826 }
00827
00839 bool Abc_NodeIsConst0( Abc_Obj_t * pNode )
00840 {
00841 Abc_Ntk_t * pNtk = pNode->pNtk;
00842 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00843 assert( Abc_ObjIsNode(pNode) );
00844 if ( !Abc_NodeIsConst(pNode) )
00845 return 0;
00846 if ( Abc_NtkHasSop(pNtk) )
00847 return Abc_SopIsConst0(pNode->pData);
00848 if ( Abc_NtkHasBdd(pNtk) )
00849 return Cudd_IsComplement(pNode->pData);
00850 if ( Abc_NtkHasAig(pNtk) )
00851 return Hop_IsComplement(pNode->pData);
00852 if ( Abc_NtkHasMapping(pNtk) )
00853 return pNode->pData == Mio_LibraryReadConst0(Abc_FrameReadLibGen());
00854 assert( 0 );
00855 return 0;
00856 }
00857
00869 bool Abc_NodeIsConst1( Abc_Obj_t * pNode )
00870 {
00871 Abc_Ntk_t * pNtk = pNode->pNtk;
00872 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00873 assert( Abc_ObjIsNode(pNode) );
00874 if ( !Abc_NodeIsConst(pNode) )
00875 return 0;
00876 if ( Abc_NtkHasSop(pNtk) )
00877 return Abc_SopIsConst1(pNode->pData);
00878 if ( Abc_NtkHasBdd(pNtk) )
00879 return !Cudd_IsComplement(pNode->pData);
00880 if ( Abc_NtkHasAig(pNtk) )
00881 return !Hop_IsComplement(pNode->pData);
00882 if ( Abc_NtkHasMapping(pNtk) )
00883 return pNode->pData == Mio_LibraryReadConst1(Abc_FrameReadLibGen());
00884 assert( 0 );
00885 return 0;
00886 }
00887
00899 bool Abc_NodeIsBuf( Abc_Obj_t * pNode )
00900 {
00901 Abc_Ntk_t * pNtk = pNode->pNtk;
00902 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00903 assert( Abc_ObjIsNode(pNode) );
00904 if ( Abc_ObjFaninNum(pNode) != 1 )
00905 return 0;
00906 if ( Abc_NtkHasSop(pNtk) )
00907 return Abc_SopIsBuf(pNode->pData);
00908 if ( Abc_NtkHasBdd(pNtk) )
00909 return !Cudd_IsComplement(pNode->pData);
00910 if ( Abc_NtkHasAig(pNtk) )
00911 return !Hop_IsComplement(pNode->pData);
00912 if ( Abc_NtkHasMapping(pNtk) )
00913 return pNode->pData == Mio_LibraryReadBuf(Abc_FrameReadLibGen());
00914 assert( 0 );
00915 return 0;
00916 }
00917
00929 bool Abc_NodeIsInv( Abc_Obj_t * pNode )
00930 {
00931 Abc_Ntk_t * pNtk = pNode->pNtk;
00932 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
00933 assert( Abc_ObjIsNode(pNode) );
00934 if ( Abc_ObjFaninNum(pNode) != 1 )
00935 return 0;
00936 if ( Abc_NtkHasSop(pNtk) )
00937 return Abc_SopIsInv(pNode->pData);
00938 if ( Abc_NtkHasBdd(pNtk) )
00939 return Cudd_IsComplement(pNode->pData);
00940 if ( Abc_NtkHasAig(pNtk) )
00941 return Hop_IsComplement(pNode->pData);
00942 if ( Abc_NtkHasMapping(pNtk) )
00943 return pNode->pData == Mio_LibraryReadInv(Abc_FrameReadLibGen());
00944 assert( 0 );
00945 return 0;
00946 }
00947
00959 void Abc_NodeComplement( Abc_Obj_t * pNode )
00960 {
00961 assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
00962 assert( Abc_ObjIsNode(pNode) );
00963 if ( Abc_NtkHasSop(pNode->pNtk) )
00964 Abc_SopComplement( pNode->pData );
00965 else if ( Abc_NtkHasBdd(pNode->pNtk) )
00966 pNode->pData = Cudd_Not( pNode->pData );
00967 else if ( Abc_NtkHasAig(pNode->pNtk) )
00968 pNode->pData = Hop_Not( pNode->pData );
00969 else
00970 assert( 0 );
00971 }
00972
00976