Commit 036be3a5 by Alan Mishchenko

Experiments with don't-cares.

parent d0ea4853
...@@ -1079,6 +1079,10 @@ SOURCE=.\src\base\acb\acbMfs.c ...@@ -1079,6 +1079,10 @@ SOURCE=.\src\base\acb\acbMfs.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\acb\acbPar.h
# End Source File
# Begin Source File
SOURCE=.\src\base\acb\acbUtil.c SOURCE=.\src\base\acb\acbUtil.c
# End Source File # End Source File
# End Group # End Group
......
...@@ -378,6 +378,8 @@ char * Abc_SopCreateFromTruth( Mem_Flex_t * pMan, int nVars, unsigned * pTruth ) ...@@ -378,6 +378,8 @@ char * Abc_SopCreateFromTruth( Mem_Flex_t * pMan, int nVars, unsigned * pTruth )
{ {
char * pSop, * pCube; char * pSop, * pCube;
int nMints, Counter, i, k; int nMints, Counter, i, k;
if ( nVars == 0 )
return pTruth[0] ? Abc_SopCreateConst1(pMan) : Abc_SopCreateConst0(pMan);
// count the number of true minterms // count the number of true minterms
Counter = 0; Counter = 0;
nMints = (1 << nVars); nMints = (1 << nVars);
......
...@@ -62,6 +62,8 @@ ...@@ -62,6 +62,8 @@
#include "map/mpm/mpm.h" #include "map/mpm/mpm.h"
#include "opt/fret/fretime.h" #include "opt/fret/fretime.h"
#include "opt/nwk/nwkMerge.h" #include "opt/nwk/nwkMerge.h"
#include "base/acb/acbPar.h"
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
...@@ -121,6 +123,7 @@ static int Abc_CommandLutmin ( Abc_Frame_t * pAbc, int argc, cha ...@@ -121,6 +123,7 @@ static int Abc_CommandLutmin ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandMfs ( 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_CommandMfs2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMfs3 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandMfs3 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMfse ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTrace ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTrace ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandGlitch ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandGlitch ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSpeedup ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSpeedup ( Abc_Frame_t * pAbc, int argc, char ** argv );
...@@ -777,6 +780,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -777,6 +780,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Synthesis", "mfs", Abc_CommandMfs, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "mfs", Abc_CommandMfs, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "mfs2", Abc_CommandMfs2, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "mfs2", Abc_CommandMfs2, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "mfs3", Abc_CommandMfs3, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "mfs3", Abc_CommandMfs3, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "mfse", Abc_CommandMfse, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "trace", Abc_CommandTrace, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "trace", Abc_CommandTrace, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "glitch", Abc_CommandGlitch, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "glitch", Abc_CommandGlitch, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "speedup", Abc_CommandSpeedup, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "speedup", Abc_CommandSpeedup, 1 );
...@@ -5654,6 +5658,137 @@ usage: ...@@ -5654,6 +5658,137 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandMfse( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Abc_Ntk_t * Abc_NtkOptMfse( Abc_Ntk_t * pNtk, Acb_Par_t * pPars );
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Acb_Par_t Pars, * pPars = &Pars; int c;
Acb_ParSetDefault( pPars );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "MDOFLCavwh" ) ) != EOF )
{
switch ( c )
{
case 'M':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPars->nTabooMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nTabooMax < 0 )
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->nDivMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nDivMax < 0 )
goto usage;
break;
case 'O':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-O\" 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 < 0 )
goto usage;
break;
case 'L':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nGrowthLevel < -ABC_INFINITY || pPars->nGrowthLevel > ABC_INFINITY )
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 'a':
pPars->fArea ^= 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;
}
return 0;
usage:
Abc_Print( -2, "usage: mfse [-MDOFLC <num>] [-avwh]\n" );
Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" );
Abc_Print( -2, "\t-M <num> : the max number of fanin nodes to skip (num >= 1) [default = %d]\n", pPars->nTabooMax );
Abc_Print( -2, "\t-D <num> : the max number of divisors [default = %d]\n", pPars->nDivMax );
Abc_Print( -2, "\t-O <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-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
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-a : toggle minimizing area [default = %s]\n", pPars->fArea? "area": "delay" );
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************************************************************* /**Function*************************************************************
...@@ -244,6 +244,7 @@ static inline int * Acb_ObjFanins( Acb_Ntk_t * p, int i ) { r ...@@ -244,6 +244,7 @@ static inline int * Acb_ObjFanins( Acb_Ntk_t * p, int i ) { r
static inline int Acb_ObjFanin( Acb_Ntk_t * p, int i, int k ) { return Acb_ObjFanins(p, i)[k+1]; } static inline int Acb_ObjFanin( Acb_Ntk_t * p, int i, int k ) { return Acb_ObjFanins(p, i)[k+1]; }
static inline int Acb_ObjFaninNum( Acb_Ntk_t * p, int i ) { return Acb_ObjFanins(p, i)[0]; } static inline int Acb_ObjFaninNum( Acb_Ntk_t * p, int i ) { return Acb_ObjFanins(p, i)[0]; }
static inline int Acb_ObjFanoutNum( Acb_Ntk_t * p, int i ) { return Vec_IntSize( Vec_WecEntry(&p->vFanouts, i) ); } static inline int Acb_ObjFanoutNum( Acb_Ntk_t * p, int i ) { return Vec_IntSize( Vec_WecEntry(&p->vFanouts, i) ); }
static inline Vec_Int_t * Acb_ObjFanoutVec( Acb_Ntk_t * p, int i ) { return Vec_WecEntry( &p->vFanouts, i ); }
static inline int Acb_ObjFanin0( Acb_Ntk_t * p, int i ) { return Acb_ObjFanins(p, i)[1]; } static inline int Acb_ObjFanin0( Acb_Ntk_t * p, int i ) { return Acb_ObjFanins(p, i)[1]; }
static inline int Acb_ObjCioId( Acb_Ntk_t * p, int i ) { return Acb_ObjFanins(p, i)[2]; } static inline int Acb_ObjCioId( Acb_Ntk_t * p, int i ) { return Acb_ObjFanins(p, i)[2]; }
...@@ -251,6 +252,7 @@ static inline int Acb_ObjCopy( Acb_Ntk_t * p, int i ) { a ...@@ -251,6 +252,7 @@ static inline int Acb_ObjCopy( Acb_Ntk_t * p, int i ) { a
static inline int Acb_ObjFunc( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjFuncs(p) ); return Vec_IntGetEntry(&p->vObjFunc, i); } static inline int Acb_ObjFunc( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjFuncs(p) ); return Vec_IntGetEntry(&p->vObjFunc, i); }
static inline int Acb_ObjWeight( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjWeights(p) );return Vec_IntGetEntry(&p->vObjWeight, i); } static inline int Acb_ObjWeight( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjWeights(p) );return Vec_IntGetEntry(&p->vObjWeight, i); }
static inline word Acb_ObjTruth( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjTruths(p) ); return Vec_WrdGetEntry(&p->vObjTruth, i); } static inline word Acb_ObjTruth( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjTruths(p) ); return Vec_WrdGetEntry(&p->vObjTruth, i); }
static inline word * Acb_ObjTruthP( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjTruths(p) ); return Vec_WrdEntryP(&p->vObjTruth, i); }
static inline int Acb_ObjName( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjNames(p) ); return Vec_IntGetEntry(&p->vObjName, i); } static inline int Acb_ObjName( Acb_Ntk_t * p, int i ) { assert(i>0); assert( Acb_NtkHasObjNames(p) ); return Vec_IntGetEntry(&p->vObjName, i); }
static inline char * Acb_ObjNameStr( Acb_Ntk_t * p, int i ) { assert(i>0); return Acb_NtkStr(p, Acb_ObjName(p, i)); } static inline char * Acb_ObjNameStr( Acb_Ntk_t * p, int i ) { assert(i>0); return Acb_NtkStr(p, Acb_ObjName(p, i)); }
static inline int Acb_ObjAttr( Acb_Ntk_t * p, int i ) { assert(i>=0); return Acb_NtkHasObjAttrs(p) ? Vec_IntGetEntry(&p->vObjAttr, i) : 0; } static inline int Acb_ObjAttr( Acb_Ntk_t * p, int i ) { assert(i>=0); return Acb_NtkHasObjAttrs(p) ? Vec_IntGetEntry(&p->vObjAttr, i) : 0; }
...@@ -397,6 +399,16 @@ static inline void Acb_ObjSetNtkId( Acb_Ntk_t * p, int iObj, int iNtk ) // shoul ...@@ -397,6 +399,16 @@ static inline void Acb_ObjSetNtkId( Acb_Ntk_t * p, int iObj, int iNtk ) // shoul
assert( pFanins[ 1 + pFanins[0] ] == -1 ); assert( pFanins[ 1 + pFanins[0] ] == -1 );
pFanins[ 1 + pFanins[0] ] = iNtk; pFanins[ 1 + pFanins[0] ] = iNtk;
} }
static inline void Acb_ObjRemoveFanins( Acb_Ntk_t * p, int iObj )
{
int i, * pFanins = Acb_ObjFanins( p, iObj );
for ( i = 1; i <= pFanins[0]; i++ )
{
assert( pFanins[i] > 0 );
pFanins[i] = -1;
}
pFanins[0] = 0;
}
static inline int Acb_ObjAlloc( Acb_Ntk_t * p, Acb_ObjType_t Type, int nFans, int nFons ) static inline int Acb_ObjAlloc( Acb_Ntk_t * p, Acb_ObjType_t Type, int nFans, int nFons )
{ {
int i, nFansReal, CioId = -1, iObj = Vec_StrSize(&p->vObjType); int i, nFansReal, CioId = -1, iObj = Vec_StrSize(&p->vObjType);
...@@ -925,110 +937,10 @@ static inline void Acb_ManPrintStats( Acb_Man_t * p, int nModules, int fVerbose ...@@ -925,110 +937,10 @@ static inline void Acb_ManPrintStats( Acb_Man_t * p, int nModules, int fVerbose
} }
/**Function*************************************************************
Synopsis [Name handling.]
Description [] /*=== acbUtil.c =============================================================*/
extern void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj );
SideEffects [] extern void Acb_NtkUpdateNode( Acb_Ntk_t * p, int Pivot, word uTruth, Vec_Int_t * vSupp );
SeeAlso []
***********************************************************************/
/*
static inline void Acb_NtkAddMissingFonNames( Acb_Ntk_t * p, char * pPref )
{
int iFon, NameId, Index;
// populate map
Acb_ManCleanMap( p->pDesign );
Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
if ( NameId )
Acb_ManSetMap( p->pDesign, NameId, iFon );
// check remaining ones
Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
{
if ( NameId )
continue;
NameId = Acb_NtkNewStrId(p, "%s%d", pPref, iFon);
for ( Index = 1; Acb_ManGetMap(p->pDesign, NameId); Index++ )
NameId = Acb_NtkNewStrId(p, "%s%d_%d", pPref, iFon, Index);
Acb_FonSetName( p, iFon, NameId );
Acb_ManSetMap( p->pDesign, NameId, iFon );
}
}
static inline void Acb_NtkCreateFonNames( Acb_Ntk_t * p, char * pPref )
{
int i, iObj, iFon;//, NameId;
Acb_NtkCleanFonNames( p );
Acb_NtkForEachPiFon( p, iObj, iFon, i )
if ( !Acb_FonName(p, iFon) )
Acb_FonSetName( p, iFon, Acb_ObjName(p, iObj) );
Acb_NtkForEachPoDriverFon( p, iObj, iFon, i )
if ( Acb_FonIsReal(iFon) && !Acb_FonName(p, iFon) )
Acb_FonSetName( p, iFon, Acb_ObjName(p, iObj) );
// Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
// if ( NameId == 0 )
// Vec_IntWriteEntry( &p->vFonName, iFon, Acb_NtkNewStrId(p, "%s%d", pPref, iFon) );
Acb_NtkAddMissingFonNames( p, pPref );
}
static inline void Acb_NtkMissingFonNames( Acb_Ntk_t * p, char * pPref )
{
int i, iObj, iFon;//, NameId;
Acb_NtkForEachPiFon( p, iObj, iFon, i )
if ( !Acb_FonName(p, iFon) )
Acb_FonSetName( p, iFon, Acb_ObjName(p, iObj) );
Acb_NtkForEachPoDriverFon( p, iObj, iFon, i )
if ( Acb_FonIsReal(iFon) && !Acb_FonName(p, iFon) )
Acb_FonSetName( p, iFon, Acb_ObjName(p, iObj) );
// Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
// if ( NameId == 0 )
// Acb_FonSetName( p, iFon, Acb_NtkNewStrId(p, "%s%d", pPref, iFon) );
Acb_NtkAddMissingFonNames( p, pPref );
}
*/
/*=== acbBlast.c =============================================================*/
extern Gia_Man_t * Acb_ManBlast( Acb_Man_t * p, int fBarBufs, int fSeq, int fVerbose );
extern Acb_Man_t * Acb_ManInsertGia( Acb_Man_t * p, Gia_Man_t * pGia );
extern Acb_Man_t * Acb_ManInsertAbc( Acb_Man_t * p, void * pAbc );
/*=== acbCba.c ===============================================================*/
extern Acb_Man_t * Acb_ManReadCba( char * pFileName );
extern void Acb_ManWriteCba( char * pFileName, Acb_Man_t * p );
/*=== acbCom.c ===============================================================*/
/*=== acbNtk.c ===============================================================*/
extern void Acb_NtkPrintStatsFull( Acb_Ntk_t * p, int fDistrib, int fVerbose );
extern void Acb_NtkPrintNodes( Acb_Ntk_t * p, int Type );
extern void Acb_NtkPrintDistribOld( Acb_Ntk_t * p );
extern void Acb_ManPrintDistrib( Acb_Man_t * p );
//extern void Acb_ManPrepareTypeNames( Acb_Man_t * p );
extern void Acb_NtkObjOrder( Acb_Ntk_t * p, Vec_Int_t * vObjs, Vec_Int_t * vNameIds );
extern int Acb_NtkCiFonNum( Acb_Ntk_t * p );
extern int Acb_NtkCoFinNum( Acb_Ntk_t * p );
extern int Acb_NtkCheckComboLoop( Acb_Ntk_t * p );
extern int Acb_ManIsTopoOrder( Acb_Man_t * p );
extern Vec_Int_t * Acb_NtkCollectDfs( Acb_Ntk_t * p );
extern Acb_Man_t * Acb_ManCollapse( Acb_Man_t * p );
extern Acb_Man_t * Acb_ManExtractGroup( Acb_Man_t * p, Vec_Int_t * vObjs );
extern Acb_Man_t * Acb_ManDeriveFromGia( Acb_Man_t * p, Gia_Man_t * pGia, int fUseXor );
extern Acb_Man_t * Acb_ManInsertGroup( Acb_Man_t * p, Vec_Int_t * vObjs, Acb_Ntk_t * pSyn );
/*=== acbReadBlif.c ==========================================================*/
extern Acb_Man_t * Prs_ManBuildCbaBlif( char * pFileName, Vec_Ptr_t * vDes );
extern void Prs_ManReadBlifTest( char * pFileName );
extern Acb_Man_t * Acb_ManReadBlif( char * pFileName );
/*=== acbReadVer.c ===========================================================*/
extern Acb_Man_t * Prs_ManBuildCbaVerilog( char * pFileName, Vec_Ptr_t * vDes );
extern void Prs_ManReadVerilogTest( char * pFileName );
extern Acb_Man_t * Acb_ManReadVerilog( char * pFileName );
/*=== acbWriteBlif.c =========================================================*/
extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * p );
extern void Acb_ManWriteBlif( char * pFileName, Acb_Man_t * p );
/*=== acbWriteVer.c ==========================================================*/
extern void Acb_ManCreatePrimMap( char ** pMap );
extern char * Acb_ManGetSliceName( Acb_Ntk_t * p, int iFon, int RangeId );
extern void Prs_ManWriteVerilog( char * pFileName, Vec_Ptr_t * p );
extern void Acb_ManWriteVerilog( char * pFileName, Acb_Man_t * p, int fInlineConcat );
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "acb.h" #include "acb.h"
#include "base/abc/abc.h" #include "base/abc/abc.h"
#include "aig/miniaig/ndr.h" #include "aig/miniaig/ndr.h"
#include "acbPar.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
...@@ -80,6 +81,43 @@ Acb_Ntk_t * Acb_NtkFromAbc( Abc_Ntk_t * p ) ...@@ -80,6 +81,43 @@ Acb_Ntk_t * Acb_NtkFromAbc( Abc_Ntk_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Acb_NtkToAbc( Abc_Ntk_t * pNtk, Acb_Ntk_t * p )
{
int i, k, iObj, iFanin;
Abc_Ntk_t * pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
Mem_Flex_t * pMan = (Mem_Flex_t *)pNtkNew->pManFunc;
Acb_NtkCleanObjCopies( p );
Acb_NtkForEachCi( p, iObj, i )
Acb_ObjSetCopy( p, iObj, Abc_ObjId(Abc_NtkCi(pNtkNew, i)) );
Acb_NtkForEachNode( p, iObj )
{
Abc_Obj_t * pObjNew = Abc_NtkCreateNode( pNtkNew );
Acb_ObjForEachFanin( p, iObj, iFanin, k )
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iFanin)) );
pObjNew->pData = Abc_SopCreateFromTruth( pMan, Acb_ObjFaninNum(p, iObj), (unsigned *)Acb_ObjTruthP(p, iObj) );
}
Acb_NtkForEachCoDriver( p, iFanin, i )
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), Abc_NtkObj(pNtkNew, Acb_ObjCopy(p, iFanin)) );
if ( !Abc_NtkCheck( pNtkNew ) )
{
printf( "Acb_NtkToAbc: The network check has failed.\n" );
Abc_NtkDelete( pNtkNew );
return NULL;
}
return pNtkNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames, Vec_Int_t * vWeights, int nNameIdMax ) Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames, Vec_Int_t * vWeights, int nNameIdMax )
{ {
Ndr_Data_t * p = (Ndr_Data_t *)pModule; Ndr_Data_t * p = (Ndr_Data_t *)pModule;
...@@ -138,6 +176,58 @@ Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames ...@@ -138,6 +176,58 @@ Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames
return pNtk; return pNtk;
} }
/**Function*************************************************************
Synopsis [Setup parameter structure.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Acb_ParSetDefault( Acb_Par_t * pPars )
{
memset( pPars, 0, sizeof(Acb_Par_t) );
pPars->nLutSize = 4; // LUT size
pPars->nTfoLevMax = 3; // the maximum fanout levels
pPars->nTfiLevMax = 3; // the maximum fanin levels
pPars->nFanoutMax = 10; // the maximum number of fanouts
pPars->nDivMax = 16; // the maximum divisor count
pPars->nTabooMax = 4; // the minimum MFFC size
pPars->nGrowthLevel = 0; // the maximum allowed growth in level
pPars->nBTLimit = 0; // the maximum number of conflicts in one SAT run
pPars->nNodesMax = 0; // the maximum number of nodes to try
pPars->iNodeOne = 0; // one particular node to try
pPars->fArea = 0; // performs optimization for area
pPars->fMoreEffort = 0; // enables using more effort
pPars->fVerbose = 0; // enable basic stats
pPars->fVeryVerbose = 0; // enable detailed stats
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkOptMfse( Abc_Ntk_t * pNtk, Acb_Par_t * pPars )
{
extern void Acb_NtkOpt( Acb_Ntk_t * p, Acb_Par_t * pPars );
Abc_Ntk_t * pNtkNew;
Acb_Ntk_t * p = Acb_NtkFromAbc( pNtk );
Acb_NtkOpt( p, pPars );
pNtkNew = Acb_NtkToAbc( pNtk, p );
Acb_ManFree( p->pDesign );
return pNtkNew;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
/**CFile****************************************************************
FileName [acbPar.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Hierarchical word-level netlist.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: acbPar.h,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef ABC__base__acb__acbPar_h
#define ABC__base__acb__acbPar_h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef struct Acb_Par_t_ Acb_Par_t;
struct Acb_Par_t_
{
int nLutSize; // LUT size
int nTfoLevMax; // the maximum fanout levels
int nTfiLevMax; // the maximum fanin levels
int nFanoutMax; // the maximum number of fanouts
int nDivMax; // the maximum divisor count
int nTabooMax; // the minimum MFFC size
int nGrowthLevel; // the maximum allowed growth in level
int nBTLimit; // the maximum number of conflicts in one SAT run
int nNodesMax; // the maximum number of nodes to try
int iNodeOne; // one particular node to try
int fArea; // performs optimization for area
int fMoreEffort; // performs high-affort minimization
int fVerbose; // enable basic stats
int fVeryVerbose; // enable detailed stats
};
/*=== acbAbc.c =============================================================*/
extern void Acb_ParSetDefault( Acb_Par_t * pPars );
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -42,13 +42,24 @@ ABC_NAMESPACE_IMPL_START ...@@ -42,13 +42,24 @@ ABC_NAMESPACE_IMPL_START
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Acb_ObjAddFanout( Acb_Ntk_t * p, int iObj )
{
int k, iFanin, * pFanins;
Acb_ObjForEachFaninFast( p, iObj, pFanins, iFanin, k )
Vec_IntPush( Vec_WecEntry(&p->vFanouts, iFanin), iObj );
}
void Acb_ObjRemoveFanout( Acb_Ntk_t * p, int iObj )
{
int k, iFanin, * pFanins;
Acb_ObjForEachFaninFast( p, iObj, pFanins, iFanin, k )
Vec_IntRemove( Vec_WecEntry(&p->vFanouts, iFanin), iObj );
}
void Acb_NtkCreateFanout( Acb_Ntk_t * p ) void Acb_NtkCreateFanout( Acb_Ntk_t * p )
{ {
int k, iObj, iFanin, * pFanins; int iObj;
Vec_WecInit( &p->vFanouts, Acb_NtkObjNumMax(p) ); Vec_WecInit( &p->vFanouts, Acb_NtkObjNumMax(p) );
Acb_NtkForEachObj( p, iObj ) Acb_NtkForEachObj( p, iObj )
Acb_ObjForEachFaninFast( p, iObj, pFanins, iFanin, k ) Acb_ObjAddFanout( p, iObj );
Vec_IntPush( Vec_WecEntry(&p->vFanouts, iFanin), iObj );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -263,12 +274,11 @@ int Acb_NtkComputePathsR( Acb_Ntk_t * p, Vec_Int_t * vTfi ) ...@@ -263,12 +274,11 @@ int Acb_NtkComputePathsR( Acb_Ntk_t * p, Vec_Int_t * vTfi )
int Acb_NtkComputePaths( Acb_Ntk_t * p ) int Acb_NtkComputePaths( Acb_Ntk_t * p )
{ {
int LevelD = Acb_NtkComputeLevelD( p, NULL ); Acb_NtkComputeLevelD( p, NULL );
int LevelR = Acb_NtkComputeLevelR( p, NULL ); Acb_NtkComputeLevelR( p, NULL );
int PathD = Acb_NtkComputePathsD( p, NULL ); Acb_NtkComputePathsD( p, NULL );
int PathR = Acb_NtkComputePathsR( p, NULL ); Acb_NtkComputePathsR( p, NULL );
assert( PathD == PathR ); return p->nPaths;
return PathR;
} }
void Abc_NtkComputePaths( Abc_Ntk_t * p ) void Abc_NtkComputePaths( Abc_Ntk_t * p )
...@@ -310,10 +320,10 @@ void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj ) ...@@ -310,10 +320,10 @@ void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj )
// assuming that level of the new nodes is up to date // assuming that level of the new nodes is up to date
Vec_Int_t * vTfi = Acb_ObjCollectTfi( p, iObj, 1 ); Vec_Int_t * vTfi = Acb_ObjCollectTfi( p, iObj, 1 );
Vec_Int_t * vTfo = Acb_ObjCollectTfo( p, iObj, 1 ); Vec_Int_t * vTfo = Acb_ObjCollectTfo( p, iObj, 1 );
int nLevelD = Acb_NtkComputeLevelD( p, vTfo ); Acb_NtkComputeLevelD( p, vTfo );
int nLevelR = Acb_NtkComputeLevelR( p, vTfi ); Acb_NtkComputeLevelR( p, vTfi );
int nPathD = Acb_NtkComputePathsD( p, vTfo ); Acb_NtkComputePathsD( p, vTfo );
int nPathR = Acb_NtkComputePathsR( p, vTfi ); Acb_NtkComputePathsR( p, vTfi );
Vec_IntForEachEntry( vTfi, Entry, i ) Vec_IntForEachEntry( vTfi, Entry, i )
Acb_ObjUpdateTiming( p, Entry ); Acb_ObjUpdateTiming( p, Entry );
Vec_IntForEachEntry( vTfo, Entry, i ) Vec_IntForEachEntry( vTfo, Entry, i )
...@@ -321,16 +331,40 @@ void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj ) ...@@ -321,16 +331,40 @@ void Acb_NtkUpdateTiming( Acb_Ntk_t * p, int iObj )
} }
else else
{ {
int LevelD = Acb_NtkComputeLevelD( p, NULL ); Acb_NtkComputeLevelD( p, NULL );
int LevelR = Acb_NtkComputeLevelR( p, NULL ); Acb_NtkComputeLevelR( p, NULL );
int PathD = Acb_NtkComputePathsD( p, NULL ); Acb_NtkComputePathsD( p, NULL );
int PathR = Acb_NtkComputePathsR( p, NULL ); Acb_NtkComputePathsR( p, NULL );
Acb_NtkForEachNode( p, Entry ) Acb_NtkForEachNode( p, Entry )
Acb_ObjUpdateTiming( p, Entry ); Acb_ObjUpdateTiming( p, Entry );
} }
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Acb_NtkUpdateNode( Acb_Ntk_t * p, int Pivot, word uTruth, Vec_Int_t * vSupp )
{
int i, iFanin;
Vec_WrdSetEntry( &p->vObjTruth, Pivot, uTruth );
Acb_ObjRemoveFanout( p, Pivot );
Acb_ObjRemoveFanins( p, Pivot );
Vec_IntForEachEntry( vSupp, iFanin, i )
Acb_ObjAddFanin( p, Pivot, iFanin );
Acb_ObjAddFanout( p, Pivot );
Acb_NtkUpdateTiming( p, Pivot );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -855,7 +855,7 @@ int Sdb_StoDiffExactlyOne3( Vec_Wec_t * vCuts, int Limit, int * pCut, int * pCou ...@@ -855,7 +855,7 @@ int Sdb_StoDiffExactlyOne3( Vec_Wec_t * vCuts, int Limit, int * pCut, int * pCou
} }
Vec_Int_t * Sdb_StoFindAll( Vec_Wec_t * vCuts ) Vec_Int_t * Sdb_StoFindAll( Vec_Wec_t * vCuts )
{ {
int i, k, Entry, iNew = -1; int i, k, Entry;
Vec_Int_t * vCut, * vAll = Vec_IntAlloc( 100 ); Vec_Int_t * vCut, * vAll = Vec_IntAlloc( 100 );
Vec_WecForEachLevel( vCuts, vCut, i ) Vec_WecForEachLevel( vCuts, vCut, i )
Vec_IntForEachEntry( vCut, Entry, k ) Vec_IntForEachEntry( vCut, Entry, k )
......
...@@ -156,7 +156,8 @@ extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, ...@@ -156,7 +156,8 @@ extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses,
extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p ); extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p );
extern void Cnf_DataFree( Cnf_Dat_t * p ); extern void Cnf_DataFree( Cnf_Dat_t * p );
extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus ); extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus );
extern void Cnf_DataFlipLastLiteral( Cnf_Dat_t * p ); extern Vec_Int_t * Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar );
extern void Cnf_DataLiftAndFlipLits( Cnf_Dat_t * p, int nVarsPlus, Vec_Int_t * vLits );
extern void Cnf_DataPrint( Cnf_Dat_t * p, int fReadable ); extern void Cnf_DataPrint( Cnf_Dat_t * p, int fReadable );
extern void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable, Vec_Int_t * vForAlls, Vec_Int_t * vExists ); extern void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable, Vec_Int_t * vForAlls, Vec_Int_t * vExists );
extern void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p, int nFrames, int fInit ); extern void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p, int nFrames, int fInit );
......
...@@ -193,7 +193,7 @@ void Cnf_DataFree( Cnf_Dat_t * p ) ...@@ -193,7 +193,7 @@ void Cnf_DataFree( Cnf_Dat_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Writes CNF into a file.] Synopsis []
Description [] Description []
...@@ -215,26 +215,26 @@ void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus ) ...@@ -215,26 +215,26 @@ void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus )
for ( v = 0; v < p->nLiterals; v++ ) for ( v = 0; v < p->nLiterals; v++ )
p->pClauses[0][v] += 2*nVarsPlus; p->pClauses[0][v] += 2*nVarsPlus;
} }
Vec_Int_t * Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar )
/**Function*************************************************************
Synopsis [Writes CNF into a file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cnf_DataFlipLastLiteral( Cnf_Dat_t * p )
{ {
p->pClauses[0][p->nLiterals-1] = lit_neg( p->pClauses[0][p->nLiterals-1] ); Vec_Int_t * vLits = Vec_IntAlloc( 100 ); int v;
assert( p->pMan == NULL );
for ( v = 0; v < p->nLiterals; v++ )
if ( Abc_Lit2Var(p->pClauses[0][v]) == iFlipVar )
Vec_IntPush( vLits, v );
return vLits;
}
void Cnf_DataLiftAndFlipLits( Cnf_Dat_t * p, int nVarsPlus, Vec_Int_t * vLits )
{
int i, iLit;
assert( p->pMan == NULL );
Vec_IntForEachEntry( vLits, iLit, i )
p->pClauses[0][iLit] = Abc_LitNot(p->pClauses[0][iLit]) + 2*nVarsPlus;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Writes CNF into a file.] Synopsis []
Description [] Description []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment