ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcObj.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22#include "abcInt.h"
23#include "base/main/main.h"
24#include "map/mio/mio.h"
25
26#ifdef ABC_USE_CUDD
27#include "bdd/extrab/extraBdd.h"
28#endif
29
31
32
36
40
53{
54 Abc_Obj_t * pObj;
55 if ( pNtk->pMmObj )
56 pObj = (Abc_Obj_t *)Mem_FixedEntryFetch( pNtk->pMmObj );
57 else
58 pObj = (Abc_Obj_t *)ABC_ALLOC( Abc_Obj_t, 1 );
59 memset( pObj, 0, sizeof(Abc_Obj_t) );
60 pObj->pNtk = pNtk;
61 pObj->Type = Type;
62 pObj->Id = -1;
63 return pObj;
64}
65
78{
79 Abc_Ntk_t * pNtk = pObj->pNtk;
80// int LargePiece = (4 << ABC_NUM_STEPS);
81 // free large fanout arrays
82// if ( pNtk->pMmStep && pObj->vFanouts.nCap * 4 > LargePiece )
83// free( pObj->vFanouts.pArray );
84 if ( pNtk->pMmStep == NULL )
85 {
86 ABC_FREE( pObj->vFanouts.pArray );
87 ABC_FREE( pObj->vFanins.pArray );
88 }
89 // clean the memory to make deleted object distinct from the live one
90 memset( pObj, 0, sizeof(Abc_Obj_t) );
91 // recycle the object
92 if ( pNtk->pMmObj )
93 Mem_FixedEntryRecycle( pNtk->pMmObj, (char *)pObj );
94 else
95 ABC_FREE( pObj );
96}
97
110{
111 Abc_Obj_t * pObj;
112 // create new object, assign ID, and add to the array
113 pObj = Abc_ObjAlloc( pNtk, Type );
114 pObj->Id = pNtk->vObjs->nSize;
115 Vec_PtrPush( pNtk->vObjs, pObj );
116 pNtk->nObjCounts[Type]++;
117 pNtk->nObjs++;
118 // perform specialized operations depending on the object type
119 switch (Type)
120 {
121 case ABC_OBJ_NONE:
122 assert(0);
123 break;
124 case ABC_OBJ_CONST1:
125 assert(0);
126 break;
127 case ABC_OBJ_PI:
128// pObj->iTemp = Vec_PtrSize(pNtk->vCis);
129 Vec_PtrPush( pNtk->vPis, pObj );
130 Vec_PtrPush( pNtk->vCis, pObj );
131 break;
132 case ABC_OBJ_PO:
133// pObj->iTemp = Vec_PtrSize(pNtk->vCos);
134 Vec_PtrPush( pNtk->vPos, pObj );
135 Vec_PtrPush( pNtk->vCos, pObj );
136 break;
137 case ABC_OBJ_BI:
138 if ( pNtk->vCos ) Vec_PtrPush( pNtk->vCos, pObj );
139 break;
140 case ABC_OBJ_BO:
141 if ( pNtk->vCis ) Vec_PtrPush( pNtk->vCis, pObj );
142 break;
143 case ABC_OBJ_NET:
144 case ABC_OBJ_NODE:
145 break;
146 case ABC_OBJ_LATCH:
147 pObj->pData = (void *)ABC_INIT_NONE;
148 case ABC_OBJ_WHITEBOX:
149 case ABC_OBJ_BLACKBOX:
150 if ( pNtk->vBoxes ) Vec_PtrPush( pNtk->vBoxes, pObj );
151 break;
152 default:
153 assert(0);
154 break;
155 }
156 return pObj;
157}
158
171{
172 Abc_Ntk_t * pNtk = pObj->pNtk;
173 Vec_Ptr_t * vNodes;
174 int i;
175 assert( !Abc_ObjIsComplement(pObj) );
176 // remove from the table of names
177 if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
178 Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
179 // delete fanins and fanouts
180 vNodes = Vec_PtrAlloc( 100 );
181 Abc_NodeCollectFanouts( pObj, vNodes );
182 for ( i = 0; i < vNodes->nSize; i++ )
183 Abc_ObjDeleteFanin( (Abc_Obj_t *)vNodes->pArray[i], pObj );
184 Abc_NodeCollectFanins( pObj, vNodes );
185 for ( i = 0; i < vNodes->nSize; i++ )
186 Abc_ObjDeleteFanin( pObj, (Abc_Obj_t *)vNodes->pArray[i] );
187 Vec_PtrFree( vNodes );
188 // remove from the list of objects
189 Vec_PtrWriteEntry( pNtk->vObjs, pObj->Id, NULL );
190 pObj->Id = (1<<26)-1;
191 pNtk->nObjCounts[pObj->Type]--;
192 pNtk->nObjs--;
193 // perform specialized operations depending on the object type
194 switch (pObj->Type)
195 {
196 case ABC_OBJ_NONE:
197 assert(0);
198 break;
199 case ABC_OBJ_CONST1:
200 assert(0);
201 break;
202 case ABC_OBJ_PI:
203 Vec_PtrRemove( pNtk->vPis, pObj );
204 Vec_PtrRemove( pNtk->vCis, pObj );
205 break;
206 case ABC_OBJ_PO:
207 Vec_PtrRemove( pNtk->vPos, pObj );
208 Vec_PtrRemove( pNtk->vCos, pObj );
209 break;
210 case ABC_OBJ_BI:
211 if ( pNtk->vCos ) Vec_PtrRemove( pNtk->vCos, pObj );
212 break;
213 case ABC_OBJ_BO:
214 if ( pNtk->vCis ) Vec_PtrRemove( pNtk->vCis, pObj );
215 break;
216 case ABC_OBJ_NET:
217 break;
218 case ABC_OBJ_NODE:
219#ifdef ABC_USE_CUDD
220 if ( Abc_NtkHasBdd(pNtk) )
221 Cudd_RecursiveDeref( (DdManager *)pNtk->pManFunc, (DdNode *)pObj->pData );
222#endif
223 pObj->pData = NULL;
224 break;
225 case ABC_OBJ_LATCH:
226 case ABC_OBJ_WHITEBOX:
227 case ABC_OBJ_BLACKBOX:
228 if ( pNtk->vBoxes ) Vec_PtrRemove( pNtk->vBoxes, pObj );
229 break;
230 default:
231 assert(0);
232 break;
233 }
234 // recycle the object memory
235 Abc_ObjRecycle( pObj );
236}
237
250{
251 assert( Abc_ObjIsPo(pObj) );
252 // remove from the table of names
253 if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
254 Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
255 // delete fanins
256 Abc_ObjDeleteFanin( pObj, Abc_ObjFanin0(pObj) );
257 // remove from the list of objects
258 Vec_PtrWriteEntry( pObj->pNtk->vObjs, pObj->Id, NULL );
259 pObj->Id = (1<<26)-1;
260 pObj->pNtk->nObjCounts[pObj->Type]--;
261 pObj->pNtk->nObjs--;
262 // recycle the object memory
263 Abc_ObjRecycle( pObj );
264}
265
266
278void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj, int fOnlyNodes )
279{
280 Vec_Ptr_t * vNodes;
281 int i;
282 assert( !Abc_ObjIsComplement(pObj) );
283 assert( !Abc_ObjIsPi(pObj) );
284 assert( Abc_ObjFanoutNum(pObj) == 0 );
285 // delete fanins and fanouts
286 vNodes = Vec_PtrAlloc( 100 );
287 Abc_NodeCollectFanins( pObj, vNodes );
288 Abc_NtkDeleteObj( pObj );
289 if ( fOnlyNodes )
290 {
291 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
292 if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
293 Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
294 }
295 else
296 {
297 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
298 if ( !Abc_ObjIsPi(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
299 Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
300 }
301 Vec_PtrFree( vNodes );
302}
303
316{
317 Vec_Ptr_t * vNodes;
318 int i;
319 assert( !Abc_ObjIsComplement(pObj) );
320 assert( Abc_ObjFanoutNum(pObj) == 0 );
321 // delete fanins and fanouts
322 vNodes = Vec_PtrAlloc( 100 );
323 Abc_NodeCollectFanins( pObj, vNodes );
324 Abc_NtkDeleteObj( pObj );
325 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
326 if ( !Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
327 Abc_NtkDeleteAll_rec( pObj );
328 Vec_PtrFree( vNodes );
329}
330
342Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName )
343{
344 Abc_Obj_t * pObjNew;
345 // create the new object
346 pObjNew = Abc_NtkCreateObj( pNtkNew, (Abc_ObjType_t)pObj->Type );
347 // transfer names of the terminal objects
348 if ( fCopyName )
349 {
350 if ( Abc_ObjIsCi(pObj) )
351 {
352 if ( !Abc_NtkIsNetlist(pNtkNew) )
353 Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
354 }
355 else if ( Abc_ObjIsCo(pObj) )
356 {
357 if ( !Abc_NtkIsNetlist(pNtkNew) )
358 {
359 if ( Abc_ObjIsPo(pObj) )
360 Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
361 else
362 {
363 assert( Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) );
364 Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
365 }
366 }
367 }
368 else if ( Abc_ObjIsBox(pObj) || Abc_ObjIsNet(pObj) )
369 Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
370 }
371 // copy functionality/names
372 if ( Abc_ObjIsNode(pObj) ) // copy the function if functionality is compatible
373 {
374 if ( pNtkNew->ntkFunc == pObj->pNtk->ntkFunc )
375 {
376 if ( Abc_NtkIsStrash(pNtkNew) )
377 {}
378 else if ( Abc_NtkHasSop(pNtkNew) || Abc_NtkHasBlifMv(pNtkNew) )
379 pObjNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, (char *)pObj->pData );
380#ifdef ABC_USE_CUDD
381 else if ( Abc_NtkHasBdd(pNtkNew) )
382 pObjNew->pData = Cudd_bddTransfer((DdManager *)pObj->pNtk->pManFunc, (DdManager *)pNtkNew->pManFunc, (DdNode *)pObj->pData), Cudd_Ref((DdNode *)pObjNew->pData);
383#endif
384 else if ( Abc_NtkHasAig(pNtkNew) )
385 pObjNew->pData = Hop_Transfer((Hop_Man_t *)pObj->pNtk->pManFunc, (Hop_Man_t *)pNtkNew->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj));
386 else if ( Abc_NtkHasMapping(pNtkNew) )
387 pObjNew->pData = pObj->pData, pNtkNew->nBarBufs2 += !pObj->pData;
388 else assert( 0 );
389 }
390 }
391 else if ( Abc_ObjIsNet(pObj) ) // copy the name
392 {
393 }
394 else if ( Abc_ObjIsLatch(pObj) ) // copy the reset value
395 pObjNew->pData = pObj->pData;
396 pObjNew->fPersist = pObj->fPersist;
397 // transfer HAIG
398// pObjNew->pEquiv = pObj->pEquiv;
399 // remember the new node in the old node
400 pObj->pCopy = pObjNew;
401 return pObjNew;
402}
403
415Abc_Obj_t * Abc_NtkDupBox( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pBox, int fCopyName )
416{
417 Abc_Obj_t * pTerm, * pBoxNew;
418 int i;
419 assert( Abc_ObjIsBox(pBox) );
420 // duplicate the box
421 pBoxNew = Abc_NtkDupObj( pNtkNew, pBox, fCopyName );
422 // duplicate the fanins and connect them
423 Abc_ObjForEachFanin( pBox, pTerm, i )
424 Abc_ObjAddFanin( pBoxNew, Abc_NtkDupObj(pNtkNew, pTerm, fCopyName) );
425 // duplicate the fanouts and connect them
426 Abc_ObjForEachFanout( pBox, pTerm, i )
427 Abc_ObjAddFanin( Abc_NtkDupObj(pNtkNew, pTerm, fCopyName), pBoxNew );
428 return pBoxNew;
429}
430
443{
444 Abc_Obj_t * pClone, * pFanin;
445 int i;
446 pClone = Abc_NtkCreateObj( pObj->pNtk, (Abc_ObjType_t)pObj->Type );
447 Abc_ObjForEachFanin( pObj, pFanin, i )
448 Abc_ObjAddFanin( pClone, pFanin );
449 return pClone;
450}
451
452
464Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
465{
466 Abc_Obj_t * pObj;
467 int Num;
468 // try to find the terminal
469 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
470 if ( Num >= 0 )
471 return Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
472 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
473 if ( Num >= 0 )
474 return Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
475 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NODE );
476 if ( Num >= 0 )
477 return Abc_NtkObj( pNtk, Num );
478 // find the internal node
479 if ( pName[0] != 'n' )
480 {
481 printf( "Name \"%s\" is not found among CO or node names (internal names often look as \"n<num>\").\n", pName );
482 return NULL;
483 }
484 Num = atoi( pName + 1 );
485 if ( Num < 0 || Num >= Abc_NtkObjNumMax(pNtk) )
486 {
487 printf( "The node \"%s\" with ID %d is not in the current network.\n", pName, Num );
488 return NULL;
489 }
490 pObj = Abc_NtkObj( pNtk, Num );
491 if ( pObj == NULL )
492 {
493 printf( "The node \"%s\" with ID %d has been removed from the current network.\n", pName, Num );
494 return NULL;
495 }
496 if ( !Abc_ObjIsNode(pObj) )
497 {
498 printf( "Object with ID %d is not a node.\n", Num );
499 return NULL;
500 }
501 return pObj;
502}
503
515Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName )
516{
517 Abc_Obj_t * pNet;
518 int ObjId;
519 assert( Abc_NtkIsNetlist(pNtk) );
520 ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NET );
521 if ( ObjId == -1 )
522 return NULL;
523 pNet = Abc_NtkObj( pNtk, ObjId );
524 return pNet;
525}
526
538Abc_Obj_t * Abc_NtkFindCi( Abc_Ntk_t * pNtk, char * pName )
539{
540 int Num;
541 assert( !Abc_NtkIsNetlist(pNtk) );
542 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PI );
543 if ( Num >= 0 )
544 return Abc_NtkObj( pNtk, Num );
545 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
546 if ( Num >= 0 )
547 return Abc_NtkObj( pNtk, Num );
548 return NULL;
549}
550
562Abc_Obj_t * Abc_NtkFindCo( Abc_Ntk_t * pNtk, char * pName )
563{
564 int Num;
565 assert( !Abc_NtkIsNetlist(pNtk) );
566 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
567 if ( Num >= 0 )
568 return Abc_NtkObj( pNtk, Num );
569 Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
570 if ( Num >= 0 )
571 return Abc_NtkObj( pNtk, Num );
572 return NULL;
573}
574
575
588{
589 Abc_Obj_t * pNet;
590 assert( Abc_NtkIsNetlist(pNtk) );
591 if ( pName && (pNet = Abc_NtkFindNet( pNtk, pName )) )
592 return pNet;
593//printf( "Creating net %s.\n", pName );
594 // create a new net
595 pNet = Abc_NtkCreateNet( pNtk );
596 if ( pName )
597 Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pNet->Type, pName, NULL );
598 return pNet;
599}
600
613{
614 Abc_Obj_t * pNode;
615 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
616 pNode = Abc_NtkCreateNode( pNtk );
617 if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
618 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 0\n" );
619#ifdef ABC_USE_CUDD
620 else if ( Abc_NtkHasBdd(pNtk) )
621 pNode->pData = Cudd_ReadLogicZero((DdManager *)pNtk->pManFunc), Cudd_Ref( (DdNode *)pNode->pData );
622#endif
623 else if ( Abc_NtkHasAig(pNtk) )
624 pNode->pData = Hop_ManConst0((Hop_Man_t *)pNtk->pManFunc);
625 else if ( Abc_NtkHasMapping(pNtk) )
627 else if ( !Abc_NtkHasBlackbox(pNtk) )
628 assert( 0 );
629 return pNode;
630}
631
644{
645 Abc_Obj_t * pNode;
646 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
647 pNode = Abc_NtkCreateNode( pNtk );
648 if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
649 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 1\n" );
650#ifdef ABC_USE_CUDD
651 else if ( Abc_NtkHasBdd(pNtk) )
652 pNode->pData = Cudd_ReadOne((DdManager *)pNtk->pManFunc), Cudd_Ref( (DdNode *)pNode->pData );
653#endif
654 else if ( Abc_NtkHasAig(pNtk) )
655 pNode->pData = Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc);
656 else if ( Abc_NtkHasMapping(pNtk) )
658 else if ( !Abc_NtkHasBlackbox(pNtk) )
659 assert( 0 );
660 return pNode;
661}
662
675{
676 Abc_Obj_t * pNode;
677 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
678 pNode = Abc_NtkCreateNode( pNtk );
679 if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
680 if ( Abc_NtkHasSop(pNtk) )
681 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, "0 1\n" );
682#ifdef ABC_USE_CUDD
683 else if ( Abc_NtkHasBdd(pNtk) )
684 pNode->pData = Cudd_Not(Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0)), Cudd_Ref( (DdNode *)pNode->pData );
685#endif
686 else if ( Abc_NtkHasAig(pNtk) )
687 pNode->pData = Hop_Not(Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0));
688 else if ( Abc_NtkHasMapping(pNtk) )
690 else
691 assert( 0 );
692 return pNode;
693}
694
707{
708 Abc_Obj_t * pNode;
709 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
710 pNode = Abc_NtkCreateNode( pNtk );
711 if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
712 if ( Abc_NtkHasSop(pNtk) )
713 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, "1 1\n" );
714#ifdef ABC_USE_CUDD
715 else if ( Abc_NtkHasBdd(pNtk) )
716 pNode->pData = Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0), Cudd_Ref( (DdNode *)pNode->pData );
717#endif
718 else if ( Abc_NtkHasAig(pNtk) )
719 pNode->pData = Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0);
720 else if ( Abc_NtkHasMapping(pNtk) )
722 else
723 assert( 0 );
724 return pNode;
725}
726
739{
740 Abc_Obj_t * pNode;
741 int i;
742 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
743 pNode = Abc_NtkCreateNode( pNtk );
744 for ( i = 0; i < vFanins->nSize; i++ )
745 Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
746 if ( Abc_NtkHasSop(pNtk) )
747 pNode->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
748#ifdef ABC_USE_CUDD
749 else if ( Abc_NtkHasBdd(pNtk) )
750 pNode->pData = Extra_bddCreateAnd( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
751#endif
752 else if ( Abc_NtkHasAig(pNtk) )
753 pNode->pData = Hop_CreateAnd( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
754 else
755 assert( 0 );
756 return pNode;
757}
758
771{
772 Abc_Obj_t * pNode;
773 int i;
774 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
775 pNode = Abc_NtkCreateNode( pNtk );
776 for ( i = 0; i < vFanins->nSize; i++ )
777 Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
778 if ( Abc_NtkHasSop(pNtk) )
779 pNode->pData = Abc_SopCreateOr( (Mem_Flex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
780#ifdef ABC_USE_CUDD
781 else if ( Abc_NtkHasBdd(pNtk) )
782 pNode->pData = Extra_bddCreateOr( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
783#endif
784 else if ( Abc_NtkHasAig(pNtk) )
785 pNode->pData = Hop_CreateOr( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
786 else
787 assert( 0 );
788 return pNode;
789}
790
803{
804 Abc_Obj_t * pNode;
805 int i;
806 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
807 pNode = Abc_NtkCreateNode( pNtk );
808 for ( i = 0; i < vFanins->nSize; i++ )
809 Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
810 if ( Abc_NtkHasSop(pNtk) )
811 pNode->pData = Abc_SopCreateXorSpecial( (Mem_Flex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
812#ifdef ABC_USE_CUDD
813 else if ( Abc_NtkHasBdd(pNtk) )
814 pNode->pData = Extra_bddCreateExor( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
815#endif
816 else if ( Abc_NtkHasAig(pNtk) )
817 pNode->pData = Hop_CreateExor( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
818 else
819 assert( 0 );
820 return pNode;
821}
822
834Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 )
835{
836 Abc_Obj_t * pNode;
837 assert( Abc_NtkIsLogic(pNtk) );
838 pNode = Abc_NtkCreateNode( pNtk );
839 Abc_ObjAddFanin( pNode, pNodeC );
840 Abc_ObjAddFanin( pNode, pNode1 );
841 Abc_ObjAddFanin( pNode, pNode0 );
842 if ( Abc_NtkHasSop(pNtk) )
843 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, "11- 1\n0-1 1\n" );
844#ifdef ABC_USE_CUDD
845 else if ( Abc_NtkHasBdd(pNtk) )
846 pNode->pData = Cudd_bddIte((DdManager *)pNtk->pManFunc,Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,1),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,2)), Cudd_Ref( (DdNode *)pNode->pData );
847#endif
848 else if ( Abc_NtkHasAig(pNtk) )
850 else
851 assert( 0 );
852 return pNode;
853}
854
855
868{
869 assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
870 return Abc_ObjIsNode(pNode) && Abc_ObjFaninNum(pNode) == 0;
871}
872
885{
886 Abc_Ntk_t * pNtk = pNode->pNtk;
887 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
888 assert( Abc_ObjIsNode(pNode) );
889 if ( !Abc_NodeIsConst(pNode) )
890 return 0;
891 if ( Abc_NtkHasSop(pNtk) )
892 return Abc_SopIsConst0((char *)pNode->pData);
893#ifdef ABC_USE_CUDD
894 if ( Abc_NtkHasBdd(pNtk) )
895 return Cudd_IsComplement(pNode->pData);
896#endif
897 if ( Abc_NtkHasAig(pNtk) )
898 return Hop_IsComplement((Hop_Obj_t *)pNode->pData)? 1:0;
899 if ( Abc_NtkHasMapping(pNtk) )
901 assert( 0 );
902 return 0;
903}
904
917{
918 Abc_Ntk_t * pNtk = pNode->pNtk;
919 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
920 assert( Abc_ObjIsNode(pNode) );
921 if ( !Abc_NodeIsConst(pNode) )
922 return 0;
923 if ( Abc_NtkHasSop(pNtk) )
924 return Abc_SopIsConst1((char *)pNode->pData);
925#ifdef ABC_USE_CUDD
926 if ( Abc_NtkHasBdd(pNtk) )
927 return !Cudd_IsComplement(pNode->pData);
928#endif
929 if ( Abc_NtkHasAig(pNtk) )
930 return !Hop_IsComplement((Hop_Obj_t *)pNode->pData);
931 if ( Abc_NtkHasMapping(pNtk) )
933 assert( 0 );
934 return 0;
935}
936
949{
950 Abc_Ntk_t * pNtk = pNode->pNtk;
951 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
952 assert( Abc_ObjIsNode(pNode) );
953 if ( Abc_ObjFaninNum(pNode) != 1 )
954 return 0;
955 if ( Abc_NtkHasSop(pNtk) )
956 return Abc_SopIsBuf((char *)pNode->pData);
957#ifdef ABC_USE_CUDD
958 if ( Abc_NtkHasBdd(pNtk) )
959 return !Cudd_IsComplement(pNode->pData);
960#endif
961 if ( Abc_NtkHasAig(pNtk) )
962 return !Hop_IsComplement((Hop_Obj_t *)pNode->pData);
963 if ( Abc_NtkHasMapping(pNtk) )
965 assert( 0 );
966 return 0;
967}
968
981{
982 Abc_Ntk_t * pNtk = pNode->pNtk;
983 assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
984 assert( Abc_ObjIsNode(pNode) );
985 if ( Abc_ObjFaninNum(pNode) != 1 )
986 return 0;
987 if ( Abc_NtkHasSop(pNtk) )
988 return Abc_SopIsInv((char *)pNode->pData);
989#ifdef ABC_USE_CUDD
990 if ( Abc_NtkHasBdd(pNtk) )
991 return Cudd_IsComplement(pNode->pData);
992#endif
993 if ( Abc_NtkHasAig(pNtk) )
994 return Hop_IsComplement((Hop_Obj_t *)pNode->pData)? 1:0;
995 if ( Abc_NtkHasMapping(pNtk) )
997 assert( 0 );
998 return 0;
999}
1000
1013{
1014 assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
1015 assert( Abc_ObjIsNode(pNode) );
1016 if ( Abc_NtkHasSop(pNode->pNtk) )
1017 Abc_SopComplement( (char *)pNode->pData );
1018 else if ( Abc_NtkHasAig(pNode->pNtk) )
1019 pNode->pData = Hop_Not( (Hop_Obj_t *)pNode->pData );
1020#ifdef ABC_USE_CUDD
1021 else if ( Abc_NtkHasBdd(pNode->pNtk) )
1022 pNode->pData = Cudd_Not( pNode->pData );
1023#endif
1024 else
1025 assert( 0 );
1026}
1027
1040{
1041 int iFanin;
1042 if ( (iFanin = Vec_IntFind( &pNode->vFanins, pFanin->Id )) == -1 )
1043 {
1044 printf( "Node %s should be among", Abc_ObjName(pFanin) );
1045 printf( " the fanins of node %s...\n", Abc_ObjName(pNode) );
1046 return;
1047 }
1048 if ( Abc_NtkHasSop(pNode->pNtk) )
1049 Abc_SopComplementVar( (char *)pNode->pData, iFanin );
1050 else if ( Abc_NtkHasAig(pNode->pNtk) )
1051 pNode->pData = Hop_Complement( (Hop_Man_t *)pNode->pNtk->pManFunc, (Hop_Obj_t *)pNode->pData, iFanin );
1052#ifdef ABC_USE_CUDD
1053 else if ( Abc_NtkHasBdd(pNode->pNtk) )
1054 {
1055 DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
1056 DdNode * bVar, * bCof0, * bCof1;
1057 bVar = Cudd_bddIthVar( dd, iFanin );
1058 bCof0 = Cudd_Cofactor( dd, (DdNode *)pNode->pData, Cudd_Not(bVar) ); Cudd_Ref( bCof0 );
1059 bCof1 = Cudd_Cofactor( dd, (DdNode *)pNode->pData, bVar ); Cudd_Ref( bCof1 );
1060 Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
1061 pNode->pData = Cudd_bddIte( dd, bVar, bCof0, bCof1 ); Cudd_Ref( (DdNode *)pNode->pData );
1062 Cudd_RecursiveDeref( dd, bCof0 );
1063 Cudd_RecursiveDeref( dd, bCof1 );
1064 }
1065#endif
1066 else
1067 assert( 0 );
1068}
1069
1070
1074
1076
Abc_Obj_t * Abc_NtkFindCi(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:538
int Abc_NodeIsConst1(Abc_Obj_t *pNode)
Definition abcObj.c:916
Abc_Obj_t * Abc_NtkCreateNodeAnd(Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Definition abcObj.c:738
Abc_Obj_t * Abc_NtkFindNode(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:464
Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:587
Abc_Obj_t * Abc_NtkCreateNodeMux(Abc_Ntk_t *pNtk, Abc_Obj_t *pNodeC, Abc_Obj_t *pNode1, Abc_Obj_t *pNode0)
Definition abcObj.c:834
Abc_Obj_t * Abc_NtkCreateNodeExor(Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Definition abcObj.c:802
Abc_Obj_t * Abc_NtkCreateObj(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
Definition abcObj.c:109
Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:515
Abc_Obj_t * Abc_NtkDupBox(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
Definition abcObj.c:415
int Abc_NodeIsBuf(Abc_Obj_t *pNode)
Definition abcObj.c:948
int Abc_NodeIsConst0(Abc_Obj_t *pNode)
Definition abcObj.c:884
void Abc_NtkDeleteAll_rec(Abc_Obj_t *pObj)
Definition abcObj.c:315
Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
Abc_Obj_t * Abc_NtkCreateNodeOr(Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Definition abcObj.c:770
int Abc_NodeIsInv(Abc_Obj_t *pNode)
Definition abcObj.c:980
void Abc_NtkDeleteObjPo(Abc_Obj_t *pObj)
Definition abcObj.c:249
void Abc_ObjRecycle(Abc_Obj_t *pObj)
Definition abcObj.c:77
Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:706
void Abc_NodeComplementInput(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition abcObj.c:1039
void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_ObjAlloc(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
DECLARATIONS ///.
Definition abcObj.c:52
Abc_Obj_t * Abc_NtkCloneObj(Abc_Obj_t *pObj)
Definition abcObj.c:442
void Abc_NodeComplement(Abc_Obj_t *pNode)
Definition abcObj.c:1012
Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition abcObj.c:342
int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition abcObj.c:867
Abc_Obj_t * Abc_NtkFindCo(Abc_Ntk_t *pNtk, char *pName)
Definition abcObj.c:562
Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:674
Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
void Abc_NtkDeleteObj_rec(Abc_Obj_t *pObj, int fOnlyNodes)
Definition abcObj.c:278
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL char * Abc_SopCreateXorSpecial(Mem_Flex_t *pMan, int nVars)
Definition abcSop.c:297
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL int Abc_SopIsConst0(char *pSop)
Definition abcSop.c:724
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
Abc_ObjType_t
Definition abc.h:86
@ ABC_OBJ_NET
Definition abc.h:93
@ ABC_OBJ_NONE
Definition abc.h:87
@ ABC_OBJ_NODE
Definition abc.h:94
@ ABC_OBJ_BLACKBOX
Definition abc.h:97
@ ABC_OBJ_BI
Definition abc.h:91
@ ABC_OBJ_BO
Definition abc.h:92
@ ABC_OBJ_WHITEBOX
Definition abc.h:96
@ ABC_OBJ_PI
Definition abc.h:89
@ ABC_OBJ_LATCH
Definition abc.h:95
@ ABC_OBJ_PO
Definition abc.h:90
@ ABC_OBJ_CONST1
Definition abc.h:88
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:212
ABC_DLL void Abc_SopComplement(char *pSop)
Definition abcSop.c:648
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1647
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
@ ABC_INIT_NONE
Definition abc.h:103
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:168
ABC_DLL void Abc_ObjDeleteFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:111
ABC_DLL void Abc_SopComplementVar(char *pSop, int iVar)
Definition abcSop.c:678
ABC_DLL void Abc_NodeCollectFanins(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1627
ABC_DLL int Abc_SopIsInv(char *pSop)
Definition abcSop.c:776
ABC_DLL int Abc_SopIsBuf(char *pSop)
Definition abcSop.c:756
ABC_DLL int Abc_SopIsConst1(char *pSop)
Definition abcSop.c:740
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
DdNode * Extra_bddCreateOr(DdManager *dd, int nVars)
DdNode * Extra_bddCreateAnd(DdManager *dd, int nVars)
DdNode * Extra_bddCreateExor(DdManager *dd, int nVars)
Hop_Obj_t * Hop_Transfer(Hop_Man_t *pSour, Hop_Man_t *pDest, Hop_Obj_t *pObj, int nVars)
Definition hopDfs.c:353
Hop_Obj_t * Hop_CreateOr(Hop_Man_t *p, int nVars)
Definition hopOper.c:341
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
Hop_Obj_t * Hop_Complement(Hop_Man_t *p, Hop_Obj_t *pRoot, int iVar)
Definition hopDfs.c:469
Hop_Obj_t * Hop_CreateAnd(Hop_Man_t *p, int nVars)
Definition hopOper.c:320
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition hopOper.c:63
Hop_Obj_t * Hop_CreateExor(Hop_Man_t *p, int nVars)
Definition hopOper.c:362
Hop_Obj_t * Hop_Mux(Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
Definition hopOper.c:187
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
char * Mem_FixedEntryFetch(Mem_Fixed_t *p)
Definition mem.c:184
void Mem_FixedEntryRecycle(Mem_Fixed_t *p, char *pEntry)
Definition mem.c:235
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
Definition mioApi.c:51
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
Definition mioApi.c:52
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition mioApi.c:50
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition mioApi.c:49
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)
Definition nmApi.c:199
void Nm_ManDeleteIdName(Nm_Man_t *p, int ObjId)
Definition nmApi.c:149
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
Definition nmApi.c:219
char * Nm_ManStoreIdName(Nm_Man_t *p, int ObjId, int Type, char *pName, char *pSuffix)
Definition nmApi.c:112
Vec_Ptr_t * vCis
Definition abc.h:165
Vec_Ptr_t * vCos
Definition abc.h:166
Vec_Ptr_t * vPos
Definition abc.h:164
Vec_Ptr_t * vBoxes
Definition abc.h:168
int nObjs
Definition abc.h:172
Mem_Step_t * pMmStep
Definition abc.h:190
int nObjCounts[ABC_OBJ_NUMBER]
Definition abc.h:171
void * pManFunc
Definition abc.h:191
Mem_Fixed_t * pMmObj
Definition abc.h:189
Nm_Man_t * pManName
Definition abc.h:160
Vec_Ptr_t * vPis
Definition abc.h:163
int nBarBufs2
Definition abc.h:175
Vec_Ptr_t * vObjs
Definition abc.h:162
Abc_NtkFunc_t ntkFunc
Definition abc.h:157
void * pData
Definition abc.h:145
Vec_Int_t vFanins
Definition abc.h:143
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
Vec_Int_t vFanouts
Definition abc.h:144
Abc_Obj_t * pCopy
Definition abc.h:148
unsigned Type
Definition abc.h:133
unsigned fPersist
Definition abc.h:139
#define assert(ex)
Definition util_old.h:213
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55