summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-07-26 16:46:45 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-07-26 16:46:45 -0700
commit704b4bad6b43ed1df4c16eb73555dc3580750f7f (patch)
tree927058d2ced65d07bc9e246c7aaba91845e76d63
parent7d81490fe66c0deda91ef04be6d1f79be7025c6a (diff)
downloadabc-704b4bad6b43ed1df4c16eb73555dc3580750f7f.tar.gz
abc-704b4bad6b43ed1df4c16eb73555dc3580750f7f.tar.bz2
abc-704b4bad6b43ed1df4c16eb73555dc3580750f7f.zip
Generating abstraction of standard cell library.
-rw-r--r--abclib.dsp4
-rw-r--r--src/aig/gia/giaNf.c58
-rw-r--r--src/aig/gia/module.make1
-rw-r--r--src/base/abci/abc.c189
-rw-r--r--src/map/mio/mioUtils.c145
5 files changed, 397 insertions, 0 deletions
diff --git a/abclib.dsp b/abclib.dsp
index ffb4eaed..943682c0 100644
--- a/abclib.dsp
+++ b/abclib.dsp
@@ -3847,6 +3847,10 @@ SOURCE=.\src\aig\gia\giaMuxes.c
# End Source File
# Begin Source File
+SOURCE=.\src\aig\gia\giaNf.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\aig\gia\giaPat.c
# End Source File
# Begin Source File
diff --git a/src/aig/gia/giaNf.c b/src/aig/gia/giaNf.c
new file mode 100644
index 00000000..fb0f094c
--- /dev/null
+++ b/src/aig/gia/giaNf.c
@@ -0,0 +1,58 @@
+/**CFile****************************************************************
+
+ FileName [giaNf.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Technology mapper.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaNf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Nf_ManSetDefaultPars( Jf_Par_t * pPars )
+{
+}
+Gia_Man_t * Nf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+ return Gia_ManDup( pGia );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/module.make b/src/aig/gia/module.make
index a8ebc836..0bee3524 100644
--- a/src/aig/gia/module.make
+++ b/src/aig/gia/module.make
@@ -42,6 +42,7 @@ SRC += src/aig/gia/giaAig.c \
src/aig/gia/giaMfs.c \
src/aig/gia/giaMini.c \
src/aig/gia/giaMuxes.c \
+ src/aig/gia/giaNf.c \
src/aig/gia/giaPat.c \
src/aig/gia/giaResub.c \
src/aig/gia/giaRetime.c \
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 6bec3157..df3fc630 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -385,6 +385,7 @@ static int Abc_CommandAbc9Jf ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Kf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Lf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Mf ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Nf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Struct ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Speedup ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -966,6 +967,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC9", "&kf", Abc_CommandAbc9Kf, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&lf", Abc_CommandAbc9Lf, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&mf", Abc_CommandAbc9Mf, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&nf", Abc_CommandAbc9Nf, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&struct", Abc_CommandAbc9Struct, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&speedup", Abc_CommandAbc9Speedup, 0 );
@@ -31598,6 +31600,193 @@ usage:
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern void Nf_ManSetDefaultPars( Jf_Par_t * pPars );
+ extern Gia_Man_t * Nf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
+ char Buffer[200];
+ Jf_Par_t Pars, * pPars = &Pars;
+ Gia_Man_t * pNew; int c;
+ Nf_ManSetDefaultPars( pPars );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWakvwh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'K':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nLutSize = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
+ {
+ Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
+ goto usage;
+ }
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nCutNum = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
+ {
+ Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
+ goto usage;
+ }
+ break;
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nRounds = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nRounds < 0 )
+ goto usage;
+ break;
+ case 'A':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nRoundsEla < 0 )
+ goto usage;
+ break;
+ case 'R':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+ return 0;
+ }
+ pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nRelaxRatio < 0 )
+ goto usage;
+ break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+ return 0;
+ }
+ pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nCoarseLimit < 0 )
+ goto usage;
+ break;
+ case 'E':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+ return 0;
+ }
+ pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nAreaTuner < 0 )
+ goto usage;
+ break;
+ case 'D':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ goto usage;
+ }
+ pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->DelayTarget <= 0.0 )
+ goto usage;
+ break;
+ case 'W':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nVerbLimit < 0 )
+ goto usage;
+ break;
+ case 'a':
+ pPars->fAreaOnly ^= 1;
+ break;
+ case 'k':
+ pPars->fCoarsen ^= 1;
+ break;
+ case 'v':
+ pPars->fVerbose ^= 1;
+ break;
+ case 'w':
+ pPars->fVeryVerbose ^= 1;
+ break;
+ case 'h':
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Empty GIA network.\n" );
+ return 1;
+ }
+ if ( Abc_FrameReadLibGen() == NULL )
+ {
+ Abc_Print( -1, "Current library is not available.\n" );
+ return 1;
+ }
+ pNew = Nf_ManPerformMapping( pAbc->pGia, pPars );
+ if ( pNew == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Nf(): Mapping into LUTs has failed.\n" );
+ return 1;
+ }
+ Abc_FrameUpdateGia( pAbc, pNew );
+ return 0;
+
+usage:
+ if ( pPars->DelayTarget == -1 )
+ sprintf(Buffer, "best possible" );
+ else
+ sprintf(Buffer, "%d", pPars->DelayTarget );
+ Abc_Print( -2, "usage: &nf [-KCFARLED num] [-akvwh]\n" );
+ Abc_Print( -2, "\t performs technology mapping of the network\n" );
+ Abc_Print( -2, "\t-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
+ Abc_Print( -2, "\t-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
+ Abc_Print( -2, "\t-F num : the number of area flow rounds [default = %d]\n", pPars->nRounds );
+ Abc_Print( -2, "\t-A num : the number of exact area rounds [default = %d]\n", pPars->nRoundsEla );
+ Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
+ Abc_Print( -2, "\t-L num : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
+ Abc_Print( -2, "\t-E num : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
+ Abc_Print( -2, "\t-D num : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+ Abc_Print( -2, "\t-k : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : prints the command usage\n");
+ return 1;
+}
/**Function*************************************************************
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index 21b61d75..842391c7 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -20,6 +20,7 @@
#include "mioInt.h"
#include "base/main/main.h"
#include "exp.h"
+#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
@@ -887,6 +888,150 @@ void Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_Library_t * pLibS )
}
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Nf_ManPrepareGate( int nVars, word uTruth, int * pComp, int * pPerm, Vec_Wrd_t * vResult )
+{
+ int nPerms = Extra_Factorial( nVars );
+ int nMints = (1 << nVars);
+ word tCur, tTemp1, tTemp2;
+ int i, p, c;
+ Vec_WrdClear( vResult );
+ for ( i = 0; i < 2; i++ )
+ {
+ tCur = i ? ~uTruth : uTruth;
+ tTemp1 = tCur;
+ for ( p = 0; p < nPerms; p++ )
+ {
+ tTemp2 = tCur;
+ for ( c = 0; c < nMints; c++ )
+ {
+ Vec_WrdPush( vResult, tCur );
+ tCur = Abc_Tt6Flip( tCur, pComp[c] );
+ }
+ assert( tTemp2 == tCur );
+ tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[p] );
+ }
+ assert( tTemp1 == tCur );
+ }
+}
+void Nf_ManPreparePrint( int nVars, int * pComp, int * pPerm, char Line[2*720*64][8] )
+{
+ int nPerms = Extra_Factorial( nVars );
+ int nMints = (1 << nVars);
+ char * pChar, * pChar2;
+ int i, p, c, n = 0;
+ for ( i = 0; i < nVars; i++ )
+ Line[0][i] = 'A' + nVars - 1 - i;
+ Line[0][nVars] = '+';
+ Line[0][nVars+1] = 0;
+ for ( i = 0; i < 2; i++ )
+ {
+ Line[n][nVars] = i ? '-' : '+';
+ for ( p = 0; p < nPerms; p++ )
+ {
+ for ( c = 0; c < nMints; c++ )
+ {
+ strcpy( Line[n+1], Line[n] ); n++;
+ pChar = &Line[n][pComp[c]];
+ if ( *pChar >= 'A' && *pChar <= 'Z' )
+ *pChar += 'a' - 'A';
+ else if ( *pChar >= 'a' && *pChar <= 'z' )
+ *pChar -= 'a' - 'A';
+ }
+ pChar = &Line[n][pPerm[p]];
+ pChar2 = pChar + 1;
+ ABC_SWAP( char, *pChar, *pChar2 );
+ }
+ }
+ assert( n == 2*nPerms*nMints );
+ n = 0;
+ for ( i = 0; i < 2; i++ )
+ for ( p = 0; p < nPerms; p++ )
+ for ( c = 0; c < nMints; c++ )
+ printf( "%8d : %d %3d %2d : %s\n", n, i, p, c, Line[n++] );
+}
+
+void Nf_ManPrepareLibrary( Mio_Library_t * pLib )
+{
+ extern void Dau_DsdPrintFromTruth( word * pTruth, int nVarsInit );
+// char Lines[2*720*64][8];
+// Nf_ManPreparePrint( 6, pComp, pPerm, Lines );
+ int * pComp[7];
+ int * pPerm[7];
+ Mio_Gate_t ** ppGates;
+ Vec_Wrd_t * vResult;
+ word * pTruths;
+ int * pSizes;
+ int nGates, i, nClasses = 0, nTotal;
+ abctime clk = Abc_Clock();
+
+ for ( i = 2; i <= 6; i++ )
+ pComp[i] = Extra_GreyCodeSchedule( i );
+ for ( i = 2; i <= 6; i++ )
+ pPerm[i] = Extra_PermSchedule( i );
+
+ // collect truth tables
+ ppGates = Mio_CollectRoots( pLib, 6, (float)1.0e+20, 1, &nGates, 0 );
+ pSizes = ABC_CALLOC( int, nGates );
+ pTruths = ABC_CALLOC( word, nGates );
+ vResult = Vec_WrdAlloc( 2 * 720 * 64 );
+ for ( i = 0; i < nGates; i++ )
+ {
+ pSizes[i] = Mio_GateReadPinNum( ppGates[i] );
+ assert( pSizes[i] > 1 && pSizes[i] <= 6 );
+ pTruths[i] = Mio_GateReadTruth( ppGates[i] );
+
+ Nf_ManPrepareGate( pSizes[i], pTruths[i], pComp[pSizes[i]], pPerm[pSizes[i]], vResult );
+ Vec_WrdUniqify(vResult);
+ nClasses += Vec_WrdSize(vResult);
+ nTotal = (1 << (pSizes[i]+1)) * Extra_Factorial(pSizes[i]);
+
+ printf( "%6d : ", i );
+ printf( "%16s : ", Mio_GateReadName( ppGates[i] ) );
+ printf( "%48s : ", Mio_GateReadForm( ppGates[i] ) );
+ printf( "Inputs = %2d ", pSizes[i] );
+ printf( "Total = %6d ", nTotal );
+ printf( "Classes = %6d ", Vec_WrdSize(vResult) );
+ printf( "Configs = %8.2f ", 1.0*nTotal/Vec_WrdSize(vResult) );
+ printf( "%6.2f %% ", 100.0*Vec_WrdSize(vResult)/nTotal );
+ Dau_DsdPrintFromTruth( &pTruths[i], pSizes[i] );
+// printf( "\n" );
+ }
+ Vec_WrdFree( vResult );
+ ABC_FREE( ppGates );
+ ABC_FREE( pSizes );
+ ABC_FREE( pTruths );
+
+ for ( i = 2; i <= 6; i++ )
+ ABC_FREE( pComp[i] );
+ for ( i = 2; i <= 6; i++ )
+ ABC_FREE( pPerm[i] );
+
+ printf( "Classes = %d. ", nClasses );
+ Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+}
+
+void Nf_ManPrepareLibraryTest2()
+{
+ Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
+ if ( pLib != NULL )
+ Nf_ManPrepareLibrary( pLib );
+ else
+ printf( "Standard cell library is not available.\n" );
+
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////