ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
xsatMemory.h
Go to the documentation of this file.
1
21#ifndef ABC__sat__xSAT__xsatMemory_h
22#define ABC__sat__xSAT__xsatMemory_h
23
28
29#include "xsatClause.h"
30
32
36typedef struct xSAT_Mem_t_ xSAT_Mem_t;
38{
39 unsigned nSize;
40 unsigned nCap;
41 unsigned nWasted;
42 unsigned * pData;
43};
44
48
59static inline xSAT_Clause_t * xSAT_MemClauseHand( xSAT_Mem_t * p, int h )
60{
61 return h != 0xFFFFFFFF ? ( xSAT_Clause_t * )( p->pData + h ) : NULL;
62}
63
75static inline void xSAT_MemGrow( xSAT_Mem_t * p, unsigned nCap )
76{
77 unsigned nPrevCap = p->nCap;
78 if ( p->nCap >= nCap )
79 return;
80 while (p->nCap < nCap)
81 {
82 unsigned delta = ( ( p->nCap >> 1 ) + ( p->nCap >> 3 ) + 2 ) & ~1;
83 p->nCap += delta;
84 assert(p->nCap >= nPrevCap);
85 }
86 assert(p->nCap > 0);
87 p->pData = ABC_REALLOC( unsigned, p->pData, p->nCap );
88}
89
101static inline xSAT_Mem_t * xSAT_MemAlloc( int nCap )
102{
103 xSAT_Mem_t * p;
104 p = ABC_CALLOC( xSAT_Mem_t, 1 );
105 if (nCap <= 0)
106 nCap = 1024*1024;
107
108 xSAT_MemGrow(p, nCap);
109 return p;
110}
111
123static inline void xSAT_MemRestart( xSAT_Mem_t * p )
124{
125 p->nSize = 0;
126 p->nWasted = 0;
127}
128
140static inline void xSAT_MemFree( xSAT_Mem_t * p )
141{
142 ABC_FREE( p->pData );
143 ABC_FREE( p );
144}
145
157static inline unsigned xSAT_MemAppend( xSAT_Mem_t * p, int nSize )
158{
159 unsigned nPrevSize;
160 assert(nSize > 0);
161 xSAT_MemGrow( p, p->nSize + nSize );
162 nPrevSize = p->nSize;
163 p->nSize += nSize;
164 assert(p->nSize > nPrevSize);
165 return nPrevSize;
166}
167
179static inline unsigned xSAT_MemCRef( xSAT_Mem_t * p, unsigned * pC )
180{
181 return ( unsigned )( pC - &(p->pData[0]) );
182}
183
195static inline unsigned xSAT_MemCap( xSAT_Mem_t * p )
196{
197 return p->nCap;
198}
199
211static inline unsigned xSAT_MemWastedCap( xSAT_Mem_t * p )
212{
213 return p->nWasted;
214}
215
217
218#endif
219
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Cube * p
Definition exorList.c:222
unsigned nSize
Definition xsatMemory.h:39
unsigned nCap
Definition xsatMemory.h:40
unsigned * pData
Definition xsatMemory.h:42
unsigned nWasted
Definition xsatMemory.h:41
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct xSAT_Clause_t_ xSAT_Clause_t
INCLUDES ///.
Definition xsatClause.h:34
typedefABC_NAMESPACE_HEADER_START struct xSAT_Mem_t_ xSAT_Mem_t
INCLUDES ///.
Definition xsatMemory.h:36