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

Go to the source code of this file.

Data Structures

struct  Aig_ManPack_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Aig_ManPack_t_ 
Aig_ManPack_t
 DECLARATIONS ///. More...
 

Functions

static int Aig_Word6CountOnes (word t)
 
static int Aig_Word6HasOneBit (word t)
 
Aig_ManPack_tAig_ManPackAlloc (Aig_Man_t *pAig)
 FUNCTION DEFINITIONS ///. More...
 
int Aig_ManPackCountCares (Aig_ManPack_t *p)
 
void Aig_ManPackPrintCare (Aig_ManPack_t *p)
 
void Aig_ManPackFree (Aig_ManPack_t *p)
 
void Aig_ManPackSetRandom (Aig_ManPack_t *p)
 
void Aig_ManPackSimulate (Aig_ManPack_t *p)
 
void Aig_ManPackPrintStats (Aig_ManPack_t *p)
 
Vec_Int_tAig_ManPackConstNodes (Aig_ManPack_t *p)
 
int Aig_ManPackAddPatternTry (Aig_ManPack_t *p, int iBit, Vec_Int_t *vLits)
 
void Aig_ManPackAddPattern (Aig_ManPack_t *p, Vec_Int_t *vLits)
 
Aig_ManPack_tAig_ManPackStart (Aig_Man_t *pAig)
 
void Aig_ManPackStop (Aig_ManPack_t *p)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Aig_ManPack_t_ Aig_ManPack_t

DECLARATIONS ///.

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

FileName [aigPack.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Bit-packing code.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigPack.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

]

Definition at line 31 of file aigPack.c.

Function Documentation

void Aig_ManPackAddPattern ( Aig_ManPack_t p,
Vec_Int_t vLits 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 326 of file aigPack.c.

327 {
328  int k;
329  for ( k = 1; k < 64; k++ )
330  if ( Aig_ManPackAddPatternTry( p, k, vLits ) )
331  break;
332  if ( k == 64 )
333  {
334 /*
335  word * pInfo, * pPres;
336  int i, Lit;
337  Vec_IntForEachEntry( vLits, Lit, i )
338  printf( "%d", Abc_LitIsCompl(Lit) );
339  printf( "\n\n" );
340  for ( k = 1; k < 64; k++ )
341  {
342  Vec_IntForEachEntry( vLits, Lit, i )
343  {
344  pInfo = Vec_WrdEntryP( p->vPiPats, Abc_Lit2Var(Lit) );
345  pPres = Vec_WrdEntryP( p->vPiCare, Abc_Lit2Var(Lit) );
346  if ( Abc_InfoHasBit( (unsigned *)pPres, k ) )
347  printf( "%d", Abc_InfoHasBit( (unsigned *)pInfo, k ) );
348  else
349  printf( "-" );
350  }
351  printf( "\n" );
352  }
353 */
354  p->nPatSkip++;
355  }
356  p->nPatTotal++;
357 }
int nPatTotal
Definition: aigPack.c:41
int nPatSkip
Definition: aigPack.c:42
int Aig_ManPackAddPatternTry(Aig_ManPack_t *p, int iBit, Vec_Int_t *vLits)
Definition: aigPack.c:292
int Aig_ManPackAddPatternTry ( Aig_ManPack_t p,
int  iBit,
Vec_Int_t vLits 
)

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

Synopsis [Packs patterns into array of simulation info.]

Description []

SideEffects []

SeeAlso []

                               ` 

Definition at line 292 of file aigPack.c.

293 {
294  word * pInfo, * pPres;
295  int i, Lit;
296  Vec_IntForEachEntry( vLits, Lit, i )
297  {
298  pInfo = Vec_WrdEntryP( p->vPiPats, Abc_Lit2Var(Lit) );
299  pPres = Vec_WrdEntryP( p->vPiCare, Abc_Lit2Var(Lit) );
300  if ( Abc_InfoHasBit( (unsigned *)pPres, iBit ) &&
301  Abc_InfoHasBit( (unsigned *)pInfo, iBit ) == Abc_LitIsCompl(Lit) )
302  return 0;
303  }
304  Vec_IntForEachEntry( vLits, Lit, i )
305  {
306  pInfo = Vec_WrdEntryP( p->vPiPats, Abc_Lit2Var(Lit) );
307  pPres = Vec_WrdEntryP( p->vPiCare, Abc_Lit2Var(Lit) );
308  Abc_InfoSetBit( (unsigned *)pPres, iBit );
309  if ( Abc_InfoHasBit( (unsigned *)pInfo, iBit ) == Abc_LitIsCompl(Lit) )
310  Abc_InfoXorBit( (unsigned *)pInfo, iBit );
311  }
312  return 1;
313 }
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
static void Abc_InfoXorBit(unsigned *p, int i)
Definition: abc_global.h:260
Vec_Wrd_t * vPiCare
Definition: aigPack.c:37
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Vec_Wrd_t * vPiPats
Definition: aigPack.c:36
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:401
Aig_ManPack_t* Aig_ManPackAlloc ( Aig_Man_t pAig)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file aigPack.c.

66 {
67  Aig_ManPack_t * p;
68  p = ABC_CALLOC( Aig_ManPack_t, 1 );
69  p->pAig = pAig;
70  p->vSigns = Vec_WrdStart( Aig_ManObjNumMax(pAig) );
71  p->vPiPats = Vec_WrdStart( Aig_ManCiNum(pAig) );
72  p->vPiCare = Vec_WrdStart( Aig_ManCiNum(pAig) );
73  p->iPatCur = 1;
74  return p;
75 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Wrd_t * vPiCare
Definition: aigPack.c:37
Aig_Man_t * pAig
Definition: aigPack.c:34
Vec_Wrd_t * vSigns
Definition: aigPack.c:35
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Wrd_t * vPiPats
Definition: aigPack.c:36
Vec_Int_t* Aig_ManPackConstNodes ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file aigPack.c.

265 {
266  Vec_Int_t * vNodes;
267  Aig_Obj_t * pObj;
268  word Sign;
269  int i;
270  vNodes = Vec_IntAlloc( 1000 );
271  Aig_ManForEachNode( p->pAig, pObj, i )
272  {
273  Sign = Vec_WrdEntry( p->vSigns, Aig_ObjId(pObj) );
274  if ( Sign == 0 || ~Sign == 0 || Aig_Word6HasOneBit(Sign) || Aig_Word6HasOneBit(~Sign) )
275  Vec_IntPush( vNodes, Aig_ObjId(pObj) );
276  }
277  return vNodes;
278 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Aig_Man_t * pAig
Definition: aigPack.c:34
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Wrd_t * vSigns
Definition: aigPack.c:35
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Aig_Word6HasOneBit(word t)
Definition: aigPack.c:47
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
int Aig_ManPackCountCares ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file aigPack.c.

89 {
90  Aig_Obj_t * pObj;
91  int i, Total = 0;
92  Aig_ManForEachCi( p->pAig, pObj, i )
93  Total += Aig_Word6CountOnes( Vec_WrdEntry(p->vPiCare, i) );
94  return Total;
95 }
static int Aig_Word6CountOnes(word t)
Definition: aigPack.c:46
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Man_t * pAig
Definition: aigPack.c:34
Definition: aig.h:69
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
void Aig_ManPackFree ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file aigPack.c.

135 {
136 // Aig_ManPackPrintCare( p );
137  printf( "Patterns: " );
138  printf( "Total = %6d. ", p->nPatTotal );
139  printf( "Skipped = %6d. ", p->nPatSkip );
140  printf( "Cares = %6.2f %% ", 100.0*Aig_ManPackCountCares(p)/Aig_ManCiNum(p->pAig)/64 );
141  printf( "\n" );
142  Vec_WrdFree( p->vSigns );
143  Vec_WrdFree( p->vPiPats );
144  Vec_WrdFree( p->vPiCare );
145  ABC_FREE( p );
146 }
int Aig_ManPackCountCares(Aig_ManPack_t *p)
Definition: aigPack.c:88
int nPatTotal
Definition: aigPack.c:41
Vec_Wrd_t * vPiCare
Definition: aigPack.c:37
Aig_Man_t * pAig
Definition: aigPack.c:34
int nPatSkip
Definition: aigPack.c:42
Vec_Wrd_t * vSigns
Definition: aigPack.c:35
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Wrd_t * vPiPats
Definition: aigPack.c:36
void Aig_ManPackPrintCare ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file aigPack.c.

109 {
110  Aig_Obj_t * pObj;
111  word Sign;
112  int i;
113  Aig_ManForEachCi( p->pAig, pObj, i )
114  {
115  Sign = Vec_WrdEntry( p->vPiCare, i );
116 // Extra_PrintBinary( stdout, (unsigned *)&Sign, 64 );
117 // printf( "\n" );
118  }
119 // printf( "\n" );
120 }
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Vec_Wrd_t * vPiCare
Definition: aigPack.c:37
Aig_Man_t * pAig
Definition: aigPack.c:34
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: aig.h:69
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
void Aig_ManPackPrintStats ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 227 of file aigPack.c.

228 {
229  word Sign;
230  Aig_Obj_t * pObj;
231  int i, Total, Count, Counts[33] = {0}; // the number of nodes having that many patterns
232  Aig_ManForEachNode( p->pAig, pObj, i )
233  {
234  Sign = Vec_WrdEntry( p->vSigns, Aig_ObjId(pObj) );
235  Count = Aig_Word6CountOnes( Sign );
236  if ( Count > 32 )
237  Count = 64 - Count;
238  Counts[Count]++;
239  }
240  // print statistics
241  Total = 0;
242  for ( i = 0; i <= 32; i++ )
243  {
244  Total += Counts[i];
245  printf( "%2d : ", i );
246  printf( "%6d ", Counts[i] );
247  printf( "%6.1f %%", 100.0*Counts[i]/Aig_ManNodeNum(p->pAig) );
248  printf( "%6.1f %%", 100.0*Total/Aig_ManNodeNum(p->pAig) );
249  printf( "\n" );
250  }
251 }
static int Aig_Word6CountOnes(word t)
Definition: aigPack.c:46
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Aig_Man_t * pAig
Definition: aigPack.c:34
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Vec_Wrd_t * vSigns
Definition: aigPack.c:35
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: aig.h:69
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
void Aig_ManPackSetRandom ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file aigPack.c.

160 {
161  Aig_Obj_t * pObj;
162  word Sign;
163  int i;
164  Aig_ManForEachCi( p->pAig, pObj, i )
165  {
166  Sign = (((word)Aig_ManRandom(0)) << 32) | ((word)Aig_ManRandom(0));
167  Vec_WrdWriteEntry( p->vPiPats, i, Sign << 1 );
168  }
169 }
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
Aig_Man_t * pAig
Definition: aigPack.c:34
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: aig.h:69
Vec_Wrd_t * vPiPats
Definition: aigPack.c:36
void Aig_ManPackSimulate ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file aigPack.c.

183 {
184  Aig_Obj_t * pObj;
185  word Sign, Sign0, Sign1;
186  int i;
187  // set the constant
188  Vec_WrdWriteEntry( p->vSigns, 0, ~(word)0 );
189  // transfer into the array
190  Aig_ManForEachCi( p->pAig, pObj, i )
191  Vec_WrdWriteEntry( p->vSigns, Aig_ObjId(pObj), Vec_WrdEntry(p->vPiPats, i) );
192  // simulate internal nodes
193  Aig_ManForEachNode( p->pAig, pObj, i )
194  {
195  Sign0 = Vec_WrdEntry( p->vSigns, Aig_ObjFaninId0(pObj) );
196  Sign1 = Vec_WrdEntry( p->vSigns, Aig_ObjFaninId1(pObj) );
197  if ( Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
198  Sign = ~(Sign0 | Sign1);
199  else if ( Aig_ObjFaninC0(pObj) )
200  Sign = ~Sign0 & Sign1;
201  else if ( Aig_ObjFaninC1(pObj) )
202  Sign = Sign0 & ~Sign1;
203  else
204  Sign = Sign0 & Sign1;
205  Vec_WrdWriteEntry( p->vSigns, Aig_ObjId(pObj), Sign );
206  }
207  // set the outputs
208  Aig_ManForEachCo( p->pAig, pObj, i )
209  {
210  Sign0 = Vec_WrdEntry( p->vSigns, Aig_ObjFaninId0(pObj) );
211  Sign = Aig_ObjFaninC0(pObj) ? ~Sign0 : Sign0;
212  Vec_WrdWriteEntry( p->vSigns, Aig_ObjId(pObj), Sign );
213  }
214 }
static int Aig_ObjFaninId0(Aig_Obj_t *pObj)
Definition: aig.h:304
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static int Aig_ObjFaninId1(Aig_Obj_t *pObj)
Definition: aig.h:305
Aig_Man_t * pAig
Definition: aigPack.c:34
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
Vec_Wrd_t * vSigns
Definition: aigPack.c:35
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
Aig_ManPack_t* Aig_ManPackStart ( Aig_Man_t pAig)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 370 of file aigPack.c.

371 {
372  Aig_ManPack_t * p;
373  p = Aig_ManPackAlloc( pAig );
375  Aig_ManPackSimulate( p );
377  return p;
378 }
Aig_ManPack_t * Aig_ManPackAlloc(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: aigPack.c:65
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManPackPrintStats(Aig_ManPack_t *p)
Definition: aigPack.c:227
void Aig_ManPackSetRandom(Aig_ManPack_t *p)
Definition: aigPack.c:159
void Aig_ManPackSimulate(Aig_ManPack_t *p)
Definition: aigPack.c:182
void Aig_ManPackStop ( Aig_ManPack_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 391 of file aigPack.c.

392 {
393  Aig_ManPackSimulate( p );
395  Aig_ManPackFree( p );
396 }
void Aig_ManPackPrintStats(Aig_ManPack_t *p)
Definition: aigPack.c:227
void Aig_ManPackFree(Aig_ManPack_t *p)
Definition: aigPack.c:134
void Aig_ManPackSimulate(Aig_ManPack_t *p)
Definition: aigPack.c:182
static int Aig_Word6CountOnes ( word  t)
inlinestatic

Definition at line 46 of file aigPack.c.

46 { return Aig_WordCountOnes( (unsigned)(t >> 32) ) + Aig_WordCountOnes( (unsigned)(t & 0xFFFFFFFF) ); }
static int Aig_WordCountOnes(unsigned uWord)
Definition: aig.h:229
static int Aig_Word6HasOneBit ( word  t)
inlinestatic

Definition at line 47 of file aigPack.c.

47 { return (t & (t-1)) == 0; }