mirror of https://github.com/YosysHQ/abc.git
Updates to the GPC-based mapping.
This commit is contained in:
parent
6d6a5accb4
commit
4656ae10e0
|
|
@ -3445,7 +3445,7 @@ int Abc_NtkCheckGpc( char * pGPC, char * pGPC0 )
|
|||
RetValue = 1;
|
||||
return RetValue;
|
||||
}
|
||||
void Abc_NtkATMap( int nXVars, int nYVars, char ** pGPCs0, int nGPCs, int fReturn, int fVerbose )
|
||||
void Abc_NtkATMap( int nXVars, int nYVars, int nAdder, char ** pGPCs0, int nGPCs, int fReturn, int fVerbose )
|
||||
{
|
||||
abctime clkStart = Abc_Clock();
|
||||
char ** pGPCs = Abc_NtkTransformGPCs(pGPCs0, nGPCs);
|
||||
|
|
@ -3490,13 +3490,15 @@ void Abc_NtkATMap( int nXVars, int nYVars, char ** pGPCs0, int nGPCs, int fRetur
|
|||
Vec_IntClear( vRank[2] );
|
||||
Vec_IntAppend( vRank[2], vRank[0] );
|
||||
fFinished = 1;
|
||||
for ( x = 0; x < nBits; x++ )
|
||||
if ( (nGpcs = Abc_NtkMatchGpcPattern(vRank[0], x, pGPCs[n])) )
|
||||
Abc_NtkUpdateGpcPattern(vRank[0], x, pGPCs[n], nGpcs, vRank[1], vLevel), fFinished = 0, fAdded = 1;
|
||||
nLuts += Vec_IntSum(vLevel) * nGPCluts[n];
|
||||
Vec_IntForEachEntry( vRank[1], Entry, x )
|
||||
Vec_IntAddToEntry( vRank[0], x, Entry );
|
||||
if ( fVerbose && (fAdded || Vec_IntFindMax(vRank[2]) <= 2 ) ) {
|
||||
if ( Vec_IntFindMax(vRank[0]) > nAdder ) {
|
||||
for ( x = 0; x < nBits; x++ )
|
||||
if ( (nGpcs = Abc_NtkMatchGpcPattern(vRank[0], x, pGPCs[n])) )
|
||||
Abc_NtkUpdateGpcPattern(vRank[0], x, pGPCs[n], nGpcs, vRank[1], vLevel), fFinished = 0, fAdded = 1;
|
||||
nLuts += Vec_IntSum(vLevel) * nGPCluts[n];
|
||||
Vec_IntForEachEntry( vRank[1], Entry, x )
|
||||
Vec_IntAddToEntry( vRank[0], x, Entry );
|
||||
}
|
||||
if ( fVerbose && (fAdded || Vec_IntFindMax(vRank[2]) <= nAdder ) ) {
|
||||
printf( "Lev%02d: ", iLevel++ );
|
||||
Abc_PrintAT( vRank[2] );
|
||||
if ( fAdded ) {
|
||||
|
|
@ -3504,15 +3506,16 @@ void Abc_NtkATMap( int nXVars, int nYVars, char ** pGPCs0, int nGPCs, int fRetur
|
|||
Abc_PrintAT( vLevel );
|
||||
printf( " %4d", Vec_IntSum(vLevel) * nGPCluts[n] );
|
||||
}
|
||||
else if ( Vec_IntFindMax(vRank[2]) == 2 ) {
|
||||
printf( " RCA : " );
|
||||
x = Vec_IntArgMax(vRank[2]);
|
||||
assert( Vec_IntEntry(vRank[2], x) == 2 );
|
||||
else if ( Vec_IntFindMax(vRank[2]) <= nAdder ) {
|
||||
printf( " ADD%d: ", nAdder );
|
||||
for ( x = 0; x < nBits; x++ )
|
||||
if ( Vec_IntEntry(vRank[2], x) > 1 )
|
||||
break;
|
||||
for ( i = nBits-1; i >= x; i-- )
|
||||
printf( "%4d", 1 );
|
||||
for ( ; i >= 0; i-- )
|
||||
printf( " " );
|
||||
printf( " %4d", (nBits-x+1)/2 );
|
||||
printf( " %4d", (nBits-x)*(nAdder == 4 ? 2 : 1) );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
|
|
@ -3522,14 +3525,14 @@ void Abc_NtkATMap( int nXVars, int nYVars, char ** pGPCs0, int nGPCs, int fRetur
|
|||
n = -1;
|
||||
}
|
||||
}
|
||||
else if ( Vec_IntFindMax(vRank[2]) <= 2 ) {
|
||||
else if ( Vec_IntFindMax(vRank[2]) <= nAdder ) {
|
||||
fFinished = 1;
|
||||
n = nGPCs;
|
||||
}
|
||||
}
|
||||
if ( Vec_IntFindMax(vRank[0]) > 2 )
|
||||
if ( Vec_IntFindMax(vRank[0]) > nAdder )
|
||||
printf( "Synthesis of the adder tree is incomplete. Try using the full adder \"3:11:1\" as the last GPC.\n" );
|
||||
else if ( fVerbose && Vec_IntFindMax(vRank[0]) == 2 ) {
|
||||
else if ( fVerbose && Vec_IntFindMax(vRank[0]) <= nAdder ) {
|
||||
printf( "Lev%02d: ", iLevel++ );
|
||||
for ( i = nBits-1; i >= 0; i-- )
|
||||
printf( "%4d", 1 );
|
||||
|
|
@ -3538,12 +3541,14 @@ void Abc_NtkATMap( int nXVars, int nYVars, char ** pGPCs0, int nGPCs, int fRetur
|
|||
printf( "Statistics: " );
|
||||
for ( n = 0; n < nGPCs; n++ )
|
||||
printf( "GPC%d = %d. ", n, Vec_WecSum(vGPCs[n]) );
|
||||
x = Vec_IntArgMax(vRank[0]);
|
||||
nRcaLuts = Vec_IntFindMax(vRank[0]) == 2 ? (nBits-x+1)/2 : 0;
|
||||
printf( "RCA = %d. ", nRcaLuts );
|
||||
for ( x = 0; x < nBits; x++ )
|
||||
if ( Vec_IntEntry(vRank[0], x) > 1 )
|
||||
break;
|
||||
nRcaLuts = (nBits-x)*(nAdder == 4 ? 2 : 1);
|
||||
printf( "ADD%d = %d. ", nAdder, nRcaLuts );
|
||||
printf( "Total LUT count = %d. ", nLuts+nRcaLuts );
|
||||
Vec_IntFree( vRank[0] );
|
||||
Vec_IntFree( vRank[1] );
|
||||
for ( i = 0; i < 3; i++ )
|
||||
Vec_IntFree( vRank[i] );
|
||||
for ( i = 0; i < nGPCs; i++ )
|
||||
Vec_WecFree( vGPCs[i] );
|
||||
ABC_FREE( vGPCs );
|
||||
|
|
|
|||
|
|
@ -26089,12 +26089,12 @@ usage:
|
|||
***********************************************************************/
|
||||
int Abc_CommandATMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
extern void Abc_NtkATMap( int nXVars, int nYVars, char ** pGPC, int nGPCs, int fReturn, int fVerbose );
|
||||
int c, nXVars = -1, nYVars = -1, fReturn = 0, fVerbose = 1;
|
||||
extern void Abc_NtkATMap( int nXVars, int nYVars, int nAdder, char ** pGPC, int nGPCs, int fReturn, int fVerbose );
|
||||
int c, nXVars = -1, nYVars = -1, nAdder = 2, fReturn = 0, fVerbose = 1;
|
||||
char * pGPCs0[1] = { (char*)"3:11:1" };
|
||||
char ** pGPCs = NULL; int nGPCs = 0;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "XYrvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "XYArvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -26116,6 +26116,15 @@ int Abc_CommandATMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
nYVars = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
break;
|
||||
case 'A':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-A\" should be followed by a file name.\n" );
|
||||
goto usage;
|
||||
}
|
||||
nAdder = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
break;
|
||||
case 'r':
|
||||
fReturn ^= 1;
|
||||
break;
|
||||
|
|
@ -26125,10 +26134,14 @@ int Abc_CommandATMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'h':
|
||||
goto usage;
|
||||
default:
|
||||
//Abc_Print( -2, "Unknown switch.\n");
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
if ( nAdder < 2 || nAdder > 4 )
|
||||
{
|
||||
printf( "The terminal adder should have 2, 3, or 4 bits.\n" );
|
||||
return 0;
|
||||
}
|
||||
pGPCs = argv + globalUtilOptind;
|
||||
nGPCs = argc - globalUtilOptind;
|
||||
if ( nGPCs == 0 )
|
||||
|
|
@ -26137,14 +26150,15 @@ int Abc_CommandATMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
pGPCs = pGPCs0;
|
||||
nGPCs = 1;
|
||||
}
|
||||
Abc_NtkATMap( nXVars, nYVars, pGPCs, nGPCs, fReturn, fVerbose );
|
||||
Abc_NtkATMap( nXVars, nYVars, nAdder, pGPCs, nGPCs, fReturn, fVerbose );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: atmap [-XY num] [-G str] [-rv] <GPC(0)> <GPC(1)> ... <GPC(N-1)>\n" );
|
||||
Abc_Print( -2, "usage: atmap [-XYA num] [-G str] [-rv] <GPC(0)> <GPC(1)> ... <GPC(N-1)>\n" );
|
||||
Abc_Print( -2, "\t maps rectangular adder tree using GPCs\n" );
|
||||
Abc_Print( -2, "\t-X <num> : the number of different ranks [default = %d]\n", nXVars );
|
||||
Abc_Print( -2, "\t-Y <num> : the number of bits of each rank [default = %d]\n", nYVars );
|
||||
Abc_Print( -2, "\t-A <num> : the number of arguments in the terminal adder [default = %d]\n", nAdder );
|
||||
Abc_Print( -2, "\t-r : return to the first GPC after each step [default = %s]\n", fReturn? "yes": "no" );
|
||||
Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue