Commit 94d722c5 by Alan Mishchenko

Improvements to LMS code.

parent cb7bf6ae
......@@ -391,6 +391,10 @@ SOURCE=.\src\base\abci\abcRec2.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcRec3.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcReconv.c
# End Source File
# Begin Source File
......
......@@ -798,6 +798,16 @@ extern ABC_DLL void Abc_NtkRecLibMerge2(Gia_Man_t * pGia);
extern ABC_DLL int Abc_NtkRecIsRunning2();
extern ABC_DLL int Abc_NtkRecIsInTrimMode2();
extern ABC_DLL void Abc_NtkRecFilter2(int nLimit);
/*=== abcRec3.c ==========================================================*/
extern ABC_DLL void Abc_NtkRecStart3( Gia_Man_t *p, int nVars, int nCuts, int fTrim );
extern ABC_DLL void Abc_NtkRecStop3();
extern ABC_DLL void Abc_NtkRecAdd3( Abc_Ntk_t * pNtk, int fUseSOPB );
extern ABC_DLL void Abc_NtkRecPs3(int fPrintLib);
extern ABC_DLL Gia_Man_t * Abc_NtkRecGetGia3();
extern ABC_DLL int Abc_NtkRecIsRunning3();
//extern ABC_DLL int Abc_NtkRecIsInTrimMode3();
//extern ABC_DLL void Abc_NtkRecLibMerge3(Gia_Man_t * pGia);
//extern ABC_DLL void Abc_NtkRecFilter3(int nLimit);
/*=== abcReconv.c ==========================================================*/
extern ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart( int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop );
extern ABC_DLL void Abc_NtkManCutStop( Abc_ManCut_t * p );
......
......@@ -46,6 +46,7 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcQuant.c \
src/base/abci/abcRec.c \
src/base/abci/abcRec2.c \
src/base/abci/abcRec3.c \
src/base/abci/abcReconv.c \
src/base/abci/abcReach.c \
src/base/abci/abcRefactor.c \
......
......@@ -528,6 +528,7 @@ extern Vec_Int_t * If_ManCollectMappingInt( If_Man_t * p );
extern int If_ManCountSpecialPos( If_Man_t * p );
extern void If_CutTraverse( If_Man_t * p, If_Obj_t * pRoot, If_Cut_t * pCut, Vec_Ptr_t * vNodes );
extern void If_ObjPrint( If_Obj_t * pObj );
/*=== abcRec.c ============================================================*/
extern int If_CutDelayRecCost(If_Man_t* p, If_Cut_t* pCut, If_Obj_t * pObj);
......
......@@ -820,6 +820,39 @@ void If_CutTraverseTest( If_Man_t * p, If_Obj_t * pRoot, If_Cut_t * pCut )
Vec_PtrFree( vNodes );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void If_ObjPrint( If_Obj_t * pObj )
{
if ( pObj == NULL )
{
printf( "Object is NULL." );
return;
}
printf( "Obj %4d : ", If_ObjId(pObj) );
if ( If_ObjIsConst1(pObj) )
printf( "constant 1" );
else if ( If_ObjIsCi(pObj) )
printf( "PI" );
else if ( If_ObjIsCo(pObj) )
printf( "PO( %4d%s )", If_ObjId(If_ObjFanin0(pObj)), (If_ObjFaninC0(pObj)? "\'" : " ") );
else
printf( "AND( %4d%s, %4d%s )",
If_ObjId(If_ObjFanin0(pObj)), (If_ObjFaninC0(pObj)? "\'" : " "),
If_ObjId(If_ObjFanin1(pObj)), (If_ObjFaninC1(pObj)? "\'" : " ") );
printf( " (refs = %3d)", pObj->nVisitsCopy );
printf( "\n" );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -57,14 +57,16 @@ struct Vec_Mem_t_
int nPageAlloc; // number of pages currently allocated
int iPage; // the number of a page currently used
word ** ppPages; // memory pages
Vec_Int_t * vTable; // hash table
Vec_Int_t * vNexts; // next pointers
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#define Vec_MemForEachEntry( vVec, pEntry, i ) \
for ( i = 0; (i < Vec_MemEntryNum(vVec)) && ((pEntry) = Vec_MemReadEntry(vVec, i)); i++ )
#define Vec_MemForEachEntry( p, pEntry, i ) \
for ( i = 0; (i < Vec_MemEntryNum(p)) && ((pEntry) = Vec_MemReadEntry(p, i)); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......@@ -266,12 +268,12 @@ static inline void Vec_MemShrink( Vec_Mem_t * p, int nEntriesNew )
SeeAlso []
***********************************************************************/
static inline void Vec_MemPrint( Vec_Mem_t * vVec )
static inline void Vec_MemPrint( Vec_Mem_t * p )
{
word * pEntry;
int i;
printf( "Memory vector has %d entries: ", Vec_MemEntryNum(vVec) );
Vec_MemForEachEntry( vVec, pEntry, i )
printf( "Memory vector has %d entries: ", Vec_MemEntryNum(p) );
Vec_MemForEachEntry( p, pEntry, i )
{
printf( "%3d : ", i );
// add printout here
......@@ -279,6 +281,77 @@ static inline void Vec_MemPrint( Vec_Mem_t * vVec )
}
}
/**Function*************************************************************
Synopsis [Hashing entries in the memory vector.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_MemHashAlloc( Vec_Mem_t * p, int nTableSize )
{
assert( p->vTable == NULL && p->vNexts == NULL );
p->vTable = Vec_IntStartFull( Abc_PrimeCudd(nTableSize) );
p->vNexts = Vec_IntAlloc( nTableSize );
}
static inline void Vec_MemHashFree( Vec_Mem_t * p )
{
Vec_IntFreeP( &p->vTable );
Vec_IntFreeP( &p->vNexts );
}
static inline unsigned Vec_MemHashKey( Vec_Mem_t * p, word * pEntry )
{
static int s_Primes[8] = { 1699, 4177, 5147, 5647, 6343, 7103, 7873, 8147 };
int i, nData = 2 * p->nEntrySize;
unsigned * pData = (unsigned *)pEntry;
unsigned uHash = 0;
for ( i = 0; i < nData; i++ )
uHash += pData[i] * s_Primes[i & 0x7];
return uHash % Vec_IntSize(p->vTable);
}
static int * Vec_MemHashLookup( Vec_Mem_t * p, word * pEntry )
{
int * pSpot = Vec_IntEntryP( p->vTable, Vec_MemHashKey(p, pEntry) );
for ( ; *pSpot != -1; pSpot = Vec_IntEntryP(p->vNexts, *pSpot) )
if ( !memcmp( Vec_MemReadEntry(p, *pSpot), pEntry, sizeof(word) * p->nEntrySize ) ) // equal
return pSpot;
return pSpot;
}
static void Vec_MemHashResize( Vec_Mem_t * p )
{
word * pEntry;
int i, * pSpot;
Vec_IntFill( p->vTable, Abc_PrimeCudd(2 * Vec_IntSize(p->vTable)), -1 );
Vec_IntClear( p->vNexts );
Vec_MemForEachEntry( p, pEntry, i )
{
pSpot = Vec_MemHashLookup( p, pEntry );
assert( *pSpot == -1 );
*pSpot = Vec_IntSize(p->vNexts);
Vec_IntPush( p->vNexts, -1 );
}
assert( p->nEntries == Vec_IntSize(p->vNexts) );
}
static int Vec_MemHashInsert( Vec_Mem_t * p, word * pEntry )
{
int * pSpot;
if ( p->nEntries > Vec_IntSize(p->vTable) )
Vec_MemHashResize( p );
pSpot = Vec_MemHashLookup( p, pEntry );
if ( *pSpot == -1 )
{
*pSpot = Vec_IntSize(p->vNexts);
Vec_IntPush( p->vNexts, -1 );
Vec_MemPush( p, pEntry );
assert( p->nEntries == Vec_IntSize(p->vNexts) );
}
return *pSpot;
}
ABC_NAMESPACE_HEADER_END
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment