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

Go to the source code of this file.

Functions

Vec_Ptr_tSim_UtilInfoAlloc (int nSize, int nWords, int fClean)
 FUNCTION DEFINITIONS ///. More...
 
void Sim_UtilInfoFree (Vec_Ptr_t *p)
 
void Sim_UtilInfoAdd (unsigned *pInfo1, unsigned *pInfo2, int nWords)
 
void Sim_UtilInfoDetectDiffs (unsigned *pInfo1, unsigned *pInfo2, int nWords, Vec_Int_t *vDiffs)
 
void Sim_UtilInfoDetectNews (unsigned *pInfo1, unsigned *pInfo2, int nWords, Vec_Int_t *vDiffs)
 
void Sim_UtilInfoFlip (Sim_Man_t *p, Abc_Obj_t *pNode)
 
int Sim_UtilInfoCompare (Sim_Man_t *p, Abc_Obj_t *pNode)
 
void Sim_UtilSimulate (Sim_Man_t *p, int fType)
 
void Sim_UtilSimulateNode (Sim_Man_t *p, Abc_Obj_t *pNode, int fType, int fType1, int fType2)
 
void Sim_UtilSimulateNodeOne (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset)
 
void Sim_UtilTransferNodeOne (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset, int fShift)
 
int Sim_UtilCountSuppSizes (Sim_Man_t *p, int fStruct)
 
int Sim_UtilCountOnes (unsigned *pSimInfo, int nSimWords)
 
Vec_Int_tSim_UtilCountOnesArray (Vec_Ptr_t *vInfo, int nSimWords)
 
void Sim_UtilSetRandom (unsigned *pPatRand, int nSimWords)
 
void Sim_UtilSetCompl (unsigned *pPatRand, int nSimWords)
 
void Sim_UtilSetConst (unsigned *pPatRand, int nSimWords, int fConst1)
 
int Sim_UtilInfoIsEqual (unsigned *pPats1, unsigned *pPats2, int nSimWords)
 
int Sim_UtilInfoIsImp (unsigned *pPats1, unsigned *pPats2, int nSimWords)
 
int Sim_UtilInfoIsClause (unsigned *pPats1, unsigned *pPats2, int nSimWords)
 
int Sim_UtilCountAllPairs (Vec_Ptr_t *vSuppFun, int nSimWords, Vec_Int_t *vCounters)
 
int Sim_UtilCountPairsOne (Extra_BitMat_t *pMat, Vec_Int_t *vSupport)
 
int Sim_UtilCountPairsOnePrint (Extra_BitMat_t *pMat, Vec_Int_t *vSupport)
 
void Sim_UtilCountPairsAllPrint (Sym_Man_t *p)
 
void Sim_UtilCountPairsAll (Sym_Man_t *p)
 
int Sim_UtilMatrsAreDisjoint (Sym_Man_t *p)
 

Variables

static ABC_NAMESPACE_IMPL_START int bit_count [256]
 DECLARATIONS ///. More...
 

Function Documentation

int Sim_UtilCountAllPairs ( Vec_Ptr_t vSuppFun,
int  nSimWords,
Vec_Int_t vCounters 
)

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

Synopsis [Counts the total number of pairs.]

Description []

SideEffects []

SeeAlso []

Definition at line 563 of file simUtils.c.

564 {
565  unsigned * pSupp;
566  int Counter, nOnes, nPairs, i;
567  Counter = 0;
568  Vec_PtrForEachEntry( unsigned *, vSuppFun, pSupp, i )
569  {
570  nOnes = Sim_UtilCountOnes( pSupp, nSimWords );
571  nPairs = nOnes * (nOnes - 1) / 2;
572  Vec_IntWriteEntry( vCounters, i, nPairs );
573  Counter += nPairs;
574  }
575  return Counter;
576 }
int Sim_UtilCountOnes(unsigned *pSimInfo, int nSimWords)
Definition: simUtils.c:402
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Counter
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Sim_UtilCountOnes ( unsigned *  pSimInfo,
int  nSimWords 
)

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

