abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcExtract.c File Reference
#include "base/abc/abc.h"

Go to the source code of this file.

Data Structures

struct  Abc_ShaMan_t_
 

Macros

#define SHARE_NUM   2
 DECLARATIONS ///. More...
 

Typedefs

typedef struct Abc_ShaMan_t_ Abc_ShaMan_t
 

Functions

static word Abc_NtkSharePack (int Lev, int Id)
 
static int Abc_NtkShareUnpackLev (word Num)
 
static int Abc_NtkShareUnpackId (word Num)
 
Abc_ShaMan_tAbc_ShaManStart (Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///. More...
 
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)
 

Macro Definition Documentation

#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 29 of file abcExtract.c.

Typedef Documentation

typedef struct Abc_ShaMan_t_ Abc_ShaMan_t

Definition at line 31 of file abcExtract.c.

Function Documentation

void Abc_NtkDumpBlif ( Abc_Ntk_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 422 of file abcExtract.c.

423 {
424  FILE * pFile;
425  Vec_Ptr_t * vSupp;
426  Abc_Obj_t * pObj;
427  int i, k;
428  pFile = fopen( "multi_and.blif", "wb" );
429  if ( pFile == NULL )
430  {
431  printf( "Cannot open output file.\n" );
432  return;
433  }
434  fprintf( pFile, ".model %s\n", "multi_and" );
435  fprintf( pFile, ".inputs" );
436  for ( i = 0; i < Abc_NtkCiNum(p); i++ )
437  fprintf( pFile, " i%d", i );
438  fprintf( pFile, "\n" );
439  fprintf( pFile, ".outputs" );
440  for ( i = 0; i < Abc_NtkCoNum(p); i++ )
441  fprintf( pFile, " o%d", i );
442  fprintf( pFile, "\n" );
443  Abc_NtkForEachCi( p, pObj, i )
444  pObj->iTemp = i;
445  for ( i = 0; i < Abc_NtkCoNum(p); i++ )
446  {
447  pObj = Abc_NtkCo( p, i );
448  vSupp = Abc_NtkNodeSupport( p, &pObj, 1 );
449  fprintf( pFile, ".names" );
450  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, k )
451  fprintf( pFile, " i%d", pObj->iTemp );
452  fprintf( pFile, " o%d\n", i );
453  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, k )
454  fprintf( pFile, "1" );
455  fprintf( pFile, " 1\n" );
456  Vec_PtrFree( vSupp );
457  }
458  fprintf( pFile, ".end\n\n" );
459  fclose( pFile );
460 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
for(p=first;p->value< newval;p=p->next)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:859
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkShareFindBestMatch ( Vec_Ptr_t vBuckets,
Vec_Int_t **  pvInput,
Vec_Int_t **  pvInput2 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 474 of file abcExtract.c.

475 {
476  int nPoolSize = 40;
477  Vec_Ptr_t * vPool = Vec_PtrAlloc( nPoolSize );
478  Vec_Ptr_t * vBucket;
479  Vec_Int_t * vInput, * vInput2, * vInputBest = NULL, * vInputBest2 = NULL;
480  int i, k, Cost, CostBest = 0, Delay, DelayBest = 0;
481 
482  Vec_PtrForEachEntryReverse( Vec_Ptr_t *, vBuckets, vBucket, i )
483  Vec_PtrForEachEntry( Vec_Int_t *, vBucket, vInput, k )
484  {
485  Vec_PtrPush( vPool, vInput );
486  if ( Vec_PtrSize(vPool) == nPoolSize )
487  goto outside;
488  }
489 outside:
490 
491  Vec_PtrForEachEntryReverse( Vec_Int_t *, vPool, vInput, i )
492  Vec_PtrForEachEntryReverse( Vec_Int_t *, vPool, vInput2, k )
493  {
494  if ( i == k )
495  continue;
496 
497  vInput->pArray += SHARE_NUM;
498  vInput2->pArray += SHARE_NUM;
499  vInput->nSize -= SHARE_NUM;
500  vInput2->nSize -= SHARE_NUM;
501 
502  Cost = Vec_IntTwoCountCommon(vInput, vInput2);
503 
504  vInput->pArray -= SHARE_NUM;
505  vInput2->pArray -= SHARE_NUM;
506  vInput->nSize += SHARE_NUM;
507  vInput2->nSize += SHARE_NUM;
508 
509  if ( Cost < 2 )
510  continue;
511 
512  Delay = Abc_MaxInt( Vec_IntEntry(vInput, 1), Vec_IntEntry(vInput2, 1) );
513 
514  if ( CostBest < Cost || (CostBest == Cost && (DelayBest > Delay)) )
515  {
516  CostBest = Cost;
517  DelayBest = Delay;
518  vInputBest = vInput;
519  vInputBest2 = vInput2;
520  }
521  }
522  Vec_PtrFree( vPool );
523 
524  *pvInput = vInputBest;
525  *pvInput2 = vInputBest2;
526 
527  if ( vInputBest == NULL )
528  return;
529 
530  Vec_PtrRemove( (Vec_Ptr_t *)Vec_PtrEntry(vBuckets, Vec_IntSize(vInputBest)-SHARE_NUM), (Vec_Int_t *)vInputBest );
531  Vec_PtrRemove( (Vec_Ptr_t *)Vec_PtrEntry(vBuckets, Vec_IntSize(vInputBest2)-SHARE_NUM), (Vec_Int_t *)vInputBest2 );
532 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
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
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_IntTwoCountCommon(Vec_Int_t *vArr1, Vec_Int_t *vArr2)
Definition: vecInt.h:1528
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkShareOptimize ( Abc_ShaMan_t p,
int  fAnd 
)

Definition at line 533 of file abcExtract.c.

534 {
535  Abc_Obj_t * pObj, * pObj0, * pObj1;
536  Vec_Int_t * vInput, * vInput2;
537  Vec_Int_t * vNew, * vOld1, * vOld2;
538  int i;
539  for ( i = 0; ; i++ )
540  {
541  Abc_NtkShareFindBestMatch( p->vBuckets, &vInput, &vInput2 );
542  if ( vInput == NULL )
543  break;
544 
545  // create new node
546  pObj0 = Abc_ObjFromLit( p->pNtk, Vec_IntEntry(vInput, 0) );
547  pObj1 = Abc_ObjFromLit( p->pNtk, Vec_IntEntry(vInput2, 0) );
548  if ( fAnd )
549  pObj = Abc_AigAnd( (Abc_Aig_t *)p->pNtk->pManFunc, pObj0, pObj1 );
550  else
551  pObj = Abc_AigXor( (Abc_Aig_t *)p->pNtk->pManFunc, pObj0, pObj1 );
552  p->nCountGates++;
553 
554  // save new node
555  vOld1 = Vec_IntAlloc( 16 ); Vec_IntPush( vOld1, Vec_IntEntry(vInput, 0) ); Vec_IntPush( vOld1, Vec_IntEntry(vInput, 1) );
556  vOld2 = Vec_IntAlloc( 16 ); Vec_IntPush( vOld2, Vec_IntEntry(vInput2, 0) ); Vec_IntPush( vOld2, Vec_IntEntry(vInput2, 1) );
557  vNew = Vec_IntAlloc( 16 ); Vec_IntPush( vNew, Abc_ObjToLit(pObj) ); Vec_IntPush( vNew, Abc_ObjLevel(Abc_ObjRegular(pObj)) );
558 
559  // compute new arrays
560  vInput->pArray += SHARE_NUM;
561  vInput2->pArray += SHARE_NUM;
562  vInput->nSize -= SHARE_NUM;
563  vInput2->nSize -= SHARE_NUM;
564 
565  Vec_IntTwoSplit( vInput, vInput2, vNew, vOld1, vOld2 );
566 
567  vInput->pArray -= SHARE_NUM;
568  vInput2->pArray -= SHARE_NUM;
569  vInput->nSize += SHARE_NUM;
570  vInput2->nSize += SHARE_NUM;
571 
572  // add to the old ones
573  Vec_IntPush( vOld1, Vec_IntSize(p->vObj2Lit) );
574  Vec_IntPush( vOld2, Vec_IntSize(p->vObj2Lit) );
575  Vec_IntPush( p->vObj2Lit, Abc_ObjToLit(pObj) );
576 
580 
581  Vec_IntFree( vInput );
582  Vec_IntFree( vInput2 );
583  }
584 }
static Abc_Obj_t * Abc_ObjFromLit(Abc_Ntk_t *p, int iLit)
Definition: abc.h:390
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Abc_Ntk_t * pNtk
Definition: abcExtract.c:36
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:735
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntTwoSplit(Vec_Int_t *vArr1, Vec_Int_t *vArr2, Vec_Int_t *vArr, Vec_Int_t *vArr1n, Vec_Int_t *vArr2n)
Definition: vecInt.h:1707
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Abc_NtkShareFindBestMatch(Vec_Ptr_t *vBuckets, Vec_Int_t **pvInput, Vec_Int_t **pvInput2)
Definition: abcExtract.c:474
static int Abc_ObjToLit(Abc_Obj_t *p)
Definition: abc.h:391
Vec_Int_t * vObj2Lit
Definition: abcExtract.c:38
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Ptr_t * vBuckets
Definition: abcExtract.c:37
static word Abc_NtkSharePack ( int  Lev,
int  Id 
)
inlinestatic

Definition at line 44 of file abcExtract.c.

44 { return (((word)Lev) << 32) | Id; }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
void Abc_NtkSharePrint ( Abc_ShaMan_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 367 of file abcExtract.c.

368 {
369  Vec_Ptr_t * vBucket;
370  Vec_Int_t * vInput;
371  int i, k, j, ObjId;
372  char * pBuffer = ABC_ALLOC( char, Vec_IntSize(p->vObj2Lit) + 1 );
373  int * pCounters = ABC_CALLOC( int, Vec_IntSize(p->vObj2Lit) + 1 );
374  int nTotal = 0;
375  Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
376  Vec_PtrForEachEntry( Vec_Int_t *, vBucket, vInput, j )
377  {
378  for ( k = 0; k < Vec_IntSize(p->vObj2Lit); k++ )
379  pBuffer[k] = '0';
380  pBuffer[k] = 0;
381 
382  Vec_IntForEachEntryStart( vInput, ObjId, k, SHARE_NUM )
383  {
384  assert( ObjId < Vec_IntSize(p->vObj2Lit) );
385  pBuffer[ObjId] = '1';
386  pCounters[ObjId]++;
387  }
388  printf( "%4d%3d: %s\n", Vec_IntEntry(vInput, 0), Vec_IntEntry(vInput, 1), pBuffer );
389  }
390 
391  for ( i = 0; i < Vec_IntSize(p->vObj2Lit); i++ )
392  if ( pCounters[i] > 0 )
393  printf( "%d=%d ", i, pCounters[i] );
394  printf( "\n" );
395 
396  nTotal = 0;
397  for ( i = 0; i < p->nStartCols; i++ )
398  nTotal += pCounters[i] - 1;
399  printf( "Total = %d. ", nTotal );
400  printf( "Gates = %d.\n", Vec_IntSize(p->vObj2Lit) - p->nStartCols + nTotal );
401 
402  ABC_FREE( pCounters );
403  ABC_FREE( pBuffer );
404 
405  printf( "Bucket contents: " );
406  Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
407  printf( "%d ", Vec_PtrSize(vBucket) );
408  printf( "\n" );
409 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t * vObj2Lit
Definition: abcExtract.c:38
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Ptr_t * vBuckets
Definition: abcExtract.c:37
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
Vec_Wrd_t* Abc_NtkShareSuperAnd ( Abc_Obj_t pObj,
int *  pCounter 
)

Definition at line 159 of file abcExtract.c.

160 {
161  Abc_Ntk_t * pNtk = Abc_ObjNtk(pObj);
162  Abc_Obj_t * pObj0, * pObj1, * pRoot = NULL;
163  Vec_Wrd_t * vSuper;
164  word Num, NumNext;
165  int i, k;
166  assert( !Abc_ObjIsComplement(pObj) );
167  // start iteration
168  vSuper = Vec_WrdAlloc( 10 );
169  Vec_WrdPush( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObj), Abc_ObjToLit(pObj)) );
170  while ( Vec_WrdSize(vSuper) > 0 )
171  {
172  // make sure there are no duplicates
173  Num = Vec_WrdEntry( vSuper, 0 );
174  Vec_WrdForEachEntryStart( vSuper, NumNext, i, 1 )
175  {
176  assert( Num < NumNext );
177  Num = NumNext;
178  }
179  // extract AND gate decomposable on the topmost level
180  Vec_WrdForEachEntryReverse( vSuper, Num, i )
181  {
182  pRoot = Abc_ObjFromLit( pNtk, Abc_NtkShareUnpackId(Num) );
183  if ( !Abc_ObjIsComplement(pRoot) && Abc_ObjIsNode(pRoot) )
184  {
185  Vec_WrdRemove( vSuper, Num );
186  break;
187  }
188  }
189  if ( i == -1 )
190  break;
191  assert( Abc_ObjIsNode(pRoot) );
192  // extract
193  pObj0 = Abc_ObjChild0(pRoot);
194  pObj1 = Abc_ObjChild1(pRoot);
199  (*pCounter)++;
200  // remove duplicates
201  k = 0;
202  Vec_WrdForEachEntry( vSuper, Num, i )
203  {
204  if ( i + 1 == Vec_WrdSize(vSuper) )
205  {
206  Vec_WrdWriteEntry( vSuper, k++, Num );
207  break;
208  }
209  NumNext = Vec_WrdEntry( vSuper, i+1 );
210  assert( Num <= NumNext );
211  if ( Num + 1 == NumNext && (NumNext & 1) ) // pos_lit & neg_lit = 0
212  {
213  Vec_WrdClear( vSuper );
214  return vSuper;
215  }
216  if ( Num < NumNext )
217  Vec_WrdWriteEntry( vSuper, k++, Num );
218  }
219  Vec_WrdShrink( vSuper, k );
220  }
221  Vec_WrdForEachEntry( vSuper, Num, i )
222  Vec_WrdWriteEntry( vSuper, i, Abc_NtkShareUnpackId(Num) );
223  return vSuper;
224 }
static Abc_Obj_t * Abc_ObjFromLit(Abc_Ntk_t *p, int iLit)
Definition: abc.h:390
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static void Vec_WrdPushOrder(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:668
static int Abc_NtkShareUnpackId(word Num)
Definition: abcExtract.c:46
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
static Abc_Obj_t * Abc_ObjChild0(Abc_Obj_t *pObj)
Definition: abc.h:383
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static void Vec_WrdClear(Vec_Wrd_t *p)
Definition: vecWrd.h:602
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
static void Vec_WrdShrink(Vec_Wrd_t *p, int nSizeNew)
Definition: vecWrd.h:585
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
static word Abc_NtkSharePack(int Lev, int Id)
Definition: abcExtract.c:44
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Vec_WrdRemove(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:802
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Abc_ObjToLit(Abc_Obj_t *p)
Definition: abc.h:391
#define assert(ex)
Definition: util_old.h:213
#define Vec_WrdForEachEntryStart(vVec, Entry, i, Start)
Definition: vecWrd.h:56
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static Abc_Obj_t * Abc_ObjChild1(Abc_Obj_t *pObj)
Definition: abc.h:384
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
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 95 of file abcExtract.c.

96 {
97  Abc_Ntk_t * pNtk = Abc_ObjNtk(pObj);
98  Abc_Obj_t * pObjC, * pObj0, * pObj1, * pRoot = NULL;
99  Vec_Wrd_t * vSuper;
100  word Num, NumNext;
101  int i, k, fCompl = 0;
102  assert( !Abc_ObjIsComplement(pObj) );
103  assert( Abc_NodeIsExorType(pObj) );
104  // start iteration
105  vSuper = Vec_WrdAlloc( 10 );
106  Vec_WrdPush( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObj), Abc_ObjId(pObj)) );
107  while ( Vec_WrdSize(vSuper) > 0 )
108  {
109  // make sure there are no duplicates
110  Num = Vec_WrdEntry( vSuper, 0 );
111  Vec_WrdForEachEntryStart( vSuper, NumNext, i, 1 )
112  {
113  assert( Num < NumNext );
114  Num = NumNext;
115  }
116  // extract XOR gate decomposable on the topmost level
117  Vec_WrdForEachEntryReverse( vSuper, Num, i )
118  {
119  pRoot = Abc_NtkObj( pNtk, Abc_NtkShareUnpackId(Num) );
120  if ( Abc_NodeIsExorType(pRoot) )
121  {
122  Vec_WrdRemove( vSuper, Num );
123  break;
124  }
125  }
126  if ( i == -1 )
127  break;
128  // extract
129  pObjC = Abc_NodeRecognizeMux( pRoot, &pObj1, &pObj0 );
130  assert( pObj1 == Abc_ObjNot(pObj0) );
131  fCompl ^= Abc_ObjIsComplement(pObjC); pObjC = Abc_ObjRegular(pObjC);
132  fCompl ^= Abc_ObjIsComplement(pObj0); pObj0 = Abc_ObjRegular(pObj0);
133  Vec_WrdPushOrder( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObjC), Abc_ObjId(pObjC)) );
134  Vec_WrdPushOrder( vSuper, Abc_NtkSharePack(Abc_ObjLevel(pObj0), Abc_ObjId(pObj0)) );
135  (*pCounter)++;
136  // remove duplicates
137  k = 0;
138  Vec_WrdForEachEntry( vSuper, Num, i )
139  {
140  if ( i + 1 == Vec_WrdSize(vSuper) )
141  {
142  Vec_WrdWriteEntry( vSuper, k++, Num );
143  break;
144  }
145  NumNext = Vec_WrdEntry( vSuper, i+1 );
146  assert( Num <= NumNext );
147  if ( Num == NumNext )
148  i++;
149  else
150  Vec_WrdWriteEntry( vSuper, k++, Num );
151  }
152  Vec_WrdShrink( vSuper, k );
153  }
154  *pfCompl = fCompl;
155  Vec_WrdForEachEntry( vSuper, Num, i )
156  Vec_WrdWriteEntry( vSuper, i, Abc_NtkShareUnpackId(Num) );
157  return vSuper;
158 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static void Vec_WrdPushOrder(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:668
static int Abc_NtkShareUnpackId(word Num)
Definition: abcExtract.c:46
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
static void Vec_WrdShrink(Vec_Wrd_t *p, int nSizeNew)
Definition: vecWrd.h:585
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
static word Abc_NtkSharePack(int Lev, int Id)
Definition: abcExtract.c:44
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Vec_WrdRemove(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:802
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
#define assert(ex)
Definition: util_old.h:213
#define Vec_WrdForEachEntryStart(vVec, Entry, i, Start)
Definition: vecWrd.h:56
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
ABC_DLL int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1259
ABC_DLL Abc_Obj_t * Abc_NodeRecognizeMux(Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
Definition: abcUtil.c:1389
#define Vec_WrdForEachEntryReverse(vVec, pEntry, i)
Definition: vecWrd.h:62
static int Abc_NtkShareUnpackId ( word  Num)
inlinestatic

Definition at line 46 of file abcExtract.c.

46 { return Num & 0xFFFFFFFF; }
static int Abc_NtkShareUnpackLev ( word  Num)
inlinestatic

Definition at line 45 of file abcExtract.c.

45 { return (Num >> 32); }
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 720 of file abcExtract.c.

721 {
722  Abc_Ntk_t * pNtkNew;
723  Abc_ShaMan_t * p;
724  assert( Abc_NtkIsStrash(pNtk) );
725 // Abc_NtkDumpBlif( pNtk );
726  p = Abc_ShaManStart( pNtk );
727  p->nMultiSize = nMultiSize;
728  p->fVerbose = fVerbose;
729  Abc_NtkTraverseSupers( p, fAnd );
730  if ( p->nStartCols < 2 )
731  {
732  Abc_ShaManStop( p );
733  return Abc_NtkDup( pNtk );
734  }
735  if ( fVerbose )
736  Abc_NtkSharePrint( p );
737  Abc_NtkShareOptimize( p, fAnd );
738  if ( fVerbose )
739  Abc_NtkSharePrint( p );
740  pNtkNew = Abc_NtkUpdateNetwork( p, fAnd );
741  Abc_ShaManStop( p );
742  return pNtkNew;
743 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Abc_ShaMan_t * Abc_ShaManStart(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcExtract.c:64
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Abc_NtkSharePrint(Abc_ShaMan_t *p)
Definition: abcExtract.c:367
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
void Abc_NtkShareOptimize(Abc_ShaMan_t *p, int fAnd)
Definition: abcExtract.c:533
void Abc_NtkTraverseSupers(Abc_ShaMan_t *p, int fAnd)
Definition: abcExtract.c:313
#define assert(ex)
Definition: util_old.h:213
void Abc_ShaManStop(Abc_ShaMan_t *p)
Definition: abcExtract.c:72
Abc_Ntk_t * Abc_NtkUpdateNetwork(Abc_ShaMan_t *p, int fAnd)
Definition: abcExtract.c:597
void Abc_NtkTraverseSupers ( Abc_ShaMan_t p,
int  fAnd 
)

Definition at line 313 of file abcExtract.c.

314 {
315  Vec_Ptr_t * vInputs;
316  Vec_Int_t * vInput;
317  Abc_Obj_t * pObj;
318  int i, nOnesMax;
319 
320  // create mapping of nodes into their column vectors
321  vInputs = Vec_PtrStart( Abc_NtkObjNumMax(p->pNtk) * (1 + fAnd) );
323  if ( fAnd )
324  {
325  Abc_NtkForEachCo( p->pNtk, pObj, i )
326  if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
327  Abc_NtkTraverseSupersAnd_rec( p, Abc_ObjFanin0(pObj), vInputs );
328  }
329  else
330  {
331  Abc_NtkForEachCo( p->pNtk, pObj, i )
332  if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
333  Abc_NtkTraverseSupersXor_rec( p, Abc_ObjFanin0(pObj), vInputs );
334  }
335  p->nStartCols = Vec_IntSize(p->vObj2Lit);
336 
337  // find the largest number of 1s
338  nOnesMax = 0;
339  Vec_PtrForEachEntry( Vec_Int_t *, vInputs, vInput, i )
340  if ( vInput )
341  nOnesMax = Abc_MaxInt( nOnesMax, Vec_IntSize(vInput)-SHARE_NUM );
342 
343  // create buckets
344  assert( p->vBuckets == NULL );
345  p->vBuckets = Vec_PtrAlloc( nOnesMax + 1 );
346  for ( i = 0; i <= nOnesMax; i++ )
347  Vec_PtrPush( p->vBuckets, Vec_PtrAlloc(10) );
348 
349  // load vectors into buckets
350  Vec_PtrForEachEntry( Vec_Int_t *, vInputs, vInput, i )
351  if ( vInput )
352  Vec_PtrPush( (Vec_Ptr_t *)Vec_PtrEntry(p->vBuckets, Vec_IntSize(vInput)-SHARE_NUM), vInput );
353  Vec_PtrFree( vInputs );
354 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Abc_NtkTraverseSupersXor_rec(Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
Definition: abcExtract.c:237
Abc_Ntk_t * pNtk
Definition: abcExtract.c:36
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
void Abc_NtkTraverseSupersAnd_rec(Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
Definition: abcExtract.c:279
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkTraverseSupersAnd_rec ( Abc_ShaMan_t p,
Abc_Obj_t pObj,
Vec_Ptr_t vInputs 
)

Definition at line 279 of file abcExtract.c.

280 {
281  Vec_Wrd_t * vSuper;
282  word Num;
283  int k;
284  if ( Abc_NodeIsTravIdCurrent( pObj ) )
285  return;
286  Abc_NodeSetTravIdCurrent( pObj );
287  if ( Abc_ObjIsCi(pObj) )
288  return;
289  assert( Abc_ObjIsNode(pObj) );
290  vSuper = Abc_NtkShareSuperAnd( pObj, &p->nFoundGates );
291  if ( Vec_WrdSize(vSuper) <= 1 || Vec_WrdSize(vSuper) >= p->nMultiSize )
292  {
293  Vec_WrdForEachEntry( vSuper, Num, k )
294  {
295  Vec_Int_t * vInput = (Vec_Int_t *)Vec_PtrEntry( vInputs, (int)Num );
296  if ( vInput == NULL )
297  {
298  vInput = Vec_IntAlloc( 10 );
299  Vec_IntPush( vInput, (int)Num );
300  Vec_IntPush( vInput, Abc_ObjLevel(Abc_NtkObj(p->pNtk, Abc_Lit2Var((int)Num))) );
301  assert( SHARE_NUM == Vec_IntSize(vInput) );
302  Vec_PtrWriteEntry( vInputs, (int)Num, vInput );
303  }
304  Vec_IntPush( vInput, Vec_IntSize(p->vObj2Lit) );
305  }
306  Vec_IntPush( p->vObj2Lit, Abc_ObjToLit(pObj) );
307  }
308  // call recursively
309  Vec_WrdForEachEntry( vSuper, Num, k )
310  Abc_NtkTraverseSupersAnd_rec( p, Abc_NtkObj(p->pNtk, Abc_Lit2Var((int)Num)), vInputs );
311  Vec_WrdFree( vSuper );
312 }
Vec_Wrd_t * Abc_NtkShareSuperAnd(Abc_Obj_t *pObj, int *pCounter)
Definition: abcExtract.c:159
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Abc_Ntk_t * pNtk
Definition: abcExtract.c:36
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
void Abc_NtkTraverseSupersAnd_rec(Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
Definition: abcExtract.c:279
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Abc_ObjToLit(Abc_Obj_t *p)
Definition: abc.h:391
Vec_Int_t * vObj2Lit
Definition: abcExtract.c:38
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
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 237 of file abcExtract.c.

238 {
239  if ( Abc_NodeIsTravIdCurrent( pObj ) )
240  return;
241  Abc_NodeSetTravIdCurrent( pObj );
242  if ( Abc_ObjIsCi(pObj) )
243  return;
244  assert( Abc_ObjIsNode(pObj) );
245  if ( Abc_NodeIsExorType(pObj) )
246  {
247  Vec_Wrd_t * vSuper;
248  int k, fCompl;
249  word Num;
250  vSuper = Abc_NtkShareSuperXor( pObj, &fCompl, &p->nFoundGates );
251  if ( Vec_WrdSize(vSuper) <= 1 || Vec_WrdSize(vSuper) >= p->nMultiSize )
252  {
253  Vec_WrdForEachEntry( vSuper, Num, k )
254  {
255  Vec_Int_t * vInput = (Vec_Int_t *)Vec_PtrEntry( vInputs, (int)Num );
256  if ( vInput == NULL )
257  {
258  vInput = Vec_IntAlloc( 10 );
259  Vec_IntPush( vInput, Abc_Var2Lit((int)Num, 0) );
260  Vec_IntPush( vInput, Abc_ObjLevel(Abc_NtkObj(p->pNtk, (int)Num)) );
261  assert( SHARE_NUM == Vec_IntSize(vInput) );
262  Vec_PtrWriteEntry( vInputs, (int)Num, vInput );
263  }
264  Vec_IntPush( vInput, Vec_IntSize(p->vObj2Lit) );
265  }
266  Vec_IntPush( p->vObj2Lit, Abc_Var2Lit(Abc_ObjId(pObj), fCompl) );
267  }
268  // call recursively
269  Vec_WrdForEachEntry( vSuper, Num, k )
270  Abc_NtkTraverseSupersXor_rec( p, Abc_NtkObj(p->pNtk, (int)Num), vInputs );
271  Vec_WrdFree( vSuper );
272  }
273  else
274  {
275  Abc_NtkTraverseSupersXor_rec( p, Abc_ObjFanin0(pObj), vInputs );
276  Abc_NtkTraverseSupersXor_rec( p, Abc_ObjFanin1(pObj), vInputs );
277  }
278 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Abc_NtkTraverseSupersXor_rec(Abc_ShaMan_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vInputs)
Definition: abcExtract.c:237
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Abc_Ntk_t * pNtk
Definition: abcExtract.c:36
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecWrd.h:54
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
Vec_Wrd_t * Abc_NtkShareSuperXor(Abc_Obj_t *pObj, int *pfCompl, int *pCounter)
Definition: abcExtract.c:95
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * vObj2Lit
Definition: abcExtract.c:38
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
ABC_DLL int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1259
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Abc_Ntk_t* Abc_NtkUpdateNetwork ( Abc_ShaMan_t p,
int  fAnd 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 597 of file abcExtract.c.

598 {
599  Abc_Ntk_t * pNtk;
600  Vec_Int_t * vInput, * vMap2Repl;
601  Vec_Ptr_t * vOrig, * vRepl, * vBucket;
602  Abc_Obj_t * pObj, * pNew;
603  int i, j, k, ObjId, iLit;
604  int iLitConst1 = Abc_ObjToLit( Abc_AigConst1(p->pNtk) );
605 
606  vOrig = Vec_PtrAlloc( p->nStartCols );
607  vRepl = Vec_PtrAlloc( p->nStartCols );
608  for ( i = 0; i < p->nStartCols; i++ )
609  {
610  iLit = Vec_IntEntry( p->vObj2Lit, i );
611  assert( !fAnd || !Abc_LitIsCompl(iLit) );
612 
613  pObj = Abc_NtkObj( p->pNtk, Abc_Lit2Var(iLit) );
614 
615  if ( fAnd )
616  pNew = Abc_AigConst1(p->pNtk);
617  else
618  pNew = Abc_ObjNotCond( Abc_AigConst1(p->pNtk), !Abc_LitIsCompl(iLit) );
619 
620  Vec_PtrPush( vOrig, pObj );
621  Vec_PtrPush( vRepl, pNew );
622 
623  p->nCountGates--;
624  }
625 
626  // go through the columns
627  Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
628  Vec_PtrForEachEntry( Vec_Int_t *, vBucket, vInput, j )
629  {
630  Vec_IntForEachEntryStart( vInput, ObjId, k, SHARE_NUM )
631  {
632  assert( ObjId < Vec_IntSize(p->vObj2Lit) );
633  if ( ObjId >= p->nStartCols )
634  break;
635  assert( ObjId < p->nStartCols );
636  iLit = Vec_IntEntry( vInput, 0 );
637 
638  pNew = (Abc_Obj_t *)Vec_PtrEntry( vRepl, ObjId );
639  if ( fAnd )
640  pNew = Abc_AigAnd( (Abc_Aig_t *)p->pNtk->pManFunc, pNew, Abc_ObjFromLit(p->pNtk, iLit) );
641  else
642  pNew = Abc_AigXor( (Abc_Aig_t *)p->pNtk->pManFunc, pNew, Abc_ObjFromLit(p->pNtk, iLit) );
643  Vec_PtrWriteEntry( vRepl, ObjId, pNew );
644  p->nCountGates++;
645  }
646  }
647 
648  if ( p->fVerbose )
649  printf( "Total gates collected = %d. Total gates constructed = %d.\n", p->nFoundGates, p->nCountGates );
650 
651  // create map of originals
652  vMap2Repl = Vec_IntStartFull( Abc_NtkObjNumMax(p->pNtk) );
653  Vec_PtrForEachEntry( Abc_Obj_t *, vOrig, pObj, i )
654  {
655 // printf( "Replacing %d by %d.\n", Abc_ObjId(pObj), Abc_ObjToLit((Abc_Obj_t *)Vec_PtrEntry(vRepl, i)) );
656  Vec_IntWriteEntry( vMap2Repl, Abc_ObjId(pObj), Abc_ObjToLit((Abc_Obj_t *)Vec_PtrEntry(vRepl, i)) );
657  }
658  Vec_PtrFree( vOrig );
659  Vec_PtrFree( vRepl );
660 
661  // update fanin pointers
662  Abc_NtkForEachObj( p->pNtk, pObj, i )
663  {
664  if ( Abc_ObjIsCo(pObj) || Abc_ObjIsNode(pObj) )
665  {
666  iLit = Vec_IntEntry( vMap2Repl, Abc_ObjFaninId0(pObj) );
667  if ( iLit >= 0 )
668  {
669  if ( iLit == iLitConst1 && fAnd )
670  {
671  pObj->fCompl0 ^= 1;
672  Vec_IntWriteEntry( &pObj->vFanins, 0, Abc_Lit2Var(iLitConst1) );
673  }
674  else
675  {
676  pObj->fCompl0 ^= Abc_LitIsCompl(iLit);
677  Vec_IntWriteEntry( &pObj->vFanins, 0, Abc_Lit2Var(iLit) );
678  }
679  }
680  }
681  if ( Abc_ObjIsNode(pObj) )
682  {
683  iLit = Vec_IntEntry( vMap2Repl, Abc_ObjFaninId1(pObj) );
684  if ( iLit >= 0 )
685  {
686  if ( iLit == iLitConst1 && fAnd )
687  {
688  pObj->fCompl1 ^= 1;
689  Vec_IntWriteEntry( &pObj->vFanins, 1, Abc_Lit2Var(iLitConst1) );
690  }
691  else
692  {
693  pObj->fCompl1 ^= Abc_LitIsCompl(iLit);
694  Vec_IntWriteEntry( &pObj->vFanins, 1, Abc_Lit2Var(iLit) );
695  }
696  }
697  }
698  }
699  Vec_IntFree( vMap2Repl );
700 
701 // pNtk = Abc_NtkRestrash( p->pNtk, 1 );
702  if ( fAnd )
703  pNtk = Abc_NtkBalance( p->pNtk, 0, 0, 1 );
704  else
705  pNtk = Abc_NtkBalanceExor( p->pNtk, 1, 0 );
706  return pNtk;
707 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static Abc_Obj_t * Abc_ObjFromLit(Abc_Ntk_t *p, int iLit)
Definition: abc.h:390
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define SHARE_NUM
DECLARATIONS ///.
Definition: abcExtract.c:29
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
unsigned fCompl0
Definition: abc.h:140
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Abc_Ntk_t * pNtk
Definition: abcExtract.c:36
ABC_DLL Abc_Ntk_t * Abc_NtkBalanceExor(Abc_Ntk_t *pNtk, int fUpdateLevel, int fVerbose)
Definition: abcDar.c:3935
Vec_Int_t vFanins
Definition: abc.h:143
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
unsigned fCompl1
Definition: abc.h:141
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
DECLARATIONS ///.
Definition: abcAig.c:52
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:735
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
ABC_DLL Abc_Ntk_t * Abc_NtkBalance(Abc_Ntk_t *pNtk, int fDuplicate, int fSelective, int fUpdateLevel)
FUNCTION DEFINITIONS ///.
Definition: abcBalance.c:53
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Abc_ObjToLit(Abc_Obj_t *p)
Definition: abc.h:391
Vec_Int_t * vObj2Lit
Definition: abcExtract.c:38
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
Vec_Ptr_t * vBuckets
Definition: abcExtract.c:37
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_ShaMan_t* Abc_ShaManStart ( Abc_Ntk_t pNtk)

FUNCTION DEFINITIONS ///.

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

Synopsis [Working with the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file abcExtract.c.

65 {
66  Abc_ShaMan_t * p;
67  p = ABC_CALLOC( Abc_ShaMan_t, 1 );
68  p->pNtk = pNtk;
69  p->vObj2Lit = Vec_IntAlloc( 1000 );
70  return p;
71 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Abc_Ntk_t * pNtk
Definition: abcExtract.c:36
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t * vObj2Lit
Definition: abcExtract.c:38
void Abc_ShaManStop ( Abc_ShaMan_t p)

Definition at line 72 of file abcExtract.c.

73 {
74  Vec_Ptr_t * vBucket;
75  int i;
76  Vec_PtrForEachEntry( Vec_Ptr_t *, p->vBuckets, vBucket, i )
77  Vec_VecFree( (Vec_Vec_t *)vBucket );
78  Vec_PtrFreeP( &p->vBuckets );
79  Vec_IntFreeP( &p->vObj2Lit );
80  ABC_FREE( p );
81 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Ptr_t * vBuckets
Definition: abcExtract.c:37