ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcFunc.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22#include "base/main/main.h"
23#include "map/mio/mio.h"
24
25#ifdef ABC_USE_CUDD
26#include "bdd/extrab/extraBdd.h"
27#endif
28
30
31
35
36#define ABC_MAX_CUBES 1000000
37#define ABC_MAX_CUBES2 10000
38
39static Hop_Obj_t * Abc_ConvertSopToAig( Hop_Man_t * pMan, char * pSop );
40
41#ifdef ABC_USE_CUDD
42
43int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFanins, Vec_Str_t * vCube, int fPhase );
44static DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot);
45extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
46extern void Abc_NtkSortCubes( Abc_Ntk_t * pNtk, int fWeight );
47
51
63void Abc_ConvertSopToBdd2Count( char * pSop, int nCubes, int nStep, int iVar, int pRes[3] )
64{
65 int i;
66 for ( i = 0; i < nCubes; i++ )
67 if ( pSop[i*nStep+iVar] == '-' )
68 pRes[0]++, assert( pRes[1] == 0 && pRes[2] == 0 );
69 else if ( pSop[i*nStep+iVar] == '0' )
70 pRes[1]++, assert( pRes[2] == 0 );
71 else if ( pSop[i*nStep+iVar] == '1' )
72 pRes[2]++;
73 else assert( 0 );
74}
75DdNode * Abc_ConvertSopToBdd2_rec( DdManager * dd, char * pSop, DdNode ** pbVars, int nCubes, int nStep, int iVar )
76{
77 DdNode * bRes[5] = {NULL};
78 int pRes[3] = {0}, i, Start = 0;
79 if ( nCubes == 0 )
80 return Cudd_ReadLogicZero(dd);
81 if ( iVar == nStep - 3 )
82 return Cudd_ReadOne(dd);
83 Abc_ConvertSopToBdd2Count( pSop, nCubes, nStep, iVar, pRes );
84 for ( i = 0; i < 3; Start += pRes[i++] )
85 bRes[i] = Abc_ConvertSopToBdd2_rec( dd, pSop + Start*nStep, pbVars, pRes[i], nStep, iVar+1 ), Cudd_Ref( bRes[i] );
86 bRes[3] = Cudd_bddIte( dd, pbVars[iVar], bRes[2], bRes[1] ); Cudd_Ref( bRes[3] );
87 Cudd_RecursiveDeref( dd, bRes[1] );
88 Cudd_RecursiveDeref( dd, bRes[2] );
89 bRes[4] = Cudd_bddOr( dd, bRes[0], bRes[3] ); Cudd_Ref( bRes[4] );
90 Cudd_RecursiveDeref( dd, bRes[3] );
91 Cudd_RecursiveDeref( dd, bRes[0] );
92 Cudd_Deref( bRes[4] );
93 return bRes[4];
94}
95DdNode * Abc_ConvertSopToBdd2( DdManager * dd, char * pSop, DdNode ** pbVars )
96{
97 int nCubes = Abc_SopGetCubeNum(pSop);
98 int nStep = Abc_SopGetVarNum(pSop) + 3;
99 assert( pSop[nCubes*nStep] == '\0' );
100 return Abc_ConvertSopToBdd2_rec( dd, pSop, pbVars, nCubes, nStep, 0 );
101}
102
114DdNode * Abc_ConvertSopToBdd( DdManager * dd, char * pSop, DdNode ** pbVars )
115{
116 DdNode * bSum, * bCube, * bTemp, * bVar;
117 char * pCube;
118 int nVars, Value, v;
119
120 // start the cover
121 nVars = Abc_SopGetVarNum(pSop);
122 bSum = Cudd_ReadLogicZero(dd); Cudd_Ref( bSum );
123 if ( Abc_SopIsExorType(pSop) )
124 {
125 for ( v = 0; v < nVars; v++ )
126 {
127 bSum = Cudd_bddXor( dd, bTemp = bSum, pbVars? pbVars[v] : Cudd_bddIthVar(dd, v) ); Cudd_Ref( bSum );
128 Cudd_RecursiveDeref( dd, bTemp );
129 }
130 }
131 else if ( Abc_SopGetCubeNum(pSop) > ABC_MAX_CUBES2 )
132 {
133 Cudd_Deref( bSum );
134 if ( pbVars )
135 bSum = Abc_ConvertSopToBdd2( dd, pSop, pbVars );
136 else
137 {
138 DdNode ** pbVars = ABC_ALLOC( DdNode *, nVars );
139 for ( v = 0; v < nVars; v++ )
140 pbVars[v] = Cudd_bddIthVar( dd, v );
141 bSum = Abc_ConvertSopToBdd2( dd, pSop, pbVars );
142 ABC_FREE( pbVars );
143 }
144 Cudd_Ref( bSum );
145 }
146 else
147 {
148 // check the logic function of the node
149 Abc_SopForEachCube( pSop, nVars, pCube )
150 {
151 bCube = Cudd_ReadOne(dd); Cudd_Ref( bCube );
152 Abc_CubeForEachVar( pCube, Value, v )
153 {
154 if ( Value == '0' )
155 bVar = Cudd_Not( pbVars? pbVars[v] : Cudd_bddIthVar( dd, v ) );
156 else if ( Value == '1' )
157 bVar = pbVars? pbVars[v] : Cudd_bddIthVar( dd, v );
158 else
159 continue;
160 bCube = Cudd_bddAnd( dd, bTemp = bCube, bVar ); Cudd_Ref( bCube );
161 Cudd_RecursiveDeref( dd, bTemp );
162 }
163 bSum = Cudd_bddOr( dd, bTemp = bSum, bCube );
164 Cudd_Ref( bSum );
165 Cudd_RecursiveDeref( dd, bTemp );
166 Cudd_RecursiveDeref( dd, bCube );
167 }
168 }
169 // complement the result if necessary
170 bSum = Cudd_NotCond( bSum, !Abc_SopGetPhase(pSop) );
171 Cudd_Deref( bSum );
172 return bSum;
173}
174
186int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk )
187{
188 Abc_Obj_t * pNode;
189 DdManager * dd, * ddTemp = NULL;
190 Vec_Int_t * vFanins = NULL;
191 int nFaninsMax, i, k, iVar, nCubesMax = 0;
192
193 assert( Abc_NtkHasSop(pNtk) );
194
195 // check SOP sizes
196 Abc_NtkForEachNode( pNtk, pNode, i )
197 nCubesMax = Abc_MaxInt( nCubesMax, Abc_SopGetCubeNum((char *)pNode->pData) );
198 if ( nCubesMax > ABC_MAX_CUBES2 )
199 Abc_NtkSortCubes( pNtk, 0 );
200
201 // start the functionality manager
202 nFaninsMax = Abc_NtkGetFaninMax( pNtk );
203 if ( nFaninsMax == 0 )
204 printf( "Warning: The network has only constant nodes.\n" );
205 dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
206
207 // start temporary manager for reordered local functions
208 if ( nFaninsMax > 10 )
209 {
210 ddTemp = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
211 Cudd_AutodynEnable( ddTemp, CUDD_REORDER_SYMM_SIFT );
212 vFanins = Vec_IntAlloc( nFaninsMax );
213 }
214
215 // convert each node from SOP to BDD
216 Abc_NtkForEachNode( pNtk, pNode, i )
217 {
218 if ( Abc_ObjIsBarBuf(pNode) )
219 continue;
220 assert( pNode->pData );
221 if ( Abc_ObjFaninNum(pNode) > 10 )
222 {
223 DdNode * pFunc = Abc_ConvertSopToBdd( ddTemp, (char *)pNode->pData, NULL );
224 if ( pFunc == NULL )
225 {
226 printf( "Abc_NtkSopToBdd: Error while converting SOP into BDD.\n" );
227 return 0;
228 }
229 Cudd_Ref( pFunc );
230 // find variable mapping
231 Vec_IntFill( vFanins, Abc_ObjFaninNum(pNode), -1 );
232 for ( k = iVar = 0; k < nFaninsMax; k++ )
233 if ( ddTemp->invperm[k] < Abc_ObjFaninNum(pNode) )
234 Vec_IntWriteEntry( vFanins, ddTemp->invperm[k], iVar++ );
235 assert( iVar == Abc_ObjFaninNum(pNode) );
236 // transfer to the main manager
237 pNode->pData = Extra_TransferPermute( ddTemp, dd, pFunc, Vec_IntArray(vFanins) );
238 Cudd_Ref( (DdNode *)pNode->pData );
239 Cudd_RecursiveDeref( ddTemp, pFunc );
240 // update variable order
241 Vec_IntClear( vFanins );
242 for ( k = 0; k < nFaninsMax; k++ )
243 if ( ddTemp->invperm[k] < Abc_ObjFaninNum(pNode) )
244 Vec_IntPush( vFanins, Vec_IntEntry(&pNode->vFanins, ddTemp->invperm[k]) );
245 for ( k = 0; k < Abc_ObjFaninNum(pNode); k++ )
246 Vec_IntWriteEntry( &pNode->vFanins, k, Vec_IntEntry(vFanins, k) );
247 }
248 else
249 {
250 pNode->pData = Abc_ConvertSopToBdd( dd, (char *)pNode->pData, NULL );
251 if ( pNode->pData == NULL )
252 {
253 printf( "Abc_NtkSopToBdd: Error while converting SOP into BDD.\n" );
254 return 0;
255 }
256 Cudd_Ref( (DdNode *)pNode->pData );
257 }
258 }
259
260 if ( ddTemp )
261 {
262// printf( "Reorderings performed = %d.\n", Cudd_ReadReorderings(ddTemp) );
263 Extra_StopManager( ddTemp );
264 }
265 Vec_IntFreeP( &vFanins );
266 Mem_FlexStop( (Mem_Flex_t *)pNtk->pManFunc, 0 );
267 pNtk->pManFunc = dd;
268
269 // update the network type
270 pNtk->ntkFunc = ABC_FUNC_BDD;
271 return 1;
272}
273
274
275
276
288char * Abc_ConvertBddToSop( Mem_Flex_t * pMan, DdManager * dd, DdNode * bFuncOn, DdNode * bFuncOnDc, int nFanins, int fAllPrimes, Vec_Str_t * vCube, int fMode )
289{
290 int fVerify = 0;
291 char * pSop;
292 DdNode * bFuncNew, * bCover, * zCover, * zCover0, * zCover1;
293 int nCubes = 0, nCubes0, nCubes1, fPhase = 0;
294
295 assert( bFuncOn == bFuncOnDc || Cudd_bddLeq( dd, bFuncOn, bFuncOnDc ) );
296 if ( Cudd_IsConstant(bFuncOn) || Cudd_IsConstant(bFuncOnDc) )
297 {
298 if ( pMan )
299 pSop = Mem_FlexEntryFetch( pMan, nFanins + 4 );
300 else
301 pSop = ABC_ALLOC( char, nFanins + 4 );
302 pSop[0] = ' ';
303 pSop[1] = '0' + (int)(bFuncOn == Cudd_ReadOne(dd));
304 pSop[2] = '\n';
305 pSop[3] = '\0';
306 return pSop;
307 }
308
309 if ( fMode == -1 )
310 { // try both phases
311 assert( fAllPrimes == 0 );
312
313 // get the ZDD of the negative polarity
314 bCover = Cudd_zddIsop( dd, Cudd_Not(bFuncOnDc), Cudd_Not(bFuncOn), &zCover0 );
315 Cudd_Ref( zCover0 );
316 Cudd_Ref( bCover );
317 Cudd_RecursiveDeref( dd, bCover );
318 nCubes0 = Abc_CountZddCubes( dd, zCover0 );
319
320 // get the ZDD of the positive polarity
321 bCover = Cudd_zddIsop( dd, bFuncOn, bFuncOnDc, &zCover1 );
322 Cudd_Ref( zCover1 );
323 Cudd_Ref( bCover );
324 Cudd_RecursiveDeref( dd, bCover );
325 nCubes1 = Abc_CountZddCubes( dd, zCover1 );
326
327 // compare the number of cubes
328 if ( nCubes1 <= nCubes0 )
329 { // use positive polarity
330 nCubes = nCubes1;
331 zCover = zCover1;
332 Cudd_RecursiveDerefZdd( dd, zCover0 );
333 fPhase = 1;
334 }
335 else
336 { // use negative polarity
337 nCubes = nCubes0;
338 zCover = zCover0;
339 Cudd_RecursiveDerefZdd( dd, zCover1 );
340 fPhase = 0;
341 }
342 }
343 else if ( fMode == 0 )
344 {
345 // get the ZDD of the negative polarity
346 if ( fAllPrimes )
347 {
348 zCover = Extra_zddPrimes( dd, Cudd_Not(bFuncOnDc) );
349 Cudd_Ref( zCover );
350 }
351 else
352 {
353 bCover = Cudd_zddIsop( dd, Cudd_Not(bFuncOnDc), Cudd_Not(bFuncOn), &zCover );
354 Cudd_Ref( zCover );
355 Cudd_Ref( bCover );
356 Cudd_RecursiveDeref( dd, bCover );
357 }
358 nCubes = Abc_CountZddCubes( dd, zCover );
359 fPhase = 0;
360 }
361 else if ( fMode == 1 )
362 {
363 // get the ZDD of the positive polarity
364 if ( fAllPrimes )
365 {
366 zCover = Extra_zddPrimes( dd, bFuncOnDc );
367 Cudd_Ref( zCover );
368 }
369 else
370 {
371 bCover = Cudd_zddIsop( dd, bFuncOn, bFuncOnDc, &zCover );
372 Cudd_Ref( zCover );
373 Cudd_Ref( bCover );
374 Cudd_RecursiveDeref( dd, bCover );
375 }
376 nCubes = Abc_CountZddCubes( dd, zCover );
377 fPhase = 1;
378 }
379 else
380 {
381 assert( 0 );
382 }
383
384 if ( nCubes > ABC_MAX_CUBES )
385 {
386 Cudd_RecursiveDerefZdd( dd, zCover );
387 printf( "The number of cubes exceeded the predefined limit (%d).\n", ABC_MAX_CUBES );
388 return NULL;
389 }
390
391 // allocate memory for the cover
392 if ( pMan )
393 pSop = Mem_FlexEntryFetch( pMan, (nFanins + 3) * nCubes + 1 );
394 else
395 pSop = ABC_ALLOC( char, (nFanins + 3) * nCubes + 1 );
396 pSop[(nFanins + 3) * nCubes] = 0;
397 // create the SOP
398 Vec_StrFill( vCube, nFanins, '-' );
399 Vec_StrPush( vCube, '\0' );
400 Abc_ConvertZddToSop( dd, zCover, pSop, nFanins, vCube, fPhase );
401 Cudd_RecursiveDerefZdd( dd, zCover );
402
403 // verify
404 if ( fVerify )
405 {
406 bFuncNew = Abc_ConvertSopToBdd( dd, pSop, NULL ); Cudd_Ref( bFuncNew );
407 if ( bFuncOn == bFuncOnDc )
408 {
409 if ( bFuncNew != bFuncOn )
410 printf( "Verification failed.\n" );
411 }
412 else
413 {
414 if ( !Cudd_bddLeq(dd, bFuncOn, bFuncNew) || !Cudd_bddLeq(dd, bFuncNew, bFuncOnDc) )
415 printf( "Verification failed.\n" );
416 }
417 Cudd_RecursiveDeref( dd, bFuncNew );
418 }
419 return pSop;
420}
421
433int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort )
434{
435 Vec_Int_t * vGuide;
436 Vec_Str_t * vCube;
437 Abc_Obj_t * pNode;
438 Mem_Flex_t * pManNew;
439 DdManager * dd = (DdManager *)pNtk->pManFunc;
440 DdNode * bFunc;
441 int i, nCubes;
442
443 // compute SOP size
444 vGuide = Vec_IntAlloc( Abc_NtkObjNumMax(pNtk) );
445 Vec_IntFill( vGuide, Abc_NtkObjNumMax(pNtk), fMode );
446 if ( nCubeLimit < ABC_INFINITY )
447 {
448 // collect all BDDs into one array
449 Vec_Ptr_t * vFuncs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
450 assert( !Cudd_ReorderingStatus(dd, (Cudd_ReorderingType *)&nCubes) );
451 Abc_NtkForEachNode( pNtk, pNode, i )
452 if ( !Abc_ObjIsBarBuf(pNode) )
453 Vec_PtrWriteEntry( vFuncs, i, pNode->pData );
454 // compute the number of cubes in the ISOPs and detemine polarity
455 nCubes = Extra_bddCountCubes( dd, (DdNode **)Vec_PtrArray(vFuncs), Vec_PtrSize(vFuncs), fMode, nCubeLimit, Vec_IntArray(vGuide) );
456 Vec_PtrFree( vFuncs );
457 if ( nCubes == -1 )
458 {
459 Vec_IntFree( vGuide );
460 return 0;
461 }
462 //printf( "The total number of cubes = %d.\n", nCubes );
463 }
464
465 assert( Abc_NtkHasBdd(pNtk) );
466 if ( dd->size > 0 )
467 Cudd_zddVarsFromBddVars( dd, 2 );
468 // create the new manager
469 pManNew = Mem_FlexStart();
470
471 // go through the objects
472 vCube = Vec_StrAlloc( 100 );
473 Abc_NtkForEachNode( pNtk, pNode, i )
474 {
475 if ( Abc_ObjIsBarBuf(pNode) )
476 continue;
477 assert( pNode->pData );
478 bFunc = (DdNode *)pNode->pData;
479 pNode->pNext = (Abc_Obj_t *)Abc_ConvertBddToSop( pManNew, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, Vec_IntEntry(vGuide, i) );
480 if ( pNode->pNext == NULL )
481 {
482 Mem_FlexStop( pManNew, 0 );
483 Abc_NtkCleanNext( pNtk );
484// printf( "Converting from BDDs to SOPs has failed.\n" );
485 Vec_IntFree( vGuide );
486 Vec_StrFree( vCube );
487 return 0;
488 }
489 // it may happen that a constant node was created after structural mapping
490 if ( Abc_SopGetVarNum((char *)pNode->pNext) == 0 )
491 pNode->vFanins.nSize = 0;
492 // check the support
493 if ( Abc_ObjFaninNum(pNode) != Abc_SopGetVarNum((char *)pNode->pNext) )
494 {
495 printf( "Node %d with level %d has %d fanins but its SOP has support size %d.\n",
496 pNode->Id, pNode->Level, Abc_ObjFaninNum(pNode), Abc_SopGetVarNum((char *)pNode->pNext) );
497 fflush( stdout );
498 }
499 assert( Abc_ObjFaninNum(pNode) == Abc_SopGetVarNum((char *)pNode->pNext) );
500 }
501 Vec_IntFree( vGuide );
502 Vec_StrFree( vCube );
503
504 // update the network type
505 pNtk->ntkFunc = ABC_FUNC_SOP;
506 // set the new manager
507 pNtk->pManFunc = pManNew;
508 // transfer from next to data
509 Abc_NtkForEachNode( pNtk, pNode, i )
510 {
511 if ( Abc_ObjIsBarBuf(pNode) )
512 continue;
513 Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
514 pNode->pData = pNode->pNext;
515 pNode->pNext = NULL;
516 }
517
518 // check for remaining references in the package
519 Extra_StopManager( dd );
520
521 // reorder fanins and cubes to make SOPs more human-readable
522 if ( fCubeSort )
523 Abc_NtkSortSops( pNtk );
524 return 1;
525}
526
527
539void Abc_ConvertZddToSop_rec( DdManager * dd, DdNode * zCover, char * pSop, int nFanins, Vec_Str_t * vCube, int fPhase, int * pnCubes )
540{
541 DdNode * zC0, * zC1, * zC2;
542 int Index;
543
544 if ( zCover == dd->zero )
545 return;
546 if ( zCover == dd->one )
547 {
548 char * pCube;
549 pCube = pSop + (*pnCubes) * (nFanins + 3);
550 sprintf( pCube, "%s %d\n", vCube->pArray, fPhase );
551 (*pnCubes)++;
552 return;
553 }
554 Index = zCover->index/2;
555 assert( Index < nFanins );
556 extraDecomposeCover( dd, zCover, &zC0, &zC1, &zC2 );
557 vCube->pArray[Index] = '0';
558 Abc_ConvertZddToSop_rec( dd, zC0, pSop, nFanins, vCube, fPhase, pnCubes );
559 vCube->pArray[Index] = '1';
560 Abc_ConvertZddToSop_rec( dd, zC1, pSop, nFanins, vCube, fPhase, pnCubes );
561 vCube->pArray[Index] = '-';
562 Abc_ConvertZddToSop_rec( dd, zC2, pSop, nFanins, vCube, fPhase, pnCubes );
563}
564
576int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFanins, Vec_Str_t * vCube, int fPhase )
577{
578 int nCubes = 0;
579 Abc_ConvertZddToSop_rec( dd, zCover, pSop, nFanins, vCube, fPhase, &nCubes );
580 return nCubes;
581}
582
583
595void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Mem_Flex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 )
596{
597 assert( Abc_NtkHasBdd(pNode->pNtk) );
598 *ppSop0 = Abc_ConvertBddToSop( pMmMan, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, (DdNode *)pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 0 );
599 *ppSop1 = Abc_ConvertBddToSop( pMmMan, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, (DdNode *)pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 1 );
600}
601
602
615{
616 DdManager * dd;
617 DdNode * bFunc;
618 Vec_Str_t * vCube;
619 Abc_Obj_t * pNode;
620 int nFaninsMax, fFound, i;
621
622 assert( Abc_NtkHasSop(pNtk) );
623
624 // check if there are nodes with complemented SOPs
625 fFound = 0;
626 Abc_NtkForEachNode( pNtk, pNode, i )
627 if ( !Abc_ObjIsBarBuf(pNode) && Abc_SopIsComplement((char *)pNode->pData) )
628 {
629 fFound = 1;
630 break;
631 }
632 if ( !fFound )
633 return;
634
635 // start the BDD package
636 nFaninsMax = Abc_NtkGetFaninMax( pNtk );
637 if ( nFaninsMax == 0 )
638 printf( "Warning: The network has only constant nodes.\n" );
639 dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
640
641 // change the cover of negated nodes
642 vCube = Vec_StrAlloc( 100 );
643 Abc_NtkForEachNode( pNtk, pNode, i )
644 if ( !Abc_ObjIsBarBuf(pNode) && Abc_SopIsComplement((char *)pNode->pData) )
645 {
646 bFunc = Abc_ConvertSopToBdd( dd, (char *)pNode->pData, NULL ); Cudd_Ref( bFunc );
647 pNode->pData = Abc_ConvertBddToSop( (Mem_Flex_t *)pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, 1 );
648 Cudd_RecursiveDeref( dd, bFunc );
649 assert( !Abc_SopIsComplement((char *)pNode->pData) );
650 }
651 Vec_StrFree( vCube );
652 Extra_StopManager( dd );
653}
654
655
656
657
669void Abc_CountZddCubes_rec( DdManager * dd, DdNode * zCover, int * pnCubes )
670{
671 DdNode * zC0, * zC1, * zC2;
672 if ( zCover == dd->zero )
673 return;
674 if ( zCover == dd->one )
675 {
676 (*pnCubes)++;
677 return;
678 }
679 if ( (*pnCubes) > ABC_MAX_CUBES )
680 return;
681 extraDecomposeCover( dd, zCover, &zC0, &zC1, &zC2 );
682 Abc_CountZddCubes_rec( dd, zC0, pnCubes );
683 Abc_CountZddCubes_rec( dd, zC1, pnCubes );
684 Abc_CountZddCubes_rec( dd, zC2, pnCubes );
685}
686
698int Abc_CountZddCubes( DdManager * dd, DdNode * zCover )
699{
700 int nCubes = 0;
701 Abc_CountZddCubes_rec( dd, zCover, &nCubes );
702 return nCubes;
703}
704
716int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
717{
718 Abc_Obj_t * pNode;
719 Hop_Man_t * pMan;
720 DdNode * pFunc;
721 DdManager * dd, * ddTemp = NULL;
722 Vec_Int_t * vFanins = NULL;
723 int nFaninsMax, i, k, iVar;
724
725 assert( Abc_NtkHasAig(pNtk) );
726
727 // start the functionality manager
728 nFaninsMax = Abc_NtkGetFaninMax( pNtk );
729 if ( nFaninsMax == 0 )
730 printf( "Warning: The network has only constant nodes.\n" );
731
732 dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
733
734 // start temporary manager for reordered local functions
735 ddTemp = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
736 Cudd_AutodynEnable( ddTemp, CUDD_REORDER_SYMM_SIFT );
737 vFanins = Vec_IntAlloc( nFaninsMax );
738
739 // set the mapping of elementary AIG nodes into the elementary BDD nodes
740 pMan = (Hop_Man_t *)pNtk->pManFunc;
741 assert( Hop_ManPiNum(pMan) >= nFaninsMax );
742 for ( i = 0; i < nFaninsMax; i++ )
743 Hop_ManPi(pMan, i)->pData = Cudd_bddIthVar(ddTemp, i);
744
745 // convert each node from SOP to BDD
746 Abc_NtkForEachNode( pNtk, pNode, i )
747 {
748 if ( Abc_ObjIsBarBuf(pNode) )
749 continue;
750 pFunc = Abc_ConvertAigToBdd( ddTemp, (Hop_Obj_t *)pNode->pData );
751 if ( pFunc == NULL )
752 {
753 printf( "Abc_NtkAigToBdd: Error while converting AIG into BDD.\n" );
754 return 0;
755 }
756 Cudd_Ref( pFunc );
757 // find variable mapping
758 Vec_IntFill( vFanins, Abc_ObjFaninNum(pNode), -1 );
759 for ( k = iVar = 0; k < nFaninsMax; k++ )
760 if ( ddTemp->invperm[k] < Abc_ObjFaninNum(pNode) )
761 Vec_IntWriteEntry( vFanins, ddTemp->invperm[k], iVar++ );
762 assert( iVar == Abc_ObjFaninNum(pNode) );
763 // transfer to the main manager
764 pNode->pData = Extra_TransferPermute( ddTemp, dd, pFunc, Vec_IntArray(vFanins) );
765 Cudd_Ref( (DdNode *)pNode->pData );
766 Cudd_RecursiveDeref( ddTemp, pFunc );
767 // update variable order
768 Vec_IntClear( vFanins );
769 for ( k = 0; k < nFaninsMax; k++ )
770 if ( ddTemp->invperm[k] < Abc_ObjFaninNum(pNode) )
771 Vec_IntPush( vFanins, Vec_IntEntry(&pNode->vFanins, ddTemp->invperm[k]) );
772 for ( k = 0; k < Abc_ObjFaninNum(pNode); k++ )
773 Vec_IntWriteEntry( &pNode->vFanins, k, Vec_IntEntry(vFanins, k) );
774 }
775
776// printf( "Reorderings performed = %d.\n", Cudd_ReadReorderings(ddTemp) );
777 Extra_StopManager( ddTemp );
778 Vec_IntFreeP( &vFanins );
779 Hop_ManStop( (Hop_Man_t *)pNtk->pManFunc );
780 pNtk->pManFunc = dd;
781
782 // update the network type
783 pNtk->ntkFunc = ABC_FUNC_BDD;
784 return 1;
785}
786
798void Abc_ConvertAigToBdd_rec1( DdManager * dd, Hop_Obj_t * pObj )
799{
800 assert( !Hop_IsComplement(pObj) );
801 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
802 return;
803 Abc_ConvertAigToBdd_rec1( dd, Hop_ObjFanin0(pObj) );
804 Abc_ConvertAigToBdd_rec1( dd, Hop_ObjFanin1(pObj) );
805 pObj->pData = Cudd_bddAnd( dd, (DdNode *)Hop_ObjChild0Copy(pObj), (DdNode *)Hop_ObjChild1Copy(pObj) );
806 Cudd_Ref( (DdNode *)pObj->pData );
807 assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
808 Hop_ObjSetMarkA( pObj );
809}
810
822void Abc_ConvertAigToBdd_rec2( DdManager * dd, Hop_Obj_t * pObj )
823{
824 assert( !Hop_IsComplement(pObj) );
825 if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
826 return;
827 Abc_ConvertAigToBdd_rec2( dd, Hop_ObjFanin0(pObj) );
828 Abc_ConvertAigToBdd_rec2( dd, Hop_ObjFanin1(pObj) );
829 Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
830 pObj->pData = NULL;
831 assert( Hop_ObjIsMarkA(pObj) ); // loop detection
832 Hop_ObjClearMarkA( pObj );
833}
834
846DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot )
847{
848 DdNode * bFunc;
849 // check the case of a constant
850 if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
851 return Cudd_NotCond( Cudd_ReadOne(dd), Hop_IsComplement(pRoot) );
852 // construct BDD
853 Abc_ConvertAigToBdd_rec1( dd, Hop_Regular(pRoot) );
854 // hold on to the result
855 bFunc = Cudd_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) ); Cudd_Ref( bFunc );
856 // dereference BDD
857 Abc_ConvertAigToBdd_rec2( dd, Hop_Regular(pRoot) );
858 // return the result
859 Cudd_Deref( bFunc );
860 return bFunc;
861}
862
863#else
864
865int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk ) { return 1; }
866int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort ) { return 1; }
867void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Mem_Flex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 ) {}
869int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk ) { return 1; }
870
871#endif
872
885{
886 Abc_Obj_t * pNode;
887 Hop_Man_t * pMan;
888 int i, Max;
889
890 assert( Abc_NtkHasSop(pNtk) );
891
892 // make dist1-free and SCC-free
893// Abc_NtkMakeLegit( pNtk );
894
895 // start the functionality manager
896 pMan = Hop_ManStart();
897 Max = Abc_NtkGetFaninMax(pNtk);
898 if ( Max ) Hop_IthVar( pMan, Max-1 );
899
900 // convert each node from SOP to BDD
901 Abc_NtkForEachNode( pNtk, pNode, i )
902 {
903 if ( Abc_ObjIsBarBuf(pNode) )
904 continue;
905 assert( pNode->pData );
906 pNode->pData = Abc_ConvertSopToAig( pMan, (char *)pNode->pData );
907 if ( pNode->pData == NULL )
908 {
909 Hop_ManStop( pMan );
910 printf( "Abc_NtkSopToAig: Error while converting SOP into AIG.\n" );
911 return 0;
912 }
913 }
914 Mem_FlexStop( (Mem_Flex_t *)pNtk->pManFunc, 0 );
915 pNtk->pManFunc = pMan;
916
917 // update the network type
918 pNtk->ntkFunc = ABC_FUNC_AIG;
919 return 1;
920}
921
922
935{
936 Hop_Obj_t * pAnd, * pSum;
937 int i, Value, nFanins;
938 char * pCube;
939 // get the number of variables
940 nFanins = Abc_SopGetVarNum(pSop);
941 if ( Abc_SopIsExorType(pSop) )
942 {
943 pSum = Hop_ManConst0(pMan);
944 for ( i = 0; i < nFanins; i++ )
945 pSum = Hop_Exor( pMan, pSum, Hop_IthVar(pMan,i) );
946 }
947 else
948 {
949 // go through the cubes of the node's SOP
950 pSum = Hop_ManConst0(pMan);
951 Abc_SopForEachCube( pSop, nFanins, pCube )
952 {
953 // create the AND of literals
954 pAnd = Hop_ManConst1(pMan);
955 Abc_CubeForEachVar( pCube, Value, i )
956 {
957 if ( Value == '1' )
958 pAnd = Hop_And( pMan, pAnd, Hop_IthVar(pMan,i) );
959 else if ( Value == '0' )
960 pAnd = Hop_And( pMan, pAnd, Hop_Not(Hop_IthVar(pMan,i)) );
961 }
962 // add to the sum of cubes
963 pSum = Hop_Or( pMan, pSum, pAnd );
964 }
965 }
966 // decide whether to complement the result
967 if ( Abc_SopIsComplement(pSop) )
968 pSum = Hop_Not(pSum);
969 return pSum;
970}
971
983Hop_Obj_t * Abc_ConvertSopToAig( Hop_Man_t * pMan, char * pSop )
984{
985 extern Hop_Obj_t * Dec_GraphFactorSop( Hop_Man_t * pMan, char * pSop );
986 int fUseFactor = 1;
987 // consider the constant node
988 if ( Abc_SopGetVarNum(pSop) == 0 )
989 return Hop_NotCond( Hop_ManConst1(pMan), Abc_SopIsConst0(pSop) );
990 // decide when to use factoring
991 if ( fUseFactor && Abc_SopGetVarNum(pSop) > 2 && Abc_SopGetCubeNum(pSop) > 1 && !Abc_SopIsExorType(pSop) )
992 return Dec_GraphFactorSop( pMan, pSop );
993 return Abc_ConvertSopToAigInternal( pMan, pSop );
994}
995
996
1009{
1010 assert( !Hop_IsComplement(pObj) );
1011 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
1012 return;
1013 Abc_ConvertAigToGia_rec1( p, Hop_ObjFanin0(pObj) );
1014 Abc_ConvertAigToGia_rec1( p, Hop_ObjFanin1(pObj) );
1015 pObj->iData = Gia_ManAppendAnd2( p, Hop_ObjChild0CopyI(pObj), Hop_ObjChild1CopyI(pObj) );
1016 assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
1017 Hop_ObjSetMarkA( pObj );
1018}
1020{
1021 assert( !Hop_IsComplement(pObj) );
1022 if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
1023 return;
1024 Abc_ConvertAigToGia_rec2( Hop_ObjFanin0(pObj) );
1025 Abc_ConvertAigToGia_rec2( Hop_ObjFanin1(pObj) );
1026 assert( Hop_ObjIsMarkA(pObj) ); // loop detection
1027 Hop_ObjClearMarkA( pObj );
1028}
1030{
1031 assert( !Hop_IsComplement(pRoot) );
1032 if ( Hop_ObjIsConst1( pRoot ) )
1033 return 1;
1034 Abc_ConvertAigToGia_rec1( p, pRoot );
1035 Abc_ConvertAigToGia_rec2( pRoot );
1036 return pRoot->iData;
1037}
1038
1050Gia_Man_t * Abc_NtkAigToGia( Abc_Ntk_t * p, int fGiaSimple )
1051{
1052 Gia_Man_t * pNew;
1053 Hop_Man_t * pHopMan;
1054 Hop_Obj_t * pHopObj;
1055 Vec_Int_t * vMapping = NULL;
1056 Vec_Ptr_t * vNodes;
1057 Abc_Obj_t * pNode, * pFanin;
1058 int i, k, nObjs, iGiaObj;
1059 assert( Abc_NtkIsAigLogic(p) );
1060 pHopMan = (Hop_Man_t *)p->pManFunc;
1061 // create new manager
1062 pNew = Gia_ManStart( 10000 );
1063 pNew->pName = Abc_UtilStrsav( Abc_NtkName(p) );
1064 pNew->pSpec = Abc_UtilStrsav( Abc_NtkSpec(p) );
1065 pNew->fGiaSimple = fGiaSimple;
1067 Hop_ManConst1(pHopMan)->iData = 1;
1068 // create primary inputs
1069 Abc_NtkForEachCi( p, pNode, i )
1070 pNode->iTemp = Gia_ManAppendCi(pNew);
1071 // find the number of objects
1072 nObjs = 1 + Abc_NtkCiNum(p) + Abc_NtkCoNum(p);
1073 Abc_NtkForEachNode( p, pNode, i )
1074 nObjs += Abc_ObjIsBarBuf(pNode) ? 1 : Hop_DagSize( (Hop_Obj_t *)pNode->pData );
1075 if ( !fGiaSimple )
1076 vMapping = Vec_IntStart( nObjs );
1077 // iterate through nodes used in the mapping
1078 vNodes = Abc_NtkDfs( p, 0 );
1079 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
1080 {
1081 if ( Abc_ObjIsBarBuf(pNode) )
1082 {
1083 assert( !Abc_ObjFaninC0(pNode) );
1084 pNode->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanin0(pNode)->iTemp );
1085 continue;
1086 }
1087 Abc_ObjForEachFanin( pNode, pFanin, k )
1088 Hop_ManPi(pHopMan, k)->iData = pFanin->iTemp;
1089 pHopObj = Hop_Regular( (Hop_Obj_t *)pNode->pData );
1090 if ( Hop_DagSize(pHopObj) > 0 )
1091 {
1092 assert( Abc_ObjFaninNum(pNode) <= Hop_ManPiNum(pHopMan) );
1093 Abc_ConvertAigToGia( pNew, pHopObj );
1094 iGiaObj = Abc_Lit2Var( pHopObj->iData );
1095 if ( vMapping && Gia_ObjIsAnd(Gia_ManObj(pNew, iGiaObj)) && !Vec_IntEntry(vMapping, iGiaObj) )
1096 {
1097 Vec_IntWriteEntry( vMapping, iGiaObj, Vec_IntSize(vMapping) );
1098 Vec_IntPush( vMapping, Abc_ObjFaninNum(pNode) );
1099 Abc_ObjForEachFanin( pNode, pFanin, k )
1100 Vec_IntPush( vMapping, Abc_Lit2Var(pFanin->iTemp) );
1101 Vec_IntPush( vMapping, iGiaObj );
1102 }
1103 }
1104 pNode->iTemp = Abc_LitNotCond( pHopObj->iData, Hop_IsComplement( (Hop_Obj_t *)pNode->pData ) );
1105 }
1106 // create primary outputs
1107 Abc_NtkForEachCo( p, pNode, i )
1108 Gia_ManAppendCo( pNew, Abc_ObjFanin0(pNode)->iTemp );
1109 Gia_ManSetRegNum( pNew, Abc_NtkLatchNum(p) );
1110 // copy original IDs
1111 pNew->vIdsOrig = Vec_IntStart( Gia_ManObjNum(pNew) );
1112 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
1113 Vec_IntWriteEntry( pNew->vIdsOrig, Abc_Lit2Var(pNode->iTemp), Abc_ObjId(pNode) );
1114 Vec_PtrFree( vNodes );
1115 // finish mapping
1116 assert( Gia_ManObjNum(pNew) <= nObjs );
1117 assert( pNew->vMapping == NULL );
1118 pNew->vMapping = vMapping;
1119 return pNew;
1120}
1121
1122
1135{
1136 assert( !Hop_IsComplement(pObj) );
1137 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
1138 return;
1139 Abc_ConvertAigToAig_rec( pNtkAig, Hop_ObjFanin0(pObj) );
1140 Abc_ConvertAigToAig_rec( pNtkAig, Hop_ObjFanin1(pObj) );
1141 pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
1142 assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
1143 Hop_ObjSetMarkA( pObj );
1144}
1145
1158{
1159 Hop_Man_t * pHopMan;
1160 Hop_Obj_t * pRoot;
1161 Abc_Obj_t * pFanin;
1162 int i;
1163 // get the local AIG
1164 pHopMan = (Hop_Man_t *)pObjOld->pNtk->pManFunc;
1165 pRoot = (Hop_Obj_t *)pObjOld->pData;
1166 // check the case of a constant
1167 if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
1168 return Abc_ObjNotCond( Abc_AigConst1(pNtkAig), Hop_IsComplement(pRoot) );
1169 // assign the fanin nodes
1170 Abc_ObjForEachFanin( pObjOld, pFanin, i )
1171 {
1172 assert( pFanin->pCopy != NULL );
1173 Hop_ManPi(pHopMan, i)->pData = pFanin->pCopy;
1174 }
1175 // construct the AIG
1176 Abc_ConvertAigToAig_rec( pNtkAig, Hop_Regular(pRoot) );
1177 Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
1178 // return the result
1179 return Abc_ObjNotCond( (Abc_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
1180}
1181
1182
1194int Abc_NtkMapToSopUsingLibrary( Abc_Ntk_t * pNtk, void* library)
1195{
1196 Abc_Obj_t * pNode;
1197 char * pSop;
1198 int i;
1199
1200 assert( Abc_NtkHasMapping(pNtk) );
1201 // update the functionality manager
1202 assert( pNtk->pManFunc == (void*) library );
1203 pNtk->pManFunc = Mem_FlexStart();
1204 // update the nodes
1205 Abc_NtkForEachNode( pNtk, pNode, i )
1206 {
1207 if ( Abc_ObjIsBarBuf(pNode) )
1208 continue;
1209 pSop = Mio_GateReadSop((Mio_Gate_t *)pNode->pData);
1210 assert( Abc_SopGetVarNum(pSop) == Abc_ObjFaninNum(pNode) );
1211 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, pSop );
1212 }
1213 pNtk->ntkFunc = ABC_FUNC_SOP;
1214 return 1;
1215}
1216
1229{
1230 extern void * Abc_FrameReadLibGen();
1232}
1233
1246{
1247 return 1;
1248}
1249
1261int Abc_NtkToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit )
1262{
1263 assert( !Abc_NtkIsStrash(pNtk) );
1264 if ( Abc_NtkHasBlackbox(pNtk) )
1265 return 1;
1266 if ( Abc_NtkHasSop(pNtk) )
1267 {
1268 if ( fMode == -1 )
1269 return 1;
1270 if ( !Abc_NtkSopToBdd(pNtk) )
1271 return 0;
1272 return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1);
1273 }
1274 if ( Abc_NtkHasMapping(pNtk) )
1275 return Abc_NtkMapToSop(pNtk);
1276 if ( Abc_NtkHasBdd(pNtk) )
1277 return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1);
1278 if ( Abc_NtkHasAig(pNtk) )
1279 {
1280 if ( !Abc_NtkAigToBdd(pNtk) )
1281 return 0;
1282 return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1);
1283 }
1284 assert( 0 );
1285 return 0;
1286}
1287
1300{
1301 assert( !Abc_NtkIsStrash(pNtk) );
1302 if ( Abc_NtkHasBlackbox(pNtk) )
1303 return 1;
1304 if ( Abc_NtkHasBdd(pNtk) )
1305 return 1;
1306 if ( Abc_NtkHasMapping(pNtk) )
1307 {
1308 Abc_NtkMapToSop(pNtk);
1309 return Abc_NtkSopToBdd(pNtk);
1310 }
1311 if ( Abc_NtkHasSop(pNtk) )
1312 {
1313 Abc_NtkSopToAig(pNtk);
1314 return Abc_NtkAigToBdd(pNtk);
1315 }
1316 if ( Abc_NtkHasAig(pNtk) )
1317 return Abc_NtkAigToBdd(pNtk);
1318 assert( 0 );
1319 return 0;
1320}
1321
1334{
1335 assert( !Abc_NtkIsStrash(pNtk) );
1336 if ( Abc_NtkHasBlackbox(pNtk) )
1337 return 1;
1338 if ( Abc_NtkHasAig(pNtk) )
1339 return 1;
1340 if ( Abc_NtkHasMapping(pNtk) )
1341 {
1342 Abc_NtkMapToSop(pNtk);
1343 return Abc_NtkSopToAig(pNtk);
1344 }
1345 if ( Abc_NtkHasBdd(pNtk) )
1346 {
1347 if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
1348 return 0;
1349 return Abc_NtkSopToAig(pNtk);
1350 }
1351 if ( Abc_NtkHasSop(pNtk) )
1352 return Abc_NtkSopToAig(pNtk);
1353 assert( 0 );
1354 return 0;
1355}
1356
1357
1370{
1371 Vec_Int_t * vFanins = Abc_ObjFaninVec( pObj );
1372 char * pCube, * pSop = (char*)pObj->pData;
1373 int i, j, nVars = Abc_SopGetVarNum( pSop );
1374 assert( nVars == Vec_IntSize(vFanins) );
1375 for ( i = 0; i < Vec_IntSize(vFanins); i++ )
1376 for ( j = i+1; j < Vec_IntSize(vFanins); j++ )
1377 {
1378 if ( Vec_IntEntry(vFanins, i) < Vec_IntEntry(vFanins, j) )
1379 continue;
1380 ABC_SWAP( int, Vec_IntArray(vFanins)[i], Vec_IntArray(vFanins)[j] );
1381 for ( pCube = pSop; *pCube; pCube += nVars + 3 ) {
1382 ABC_SWAP( char, pCube[i], pCube[j] );
1383 }
1384 }
1385}
1387{
1388 Abc_Obj_t * pObj; int i;
1389 assert( Abc_NtkIsSopLogic(pNtk) );
1390 Abc_NtkForEachNode( pNtk, pObj, i )
1391 Abc_ObjFaninSort( pObj );
1392}
1393
1397
1398
1400
void Abc_NtkSortCubes(Abc_Ntk_t *pNtk, int fWeight)
void Abc_ConvertAigToGia_rec2(Hop_Obj_t *pObj)
Definition abcFunc.c:1019
int Abc_NtkSopToBlifMv(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1245
#define ABC_MAX_CUBES
DECLARATIONS ///.
Definition abcFunc.c:36
#define ABC_MAX_CUBES2
Definition abcFunc.c:37
void Abc_NtkFaninSort(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1386
void Abc_ConvertAigToGia_rec1(Gia_Man_t *p, Hop_Obj_t *pObj)
Definition abcFunc.c:1008
Gia_Man_t * Abc_NtkAigToGia(Abc_Ntk_t *p, int fGiaSimple)
Definition abcFunc.c:1050
int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1228
Abc_Obj_t * Abc_ConvertAigToAig(Abc_Ntk_t *pNtkAig, Abc_Obj_t *pObjOld)
DECLARATIONS ///.
Definition abcFunc.c:1157
int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit, int fCubeSort)
Definition abcFunc.c:866
int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1333
int Abc_NtkMapToSopUsingLibrary(Abc_Ntk_t *pNtk, void *library)
Definition abcFunc.c:1194
int Abc_NtkSopToBdd(Abc_Ntk_t *pNtk)
Definition abcFunc.c:865
Hop_Obj_t * Abc_ConvertSopToAigInternal(Hop_Man_t *pMan, char *pSop)
Definition abcFunc.c:934
int Abc_NtkSopToAig(Abc_Ntk_t *pNtk)
Definition abcFunc.c:884
int Abc_ConvertAigToGia(Gia_Man_t *p, Hop_Obj_t *pRoot)
Definition abcFunc.c:1029
void Abc_NodeBddToCnf(Abc_Obj_t *pNode, Mem_Flex_t *pMmMan, Vec_Str_t *vCube, int fAllPrimes, char **ppSop0, char **ppSop1)
Definition abcFunc.c:867
int Abc_NtkToBdd(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1299
void Abc_ConvertAigToAig_rec(Abc_Ntk_t *pNtkAig, Hop_Obj_t *pObj)
Definition abcFunc.c:1134
int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
Definition abcFunc.c:1261
void Abc_NtkLogicMakeDirectSops(Abc_Ntk_t *pNtk)
Definition abcFunc.c:868
void Abc_ObjFaninSort(Abc_Obj_t *pObj)
Definition abcFunc.c:1369
int Abc_NtkAigToBdd(Abc_Ntk_t *pNtk)
Definition abcFunc.c:869
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition abcUtil.c:486
ABC_DLL int Abc_SopIsConst0(char *pSop)
Definition abcSop.c:724
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition abcDfs.c:82
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL int Abc_SopGetPhase(char *pSop)
Definition abcSop.c:604
#define Abc_CubeForEachVar(pCube, Value, i)
Definition abc.h:536
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkSortSops(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkCleanNext(Abc_Ntk_t *pNtk)
Definition abcUtil.c:669
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
ABC_DLL int Abc_SopIsExorType(char *pSop)
Definition abcSop.c:850
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition abcSop.c:703
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
@ ABC_FUNC_SOP
Definition abc.h:65
@ ABC_FUNC_BDD
Definition abc.h:66
@ ABC_FUNC_AIG
Definition abc.h:67
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
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
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#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
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
Hop_Obj_t * Dec_GraphFactorSop(Hop_Man_t *pMan, char *pSop)
Definition decAbc.c:302
Cube * p
Definition exorList.c:222
void extraDecomposeCover(DdManager *dd, DdNode *zC, DdNode **zC0, DdNode **zC1, DdNode **zC2)
void Extra_StopManager(DdManager *dd)
DdNode * Extra_zddPrimes(DdManager *dd, DdNode *F)
DdNode * Extra_TransferPermute(DdManager *ddSource, DdManager *ddDestination, DdNode *f, int *Permute)
int Extra_bddCountCubes(DdManager *dd, DdNode **pFuncs, int nFuncs, int fMode, int nLimit, int *pGuide)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition hopDfs.c:257
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition hopOper.c:63
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:138
int Hop_DagSize(Hop_Obj_t *pObj)
Definition hopDfs.c:279
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:104
void Hop_ManStop(Hop_Man_t *p)
Definition hopMan.c:84
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:171
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
Definition hopMan.c:45
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
Mem_Flex_t * Mem_FlexStart()
Definition mem.c:327
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition mem.c:388
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition mem.c:359
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition mioApi.c:179
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void * pManFunc
Definition abc.h:191
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
int iTemp
Definition abc.h:149
Abc_Obj_t * pCopy
Definition abc.h:148
Abc_Obj_t * pNext
Definition abc.h:131
unsigned Level
Definition abc.h:142
char * pSpec
Definition gia.h:100
Vec_Int_t * vIdsOrig
Definition gia.h:189
int fGiaSimple
Definition gia.h:116
Vec_Int_t * vMapping
Definition gia.h:136
char * pName
Definition gia.h:99
int iData
Definition hop.h:69
void * pData
Definition hop.h:68
char * pArray
Definition bblif.c:51
#define assert(ex)
Definition util_old.h:213
char * sprintf()
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