Synopsis [Counts the number of 1's in the bitstring.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file simUtils.c.

403 {
404  unsigned char * pBytes;
405  int nOnes, nBytes, i;
406  pBytes = (unsigned char *)pSimInfo;
407  nBytes = 4 * nSimWords;
408  nOnes = 0;
409  for ( i = 0; i < nBytes; i++ )
410  nOnes += bit_count[ pBytes[i] ];
411  return nOnes;
412 }
static ABC_NAMESPACE_IMPL_START int bit_count[256]
DECLARATIONS ///.
Definition: simUtils.c:31
Vec_Int_t* Sim_UtilCountOnesArray ( Vec_Ptr_t vInfo,
int  nSimWords 
)

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

Synopsis [Counts the number of 1's in the bitstring.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file simUtils.c.

426 {
427  Vec_Int_t * vCounters;
428  unsigned * pSimInfo;
429  int i;
430  vCounters = Vec_IntStart( Vec_PtrSize(vInfo) );
431  Vec_PtrForEachEntry( unsigned *, vInfo, pSimInfo, i )
432  Vec_IntWriteEntry( vCounters, i, Sim_UtilCountOnes(pSimInfo, nSimWords) );
433  return vCounters;
434 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Sim_UtilCountOnes(unsigned *pSimInfo, int nSimWords)
Definition: simUtils.c:402
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Sim_UtilCountPairsAll ( Sym_Man_t p)

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

Synopsis [Counts the number of entries in the array of matrices.]

Description []

SideEffects []

SeeAlso []

Definition at line 659 of file simUtils.c.

660 {
661  int nPairsTotal, nPairsSym, nPairsNonSym, i;
662  abctime clk;
663 clk = Abc_Clock();
664  p->nPairsSymm = 0;
665  p->nPairsNonSymm = 0;
666  for ( i = 0; i < p->nOutputs; i++ )
667  {
668  nPairsTotal = Vec_IntEntry(p->vPairsTotal, i);
669  nPairsSym = Vec_IntEntry(p->vPairsSym, i);
670  nPairsNonSym = Vec_IntEntry(p->vPairsNonSym,i);
671  assert( nPairsTotal >= nPairsSym + nPairsNonSym );
672  if ( nPairsTotal == nPairsSym + nPairsNonSym )
673  {
674  p->nPairsSymm += nPairsSym;
675  p->nPairsNonSymm += nPairsNonSym;
676  continue;
677  }
678  nPairsSym = Sim_UtilCountPairsOne( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms, i), Vec_VecEntryInt(p->vSupports, i) );
679  nPairsNonSym = Sim_UtilCountPairsOne( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrNonSymms,i), Vec_VecEntryInt(p->vSupports, i) );
680  assert( nPairsTotal >= nPairsSym + nPairsNonSym );
681  Vec_IntWriteEntry( p->vPairsSym, i, nPairsSym );
682  Vec_IntWriteEntry( p->vPairsNonSym, i, nPairsNonSym );
683  p->nPairsSymm += nPairsSym;
684  p->nPairsNonSymm += nPairsNonSym;
685 // printf( "%d ", nPairsTotal - nPairsSym - nPairsNonSym );
686  }
687 //printf( "\n" );
688  p->nPairsRem = p->nPairsTotal-p->nPairsSymm-p->nPairsNonSymm;
689 p->timeCount += Abc_Clock() - clk;
690 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static abctime Abc_Clock()
Definition: abc_global.h:279
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
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
Definition: vecVec.h:276
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int Sim_UtilCountPairsOne(Extra_BitMat_t *pMat, Vec_Int_t *vSupport)
Definition: simUtils.c:589
void Sim_UtilCountPairsAllPrint ( Sym_Man_t p)

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

Synopsis [Counts the number of entries in the array of matrices.]

Description []

SideEffects []

SeeAlso []

Definition at line 634 of file simUtils.c.

635 {
636  int i;
637  abctime clk;
638 clk = Abc_Clock();
639  for ( i = 0; i < p->nOutputs; i++ )
640  {
641  printf( "Output %2d :", i );
642  Sim_UtilCountPairsOnePrint( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms, i), Vec_VecEntryInt(p->vSupports, i) );
643  printf( "\n" );
644  }
645 p->timeCount += Abc_Clock() - clk;
646 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static abctime Abc_Clock()
Definition: abc_global.h:279
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
Definition: vecVec.h:276
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
ABC_INT64_T abctime
Definition: abc_global.h:278
int Sim_UtilCountPairsOnePrint(Extra_BitMat_t *pMat, Vec_Int_t *vSupport)
Definition: simUtils.c:613
int Sim_UtilCountPairsOne ( Extra_BitMat_t pMat,
Vec_Int_t vSupport 
)

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

Synopsis [Counts the number of entries in the array of matrices.]

Description []

SideEffects []

SeeAlso []

Definition at line 589 of file simUtils.c.

590 {
591  int i, k, Index1, Index2;
592  int Counter = 0;
593 // int Counter2;
594  Vec_IntForEachEntry( vSupport, i, Index1 )
595  Vec_IntForEachEntryStart( vSupport, k, Index2, Index1+1 )
596  Counter += Extra_BitMatrixLookup1( pMat, i, k );
597 // Counter2 = Extra_BitMatrixCountOnesUpper(pMat);
598 // assert( Counter == Counter2 );
599  return Counter;
600 }
int Extra_BitMatrixLookup1(Extra_BitMat_t *p, int i, int k)
static int Counter
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Sim_UtilCountPairsOnePrint ( Extra_BitMat_t pMat,
Vec_Int_t vSupport 
)

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

Synopsis [Counts the number of entries in the array of matrices.]

Description []

SideEffects []

SeeAlso []

Definition at line 613 of file simUtils.c.

614 {
615  int i, k, Index1, Index2;
616  Vec_IntForEachEntry( vSupport, i, Index1 )
617  Vec_IntForEachEntryStart( vSupport, k, Index2, Index1+1 )
618  if ( Extra_BitMatrixLookup1( pMat, i, k ) )
619  printf( "(%d,%d) ", i, k );
620  return 0;
621 }
int Extra_BitMatrixLookup1(Extra_BitMat_t *p, int i, int k)
if(last==0)
Definition: sparse_int.h:34
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Sim_UtilCountSuppSizes ( Sim_Man_t p,
int  fStruct 
)

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

Synopsis [Returns 1 if the simulation infos are equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 371 of file simUtils.c.

372 {
373  Abc_Obj_t * pNode, * pNodeCi;
374  int i, v, Counter;
375  Counter = 0;
376  if ( fStruct )
377  {
378  Abc_NtkForEachCo( p->pNtk, pNode, i )
379  Abc_NtkForEachCi( p->pNtk, pNodeCi, v )
380  Counter += Sim_SuppStrHasVar( p->vSuppStr, pNode, v );
381  }
382  else
383  {
384  Abc_NtkForEachCo( p->pNtk, pNode, i )
385  Abc_NtkForEachCi( p->pNtk, pNodeCi, v )
386  Counter += Sim_SuppFunHasVar( p->vSuppFun, i, v );
387  }
388  return Counter;
389 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
else
Definition: sparse_int.h:55
static int Counter
#define Sim_SuppStrHasVar(vSupps, pNode, v)
Definition: sim.h:167
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Abc_Ntk_t * pNtk
Definition: sim.h:104
#define Sim_SuppFunHasVar(vSupps, Output, v)
Definition: sim.h:169
void Sim_UtilInfoAdd ( unsigned *  pInfo1,
unsigned *  pInfo2,
int  nWords 
)

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

Synopsis [Adds the second supp-info the first.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file simUtils.c.

101 {
102  int w;
103  for ( w = 0; w < nWords; w++ )
104  pInfo1[w] |= pInfo2[w];
105 }
int nWords
Definition: abcNpn.c:127
Vec_Ptr_t* Sim_UtilInfoAlloc ( int  nSize,
int  nWords,
int  fClean 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates simulation information for all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 57 of file simUtils.c.

58 {
59  Vec_Ptr_t * vInfo;
60  int i;
61  assert( nSize > 0 && nWords > 0 );
62  vInfo = Vec_PtrAlloc( nSize );
63  vInfo->pArray[0] = ABC_ALLOC( unsigned, nSize * nWords );
64  if ( fClean )
65  memset( vInfo->pArray[0], 0, sizeof(unsigned) * nSize * nWords );
66  for ( i = 1; i < nSize; i++ )
67  vInfo->pArray[i] = ((unsigned *)vInfo->pArray[i-1]) + nWords;
68  vInfo->nSize = nSize;
69  return vInfo;
70 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nWords
Definition: abcNpn.c:127
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
int Sim_UtilInfoCompare ( Sim_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Returns 1 if the simulation infos are equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file simUtils.c.

186 {
187  unsigned * pSimInfo1, * pSimInfo2;
188  int k;
189  pSimInfo1 = (unsigned *)p->vSim0->pArray[pNode->Id];
190  pSimInfo2 = (unsigned *)p->vSim1->pArray[pNode->Id];
191  for ( k = 0; k < p->nSimWords; k++ )
192  if ( pSimInfo2[k] != pSimInfo1[k] )
193  return 0;
194  return 1;
195 }
int nSimWords
Definition: sim.h:110
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
int Id
Definition: abc.h:132
void Sim_UtilInfoDetectDiffs ( unsigned *  pInfo1,
unsigned *  pInfo2,
int  nWords,
Vec_Int_t vDiffs 
)

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

Synopsis [Returns the positions where pInfo2 is 1 while pInfo1 is 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file simUtils.c.

119 {
120  int w, b;
121  unsigned uMask;
122  vDiffs->nSize = 0;
123  for ( w = 0; w < nWords; w++ )
124  if ( (uMask = (pInfo2[w] ^ pInfo1[w])) )
125  for ( b = 0; b < 32; b++ )
126  if ( uMask & (1 << b) )
127  Vec_IntPush( vDiffs, 32*w + b );
128 }
int nWords
Definition: abcNpn.c:127
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Sim_UtilInfoDetectNews ( unsigned *  pInfo1,
unsigned *  pInfo2,
int  nWords,
Vec_Int_t vDiffs 
)

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

Synopsis [Returns the positions where pInfo2 is 1 while pInfo1 is 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 141 of file simUtils.c.

142 {
143  int w, b;
144  unsigned uMask;
145  vDiffs->nSize = 0;
146  for ( w = 0; w < nWords; w++ )
147  if ( (uMask = (pInfo2[w] & ~pInfo1[w])) )
148  for ( b = 0; b < 32; b++ )
149  if ( uMask & (1 << b) )
150  Vec_IntPush( vDiffs, 32*w + b );
151 }
int nWords
Definition: abcNpn.c:127
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Sim_UtilInfoFlip ( Sim_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Flips the simulation info of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file simUtils.c.

165 {
166  unsigned * pSimInfo1, * pSimInfo2;
167  int k;
168  pSimInfo1 = (unsigned *)p->vSim0->pArray[pNode->Id];
169  pSimInfo2 = (unsigned *)p->vSim1->pArray[pNode->Id];
170  for ( k = 0; k < p->nSimWords; k++ )
171  pSimInfo2[k] = ~pSimInfo1[k];
172 }
int nSimWords
Definition: sim.h:110
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
int Id
Definition: abc.h:132
void Sim_UtilInfoFree ( Vec_Ptr_t p)

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

Synopsis [Allocates simulation information for all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file simUtils.c.

84 {
85  ABC_FREE( p->pArray[0] );
86  Vec_PtrFree( p );
87 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Sim_UtilInfoIsClause ( unsigned *  pPats1,
unsigned *  pPats2,
int  nSimWords 
)

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

Synopsis [Returns 1 if Node1 v Node2 is always true.]

Description []

SideEffects []

SeeAlso []

Definition at line 543 of file simUtils.c.

544 {
545  int k;
546  for ( k = 0; k < nSimWords; k++ )
547  if ( ~pPats1[k] & ~pPats2[k] )
548  return 0;
549  return 1;
550 }
int Sim_UtilInfoIsEqual ( unsigned *  pPats1,
unsigned *  pPats2,
int  nSimWords 
)

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

Synopsis [Returns 1 if equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 503 of file simUtils.c.

504 {
505  int k;
506  for ( k = 0; k < nSimWords; k++ )
507  if ( pPats1[k] != pPats2[k] )
508  return 0;
509  return 1;
510 }
int Sim_UtilInfoIsImp ( unsigned *  pPats1,
unsigned *  pPats2,
int  nSimWords 
)

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

Synopsis [Returns 1 if Node1 implies Node2.]

Description []

SideEffects []

SeeAlso []

Definition at line 523 of file simUtils.c.

524 {
525  int k;
526  for ( k = 0; k < nSimWords; k++ )
527  if ( pPats1[k] & ~pPats2[k] )
528  return 0;
529  return 1;
530 }
int Sim_UtilMatrsAreDisjoint ( Sym_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 703 of file simUtils.c.

704 {
705  int i;
706  for ( i = 0; i < p->nOutputs; i++ )
707  if ( !Extra_BitMatrixIsDisjoint( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms,i), (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrNonSymms,i) ) )
708  return 0;
709  return 1;
710 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Extra_BitMatrixIsDisjoint(Extra_BitMat_t *p1, Extra_BitMat_t *p2)
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
void Sim_UtilSetCompl ( unsigned *  pPatRand,
int  nSimWords 
)

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

Synopsis [Returns complemented patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 465 of file simUtils.c.

466 {
467  int k;
468  for ( k = 0; k < nSimWords; k++ )
469  pPatRand[k] = ~pPatRand[k];
470 }
void Sim_UtilSetConst ( unsigned *  pPatRand,
int  nSimWords,
int  fConst1 
)

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

Synopsis [Returns constant patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 483 of file simUtils.c.

484 {
485  int k;
486  for ( k = 0; k < nSimWords; k++ )
487  pPatRand[k] = 0;
488  if ( fConst1 )
489  Sim_UtilSetCompl( pPatRand, nSimWords );
490 }
void Sim_UtilSetCompl(unsigned *pPatRand, int nSimWords)
Definition: simUtils.c:465
void Sim_UtilSetRandom ( unsigned *  pPatRand,
int  nSimWords 
)

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

Synopsis [Returns random patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 447 of file simUtils.c.

448 {
449  int k;
450  for ( k = 0; k < nSimWords; k++ )
451  pPatRand[k] = SIM_RANDOM_UNSIGNED;
452 }
#define SIM_RANDOM_UNSIGNED
Definition: sim.h:158
void Sim_UtilSimulate ( Sim_Man_t p,
int  fType 
)

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

Synopsis [Simulates the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file simUtils.c.

209 {
210  Abc_Obj_t * pNode;
211  int i;
212  // simulate the internal nodes
213  Abc_NtkForEachNode( p->pNtk, pNode, i )
214  Sim_UtilSimulateNode( p, pNode, fType, fType, fType );
215  // assign simulation info of the CO nodes
216  Abc_NtkForEachCo( p->pNtk, pNode, i )
217  Sim_UtilSimulateNode( p, pNode, fType, fType, fType );
218 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
void Sim_UtilSimulateNode(Sim_Man_t *p, Abc_Obj_t *pNode, int fType, int fType1, int fType2)
Definition: simUtils.c:231
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
Abc_Ntk_t * pNtk
Definition: sim.h:104
void Sim_UtilSimulateNode ( Sim_Man_t p,
Abc_Obj_t pNode,
int  fType,
int  fType1,
int  fType2 
)

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file simUtils.c.

232 {
233  unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
234  int k, fComp1, fComp2;
235  // simulate the internal nodes
236  if ( Abc_ObjIsNode(pNode) )
237  {
238  if ( fType )
239  pSimmNode = (unsigned *)p->vSim1->pArray[ pNode->Id ];
240  else
241  pSimmNode = (unsigned *)p->vSim0->pArray[ pNode->Id ];
242 
243  if ( fType1 )
244  pSimmNode1 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
245  else
246  pSimmNode1 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
247 
248  if ( fType2 )
249  pSimmNode2 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId1(pNode) ];
250  else
251  pSimmNode2 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId1(pNode) ];
252 
253  fComp1 = Abc_ObjFaninC0(pNode);
254  fComp2 = Abc_ObjFaninC1(pNode);
255  if ( fComp1 && fComp2 )
256  for ( k = 0; k < p->nSimWords; k++ )
257  pSimmNode[k] = ~pSimmNode1[k] & ~pSimmNode2[k];
258  else if ( fComp1 && !fComp2 )
259  for ( k = 0; k < p->nSimWords; k++ )
260  pSimmNode[k] = ~pSimmNode1[k] & pSimmNode2[k];
261  else if ( !fComp1 && fComp2 )
262  for ( k = 0; k < p->nSimWords; k++ )
263  pSimmNode[k] = pSimmNode1[k] & ~pSimmNode2[k];
264  else // if ( fComp1 && fComp2 )
265  for ( k = 0; k < p->nSimWords; k++ )
266  pSimmNode[k] = pSimmNode1[k] & pSimmNode2[k];
267  }
268  else
269  {
270  assert( Abc_ObjFaninNum(pNode) == 1 );
271  if ( fType )
272  pSimmNode = (unsigned *)p->vSim1->pArray[ pNode->Id ];
273  else
274  pSimmNode = (unsigned *)p->vSim0->pArray[ pNode->Id ];
275 
276  if ( fType1 )
277  pSimmNode1 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
278  else
279  pSimmNode1 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
280 
281  fComp1 = Abc_ObjFaninC0(pNode);
282  if ( fComp1 )
283  for ( k = 0; k < p->nSimWords; k++ )
284  pSimmNode[k] = ~pSimmNode1[k];
285  else
286  for ( k = 0; k < p->nSimWords; k++ )
287  pSimmNode[k] = pSimmNode1[k];
288  }
289 }
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
int nSimWords
Definition: sim.h:110
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
void Sim_UtilSimulateNodeOne ( Abc_Obj_t pNode,
Vec_Ptr_t vSimInfo,
int  nSimWords,
int  nOffset 
)

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 302 of file simUtils.c.

303 {
304  unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
305  int k, fComp1, fComp2;
306  // simulate the internal nodes
307  assert( Abc_ObjIsNode(pNode) );
308  pSimmNode = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
309  pSimmNode1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
310  pSimmNode2 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
311  pSimmNode += nOffset;
312  pSimmNode1 += nOffset;
313  pSimmNode2 += nOffset;
314  fComp1 = Abc_ObjFaninC0(pNode);
315  fComp2 = Abc_ObjFaninC1(pNode);
316  if ( fComp1 && fComp2 )
317  for ( k = 0; k < nSimWords; k++ )
318  pSimmNode[k] = ~pSimmNode1[k] & ~pSimmNode2[k];
319  else if ( fComp1 && !fComp2 )
320  for ( k = 0; k < nSimWords; k++ )
321  pSimmNode[k] = ~pSimmNode1[k] & pSimmNode2[k];
322  else if ( !fComp1 && fComp2 )
323  for ( k = 0; k < nSimWords; k++ )
324  pSimmNode[k] = pSimmNode1[k] & ~pSimmNode2[k];
325  else // if ( fComp1 && fComp2 )
326  for ( k = 0; k < nSimWords; k++ )
327  pSimmNode[k] = pSimmNode1[k] & pSimmNode2[k];
328 }
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
void Sim_UtilTransferNodeOne ( Abc_Obj_t pNode,
Vec_Ptr_t vSimInfo,
int  nSimWords,
int  nOffset,
int  fShift 
)

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 341 of file simUtils.c.

342 {
343  unsigned * pSimmNode, * pSimmNode1;
344  int k, fComp1;
345  // simulate the internal nodes
346  assert( Abc_ObjIsCo(pNode) );
347  pSimmNode = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
348  pSimmNode1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
349  pSimmNode += nOffset + (fShift > 0)*nSimWords;
350  pSimmNode1 += nOffset;
351  fComp1 = Abc_ObjFaninC0(pNode);
352  if ( fComp1 )
353  for ( k = 0; k < nSimWords; k++ )
354  pSimmNode[k] = ~pSimmNode1[k];
355  else
356  for ( k = 0; k < nSimWords; k++ )
357  pSimmNode[k] = pSimmNode1[k];
358 }
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213

Variable Documentation

ABC_NAMESPACE_IMPL_START int bit_count[256]
static
Initial value:
= {
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
}

DECLARATIONS ///.

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

FileName [simUtils.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Various simulation utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file simUtils.c.