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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
unsigned long 
Hop_Hash (Hop_Obj_t *pObj, int TableSize)
 DECLARATIONS ///. More...
 
static Hop_Obj_t ** Hop_TableFind (Hop_Man_t *p, Hop_Obj_t *pObj)
 
static void Hop_TableResize (Hop_Man_t *p)
 
Hop_Obj_tHop_TableLookup (Hop_Man_t *p, Hop_Obj_t *pGhost)
 FUNCTION DEFINITIONS ///. More...
 
void Hop_TableInsert (Hop_Man_t *p, Hop_Obj_t *pObj)
 
void Hop_TableDelete (Hop_Man_t *p, Hop_Obj_t *pObj)
 
int Hop_TableCountEntries (Hop_Man_t *p)
 
void Hop_TableProfile (Hop_Man_t *p)
 

Function Documentation

static ABC_NAMESPACE_IMPL_START unsigned long Hop_Hash ( Hop_Obj_t pObj,
int  TableSize 
)
static

DECLARATIONS ///.

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

FileName [hopTable.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Minimalistic And-Inverter Graph package.]

Synopsis [Structural hashing table.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006. ]

Revision [

Id:
hopTable.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

]

Definition at line 31 of file hopTable.c.

32 {
33  unsigned long Key = Hop_ObjIsExor(pObj) * 1699;
34  Key ^= Hop_ObjFanin0(pObj)->Id * 7937;
35  Key ^= Hop_ObjFanin1(pObj)->Id * 2971;
36  Key ^= Hop_ObjFaninC0(pObj) * 911;
37  Key ^= Hop_ObjFaninC1(pObj) * 353;
38  return Key % TableSize;
39 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
int Id
Definition: hop.h:80
static int Hop_ObjFaninC1(Hop_Obj_t *pObj)
Definition: hop.h:181
static int Hop_ObjIsExor(Hop_Obj_t *pObj)
Definition: hop.h:159
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjFaninC0(Hop_Obj_t *pObj)
Definition: hop.h:180
int Hop_TableCountEntries ( Hop_Man_t p)

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

Synopsis [Count the number of nodes in the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file hopTable.c.

146 {
147  Hop_Obj_t * pEntry;
148  int i, Counter = 0;
149  for ( i = 0; i < p->nTableSize; i++ )
150  for ( pEntry = p->pTable[i]; pEntry; pEntry = pEntry->pNext )
151  Counter++;
152  return Counter;
153 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static int Counter
Hop_Obj_t * pNext
Definition: hop.h:71
void Hop_TableDelete ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Deletes the node from the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file hopTable.c.

124 {
125  Hop_Obj_t ** ppPlace;
126  assert( !Hop_IsComplement(pObj) );
127  ppPlace = Hop_TableFind( p, pObj );
128  assert( *ppPlace == pObj ); // node should be in the table
129  // remove the node
130  *ppPlace = pObj->pNext;
131  pObj->pNext = NULL;
132 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static Hop_Obj_t ** Hop_TableFind(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:42
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
Hop_Obj_t * pNext
Definition: hop.h:71
#define assert(ex)
Definition: util_old.h:213
static Hop_Obj_t** Hop_TableFind ( Hop_Man_t p,
Hop_Obj_t pObj 
)
static

Definition at line 42 of file hopTable.c.

43 {
44  Hop_Obj_t ** ppEntry;
45  assert( Hop_ObjChild0(pObj) && Hop_ObjChild1(pObj) );
46  assert( Hop_ObjFanin0(pObj)->Id < Hop_ObjFanin1(pObj)->Id );
47  for ( ppEntry = p->pTable + Hop_Hash(pObj, p->nTableSize); *ppEntry; ppEntry = &(*ppEntry)->pNext )
48  if ( *ppEntry == pObj )
49  return ppEntry;
50  assert( *ppEntry == NULL );
51  return ppEntry;
52 }
static Hop_Obj_t * Hop_ObjChild0(Hop_Obj_t *pObj)
Definition: hop.h:184
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static ABC_NAMESPACE_IMPL_START unsigned long Hop_Hash(Hop_Obj_t *pObj, int TableSize)
DECLARATIONS ///.
Definition: hopTable.c:31
static Hop_Obj_t * Hop_ObjChild1(Hop_Obj_t *pObj)
Definition: hop.h:185
Hop_Obj_t * pNext
Definition: hop.h:71
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define assert(ex)
Definition: util_old.h:213
void Hop_TableInsert ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Adds the new node to the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file hopTable.c.

101 {
102  Hop_Obj_t ** ppPlace;
103  assert( !Hop_IsComplement(pObj) );
104  assert( Hop_TableLookup(p, pObj) == NULL );
105  if ( (pObj->Id & 0xFF) == 0 && 2 * p->nTableSize < Hop_ManNodeNum(p) )
106  Hop_TableResize( p );
107  ppPlace = Hop_TableFind( p, pObj );
108  assert( *ppPlace == NULL );
109  *ppPlace = pObj;
110 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: hop.h:80
static void Hop_TableResize(Hop_Man_t *p)
Definition: hopTable.c:166
Definition: hop.h:65
Hop_Obj_t * Hop_TableLookup(Hop_Man_t *p, Hop_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition: hopTable.c:71
static Hop_Obj_t ** Hop_TableFind(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:42
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
#define assert(ex)
Definition: util_old.h:213
static int Hop_ManNodeNum(Hop_Man_t *p)
Definition: hop.h:149
Hop_Obj_t* Hop_TableLookup ( Hop_Man_t p,
Hop_Obj_t pGhost 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Checks if a node with the given attributes is in the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file hopTable.c.

72 {
73  Hop_Obj_t * pEntry;
74  assert( !Hop_IsComplement(pGhost) );
75  assert( Hop_ObjChild0(pGhost) && Hop_ObjChild1(pGhost) );
76  assert( Hop_ObjFanin0(pGhost)->Id < Hop_ObjFanin1(pGhost)->Id );
77  if ( p->fRefCount && (!Hop_ObjRefs(Hop_ObjFanin0(pGhost)) || !Hop_ObjRefs(Hop_ObjFanin1(pGhost))) )
78  return NULL;
79  for ( pEntry = p->pTable[Hop_Hash(pGhost, p->nTableSize)]; pEntry; pEntry = pEntry->pNext )
80  {
81  if ( Hop_ObjChild0(pEntry) == Hop_ObjChild0(pGhost) &&
82  Hop_ObjChild1(pEntry) == Hop_ObjChild1(pGhost) &&
83  Hop_ObjType(pEntry) == Hop_ObjType(pGhost) )
84  return pEntry;
85  }
86  return NULL;
87 }
static Hop_Obj_t * Hop_ObjChild0(Hop_Obj_t *pObj)
Definition: hop.h:184
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Hop_Type_t Hop_ObjType(Hop_Obj_t *pObj)
Definition: hop.h:153
Definition: hop.h:65
static ABC_NAMESPACE_IMPL_START unsigned long Hop_Hash(Hop_Obj_t *pObj, int TableSize)
DECLARATIONS ///.
Definition: hopTable.c:31
static Hop_Obj_t * Hop_ObjChild1(Hop_Obj_t *pObj)
Definition: hop.h:185
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
Hop_Obj_t * pNext
Definition: hop.h:71
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define assert(ex)
Definition: util_old.h:213
void Hop_TableProfile ( Hop_Man_t p)

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

Synopsis [Profiles the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file hopTable.c.

213 {
214  Hop_Obj_t * pEntry;
215  int i, Counter;
216  for ( i = 0; i < p->nTableSize; i++ )
217  {
218  Counter = 0;
219  for ( pEntry = p->pTable[i]; pEntry; pEntry = pEntry->pNext )
220  Counter++;
221  if ( Counter )
222  printf( "%d ", Counter );
223  }
224 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: hop.h:65
static int Counter
Hop_Obj_t * pNext
Definition: hop.h:71
void Hop_TableResize ( Hop_Man_t p)
static

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

Synopsis [Resizes the table.]

Description [Typically this procedure should not be called.]

SideEffects []

SeeAlso []

Definition at line 166 of file hopTable.c.

167 {
168  Hop_Obj_t * pEntry, * pNext;
169  Hop_Obj_t ** pTableOld, ** ppPlace;
170  int nTableSizeOld, Counter, nEntries, i;
171  abctime clk;
172 clk = Abc_Clock();
173  // save the old table
174  pTableOld = p->pTable;
175  nTableSizeOld = p->nTableSize;
176  // get the new table
177  p->nTableSize = Abc_PrimeCudd( 2 * Hop_ManNodeNum(p) );
178  p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize );
179  memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
180  // rehash the entries from the old table
181  Counter = 0;
182  for ( i = 0; i < nTableSizeOld; i++ )
183  for ( pEntry = pTableOld[i], pNext = pEntry? pEntry->pNext : NULL; pEntry; pEntry = pNext, pNext = pEntry? pEntry->pNext : NULL )
184  {
185  // get the place where this entry goes in the table
186  ppPlace = Hop_TableFind( p, pEntry );
187  assert( *ppPlace == NULL ); // should not be there
188  // add the entry to the list
189  *ppPlace = pEntry;
190  pEntry->pNext = NULL;
191  Counter++;
192  }
193  nEntries = Hop_ManNodeNum(p);
194  assert( Counter == nEntries );
195 // printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
196 // ABC_PRT( "Time", Abc_Clock() - clk );
197  // replace the table and the parameters
198  ABC_FREE( pTableOld );
199 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: hop.h:65
static Hop_Obj_t ** Hop_TableFind(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:42
static int Counter
Hop_Obj_t * pNext
Definition: hop.h:71
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Hop_ManNodeNum(Hop_Man_t *p)
Definition: hop.h:149