Adding new XX decomposition to &if

This commit is contained in:
aletempiac 2024-04-23 11:10:16 +02:00
parent 864f96b11e
commit 043a2ffcc6
4 changed files with 120 additions and 8 deletions

View File

@ -1308,12 +1308,25 @@ int Gia_ManFromIfLogicNode( void * pIfMan, Gia_Man_t * pNew, int iObj, Vec_Int_t
{
if ( Length == 2 )
{
if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
if ( ((If_Man_t *)pIfMan)->pPars->fEnableStructN )
{
Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
printf( "Node %d is not decomposable. Deriving LUT structures has failed.\n", iObj );
return -1;
if ( !If_CluCheckXXExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
{
Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
printf( "Node %d is not decomposable. Deriving LUT structures has failed.\n", iObj );
return -1;
}
}
else
{
if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
{
Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
printf( "Node %d is not decomposable. Deriving LUT structures has failed.\n", iObj );
return -1;
}
}
}
else

View File

@ -40402,7 +40402,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
}
pPars->pLutLib = (If_LibLut_t *)pAbc->pLibLut;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRDEWSTXYqalepmrsdbgxyofuijkztncvwh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRDEWSJTXYqalepmrsdbgxyofuijkztncvwh" ) ) != EOF )
{
switch ( c )
{
@ -40554,6 +40554,21 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
break;
case 'J':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
goto usage;
}
pPars->pLutStruct = argv[globalUtilOptind];
pPars->fEnableStructN = 1;
globalUtilOptind++;
if ( strlen(pPars->pLutStruct) != 2 )
{
Abc_Print( -1, "Command line switch \"-J\" should be followed by a 2-char string (e.g. \"44\" or \"55\").\n" );
goto usage;
}
break;
case 'q':
pPars->fPreprocess ^= 1;
break;
@ -40788,8 +40803,16 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "This feature only works for [6;16]-LUTs.\n" );
return 1;
}
pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16;
if ( pPars->fEnableStructN )
{
pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheckXX;
}
else
{
pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16;
}
pPars->fCutMin = 1;
pPars->nLutDecSize = pPars->pLutStruct[0] - '0';
}
if ( pPars->fUse34Spec )
@ -40934,7 +40957,7 @@ usage:
sprintf(LutSize, "library" );
else
sprintf(LutSize, "%d", pPars->nLutSize );
Abc_Print( -2, "usage: &if [-KCFAGRTXY num] [-DEW float] [-S str] [-qarlepmsdbgxyofuijkztnchvw]\n" );
Abc_Print( -2, "usage: &if [-KCFAGRTXY num] [-DEW float] [-SJ str] [-qarlepmsdbgxyofuijkztnchvw]\n" );
Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
@ -40949,6 +40972,7 @@ usage:
Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
Abc_Print( -2, "\t-W float : sets wire delay between adjects LUTs [default = %f]\n", pPars->WireDelay );
Abc_Print( -2, "\t-S str : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
Abc_Print( -2, "\t-J str : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
Abc_Print( -2, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
Abc_Print( -2, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );

View File

@ -564,6 +564,8 @@ extern int If_CluCheckExt( void * p, word * pTruth, int nVars, int n
char * pLut0, char * pLut1, word * pFunc0, word * pFunc1 );
extern int If_CluCheckExt3( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot,
char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 );
extern int If_CluCheckXXExt( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutRoot,
char * pLut0, char * pLut1, word * pFunc0, word * pFunc1 );
extern int If_MatchCheck1( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int If_MatchCheck2( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
/*=== ifDelay.c =============================================================*/

View File

@ -104,6 +104,27 @@ static inline int If_CluWordNum2( int nVars )
return nVars <= 6 ? 1 : 1 << (nVars-6);
}
static inline word If_CluAdjust2( word t, int nVars )
{
assert( nVars >= 0 && nVars <= 6 );
if ( nVars == 6 )
return t;
t &= (((word)1) << (1 << nVars)) - 1;
if ( nVars == 0 )
t |= t << (1<<nVars++);
if ( nVars == 1 )
t |= t << (1<<nVars++);
if ( nVars == 2 )
t |= t << (1<<nVars++);
if ( nVars == 3 )
t |= t << (1<<nVars++);
if ( nVars == 4 )
t |= t << (1<<nVars++);
if ( nVars == 5 )
t |= t << (1<<nVars++);
return t;
}
int If_CluHashFindMedian2( If_Man_t * p, int t )
{
If_Hte_t * pEntry;
@ -276,6 +297,58 @@ int If_CluCheckXX( If_Man_t * p, word * pTruth0, int lutSize, int nVars, int fHa
return G1.nVars;
}
// returns the best group found
int If_CluCheckXXExt( void * pMan, word * pTruth, int nVars, int nLutLeaf, int nLutRoot,
char * pLut0, char * pLut1, word * pFunc0, word * pFunc1 )
{
(void)pMan;
assert( nLutLeaf == nLutRoot );
unsigned char result[32];
int i;
if ( acdXX_decompose( pTruth, nLutRoot, nVars, result ) )
{
/* decomposition failed */
return 0;
}
/* copy LUT bound set */
unsigned char * pResult = result + 2;
int Lut1Size = (int) (*pResult++);
pLut1[0] = Lut1Size;
pLut1[1] = 0; /* not used */
for (i = 0; i < Lut1Size; ++i)
{
pLut1[2+i] = *pResult++;
}
int func_num_bytes = ( Lut1Size <= 3 ) ? 1 : ( 1 << ( Lut1Size - 3 ) );
*pFunc1 = 0;
for (i = 0; i < func_num_bytes; ++i)
{
*pFunc1 |= ( ( (word) *pResult++ ) & 0xFF ) << 8*i;
}
/* copy LUT composition */
int Lut0Size = (int) (*pResult++);
pLut0[0] = Lut0Size;
pLut0[1] = 0; /* not used */
for (i = 0; i < Lut0Size; ++i)
{
pLut0[2+i] = *pResult++;
}
func_num_bytes = ( Lut0Size <= 3 ) ? 1 : ( 1 << ( Lut0Size - 3 ) );
*pFunc0 = 0;
for (i = 0; i < func_num_bytes; ++i)
{
*pFunc0 |= ( ( (word) *pResult++ ) & 0xFF ) << 8*i;
}
*pFunc1 = If_CluAdjust2( *pFunc1, Lut1Size );
*pFunc0 = If_CluAdjust2( *pFunc0, Lut0Size );
return 1;
}
/**Function*************************************************************
Synopsis [Performs ACD into 66 cascade.]