Extending "stochmap" to work for AIGs.

This commit is contained in:
Alan Mishchenko 2025-04-15 21:56:24 -07:00
parent 47ac9f75ca
commit dcf9079507
3 changed files with 60 additions and 2 deletions

View File

@ -20309,7 +20309,8 @@ usage:
***********************************************************************/
int Abc_CommandStochMap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Ntk_t * pNtkRes = NULL, * pNtk = Abc_FrameReadNtk(pAbc);
extern void Mio_IntallAndLibrary();
extern void Abc_NtkStochMap( int nSuppMax, int nIters, int TimeOut, int Seed, int fOverlap, int fVerbose, char * pScript, int nProcs );
int c, nMaxSize = 14, nIters = 1, TimeOut = 0, Seed = 0, nProcs = 1, fOverlap = 0, fVerbose = 0; char * pScript;
Extra_UtilGetoptReset();
@ -20389,6 +20390,21 @@ int Abc_CommandStochMap( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandStochMap(): There is no AIG.\n" );
return 0;
}
if ( Abc_NtkIsStrash(pNtk) )
{
extern Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars );
Amap_Par_t Pars, * pPars = &Pars;
Amap_ManSetDefaultParams( pPars );
Mio_IntallAndLibrary();
pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
if ( pNtkRes == NULL )
{
Abc_Print( -1, "Mapping has failed.\n" );
return 1;
}
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
pNtk = Abc_FrameReadNtk(pAbc);
}
if ( !Abc_NtkIsMappedLogic(pNtk) )
{
Abc_Print( -1, "Abc_CommandStochMap(): Expecting a mapped current newtork as input.\n" );
@ -20402,6 +20418,17 @@ int Abc_CommandStochMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pScript = Abc_UtilStrsav( argv[globalUtilOptind] );
Abc_NtkStochMap( nMaxSize, nIters, TimeOut, Seed, fOverlap, fVerbose, pScript, nProcs );
ABC_FREE( pScript );
if ( pNtkRes )
{
pNtk = Abc_FrameReadNtk(pAbc);
pNtkRes = Abc_NtkStrash( pNtk, 1, 1, 0 );
if ( pNtkRes == NULL )
{
Abc_Print( -1, "Strashing has failed.\n" );
return 1;
}
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
}
return 0;
usage:

View File

@ -1481,7 +1481,7 @@ Abc_Ntk_t * Abc_NtkInsertPartitions( Abc_Ntk_t * p, Vec_Ptr_t * vvIns, Vec_Ptr_t
Abc_NtkIncrementTravId( p );
while ( 1 ) {
int i, Gain, iEntry = Vec_IntArgMax(vGains);
if ( Vec_IntEntry(vGains, iEntry) <= 0 )
if ( iEntry == -1 || Vec_IntEntry(vGains, iEntry) <= 0 )
break;
//printf( "Selecting partition %d with gain %d.\n", iEntry, Vec_IntEntry(vGains, iEntry) );
Vec_IntWriteEntry( vGains, iEntry, -1 );

View File

@ -73,6 +73,23 @@ static char * pMcncGenlib[] = {
};
*/
// internal version of genlib library
static char * pAndGenlib[] = {
"GATE zero 0 O=CONST0;\n",
"GATE one 0 O=CONST1;\n",
"GATE buf 1 O=a; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE inv 1 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
"GATE and00 1 O=a*b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE and01 1 O=a*!b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE and10 1 O=!a*b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE and11 1 O=!a*!b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE nand00 1 O=!(a*b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE nand01 1 O=!(a*!b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE nand10 1 O=!(!a*b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
"GATE nand11 1 O=!(!a*!b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
NULL
};
// internal version of genlib library
static char * pSimpleGenlib[] = {
"GATE zero 0 O=CONST0;\n",
@ -126,6 +143,20 @@ static char * pSimpleGenlib2[] = {
SeeAlso []
***********************************************************************/
void Mio_IntallAndLibrary()
{
extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int nFaninLimit, int fVerbose );
Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 );
for ( int i = 0; pAndGenlib[i]; i++ )
Vec_StrAppend( vLibStr, pAndGenlib[i] );
Vec_Str_t * vLibStr2 = Vec_StrDup( vLibStr );
Vec_StrAppend( vLibStr2, ".end\n" );
Vec_StrPush( vLibStr2, '\0' );
Vec_StrPush( vLibStr, '\0' );
Mio_UpdateGenlib2( vLibStr, vLibStr2, "and.genlib", 0 );
Vec_StrFree( vLibStr );
Vec_StrFree( vLibStr2 );
}
void Mio_IntallSimpleLibrary()
{
extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int nFaninLimit, int fVerbose );