summaryrefslogtreecommitdiffstats
path: root/src/misc/vec/vecPtr.h
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-12-08 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2007-12-08 08:01:00 -0800
commit65687f72ae77440628c21d63966656c1049c4981 (patch)
tree27a4c7800e372349f1521daac76c0b30e2578ca1 /src/misc/vec/vecPtr.h
parent369f008e69a4f201cbc7c890a08221086bee4698 (diff)
downloadabc-65687f72ae77440628c21d63966656c1049c4981.tar.gz
abc-65687f72ae77440628c21d63966656c1049c4981.tar.bz2
abc-65687f72ae77440628c21d63966656c1049c4981.zip
Version abc71208
Diffstat (limited to 'src/misc/vec/vecPtr.h')
-rw-r--r--src/misc/vec/vecPtr.h242
1 files changed, 146 insertions, 96 deletions
diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h
index 1862bc7c..9595bc72 100644
--- a/src/misc/vec/vecPtr.h
+++ b/src/misc/vec/vecPtr.h
@@ -151,71 +151,6 @@ static inline Vec_Ptr_t * Vec_PtrAllocArrayCopy( void ** pArray, int nSize )
/**Function*************************************************************
- Synopsis [Allocates the array of simulation info.]
-
- Description [Allocates the array containing given number of entries,
- each of which contains given number of unsigned words of simulation data.
- The resulting array can be freed using regular procedure Vec_PtrFree().
- It is the responsibility of the user to ensure this array is never grown.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrAllocSimInfo( int nEntries, int nWords )
-{
- void ** pMemory;
- unsigned * pInfo;
- int i;
- pMemory = (void **)ALLOC( char, (sizeof(void *) + sizeof(unsigned) * nWords) * nEntries );
- pInfo = (unsigned *)(pMemory + nEntries);
- for ( i = 0; i < nEntries; i++ )
- pMemory[i] = pInfo + i * nWords;
- return Vec_PtrAllocArray( pMemory, nEntries );
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates the array of truth tables for the given number of vars.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrAllocTruthTables( int nVars )
-{
- Vec_Ptr_t * p;
- unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
- unsigned * pTruth;
- int i, k, nWords;
- nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
- p = Vec_PtrAllocSimInfo( nVars, nWords );
- for ( i = 0; i < nVars; i++ )
- {
- pTruth = (unsigned *)p->pArray[i];
- if ( i < 5 )
- {
- for ( k = 0; k < nWords; k++ )
- pTruth[k] = Masks[i];
- }
- else
- {
- for ( k = 0; k < nWords; k++ )
- if ( k & (1 << (i-5)) )
- pTruth[k] = ~(unsigned)0;
- else
- pTruth[k] = 0;
- }
- }
- return p;
-}
-
-/**Function*************************************************************
-
Synopsis [Duplicates the integer array.]
Description []
@@ -348,37 +283,6 @@ static inline void * Vec_PtrEntry( Vec_Ptr_t * p, int i )
/**Function*************************************************************
- Synopsis [Resizes the array of simulation info.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrDoubleSimInfo( Vec_Ptr_t * vInfo )
-{
- Vec_Ptr_t * vInfoNew;
- int nWords;
- assert( Vec_PtrSize(vInfo) > 2 );
- // get the new array
- nWords = (unsigned *)Vec_PtrEntry(vInfo,1) - (unsigned *)Vec_PtrEntry(vInfo,0);
- vInfoNew = Vec_PtrAllocSimInfo( 2*Vec_PtrSize(vInfo), nWords );
- // copy the simulation info
- memcpy( Vec_PtrEntry(vInfoNew,0), Vec_PtrEntry(vInfo,0), Vec_PtrSize(vInfo) * nWords * 4 );
- // replace the array
- free( vInfo->pArray );
- vInfo->pArray = vInfoNew->pArray;
- vInfo->nSize *= 2;
- vInfo->nCap *= 2;
- // free the old array
- vInfoNew->pArray = NULL;
- free( vInfoNew );
-}
-
-/**Function*************************************************************
-
Synopsis []
Description []
@@ -753,6 +657,152 @@ static inline void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
p->nSize = k;
}
+
+
+/**Function*************************************************************
+
+ Synopsis [Allocates the array of simulation info.]
+
+ Description [Allocates the array containing given number of entries,
+ each of which contains given number of unsigned words of simulation data.
+ The resulting array can be freed using regular procedure Vec_PtrFree().
+ It is the responsibility of the user to ensure this array is never grown.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Ptr_t * Vec_PtrAllocSimInfo( int nEntries, int nWords )
+{
+ void ** pMemory;
+ unsigned * pInfo;
+ int i;
+ pMemory = (void **)ALLOC( char, (sizeof(void *) + sizeof(unsigned) * nWords) * nEntries );
+ pInfo = (unsigned *)(pMemory + nEntries);
+ for ( i = 0; i < nEntries; i++ )
+ pMemory[i] = pInfo + i * nWords;
+ return Vec_PtrAllocArray( pMemory, nEntries );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Cleans simulation info of each entry beginning with iWord.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_PtrCleanSimInfo( Vec_Ptr_t * vInfo, int iWord, int nWords )
+{
+ int i;
+ for ( i = 0; i < vInfo->nSize; i++ )
+ memset( (char*)Vec_PtrEntry(vInfo,i) + 4*iWord, 0, 4*(nWords-iWord) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the array of simulation info.]
+
+ Description [Doubles the number of objects for which siminfo is allocated.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_PtrDoubleSimInfo( Vec_Ptr_t * vInfo )
+{
+ Vec_Ptr_t * vInfoNew;
+ int nWords;
+ assert( Vec_PtrSize(vInfo) > 1 );
+ // get the new array
+ nWords = (unsigned *)Vec_PtrEntry(vInfo,1) - (unsigned *)Vec_PtrEntry(vInfo,0);
+ vInfoNew = Vec_PtrAllocSimInfo( 2*Vec_PtrSize(vInfo), nWords );
+ // copy the simulation info
+ memcpy( Vec_PtrEntry(vInfoNew,0), Vec_PtrEntry(vInfo,0), Vec_PtrSize(vInfo) * nWords * 4 );
+ // replace the array
+ free( vInfo->pArray );
+ vInfo->pArray = vInfoNew->pArray;
+ vInfo->nSize *= 2;
+ vInfo->nCap *= 2;
+ // free the old array
+ vInfoNew->pArray = NULL;
+ free( vInfoNew );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the array of simulation info.]
+
+ Description [Doubles the number of simulation patterns stored for each object.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_PtrReallocSimInfo( Vec_Ptr_t * vInfo )
+{
+ Vec_Ptr_t * vInfoNew;
+ int nWords, i;
+ assert( Vec_PtrSize(vInfo) > 1 );
+ // get the new array
+ nWords = (unsigned *)Vec_PtrEntry(vInfo,1) - (unsigned *)Vec_PtrEntry(vInfo,0);
+ vInfoNew = Vec_PtrAllocSimInfo( Vec_PtrSize(vInfo), 2*nWords );
+ // copy the simulation info
+ for ( i = 0; i < vInfo->nSize; i++ )
+ memcpy( Vec_PtrEntry(vInfoNew,i), Vec_PtrEntry(vInfo,i), nWords * 4 );
+ // replace the array
+ free( vInfo->pArray );
+ vInfo->pArray = vInfoNew->pArray;
+ // free the old array
+ vInfoNew->pArray = NULL;
+ free( vInfoNew );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates the array of truth tables for the given number of vars.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Ptr_t * Vec_PtrAllocTruthTables( int nVars )
+{
+ Vec_Ptr_t * p;
+ unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
+ unsigned * pTruth;
+ int i, k, nWords;
+ nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
+ p = Vec_PtrAllocSimInfo( nVars, nWords );
+ for ( i = 0; i < nVars; i++ )
+ {
+ pTruth = (unsigned *)p->pArray[i];
+ if ( i < 5 )
+ {
+ for ( k = 0; k < nWords; k++ )
+ pTruth[k] = Masks[i];
+ }
+ else
+ {
+ for ( k = 0; k < nWords; k++ )
+ if ( k & (1 << (i-5)) )
+ pTruth[k] = ~(unsigned)0;
+ else
+ pTruth[k] = 0;
+ }
+ }
+ return p;
+}
+
#endif