ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
hopMem.c
Go to the documentation of this file.
1
20
21#include "hop.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 assert( sizeof(Hop_Obj_t) <= 64 );
94 assert( p->pListFree == NULL );
95// assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
96 // allocate new memory page
97 nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
98 pMemory = ABC_ALLOC( char, nBytes );
99 Vec_PtrPush( p->vChunks, pMemory );
100 // align memory at the 32-byte boundary
101 pMemory = pMemory + 64 - (((int)(ABC_PTRUINT_T)pMemory) & 63);
102 // remember the manager in the first entry
103 Vec_PtrPush( p->vPages, pMemory );
104 // break the memory down into nodes
105 p->pListFree = (Hop_Obj_t *)pMemory;
106 for ( i = 1; i <= IVY_PAGE_MASK; i++ )
107 {
108 *((char **)pMemory) = pMemory + sizeof(Hop_Obj_t);
109 pMemory += sizeof(Hop_Obj_t);
110 }
111 *((char **)pMemory) = NULL;
112}
113
117
118
120
#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
void Hop_ManStartMemory(Hop_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition hopMem.c:49
#define IVY_PAGE_SIZE
DECLARATIONS ///.
Definition hopMem.c:31
#define IVY_PAGE_MASK
Definition hopMem.c:32
void Hop_ManStopMemory(Hop_Man_t *p)
Definition hopMem.c:66
void Hop_ManAddMemory(Hop_Man_t *p)
MACRO DEFINITIONS ///.
Definition hopMem.c:89
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55