ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcCollapse.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "aig/gia/gia.h"
23#include "misc/vec/vecWec.h"
24#include "sat/cnf/cnf.h"
25#include "sat/bsat/satStore.h"
26
27#ifdef ABC_USE_CUDD
28#include "bdd/extrab/extraBdd.h"
29#endif
30
32
36
37#ifdef ABC_USE_CUDD
38
39extern int Abc_NodeSupport( DdNode * bFunc, Vec_Str_t * vSupport, int nVars );
40
44
56int Abc_NodeMinimumBase2( Abc_Obj_t * pNode )
57{
58 Vec_Str_t * vSupport;
59 Vec_Ptr_t * vFanins;
60 DdNode * bTemp;
61 int i, nVars;
62
63 assert( Abc_NtkIsBddLogic(pNode->pNtk) );
64 assert( Abc_ObjIsNode(pNode) );
65
66 // compute support
67 vSupport = Vec_StrAlloc( 10 );
68 nVars = Abc_NodeSupport( Cudd_Regular(pNode->pData), vSupport, Abc_ObjFaninNum(pNode) );
69 if ( nVars == Abc_ObjFaninNum(pNode) )
70 {
71 Vec_StrFree( vSupport );
72 return 0;
73 }
74
75 // add fanins
76 vFanins = Vec_PtrAlloc( Abc_ObjFaninNum(pNode) );
77 Abc_NodeCollectFanins( pNode, vFanins );
78 Vec_IntClear( &pNode->vFanins );
79 for ( i = 0; i < vFanins->nSize; i++ )
80 if ( vSupport->pArray[i] != 0 ) // useful
81 Vec_IntPush( &pNode->vFanins, Abc_ObjId((Abc_Obj_t *)vFanins->pArray[i]) );
82 assert( nVars == Abc_ObjFaninNum(pNode) );
83
84 // update the function of the node
85 pNode->pData = Extra_bddRemapUp( (DdManager *)pNode->pNtk->pManFunc, bTemp = (DdNode *)pNode->pData ); Cudd_Ref( (DdNode *)pNode->pData );
86 Cudd_RecursiveDeref( (DdManager *)pNode->pNtk->pManFunc, bTemp );
87 Vec_PtrFree( vFanins );
88 Vec_StrFree( vSupport );
89 return 1;
90}
91int Abc_NtkMinimumBase2( Abc_Ntk_t * pNtk )
92{
93 Abc_Obj_t * pNode, * pFanin;
94 int i, k, Counter;
95 assert( Abc_NtkIsBddLogic(pNtk) );
96 // remove all fanouts
97 Abc_NtkForEachObj( pNtk, pNode, i )
98 Vec_IntClear( &pNode->vFanouts );
99 // add useful fanins
100 Counter = 0;
101 Abc_NtkForEachNode( pNtk, pNode, i )
102 Counter += Abc_NodeMinimumBase2( pNode );
103 // add fanouts
104 Abc_NtkForEachObj( pNtk, pNode, i )
105 Abc_ObjForEachFanin( pNode, pFanin, k )
106 Vec_IntPush( &pFanin->vFanouts, Abc_ObjId(pNode) );
107 return Counter;
108}
109
121Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc, int fReverse )
122{
123 Abc_Obj_t * pNodeNew, * pTemp;
124 int i;
125 // create a new node
126 pNodeNew = Abc_NtkCreateNode( pNtkNew );
127 // add the fanins in the order, in which they appear in the reordered manager
128 Abc_NtkForEachCi( pNtkNew, pTemp, i )
129 Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, fReverse ? Abc_NtkCiNum(pNtkNew)-1-dd->invperm[i] : dd->invperm[i]) );
130 // transfer the function
131 pNodeNew->pData = Extra_TransferLevelByLevel( dd, (DdManager *)pNtkNew->pManFunc, bFunc ); Cudd_Ref( (DdNode *)pNodeNew->pData );
132 return pNodeNew;
133}
134Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk, int fReverse )
135{
136 ProgressBar * pProgress;
137 Abc_Ntk_t * pNtkNew;
138 Abc_Obj_t * pNode, * pDriver, * pNodeNew;
139 DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
140 int i;
141
142 // extract don't-care and compute ISOP
143 if ( pNtk->pExdc )
144 {
145 DdManager * ddExdc = NULL;
146 DdNode * bBddMin, * bBddDc, * bBddL, * bBddU;
147 assert( Abc_NtkIsStrash(pNtk->pExdc) );
148 assert( Abc_NtkCoNum(pNtk->pExdc) == 1 );
149 // compute the global BDDs
150 if ( Abc_NtkBuildGlobalBdds(pNtk->pExdc, 10000000, 1, 1, 0, 0) == NULL )
151 return NULL;
152 // transfer tot the same manager
153 ddExdc = (DdManager *)Abc_NtkGlobalBddMan( pNtk->pExdc );
154 bBddDc = (DdNode *)Abc_ObjGlobalBdd(Abc_NtkCo(pNtk->pExdc, 0));
155 bBddDc = Cudd_bddTransfer( ddExdc, dd, bBddDc ); Cudd_Ref( bBddDc );
156 Abc_NtkFreeGlobalBdds( pNtk->pExdc, 1 );
157 // minimize the output
158 Abc_NtkForEachCo( pNtk, pNode, i )
159 {
160 bBddMin = (DdNode *)Abc_ObjGlobalBdd(pNode);
161 // derive lower and uppwer bound
162 bBddL = Cudd_bddAnd( dd, bBddMin, Cudd_Not(bBddDc) ); Cudd_Ref( bBddL );
163 bBddU = Cudd_bddAnd( dd, Cudd_Not(bBddMin), Cudd_Not(bBddDc) ); Cudd_Ref( bBddU );
164 Cudd_RecursiveDeref( dd, bBddMin );
165 // compute new one
166 bBddMin = Cudd_bddIsop( dd, bBddL, Cudd_Not(bBddU) ); Cudd_Ref( bBddMin );
167 Cudd_RecursiveDeref( dd, bBddL );
168 Cudd_RecursiveDeref( dd, bBddU );
169 // update global BDD
170 Abc_ObjSetGlobalBdd( pNode, bBddMin );
171 //Extra_bddPrint( dd, bBddMin ); printf( "\n" );
172 }
173 Cudd_RecursiveDeref( dd, bBddDc );
174 }
175
176 // start the new network
177 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
178 // make sure the new manager has the same number of inputs
179 Cudd_bddIthVar( (DdManager *)pNtkNew->pManFunc, dd->size-1 );
180 // process the POs
181 pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
182 Abc_NtkForEachCo( pNtk, pNode, i )
183 {
184 Extra_ProgressBarUpdate( pProgress, i, NULL );
185 pDriver = Abc_ObjFanin0(pNode);
186 if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
187 {
188 Abc_ObjAddFanin( pNode->pCopy, pDriver->pCopy );
189 continue;
190 }
191 pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, (DdNode *)Abc_ObjGlobalBdd(pNode), fReverse );
192 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
193
194 }
195 Extra_ProgressBarStop( pProgress );
196 return pNtkNew;
197}
198void Abc_NtkDumpVariableOrder( Abc_Ntk_t * pNtk )
199{
200 DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
201 FILE * pFile = fopen( "order.txt", "wb" ); int i;
202 for ( i = 0; i < dd->size; i++ )
203 fprintf( pFile, "%d ", dd->invperm[i] );
204 fprintf( pFile, "\n" );
205 fclose( pFile );
206}
207Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose )
208{
209 Abc_Ntk_t * pNtkNew;
210 abctime clk = Abc_Clock();
211
212 assert( Abc_NtkIsStrash(pNtk) );
213 // compute the global BDDs
214 if ( Abc_NtkBuildGlobalBdds(pNtk, fBddSizeMax, 1, fReorder, fReverse, fVerbose) == NULL )
215 return NULL;
216 if ( fVerbose )
217 {
218 DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
219 printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
220 ABC_PRT( "BDD construction time", Abc_Clock() - clk );
221 }
222 if ( fDumpOrder )
223 Abc_NtkDumpVariableOrder( pNtk );
224
225 // create the new network
226 pNtkNew = Abc_NtkFromGlobalBdds( pNtk, fReverse );
227 Abc_NtkFreeGlobalBdds( pNtk, 1 );
228 if ( pNtkNew == NULL )
229 return NULL;
230
231 // make the network minimum base
232 Abc_NtkMinimumBase2( pNtkNew );
233
234 if ( pNtk->pExdc )
235 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
236
237 // make sure that everything is okay
238 if ( !Abc_NtkCheck( pNtkNew ) )
239 {
240 printf( "Abc_NtkCollapse: The network check has failed.\n" );
241 Abc_NtkDelete( pNtkNew );
242 return NULL;
243 }
244 return pNtkNew;
245}
246
247
248#else
249
250Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose )
251{
252 return NULL;
253}
254
255#endif
256
257
258#if 0
259
271int Abc_NtkClpOneGia_rec( Gia_Man_t * pNew, Abc_Obj_t * pNode )
272{
273 int iLit0, iLit1;
274 if ( Abc_NodeIsTravIdCurrent(pNode) || Abc_ObjFaninNum(pNode) == 0 || Abc_ObjIsCi(pNode) )
275 return pNode->iTemp;
276 assert( Abc_ObjIsNode( pNode ) );
277 Abc_NodeSetTravIdCurrent( pNode );
278 iLit0 = Abc_NtkClpOneGia_rec( pNew, Abc_ObjFanin0(pNode) );
279 iLit1 = Abc_NtkClpOneGia_rec( pNew, Abc_ObjFanin1(pNode) );
280 iLit0 = Abc_LitNotCond( iLit0, Abc_ObjFaninC0(pNode) );
281 iLit1 = Abc_LitNotCond( iLit1, Abc_ObjFaninC1(pNode) );
282 return (pNode->iTemp = Gia_ManHashAnd(pNew, iLit0, iLit1));
283}
284Gia_Man_t * Abc_NtkClpOneGia( Abc_Ntk_t * pNtk, int iCo, Vec_Int_t * vSupp )
285{
286 int i, iCi, iLit;
287 Abc_Obj_t * pNode;
288 Gia_Man_t * pNew, * pTemp;
289 pNew = Gia_ManStart( 1000 );
290 pNew->pName = Abc_UtilStrsav( pNtk->pName );
291 pNew->pSpec = Abc_UtilStrsav( pNtk->pSpec );
292 Gia_ManHashStart( pNew );
293 // primary inputs
294 Abc_AigConst1(pNtk)->iTemp = 1;
295 Vec_IntForEachEntry( vSupp, iCi, i )
296 Abc_NtkCi(pNtk, iCi)->iTemp = Gia_ManAppendCi(pNew);
297 // create the first cone
298 Abc_NtkIncrementTravId( pNtk );
299 pNode = Abc_NtkCo( pNtk, iCo );
300 iLit = Abc_NtkClpOneGia_rec( pNew, Abc_ObjFanin0(pNode) );
301 iLit = Abc_LitNotCond( iLit, Abc_ObjFaninC0(pNode) );
302 Gia_ManAppendCo( pNew, iLit );
303 // perform cleanup
304 pNew = Gia_ManCleanup( pTemp = pNew );
305 Gia_ManStop( pTemp );
306 return pNew;
307}
308Vec_Str_t * Abc_NtkClpOne( Abc_Ntk_t * pNtk, int iCo, int nCubeLim, int nBTLimit, int fVerbose, int fCanon, int fReverse, Vec_Int_t * vSupp )
309{
310 Vec_Str_t * vSop;
311 abctime clk = Abc_Clock();
312 extern Vec_Str_t * Bmc_CollapseOne( Gia_Man_t * p, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
313 Gia_Man_t * pGia = Abc_NtkClpOneGia( pNtk, iCo, vSupp );
314 if ( fVerbose )
315 printf( "Output %4d: Supp = %4d. Cone =%6d.\n", iCo, Vec_IntSize(vSupp), Gia_ManAndNum(pGia) );
316 vSop = Bmc_CollapseOne( pGia, nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
317 Gia_ManStop( pGia );
318 if ( vSop == NULL )
319 return NULL;
320 if ( Vec_StrSize(vSop) == 4 ) // constant
321 Vec_IntClear(vSupp);
322 if ( fVerbose )
323 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
324 return vSop;
325}
326
338Vec_Wec_t * Abc_NtkCreateCoSupps( Abc_Ntk_t * pNtk, int fVerbose )
339{
340 abctime clk = Abc_Clock();
341 Abc_Obj_t * pNode; int i;
342 Vec_Wec_t * vSupps = Vec_WecStart( Abc_NtkObjNumMax(pNtk) );
343 Abc_NtkForEachCi( pNtk, pNode, i )
344 Vec_IntPush( Vec_WecEntry(vSupps, pNode->Id), i );
345 Abc_NtkForEachNode( pNtk, pNode, i )
346 Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Abc_ObjFanin0(pNode)->Id),
347 Vec_WecEntry(vSupps, Abc_ObjFanin1(pNode)->Id),
348 Vec_WecEntry(vSupps, pNode->Id) );
349 if ( fVerbose )
350 Abc_PrintTime( 1, "Support computation", Abc_Clock() - clk );
351 return vSupps;
352}
353
365int Abc_NodeCompareByTemp( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
366{
367 int Diff = (*pp2)->iTemp - (*pp1)->iTemp;
368 if ( Diff < 0 )
369 return -1;
370 if ( Diff > 0 )
371 return 1;
372 Diff = strcmp( Abc_ObjName(*pp1), Abc_ObjName(*pp2) );
373 if ( Diff < 0 )
374 return -1;
375 if ( Diff > 0 )
376 return 1;
377 return 0;
378}
379Vec_Ptr_t * Abc_NtkCreateCoOrder( Abc_Ntk_t * pNtk, Vec_Wec_t * vSupps )
380{
381 Abc_Obj_t * pNode; int i;
382 Vec_Ptr_t * vNodes = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
383 Abc_NtkForEachCo( pNtk, pNode, i )
384 {
385 pNode->iTemp = Vec_IntSize( Vec_WecEntry(vSupps, Abc_ObjFaninId0(pNode)) );
386 Vec_PtrPush( vNodes, pNode );
387 }
388 // order objects alphabetically
389 qsort( (void *)Vec_PtrArray(vNodes), (size_t)Vec_PtrSize(vNodes), sizeof(Abc_Obj_t *),
390 (int (*)(const void *, const void *)) Abc_NodeCompareByTemp );
391 // cleanup
392// Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
393// printf( "%s %d ", Abc_ObjName(pNode), pNode->iTemp );
394// printf( "\n" );
395 return vNodes;
396}
397
409Abc_Obj_t * Abc_NtkFromSopsOne( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, int iCo, Vec_Int_t * vSupp, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose )
410{
411 Abc_Obj_t * pNodeNew;
412 Vec_Str_t * vSop;
413 int i, iCi;
414 // compute SOP of the node
415 vSop = Abc_NtkClpOne( pNtk, iCo, nCubeLim, nBTLimit, fVerbose, fCanon, fReverse, vSupp );
416 if ( vSop == NULL )
417 return NULL;
418 // create a new node
419 pNodeNew = Abc_NtkCreateNode( pNtkNew );
420 // add fanins
421 if ( Vec_StrSize(vSop) > 4 ) // non-constant SOP
422 Vec_IntForEachEntry( vSupp, iCi, i )
423 Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, iCi) );
424 // transfer the function
425 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Vec_StrArray(vSop) );
426 Vec_StrFree( vSop );
427 return pNodeNew;
428}
429Abc_Ntk_t * Abc_NtkFromSops( Abc_Ntk_t * pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fVerbose )
430{
431 ProgressBar * pProgress;
432 Abc_Ntk_t * pNtkNew;
433 Abc_Obj_t * pNode, * pDriver, * pNodeNew;
434 Vec_Ptr_t * vDriverCopy, * vCoNodes, * vDfsNodes;
435 Vec_Int_t * vNodeCoIds, * vLevel;
436 Vec_Wec_t * vSupps;
437 int i;
438
439// Abc_NtkForEachCi( pNtk, pNode, i )
440// printf( "%d ", Abc_ObjFanoutNum(pNode) );
441// printf( "\n" );
442
443 // compute structural supports
444 vSupps = Abc_NtkCreateCoSupps( pNtk, fVerbose );
445 // order CO nodes by support size
446 vCoNodes = Abc_NtkCreateCoOrder( pNtk, vSupps );
447 // compute cost of the largest node
448 if ( nCubeLim > 0 )
449 {
450 word Cost;
451 pNode = (Abc_Obj_t *)Vec_PtrEntry( vCoNodes, 0 );
452 vDfsNodes = Abc_NtkDfsNodes( pNtk, &pNode, 1 );
453 vLevel = Vec_WecEntry( vSupps, Abc_ObjFaninId0(pNode) );
454 Cost = (word)Vec_PtrSize(vDfsNodes) * (word)Vec_IntSize(vLevel) * (word)nCubeLim;
455 if ( Cost > (word)nCostMax )
456 {
457 printf( "Cost of the largest output cone exceeded the limit (%d * %d * %d > %d).\n",
458 Vec_PtrSize(vDfsNodes), Vec_IntSize(vLevel), nCubeLim, nCostMax );
459 Vec_PtrFree( vDfsNodes );
460 Vec_PtrFree( vCoNodes );
461 Vec_WecFree( vSupps );
462 return NULL;
463 }
464 Vec_PtrFree( vDfsNodes );
465 }
466 // collect CO IDs in this order
467 vNodeCoIds = Vec_IntAlloc( Abc_NtkCoNum(pNtk) );
468 Abc_NtkForEachCo( pNtk, pNode, i )
469 pNode->iTemp = i;
470 Vec_PtrForEachEntry( Abc_Obj_t *, vCoNodes, pNode, i )
471 Vec_IntPush( vNodeCoIds, pNode->iTemp );
472
473 // start the new network
474 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
475 // collect driver copies
476 vDriverCopy = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
477// Abc_NtkForEachCo( pNtk, pNode, i )
478 Vec_PtrForEachEntry( Abc_Obj_t *, vCoNodes, pNode, i )
479 Vec_PtrPush( vDriverCopy, Abc_ObjFanin0(pNode)->pCopy );
480 // process the POs
481 pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
482// Abc_NtkForEachCo( pNtk, pNode, i )
483 Vec_PtrForEachEntry( Abc_Obj_t *, vCoNodes, pNode, i )
484 {
485 Extra_ProgressBarUpdate( pProgress, i, NULL );
486 pDriver = Abc_ObjFanin0(pNode);
487 if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
488 {
489 Abc_ObjAddFanin( pNode->pCopy, (Abc_Obj_t *)Vec_PtrEntry(vDriverCopy, i) );
490 continue;
491 }
492 if ( Abc_ObjIsCi(pDriver) )
493 {
494 pNodeNew = Abc_NtkCreateNode( pNtkNew );
495 Abc_ObjAddFanin( pNodeNew, (Abc_Obj_t *)Vec_PtrEntry(vDriverCopy, i) );
496 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pNode) ? "0 1\n" : "1 1\n" );
497 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
498 continue;
499 }
500 if ( pDriver == Abc_AigConst1(pNtk) )
501 {
502 pNodeNew = Abc_NtkCreateNode( pNtkNew );
503 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pNode) ? " 0\n" : " 1\n" );
504 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
505 continue;
506 }
507 pNodeNew = Abc_NtkFromSopsOne( pNtkNew, pNtk, Vec_IntEntry(vNodeCoIds, i), Vec_WecEntry(vSupps, Abc_ObjFanin0(pNode)->Id), nCubeLim, nBTLimit, fCanon, fReverse, i ? 0 : fVerbose );
508 if ( pNodeNew == NULL )
509 {
510 Abc_NtkDelete( pNtkNew );
511 pNtkNew = NULL;
512 break;
513 }
514 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
515 }
516 Vec_PtrFree( vDriverCopy );
517 Vec_PtrFree( vCoNodes );
518 Vec_IntFree( vNodeCoIds );
519 Vec_WecFree( vSupps );
520 Extra_ProgressBarStop( pProgress );
521 return pNtkNew;
522}
523Abc_Ntk_t * Abc_NtkCollapseSat( Abc_Ntk_t * pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fVerbose )
524{
525 Abc_Ntk_t * pNtkNew;
526 assert( Abc_NtkIsStrash(pNtk) );
527 // create the new network
528 pNtkNew = Abc_NtkFromSops( pNtk, nCubeLim, nBTLimit, nCostMax, fCanon, fReverse, fVerbose );
529 if ( pNtkNew == NULL )
530 return NULL;
531 if ( pNtk->pExdc )
532 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
533 // make sure that everything is okay
534 if ( !Abc_NtkCheck( pNtkNew ) )
535 {
536 printf( "Abc_NtkCollapseSat: The network check has failed.\n" );
537 Abc_NtkDelete( pNtkNew );
538 return NULL;
539 }
540 return pNtkNew;
541}
542
543#endif
544
545
546
547extern Vec_Wec_t * Gia_ManCreateCoSupps( Gia_Man_t * p, int fVerbose );
548extern int Gia_ManCoLargestSupp( Gia_Man_t * p, Vec_Wec_t * vSupps );
549extern Vec_Wec_t * Gia_ManIsoStrashReduceInt( Gia_Man_t * p, Vec_Wec_t * vSupps, int fVerbose );
550
563{
564 int iLit0, iLit1;
565 if ( pNode->iTemp >= 0 )
566 return pNode->iTemp;
567 assert( Abc_ObjIsNode( pNode ) );
568 iLit0 = Abc_NtkClpGia_rec( pNew, Abc_ObjFanin0(pNode) );
569 iLit1 = Abc_NtkClpGia_rec( pNew, Abc_ObjFanin1(pNode) );
570 iLit0 = Abc_LitNotCond( iLit0, Abc_ObjFaninC0(pNode) );
571 iLit1 = Abc_LitNotCond( iLit1, Abc_ObjFaninC1(pNode) );
572 return (pNode->iTemp = Gia_ManAppendAnd(pNew, iLit0, iLit1));
573}
575{
576 int i, iLit;
577 Gia_Man_t * pNew;
578 Abc_Obj_t * pNode;
579 assert( Abc_NtkIsStrash(pNtk) );
580 pNew = Gia_ManStart( 1000 );
581 pNew->pName = Abc_UtilStrsav( pNtk->pName );
582 pNew->pSpec = Abc_UtilStrsav( pNtk->pSpec );
583 Abc_NtkForEachObj( pNtk, pNode, i )
584 pNode->iTemp = -1;
585 Abc_AigConst1(pNtk)->iTemp = 1;
586 Abc_NtkForEachCi( pNtk, pNode, i )
587 pNode->iTemp = Gia_ManAppendCi(pNew);
588 Abc_NtkForEachCo( pNtk, pNode, i )
589 {
590 iLit = Abc_NtkClpGia_rec( pNew, Abc_ObjFanin0(pNode) );
591 iLit = Abc_LitNotCond( iLit, Abc_ObjFaninC0(pNode) );
592 Gia_ManAppendCo( pNew, iLit );
593 }
594 return pNew;
595}
596
608#define Abc_NtkSopForEachCube( pSop, nVars, pCube ) for ( pCube = (pSop); *pCube; pCube += (nVars) + 3 )
609
610int Abc_NtkCollapseReduce( Vec_Str_t * vSop, Vec_Int_t * vSupp, Vec_Int_t * vClass, Vec_Wec_t * vSupps )
611{
612 int j = 0, i, k, iCo, iVar, nVars = Vec_IntSize(vSupp);
613 char * pCube, * pSop = Vec_StrArray(vSop);
614 Vec_Int_t * vPres;
615 if ( Vec_StrSize(vSop) == 4 ) // constant
616 {
617 Vec_IntForEachEntry( vClass, iCo, i )
618 Vec_IntClear( Vec_WecEntry(vSupps, iCo) );
619 return 1;
620 }
621 vPres = Vec_IntStart( nVars );
622 Abc_NtkSopForEachCube( pSop, nVars, pCube )
623 for ( k = 0; k < nVars; k++ )
624 if ( pCube[k] != '-' )
625 Vec_IntWriteEntry( vPres, k, 1 );
626 if ( Vec_IntCountZero(vPres) == 0 )
627 {
628 Vec_IntFree( vPres );
629 return 0;
630 }
631 // reduce cubes
632 Abc_NtkSopForEachCube( pSop, nVars, pCube )
633 for ( k = 0; k < nVars + 3; k++ )
634 if ( k >= nVars || Vec_IntEntry(vPres, k) )
635 Vec_StrWriteEntry( vSop, j++, pCube[k] );
636 Vec_StrWriteEntry( vSop, j++, '\0' );
637 Vec_StrShrink( vSop, j );
638 // reduce support
639 Vec_IntForEachEntry( vClass, iCo, i )
640 {
641 j = 0;
642 vSupp = Vec_WecEntry( vSupps, iCo );
643 Vec_IntForEachEntry( vSupp, iVar, k )
644 if ( Vec_IntEntry(vPres, k) )
645 Vec_IntWriteEntry( vSupp, j++, iVar );
646 Vec_IntShrink( vSupp, j );
647 }
648 Vec_IntFree( vPres );
649// if ( Vec_IntSize(vSupp) != Abc_SopGetVarNum(Vec_StrArray(vSop)) )
650// printf( "Mismatch!!!\n" );
651 return 1;
652}
653
654
666sat_solver * Abc_NtkClpDeriveSatSolver( Cnf_Dat_t * pCnf, int iCoObjId, Vec_Int_t * vSupp, Vec_Int_t * vAnds, Vec_Int_t * vMap, sat_solver ** ppSat1, sat_solver ** ppSat2, sat_solver ** ppSat3 )
667{
668 int i, k, iObj, status, nVars = 2;
669// int i, k, iObj, status, nVars = 1;
670 Vec_Int_t * vLits = Vec_IntAlloc( 16 );
671 sat_solver * pSat = sat_solver_new();
672 if ( ppSat1 ) *ppSat1 = sat_solver_new();
673 if ( ppSat2 ) *ppSat2 = sat_solver_new();
674 if ( ppSat3 ) *ppSat3 = sat_solver_new();
675 // assign SAT variable numbers
676 Vec_IntWriteEntry( vMap, iCoObjId, nVars++ );
677 Vec_IntForEachEntry( vSupp, iObj, k )
678 Vec_IntWriteEntry( vMap, iObj, nVars++ );
679 Vec_IntForEachEntry( vAnds, iObj, k )
680 if ( pCnf->pObj2Clause[iObj] != -1 )
681 Vec_IntWriteEntry( vMap, iObj, nVars++ );
682// Vec_IntForEachEntry( vSupp, iObj, k )
683// Vec_IntWriteEntry( vMap, iObj, nVars++ );
684 // create clauses for the internal nodes and for the output
685 sat_solver_setnvars( pSat, nVars );
686 if ( ppSat1 ) sat_solver_setnvars( *ppSat1, nVars );
687 if ( ppSat2 ) sat_solver_setnvars( *ppSat2, nVars );
688 if ( ppSat3 ) sat_solver_setnvars( *ppSat3, nVars );
689 Vec_IntPush( vAnds, iCoObjId );
690 Vec_IntForEachEntry( vAnds, iObj, k )
691 {
692 int iClaBeg, iClaEnd, * pLit;
693 if ( pCnf->pObj2Clause[iObj] == -1 )
694 continue;
695 iClaBeg = pCnf->pObj2Clause[iObj];
696 iClaEnd = iClaBeg + pCnf->pObj2Count[iObj];
697 assert( iClaBeg < iClaEnd );
698 for ( i = iClaBeg; i < iClaEnd; i++ )
699 {
700 Vec_IntClear( vLits );
701 for ( pLit = pCnf->pClauses[i]; pLit < pCnf->pClauses[i+1]; pLit++ )
702 Vec_IntPush( vLits, Abc_Lit2LitV(Vec_IntArray(vMap), *pLit) );
703 status = sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
704 assert( status );
705 (void) status;
706 if ( ppSat1 ) sat_solver_addclause( *ppSat1, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
707 if ( ppSat2 ) sat_solver_addclause( *ppSat2, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
708 if ( ppSat3 ) sat_solver_addclause( *ppSat3, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
709 }
710 }
711 Vec_IntPop( vAnds );
712 Vec_IntFree( vLits );
713 assert( nVars == sat_solver_nvars(pSat) );
714 return pSat;
715}
716
728Vec_Str_t * Abc_NtkClpGiaOne( Gia_Man_t * p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t * vSupp, int fVerbose, Vec_Int_t * vClass, Vec_Wec_t * vSupps )
729{
730 Vec_Str_t * vSop;
731 abctime clk = Abc_Clock();
732 extern Vec_Str_t * Bmc_CollapseOneOld( Gia_Man_t * p, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
733 Gia_Man_t * pGia = Gia_ManDupCones( p, &iCo, 1, 1 );
734 if ( fVerbose )
735 printf( "Output %4d: Supp = %4d. Cone =%6d.\n", iCo, Vec_IntSize(vSupp), Gia_ManAndNum(pGia) );
736 vSop = Bmc_CollapseOneOld( pGia, nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
737 Gia_ManStop( pGia );
738 if ( vSop == NULL )
739 return NULL;
740 Abc_NtkCollapseReduce( vSop, vSupp, vClass, vSupps );
741 if ( fVerbose )
742 printf( "Supp new = %4d. Sop = %4d. ", Vec_IntSize(vSupp), Vec_StrSize(vSop)/(Vec_IntSize(vSupp) +3) );
743 if ( fVerbose )
744 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
745 return vSop;
746}
747Vec_Str_t * Abc_NtkClpGiaOne2( Cnf_Dat_t * pCnf, Gia_Man_t * p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t * vSupp, Vec_Int_t * vMap, int fVerbose, Vec_Int_t * vClass, Vec_Wec_t * vSupps )
748{
749 Vec_Str_t * vSop;
750 sat_solver * pSat, * pSat1 = NULL, * pSat2 = NULL, * pSat3 = NULL;
751 Gia_Obj_t * pObj;
752 abctime clk = Abc_Clock();
753 extern Vec_Str_t * Bmc_CollapseOne_int( sat_solver * pSat, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
754 extern Vec_Str_t * Bmc_CollapseOne_int2( sat_solver * pSat, sat_solver * pSat2, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
755 extern Vec_Str_t * Bmc_CollapseOne_int3( sat_solver * pSat, sat_solver * pSat1, sat_solver * pSat2, sat_solver * pSat3, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
756 int i, iCoObjId = Gia_ObjId( p, Gia_ManCo(p, iCo) );
757 Vec_Int_t * vAnds = Vec_IntAlloc( 100 );
758 Vec_Int_t * vSuppObjs = Vec_IntAlloc( 100 );
759 Gia_ManForEachCiVec( vSupp, p, pObj, i )
760 Vec_IntPush( vSuppObjs, Gia_ObjId(p, pObj) );
762 Gia_ManCollectAnds( p, &iCoObjId, 1, vAnds, NULL );
763 assert( Vec_IntSize(vAnds) > 0 );
764// pSat = Abc_NtkClpDeriveSatSolver( pCnf, iCoObjId, vSuppObjs, vAnds, vMap, &pSat1, &pSat2, &pSat3 );
765 pSat = Abc_NtkClpDeriveSatSolver( pCnf, iCoObjId, vSuppObjs, vAnds, vMap, NULL, NULL, NULL );
766 Vec_IntFree( vSuppObjs );
767 if ( fVerbose )
768 printf( "Output %4d: Supp = %4d. Cone =%6d.\n", iCo, Vec_IntSize(vSupp), Vec_IntSize(vAnds) );
769// vSop = Bmc_CollapseOne_int3( pSat, pSat1, pSat2, pSat3, Vec_IntSize(vSupp), nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
770// vSop = Bmc_CollapseOne_int2( pSat, pSat1, Vec_IntSize(vSupp), nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
771 vSop = Bmc_CollapseOne_int( pSat, Vec_IntSize(vSupp), nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
772 sat_solver_delete( pSat );
773 if ( pSat1 ) sat_solver_delete( pSat1 );
774 if ( pSat2 ) sat_solver_delete( pSat2 );
775 if ( pSat3 ) sat_solver_delete( pSat3 );
776 Vec_IntFree( vAnds );
777 if ( vSop == NULL )
778 return NULL;
779 Abc_NtkCollapseReduce( vSop, vSupp, vClass, vSupps );
780 if ( fVerbose )
781 printf( "Supp new = %4d. Sop = %4d. ", Vec_IntSize(vSupp), Vec_StrSize(vSop)/(Vec_IntSize(vSupp) +3) );
782 if ( fVerbose )
783 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
784 return vSop;
785}
786Vec_Ptr_t * Abc_GiaDeriveSops( Abc_Ntk_t * pNtkNew, Gia_Man_t * p, Vec_Wec_t * vSupps, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose )
787{
788 ProgressBar * pProgress;
789 abctime clk = Abc_Clock();
790 Vec_Ptr_t * vSops = NULL, * vSopsRepr;
791 Vec_Int_t * vReprs, * vClass, * vReprSuppSizes;
792 int i, k, Entry, iCo, * pOrder;
793 Vec_Wec_t * vClasses;
794 Cnf_Dat_t * pCnf = NULL;
795 Vec_Int_t * vMap = NULL;
796 // derive classes of outputs
797 vClasses = Gia_ManIsoStrashReduceInt( p, vSupps, 0 );
798 if ( fVerbose )
799 {
800 printf( "Considering %d (out of %d) outputs. ", Vec_WecSize(vClasses), Gia_ManCoNum(p) );
801 Abc_PrintTime( 1, "Reduction time", Abc_Clock() - clk );
802 }
803 // derive representatives
804 vReprs = Vec_WecCollectFirsts( vClasses );
805 vReprSuppSizes = Vec_IntAlloc( Vec_IntSize(vReprs) );
806 Vec_IntForEachEntry( vReprs, Entry, i )
807 Vec_IntPush( vReprSuppSizes, Vec_IntSize(Vec_WecEntry(vSupps, Entry)) );
808 pOrder = Abc_MergeSortCost( Vec_IntArray(vReprSuppSizes), Vec_IntSize(vReprSuppSizes) );
809 Vec_IntFree( vReprSuppSizes );
810 // consider SOPs for representatives
811 if ( fCnfShared )
812 {
813 vMap = Vec_IntStartFull( Gia_ManObjNum(p) );
814 pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8, 1, 0, 0, 0 );
815 }
816 vSopsRepr = Vec_PtrStart( Vec_IntSize(vReprs) );
817 pProgress = Extra_ProgressBarStart( stdout, Vec_IntSize(vReprs) );
818 Extra_ProgressBarUpdate( pProgress, 0, NULL );
819 for ( i = 0; i < Vec_IntSize(vReprs); i++ )
820 {
821 int iEntry = pOrder[Vec_IntSize(vReprs) - 1 - i];
822 int iCoThis = Vec_IntEntry( vReprs, iEntry );
823 Vec_Int_t * vSupp = Vec_WecEntry( vSupps, iCoThis );
824 Vec_Str_t * vSop;
825 if ( Vec_IntSize(vSupp) < 2 )
826 {
827 Vec_PtrWriteEntry( vSopsRepr, iEntry, (void *)(ABC_PTRINT_T)1 );
828 continue;
829 }
830 if ( fCnfShared && !fCanon )
831 vSop = Abc_NtkClpGiaOne2( pCnf, p, iCoThis, nCubeLim, nBTLimit, fCanon, fReverse, vSupp, vMap, i ? 0 : fVerbose, Vec_WecEntry(vClasses, iEntry), vSupps );
832 else
833 vSop = Abc_NtkClpGiaOne( p, iCoThis, nCubeLim, nBTLimit, fCanon, fReverse, vSupp, i ? 0 : fVerbose, Vec_WecEntry(vClasses, iEntry), vSupps );
834 if ( vSop == NULL )
835 goto finish;
836 assert( Vec_IntSize( Vec_WecEntry(vSupps, iCoThis) ) == Abc_SopGetVarNum(Vec_StrArray(vSop)) );
837 Extra_ProgressBarUpdate( pProgress, i, NULL );
838 Vec_PtrWriteEntry( vSopsRepr, iEntry, Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Vec_StrArray(vSop) ) );
839 Vec_StrFree( vSop );
840 }
841 Extra_ProgressBarStop( pProgress );
842 if ( fCnfShared )
843 {
844 Cnf_DataFree( pCnf );
845 Vec_IntFree( vMap );
846 }
847 // derive SOPs for each output
848 vSops = Vec_PtrStart( Gia_ManCoNum(p) );
849 Vec_WecForEachLevel ( vClasses, vClass, i )
850 Vec_IntForEachEntry( vClass, iCo, k )
851 Vec_PtrWriteEntry( vSops, iCo, Vec_PtrEntry(vSopsRepr, i) );
852 assert( Vec_PtrCountZero(vSops) == 0 );
853/*
854 // verify
855 for ( i = 0; i < Gia_ManCoNum(p); i++ )
856 {
857 Vec_Int_t * vSupp = Vec_WecEntry( vSupps, i );
858 char * pSop = (char *)Vec_PtrEntry( vSops, i );
859 assert( Vec_IntSize(vSupp) == Abc_SopGetVarNum(pSop) );
860 }
861*/
862 // cleanup
863finish:
864 ABC_FREE( pOrder );
865 Vec_IntFree( vReprs );
866 Vec_WecFree( vClasses );
867 Vec_PtrFree( vSopsRepr );
868 return vSops;
869}
870Abc_Ntk_t * Abc_NtkFromSopsInt( Abc_Ntk_t * pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose )
871{
872 Abc_Ntk_t * pNtkNew;
873 Gia_Man_t * pGia;
874 Vec_Wec_t * vSupps;
875 Vec_Int_t * vSupp;
876 Vec_Ptr_t * vSops;
877 Abc_Obj_t * pNode, * pNodeNew, * pDriver;
878 int i, k, iCi;
879 pGia = Abc_NtkClpGia( pNtk );
880 vSupps = Gia_ManCreateCoSupps( pGia, fVerbose );
881 // check the largest output
882 if ( nCubeLim > 0 && nCostMax > 0 )
883 {
884 int iCoMax = Gia_ManCoLargestSupp( pGia, vSupps );
885 int iObjMax = Gia_ObjId( pGia, Gia_ManCo(pGia, iCoMax) );
886 int nSuppMax = Vec_IntSize( Vec_WecEntry(vSupps, iCoMax) );
887 int nNodeMax = Gia_ManConeSize( pGia, &iObjMax, 1 );
888 word Cost = (word)nNodeMax * (word)nSuppMax * (word)nCubeLim;
889 if ( Cost > (word)nCostMax )
890 {
891 printf( "Cost of the largest output cone exceeded the limit (%d * %d * %d > %d).\n",
892 nNodeMax, nSuppMax, nCubeLim, nCostMax );
893 Gia_ManStop( pGia );
894 Vec_WecFree( vSupps );
895 return NULL;
896 }
897 }
898 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
899 vSops = Abc_GiaDeriveSops( pNtkNew, pGia, vSupps, nCubeLim, nBTLimit, nCostMax, fCanon, fReverse, fCnfShared, fVerbose );
900 Gia_ManStop( pGia );
901 if ( vSops == NULL )
902 {
903 Vec_WecFree( vSupps );
904 Abc_NtkDelete( pNtkNew );
905 return NULL;
906 }
907 Abc_NtkForEachCo( pNtk, pNode, i )
908 {
909 pDriver = Abc_ObjFanin0(pNode);
910 if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
911 {
912 Abc_ObjAddFanin( pNode->pCopy, pDriver->pCopy );
913 continue;
914 }
915 if ( Abc_ObjIsCi(pDriver) )
916 {
917 pNodeNew = Abc_NtkCreateNode( pNtkNew );
918 Abc_ObjAddFanin( pNodeNew, pDriver->pCopy );
919 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pNode) ? "0 1\n" : "1 1\n" );
920 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
921 continue;
922 }
923 if ( pDriver == Abc_AigConst1(pNtk) )
924 {
925 pNodeNew = Abc_NtkCreateNode( pNtkNew );
926 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pNode) ? " 0\n" : " 1\n" );
927 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
928 continue;
929 }
930 pNodeNew = Abc_NtkCreateNode( pNtkNew );
931 vSupp = Vec_WecEntry( vSupps, i );
932 Vec_IntForEachEntry( vSupp, iCi, k )
933 Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, iCi) );
934 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, (const char*)Vec_PtrEntry( vSops, i ) );
935 assert( pNodeNew->pData != (void *)(ABC_PTRINT_T)1 );
936 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
937 }
938 Vec_WecFree( vSupps );
939 Vec_PtrFree( vSops );
940 Abc_NtkSortSops( pNtkNew );
941 return pNtkNew;
942}
943Abc_Ntk_t * Abc_NtkCollapseSat( Abc_Ntk_t * pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose )
944{
945 Abc_Ntk_t * pNtkNew;
946 assert( Abc_NtkIsStrash(pNtk) );
947 pNtkNew = Abc_NtkFromSopsInt( pNtk, nCubeLim, nBTLimit, nCostMax, fCanon, fReverse, fCnfShared, fVerbose );
948 if ( pNtkNew == NULL )
949 return NULL;
950 if ( pNtk->pExdc )
951 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
952 if ( !Abc_NtkCheck( pNtkNew ) )
953 {
954 printf( "Abc_NtkCollapseSat: The network check has failed.\n" );
955 Abc_NtkDelete( pNtkNew );
956 return NULL;
957 }
958 return pNtkNew;
959}
960
961
965
966
968
Vec_Ptr_t * Abc_GiaDeriveSops(Abc_Ntk_t *pNtkNew, Gia_Man_t *p, Vec_Wec_t *vSupps, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
int Abc_NtkClpGia_rec(Gia_Man_t *pNew, Abc_Obj_t *pNode)
Abc_Ntk_t * Abc_NtkFromSopsInt(Abc_Ntk_t *pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkCollapse(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose)
DECLARATIONS ///.
Vec_Str_t * Abc_NtkClpGiaOne(Gia_Man_t *p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t *vSupp, int fVerbose, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
int Gia_ManCoLargestSupp(Gia_Man_t *p, Vec_Wec_t *vSupps)
Definition giaDup.c:4452
Vec_Wec_t * Gia_ManCreateCoSupps(Gia_Man_t *p, int fVerbose)
Definition giaDup.c:4421
Gia_Man_t * Abc_NtkClpGia(Abc_Ntk_t *pNtk)
sat_solver * Abc_NtkClpDeriveSatSolver(Cnf_Dat_t *pCnf, int iCoObjId, Vec_Int_t *vSupp, Vec_Int_t *vAnds, Vec_Int_t *vMap, sat_solver **ppSat1, sat_solver **ppSat2, sat_solver **ppSat3)
int Abc_NtkCollapseReduce(Vec_Str_t *vSop, Vec_Int_t *vSupp, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
Vec_Wec_t * Gia_ManIsoStrashReduceInt(Gia_Man_t *p, Vec_Wec_t *vSupps, int fVerbose)
Definition giaDup.c:4601
Vec_Str_t * Abc_NtkClpGiaOne2(Cnf_Dat_t *pCnf, Gia_Man_t *p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t *vSupp, Vec_Int_t *vMap, int fVerbose, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
Abc_Ntk_t * Abc_NtkCollapseSat(Abc_Ntk_t *pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
#define Abc_NtkSopForEachCube(pSop, nVars, pCube)
int Abc_NtkClpOneGia_rec(Gia_Man_t *pNew, Abc_Obj_t *pNode)
Definition abcUtil.c:3201
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#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_NTK_LOGIC
Definition abc.h:57
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
ABC_DLL void Abc_NtkSortSops(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NodeCollectFanins(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1627
ABC_DLL void * Abc_NtkBuildGlobalBdds(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fReverse, int fVerbose)
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
#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 Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:151
@ ABC_FUNC_SOP
Definition abc.h:65
@ ABC_FUNC_BDD
Definition abc.h:66
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
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_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
int * Abc_MergeSortCost(int *pCosts, int nSize)
Definition utilSort.c:442
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
Vec_Str_t * Bmc_CollapseOneOld(Gia_Man_t *p, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:864
Vec_Str_t * Bmc_CollapseOne_int(sat_solver *pSat, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1389
Vec_Str_t * Bmc_CollapseOne_int2(sat_solver *pSat1, sat_solver *pSat2, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1226
Vec_Str_t * Bmc_CollapseOne(Gia_Man_t *p, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1532
Vec_Str_t * Bmc_CollapseOne_int3(sat_solver *pSat0, sat_solver *pSat1, sat_solver *pSat2, sat_solver *pSat3, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1040
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
Cube * p
Definition exorList.c:222
DdNode * Extra_bddRemapUp(DdManager *dd, DdNode *bF)
DdNode * Extra_TransferLevelByLevel(DdManager *ddSource, DdManager *ddDestination, DdNode *f)
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
#define Gia_ManForEachCiVec(vVec, p, pObj, i)
Definition gia.h:1232
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition giaDup.c:3880
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
int Gia_ManConeSize(Gia_Man_t *p, int *pNodes, int nNodes)
Definition giaDfs.c:375
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
void Gia_ManCollectAnds(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vNodes, Vec_Int_t *vLeaves)
Definition giaDfs.c:125
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int nSuppMax
Definition llb3Image.c:83
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
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
Vec_Int_t vFanins
Definition abc.h:143
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
int iTemp
Definition abc.h:149
Vec_Int_t vFanouts
Definition abc.h:144
Abc_Obj_t * pCopy
Definition abc.h:148
int * pObj2Count
Definition cnf.h:65
int * pObj2Clause
Definition cnf.h:64
int ** pClauses
Definition cnf.h:62
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
char * pArray
Definition bblif.c:51
#define assert(ex)
Definition util_old.h:213
int strcmp()
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
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
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42