ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ivyMem.c
Go to the documentation of this file.
1
20
21#include "ivy.h"
22
24
25
29
30// memory management
31#define IVY_PAGE_SIZE 12 // page size containing 2^IVY_PAGE_SIZE nodes
32#define IVY_PAGE_MASK 4095 // page bitmask (2^IVY_PAGE_SIZE)-1
33
37
50{
51 p->vChunks = Vec_PtrAlloc( 128 );
52 p->vPages = Vec_PtrAlloc( 128 );
53}
54
67{
68 void * pMemory;
69 int i;
70 Vec_PtrForEachEntry( void *, p->vChunks, pMemory, i )
71 ABC_FREE( pMemory );
72 Vec_PtrFree( p->vChunks );
73 Vec_PtrFree( p->vPages );
74 p->pListFree = NULL;
75}
76
90{
91 char * pMemory;
92 int i, nBytes;
93 int EntrySizeMax = 128;
94 assert( sizeof(Ivy_Obj_t) <= EntrySizeMax );
95 assert( p->pListFree == NULL );
96// assert( (Ivy_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
97 // allocate new memory page
98 nBytes = sizeof(Ivy_Obj_t) * (1<<IVY_PAGE_SIZE) + EntrySizeMax;
99 pMemory = ABC_ALLOC( char, nBytes );
100 Vec_PtrPush( p->vChunks, pMemory );
101 // align memory at the 32-byte boundary
102 pMemory = pMemory + EntrySizeMax - (((int)(ABC_PTRUINT_T)pMemory) & (EntrySizeMax-1));
103 // remember the manager in the first entry
104 Vec_PtrPush( p->vPages, pMemory );
105 // break the memory down into nodes
106 p->pListFree = (Ivy_Obj_t *)pMemory;
107 for ( i = 1; i <= IVY_PAGE_MASK; i++ )
108 {
109 *((char **)pMemory) = pMemory + sizeof(Ivy_Obj_t);
110 pMemory += sizeof(Ivy_Obj_t);
111 }
112 *((char **)pMemory) = NULL;
113}
114
118
119
121
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
#define IVY_PAGE_SIZE
DECLARATIONS ///.
Definition hopMem.c:31
#define IVY_PAGE_MASK
Definition hopMem.c:32
void Ivy_ManStopMemory(Ivy_Man_t *p)
Definition ivyMem.c:66
void Ivy_ManAddMemory(Ivy_Man_t *p)
Definition ivyMem.c:89
void Ivy_ManStartMemory(Ivy_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition ivyMem.c:49
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition ivy.h:46
struct Ivy_Obj_t_ Ivy_Obj_t
Definition ivy.h:47
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55