mirror of https://github.com/YosysHQ/abc.git
New command &store.
This commit is contained in:
parent
4656ae10e0
commit
dc72d1e120
|
|
@ -552,6 +552,7 @@ static int Abc_CommandAbc9Mesh ( Abc_Frame_t * pAbc, int argc, cha
|
|||
static int Abc_CommandAbc9Iso ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9IsoNpn ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9IsoSt ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9Store ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9Compare ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9RevEng ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9Uif ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
|
|
@ -1364,6 +1365,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
|
|||
Cmd_CommandAdd( pAbc, "ABC9", "&iso", Abc_CommandAbc9Iso, 0 );
|
||||
Cmd_CommandAdd( pAbc, "ABC9", "&isonpn", Abc_CommandAbc9IsoNpn, 0 );
|
||||
Cmd_CommandAdd( pAbc, "ABC9", "&isost", Abc_CommandAbc9IsoSt, 0 );
|
||||
Cmd_CommandAdd( pAbc, "ABC9", "&store", Abc_CommandAbc9Store, 0 );
|
||||
Cmd_CommandAdd( pAbc, "ABC9", "&compare", Abc_CommandAbc9Compare, 0 );
|
||||
Cmd_CommandAdd( pAbc, "ABC9", "&reveng", Abc_CommandAbc9RevEng, 0 );
|
||||
Cmd_CommandAdd( pAbc, "ABC9", "&uif", Abc_CommandAbc9Uif, 0 );
|
||||
|
|
@ -48191,6 +48193,63 @@ usage:
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Abc_CommandAbc9Store( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
int c, fClean = 0, fPrint = 0, fVerbose = 0;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "cpvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
case 'c':
|
||||
fClean ^= 1;
|
||||
break;
|
||||
case 'p':
|
||||
fPrint ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
fVerbose ^= 1;
|
||||
break;
|
||||
case 'h':
|
||||
goto usage;
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
if ( pAbc->pGia == NULL )
|
||||
{
|
||||
Abc_Print( -1, "Abc_CommandAbc9Store(): There is no AIG.\n" );
|
||||
return 1;
|
||||
}
|
||||
if ( fClean )
|
||||
Abc_FrameStoreStop( pAbc );
|
||||
else if ( fPrint )
|
||||
Abc_FrameStorePrint( pAbc );
|
||||
else
|
||||
Abc_FrameStoreAdd( pAbc, pAbc->pGia );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: &store [-cpvh]\n" );
|
||||
Abc_Print( -2, "\t maintains the store of unique AIG structures\n" );
|
||||
Abc_Print( -2, "\t-c : toggle cleaning the store [default = %s]\n", fClean? "yes": "no" );
|
||||
Abc_Print( -2, "\t-p : toggle printing the store statistics [default = %s]\n", fPrint? "yes": "no" );
|
||||
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p )
|
|||
Vec_WecFreeP( &s_GlobalFrame->vJsonObjs );
|
||||
Ndr_Delete( s_GlobalFrame->pNdr );
|
||||
ABC_FREE( s_GlobalFrame->pNdrArray );
|
||||
Abc_FrameStoreStop( s_GlobalFrame );
|
||||
|
||||
Gia_ManStopP( &p->pGiaMiniAig );
|
||||
Gia_ManStopP( &p->pGiaMiniLut );
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "aig/gia/gia.h"
|
||||
#include "proof/ssw/ssw.h"
|
||||
#include "proof/fra/fra.h"
|
||||
#include "misc/vec/vecHsh.h"
|
||||
|
||||
#ifdef ABC_USE_CUDD
|
||||
#include "bdd/extrab/extraBdd.h"
|
||||
|
|
@ -151,6 +152,7 @@ struct Abc_Frame_t_
|
|||
void * pAbcPla;
|
||||
Abc_Nam_t * pJsonStrs;
|
||||
Vec_Wec_t * vJsonObjs;
|
||||
Hsh_VecMan_t * pHash;
|
||||
#ifdef ABC_USE_CUDD
|
||||
DdManager * dd; // temporary BDD package
|
||||
#endif
|
||||
|
|
@ -210,7 +212,10 @@ extern ABC_DLL char * Abc_UtilsGetUsersInput( Abc_Frame_t * pAbc );
|
|||
extern ABC_DLL void Abc_UtilsPrintHello( Abc_Frame_t * pAbc );
|
||||
extern ABC_DLL void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName );
|
||||
extern ABC_DLL void Abc_UtilsSource( Abc_Frame_t * pAbc );
|
||||
|
||||
extern ABC_DLL void Abc_FrameStoreStart( Abc_Frame_t * pAbc );
|
||||
extern ABC_DLL void Abc_FrameStoreStop( Abc_Frame_t * pAbc );
|
||||
extern ABC_DLL void Abc_FrameStoreAdd( Abc_Frame_t * pAbc, Gia_Man_t * p );
|
||||
extern ABC_DLL void Abc_FrameStorePrint( Abc_Frame_t * pAbc );
|
||||
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
|
|
|||
|
|
@ -291,7 +291,63 @@ char * DateReadFromDateString( char * datestr )
|
|||
}
|
||||
}
|
||||
|
||||
/**Function********************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
******************************************************************************/
|
||||
void Abc_FrameStoreStop( Abc_Frame_t * pAbc )
|
||||
{
|
||||
if ( pAbc->pHash )
|
||||
Hsh_VecManStop( pAbc->pHash );
|
||||
pAbc->pHash = NULL;
|
||||
}
|
||||
void Abc_FrameStoreStart( Abc_Frame_t * pAbc )
|
||||
{
|
||||
Abc_FrameStoreStop( pAbc );
|
||||
pAbc->pHash = Hsh_VecManStart( 1000 );
|
||||
pAbc->pHash->vEntry = Vec_IntAlloc( 1000 );
|
||||
pAbc->pHash->vValue = Vec_IntAlloc( 1000 );
|
||||
}
|
||||
void Abc_FrameStoreAdd( Abc_Frame_t * pAbc, Gia_Man_t * pGia )
|
||||
{
|
||||
if ( pAbc->pHash == NULL )
|
||||
Abc_FrameStoreStart( pAbc );
|
||||
Gia_Man_t * p = Gia_ManIsoCanonicize( pGia, 0 );
|
||||
Vec_IntClear( pAbc->pHash->vEntry );
|
||||
Vec_IntPush( pAbc->pHash->vEntry, 0 );
|
||||
Vec_IntPush( pAbc->pHash->vEntry, Gia_ManPiNum(p) );
|
||||
Vec_IntPush( pAbc->pHash->vEntry, Gia_ManPoNum(p) );
|
||||
Vec_IntPush( pAbc->pHash->vEntry, Gia_ManRegNum(p) );
|
||||
Gia_Obj_t * pObj; int i;
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
Vec_IntPushTwo( pAbc->pHash->vEntry, Gia_ObjFaninLit0(pObj, i), Gia_ObjFaninLit1(pObj, i) );
|
||||
int iEntry = Hsh_VecManAdd( pAbc->pHash, pAbc->pHash->vEntry );
|
||||
if ( Vec_IntSize(pAbc->pHash->vValue) == iEntry )
|
||||
Vec_IntPush( pAbc->pHash->vValue, 0 );
|
||||
Vec_IntAddToEntry( pAbc->pHash->vValue, iEntry, 1 );
|
||||
assert( Vec_IntSize(pAbc->pHash->vValue) == Hsh_VecSize(pAbc->pHash) );
|
||||
Gia_ManStop( p );
|
||||
}
|
||||
void Abc_FrameStorePrint( Abc_Frame_t * pAbc )
|
||||
{
|
||||
if ( pAbc->pHash == NULL )
|
||||
Abc_FrameStoreStart( pAbc );
|
||||
int i, Entry, Max = Vec_IntFindMax( pAbc->pHash->vValue );
|
||||
Vec_Int_t * vCounts = Vec_IntStart( Max+1 );
|
||||
Vec_IntForEachEntry( pAbc->pHash->vValue, Entry, i )
|
||||
Vec_IntAddToEntry( vCounts, Entry, 1 );
|
||||
printf( "Distribution of %d stored items by reference count (<ref_count>=<num_items>): ", Hsh_VecSize(pAbc->pHash) );
|
||||
Vec_IntForEachEntry( vCounts, Entry, i )
|
||||
if ( Entry )
|
||||
printf( "%d=%d ", i, Entry );
|
||||
printf( "\n" );
|
||||
Vec_IntFree( vCounts );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ struct Hsh_VecMan_t_
|
|||
{
|
||||
Vec_Int_t * vTable; // hash table
|
||||
Vec_Int_t * vData; // data storage
|
||||
Vec_Int_t * vMap; // mapping entries into data;
|
||||
Vec_Int_t * vMap; // mapping entries into data
|
||||
Vec_Int_t * vValue; // mapping entries into values
|
||||
Vec_Int_t * vEntry; // temporary entry
|
||||
Vec_Int_t vTemp; // temporary array
|
||||
Vec_Int_t vTemp1; // temporary array
|
||||
Vec_Int_t vTemp2; // temporary array
|
||||
|
|
@ -461,6 +463,8 @@ static inline void Hsh_VecManStop( Hsh_VecMan_t * p )
|
|||
Vec_IntFree( p->vTable );
|
||||
Vec_IntFree( p->vData );
|
||||
Vec_IntFree( p->vMap );
|
||||
Vec_IntFreeP( &p->vValue );
|
||||
Vec_IntFreeP( &p->vEntry );
|
||||
ABC_FREE( p );
|
||||
}
|
||||
static inline int * Hsh_VecReadArray( Hsh_VecMan_t * p, int i )
|
||||
|
|
|
|||
Loading…
Reference in New Issue