mirror of
https://github.com/The-OpenROAD-Project/abc.git
synced 2026-03-12 11:26:17 +08:00
Enabling multiple LUT libraries.
This commit is contained in:
@@ -42941,12 +42941,12 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
int c;
|
||||
// set defaults
|
||||
Gia_ManSetIfParsDefault( pPars );
|
||||
if ( pAbc->pLibLut == NULL )
|
||||
if ( Abc_FrameReadLibLut() == NULL )
|
||||
{
|
||||
Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" );
|
||||
pAbc->pLibLut = If_LibLutSetSimple( 6 );
|
||||
Abc_FrameSetLibLut( If_LibLutSetSimple( 6 ) );
|
||||
}
|
||||
pPars->pLutLib = (If_LibLut_t *)pAbc->pLibLut;
|
||||
pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut();
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRDEWSJTXYZqalepmrsdbgxyofuijkztncvwh" ) ) != EOF )
|
||||
{
|
||||
@@ -43621,12 +43621,12 @@ int Abc_CommandAbc9Iff( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
Abc_Print( -1, "Abc_CommandAbc9Iff(): Mapping of the AIG is not defined.\n" );
|
||||
return 1;
|
||||
}
|
||||
if ( pAbc->pLibLut == NULL )
|
||||
if ( Abc_FrameReadLibLut() == NULL )
|
||||
{
|
||||
Abc_Print( -1, "Abc_CommandAbc9Iff(): LUT library is not defined.\n" );
|
||||
return 1;
|
||||
}
|
||||
Gia_ManIffTest( pAbc->pGia, (If_LibLut_t *)pAbc->pLibLut, fVerbose );
|
||||
Gia_ManIffTest( pAbc->pGia, (If_LibLut_t *)Abc_FrameReadLibLut(), fVerbose );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
@@ -47296,7 +47296,7 @@ int Abc_CommandAbc9Trace( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
|
||||
return 1;
|
||||
}
|
||||
pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
|
||||
pAbc->pGia->pLutLib = fUseLutLib ? Abc_FrameReadLibLut() : NULL;
|
||||
Gia_ManDelayTraceLutPrint( pAbc->pGia, fVerbose );
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -62,6 +62,9 @@ ABC_NAMESPACE_HEADER_START
|
||||
/// MACRO DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// the maximum number of LUT libraries
|
||||
#define ABC_LUT_LIBS 4
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -96,6 +99,7 @@ extern ABC_DLL Abc_Frame_t * Abc_FrameReadGlobalFrame();
|
||||
extern ABC_DLL Vec_Ptr_t * Abc_FrameReadStore();
|
||||
extern ABC_DLL int Abc_FrameReadStoreSize();
|
||||
extern ABC_DLL void * Abc_FrameReadLibLut();
|
||||
extern ABC_DLL void * Abc_FrameReadLibLutI( int i );
|
||||
extern ABC_DLL void * Abc_FrameReadLibBox();
|
||||
extern ABC_DLL void * Abc_FrameReadLibGen();
|
||||
extern ABC_DLL void * Abc_FrameReadLibGen2();
|
||||
@@ -134,6 +138,7 @@ extern ABC_DLL int Abc_FrameReadCexFrame( Abc_Frame_t * p );
|
||||
extern ABC_DLL void Abc_FrameSetNtkStore( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL void Abc_FrameSetNtkStoreSize( int nStored );
|
||||
extern ABC_DLL void Abc_FrameSetLibLut( void * pLib );
|
||||
extern ABC_DLL void Abc_FrameSetLibLutI( void * pLib, int i );
|
||||
extern ABC_DLL void Abc_FrameSetLibBox( void * pLib );
|
||||
extern ABC_DLL void Abc_FrameSetLibGen( void * pLib );
|
||||
extern ABC_DLL void Abc_FrameSetLibGen2( void * pLib );
|
||||
|
||||
@@ -54,7 +54,8 @@ static Abc_Frame_t * s_GlobalFrame = NULL;
|
||||
***********************************************************************/
|
||||
Vec_Ptr_t * Abc_FrameReadStore() { return s_GlobalFrame->vStore; }
|
||||
int Abc_FrameReadStoreSize() { return Vec_PtrSize(s_GlobalFrame->vStore); }
|
||||
void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut; }
|
||||
void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut[0]; }
|
||||
void * Abc_FrameReadLibLutI( int i ) { return s_GlobalFrame->pLibLut[i]; }
|
||||
void * Abc_FrameReadLibBox() { return s_GlobalFrame->pLibBox; }
|
||||
void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; }
|
||||
void * Abc_FrameReadLibGen2() { return s_GlobalFrame->pLibGen2; }
|
||||
@@ -90,7 +91,8 @@ void Abc_FrameInputNdr( Abc_Frame_t * pAbc, void * pData ) { Ndr_Delete(s
|
||||
void * Abc_FrameOutputNdr( Abc_Frame_t * pAbc ) { void * pData = s_GlobalFrame->pNdr; s_GlobalFrame->pNdr = NULL; return pData; }
|
||||
int * Abc_FrameOutputNdrArray( Abc_Frame_t * pAbc ) { int * pArray = s_GlobalFrame->pNdrArray; s_GlobalFrame->pNdrArray = NULL; return pArray; }
|
||||
|
||||
void Abc_FrameSetLibLut( void * pLib ) { s_GlobalFrame->pLibLut = pLib; }
|
||||
void Abc_FrameSetLibLut( void * pLib ) { s_GlobalFrame->pLibLut[0]= pLib; }
|
||||
void Abc_FrameSetLibLutI( void * pLib, int i ) { s_GlobalFrame->pLibLut[i]= pLib; }
|
||||
void Abc_FrameSetLibBox( void * pLib ) { s_GlobalFrame->pLibBox = pLib; }
|
||||
void Abc_FrameSetLibGen( void * pLib ) { s_GlobalFrame->pLibGen = pLib; }
|
||||
void Abc_FrameSetLibGen2( void * pLib ) { s_GlobalFrame->pLibGen2 = pLib; }
|
||||
|
||||
@@ -98,7 +98,7 @@ struct Abc_Frame_t_
|
||||
void * pManDsd; // decomposition manager
|
||||
void * pManDsd2; // decomposition manager
|
||||
// libraries for mapping
|
||||
void * pLibLut; // the current LUT library
|
||||
void * pLibLut[ABC_LUT_LIBS]; // the current LUT library
|
||||
void * pLibBox; // the current box library
|
||||
void * pLibGen; // the current genlib
|
||||
void * pLibGen2; // the current genlib
|
||||
|
||||
@@ -78,7 +78,10 @@ void If_Init( Abc_Frame_t * pAbc )
|
||||
***********************************************************************/
|
||||
void If_End( Abc_Frame_t * pAbc )
|
||||
{
|
||||
If_LibLutFree( (If_LibLut_t *) Abc_FrameReadLibLut() );
|
||||
int i;
|
||||
for ( i = 0; i < ABC_LUT_LIBS; i++ )
|
||||
if ( Abc_FrameReadLibLutI(i) )
|
||||
If_LibLutFree( (If_LibLut_t *)Abc_FrameReadLibLutI(i) );
|
||||
If_LibBoxFree( (If_LibBox_t *)Abc_FrameReadLibBox() );
|
||||
}
|
||||
|
||||
@@ -125,36 +128,51 @@ int If_CommandReadLut( Abc_Frame_t * pAbc, int argc, char **argv )
|
||||
}
|
||||
}
|
||||
|
||||
if ( argc != globalUtilOptind + 1 )
|
||||
goto usage;
|
||||
|
||||
// get the input file name
|
||||
FileName = argv[globalUtilOptind];
|
||||
if ( (pFile = fopen( FileName, "r" )) == NULL )
|
||||
{
|
||||
fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
|
||||
if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
|
||||
fprintf( pErr, "Did you mean \"%s\"?", FileName );
|
||||
fprintf( pErr, "\n" );
|
||||
return 1;
|
||||
}
|
||||
fclose( pFile );
|
||||
|
||||
// set the new network
|
||||
pLib = If_LibLutRead( FileName );
|
||||
if ( pLib == NULL )
|
||||
{
|
||||
fprintf( pErr, "Reading LUT library has failed.\n" );
|
||||
if ( argc == globalUtilOptind ) {
|
||||
fprintf( pErr, "The library file should be specified in the command line.\n" );
|
||||
goto usage;
|
||||
}
|
||||
// replace the current library
|
||||
If_LibLutFree( (If_LibLut_t *)Abc_FrameReadLibLut() );
|
||||
Abc_FrameSetLibLut( pLib );
|
||||
if ( argc > globalUtilOptind + ABC_LUT_LIBS ) {
|
||||
fprintf( pErr, "Can read at most %d libraries. Quitting...\n", ABC_LUT_LIBS );
|
||||
goto usage;
|
||||
}
|
||||
|
||||
// remove current libraries
|
||||
int i;
|
||||
for ( i = 0; i < ABC_LUT_LIBS; i++ )
|
||||
if ( Abc_FrameReadLibLutI(i) ) {
|
||||
If_LibLutFree( (If_LibLut_t *)Abc_FrameReadLibLutI(i) );
|
||||
Abc_FrameSetLibLutI( NULL, i );
|
||||
}
|
||||
|
||||
// input new libraries
|
||||
for ( i = globalUtilOptind; i < argc; i++ ) {
|
||||
// get the input file name
|
||||
FileName = argv[i];
|
||||
if ( (pFile = fopen( FileName, "r" )) == NULL )
|
||||
{
|
||||
fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
|
||||
if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
|
||||
fprintf( pErr, "Did you mean \"%s\"?", FileName );
|
||||
fprintf( pErr, "\n" );
|
||||
return 1;
|
||||
}
|
||||
fclose( pFile );
|
||||
// set the new network
|
||||
pLib = If_LibLutRead( FileName );
|
||||
if ( pLib == NULL )
|
||||
{
|
||||
fprintf( pErr, "Reading LUT library has failed.\n" );
|
||||
goto usage;
|
||||
}
|
||||
// replace the current library
|
||||
Abc_FrameSetLibLutI( pLib, i-globalUtilOptind );
|
||||
}
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf( pErr, "\nusage: read_lut [-vh]\n");
|
||||
fprintf( pErr, "\t read the LUT library from the file\n" );
|
||||
fprintf( pErr, "\nusage: read_lut [-vh] <file1> <file2> ... <fileN>\n");
|
||||
fprintf( pErr, "\t read the LUT library from the file(s)\n" );
|
||||
fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
|
||||
fprintf( pErr, "\t-h : print the command usage\n");
|
||||
fprintf( pErr, "\t \n");
|
||||
@@ -216,7 +234,10 @@ int If_CommandPrintLut( Abc_Frame_t * pAbc, int argc, char **argv )
|
||||
goto usage;
|
||||
|
||||
// set the new network
|
||||
If_LibLutPrint( (If_LibLut_t *)Abc_FrameReadLibLut() );
|
||||
int i;
|
||||
for ( i = 0; i < ABC_LUT_LIBS; i++ )
|
||||
if ( Abc_FrameReadLibLutI(i) )
|
||||
If_LibLutPrint( (If_LibLut_t *)Abc_FrameReadLibLutI(i) );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
***********************************************************************/
|
||||
|
||||
#include "mpmInt.h"
|
||||
#include "base/main/main.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
@@ -55,8 +56,8 @@ Mpm_Man_t * Mpm_ManStart( Mig_Man_t * pMig, Mpm_Par_t * pPars )
|
||||
p = ABC_CALLOC( Mpm_Man_t, 1 );
|
||||
p->pMig = pMig;
|
||||
p->pPars = pPars;
|
||||
p->pLibLut = pPars->pLib;
|
||||
p->nLutSize = pPars->pLib->LutMax;
|
||||
p->pLibLut = (Mpm_LibLut_t *)Abc_FrameReadLibLut();
|
||||
p->nLutSize = p->pLibLut->LutMax;
|
||||
p->nTruWords = pPars->fUseTruth ? Abc_Truth6WordNum(p->nLutSize) : 0;
|
||||
p->nNumCuts = pPars->nNumCuts;
|
||||
// cuts
|
||||
|
||||
Reference in New Issue
Block a user