Skip to content

Commit 75ef060

Browse files
committed
LUT cascade mapping.
1 parent 45c250f commit 75ef060

File tree

5 files changed

+585
-80
lines changed

5 files changed

+585
-80
lines changed

src/base/abci/abc.c

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8853,7 +8853,7 @@ int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
88538853

88548854
if ( pNtk == NULL )
88558855
{
8856-
Abc_Print( -1, "Empty network.\n" );
8856+
Abc_Print( -1, "Empty neAtwork.\n" );
88578857
return 1;
88588858
}
88598859

@@ -8910,12 +8910,12 @@ int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
89108910
***********************************************************************/
89118911
int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
89128912
{
8913-
extern Abc_Ntk_t * Abc_NtkLutCascade( Abc_Ntk_t * pNtk, int nLutSize, int nLuts, int nRails, int nIters, int fVerbose );
8914-
extern Abc_Ntk_t * Abc_NtkLutCascade2( Abc_Ntk_t * pNtk, int nLutSize, int nLuts, int nRails, int nIters, int fVerbose );
8915-
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
8916-
int c, nLutSize = 6, nLuts = 8, nRails = 1, nIters = 1, fVerbose = 0;
8913+
extern Abc_Ntk_t * Abc_NtkLutCascadeGen( int nLutSize, int nStages, int nRails, int nShared, int fVerbose );
8914+
extern Abc_Ntk_t * Abc_NtkLutCascade2( Abc_Ntk_t * pNtk, int nLutSize, int nLuts, int nRails, int nIters, int fVerbose, char * pGuide );
8915+
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes; char * pGuide = NULL;
8916+
int c, nLutSize = 6, nStages = 8, nRails = 1, nShared = 2, nIters = 1, fGen = 0, fVerbose = 0;
89178917
Extra_UtilGetoptReset();
8918-
while ( ( c = Extra_UtilGetopt( argc, argv, "KNRIvh" ) ) != EOF )
8918+
while ( ( c = Extra_UtilGetopt( argc, argv, "KMRSIgvh" ) ) != EOF )
89198919
{
89208920
switch ( c )
89218921
{
@@ -8930,15 +8930,15 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
89308930
if ( nLutSize < 0 )
89318931
goto usage;
89328932
break;
8933-
case 'N':
8933+
case 'M':
89348934
if ( globalUtilOptind >= argc )
89358935
{
8936-
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
8936+
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
89378937
goto usage;
89388938
}
8939-
nLuts = atoi(argv[globalUtilOptind]);
8939+
nStages = atoi(argv[globalUtilOptind]);
89408940
globalUtilOptind++;
8941-
if ( nLuts < 0 )
8941+
if ( nStages < 0 )
89428942
goto usage;
89438943
break;
89448944
case 'R':
@@ -8952,6 +8952,17 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
89528952
if ( nRails < 0 )
89538953
goto usage;
89548954
break;
8955+
case 'S':
8956+
if ( globalUtilOptind >= argc )
8957+
{
8958+
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
8959+
goto usage;
8960+
}
8961+
nShared = atoi(argv[globalUtilOptind]);
8962+
globalUtilOptind++;
8963+
if ( nShared < 0 )
8964+
goto usage;
8965+
break;
89558966
case 'I':
89568967
if ( globalUtilOptind >= argc )
89578968
{
@@ -8963,6 +8974,9 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
89638974
if ( nIters < 0 )
89648975
goto usage;
89658976
break;
8977+
case 'g':
8978+
fGen ^= 1;
8979+
break;
89668980
case 'v':
89678981
fVerbose ^= 1;
89688982
break;
@@ -8972,6 +8986,17 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
89728986
goto usage;
89738987
}
89748988
}
8989+
if ( fGen )
8990+
{
8991+
pNtkRes = Abc_NtkLutCascadeGen( nLutSize, nStages, nRails, nShared, fVerbose );
8992+
if ( pNtkRes == NULL )
8993+
{
8994+
Abc_Print( -1, "LUT cascade generation failed.\n" );
8995+
return 1;
8996+
}
8997+
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
8998+
return 0;
8999+
}
89759000

89769001
if ( pNtk == NULL )
89779002
{
@@ -8988,13 +9013,15 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
89889013
Abc_Print( -1, "Run command \"strash\" to convert the network into an AIG.\n" );
89899014
return 1;
89909015
}
8991-
if ( Abc_NtkCiNum(pNtk) > nLutSize + (nLutSize - nRails) * (nLuts - 1) )
9016+
if ( Abc_NtkCiNum(pNtk) > nLutSize + (nLutSize - nRails) * (nStages - 1) )
89929017
{
89939018
Abc_Print( -1, "Cannot decompose %d-input function into a %d-rail cascade of %d %d-LUTs (max suppose size = %d).\n",
8994-
Abc_NtkCiNum(pNtk), nRails, nLuts, nLutSize, nLutSize + (nLutSize - nRails) * (nLuts - 1) );
9019+
Abc_NtkCiNum(pNtk), nRails, nStages, nLutSize, nLutSize + (nLutSize - nRails) * (nStages - 1) );
89959020
return 1;
89969021
}
8997-
pNtkRes = Abc_NtkLutCascade2( pNtk, nLutSize, nLuts, nRails, nIters, fVerbose );
9022+
if ( argc == globalUtilOptind + 1 )
9023+
pGuide = argv[globalUtilOptind];
9024+
pNtkRes = Abc_NtkLutCascade2( pNtk, nLutSize, nStages, nRails, nIters, fVerbose, pGuide );
89989025
if ( pNtkRes == NULL )
89999026
{
90009027
Abc_Print( -1, "LUT cascade mapping failed.\n" );
@@ -9004,12 +9031,14 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
90049031
return 0;
90059032

90069033
usage:
9007-
Abc_Print( -2, "usage: lutcasdec [-KNRI <num>] [-vh]\n" );
9034+
Abc_Print( -2, "usage: lutcasdec [-KMRSI <num>] [-vh]\n" );
90089035
Abc_Print( -2, "\t decomposes the primary output functions into LUT cascades\n" );
90099036
Abc_Print( -2, "\t-K <num> : the number of LUT inputs [default = %d]\n", nLutSize );
9010-
Abc_Print( -2, "\t-N <num> : the number of LUTs in the cascade [default = %d]\n", nLuts );
9037+
Abc_Print( -2, "\t-M <num> : the maximum delay (the number of stages) [default = %d]\n", nStages );
90119038
Abc_Print( -2, "\t-R <num> : the number of direct connections (rails) [default = %d]\n", nRails );
9039+
Abc_Print( -2, "\t-S <num> : the number of shared variables in each stage [default = %d]\n", nShared );
90129040
Abc_Print( -2, "\t-I <num> : the number of iterations when looking for a solution [default = %d]\n", nIters );
9041+
Abc_Print( -2, "\t-g : toggle generating random cascade with these parameters [default = %s]\n", fGen? "yes": "no" );
90139042
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
90149043
Abc_Print( -2, "\t-h : print the command usage\n");
90159044
return 1;

0 commit comments

Comments
 (0)