21 #ifndef ABC__misc__vec__vecMem_h
22 #define ABC__misc__vec__vecMem_h
68 #define Vec_MemForEachEntry( p, pEntry, i ) \
69 for ( i = 0; (i < Vec_MemEntryNum(p)) && ((pEntry) = Vec_MemReadEntry(p, i)); i++ )
91 p->nEntrySize = nEntrySize;
92 p->LogPageSze = LogPageSze;
93 p->PageMask = (1 << p->LogPageSze) - 1;
100 for ( i = 0; i <= p->iPage; i++ )
149 return p->nEntrySize;
157 return p->LogPageSze;
177 return (
double)
sizeof(
word) * p->nEntrySize * (1 << p->LogPageSze) * (p->iPage + 1) + (
double)
sizeof(
word *) * p->nPageAlloc + (
double)
sizeof(
Vec_Mem_t);
193 assert( i >= 0 && i < p->nEntries );
194 return p->ppPages[i >> p->LogPageSze] + p->nEntrySize * (i & p->PageMask);
198 assert( p->nEntries > 0 );
204 memmove( pPlace, pEntry,
sizeof(
word) * p->nEntrySize );
209 if ( i >= p->nEntries )
211 int k, iPageNew = (i >> p->LogPageSze);
212 if ( p->iPage < iPageNew )
215 if ( iPageNew >= p->nPageAlloc )
216 p->ppPages =
ABC_REALLOC(
word *, p->ppPages, (p->nPageAlloc = p->nPageAlloc ? 2 * p->nPageAlloc : iPageNew + 32) );
218 for ( k = p->iPage + 1; k <= iPageNew; k++ )
219 p->ppPages[k] =
ABC_ALLOC(
word, p->nEntrySize * (1 << p->LogPageSze) );
231 memmove( pPlace, pEntry,
sizeof(
word) * p->nEntrySize );
236 memmove( pPlace, pEntry,
sizeof(
word) * p->nEntrySize );
252 int i, iPageOld = p->iPage;
253 assert( nEntriesNew <= p->nEntries );
254 p->nEntries = nEntriesNew;
255 p->iPage = (nEntriesNew >> p->LogPageSze);
256 for ( i = p->iPage + 1; i <= iPageOld; i++ )
273 assert( HexDigit >= 0 && HexDigit < 16 );
275 fprintf( pFile,
"%d", HexDigit );
277 fprintf( pFile,
"%c",
'A' + HexDigit-10 );
283 if ( pFile == stdout )
287 for ( w = pVec->nEntrySize - 1; w >= 0; w-- )
288 for ( d = 15; d >= 0; d-- )
290 fprintf( pFile,
"\n" );
307 assert( p->vTable == NULL && p->vNexts == NULL );
320 static int s_Primes[8] = { 1699, 4177, 5147, 5647, 6343, 7103, 7873, 8147 };
321 int i, nData = 2 * p->nEntrySize;
322 unsigned * pData = (
unsigned *)pEntry;
324 for ( i = 0; i < nData; i++ )
325 uHash += pData[i] * s_Primes[i & 0x7];
331 for ( ; *pSpot != -1; pSpot =
Vec_IntEntryP(p->vNexts, *pSpot) )
380 int Value,
nWords = (nVars <= 6 ? 1 : (1 << (nVars - 6)));
384 memset( uTruth, 0x00,
sizeof(
word) * nWords );
387 memset( uTruth, 0x55,
sizeof(
word) * nWords );
389 memset( uTruth, 0xAA,
sizeof(
word) * nWords );
396 int Value,
nWords = (nVars <= 6 ? 1 : (1 << (nVars - 6)));
398 memset( uTruth, 0xCA,
sizeof(
word) * nWords );
405 char pFileName[1000];
406 sprintf( pFileName,
"tt_%s_%02d.txt", pName ? pName : NULL, nLutSize );
407 pFile = pName ? fopen( pFileName,
"wb" ) : stdout;
409 if ( pFile != stdout )
411 printf(
"Dumped %d %d-var truth tables into file \"%s\" (%.2f MB).\n",
static int Abc_PrimeCudd(unsigned int p)
static void Vec_MemAddMuxTT(Vec_Mem_t *p, int nVars)
static void Vec_MemShrink(Vec_Mem_t *p, int nEntriesNew)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define ABC_REALLOC(type, obj, num)
static void Vec_MemHashAlloc(Vec_Mem_t *p, int nTableSize)
#define Vec_MemForEachEntry(p, pEntry, i)
MACRO DEFINITIONS ///.
static Vec_Mem_t * Vec_MemAlloc(int nEntrySize, int LogPageSze)
FUNCTION DEFINITIONS ///.
static unsigned Vec_MemHashKey(Vec_Mem_t *p, word *pEntry)
static void Vec_MemHashResize(Vec_Mem_t *p)
static int Vec_MemEntrySize(Vec_Mem_t *p)
typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
DECLARATIONS ///.
static int Vec_MemEntryNum(Vec_Mem_t *p)
#define ABC_ALLOC(type, num)
static void Vec_MemClean(Vec_Mem_t *pVec, int nEntries)
static Vec_Int_t * Vec_IntStartFull(int nSize)
static void Vec_MemFill(Vec_Mem_t *pVec, int nEntries)
static void Vec_MemWriteEntry(Vec_Mem_t *p, int i, word *pEntry)
static int s_Primes[MAX_PRIMES]
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Vec_Mem_t * Vec_MemAllocForTT(int nVars, int fCompl)
static void Vec_MemFreeP(Vec_Mem_t **p)
unsigned __int64 word
DECLARATIONS ///.
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
static double Vec_MemMemory(Vec_Mem_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
static void Vec_IntFreeP(Vec_Int_t **p)
static void Vec_MemDumpTruthTables(Vec_Mem_t *p, char *pName, int nLutSize)
#define ABC_NAMESPACE_HEADER_END
static Vec_Mem_t * Vec_MemDup(Vec_Mem_t *pVec)
static word * Vec_MemGetEntry(Vec_Mem_t *p, int i)
static void Vec_MemDump(FILE *pFile, Vec_Mem_t *pVec)
static int Vec_IntSize(Vec_Int_t *p)
static word * Vec_MemReadEntryLast(Vec_Mem_t *p)
static void Vec_MemFree(Vec_Mem_t *p)
#define ABC_CALLOC(type, num)
static void Vec_MemSetEntry(Vec_Mem_t *p, int i, word *pEntry)
typedefABC_NAMESPACE_HEADER_START struct Vec_Mem_t_ Vec_Mem_t
INCLUDES ///.
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
static void Vec_MemHashFree(Vec_Mem_t *p)
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
static int Vec_MemPageSize(Vec_Mem_t *p)
static void Vec_MemDumpDigit(FILE *pFile, int HexDigit)
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
static void Vec_IntClear(Vec_Int_t *p)
static int * Vec_MemHashLookup(Vec_Mem_t *p, word *pEntry)
static int Vec_MemPageNum(Vec_Mem_t *p)
static void Vec_MemPush(Vec_Mem_t *p, word *pEntry)