abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaShrink6.c File Reference
#include "gia.h"
#include "bool/bdc/bdc.h"
#include "bool/rsb/rsb.h"

Go to the source code of this file.

Data Structures

struct  Shr_Fan_t_
 
struct  Shr_Man_t_
 

Macros

#define Shr_ObjForEachFanout(p, iNode, iFan)   for ( iFan = Shr_ManFanIterStart(p, iNode); iFan; iFan = Shr_ManFanIterNext(p) )
 

Typedefs

typedef struct Shr_Fan_t_ Shr_Fan_t
 
typedef struct Shr_Man_t_ Shr_Man_t
 

Functions

Shr_Man_tShr_ManAlloc (Gia_Man_t *pGia)
 FUNCTION DEFINITIONS ///. More...
 
Gia_Man_tShr_ManFree (Shr_Man_t *p)
 
static void Shr_ManAddFanout (Shr_Man_t *p, int iFanin, int iFanout)
 
static int Shr_ManFanIterStart (Shr_Man_t *p, int iNode)
 
static int Shr_ManFanIterNext (Shr_Man_t *p)
 
static int Shr_ManDivPushOrderByLevel (Shr_Man_t *p, int iDiv)
 
static int Shr_ManCollectDivisors (Shr_Man_t *p, Vec_Int_t *vLeaves, int Limit, int nFanoutMax)
 
int Shr_ObjPerformBidec (Shr_Man_t *p, Bdc_Man_t *pManDec, Gia_Man_t *pNew, Vec_Int_t *vLeafLits, word uTruth1, word uTruthC)
 
word Shr_ManComputeTruth6_rec (Gia_Man_t *p, int iNode, Vec_Wrd_t *vTruths)
 
word Shr_ManComputeTruth6 (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves, Vec_Wrd_t *vTruths)
 
void Shr_ManComputeTruths (Gia_Man_t *p, int nVars, Vec_Int_t *vDivs, Vec_Wrd_t *vDivTruths, Vec_Wrd_t *vTruths)
 
Gia_Man_tGia_ManMapShrink6 (Gia_Man_t *p, int nFanoutMax, int fKeepLevel, int fVerbose)
 

Variables

static
ABC_NAMESPACE_IMPL_START word 
Truth [8]
 DECLARATIONS ///. More...
 

Macro Definition Documentation

#define Shr_ObjForEachFanout (   p,
  iNode,
  iFan 
)    for ( iFan = Shr_ManFanIterStart(p, iNode); iFan; iFan = Shr_ManFanIterNext(p) )

Definition at line 78 of file giaShrink6.c.

Typedef Documentation

typedef struct Shr_Fan_t_ Shr_Fan_t

Definition at line 44 of file giaShrink6.c.

typedef struct Shr_Man_t_ Shr_Man_t

Definition at line 52 of file giaShrink6.c.

Function Documentation

