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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Map_NodeVecCompareLevels (Map_Node_t **pp1, Map_Node_t **pp2)
 DECLARATIONS ///. More...
 
Map_NodeVec_tMap_NodeVecAlloc (int nCap)
 FUNCTION DEFINITIONS ///. More...
 
void Map_NodeVecFree (Map_NodeVec_t *p)
 
Map_NodeVec_tMap_NodeVecDup (Map_NodeVec_t *p)
 
Map_Node_t ** Map_NodeVecReadArray (Map_NodeVec_t *p)
 
int Map_NodeVecReadSize (Map_NodeVec_t *p)
 
void Map_NodeVecGrow (Map_NodeVec_t *p, int nCapMin)
 
void Map_NodeVecShrink (Map_NodeVec_t *p, int nSizeNew)
 
void Map_NodeVecClear (Map_NodeVec_t *p)
 
void Map_NodeVecPush (Map_NodeVec_t *p, Map_Node_t *Entry)
 
int Map_NodeVecPushUnique (Map_NodeVec_t *p, Map_Node_t *Entry)
 
Map_Node_tMap_NodeVecPop (Map_NodeVec_t *p)
 
void Map_NodeVecRemove (Map_NodeVec_t *p, Map_Node_t *Entry)
 
void Map_NodeVecWriteEntry (Map_NodeVec_t *p, int i, Map_Node_t *Entry)
 
Map_Node_tMap_NodeVecReadEntry (Map_NodeVec_t *p, int i)
 
void Map_NodeVecSortByLevel (Map_NodeVec_t *p)
 

Function Documentation

Map_NodeVec_t* Map_NodeVecAlloc ( int  nCap)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file mapperVec.c.

46 {
47  Map_NodeVec_t * p;
48  p = ABC_ALLOC( Map_NodeVec_t, 1 );
49  if ( nCap > 0 && nCap < 16 )
50  nCap = 16;
51  p->nSize = 0;
52  p->nCap = nCap;
53  p->pArray = p->nCap? ABC_ALLOC( Map_Node_t *, p->nCap ) : NULL;
54  return p;
55 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecClear ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file mapperVec.c.

175 {
176  p->nSize = 0;
177 }
int Map_NodeVecCompareLevels ( Map_Node_t **  pp1,
Map_Node_t **  pp2 
)
static

DECLARATIONS ///.

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

FileName [mapperVec.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - June 1, 2004.]

Revision [

Id:
mapperVec.c,v 1.3 2005/01/23 06:59:45 alanmi Exp

]

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

Synopsis [Comparison procedure for two clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 324 of file mapperVec.c.

325 {
326  int Level1 = Map_Regular(*pp1)->Level;
327  int Level2 = Map_Regular(*pp2)->Level;
328  if ( Level1 < Level2 )
329  return -1;
330  if ( Level1 > Level2 )
331  return 1;
332  if ( Map_Regular(*pp1)->Num < Map_Regular(*pp2)->Num )
333  return -1;
334  if ( Map_Regular(*pp1)->Num > Map_Regular(*pp2)->Num )
335  return 1;
336  return 0;
337 }
if(last==0)
Definition: sparse_int.h:34
#define Map_Regular(p)
Definition: mapper.h:68
Map_NodeVec_t* Map_NodeVecDup ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file mapperVec.c.

88 {
89  Map_NodeVec_t * pNew = Map_NodeVecAlloc( p->nSize );
90  memcpy( pNew->pArray, p->pArray, sizeof(int) * p->nSize );
91  pNew->nSize = p->nSize;
92  return pNew;
93 }
Map_NodeVec_t * Map_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: mapperVec.c:45
char * memcpy()
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecFree ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file mapperVec.c.

69 {
70  if ( p == NULL )
71  return;
72  ABC_FREE( p->pArray );
73  ABC_FREE( p );
74 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Map_NodeVecGrow ( Map_NodeVec_t p,
int  nCapMin 
)

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 138 of file mapperVec.c.

139 {
140  if ( p->nCap >= nCapMin )
141  return;
142  p->pArray = ABC_REALLOC( Map_Node_t *, p->pArray, nCapMin );
143  p->nCap = nCapMin;
144 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
Map_Node_t ** pArray
Definition: mapperInt.h:301
Map_Node_t* Map_NodeVecPop ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file mapperVec.c.

235 {
236  return p->pArray[--p->nSize];
237 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecPush ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file mapperVec.c.

191 {
192  if ( p->nSize == p->nCap )
193  {
194  if ( p->nCap < 16 )
195  Map_NodeVecGrow( p, 16 );
196  else
197  Map_NodeVecGrow( p, 2 * p->nCap );
198  }
199  p->pArray[p->nSize++] = Entry;
200 }
void Map_NodeVecGrow(Map_NodeVec_t *p, int nCapMin)
Definition: mapperVec.c:138
Map_Node_t ** pArray
Definition: mapperInt.h:301
int Map_NodeVecPushUnique ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis [Add the element while ensuring uniqueness.]

Description [Returns 1 if the element was found, and 0 if it was new. ]

SideEffects []

SeeAlso []

Definition at line 213 of file mapperVec.c.

214 {
215  int i;
216  for ( i = 0; i < p->nSize; i++ )
217  if ( p->pArray[i] == Entry )
218  return 1;
219  Map_NodeVecPush( p, Entry );
220  return 0;
221 }
void Map_NodeVecPush(Map_NodeVec_t *p, Map_Node_t *Entry)
Definition: mapperVec.c:190
Map_Node_t ** pArray
Definition: mapperInt.h:301
Map_Node_t** Map_NodeVecReadArray ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file mapperVec.c.

107 {
108  return p->pArray;
109 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
Map_Node_t* Map_NodeVecReadEntry ( Map_NodeVec_t p,
int  i 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 290 of file mapperVec.c.

291 {
292  assert( i >= 0 && i < p->nSize );
293  return p->pArray[i];
294 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define assert(ex)
Definition: util_old.h:213
int Map_NodeVecReadSize ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 122 of file mapperVec.c.

123 {
124  return p->nSize;
125 }
void Map_NodeVecRemove ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file mapperVec.c.

251 {
252  int i;
253  for ( i = 0; i < p->nSize; i++ )
254  if ( p->pArray[i] == Entry )
255  break;
256  assert( i < p->nSize );
257  for ( i++; i < p->nSize; i++ )
258  p->pArray[i-1] = p->pArray[i];
259  p->nSize--;
260 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define assert(ex)
Definition: util_old.h:213
void Map_NodeVecShrink ( Map_NodeVec_t p,
int  nSizeNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 157 of file mapperVec.c.

158 {
159  assert( p->nSize >= nSizeNew );
160  p->nSize = nSizeNew;
161 }
#define assert(ex)
Definition: util_old.h:213
void Map_NodeVecSortByLevel ( Map_NodeVec_t p)

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

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file mapperVec.c.

308 {
309  qsort( (void *)p->pArray, p->nSize, sizeof(Map_Node_t *),
310  (int (*)(const void *, const void *)) Map_NodeVecCompareLevels );
311 }
static ABC_NAMESPACE_IMPL_START int Map_NodeVecCompareLevels(Map_Node_t **pp1, Map_Node_t **pp2)
DECLARATIONS ///.
Definition: mapperVec.c:324
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecWriteEntry ( Map_NodeVec_t p,
int  i,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file mapperVec.c.

274 {
275  assert( i >= 0 && i < p->nSize );
276  p->pArray[i] = Entry;
277 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define assert(ex)
Definition: util_old.h:213