summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-05-12 19:09:28 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-05-12 19:09:28 -0700
commit9d219eee4b8901d18b0c471205b1cec9fb1f0d1b (patch)
tree3be5e49e749d9c0cd4337d213ecb6221bc4876cc /src/base
parent7bcd75d80afd44633d018fc9636bf3788709bae2 (diff)
downloadabc-9d219eee4b8901d18b0c471205b1cec9fb1f0d1b.tar.gz
abc-9d219eee4b8901d18b0c471205b1cec9fb1f0d1b.tar.bz2
abc-9d219eee4b8901d18b0c471205b1cec9fb1f0d1b.zip
New MFS package.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/abci/abc.c143
-rw-r--r--src/base/abci/abcMfs.c189
-rw-r--r--src/base/abci/module.make1
3 files changed, 333 insertions, 0 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index bd18200c..70646874 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -52,6 +52,7 @@
#include "proof/abs/abs.h"
#include "sat/bmc/bmc.h"
#include "proof/ssc/ssc.h"
+#include "opt/sfm/sfm.h"
#ifndef _WIN32
#include <unistd.h>
@@ -104,6 +105,7 @@ static int Abc_CommandLutpack ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandLutmin ( Abc_Frame_t * pAbc, int argc, char ** argv );
//static int Abc_CommandImfs ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMfs ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMfs2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTrace ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSpeedup ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPowerdown ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -607,6 +609,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Synthesis", "lutmin", Abc_CommandLutmin, 1 );
// Cmd_CommandAdd( pAbc, "Synthesis", "imfs", Abc_CommandImfs, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "mfs", Abc_CommandMfs, 1 );
+ Cmd_CommandAdd( pAbc, "Synthesis", "mfs2", Abc_CommandMfs2, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "trace", Abc_CommandTrace, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "speedup", Abc_CommandSpeedup, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "powerdown", Abc_CommandPowerdown, 1 );
@@ -4400,6 +4403,146 @@ usage:
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern int Abc_NtkPerformMfs( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars );
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ Sfm_Par_t Pars, * pPars = &Pars;
+ int c;
+ // set defaults
+ Sfm_ParSetDefault( pPars );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMClaevwh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'W':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nTfoLevMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nTfoLevMax < 0 )
+ goto usage;
+ break;
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nFanoutMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nFanoutMax < 1 )
+ goto usage;
+ break;
+ case 'D':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nDepthMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nDepthMax < 0 )
+ goto usage;
+ break;
+ case 'M':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nWinSizeMax < 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;
+ }
+ pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nBTLimit < 0 )
+ goto usage;
+ break;
+ case 'l':
+ pPars->fFixLevel ^= 1;
+ break;
+ case 'a':
+ pPars->fArea ^= 1;
+ break;
+ case 'e':
+ pPars->fMoreEffort ^= 1;
+ break;
+ case 'v':
+ pPars->fVerbose ^= 1;
+ break;
+ case 'w':
+ pPars->fVeryVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+ if ( !Abc_NtkIsLogic(pNtk) )
+ {
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+ return 1;
+ }
+ if ( !Abc_NtkIsSopLogic(pNtk) )
+ {
+ Abc_Print( -1, "Currently this command works only for SOP logic networks (run \"sop\").\n" );
+ return 1;
+ }
+ // modify the current network
+ if ( !Abc_NtkPerformMfs( pNtk, pPars ) )
+ {
+ Abc_Print( -1, "Resynthesis has failed.\n" );
+ return 1;
+ }
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: mfs2 [-WFDMC <num>] [-laevwh]\n" );
+ Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" );
+ Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax );
+ Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax );
+ Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
+ Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
+ Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-l : allow logic level to increase [default = %s]\n", !pPars->fFixLevel? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
+ Abc_Print( -2, "\t-e : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
/**Function*************************************************************
diff --git a/src/base/abci/abcMfs.c b/src/base/abci/abcMfs.c
new file mode 100644
index 00000000..ddc91467
--- /dev/null
+++ b/src/base/abci/abcMfs.c
@@ -0,0 +1,189 @@
+/**CFile****************************************************************
+
+ FileName [abcMfs.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Optimization with don't-cares.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcMfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "base/abc/abc.h"
+#include "opt/sfm/sfm.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Abc_NtkAssignIDs( Abc_Ntk_t * pNtk )
+{
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pObj;
+ int i;
+ vNodes = Abc_NtkDfs( pNtk, 0 );
+ Abc_NtkCleanCopy( pNtk );
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ pObj->iTemp = i;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->iTemp = Abc_NtkPiNum(pNtk) + i;
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ pObj->iTemp = Abc_NtkPiNum(pNtk) + Vec_PtrSize(vNodes) + i;
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Extracts information about the network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk )
+{
+ Vec_Ptr_t * vNodes;
+ Vec_Wec_t * vFanins;
+ Vec_Str_t * vFixed;
+ Vec_Wrd_t * vTruths;
+ Vec_Int_t * vArray;
+ Abc_Obj_t * pObj, * pFanin;
+ int i, k, nObjs;
+ vNodes = Abc_NtkAssignIDs( pNtk );
+ nObjs = Abc_NtkPiNum(pNtk) + Vec_PtrSize(vNodes) + Abc_NtkPoNum(pNtk);
+ vFanins = Vec_WecStart( nObjs );
+ vFixed = Vec_StrStart( nObjs );
+ vTruths = Vec_WrdStart( nObjs );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ {
+ vArray = Vec_WecEntry( vFanins, pObj->iTemp );
+ Vec_IntGrow( vArray, Abc_ObjFaninNum(pObj) );
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ Vec_IntPush( vArray, pFanin->iTemp );
+ Vec_WrdWriteEntry( vTruths, pObj->iTemp, Abc_SopToTruth((char *)pObj->pData, Abc_ObjFaninNum(pObj)) );
+ }
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ vArray = Vec_WecEntry( vFanins, pObj->iTemp );
+ Vec_IntGrow( vArray, Abc_ObjFaninNum(pObj) );
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ Vec_IntPush( vArray, pFanin->iTemp );
+ }
+ Vec_PtrFree( vNodes );
+ return Sfm_NtkConstruct( vFanins, Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), vFixed, vTruths );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkInsertMfs( Abc_Ntk_t * pNtk, Sfm_Ntk_t * p )
+{
+ Vec_Int_t * vMap, * vArray;
+ Abc_Obj_t * pNode;
+ int i, k, Fanin;
+ // map new IDs into old nodes
+ vMap = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
+ Abc_NtkForEachPi( pNtk, pNode, i )
+ Vec_IntWriteEntry( vMap, pNode->iTemp, Abc_ObjId(pNode) );
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ if ( pNode->iTemp > 0 )
+ Vec_IntWriteEntry( vMap, pNode->iTemp, Abc_ObjId(pNode) );
+ // remove old fanins
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ Abc_ObjRemoveFanins( pNode );
+ // create new fanins
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ if ( pNode->iTemp > 0 && !Sfm_NodeReadFixed(p, pNode->iTemp) )
+ {
+ vArray = Sfm_NodeReadFanins( p, pNode->iTemp );
+ Vec_IntForEachEntry( vArray, Fanin, k )
+ Abc_ObjAddFanin( pNode, Abc_NtkObj(pNtk, Vec_IntEntry(vMap, Fanin)) );
+ pNode->pData = Abc_SopCreateFromTruth( (Mem_Flex_t *)pNtk->pManFunc, Vec_IntSize(vArray), (unsigned *)Sfm_NodeReadTruth(p, pNode->iTemp) );
+ }
+ Vec_IntFree( vMap );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkPerformMfs( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars )
+{
+ Sfm_Ntk_t * p;
+ int nFaninMax, nNodes;
+ assert( Abc_NtkIsSopLogic(pNtk) );
+ // count fanouts
+ nFaninMax = Abc_NtkGetFaninMax( pNtk );
+ if ( nFaninMax > 6 )
+ {
+ Abc_Print( 1, "Currently \"mfs\" cannot process the network containing nodes with more than 6 fanins.\n" );
+ return 0;
+ }
+ // collect information
+ p = Abc_NtkExtractMfs( pNtk );
+ // perform optimization
+ nNodes = Sfm_NtkPerform( p, pPars );
+ // call the fast extract procedure
+ if ( nNodes == 0 )
+ Abc_Print( 1, "The networks is not changed by \"mfs\".\n" );
+ else
+ {
+ Abc_NtkInsertMfs( pNtk, p );
+ Abc_Print( 1, "The networks has %d nodes changed by \"mfs\".\n", nNodes );
+ }
+ Sfm_NtkFree( p );
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/module.make b/src/base/abci/module.make
index 89e1849b..c7645775 100644
--- a/src/base/abci/module.make
+++ b/src/base/abci/module.make
@@ -30,6 +30,7 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcLutmin.c \
src/base/abci/abcMap.c \
src/base/abci/abcMerge.c \
+ src/base/abci/abcMfs.c \
src/base/abci/abcMini.c \
src/base/abci/abcMiter.c \
src/base/abci/abcMulti.c \