Gia_Man_t* Gia_ManMapShrink6 ( Gia_Man_t p,
int  nFanoutMax,
int  fKeepLevel,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 401 of file giaShrink6.c.

402 {
403  Shr_Man_t * pMan;
404  Gia_Obj_t * pObj, * pFanin;
405  word uTruth, uTruth0, uTruth1;
406  int i, k, nDivs, iNode;
407  int RetValue, Counter1 = 0, Counter2 = 0;
408  abctime clk2, clk = Abc_Clock();
409  abctime timeFanout = 0;
411  pMan = Shr_ManAlloc( p );
412  Gia_ManFillValue( p );
413  Gia_ManConst0(p)->Value = 0;
414  Gia_ManForEachObj1( p, pObj, i )
415  {
416  if ( Gia_ObjIsCi(pObj) )
417  {
418  pObj->Value = Gia_ManAppendCi( pMan->pNew );
419  if ( p->vLevels )
420  Gia_ObjSetLevel( pMan->pNew, Gia_ObjFromLit(pMan->pNew, Gia_ObjValue(pObj)), Gia_ObjLevel(p, pObj) );
421  }
422  else if ( Gia_ObjIsCo(pObj) )
423  {
424  pObj->Value = Gia_ManAppendCo( pMan->pNew, Gia_ObjFanin0Copy(pObj) );
425  }
426  else if ( Gia_ObjIsLut(p, i) )
427  {
428  // collect leaves of this gate
429  Vec_IntClear( pMan->vLeaves );
430  Gia_LutForEachFanin( p, i, iNode, k )
431  Vec_IntPush( pMan->vLeaves, iNode );
432  assert( Vec_IntSize(pMan->vLeaves) <= 6 );
433  // compute truth table
434  uTruth = Shr_ManComputeTruth6( pMan->pGia, pObj, pMan->vLeaves, pMan->vTruths );
435  assert( pObj->Value == ~0 );
436  if ( uTruth == 0 || ~uTruth == 0 )
437  pObj->Value = Abc_LitNotCond( 0, ~uTruth == 0 );
438  else
439  Gia_ManForEachObjVec( pMan->vLeaves, p, pFanin, k )
440  if ( uTruth == Truth[k] || ~uTruth == Truth[k] )
441  pObj->Value = Abc_LitNotCond( pFanin->Value, ~uTruth == Truth[k] );
442  if ( pObj->Value != ~0 )
443  continue;
444  // translate into new nodes
445  Gia_ManForEachObjVec( pMan->vLeaves, p, pFanin, k )
446  {
447  if ( Abc_LitIsCompl(pFanin->Value) )
448  uTruth = ((uTruth & Truth[k]) >> (1 << k)) | ((uTruth & ~Truth[k]) << (1 << k));
449  Vec_IntWriteEntry( pMan->vLeaves, k, Abc_Lit2Var(pFanin->Value) );
450  }
451  // compute divisors
452  clk2 = Abc_Clock();
453  nDivs = Shr_ManCollectDivisors( pMan, pMan->vLeaves, pMan->nDivMax, nFanoutMax );
454  assert( nDivs <= pMan->nDivMax );
455  timeFanout += Abc_Clock() - clk2;
456  // compute truth tables
457  Shr_ManComputeTruths( pMan->pNew, Vec_IntSize(pMan->vLeaves), pMan->vDivs, pMan->vDivTruths, pMan->vTruths );
458  // perform resubstitution
459  RetValue = Rsb_ManPerformResub6( pMan->pManRsb, Vec_IntSize(pMan->vLeaves), uTruth, pMan->vDivTruths, &uTruth0, &uTruth1, 0 );
460  if ( RetValue ) // resub exists
461  {
462  Vec_Int_t * vResult = Rsb_ManGetFanins(pMan->pManRsb);
463  Vec_IntClear( pMan->vDivResub );
464  Vec_IntForEachEntry( vResult, iNode, k )
465  Vec_IntPush( pMan->vDivResub, Vec_IntEntry(pMan->vDivs, iNode) );
466  pObj->Value = Shr_ObjPerformBidec( pMan, pMan->pManDec, pMan->pNew, pMan->vDivResub, uTruth1, uTruth0 | uTruth1 );
467  Counter1++;
468  }
469  else
470  {
471  pObj->Value = Shr_ObjPerformBidec( pMan, pMan->pManDec, pMan->pNew, pMan->vLeaves, uTruth, ~(word)0 );
472  Counter2++;
473  }
474  }
475  }
476  if ( fVerbose )
477  {
478  printf( "Performed %d resubs and %d decomps. ", Counter1, Counter2 );
479  printf( "Gain in AIG nodes = %d. ", Gia_ManObjNum(p)-Gia_ManObjNum(pMan->pNew) );
480  ABC_PRT( "Runtime", Abc_Clock() - clk );
481 // ABC_PRT( "Divisors", timeFanout );
482  }
483  return Shr_ManFree( pMan );
484 }
Gia_Man_t * Shr_ManFree(Shr_Man_t *p)
Definition: giaShrink6.c:128
Vec_Wrd_t * vTruths
Definition: giaShrink6.c:69
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Gia_Obj_t * Gia_ObjFromLit(Gia_Man_t *p, int iLit)
Definition: gia.h:496
Vec_Int_t * vLeaves
Definition: giaShrink6.c:67
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
int Shr_ObjPerformBidec(Shr_Man_t *p, Bdc_Man_t *pManDec, Gia_Man_t *pNew, Vec_Int_t *vLeafLits, word uTruth1, word uTruthC)
Definition: giaShrink6.c:275
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
Vec_Int_t * vDivs
Definition: giaShrink6.c:64
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Rsb_Man_t * pManRsb
Definition: giaShrink6.c:72
if(last==0)
Definition: sparse_int.h:34
Vec_Wrd_t * vDivTruths
Definition: giaShrink6.c:70
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
word Shr_ManComputeTruth6(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves, Vec_Wrd_t *vTruths)
Definition: giaShrink6.c:335
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
int nDivMax
Definition: giaShrink6.c:57
static int Shr_ManCollectDivisors(Shr_Man_t *p, Vec_Int_t *vLeaves, int Limit, int nFanoutMax)
Definition: giaShrink6.c:223
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
Shr_Man_t * Shr_ManAlloc(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
Definition: giaShrink6.c:96
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
Vec_Int_t * vDivResub
Definition: giaShrink6.c:66
Vec_Int_t * Rsb_ManGetFanins(Rsb_Man_t *p)
Definition: rsbMan.c:84
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
Vec_Int_t * vLevels
Definition: gia.h:115
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
#define Gia_ManForEachObj1(p, pObj, i)
Definition: gia.h:986
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
int Rsb_ManPerformResub6(Rsb_Man_t *p, int nVars, word uTruth, Vec_Wrd_t *vDivTruths, word *puTruth0, word *puTruth1, int fVerbose)
Definition: rsbDec6.c:694
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Shr_ManComputeTruths(Gia_Man_t *p, int nVars, Vec_Int_t *vDivs, Vec_Wrd_t *vDivTruths, Vec_Wrd_t *vTruths)
Definition: giaShrink6.c:359
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Gia_Man_t * pNew
Definition: giaShrink6.c:56
static void Gia_ObjSetLevel(Gia_Man_t *p, Gia_Obj_t *pObj, int l)
Definition: gia.h:503
static void Shr_ManAddFanout ( Shr_Man_t p,
int  iFanin,
int  iFanout 
)
inlinestatic

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

Synopsis [Fanout manipulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file giaShrink6.c.

172 {
173  union {
174  Shr_Fan_t sFan;
175  word sWord;
176  } FanStr;
177  FanStr.sFan.iFan = iFanout;
178  FanStr.sFan.Next = Vec_IntEntry(p->vObj2Fan, iFanin);
179  Vec_IntWriteEntry( p->vObj2Fan, iFanin, Vec_WrdSize(p->vFanMem) );
180  Vec_WrdPush(p->vFanMem, FanStr.sWord );
181 }
Vec_Int_t * vObj2Fan
Definition: giaShrink6.c:61
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Vec_Wrd_t * vFanMem
Definition: giaShrink6.c:60
Shr_Man_t* Shr_ManAlloc ( Gia_Man_t pGia)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 96 of file giaShrink6.c.

97 {
98  Shr_Man_t * p;
99  p = ABC_CALLOC( Shr_Man_t, 1 );
100  p->nDivMax = 64;
101  p->nNewSize = 2 * Gia_ManObjNum(pGia);
102  p->pGia = pGia;
103  p->vFanMem = Vec_WrdAlloc( 1000 ); Vec_WrdPush(p->vFanMem, -1);
104  p->vObj2Fan = Vec_IntStart( p->nNewSize );
105  p->vDivs = Vec_IntAlloc( 1000 );
106  p->vPrio = Vec_IntAlloc( 1000 );
107  p->vTruths = Vec_WrdStart( p->nNewSize );
108  p->vDivTruths = Vec_WrdAlloc( 100 );
109  p->vDivResub = Vec_IntAlloc( 6 );
110  p->vLeaves = Vec_IntAlloc( 6 );
111  // start new manager
112  p->pNew = Gia_ManStart( p->nNewSize );
113  p->pNew->pName = Abc_UtilStrsav( pGia->pName );
114  p->pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
115  Gia_ManHashAlloc( p->pNew );
116  Gia_ManCleanLevels( p->pNew, p->nNewSize );
117  // allocate traversal IDs
118  p->pNew->nObjs = p->nNewSize;
120  p->pNew->nObjs = 1;
121  // start decompostion
122  p->Pars.nVarsMax = 6;
123  p->Pars.fVerbose = 0;
124  p->pManDec = Bdc_ManAlloc( &p->Pars );
125  p->pManRsb = Rsb_ManAlloc( 6, p->nDivMax, 4, 1 );
126  return p;
127 }
Vec_Wrd_t * vTruths
Definition: giaShrink6.c:69
Vec_Int_t * vObj2Fan
Definition: giaShrink6.c:61
int fVerbose
Definition: bdc.h:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nVarsMax
Definition: bdc.h:48
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
Vec_Int_t * vLeaves
Definition: giaShrink6.c:67
Bdc_Man_t * Bdc_ManAlloc(Bdc_Par_t *pPars)
MACRO DEFINITIONS ///.
Definition: bdcCore.c:68
int nObjs
Definition: gia.h:101
Rsb_Man_t * Rsb_ManAlloc(int nLeafMax, int nDivMax, int nDecMax, int fVerbose)
MACRO DEFINITIONS ///.
Definition: rsbMan.c:45
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
Gia_Man_t * pGia
Definition: giaShrink6.c:55
Vec_Int_t * vDivs
Definition: giaShrink6.c:64
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Rsb_Man_t * pManRsb
Definition: giaShrink6.c:72
Vec_Wrd_t * vDivTruths
Definition: giaShrink6.c:70
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
void Gia_ManCleanLevels(Gia_Man_t *p, int Size)
Definition: giaUtil.c:470
int nDivMax
Definition: giaShrink6.c:57
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
Bdc_Par_t Pars
Definition: giaShrink6.c:74
int nNewSize
Definition: giaShrink6.c:58
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t * vDivResub
Definition: giaShrink6.c:66
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Vec_Wrd_t * vFanMem
Definition: giaShrink6.c:60
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Vec_Int_t * vPrio
Definition: giaShrink6.c:65
Bdc_Man_t * pManDec
Definition: giaShrink6.c:73
Gia_Man_t * pNew
Definition: giaShrink6.c:56
static int Shr_ManCollectDivisors ( Shr_Man_t p,
Vec_Int_t vLeaves,
int  Limit,
int  nFanoutMax 
)
inlinestatic

Definition at line 223 of file giaShrink6.c.

224 {
225  Gia_Obj_t * pFan;
226  int i, c, iDiv, iFan, iPlace;
227  assert( Limit > 6 );
228  Vec_IntClear( p->vDivs );
229  Vec_IntClear( p->vPrio );
231  Vec_IntForEachEntry( vLeaves, iDiv, i )
232  {
233  Vec_IntPush( p->vDivs, iDiv );
234  Shr_ManDivPushOrderByLevel( p, iDiv );
235  Gia_ObjSetTravIdCurrentId( p->pNew, iDiv );
236  }
237  Vec_IntForEachEntry( p->vPrio, iDiv, i )
238  {
239  c = 0;
240  assert( Gia_ObjIsTravIdCurrentId(p->pNew, iDiv) );
241  Shr_ObjForEachFanout( p, iDiv, iFan )
242  {
243  if ( c++ == nFanoutMax )
244  break;
245  if ( Gia_ObjIsTravIdCurrentId(p->pNew, iFan) )
246  continue;
247  pFan = Gia_ManObj( p->pNew, iFan );
248  assert( Gia_ObjIsAnd(pFan) );
249  assert( Gia_ObjLevel(p->pNew, Gia_ManObj(p->pNew, iDiv)) < Gia_ObjLevel(p->pNew, pFan) );
250  if ( !Gia_ObjIsTravIdCurrentId(p->pNew, Gia_ObjFaninId0(pFan, iFan)) ||
251  !Gia_ObjIsTravIdCurrentId(p->pNew, Gia_ObjFaninId1(pFan, iFan)) )
252  continue;
253  Vec_IntPush( p->vDivs, iFan );
254  Gia_ObjSetTravIdCurrentId( p->pNew, iFan );
255  iPlace = Shr_ManDivPushOrderByLevel( p, iFan );
256  assert( i < iPlace );
257  if ( Vec_IntSize(p->vDivs) == Limit )
258  return Vec_IntSize(p->vDivs);
259  }
260  }
261  return Vec_IntSize(p->vDivs);
262 }
static int Shr_ManDivPushOrderByLevel(Shr_Man_t *p, int iDiv)
Definition: giaShrink6.c:208
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
Vec_Int_t * vDivs
Definition: giaShrink6.c:64
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjIsTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:536
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static void Gia_ObjSetTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:535
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
#define Shr_ObjForEachFanout(p, iNode, iFan)
Definition: giaShrink6.c:78
Vec_Int_t * vPrio
Definition: giaShrink6.c:65
Gia_Man_t * pNew
Definition: giaShrink6.c:56
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
word Shr_ManComputeTruth6 ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vLeaves,
Vec_Wrd_t vTruths 
)

Definition at line 335 of file giaShrink6.c.

336 {
337  int i, iLeaf;
338  assert( Gia_ObjIsAnd(pObj) );
340  Vec_IntForEachEntry( vLeaves, iLeaf, i )
341  {
342  Gia_ObjSetTravIdCurrentId( p, iLeaf );
343  Vec_WrdWriteEntry( vTruths, iLeaf, Truth[i] );
344  }
345  return Shr_ManComputeTruth6_rec( p, Gia_ObjId(p, pObj), vTruths );
346 }
word Shr_ManComputeTruth6_rec(Gia_Man_t *p, int iNode, Vec_Wrd_t *vTruths)
Definition: giaShrink6.c:317
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static void Gia_ObjSetTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:535
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
word Shr_ManComputeTruth6_rec ( Gia_Man_t p,
int  iNode,
Vec_Wrd_t vTruths 
)

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

Synopsis [Compute truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file giaShrink6.c.

318 {
319  Gia_Obj_t * pObj;
320  word Truth0, Truth1;
321  if ( Gia_ObjIsTravIdCurrentId(p, iNode) )
322  return Vec_WrdEntry(vTruths, iNode);
323  Gia_ObjSetTravIdCurrentId(p, iNode);
324  pObj = Gia_ManObj( p, iNode );
325  assert( Gia_ObjIsAnd(pObj) );
326  Truth0 = Shr_ManComputeTruth6_rec( p, Gia_ObjFaninId0p(p, pObj), vTruths );
327  Truth1 = Shr_ManComputeTruth6_rec( p, Gia_ObjFaninId1p(p, pObj), vTruths );
328  if ( Gia_ObjFaninC0(pObj) )
329  Truth0 = ~Truth0;
330  if ( Gia_ObjFaninC1(pObj) )
331  Truth1 = ~Truth1;
332  Vec_WrdWriteEntry( vTruths, iNode, Truth0 & Truth1 );
333  return Truth0 & Truth1;
334 }
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
word Shr_ManComputeTruth6_rec(Gia_Man_t *p, int iNode, Vec_Wrd_t *vTruths)
Definition: giaShrink6.c:317
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 int Gia_ObjIsTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:536
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Gia_ObjSetTravIdCurrentId(Gia_Man_t *p, int Id)
Definition: gia.h:535
void Shr_ManComputeTruths ( Gia_Man_t p,
int  nVars,
Vec_Int_t vDivs,
Vec_Wrd_t vDivTruths,
Vec_Wrd_t vTruths 
)

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

Synopsis [Compute truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 359 of file giaShrink6.c.

360 {
361  Gia_Obj_t * pObj;
362  word Truth0, Truth1;//, Truthh;
363  int i, iDiv;
364  Vec_WrdClear( vDivTruths );
365  Vec_IntForEachEntryStop( vDivs, iDiv, i, nVars )
366  {
367  Vec_WrdWriteEntry( vTruths, iDiv, Truth[i] );
368  Vec_WrdPush( vDivTruths, Truth[i] );
369  }
370  Vec_IntForEachEntryStart( vDivs, iDiv, i, nVars )
371  {
372  pObj = Gia_ManObj( p, iDiv );
373  Truth0 = Vec_WrdEntry( vTruths, Gia_ObjFaninId0(pObj, iDiv) );
374  Truth1 = Vec_WrdEntry( vTruths, Gia_ObjFaninId1(pObj, iDiv) );
375  if ( Gia_ObjFaninC0(pObj) )
376  Truth0 = ~Truth0;
377  if ( Gia_ObjFaninC1(pObj) )
378  Truth1 = ~Truth1;
379  Vec_WrdWriteEntry( vTruths, iDiv, Truth0 & Truth1 );
380  Vec_WrdPush( vDivTruths, Truth0 & Truth1 );
381 
382 // Truthh = Truth0 & Truth1;
383 // Abc_TtPrintBinary( &Truthh, nVars ); //printf( "\n" );
384 // Kit_DsdPrintFromTruth( &Truthh, nVars ); printf( "\n" );
385  }
386 // printf( "\n" );
387 }
#define Vec_IntForEachEntryStop(vVec, Entry, i, Stop)
Definition: vecInt.h:58
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static void Vec_WrdClear(Vec_Wrd_t *p)
Definition: vecWrd.h:602
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static int Shr_ManDivPushOrderByLevel ( Shr_Man_t p,
int  iDiv 
)
inlinestatic

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

Synopsis [Collect divisors.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file giaShrink6.c.

209 {
210  int iPlace, * pArray;
211  Vec_IntPush( p->vPrio, iDiv );
212  if ( Vec_IntSize(p->vPrio) == 1 )
213  return 0;
214  pArray = Vec_IntArray(p->vPrio);
215  for ( iPlace = Vec_IntSize(p->vPrio) - 1; iPlace > 0; iPlace-- )
216  if ( Gia_ObjLevel(p->pNew, Gia_ManObj(p->pNew, pArray[iPlace-1])) >
217  Gia_ObjLevel(p->pNew, Gia_ManObj(p->pNew, pArray[iPlace])) )
218  ABC_SWAP( int, pArray[iPlace-1], pArray[iPlace] )
219  else
220  break;
221  return iPlace; // the place of the new divisor
222 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * vPrio
Definition: giaShrink6.c:65
Gia_Man_t * pNew
Definition: giaShrink6.c:56
static int Shr_ManFanIterNext ( Shr_Man_t p)
inlinestatic

Definition at line 189 of file giaShrink6.c.

190 {
191  if ( p->pFanTemp->Next == 0 )
192  return 0;
194  return p->pFanTemp->iFan;
195 }
Shr_Fan_t * pFanTemp
Definition: giaShrink6.c:62
Vec_Wrd_t * vFanMem
Definition: giaShrink6.c:60
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:401
static int Shr_ManFanIterStart ( Shr_Man_t p,
int  iNode 
)
inlinestatic

Definition at line 182 of file giaShrink6.c.

183 {
184  if ( Vec_IntEntry(p->vObj2Fan, iNode) == 0 )
185  return 0;
186  p->pFanTemp = (Shr_Fan_t *)Vec_WrdEntryP( p->vFanMem, Vec_IntEntry(p->vObj2Fan, iNode) );
187  return p->pFanTemp->iFan;
188 }
Vec_Int_t * vObj2Fan
Definition: giaShrink6.c:61
Shr_Fan_t * pFanTemp
Definition: giaShrink6.c:62
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Vec_Wrd_t * vFanMem
Definition: giaShrink6.c:60
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:401
Gia_Man_t* Shr_ManFree ( Shr_Man_t p)

Definition at line 128 of file giaShrink6.c.

129 {
130  // prepare the manager
131  Gia_Man_t * pTemp;
132  Gia_ManHashStop( p->pNew );
133  Vec_IntFreeP( &p->pNew->vLevels );
134  if ( Gia_ManHasDangling(p->pNew) )
135  {
136  p->pNew = Gia_ManCleanup( pTemp = p->pNew );
137  if ( Gia_ManAndNum(p->pNew) != Gia_ManAndNum(pTemp) )
138  printf( "Node reduction after sweep %6d -> %6d.\n", Gia_ManAndNum(pTemp), Gia_ManAndNum(p->pNew) );
139  Gia_ManStop( pTemp );
140  }
142  pTemp = p->pNew; p->pNew = NULL;
143  // free data structures
144  Rsb_ManFree( p->pManRsb );
145  Bdc_ManFree( p->pManDec );
146  Gia_ManStopP( &p->pNew );
147  Vec_WrdFree( p->vFanMem );
148  Vec_IntFree( p->vObj2Fan );
149  Vec_IntFree( p->vDivs );
150  Vec_IntFree( p->vPrio );
151  Vec_WrdFree( p->vTruths );
152  Vec_WrdFree( p->vDivTruths );
153  Vec_IntFree( p->vDivResub );
154  Vec_IntFree( p->vLeaves );
155  ABC_FREE( p );
156  return pTemp;
157 }
Vec_Wrd_t * vTruths
Definition: giaShrink6.c:69
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Vec_Int_t * vObj2Fan
Definition: giaShrink6.c:61
Vec_Int_t * vLeaves
Definition: giaShrink6.c:67
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
int Gia_ManHasDangling(Gia_Man_t *p)
Definition: giaUtil.c:1155
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
void Rsb_ManFree(Rsb_Man_t *p)
Definition: rsbMan.c:63
Gia_Man_t * pGia
Definition: giaShrink6.c:55
Vec_Int_t * vDivs
Definition: giaShrink6.c:64
Rsb_Man_t * pManRsb
Definition: giaShrink6.c:72
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
Vec_Wrd_t * vDivTruths
Definition: giaShrink6.c:70
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
Vec_Int_t * vDivResub
Definition: giaShrink6.c:66
Vec_Int_t * vLevels
Definition: gia.h:115
void Bdc_ManFree(Bdc_Man_t *p)
Definition: bdcCore.c:113
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Vec_Wrd_t * vFanMem
Definition: giaShrink6.c:60
Vec_Int_t * vPrio
Definition: giaShrink6.c:65
Bdc_Man_t * pManDec
Definition: giaShrink6.c:73
Gia_Man_t * pNew
Definition: giaShrink6.c:56
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
int Shr_ObjPerformBidec ( Shr_Man_t p,
Bdc_Man_t pManDec,
Gia_Man_t pNew,
Vec_Int_t vLeafLits,
word  uTruth1,
word  uTruthC 
)

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

Synopsis [Resynthesizes nodes using bi-decomposition.]

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file giaShrink6.c.

276 {
277  Bdc_Fun_t * pFunc;
278  Gia_Obj_t * pObj;
279  int i, iVar, iLit, nNodes, iLast;
280  int nVars = Vec_IntSize(vLeafLits);
281  assert( uTruth1 != 0 && uTruthC != 0 );
282  Bdc_ManDecompose( pManDec, (unsigned *)&uTruth1, (unsigned *)&uTruthC, nVars, NULL, 1000 );
283  Bdc_FuncSetCopyInt( Bdc_ManFunc(pManDec, 0), 1 );
284  Vec_IntForEachEntry( vLeafLits, iVar, i )
285  Bdc_FuncSetCopyInt( Bdc_ManFunc(pManDec, i+1), Abc_Var2Lit(iVar, 0) );
286  nNodes = Bdc_ManNodeNum( pManDec );
287  for ( i = nVars + 1; i < nNodes; i++ )
288  {
289  pFunc = Bdc_ManFunc( pManDec, i );
290  iLast = Gia_ManObjNum(pNew);
291  iLit = Gia_ManHashAnd( pNew, Bdc_FunFanin0Copy(pFunc), Bdc_FunFanin1Copy(pFunc) );
292  Bdc_FuncSetCopyInt( pFunc, iLit );
293  if ( iLast == Gia_ManObjNum(pNew) )
294  continue;
295  assert( iLast + 1 == Gia_ManObjNum(pNew) );
296  pObj = Gia_ManObj(pNew, Abc_Lit2Var(iLit));
297  Gia_ObjSetAndLevel( pNew, pObj );
298  Shr_ManAddFanout( p, Gia_ObjFaninId0p(pNew, pObj), Gia_ObjId(pNew, pObj) );
299  Shr_ManAddFanout( p, Gia_ObjFaninId1p(pNew, pObj), Gia_ObjId(pNew, pObj) );
300  assert( Gia_ManObjNum(pNew) < p->nNewSize );
301  }
302  return Bdc_FunObjCopy( Bdc_ManRoot(pManDec) );
303 }
Bdc_Fun_t * Bdc_ManRoot(Bdc_Man_t *p)
Definition: bdcCore.c:47
static void Shr_ManAddFanout(Shr_Man_t *p, int iFanin, int iFanout)
Definition: giaShrink6.c:171
static int Bdc_FunFanin1Copy(Bdc_Fun_t *pObj)
Definition: bdc.h:86
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
int Bdc_ManDecompose(Bdc_Man_t *p, unsigned *puFunc, unsigned *puCare, int nVars, Vec_Ptr_t *vDivs, int nNodesMax)
Definition: bdcCore.c:291
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
for(p=first;p->value< newval;p=p->next)
Definition: gia.h:75
Bdc_Fun_t * Bdc_ManFunc(Bdc_Man_t *p, int i)
DECLARATIONS ///.
Definition: bdcCore.c:46
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
static void Gia_ObjSetAndLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:506
void Bdc_FuncSetCopyInt(Bdc_Fun_t *p, int iCopy)
Definition: bdcCore.c:55
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nNewSize
Definition: giaShrink6.c:58
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
static int Bdc_FunFanin0Copy(Bdc_Fun_t *pObj)
Definition: bdc.h:85
int Bdc_ManNodeNum(Bdc_Man_t *p)
Definition: bdcCore.c:48
#define assert(ex)
Definition: util_old.h:213
static int Bdc_FunObjCopy(Bdc_Fun_t *pObj)
Definition: bdc.h:84
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388

Variable Documentation

ABC_NAMESPACE_IMPL_START word Truth[8]
static
Initial value:
= {
ABC_CONST(0xAAAAAAAAAAAAAAAA),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0x0000000000000000),
}
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206

DECLARATIONS ///.

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

FileName [giaShrink6.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Implementation of DAG-aware unmapping for 6-input cuts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 32 of file giaShrink6.c.