diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2007-04-08 08:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2007-04-08 08:01:00 -0700 |
commit | c09d4d499cee70f02e3e9a18226554b8d1d34488 (patch) | |
tree | 89ac20b1029dc8407f655224f6ef2b5f431fa453 /src/misc | |
parent | 94112fd22fc6f09ccc488cfc577d43aebeff9c5f (diff) | |
download | abc-c09d4d499cee70f02e3e9a18226554b8d1d34488.tar.gz abc-c09d4d499cee70f02e3e9a18226554b8d1d34488.tar.bz2 abc-c09d4d499cee70f02e3e9a18226554b8d1d34488.zip |
Version abc70408
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/nm/nm.h | 1 | ||||
-rw-r--r-- | src/misc/nm/nmApi.c | 23 | ||||
-rw-r--r-- | src/misc/vec/vecInt.h | 58 | ||||
-rw-r--r-- | src/misc/vec/vecVec.h | 61 |
4 files changed, 143 insertions, 0 deletions
diff --git a/src/misc/nm/nm.h b/src/misc/nm/nm.h index 89a9efac..c6344bbf 100644 --- a/src/misc/nm/nm.h +++ b/src/misc/nm/nm.h @@ -77,6 +77,7 @@ extern void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId ); extern char * Nm_ManCreateUniqueName( Nm_Man_t * p, int ObjId ); extern char * Nm_ManFindNameById( Nm_Man_t * p, int ObjId ); extern int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int Type ); +extern int Nm_ManFindIdByNameTwoTypes( Nm_Man_t * p, char * pName, int Type1, int Type2 ); extern Vec_Int_t * Nm_ManReturnNameIds( Nm_Man_t * p ); #ifdef __cplusplus diff --git a/src/misc/nm/nmApi.c b/src/misc/nm/nmApi.c index c46866d5..9165922f 100644 --- a/src/misc/nm/nmApi.c +++ b/src/misc/nm/nmApi.c @@ -222,6 +222,29 @@ int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int Type ) /**Function************************************************************* + Synopsis [Returns ID of the object if its name is known.] + + Description [This procedure may return two IDs because POs and latches + may have the same name (the only allowed case of name duplication).] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Nm_ManFindIdByNameTwoTypes( Nm_Man_t * p, char * pName, int Type1, int Type2 ) +{ + int iNodeId; + iNodeId = Nm_ManFindIdByName( p, pName, Type1 ); + if ( iNodeId == -1 ) + iNodeId = Nm_ManFindIdByName( p, pName, Type2 ); + if ( iNodeId == -1 ) + return -1; + return iNodeId; +} + +/**Function************************************************************* + Synopsis [Return the IDs of objects with names.] Description [] diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 75693895..f992c3cc 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -775,6 +775,64 @@ static inline void Vec_IntSortUnsigned( Vec_Int_t * p ) (int (*)(const void *, const void *)) Vec_IntSortCompareUnsigned ); } +/**Function************************************************************* + + Synopsis [Returns the number of common entries.] + + Description [Assumes that the vectors are sorted in the increasing order.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_IntTwoCountCommon( Vec_Int_t * vArr1, Vec_Int_t * vArr2 ) +{ + int i, k, Counter = 0; + for ( i = k = 0; i < Vec_IntSize(vArr1) && k < Vec_IntSize(vArr2); ) + { + if ( Vec_IntEntry(vArr1,i) == Vec_IntEntry(vArr2,k) ) + Counter++, i++, k++; + else if ( Vec_IntEntry(vArr1,i) < Vec_IntEntry(vArr2,k) ) + i++; + else + k++; + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Returns the result of merging the two vectors.] + + Description [Assumes that the vectors are sorted in the increasing order.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline Vec_Int_t * Vec_IntTwoMerge( Vec_Int_t * vArr1, Vec_Int_t * vArr2 ) +{ + Vec_Int_t * vArr; + int i, k; + vArr = Vec_IntAlloc( Vec_IntSize(vArr1) ); + for ( i = k = 0; i < Vec_IntSize(vArr1) && k < Vec_IntSize(vArr2); ) + { + if ( Vec_IntEntry(vArr1,i) == Vec_IntEntry(vArr2,k) ) + Vec_IntPush( vArr, Vec_IntEntry(vArr1,i) ), i++, k++; + else if ( Vec_IntEntry(vArr1,i) < Vec_IntEntry(vArr2,k) ) + Vec_IntPush( vArr, Vec_IntEntry(vArr1,i) ), i++; + else + Vec_IntPush( vArr, Vec_IntEntry(vArr2,k) ), k++; + } + for ( ; i < Vec_IntSize(vArr1); i++ ) + Vec_IntPush( vArr, Vec_IntEntry(vArr1,i) ); + for ( ; k < Vec_IntSize(vArr2); k++ ) + Vec_IntPush( vArr, Vec_IntEntry(vArr2,k) ); + return vArr; +} + #endif //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/vec/vecVec.h b/src/misc/vec/vecVec.h index eef33501..09e476f9 100644 --- a/src/misc/vec/vecVec.h +++ b/src/misc/vec/vecVec.h @@ -284,6 +284,67 @@ static inline void Vec_VecPushUnique( Vec_Vec_t * p, int Level, void * Entry ) Vec_PtrPushUnique( (Vec_Ptr_t*)p->pArray[Level], Entry ); } +/**Function************************************************************* + + Synopsis [Comparison procedure for two arrays.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_VecSortCompare1( Vec_Ptr_t ** pp1, Vec_Ptr_t ** pp2 ) +{ + if ( Vec_PtrSize(*pp1) < Vec_PtrSize(*pp2) ) + return -1; + if ( Vec_PtrSize(*pp1) > Vec_PtrSize(*pp2) ) + return 1; + return 0; +} + +/**Function************************************************************* + + Synopsis [Comparison procedure for two integers.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_VecSortCompare2( Vec_Ptr_t ** pp1, Vec_Ptr_t ** pp2 ) +{ + if ( Vec_PtrSize(*pp1) > Vec_PtrSize(*pp2) ) + return -1; + if ( Vec_PtrSize(*pp1) < Vec_PtrSize(*pp2) ) + return 1; + return 0; +} + +/**Function************************************************************* + + Synopsis [Sorting the entries by their integer value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Vec_VecSort( Vec_Vec_t * p, int fReverse ) +{ + if ( fReverse ) + qsort( (void *)p->pArray, p->nSize, sizeof(void *), + (int (*)(const void *, const void *)) Vec_VecSortCompare2 ); + else + qsort( (void *)p->pArray, p->nSize, sizeof(void *), + (int (*)(const void *, const void *)) Vec_VecSortCompare1 ); +} + #endif //////////////////////////////////////////////////////////////////////// |