ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcDsd.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22
23#ifdef ABC_USE_CUDD
24#include "bdd/extrab/extraBdd.h"
25#include "bdd/dsd/dsd.h"
26#endif
27
29
30
34
35#ifdef ABC_USE_CUDD
36
37static Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort );
38static void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
39static Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNodeDsd, Abc_Ntk_t * pNtkNew, int * pCounters );
40
41static Vec_Ptr_t * Abc_NtkCollectNodesForDsd( Abc_Ntk_t * pNtk );
42static void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager_t * pManDsd, int fRecursive, int * pCounters );
43static int Abc_NodeIsForDsd( Abc_Obj_t * pNode );
44static int Abc_NodeFindMuxVar( DdManager * dd, DdNode * bFunc, int nVars );
45
49
65Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort )
66{
67 DdManager * dd;
68 Abc_Ntk_t * pNtkNew;
69 assert( Abc_NtkIsStrash(pNtk) );
70 dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, 0, fVerbose );
71 if ( dd == NULL )
72 return NULL;
73 if ( fVerbose )
74 printf( "Shared BDD size = %6d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
75 // transform the result of mapping into a BDD network
76 pNtkNew = Abc_NtkDsdInternal( pNtk, fVerbose, fPrint, fShort );
78 if ( pNtkNew == NULL )
79 return NULL;
80 // copy EXDC network
81 if ( pNtk->pExdc )
82 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
83 if ( !Abc_NtkCheck( pNtkNew ) )
84 {
85 printf( "Abc_NtkDsdGlobal: The network check has failed.\n" );
86 Abc_NtkDelete( pNtkNew );
87 return NULL;
88 }
89 return pNtkNew;
90}
91
103Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort )
104{
105 char ** ppNamesCi, ** ppNamesCo;
106 Vec_Ptr_t * vFuncsGlob;
107 Dsd_Manager_t * pManDsd;
108 Abc_Ntk_t * pNtkNew;
109 DdManager * dd;
110 Abc_Obj_t * pObj;
111 int i;
112
113 // complement the global functions
114 vFuncsGlob = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
115 Abc_NtkForEachCo( pNtk, pObj, i )
116 Vec_PtrPush( vFuncsGlob, Cudd_NotCond(Abc_ObjGlobalBdd(pObj), Abc_ObjFaninC0(pObj)) );
117
118 // perform the decomposition
119 dd = (DdManager *)Abc_NtkGlobalBddMan(pNtk);
120 pManDsd = Dsd_ManagerStart( dd, Abc_NtkCiNum(pNtk), fVerbose );
121 if ( pManDsd == NULL )
122 {
123 Vec_PtrFree( vFuncsGlob );
124 Cudd_Quit( dd );
125 return NULL;
126 }
127 Dsd_Decompose( pManDsd, (DdNode **)vFuncsGlob->pArray, Abc_NtkCoNum(pNtk) );
128 Vec_PtrFree( vFuncsGlob );
129 Abc_NtkFreeGlobalBdds( pNtk, 0 );
130
131 // start the new network
132 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
133 // make sure the new manager has enough inputs
134 Cudd_bddIthVar( (DdManager *)pNtkNew->pManFunc, dd->size-1 );
135 // put the results into the new network (save new CO drivers in old CO drivers)
136 Abc_NtkDsdConstruct( pManDsd, pNtk, pNtkNew );
137 // finalize the new network
138 Abc_NtkFinalize( pNtk, pNtkNew );
139 // fix the problem with complemented and duplicated CO edges
140 Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
141 if ( fPrint )
142 {
143 ppNamesCi = Abc_NtkCollectCioNames( pNtk, 0 );
144 ppNamesCo = Abc_NtkCollectCioNames( pNtk, 1 );
145 if ( fVerbose )
146 Dsd_TreePrint( stdout, pManDsd, ppNamesCi, ppNamesCo, fShort, -1, 0 );
147 else
148 Dsd_TreePrint2( stdout, pManDsd, ppNamesCi, ppNamesCo, -1 );
149 ABC_FREE( ppNamesCi );
150 ABC_FREE( ppNamesCo );
151 }
152
153 // stop the DSD manager
154 Dsd_ManagerStop( pManDsd );
155 return pNtkNew;
156}
157
169void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
170{
171 Dsd_Node_t ** ppNodesDsd;
172 Dsd_Node_t * pNodeDsd;
173 Abc_Obj_t * pNode, * pNodeNew, * pDriver;
174 int i, nNodesDsd;
175
176 // save the CI nodes in the DSD nodes
177 Abc_AigConst1(pNtk)->pCopy = pNodeNew = Abc_NtkCreateNodeConst1(pNtkNew);
178 Dsd_NodeSetMark( Dsd_ManagerReadConst1(pManDsd), (word)(ABC_PTRINT_T)pNodeNew );
179 Abc_NtkForEachCi( pNtk, pNode, i )
180 {
181 pNodeDsd = Dsd_ManagerReadInput( pManDsd, i );
182 Dsd_NodeSetMark( pNodeDsd, (word)(ABC_PTRINT_T)pNode->pCopy );
183 }
184
185 // collect DSD nodes in DFS order (leaves and const1 are not collected)
186 ppNodesDsd = Dsd_TreeCollectNodesDfs( pManDsd, &nNodesDsd );
187 for ( i = 0; i < nNodesDsd; i++ )
188 Abc_NtkDsdConstructNode( pManDsd, ppNodesDsd[i], pNtkNew, NULL );
189 ABC_FREE( ppNodesDsd );
190
191 // set the pointers to the CO drivers
192 Abc_NtkForEachCo( pNtk, pNode, i )
193 {
194 pDriver = Abc_ObjFanin0( pNode );
195 if ( !Abc_ObjIsNode(pDriver) )
196 continue;
197 if ( !Abc_AigNodeIsAnd(pDriver) )
198 continue;
199 pNodeDsd = Dsd_ManagerReadRoot( pManDsd, i );
200 pNodeNew = (Abc_Obj_t *)(ABC_PTRINT_T)Dsd_NodeReadMark( Dsd_Regular(pNodeDsd) );
201 assert( !Abc_ObjIsComplement(pNodeNew) );
202 pDriver->pCopy = Abc_ObjNotCond( pNodeNew, Dsd_IsComplement(pNodeDsd) );
203 }
204}
205
217Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNodeDsd, Abc_Ntk_t * pNtkNew, int * pCounters )
218{
219 DdManager * ddDsd = Dsd_ManagerReadDd( pManDsd );
220 DdManager * ddNew = (DdManager *)pNtkNew->pManFunc;
221 Dsd_Node_t * pFaninDsd;
222 Abc_Obj_t * pNodeNew, * pFanin;
223 DdNode * bLocal = NULL, * bTemp, * bVar;
224 Dsd_Type_t Type;
225 int i, nDecs;
226
227 // create the new node
228 pNodeNew = Abc_NtkCreateNode( pNtkNew );
229 // add the fanins
230 Type = Dsd_NodeReadType( pNodeDsd );
231 nDecs = Dsd_NodeReadDecsNum( pNodeDsd );
232 assert( nDecs > 1 );
233 for ( i = 0; i < nDecs; i++ )
234 {
235 pFaninDsd = Dsd_NodeReadDec( pNodeDsd, i );
236 pFanin = (Abc_Obj_t *)(ABC_PTRINT_T)Dsd_NodeReadMark(Dsd_Regular(pFaninDsd));
237 Abc_ObjAddFanin( pNodeNew, pFanin );
238 assert( Type == DSD_NODE_OR || !Dsd_IsComplement(pFaninDsd) );
239 }
240
241 // create the local function depending on the type of the node
242 ddNew = (DdManager *)pNtkNew->pManFunc;
243 switch ( Type )
244 {
245 case DSD_NODE_CONST1:
246 {
247 bLocal = ddNew->one; Cudd_Ref( bLocal );
248 break;
249 }
250 case DSD_NODE_OR:
251 {
252 bLocal = Cudd_Not(ddNew->one); Cudd_Ref( bLocal );
253 for ( i = 0; i < nDecs; i++ )
254 {
255 pFaninDsd = Dsd_NodeReadDec( pNodeDsd, i );
256 bVar = Cudd_NotCond( ddNew->vars[i], Dsd_IsComplement(pFaninDsd) );
257 bLocal = Cudd_bddOr( ddNew, bTemp = bLocal, bVar ); Cudd_Ref( bLocal );
258 Cudd_RecursiveDeref( ddNew, bTemp );
259 }
260 break;
261 }
262 case DSD_NODE_EXOR:
263 {
264 bLocal = Cudd_Not(ddNew->one); Cudd_Ref( bLocal );
265 for ( i = 0; i < nDecs; i++ )
266 {
267 bLocal = Cudd_bddXor( ddNew, bTemp = bLocal, ddNew->vars[i] ); Cudd_Ref( bLocal );
268 Cudd_RecursiveDeref( ddNew, bTemp );
269 }
270 break;
271 }
272 case DSD_NODE_PRIME:
273 {
274 if ( pCounters )
275 {
276 if ( nDecs < 10 )
277 pCounters[nDecs]++;
278 else
279 pCounters[10]++;
280 }
281 bLocal = Dsd_TreeGetPrimeFunction( ddDsd, pNodeDsd ); Cudd_Ref( bLocal );
282 bLocal = Extra_TransferLevelByLevel( ddDsd, ddNew, bTemp = bLocal ); Cudd_Ref( bLocal );
283/*
284if ( nDecs == 3 )
285{
286Extra_bddPrint( ddDsd, bTemp );
287printf( "\n" );
288}
289*/
290 Cudd_RecursiveDeref( ddDsd, bTemp );
291 // bLocal is now in the new BDD manager
292 break;
293 }
294 default:
295 {
296 assert( 0 );
297 break;
298 }
299 }
300 pNodeNew->pData = bLocal;
301 Dsd_NodeSetMark( pNodeDsd, (word)(ABC_PTRINT_T)pNodeNew );
302 return pNodeNew;
303}
304
305
306
307
308
309
321int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, int fVerbose, int fRecursive )
322{
323 Dsd_Manager_t * pManDsd;
324 DdManager * dd = (DdManager *)pNtk->pManFunc;
325 Vec_Ptr_t * vNodes;
326 int i;
327 int pCounters[11] = {0};
328
329 assert( Abc_NtkIsBddLogic(pNtk) );
330
331 // make the network minimum base
332 Abc_NtkMinimumBase( pNtk );
333
334 // start the DSD manager
335 pManDsd = Dsd_ManagerStart( dd, dd->size, 0 );
336
337 // collect nodes for decomposition
338 vNodes = Abc_NtkCollectNodesForDsd( pNtk );
339 for ( i = 0; i < vNodes->nSize; i++ )
340 Abc_NodeDecompDsdAndMux( (Abc_Obj_t *)vNodes->pArray[i], vNodes, pManDsd, fRecursive, pCounters );
341 Vec_PtrFree( vNodes );
342
343 if ( fVerbose )
344 {
345 printf( "Number of non-decomposable functions:\n" );
346 for ( i = 3; i < 10; i++ )
347 printf( "Inputs = %d. Functions = %6d.\n", i, pCounters[i] );
348 printf( "Inputs > %d. Functions = %6d.\n", 9, pCounters[10] );
349 }
350
351 // stop the DSD manager
352 Dsd_ManagerStop( pManDsd );
353
354 // make sure everything is okay
355 if ( !Abc_NtkCheck( pNtk ) )
356 {
357 printf( "Abc_NtkDsdRecursive: The network check has failed.\n" );
358 return 0;
359 }
360 return 1;
361}
362
375Vec_Ptr_t * Abc_NtkCollectNodesForDsd( Abc_Ntk_t * pNtk )
376{
377 Vec_Ptr_t * vNodes;
378 Abc_Obj_t * pNode;
379 int i;
380 vNodes = Vec_PtrAlloc( 100 );
381 Abc_NtkForEachNode( pNtk, pNode, i )
382 {
383 if ( Abc_NodeIsForDsd(pNode) )
384 Vec_PtrPush( vNodes, pNode );
385 }
386 return vNodes;
387}
388
400void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager_t * pManDsd, int fRecursive, int * pCounters )
401{
402 DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
403 Abc_Obj_t * pRoot = NULL, * pFanin, * pNode1, * pNode2, * pNodeC;
404 Dsd_Node_t ** ppNodesDsd, * pNodeDsd, * pFaninDsd;
405 int i, nNodesDsd, iVar, fCompl;
406
407 // try disjoint support decomposition
408 pNodeDsd = Dsd_DecomposeOne( pManDsd, (DdNode *)pNode->pData );
409 fCompl = Dsd_IsComplement( pNodeDsd );
410 pNodeDsd = Dsd_Regular( pNodeDsd );
411
412 // determine what decomposition to use
413 if ( !fRecursive || Dsd_NodeReadDecsNum(pNodeDsd) != Abc_ObjFaninNum(pNode) )
414 { // perform DSD
415
416 // set the inputs
417 Abc_ObjForEachFanin( pNode, pFanin, i )
418 {
419 pFaninDsd = Dsd_ManagerReadInput( pManDsd, i );
420 Dsd_NodeSetMark( pFaninDsd, (word)(ABC_PTRINT_T)pFanin );
421 }
422
423 // construct the intermediate nodes
424 ppNodesDsd = Dsd_TreeCollectNodesDfsOne( pManDsd, pNodeDsd, &nNodesDsd );
425 for ( i = 0; i < nNodesDsd; i++ )
426 {
427 pRoot = Abc_NtkDsdConstructNode( pManDsd, ppNodesDsd[i], pNode->pNtk, pCounters );
428 if ( Abc_NodeIsForDsd(pRoot) && fRecursive )
429 Vec_PtrPush( vNodes, pRoot );
430 }
431 ABC_FREE( ppNodesDsd );
432 assert(pRoot);
433
434 // remove the current fanins
435 Abc_ObjRemoveFanins( pNode );
436 // add fanin to the root
437 Abc_ObjAddFanin( pNode, pRoot );
438 // update the function to be that of buffer
439 Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
440 pNode->pData = Cudd_NotCond( (DdNode *)dd->vars[0], fCompl ); Cudd_Ref( (DdNode *)pNode->pData );
441 }
442 else // perform MUX-decomposition
443 {
444 // get the cofactoring variable
445 iVar = Abc_NodeFindMuxVar( dd, (DdNode *)pNode->pData, Abc_ObjFaninNum(pNode) );
446 pNodeC = Abc_ObjFanin( pNode, iVar );
447
448 // get the negative cofactor
449 pNode1 = Abc_NtkCloneObj( pNode );
450 pNode1->pData = Cudd_Cofactor( dd, (DdNode *)pNode->pData, Cudd_Not(dd->vars[iVar]) ); Cudd_Ref( (DdNode *)pNode1->pData );
451 Abc_NodeMinimumBase( pNode1 );
452 if ( Abc_NodeIsForDsd(pNode1) )
453 Vec_PtrPush( vNodes, pNode1 );
454
455 // get the positive cofactor
456 pNode2 = Abc_NtkCloneObj( pNode );
457 pNode2->pData = Cudd_Cofactor( dd, (DdNode *)pNode->pData, dd->vars[iVar] ); Cudd_Ref( (DdNode *)pNode2->pData );
458 Abc_NodeMinimumBase( pNode2 );
459 if ( Abc_NodeIsForDsd(pNode2) )
460 Vec_PtrPush( vNodes, pNode2 );
461
462 // remove the current fanins
463 Abc_ObjRemoveFanins( pNode );
464 // add new fanins
465 Abc_ObjAddFanin( pNode, pNodeC );
466 Abc_ObjAddFanin( pNode, pNode2 );
467 Abc_ObjAddFanin( pNode, pNode1 );
468 // update the function to be that of MUX
469 Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
470 pNode->pData = Cudd_bddIte( dd, dd->vars[0], dd->vars[1], dd->vars[2] ); Cudd_Ref( (DdNode *)pNode->pData );
471 }
472}
473
485int Abc_NodeIsForDsd( Abc_Obj_t * pNode )
486{
487// DdManager * dd = pNode->pNtk->pManFunc;
488// DdNode * bFunc, * bFunc0, * bFunc1;
489 assert( Abc_ObjIsNode(pNode) );
490// if ( Cudd_DagSize(pNode->pData)-1 > Abc_ObjFaninNum(pNode) )
491// return 1;
492// return 0;
493
494/*
495 // this does not catch things like a(b+c), which should be decomposed
496 for ( bFunc = Cudd_Regular(pNode->pData); !cuddIsConstant(bFunc); )
497 {
498 bFunc0 = Cudd_Regular( cuddE(bFunc) );
499 bFunc1 = cuddT(bFunc);
500 if ( bFunc0 == b1 )
501 bFunc = bFunc1;
502 else if ( bFunc1 == b1 || bFunc0 == bFunc1 )
503 bFunc = bFunc0;
504 else
505 return 1;
506 }
507*/
508 if ( Abc_ObjFaninNum(pNode) > 2 )
509 return 1;
510 return 0;
511}
512
524int Abc_NodeFindMuxVar( DdManager * dd, DdNode * bFunc, int nVars )
525{
526 DdNode * bVar, * bCof0, * bCof1;
527 int SuppSumMin = 1000000;
528 int i, nSSD, nSSQ, iVar;
529
530// printf( "\n\nCofactors:\n\n" );
531 iVar = -1;
532 for ( i = 0; i < nVars; i++ )
533 {
534 bVar = dd->vars[i];
535
536 bCof0 = Cudd_Cofactor( dd, bFunc, Cudd_Not(bVar) ); Cudd_Ref( bCof0 );
537 bCof1 = Cudd_Cofactor( dd, bFunc, bVar ); Cudd_Ref( bCof1 );
538
539// nodD = Cudd_DagSize(bCof0);
540// nodQ = Cudd_DagSize(bCof1);
541// printf( "+%02d: D=%2d. Q=%2d. ", i, nodD, nodQ );
542// printf( "S=%2d. D=%2d. ", nodD + nodQ, abs(nodD-nodQ) );
543
544 nSSD = Cudd_SupportSize( dd, bCof0 );
545 nSSQ = Cudd_SupportSize( dd, bCof1 );
546
547// printf( "SD=%2d. SQ=%2d. ", nSSD, nSSQ );
548// printf( "S=%2d. D=%2d. ", nSSD + nSSQ, abs(nSSD - nSSQ) );
549// printf( "Cost=%3d. ", Cost(nodD,nodQ,nSSD,nSSQ) );
550// printf( "\n" );
551
552 Cudd_RecursiveDeref( dd, bCof0 );
553 Cudd_RecursiveDeref( dd, bCof1 );
554
555 if ( SuppSumMin > nSSD + nSSQ )
556 {
557 SuppSumMin = nSSD + nSSQ;
558 iVar = i;
559 }
560 }
561 return iVar;
562}
563
564
576DdNode * Extra_bddComputeSum( DdManager * dd, DdNode ** pbCubes, int nCubes )
577{
578 DdNode * bRes, * bTemp;
579 int i;
580 bRes = b0; Cudd_Ref( bRes );
581 for ( i = 0; i < nCubes; i++ )
582 {
583 bRes = Cudd_bddOr( dd, bTemp = bRes, pbCubes[i] ); Cudd_Ref( bRes );
584 Cudd_RecursiveDeref( dd, bTemp );
585 }
586 Cudd_Deref( bRes );
587 return bRes;
588}
589
601DdNode * Abc_NtkSparsifyInternalOne( DdManager * ddNew, DdNode * bFunc, int nFanins, int nPerc )
602{
603 int nSpace = (int)Cudd_CountMinterm( ddNew, bFunc, nFanins );
604 int i, nMints = Abc_MaxInt( 1, (int)(0.01 * nPerc * nSpace) );
605 DdNode ** pbMints = Cudd_bddPickArbitraryMinterms( ddNew, bFunc, ddNew->vars, nFanins, nMints );
606 DdNode * bRes;
607 for ( i = 0; i < nMints; i++ )
608 Cudd_Ref( pbMints[i] );
609 bRes = Extra_bddComputeSum( ddNew, pbMints, nMints ); Cudd_Ref( bRes );
610 for ( i = 0; i < nMints; i++ )
611 Cudd_RecursiveDeref( ddNew, pbMints[i] );
612 Cudd_Deref( bRes );
613 ABC_FREE( pbMints );
614 return bRes;
615}
616Abc_Ntk_t * Abc_NtkSparsifyInternal( Abc_Ntk_t * pNtk, int nPerc, int fVerbose )
617{
618 Abc_Ntk_t * pNtkNew;
619 Abc_Obj_t * pObj, * pDriver, * pFanin;
620 DdNode * bFunc, * bFuncOld;
621 DdManager * ddNew;
622 int i, k, c;
623 // start the new network
624 pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_BDD, 1 );
625 Abc_NtkForEachCi( pNtk, pObj, i )
626 Abc_NtkDupObj( pNtkNew, pObj, 1 );
627 // duplicate the name and the spec
628 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
629 pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
630 // make sure the new manager has enough inputs
631 ddNew = (DdManager *)pNtkNew->pManFunc;
632 Cudd_bddIthVar( ddNew, Abc_NtkCiNum(pNtk)-1 );
633 // go through the outputs
634 Abc_NtkForEachCo( pNtk, pObj, i )
635 {
636 pDriver = Abc_ObjFanin0( pObj );
637 if ( Abc_ObjIsCi(pDriver) )
638 {
639 Abc_NtkDupObj( pNtkNew, pObj, 0 );
640 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjNotCond(pDriver->pCopy, Abc_ObjFaninC0(pObj)) );
641 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), "_on" );
642
643 Abc_NtkDupObj( pNtkNew, pObj, 0 );
644 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjNotCond(pDriver->pCopy, !Abc_ObjFaninC0(pObj)) );
645 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), "_off" );
646 continue;
647 }
648 if ( Abc_ObjFaninNum(pDriver) == 0 )
649 {
650 Abc_NtkDupObj( pNtkNew, pObj, 0 );
651 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFaninC0(pObj) ? Abc_NtkCreateNodeConst0(pNtkNew) : Abc_NtkCreateNodeConst1(pNtkNew) );
652 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), "_on" );
653
654 Abc_NtkDupObj( pNtkNew, pObj, 0 );
655 Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFaninC0(pObj) ? Abc_NtkCreateNodeConst1(pNtkNew) : Abc_NtkCreateNodeConst0(pNtkNew) );
656 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), "_off" );
657 continue;
658 }
659 assert( Abc_ObjFaninNum(pObj) > 0 );
660 // onset/offset
661 for ( c = 0; c < 2; c++ )
662 {
663 Cudd_Srandom( 0 );
664 Abc_NtkDupObj( pNtkNew, pDriver, 0 );
665 Abc_ObjForEachFanin( pDriver, pFanin, k )
666 Abc_ObjAddFanin( pDriver->pCopy, pFanin->pCopy );
667 bFuncOld = Cudd_NotCond( (DdNode *)pDriver->pCopy->pData, c );
668 bFunc = Abc_NtkSparsifyInternalOne( ddNew, bFuncOld, Abc_ObjFaninNum(pDriver), nPerc ); Cudd_Ref( bFunc );
669 Cudd_RecursiveDeref( ddNew, bFuncOld );
670 pDriver->pCopy->pData = bFunc;
671 Abc_NtkDupObj( pNtkNew, pObj, 0 );
672 Abc_ObjAddFanin( pObj->pCopy, pDriver->pCopy );
673 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), (char*)(c ? "_off" : "_on") );
674 }
675 }
676 Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
677 return pNtkNew;
678}
679Abc_Ntk_t * Abc_NtkSparsify( Abc_Ntk_t * pNtk, int nPerc, int fVerbose )
680{
681 Abc_Ntk_t * pNtkNew;
682 assert( Abc_NtkIsComb(pNtk) );
683 assert( Abc_NtkIsBddLogic(pNtk) );
684 pNtkNew = Abc_NtkSparsifyInternal( pNtk, nPerc, fVerbose );
685 if ( pNtkNew == NULL )
686 return NULL;
687 if ( !Abc_NtkCheck( pNtkNew ) )
688 {
689 printf( "Abc_NtkSparsify: The network check has failed.\n" );
690 Abc_NtkDelete( pNtkNew );
691 return NULL;
692 }
693 return pNtkNew;
694}
695
696#else
697
698Abc_Ntk_t * Abc_NtkSparsify( Abc_Ntk_t * pNtk, int nPerc, int fVerbose ) { return NULL; }
699Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort ) { return NULL; }
700int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, int fVerbose, int fRecursive ) { return 0; }
701
702#endif
703
707
708
710
Abc_Ntk_t * Abc_NtkDsdGlobal(Abc_Ntk_t *pNtk, int fVerbose, int fPrint, int fShort)
Definition abcDsd.c:699
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkSparsify(Abc_Ntk_t *pNtk, int nPerc, int fVerbose)
DECLARATIONS ///.
Definition abcDsd.c:698
int Abc_NtkDsdLocal(Abc_Ntk_t *pNtk, int fVerbose, int fRecursive)
Definition abcDsd.c:700
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition abcObj.c:342
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition abcNtk.c:355
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition abcUtil.c:1080
ABC_DLL void * Abc_NtkBuildGlobalBdds(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fReverse, int fVerbose)
ABC_DLL char ** Abc_NtkCollectCioNames(Abc_Ntk_t *pNtk, int fCollectCos)
Definition abcNames.c:285
ABC_DLL int Abc_NtkMinimumBase(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition abcMinBase.c:892
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
Definition abcFanio.c:141
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Obj_t * Abc_NtkCloneObj(Abc_Obj_t *pNode)
Definition abcObj.c:442
@ ABC_FUNC_BDD
Definition abc.h:66
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:157
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
ABC_DLL int Abc_NodeMinimumBase(Abc_Obj_t *pNode)
Definition abcMinBase.c:893
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define b0
Definition bbrImage.c:96
Dsd_Manager_t * Dsd_ManagerStart(DdManager *dd, int nSuppMax, int fVerbose)
FUNCTION DECLARATIONS ///.
Definition dsdMan.c:47
Dsd_Node_t ** Dsd_TreeCollectNodesDfsOne(Dsd_Manager_t *pDsdMan, Dsd_Node_t *pNode, int *pnNodes)
Definition dsdTree.c:585
void Dsd_NodeSetMark(Dsd_Node_t *p, word Mark)
Definition dsdApi.c:77
void Dsd_TreePrint(FILE *pFile, Dsd_Manager_t *dMan, char *pInputNames[], char *pOutputNames[], int fShortNames, int Output, int OffSet)
Definition dsdTree.c:830
Dsd_Node_t * Dsd_ManagerReadConst1(Dsd_Manager_t *pMan)
Definition dsdApi.c:95
Dsd_Node_t * Dsd_NodeReadDec(Dsd_Node_t *p, int i)
Definition dsdApi.c:57
enum Dsd_Type_t_ Dsd_Type_t
Definition dsd.h:61
struct Dsd_Manager_t_ Dsd_Manager_t
TYPEDEF DEFINITIONS ///.
Definition dsd.h:59
word Dsd_NodeReadMark(Dsd_Node_t *p)
Definition dsdApi.c:59
Dsd_Node_t * Dsd_ManagerReadRoot(Dsd_Manager_t *pMan, int i)
Definition dsdApi.c:93
void Dsd_TreePrint2(FILE *pFile, Dsd_Manager_t *dMan, char *pInputNames[], char *pOutputNames[], int Output)
Definition dsdTree.c:1106
Dsd_Node_t * Dsd_DecomposeOne(Dsd_Manager_t *pDsdMan, DdNode *bFunc)
Definition dsdProc.c:230
void Dsd_ManagerStop(Dsd_Manager_t *dMan)
Definition dsdMan.c:100
struct Dsd_Node_t_ Dsd_Node_t
Definition dsd.h:60
DdNode * Dsd_TreeGetPrimeFunction(DdManager *dd, Dsd_Node_t *pNode)
FUNCTION DEFINITIONS ///.
Definition dsdLocal.c:54
DdManager * Dsd_ManagerReadDd(Dsd_Manager_t *pMan)
Definition dsdApi.c:96
#define Dsd_Regular(p)
Definition dsd.h:69
Dsd_Node_t * Dsd_ManagerReadInput(Dsd_Manager_t *pMan, int i)
Definition dsdApi.c:94
int Dsd_NodeReadDecsNum(Dsd_Node_t *p)
Definition dsdApi.c:58
Dsd_Node_t ** Dsd_TreeCollectNodesDfs(Dsd_Manager_t *dMan, int *pnNodes)
Definition dsdTree.c:555
Dsd_Type_t Dsd_NodeReadType(Dsd_Node_t *p)
FUNCTION DEFINITIONS ///.
Definition dsdApi.c:53
@ DSD_NODE_EXOR
Definition dsd.h:51
@ DSD_NODE_OR
Definition dsd.h:50
@ DSD_NODE_PRIME
Definition dsd.h:52
@ DSD_NODE_CONST1
Definition dsd.h:48
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition dsd.h:68
void Dsd_Decompose(Dsd_Manager_t *dMan, DdNode **pbFuncs, int nFuncs)
DECOMPOSITION FUNCTIONS ///.
Definition dsdProc.c:113
void Extra_StopManager(DdManager *dd)
DdNode * Extra_TransferLevelByLevel(DdManager *ddSource, DdManager *ddDestination, DdNode *f)
char * Extra_UtilStrsav(const char *s)
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
char * pName
Definition abc.h:158
Abc_Ntk_t * pExdc
Definition abc.h:201
void * pManFunc
Definition abc.h:191
char * pSpec
Definition abc.h:159
void * pData
Definition abc.h:145
Abc_Ntk_t * pNtk
Definition abc.h:130
Abc_Obj_t * pCopy
Definition abc.h:148
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42