From 9ff1776d06fdf83cd7deffda858a57dba0a4d0f9 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 21 Jul 2017 12:38:18 +0700 Subject: Experiments with logic optimization. --- src/aig/gia/giaScript.c | 54 ++++++++++++++++++++++++++ src/base/abci/abc.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++ src/base/main/mainFrame.c | 3 ++ 3 files changed, 155 insertions(+) diff --git a/src/aig/gia/giaScript.c b/src/aig/gia/giaScript.c index 56733167..fcf97511 100644 --- a/src/aig/gia/giaScript.c +++ b/src/aig/gia/giaScript.c @@ -719,6 +719,60 @@ void Gia_ManPerformFlow2( int fIsMapped, int nAnds, int nLevels, int nLutSize, i } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPerformFlow3( int nLutSize, int nCutNum, int fBalance, int fMinAve, int fUseMfs, int fUseLutLib, int fVerbose ) +{ + char Comm1[200], Comm2[200], Comm3[200]; + if ( fUseLutLib ) + sprintf( Comm1, "&st; &if -C %d; &save; &st; &syn2; &if -C %d; &save; &load", nCutNum, nCutNum ); + else + sprintf( Comm1, "&st; &if -C %d -K %d; &save; &st; &syn2; &if -C %d -K %d; &save; &load", nCutNum, nLutSize, nCutNum, nLutSize ); + if ( fUseLutLib ) + sprintf( Comm2, "&st; &if -%s -K 6; &dch -f; &if -C %d; %s&save; &load", Abc_NtkRecIsRunning3() ? "y" : "g", nCutNum, fUseMfs ? "&mfs; ":"" ); + else + sprintf( Comm2, "&st; &if -%s -K 6; &dch -f; &if -C %d -K %d; %s&save; &load", Abc_NtkRecIsRunning3() ? "y" : "g", nCutNum, nLutSize, fUseMfs ? "&mfs; ":"" ); + if ( fUseLutLib ) + sprintf( Comm3, "&st; &if -%s -K 6; &synch2; &if -C %d; %s&save; &load", Abc_NtkRecIsRunning3() ? "y" : "g", nCutNum, fUseMfs ? "&mfs; ":"" ); + else + sprintf( Comm3, "&st; &if -%s -K 6; &synch2; &if -C %d -K %d; %s&save; &load", Abc_NtkRecIsRunning3() ? "y" : "g", nCutNum, nLutSize, fUseMfs ? "&mfs; ":"" ); + + if ( fVerbose ) printf( "Trying simple synthesis with %s...\n", Abc_NtkRecIsRunning3() ? "LMS" : "SOP balancing" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm1 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + + if ( Gia_ManAndNum( Abc_FrameReadGia(Abc_FrameGetGlobalFrame()) ) < 200000 ) + { + if ( fVerbose ) printf( "Trying medium synthesis...\n" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + + if ( Gia_ManAndNum( Abc_FrameReadGia(Abc_FrameGetGlobalFrame()) ) < 10000 ) + { + if ( fVerbose ) printf( "Trying harder synthesis...\n" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm3 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + + if ( fVerbose ) printf( "Final result...\n" ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); +} + + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index a3c21c72..1a28eb35 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -435,6 +435,7 @@ static int Abc_CommandAbc9Sopb ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Dsdb ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Flow ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Flow2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Flow3 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9If ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Iff ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9If2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1092,6 +1093,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&dsdb", Abc_CommandAbc9Dsdb, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&flow", Abc_CommandAbc9Flow, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&flow2", Abc_CommandAbc9Flow2, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&flow3", Abc_CommandAbc9Flow3, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&if", Abc_CommandAbc9If, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&iff", Abc_CommandAbc9Iff, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&if2", Abc_CommandAbc9If2, 0 ); @@ -34613,6 +34615,102 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Flow3( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManPerformFlow3( int nLutSize, int nCutNum, int fBalance, int fMinAve, int fUseMfs, int fUseLutLib, int fVerbose ); + int nLutSize = 6; + int nCutNum = 8; + int fBalance = 0; + int fMinAve = 0; + int fUseMfs = 1; + int fUseLutLib = 0; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "KCbtmlvh" ) ) != EOF ) + { + switch ( c ) + { + case 'K': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" ); + goto usage; + } + nLutSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nLutSize < 0 ) + goto usage; + break; + case 'C': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" ); + goto usage; + } + nCutNum = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nCutNum < 0 ) + goto usage; + break; + case 'b': + fBalance ^= 1; + break; + case 't': + fMinAve ^= 1; + break; + case 'm': + fUseMfs ^= 1; + break; + case 'l': + fUseLutLib ^= 1; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Flow3(): There is no AIG.\n" ); + return 1; + } + if ( fUseLutLib && Abc_FrameReadLibLut() == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Flow3(): Please enter LUT library using \'read_lut\'.\n" ); + return 1; + } + Gia_ManPerformFlow3( nLutSize, nCutNum, fBalance, fMinAve, fUseMfs, fUseLutLib, fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: &flow3 [-KC num] [-btmlvh]\n" ); + Abc_Print( -2, "\t integration optimization and mapping flow\n" ); + Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize ); + Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum ); + Abc_Print( -2, "\t-b : toggle using SOP balancing during synthesis [default = %s]\n", fBalance? "yes": "no" ); + Abc_Print( -2, "\t-t : toggle minimizing average (not maximum) level [default = %s]\n", fMinAve? "yes": "no" ); + Abc_Print( -2, "\t-m : toggle using \"mfs2\" in the script [default = %s]\n", fUseMfs? "yes": "no" ); + Abc_Print( -2, "\t-l : toggle using previously entered LUT library [default = %s]\n", fUseLutLib? "yes": "no" ); + Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 7d9edecf..f7e9af7c 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -581,6 +581,9 @@ void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p ) // set the current network empty p->pNtkCur = NULL; // fprintf( p->Out, "All networks have been deleted.\n" ); + Gia_ManStopP( &p->pGia ); + Gia_ManStopP( &p->pGia2 ); + Gia_ManStopP( &p->pGiaBest ); } /**Function************************************************************* -- cgit v1.2.3