ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcExtract.c File Reference
#include "base/abc/abc.h"
#include "aig/gia/giaAig.h"
Include dependency graph for abcExtract.c:

Go to the source code of this file.

Classes

struct  Abc_ShaMan_t_
 

Macros

#define SHARE_NUM   2
 DECLARATIONS ///.
 

Typedefs

typedef struct Abc_ShaMan_t_ Abc_ShaMan_t
 

Functions

Abc_ShaMan_tAbc_ShaManStart (Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///.
 
void Abc_ShaManStop (Abc_ShaMan_t *p)
 
Vec_Wrd_tAbc_NtkShareSuperXor (Abc_Obj_t *pObj, int *pfCompl, int *pCounter)
 
Vec_Wrd_tAbc_NtkShareSuperAnd (Abc_Obj_t *pObj, int *pCounter)
 
void Abc_NtkTraverseSupersXor_rec (Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
 
void Abc_NtkTraverseSupersAnd_rec (Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
 
void Abc_NtkTraverseSupers (Abc_ShaMan_t *p, int fAnd)
 
void Abc_NtkSharePrint (Abc_ShaMan_t *p)
 
void Abc_NtkDumpBlif (Abc_Ntk_t *p)
 
void Abc_NtkShareFindBestMatch (Vec_Ptr_t *vBuckets, Vec_Int_t **pvInput, Vec_Int_t **pvInput2)
 
void Abc_NtkShareOptimize (Abc_ShaMan_t *p, int fAnd)
 
Abc_Ntk_tAbc_NtkUpdateNetwork (Abc_ShaMan_t *p, int fAnd)
 
Abc_Ntk_tAbc_NtkShareXor (Abc_Ntk_t *pNtk, int nMultiSize, int fAnd, int fVerbose)
 
Gia_Man_tAbc_NtkShareXorGia (Gia_Man_t *p, int nMultiSize, int fAnd, int fVerbose)
 

Macro Definition Documentation

◆ SHARE_NUM

#define SHARE_NUM   2

DECLARATIONS ///.

CFile****************************************************************

FileName [abcShare.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Shared logic extraction.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
abcShare.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file abcExtract.c.

Typedef Documentation

◆ Abc_ShaMan_t

typedef struct Abc_ShaMan_t_ Abc_ShaMan_t

Definition at line 32 of file abcExtract.c.

Function Documentation

◆ Abc_NtkDumpBlif()

void Abc_NtkDumpBlif ( Abc_Ntk_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 423 of file abcExtract.c.

424{
425 FILE * pFile;
426 Vec_Ptr_t * vSupp;
427 Abc_Obj_t * pObj;
428 int i, k;
429 pFile = fopen( "multi_and.blif", "wb" );
430 if ( pFile == NULL )
431 {
432 printf( "Cannot open output file.\n" );
433 return;
434 }
435 fprintf( pFile, ".model %s\n", "multi_and" );
436 fprintf( pFile, ".inputs" );
437 for ( i = 0; i < Abc_NtkCiNum(p); i++ )
438 fprintf( pFile, " i%d", i );
439 fprintf( pFile, "\n" );
440 fprintf( pFile, ".outputs" );
441 for ( i = 0; i < Abc_NtkCoNum(p); i++ )
442 fprintf( pFile, " o%d", i );
443 fprintf( pFile, "\n" );
444 Abc_NtkForEachCi( p, pObj, i )
445 pObj->iTemp = i;
446 for ( i = 0; i < Abc_NtkCoNum(p); i++ )
447 {
448 pObj = Abc_NtkCo( p, i );
449 vSupp = Abc_NtkNodeSupport( p, &pObj, 1 );
450 fprintf( pFile, ".names" );
451 Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, k )
452 fprintf( pFile, " i%d", pObj->iTemp );
453 fprintf( pFile, " o%d\n", i );
454 Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, k )
455 fprintf( pFile, "1" );
456 fprintf( pFile, " 1\n" );
457 Vec_PtrFree( vSupp );
458 }
459 fprintf( pFile, ".end\n\n" );
460 fclose( pFile );
461}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:890
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
Cube * p
Definition exorList.c:222
int iTemp
Definition abc.h:149
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
Here is the call graph for this function:

◆ Abc_NtkShareFindBestMatch()

void Abc_NtkShareFindBestMatch ( Vec_Ptr_t * vBuckets,
Vec_Int_t ** pvInput,
Vec_Int_t ** pvInput2 )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 475 of file abcExtract.c.

476{
477 int nPoolSize = 40;
478 Vec_Ptr_t * vPool = Vec_PtrAlloc( nPoolSize );
479 Vec_Ptr_t * vBucket;
480 Vec_Int_t * vInput, * vInput2, * vInputBest = NULL, * vInputBest2 = NULL;
481 int i, k, Cost, CostBest = 0, Delay, DelayBest = 0;
482
483 Vec_PtrForEachEntryReverse( Vec_Ptr_t *, vBuckets, vBucket, i )
484 Vec_PtrForEachEntry( Vec_Int_t *, vBucket, vInput, k )
485 {
486 Vec_PtrPush( vPool, vInput );
487 if ( Vec_PtrSize(vPool) == nPoolSize )
488 goto outside;
489 }
490outside:
491
492 Vec_PtrForEachEntryReverse( Vec_Int_t *, vPool, vInput, i )
493 Vec_PtrForEachEntryReverse( Vec_Int_t *, vPool, vInput2, k )
494 {
495 if ( i == k )
496 continue;
497
498 vInput->pArray += SHARE_NUM;
499 vInput2->pArray += SHARE_NUM;
500 vInput->nSize -= SHARE_NUM;
501 vInput2->nSize -= SHARE_NUM;
502
503 Cost = Vec_IntTwoCountCommon(vInput, vInput2);
504
505 vInput->pArray -= SHARE_NUM;
506 vInput2->pArray -= SHARE_NUM;
507 vInput->nSize += SHARE_NUM;
508 vInput2->nSize += SHARE_NUM;
509
510 if ( Cost < 2 )
511 continue;
512
513 Delay = Abc_MaxInt( Vec_IntEntry(vInput, 1), Vec_IntEntry(vInput2, 1) );
514
515 if ( CostBest < Cost || (CostBest == Cost && (DelayBest > Delay)) )
516 {
517 CostBest = Cost;
518 DelayBest = Delay;
519 vInputBest = vInput;
520 vInputBest2 = vInput2;
521 }
522 }
523 Vec_PtrFree( vPool );
524
525 *pvInput = vInputBest;
526 *pvInput2 = vInputBest2;
527
528 if ( vInputBest == NULL )
529 return;
530
531 Vec_PtrRemove( (Vec_Ptr_t *)Vec_PtrEntry(vBuckets, Vec_IntSize(vInputBest)-SHARE_NUM), (Vec_Int_t *)vInputBest );
532 Vec_PtrRemove( (Vec_Ptr_t *)Vec_PtrEntry(vBuckets, Vec_IntSize(vInputBest2)-SHARE_NUM), (Vec_Int_t *)vInputBest2 );
533}
#define SHARE_NUM
DECLARATIONS ///.
Definition abcExtract.c:30
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
Here is the caller graph for this function:

◆ Abc_NtkShareOptimize()

void Abc_NtkShareOptimize ( Abc_ShaMan_t * p,
int fAnd )

Definition at line 534 of file abcExtract.c.

535{
536 Abc_Obj_t * pObj, * pObj0, * pObj1;
537 Vec_Int_t * vInput, * vInput2;
538 Vec_Int_t * vNew, * vOld1, * vOld2;
539 int i;
540 for ( i = 0; ; i++ )
541 {
542 Abc_NtkShareFindBestMatch( p->vBuckets, &vInput, &vInput2 );
543 if ( vInput == NULL )
544 break;
545
546 // create new node
547 pObj0 = Abc_ObjFromLit( p->pNtk, Vec_IntEntry(vInput, 0) );
548 pObj1 = Abc_ObjFromLit( p->pNtk, Vec_IntEntry(vInput2, 0) );
549 if ( fAnd )
550 pObj = Abc_AigAnd( (Abc_Aig_t *)p->pNtk->pManFunc, pObj0, pObj1 );
551 else
552 pObj = Abc_AigXor( (Abc_Aig_t *)p->pNtk->pManFunc, pObj0, pObj1 );
553 p->nCountGates++;
554
555 // save new node
556 vOld1 = Vec_IntAlloc( 16 ); Vec_IntPush( vOld1, Vec_IntEntry(vInput, 0) ); Vec_IntPush( vOld1, Vec_IntEntry(vInput, 1) );
557 vOld2 = Vec_IntAlloc( 16 ); Vec_IntPush( vOld2, Vec_IntEntry(vInput2, 0) ); Vec_IntPush( vOld2, Vec_IntEntry(vInput2, 1) );
558 vNew = Vec_IntAlloc( 16 ); Vec_IntPush( vNew, Abc_ObjToLit(pObj) ); Vec_IntPush( vNew, Abc_ObjLevel(Abc_ObjRegular(pObj)) );
559
560 // compute new arrays
561 vInput->pArray += SHARE_NUM;
562 vInput2->pArray += SHARE_NUM;
563 vInput->nSize -= SHARE_NUM;
564 vInput2->nSize -= SHARE_NUM;
565
566 Vec_IntTwoSplit( vInput, vInput2, vNew, vOld1, vOld2 );
567
568 vInput->pArray -= SHARE_NUM;
569 vInput2->pArray -= SHARE_NUM;
570 vInput->nSize += SHARE_NUM;
571 vInput2->nSize += SHARE_NUM;
572
573 // add to the old ones
574 Vec_IntPush( vOld1, Vec_IntSize(p->vObj2Lit) );
575 Vec_IntPush( vOld2, Vec_IntSize(p->vObj2Lit) );
576 Vec_IntPush( p->vObj2Lit, Abc_ObjToLit(pObj) );
577
578 Vec_PtrPush( (Vec_Ptr_t *)Vec_PtrEntry(p->vBuckets, Vec_IntSize(vOld1)-SHARE_NUM), vOld1 );
579 Vec_PtrPush( (Vec_Ptr_t *)Vec_PtrEntry(p->vBuckets, Vec_IntSize(vOld2)-SHARE_NUM), vOld2 );
580 Vec_PtrPush( (Vec_Ptr_t *)Vec_PtrEntry(p->vBuckets, Vec_IntSize(vNew)-SHARE_NUM), vNew );
581
582 Vec_IntFree( vInput );
583 Vec_IntFree( vInput2 );
584 }
585}
void Abc_NtkShareFindBestMatch(Vec_Ptr_t *vBuckets, Vec_Int_t **pvInput, Vec_Int_t **pvInput2)
Definition abcExtract.c:475
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:735
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkSharePrint()

void Abc_NtkSharePrint ( Abc_ShaMan_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 368 of file abcExtract.c.

369{
370 Vec_Ptr_t * vBucket;
371 Vec_Int_t * vInput;
372 int i, k, j, ObjId;
373 char * pBuffer = ABC_ALLOC( char, Vec_IntSize(p->vObj2Lit) + 1 );
374 int * pCounters = ABC_CALLOC( int, Vec_IntSize(p->vObj2Lit) + 1 );
375 int nTotal = 0;
376 Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
377 Vec_PtrForEachEntry( Vec_Int_t *, vBucket, vInput, j )
378 {
379 for ( k = 0; k < Vec_IntSize(p->vObj2Lit); k++ )
380 pBuffer[k] = '0';
381 pBuffer[k] = 0;
382
383 Vec_IntForEachEntryStart( vInput, ObjId, k, SHARE_NUM )
384 {
385 assert( ObjId < Vec_IntSize(p->vObj2Lit) );
386 pBuffer[ObjId] = '1';
387 pCounters[ObjId]++;
388 }
389 printf( "%4d%3d: %s\n", Vec_IntEntry(vInput, 0), Vec_IntEntry(vInput, 1), pBuffer );
390 }
391
392 for ( i = 0; i < Vec_IntSize(p->vObj2Lit); i++ )
393 if ( pCounters[i] > 0 )
394 printf( "%d=%d ", i, pCounters[i] );
395 printf( "\n" );
396
397 nTotal = 0;
398 for ( i = 0; i < p->nStartCols; i++ )
399 nTotal += pCounters[i] - 1;
400 printf( "Total = %d. ", nTotal );
401 printf( "Gates = %d.\n", Vec_IntSize(p->vObj2Lit) - p->nStartCols + nTotal );
402
403 ABC_FREE( pCounters );
404 ABC_FREE( pBuffer );
405
406 printf( "Bucket contents: " );
407 Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
408 printf( "%d ", Vec_PtrSize(vBucket) );
409 printf( "\n" );
410}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
Here is the caller graph for this function:

◆ Abc_NtkShareSuperAnd()

Vec_Wrd_t * Abc_NtkShareSuperAnd ( Abc_Obj_t * pObj,
int * pCounter )

Definition at line 160 of file abcExtract.c.

161{
162 Abc_Ntk_t * pNtk = Abc_ObjNtk(pObj);
163 Abc_Obj_t * pObj0, * pObj1, * pRoot = NULL;
164 Vec_Wrd_t * vSuper;
165 word Num, NumNext;
166 int i, k;
167 assert( !Abc_ObjIsComplement(pObj) );
168 // start iteration
169 vSuper = Vec_WrdAlloc( 10 );
170 Vec_WrdPush( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObj), Abc_ObjToLit(pObj)) );
171 while ( Vec_WrdSize(vSuper) > 0 )
172 {
173 // make sure there are no duplicates
174 Num = Vec_WrdEntry( vSuper, 0 );
175 Vec_WrdForEachEntryStart( vSuper, NumNext, i, 1 )
176 {
177 assert( Num < NumNext );
178 Num = NumNext;
179 }
180 // extract AND gate decomposable on the topmost level
181 Vec_WrdForEachEntryReverse( vSuper, Num, i )
182 {
183 pRoot = Abc_ObjFromLit( pNtk, Abc_NtkShareUnpackId(Num) );
184 if ( !Abc_ObjIsComplement(pRoot) && Abc_ObjIsNode(pRoot) )
185 {
186 Vec_WrdRemove( vSuper, Num );
187 break;
188 }
189 }
190 if ( i == -1 )
191 break;
192 assert( Abc_ObjIsNode(pRoot) );
193 // extract
194 pObj0 = Abc_ObjChild0(pRoot);
195 pObj1 = Abc_ObjChild1(pRoot);
196 assert( Abc_ObjIsNode(Abc_ObjRegular(pObj0)) || Abc_ObjIsCi(Abc_ObjRegular(pObj0)) );
197 assert( Abc_ObjIsNode(Abc_ObjRegular(pObj1)) || Abc_ObjIsCi(Abc_ObjRegular(pObj1)) );
198 Vec_WrdPushOrder( vSuper, Abc_NtkSharePack(Abc_ObjLevel(Abc_ObjRegular(pObj0)), Abc_ObjToLit(pObj0)) );
199 Vec_WrdPushOrder( vSuper, Abc_NtkSharePack(Abc_ObjLevel(Abc_ObjRegular(pObj1)), Abc_ObjToLit(pObj1)) );
200 (*pCounter)++;
201 // remove duplicates
202 k = 0;
203 Vec_WrdForEachEntry( vSuper, Num, i )
204 {
205 if ( i + 1 == Vec_WrdSize(vSuper) )
206 {
207 Vec_WrdWriteEntry( vSuper, k++, Num );
208 break;
209 }
210 NumNext = Vec_WrdEntry( vSuper, i+1 );
211 assert( Num <= NumNext );
212 if ( Num + 1 == NumNext && (NumNext & 1) ) // pos_lit & neg_lit = 0
213 {
214 Vec_WrdClear( vSuper );
215 return vSuper;
216 }
217 if ( Num < NumNext )
218 Vec_WrdWriteEntry( vSuper, k++, Num );
219 }
220 Vec_WrdShrink( vSuper, k );
221 }
222 Vec_WrdForEachEntry( vSuper, Num, i )
223 Vec_WrdWriteEntry( vSuper, i, Abc_NtkShareUnpackId(Num) );
224 return vSuper;
225}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecWrd.h:54
#define Vec_WrdForEachEntryStart(vVec, Entry, i, Start)
Definition vecWrd.h:56
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
#define Vec_WrdForEachEntryReverse(vVec, pEntry, i)
Definition vecWrd.h:62
Here is the caller graph for this function:

◆ Abc_NtkShareSuperXor()

Vec_Wrd_t * Abc_NtkShareSuperXor ( Abc_Obj_t * pObj,
int * pfCompl,
int * pCounter )

Function*************************************************************

Synopsis [Collects one multi-input gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 96 of file abcExtract.c.

97{
98 Abc_Ntk_t * pNtk = Abc_ObjNtk(pObj);
99 Abc_Obj_t * pObjC, * pObj0, * pObj1, * pRoot = NULL;
100 Vec_Wrd_t * vSuper;
101 word Num, NumNext;
102 int i, k, fCompl = 0;
103 assert( !Abc_ObjIsComplement(pObj) );
104 assert( Abc_NodeIsExorType(pObj) );
105 // start iteration
106 vSuper = Vec_WrdAlloc( 10 );
107 Vec_WrdPush( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObj), Abc_ObjId(pObj)) );
108 while ( Vec_WrdSize(vSuper) > 0 )
109 {
110 // make sure there are no duplicates
111 Num = Vec_WrdEntry( vSuper, 0 );
112 Vec_WrdForEachEntryStart( vSuper, NumNext, i, 1 )
113 {
114 assert( Num < NumNext );
115 Num = NumNext;
116 }
117 // extract XOR gate decomposable on the topmost level
118 Vec_WrdForEachEntryReverse( vSuper, Num, i )
119 {
120 pRoot = Abc_NtkObj( pNtk, Abc_NtkShareUnpackId(Num) );
121 if ( Abc_NodeIsExorType(pRoot) )
122 {
123 Vec_WrdRemove( vSuper, Num );
124 break;
125 }
126 }
127 if ( i == -1 )
128 break;
129 // extract
130 pObjC = Abc_NodeRecognizeMux( pRoot, &pObj1, &pObj0 );
131 assert( pObj1 == Abc_ObjNot(pObj0) );
132 fCompl ^= Abc_ObjIsComplement(pObjC); pObjC = Abc_ObjRegular(pObjC);
133 fCompl ^= Abc_ObjIsComplement(pObj0); pObj0 = Abc_ObjRegular(pObj0);
134 Vec_WrdPushOrder( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObjC), Abc_ObjId(pObjC)) );
135 Vec_WrdPushOrder( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObj0), Abc_ObjId(pObj0)) );
136 (*pCounter)++;
137 // remove duplicates
138 k = 0;
139 Vec_WrdForEachEntry( vSuper, Num, i )
140 {
141 if ( i + 1 == Vec_WrdSize(vSuper) )
142 {
143 Vec_WrdWriteEntry( vSuper, k++, Num );
144 break;
145 }
146 NumNext = Vec_WrdEntry( vSuper, i+1 );
147 assert( Num <= NumNext );
148 if ( Num == NumNext )
149 i++;
150 else
151 Vec_WrdWriteEntry( vSuper, k++, Num );
152 }
153 Vec_WrdShrink( vSuper, k );
154 }
155 *pfCompl = fCompl;
156 Vec_WrdForEachEntry( vSuper, Num, i )
157 Vec_WrdWriteEntry( vSuper, i, Abc_NtkShareUnpackId(Num) );
158 return vSuper;
159}
ABC_DLL Abc_Obj_t * Abc_NodeRecognizeMux(Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
Definition abcUtil.c:1430
ABC_DLL int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition abcUtil.c:1300
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkShareXor()

Abc_Ntk_t * Abc_NtkShareXor ( Abc_Ntk_t * pNtk,
int nMultiSize,
int fAnd,
int fVerbose )

Function*************************************************************

Synopsis [Extracts one multi-output XOR.]

Description []

SideEffects []

SeeAlso []

Definition at line 721 of file abcExtract.c.

722{
723 Abc_Ntk_t * pNtkNew;
724 Abc_ShaMan_t * p;
725 assert( Abc_NtkIsStrash(pNtk) );
726// Abc_NtkDumpBlif( pNtk );
727 p = Abc_ShaManStart( pNtk );
728 p->nMultiSize = nMultiSize;
729 p->fVerbose = fVerbose;
730 Abc_NtkTraverseSupers( p, fAnd );
731 if ( p->nStartCols < 2 )
732 {
733 Abc_ShaManStop( p );
734 return Abc_NtkDup( pNtk );
735 }
736 if ( fVerbose )
738 Abc_NtkShareOptimize( p, fAnd );
739 if ( fVerbose )
741 pNtkNew = Abc_NtkUpdateNetwork( p, fAnd );
742 Abc_ShaManStop( p );
743 return pNtkNew;
744}
Abc_Ntk_t * Abc_NtkUpdateNetwork(Abc_ShaMan_t *p, int fAnd)
Definition abcExtract.c:598
void Abc_NtkTraverseSupers(Abc_ShaMan_t *p, int fAnd)
Definition abcExtract.c:314
struct Abc_ShaMan_t_ Abc_ShaMan_t
Definition abcExtract.c:32
void Abc_NtkShareOptimize(Abc_ShaMan_t *p, int fAnd)
Definition abcExtract.c:534
void Abc_ShaManStop(Abc_ShaMan_t *p)
Definition abcExtract.c:73
Abc_ShaMan_t * Abc_ShaManStart(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcExtract.c:65
void Abc_NtkSharePrint(Abc_ShaMan_t *p)
Definition abcExtract.c:368
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkShareXorGia()

Gia_Man_t * Abc_NtkShareXorGia ( Gia_Man_t * p,
int nMultiSize,
int fAnd,
int fVerbose )

Definition at line 745 of file abcExtract.c.

746{
747 extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
748 extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
749 Aig_Man_t * pMan = Gia_ManToAig( p, 0 );
750 Abc_Ntk_t * pNtk = Abc_NtkFromAigPhase( pMan );
751 Abc_Ntk_t * pNtkNew = Abc_NtkShareXor( pNtk, nMultiSize, fAnd, fVerbose );
752 Aig_Man_t * pAig = Abc_NtkToDar( pNtkNew, 0, 0 );
753 Gia_Man_t * pNew = Gia_ManFromAig( pAig );
754 Abc_NtkDelete( pNtkNew );
755 Abc_NtkDelete( pNtk );
756 Aig_ManStop( pAig );
757 Aig_ManStop( pMan );
758 return pNew;
759}
Abc_Ntk_t * Abc_NtkShareXor(Abc_Ntk_t *pNtk, int nMultiSize, int fAnd, int fVerbose)
Definition abcExtract.c:721
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Gia_Man_t * Gia_ManFromAig(Aig_Man_t *p)
INCLUDES ///.
Definition giaAig.c:76
Aig_Man_t * Gia_ManToAig(Gia_Man_t *p, int fChoices)
Definition giaAig.c:318
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkFromAigPhase(Aig_Man_t *pMan)
DECLARATIONS ///.
Definition abcDar.c:595
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Definition abcDar.c:237
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Here is the call graph for this function:

◆ Abc_NtkTraverseSupers()

void Abc_NtkTraverseSupers ( Abc_ShaMan_t * p,
int fAnd )

Definition at line 314 of file abcExtract.c.

315{
316 Vec_Ptr_t * vInputs;
317 Vec_Int_t * vInput;
318 Abc_Obj_t * pObj;
319 int i, nOnesMax;
320
321 // create mapping of nodes into their column vectors
322 vInputs = Vec_PtrStart( Abc_NtkObjNumMax(p->pNtk) * (1 + fAnd) );
323 Abc_NtkIncrementTravId( p->pNtk );
324 if ( fAnd )
325 {
326 Abc_NtkForEachCo( p->pNtk, pObj, i )
327 if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
328 Abc_NtkTraverseSupersAnd_rec( p, Abc_ObjFanin0(pObj), vInputs );
329 }
330 else
331 {
332 Abc_NtkForEachCo( p->pNtk, pObj, i )
333 if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
334 Abc_NtkTraverseSupersXor_rec( p, Abc_ObjFanin0(pObj), vInputs );
335 }
336 p->nStartCols = Vec_IntSize(p->vObj2Lit);
337
338 // find the largest number of 1s
339 nOnesMax = 0;
340 Vec_PtrForEachEntry( Vec_Int_t *, vInputs, vInput, i )
341 if ( vInput )
342 nOnesMax = Abc_MaxInt( nOnesMax, Vec_IntSize(vInput)-SHARE_NUM );
343
344 // create buckets
345 assert( p->vBuckets == NULL );
346 p->vBuckets = Vec_PtrAlloc( nOnesMax + 1 );
347 for ( i = 0; i <= nOnesMax; i++ )
348 Vec_PtrPush( p->vBuckets, Vec_PtrAlloc(10) );
349
350 // load vectors into buckets
351 Vec_PtrForEachEntry( Vec_Int_t *, vInputs, vInput, i )
352 if ( vInput )
353 Vec_PtrPush( (Vec_Ptr_t *)Vec_PtrEntry(p->vBuckets, Vec_IntSize(vInput)-SHARE_NUM), vInput );
354 Vec_PtrFree( vInputs );
355}
void Abc_NtkTraverseSupersAnd_rec(Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
Definition abcExtract.c:280
void Abc_NtkTraverseSupersXor_rec(Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
Definition abcExtract.c:238
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkTraverseSupersAnd_rec()

void Abc_NtkTraverseSupersAnd_rec ( Abc_ShaMan_t * p,
Abc_Obj_t * pObj,
Vec_Ptr_t * vInputs )

Definition at line 280 of file abcExtract.c.

281{
282 Vec_Wrd_t * vSuper;
283 word Num;
284 int k;
285 if ( Abc_NodeIsTravIdCurrent( pObj ) )
286 return;
287 Abc_NodeSetTravIdCurrent( pObj );
288 if ( Abc_ObjIsCi(pObj) )
289 return;
290 assert( Abc_ObjIsNode(pObj) );
291 vSuper = Abc_NtkShareSuperAnd( pObj, &p->nFoundGates );
292 if ( Vec_WrdSize(vSuper) <= 1 || Vec_WrdSize(vSuper) >= p->nMultiSize )
293 {
294 Vec_WrdForEachEntry( vSuper, Num, k )
295 {
296 Vec_Int_t * vInput = (Vec_Int_t *)Vec_PtrEntry( vInputs, (int)Num );
297 if ( vInput == NULL )
298 {
299 vInput = Vec_IntAlloc( 10 );
300 Vec_IntPush( vInput, (int)Num );
301 Vec_IntPush( vInput, Abc_ObjLevel(Abc_NtkObj(p->pNtk, Abc_Lit2Var((int)Num))) );
302 assert( SHARE_NUM == Vec_IntSize(vInput) );
303 Vec_PtrWriteEntry( vInputs, (int)Num, vInput );
304 }
305 Vec_IntPush( vInput, Vec_IntSize(p->vObj2Lit) );
306 }
307 Vec_IntPush( p->vObj2Lit, Abc_ObjToLit(pObj) );
308 }
309 // call recursively
310 Vec_WrdForEachEntry( vSuper, Num, k )
311 Abc_NtkTraverseSupersAnd_rec( p, Abc_NtkObj(p->pNtk, Abc_Lit2Var((int)Num)), vInputs );
312 Vec_WrdFree( vSuper );
313}
Vec_Wrd_t * Abc_NtkShareSuperAnd(Abc_Obj_t *pObj, int *pCounter)
Definition abcExtract.c:160
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkTraverseSupersXor_rec()

void Abc_NtkTraverseSupersXor_rec ( Abc_ShaMan_t * p,
Abc_Obj_t * pObj,
Vec_Ptr_t * vInputs )

Function*************************************************************

Synopsis [Creates multi-input XOR representation for the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file abcExtract.c.

239{
240 if ( Abc_NodeIsTravIdCurrent( pObj ) )
241 return;
242 Abc_NodeSetTravIdCurrent( pObj );
243 if ( Abc_ObjIsCi(pObj) )
244 return;
245 assert( Abc_ObjIsNode(pObj) );
246 if ( Abc_NodeIsExorType(pObj) )
247 {
248 Vec_Wrd_t * vSuper;
249 int k, fCompl;
250 word Num;
251 vSuper = Abc_NtkShareSuperXor( pObj, &fCompl, &p->nFoundGates );
252 if ( Vec_WrdSize(vSuper) <= 1 || Vec_WrdSize(vSuper) >= p->nMultiSize )
253 {
254 Vec_WrdForEachEntry( vSuper, Num, k )
255 {
256 Vec_Int_t * vInput = (Vec_Int_t *)Vec_PtrEntry( vInputs, (int)Num );
257 if ( vInput == NULL )
258 {
259 vInput = Vec_IntAlloc( 10 );
260 Vec_IntPush( vInput, Abc_Var2Lit((int)Num, 0) );
261 Vec_IntPush( vInput, Abc_ObjLevel(Abc_NtkObj(p->pNtk, (int)Num)) );
262 assert( SHARE_NUM == Vec_IntSize(vInput) );
263 Vec_PtrWriteEntry( vInputs, (int)Num, vInput );
264 }
265 Vec_IntPush( vInput, Vec_IntSize(p->vObj2Lit) );
266 }
267 Vec_IntPush( p->vObj2Lit, Abc_Var2Lit(Abc_ObjId(pObj), fCompl) );
268 }
269 // call recursively
270 Vec_WrdForEachEntry( vSuper, Num, k )
271 Abc_NtkTraverseSupersXor_rec( p, Abc_NtkObj(p->pNtk, (int)Num), vInputs );
272 Vec_WrdFree( vSuper );
273 }
274 else
275 {
276 Abc_NtkTraverseSupersXor_rec( p, Abc_ObjFanin0(pObj), vInputs );
277 Abc_NtkTraverseSupersXor_rec( p, Abc_ObjFanin1(pObj), vInputs );
278 }
279}
Vec_Wrd_t * Abc_NtkShareSuperXor(Abc_Obj_t *pObj, int *pfCompl, int *pCounter)
Definition abcExtract.c:96
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkUpdateNetwork()

Abc_Ntk_t * Abc_NtkUpdateNetwork ( Abc_ShaMan_t * p,
int fAnd )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 598 of file abcExtract.c.

599{
600 Abc_Ntk_t * pNtk;
601 Vec_Int_t * vInput, * vMap2Repl;
602 Vec_Ptr_t * vOrig, * vRepl, * vBucket;
603 Abc_Obj_t * pObj, * pNew;
604 int i, j, k, ObjId, iLit;
605 int iLitConst1 = Abc_ObjToLit( Abc_AigConst1(p->pNtk) );
606
607 vOrig = Vec_PtrAlloc( p->nStartCols );
608 vRepl = Vec_PtrAlloc( p->nStartCols );
609 for ( i = 0; i < p->nStartCols; i++ )
610 {
611 iLit = Vec_IntEntry( p->vObj2Lit, i );
612 assert( !fAnd || !Abc_LitIsCompl(iLit) );
613
614 pObj = Abc_NtkObj( p->pNtk, Abc_Lit2Var(iLit) );
615
616 if ( fAnd )
617 pNew = Abc_AigConst1(p->pNtk);
618 else
619 pNew = Abc_ObjNotCond( Abc_AigConst1(p->pNtk), !Abc_LitIsCompl(iLit) );
620
621 Vec_PtrPush( vOrig, pObj );
622 Vec_PtrPush( vRepl, pNew );
623
624 p->nCountGates--;
625 }
626
627 // go through the columns
628 Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
629 Vec_PtrForEachEntry( Vec_Int_t *, vBucket, vInput, j )
630 {
631 Vec_IntForEachEntryStart( vInput, ObjId, k, SHARE_NUM )
632 {
633 assert( ObjId < Vec_IntSize(p->vObj2Lit) );
634 if ( ObjId >= p->nStartCols )
635 break;
636 assert( ObjId < p->nStartCols );
637 iLit = Vec_IntEntry( vInput, 0 );
638
639 pNew = (Abc_Obj_t *)Vec_PtrEntry( vRepl, ObjId );
640 if ( fAnd )
641 pNew = Abc_AigAnd( (Abc_Aig_t *)p->pNtk->pManFunc, pNew, Abc_ObjFromLit(p->pNtk, iLit) );
642 else
643 pNew = Abc_AigXor( (Abc_Aig_t *)p->pNtk->pManFunc, pNew, Abc_ObjFromLit(p->pNtk, iLit) );
644 Vec_PtrWriteEntry( vRepl, ObjId, pNew );
645 p->nCountGates++;
646 }
647 }
648
649 if ( p->fVerbose )
650 printf( "Total gates collected = %d. Total gates constructed = %d.\n", p->nFoundGates, p->nCountGates );
651
652 // create map of originals
653 vMap2Repl = Vec_IntStartFull( Abc_NtkObjNumMax(p->pNtk) );
654 Vec_PtrForEachEntry( Abc_Obj_t *, vOrig, pObj, i )
655 {
656// printf( "Replacing %d by %d.\n", Abc_ObjId(pObj), Abc_ObjToLit((Abc_Obj_t *)Vec_PtrEntry(vRepl, i)) );
657 Vec_IntWriteEntry( vMap2Repl, Abc_ObjId(pObj), Abc_ObjToLit((Abc_Obj_t *)Vec_PtrEntry(vRepl, i)) );
658 }
659 Vec_PtrFree( vOrig );
660 Vec_PtrFree( vRepl );
661
662 // update fanin pointers
663 Abc_NtkForEachObj( p->pNtk, pObj, i )
664 {
665 if ( Abc_ObjIsCo(pObj) || Abc_ObjIsNode(pObj) )
666 {
667 iLit = Vec_IntEntry( vMap2Repl, Abc_ObjFaninId0(pObj) );
668 if ( iLit >= 0 )
669 {
670 if ( iLit == iLitConst1 && fAnd )
671 {
672 pObj->fCompl0 ^= 1;
673 Vec_IntWriteEntry( &pObj->vFanins, 0, Abc_Lit2Var(iLitConst1) );
674 }
675 else
676 {
677 pObj->fCompl0 ^= Abc_LitIsCompl(iLit);
678 Vec_IntWriteEntry( &pObj->vFanins, 0, Abc_Lit2Var(iLit) );
679 }
680 }
681 }
682 if ( Abc_ObjIsNode(pObj) )
683 {
684 iLit = Vec_IntEntry( vMap2Repl, Abc_ObjFaninId1(pObj) );
685 if ( iLit >= 0 )
686 {
687 if ( iLit == iLitConst1 && fAnd )
688 {
689 pObj->fCompl1 ^= 1;
690 Vec_IntWriteEntry( &pObj->vFanins, 1, Abc_Lit2Var(iLitConst1) );
691 }
692 else
693 {
694 pObj->fCompl1 ^= Abc_LitIsCompl(iLit);
695 Vec_IntWriteEntry( &pObj->vFanins, 1, Abc_Lit2Var(iLit) );
696 }
697 }
698 }
699 }
700 Vec_IntFree( vMap2Repl );
701
702// pNtk = Abc_NtkRestrash( p->pNtk, 1 );
703 if ( fAnd )
704 pNtk = Abc_NtkBalance( p->pNtk, 0, 0, 1 );
705 else
706 pNtk = Abc_NtkBalanceExor( p->pNtk, 1, 0 );
707 return pNtk;
708}
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
ABC_DLL Abc_Ntk_t * Abc_NtkBalanceExor(Abc_Ntk_t *pNtk, int fUpdateLevel, int fVerbose)
Definition abcDar.c:4078
ABC_DLL Abc_Ntk_t * Abc_NtkBalance(Abc_Ntk_t *pNtk, int fDuplicate, int fSelective, int fUpdateLevel)
FUNCTION DEFINITIONS ///.
Definition abcBalance.c:53
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
Vec_Int_t vFanins
Definition abc.h:143
unsigned fCompl1
Definition abc.h:141
unsigned fCompl0
Definition abc.h:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_ShaManStart()

Abc_ShaMan_t * Abc_ShaManStart ( Abc_Ntk_t * pNtk)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Working with the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file abcExtract.c.

66{
69 p->pNtk = pNtk;
70 p->vObj2Lit = Vec_IntAlloc( 1000 );
71 return p;
72}
Here is the caller graph for this function:

◆ Abc_ShaManStop()

void Abc_ShaManStop ( Abc_ShaMan_t * p)

Definition at line 73 of file abcExtract.c.

74{
75 Vec_Ptr_t * vBucket;
76 int i;
77 Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
78 Vec_VecFree( (Vec_Vec_t *)vBucket );
79 Vec_PtrFreeP( &p->vBuckets );
80 Vec_IntFreeP( &p->vObj2Lit );
81 ABC_FREE( p );
82}
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the caller graph for this function: