Commit 616bb095 by Alan Mishchenko

Version abc60701

parent 38141217
...@@ -42,7 +42,7 @@ RSC=rc.exe ...@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\ft" /I "src\sat\aig" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\map\fpga" /I "src\map\pga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\temp\ivy" /I "src\temp\esop" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\ft" /I "src\sat\aig" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\map\fpga" /I "src\map\pga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\temp\ivy" /I "src\temp\esop" /I "src\temp\rwt" /I "src\temp\deco" /I "src\temp\mem" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
...@@ -50,7 +50,7 @@ BSC32=bscmake.exe ...@@ -50,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"_TEST/abc.exe" # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /profile /machine:I386 /out:"_TEST/abc.exe"
!ELSEIF "$(CFG)" == "abc - Win32 Debug" !ELSEIF "$(CFG)" == "abc - Win32 Debug"
...@@ -66,7 +66,7 @@ LINK32=link.exe ...@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\ft" /I "src\sat\aig" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\map\fpga" /I "src\map\pga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\temp\ivy" /I "src\temp\esop" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\ft" /I "src\sat\aig" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\map\fpga" /I "src\map\pga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\temp\ivy" /I "src\temp\esop" /I "src\temp\rwt" /I "src\temp\deco" /I "src\temp\mem" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /GZ /c
# SUBTRACT CPP /X # SUBTRACT CPP /X
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
...@@ -2114,6 +2114,10 @@ SOURCE=.\src\temp\ivy\ivyMulti.c ...@@ -2114,6 +2114,10 @@ SOURCE=.\src\temp\ivy\ivyMulti.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\temp\ivy\ivyMulti8.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyObj.c SOURCE=.\src\temp\ivy\ivyObj.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -2122,10 +2126,22 @@ SOURCE=.\src\temp\ivy\ivyOper.c ...@@ -2122,10 +2126,22 @@ SOURCE=.\src\temp\ivy\ivyOper.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\temp\ivy\ivyResyn.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyRewrite.c SOURCE=.\src\temp\ivy\ivyRewrite.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\temp\ivy\ivyRwrAlg.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyRwrPre.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivySeq.c SOURCE=.\src\temp\ivy\ivySeq.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -2182,10 +2198,6 @@ SOURCE=.\src\temp\esop\esopMan.c ...@@ -2182,10 +2198,6 @@ SOURCE=.\src\temp\esop\esopMan.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\temp\esop\esopMem.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\esop\esopMin.c SOURCE=.\src\temp\esop\esopMin.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -2237,6 +2249,46 @@ SOURCE=.\src\temp\xyz\xyzMinUtil.c ...@@ -2237,6 +2249,46 @@ SOURCE=.\src\temp\xyz\xyzMinUtil.c
SOURCE=.\src\temp\xyz\xyzTest.c SOURCE=.\src\temp\xyz\xyzTest.c
# End Source File # End Source File
# End Group # End Group
# Begin Group "rwt"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\temp\rwt\rwt.h
# End Source File
# Begin Source File
SOURCE=.\src\temp\rwt\rwtDec.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\rwt\rwtMan.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\rwt\rwtUtil.c
# End Source File
# End Group
# Begin Group "deco"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\temp\deco\deco.h
# End Source File
# End Group
# Begin Group "mem"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\temp\mem\mem.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\mem\mem.h
# End Source File
# End Group
# End Group # End Group
# End Group # End Group
# Begin Group "Header Files" # Begin Group "Header Files"
......
...@@ -4647,9 +4647,11 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4647,9 +4647,11 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
// Ivy_TruthTest(); // Ivy_TruthTest();
pNtkRes = Abc_NtkIvy( pNtk ); Ivy_TruthEstimateNodesTest();
// pNtkRes = Abc_NtkIvy( pNtk );
// pNtkRes = Abc_NtkPlayer( pNtk, nLevels, 0 ); // pNtkRes = Abc_NtkPlayer( pNtk, nLevels, 0 );
// pNtkRes = NULL; pNtkRes = NULL;
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
fprintf( pErr, "Command has failed.\n" ); fprintf( pErr, "Command has failed.\n" );
......
...@@ -110,7 +110,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ) ...@@ -110,7 +110,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
Vec_IntFree( vChoices ); Vec_IntFree( vChoices );
PRT( "Total", clock() - clk ); PRT( "Total", clock() - clk );
//Abc_NtkPrintCuts_( p, pNtk, 0 ); //Abc_NtkPrintCuts( p, pNtk, 0 );
// Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk ); // Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk );
// temporary printout of stats // temporary printout of stats
......
...@@ -53,7 +53,7 @@ extern char * Mio_GateReadSop( void * pGate ); ...@@ -53,7 +53,7 @@ extern char * Mio_GateReadSop( void * pGate );
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
{ {
Ivy_Man_t * pMan; Ivy_Man_t * pMan, * pTemp = NULL;
Abc_Ntk_t * pNtkAig; Abc_Ntk_t * pNtkAig;
int fCleanup = 1; int fCleanup = 1;
int nNodes; int nNodes;
...@@ -74,7 +74,6 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) ...@@ -74,7 +74,6 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
// convert to the AIG manager // convert to the AIG manager
pMan = Abc_NtkToAig( pNtk ); pMan = Abc_NtkToAig( pNtk );
if ( !Ivy_ManCheck( pMan ) ) if ( !Ivy_ManCheck( pMan ) )
{ {
printf( "AIG check has failed.\n" ); printf( "AIG check has failed.\n" );
...@@ -82,13 +81,29 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) ...@@ -82,13 +81,29 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
return NULL; return NULL;
} }
// Ivy_MffcTest( pMan ); // Ivy_MffcTest( pMan );
Ivy_ManPrintStats( pMan ); // Ivy_ManPrintStats( pMan );
// pMan = Ivy_ManBalance( pTemp = pMan, 1 );
// Ivy_ManStop( pTemp );
// Ivy_ManSeqRewrite( pMan, 0, 0 ); // Ivy_ManSeqRewrite( pMan, 0, 0 );
// Ivy_ManTestCutsAlg( pMan ); // Ivy_ManTestCutsAlg( pMan );
Ivy_ManTestCutsBool( pMan ); // Ivy_ManTestCutsBool( pMan );
Ivy_ManPrintStats( pMan ); // Ivy_ManRewriteAlg( pMan, 1, 1 );
// pMan = Ivy_ManResyn( pTemp = pMan, 1 );
// Ivy_ManStop( pTemp );
// Ivy_ManTestCutsAll( pMan );
// Ivy_ManPrintStats( pMan );
// Ivy_ManPrintStats( pMan );
// Ivy_ManRewritePre( pMan, 1, 0, 0 );
// Ivy_ManPrintStats( pMan );
// Ivy_ManRequiredLevels( pMan );
// convert from the AIG manager // convert from the AIG manager
pNtkAig = Abc_NtkFromAig( pNtk, pMan ); pNtkAig = Abc_NtkFromAig( pNtk, pMan );
...@@ -191,9 +206,9 @@ Ivy_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtkOld ) ...@@ -191,9 +206,9 @@ Ivy_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtkOld )
// create the manager // create the manager
assert( Abc_NtkHasSop(pNtkOld) || Abc_NtkHasAig(pNtkOld) ); assert( Abc_NtkHasSop(pNtkOld) || Abc_NtkHasAig(pNtkOld) );
if ( Abc_NtkHasSop(pNtkOld) ) if ( Abc_NtkHasSop(pNtkOld) )
pMan = Ivy_ManStart( Abc_NtkCiNum(pNtkOld), Abc_NtkCoNum(pNtkOld), 3 * Abc_NtkGetLitNum(pNtkOld) + 10 ); pMan = Ivy_ManStart( Abc_NtkCiNum(pNtkOld), Abc_NtkCoNum(pNtkOld), Abc_NtkGetLitNum(pNtkOld) + 1000 );
else else
pMan = Ivy_ManStart( Abc_NtkCiNum(pNtkOld), Abc_NtkCoNum(pNtkOld), 3 * Abc_NtkNodeNum(pNtkOld) + 10 ); pMan = Ivy_ManStart( Abc_NtkCiNum(pNtkOld), Abc_NtkCoNum(pNtkOld), Abc_NtkNodeNum(pNtkOld) + 1000 );
// create the PIs // create the PIs
Abc_NtkConst1(pNtkOld)->pCopy = (Abc_Obj_t *)Ivy_ManConst1(pMan); Abc_NtkConst1(pNtkOld)->pCopy = (Abc_Obj_t *)Ivy_ManConst1(pMan);
Abc_NtkForEachCi( pNtkOld, pObj, i ) Abc_NtkForEachCi( pNtkOld, pObj, i )
......
...@@ -135,7 +135,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -135,7 +135,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
} }
*/ */
/*
// print the statistic into a file // print the statistic into a file
{ {
FILE * pTable; FILE * pTable;
...@@ -146,6 +146,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -146,6 +146,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
fprintf( pTable, "\n" ); fprintf( pTable, "\n" );
fclose( pTable ); fclose( pTable );
} }
*/
/* /*
// print the statistic into a file // print the statistic into a file
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
***********************************************************************/ ***********************************************************************/
#include "stdio.h" #include <stdio.h>
#include "extra.h" #include "extra.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
***********************************************************************/ ***********************************************************************/
#include "stdio.h" #include <stdio.h>
#include "extra.h" #include "extra.h"
#include "vec.h" #include "vec.h"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
***********************************************************************/ ***********************************************************************/
#include "stdio.h" #include <stdio.h>
#include "extra.h" #include "extra.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -325,6 +325,7 @@ static inline void Vec_IntAddToEntry( Vec_Int_t * p, int i, int Addition ) ...@@ -325,6 +325,7 @@ static inline void Vec_IntAddToEntry( Vec_Int_t * p, int i, int Addition )
***********************************************************************/ ***********************************************************************/
static inline int Vec_IntEntryLast( Vec_Int_t * p ) static inline int Vec_IntEntryLast( Vec_Int_t * p )
{ {
assert( p->nSize > 0 );
return p->pArray[p->nSize-1]; return p->pArray[p->nSize-1];
} }
......
...@@ -312,6 +312,7 @@ static inline void Vec_PtrWriteEntry( Vec_Ptr_t * p, int i, void * Entry ) ...@@ -312,6 +312,7 @@ static inline void Vec_PtrWriteEntry( Vec_Ptr_t * p, int i, void * Entry )
***********************************************************************/ ***********************************************************************/
static inline void * Vec_PtrEntryLast( Vec_Ptr_t * p ) static inline void * Vec_PtrEntryLast( Vec_Ptr_t * p )
{ {
assert( p->nSize > 0 );
return p->pArray[p->nSize-1]; return p->pArray[p->nSize-1];
} }
......
...@@ -303,6 +303,7 @@ static inline void Vec_StrWriteEntry( Vec_Str_t * p, int i, char Entry ) ...@@ -303,6 +303,7 @@ static inline void Vec_StrWriteEntry( Vec_Str_t * p, int i, char Entry )
***********************************************************************/ ***********************************************************************/
static inline char Vec_StrEntryLast( Vec_Str_t * p ) static inline char Vec_StrEntryLast( Vec_Str_t * p )
{ {
assert( p->nSize > 0 );
return p->pArray[p->nSize-1]; return p->pArray[p->nSize-1];
} }
......
...@@ -71,6 +71,9 @@ struct Vec_Vec_t_ ...@@ -71,6 +71,9 @@ struct Vec_Vec_t_
#define Vec_VecForEachEntryReverse( vGlob, pEntry, i, k ) \ #define Vec_VecForEachEntryReverse( vGlob, pEntry, i, k ) \
for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \ for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k ) Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
#define Vec_VecForEachEntryReverseReverse( vGlob, pEntry, i, k ) \
for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
......
...@@ -104,6 +104,36 @@ static inline void Cut_CutFilter( Cut_Man_t * p, Cut_Cut_t * pList ) ...@@ -104,6 +104,36 @@ static inline void Cut_CutFilter( Cut_Man_t * p, Cut_Cut_t * pList )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Checks equality of one cut.]
Description [Returns 1 if the cut is removed.]
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Cut_CutFilterOneEqual( Cut_Man_t * p, Cut_List_t * pSuperList, Cut_Cut_t * pCut )
{
Cut_Cut_t * pTemp;
Cut_ListForEachCut( pSuperList->pHead[pCut->nLeaves], pTemp )
{
// skip the non-contained cuts
if ( pCut->uSign != pTemp->uSign )
continue;
// check containment seriously
if ( Cut_CutCheckDominance( pTemp, pCut ) )
{
p->nCutsFilter++;
Cut_CutRecycle( p, pCut );
return 1;
}
}
return 0;
}
/**Function*************************************************************
Synopsis [Checks containment for one cut.] Synopsis [Checks containment for one cut.]
Description [Returns 1 if the cut is removed.] Description [Returns 1 if the cut is removed.]
...@@ -266,6 +296,7 @@ static inline int Cut_CutProcessTwo( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t ...@@ -266,6 +296,7 @@ static inline int Cut_CutProcessTwo( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t
if ( p->pParams->fFilter ) if ( p->pParams->fFilter )
{ {
if ( Cut_CutFilterOne(p, pSuperList, pCut) ) if ( Cut_CutFilterOne(p, pSuperList, pCut) )
// if ( Cut_CutFilterOneEqual(p, pSuperList, pCut) )
return 0; return 0;
if ( p->pParams->fSeq ) if ( p->pParams->fSeq )
{ {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCut, Vec_Ptr_t * vFaninsCur, int nNodesSaved, int LevelMax, int * pGainBest ); static Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCut, Vec_Ptr_t * vFaninsCur, int nNodesSaved, int LevelMax, int * pGainBest );
static int Rwr_CutIsBoolean( Abc_Obj_t * pObj, Vec_Ptr_t * vLeaves );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -64,6 +65,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int ...@@ -64,6 +65,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int
p->nNodesConsidered++; p->nNodesConsidered++;
// get the required times // get the required times
Required = fUpdateLevel? Abc_NodeReadRequiredLevel(pNode) : ABC_INFINITY; Required = fUpdateLevel? Abc_NodeReadRequiredLevel(pNode) : ABC_INFINITY;
// get the node's cuts // get the node's cuts
clk = clock(); clk = clock();
pCut = (Cut_Cut_t *)Abc_NodeGetCutsRecursive( pManCut, pNode, 0, 0 ); pCut = (Cut_Cut_t *)Abc_NodeGetCutsRecursive( pManCut, pNode, 0, 0 );
...@@ -77,6 +79,9 @@ clk = clock(); ...@@ -77,6 +79,9 @@ clk = clock();
// consider only 4-input cuts // consider only 4-input cuts
if ( pCut->nLeaves < 4 ) if ( pCut->nLeaves < 4 )
continue; continue;
// if ( pNode->Id == 82 )
// Cut_CutPrint( pCut, 0 ), printf( "\n" );
// get the fanin permutation // get the fanin permutation
uTruth = 0xFFFF & *Cut_CutReadTruth(pCut); uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
pPerm = p->pPerms4[ p->pPerms[uTruth] ]; pPerm = p->pPerms4[ p->pPerms[uTruth] ];
...@@ -144,6 +149,27 @@ p->timeRes += clock() - clk; ...@@ -144,6 +149,27 @@ p->timeRes += clock() - clk;
return -1; return -1;
// printf( "%d", nNodesSaveCur - GainBest ); // printf( "%d", nNodesSaveCur - GainBest );
/*
if ( GainBest > 0 )
{
if ( Rwr_CutIsBoolean( pNode, p->vFanins ) )
printf( "b" );
else
{
printf( "Node %d : ", pNode->Id );
Vec_PtrForEachEntry( p->vFanins, pFanin, i )
printf( "%d ", Abc_ObjRegular(pFanin)->Id );
printf( "a" );
}
}
*/
/*
if ( GainBest > 0 )
if ( p->fCompl )
printf( "c" );
else
printf( "." );
*/
// copy the leaves // copy the leaves
Vec_PtrForEachEntry( p->vFanins, pFanin, i ) Vec_PtrForEachEntry( p->vFanins, pFanin, i )
...@@ -221,6 +247,65 @@ Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCu ...@@ -221,6 +247,65 @@ Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCu
return pGraphBest; return pGraphBest;
} }
/**Function*************************************************************
Synopsis [Checks the type of the cut.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwr_CutIsBoolean_rec( Abc_Obj_t * pObj, Vec_Ptr_t * vLeaves, int fMarkA )
{
if ( Vec_PtrFind(vLeaves, pObj) >= 0 || Vec_PtrFind(vLeaves, Abc_ObjNot(pObj)) >= 0 )
{
if ( fMarkA )
pObj->fMarkA = 1;
else
pObj->fMarkB = 1;
return;
}
assert( !Abc_ObjIsCi(pObj) );
Rwr_CutIsBoolean_rec( Abc_ObjFanin0(pObj), vLeaves, fMarkA );
Rwr_CutIsBoolean_rec( Abc_ObjFanin1(pObj), vLeaves, fMarkA );
}
/**Function*************************************************************
Synopsis [Checks the type of the cut.]
Description [Returns 1(0) if the cut is Boolean (algebraic).]
SideEffects []
SeeAlso []
***********************************************************************/
int Rwr_CutIsBoolean( Abc_Obj_t * pObj, Vec_Ptr_t * vLeaves )
{
Abc_Obj_t * pTemp;
int i, RetValue;
Vec_PtrForEachEntry( vLeaves, pTemp, i )
{
pTemp = Abc_ObjRegular(pTemp);
assert( !pTemp->fMarkA && !pTemp->fMarkB );
}
Rwr_CutIsBoolean_rec( Abc_ObjFanin0(pObj), vLeaves, 1 );
Rwr_CutIsBoolean_rec( Abc_ObjFanin1(pObj), vLeaves, 0 );
RetValue = 0;
Vec_PtrForEachEntry( vLeaves, pTemp, i )
{
pTemp = Abc_ObjRegular(pTemp);
RetValue |= pTemp->fMarkA && pTemp->fMarkB;
pTemp->fMarkA = pTemp->fMarkB = 0;
}
return RetValue;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
extern "C" { extern "C" {
#endif #endif
#include "stdio.h" #include <stdio.h>
#include "vec.h" #include "vec.h"
#include "mem.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// DECLARATIONS /// /// DECLARATIONS ///
...@@ -34,16 +35,16 @@ extern "C" { ...@@ -34,16 +35,16 @@ extern "C" {
typedef struct Esop_Man_t_ Esop_Man_t; typedef struct Esop_Man_t_ Esop_Man_t;
typedef struct Esop_Cube_t_ Esop_Cube_t; typedef struct Esop_Cube_t_ Esop_Cube_t;
typedef struct Esop_MmFixed_t_ Esop_MmFixed_t; typedef struct Mem_Fixed_t_ Mem_Fixed_t;
struct Esop_Man_t_ struct Esop_Man_t_
{ {
int nVars; // the number of vars int nVars; // the number of vars
int nWords; // the number of words int nWords; // the number of words
Esop_MmFixed_t * pMemMan1; // memory manager for cubes Mem_Fixed_t * pMemMan1; // memory manager for cubes
Esop_MmFixed_t * pMemMan2; // memory manager for cubes Mem_Fixed_t * pMemMan2; // memory manager for cubes
Esop_MmFixed_t * pMemMan4; // memory manager for cubes Mem_Fixed_t * pMemMan4; // memory manager for cubes
Esop_MmFixed_t * pMemMan8; // memory manager for cubes Mem_Fixed_t * pMemMan8; // memory manager for cubes
// temporary cubes // temporary cubes
Esop_Cube_t * pOne0; // tautology cube Esop_Cube_t * pOne0; // tautology cube
Esop_Cube_t * pOne1; // tautology cube Esop_Cube_t * pOne1; // tautology cube
...@@ -99,12 +100,12 @@ static inline void Esop_CubeXorVar( Esop_Cube_t * p, int Var, int Value ) { p- ...@@ -99,12 +100,12 @@ static inline void Esop_CubeXorVar( Esop_Cube_t * p, int Var, int Value ) { p-
static inline int Esop_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); } static inline int Esop_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
/*=== esopMem.c ===========================================================*/ /*=== esopMem.c ===========================================================*/
extern Esop_MmFixed_t * Esop_MmFixedStart( int nEntrySize ); extern Mem_Fixed_t * Mem_FixedStart( int nEntrySize );
extern void Esop_MmFixedStop( Esop_MmFixed_t * p, int fVerbose ); extern void Mem_FixedStop( Mem_Fixed_t * p, int fVerbose );
extern char * Esop_MmFixedEntryFetch( Esop_MmFixed_t * p ); extern char * Mem_FixedEntryFetch( Mem_Fixed_t * p );
extern void Esop_MmFixedEntryRecycle( Esop_MmFixed_t * p, char * pEntry ); extern void Mem_FixedEntryRecycle( Mem_Fixed_t * p, char * pEntry );
extern void Esop_MmFixedRestart( Esop_MmFixed_t * p ); extern void Mem_FixedRestart( Mem_Fixed_t * p );
extern int Esop_MmFixedReadMemUsage( Esop_MmFixed_t * p ); extern int Mem_FixedReadMemUsage( Mem_Fixed_t * p );
/*=== esopMin.c ===========================================================*/ /*=== esopMin.c ===========================================================*/
extern void Esop_EsopMinimize( Esop_Man_t * p ); extern void Esop_EsopMinimize( Esop_Man_t * p );
extern void Esop_EsopAddCube( Esop_Man_t * p, Esop_Cube_t * pCube ); extern void Esop_EsopAddCube( Esop_Man_t * p, Esop_Cube_t * pCube );
...@@ -142,13 +143,13 @@ static inline Esop_Cube_t * Esop_CubeAlloc( Esop_Man_t * p ) ...@@ -142,13 +143,13 @@ static inline Esop_Cube_t * Esop_CubeAlloc( Esop_Man_t * p )
{ {
Esop_Cube_t * pCube; Esop_Cube_t * pCube;
if ( p->nWords <= 1 ) if ( p->nWords <= 1 )
pCube = (Esop_Cube_t *)Esop_MmFixedEntryFetch( p->pMemMan1 ); pCube = (Esop_Cube_t *)Mem_FixedEntryFetch( p->pMemMan1 );
else if ( p->nWords <= 2 ) else if ( p->nWords <= 2 )
pCube = (Esop_Cube_t *)Esop_MmFixedEntryFetch( p->pMemMan2 ); pCube = (Esop_Cube_t *)Mem_FixedEntryFetch( p->pMemMan2 );
else if ( p->nWords <= 4 ) else if ( p->nWords <= 4 )
pCube = (Esop_Cube_t *)Esop_MmFixedEntryFetch( p->pMemMan4 ); pCube = (Esop_Cube_t *)Mem_FixedEntryFetch( p->pMemMan4 );
else if ( p->nWords <= 8 ) else if ( p->nWords <= 8 )
pCube = (Esop_Cube_t *)Esop_MmFixedEntryFetch( p->pMemMan8 ); pCube = (Esop_Cube_t *)Mem_FixedEntryFetch( p->pMemMan8 );
pCube->pNext = NULL; pCube->pNext = NULL;
pCube->nVars = p->nVars; pCube->nVars = p->nVars;
pCube->nWords = p->nWords; pCube->nWords = p->nWords;
...@@ -211,13 +212,13 @@ static inline Esop_Cube_t * Esop_CubeDup( Esop_Man_t * p, Esop_Cube_t * pCopy ) ...@@ -211,13 +212,13 @@ static inline Esop_Cube_t * Esop_CubeDup( Esop_Man_t * p, Esop_Cube_t * pCopy )
static inline void Esop_CubeRecycle( Esop_Man_t * p, Esop_Cube_t * pCube ) static inline void Esop_CubeRecycle( Esop_Man_t * p, Esop_Cube_t * pCube )
{ {
if ( pCube->nWords <= 1 ) if ( pCube->nWords <= 1 )
Esop_MmFixedEntryRecycle( p->pMemMan1, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan1, (char *)pCube );
else if ( pCube->nWords <= 2 ) else if ( pCube->nWords <= 2 )
Esop_MmFixedEntryRecycle( p->pMemMan2, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan2, (char *)pCube );
else if ( pCube->nWords <= 4 ) else if ( pCube->nWords <= 4 )
Esop_MmFixedEntryRecycle( p->pMemMan4, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan4, (char *)pCube );
else if ( pCube->nWords <= 8 ) else if ( pCube->nWords <= 8 )
Esop_MmFixedEntryRecycle( p->pMemMan8, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan8, (char *)pCube );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -238,16 +239,16 @@ static inline void Esop_CoverRecycle( Esop_Man_t * p, Esop_Cube_t * pCover ) ...@@ -238,16 +239,16 @@ static inline void Esop_CoverRecycle( Esop_Man_t * p, Esop_Cube_t * pCover )
return; return;
if ( pCover->nWords <= 1 ) if ( pCover->nWords <= 1 )
Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 ) Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 )
Esop_MmFixedEntryRecycle( p->pMemMan1, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan1, (char *)pCube );
else if ( pCover->nWords <= 2 ) else if ( pCover->nWords <= 2 )
Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 ) Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 )
Esop_MmFixedEntryRecycle( p->pMemMan2, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan2, (char *)pCube );
else if ( pCover->nWords <= 4 ) else if ( pCover->nWords <= 4 )
Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 ) Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 )
Esop_MmFixedEntryRecycle( p->pMemMan4, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan4, (char *)pCube );
else if ( pCover->nWords <= 8 ) else if ( pCover->nWords <= 8 )
Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 ) Esop_CoverForEachCubeSafe( pCover, pCube, pCube2 )
Esop_MmFixedEntryRecycle( p->pMemMan8, (char *)pCube ); Mem_FixedEntryRecycle( p->pMemMan8, (char *)pCube );
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -47,10 +47,10 @@ Esop_Man_t * Esop_ManAlloc( int nVars ) ...@@ -47,10 +47,10 @@ Esop_Man_t * Esop_ManAlloc( int nVars )
memset( pMan, 0, sizeof(Esop_Man_t) ); memset( pMan, 0, sizeof(Esop_Man_t) );
pMan->nVars = nVars; pMan->nVars = nVars;
pMan->nWords = Esop_BitWordNum( nVars * 2 ); pMan->nWords = Esop_BitWordNum( nVars * 2 );
pMan->pMemMan1 = Esop_MmFixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (1 - 1) ); pMan->pMemMan1 = Mem_FixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (1 - 1) );
pMan->pMemMan2 = Esop_MmFixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (2 - 1) ); pMan->pMemMan2 = Mem_FixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (2 - 1) );
pMan->pMemMan4 = Esop_MmFixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (4 - 1) ); pMan->pMemMan4 = Mem_FixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (4 - 1) );
pMan->pMemMan8 = Esop_MmFixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (8 - 1) ); pMan->pMemMan8 = Mem_FixedStart( sizeof(Esop_Cube_t) + sizeof(unsigned) * (8 - 1) );
// allocate storage for the temporary cover // allocate storage for the temporary cover
pMan->ppStore = ALLOC( Esop_Cube_t *, pMan->nVars + 1 ); pMan->ppStore = ALLOC( Esop_Cube_t *, pMan->nVars + 1 );
// create tautology cubes // create tautology cubes
...@@ -101,10 +101,10 @@ void Esop_ManClean( Esop_Man_t * p, int nSupp ) ...@@ -101,10 +101,10 @@ void Esop_ManClean( Esop_Man_t * p, int nSupp )
***********************************************************************/ ***********************************************************************/
void Esop_ManFree( Esop_Man_t * p ) void Esop_ManFree( Esop_Man_t * p )
{ {
Esop_MmFixedStop ( p->pMemMan1, 0 ); Mem_FixedStop ( p->pMemMan1, 0 );
Esop_MmFixedStop ( p->pMemMan2, 0 ); Mem_FixedStop ( p->pMemMan2, 0 );
Esop_MmFixedStop ( p->pMemMan4, 0 ); Mem_FixedStop ( p->pMemMan4, 0 );
Esop_MmFixedStop ( p->pMemMan8, 0 ); Mem_FixedStop ( p->pMemMan8, 0 );
free( p->ppStore ); free( p->ppStore );
free( p ); free( p );
} }
......
SRC += src/temp/esop/esopMan.c \ SRC += src/temp/esop/esopMan.c \
src/temp/esop/esopMem.c \
src/temp/esop/esopMin.c \ src/temp/esop/esopMin.c \
src/temp/esop/esopUtil.c src/temp/esop/esopUtil.c
...@@ -69,6 +69,9 @@ Vec_Int_t * Ivy_ManDfs( Ivy_Man_t * p ) ...@@ -69,6 +69,9 @@ Vec_Int_t * Ivy_ManDfs( Ivy_Man_t * p )
Vec_Int_t * vNodes; Vec_Int_t * vNodes;
Ivy_Obj_t * pObj; Ivy_Obj_t * pObj;
int i; int i;
// make sure the nodes are not marked
Ivy_ManForEachObj( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
// collect the nodes // collect the nodes
vNodes = Vec_IntAlloc( Ivy_ManNodeNum(p) ); vNodes = Vec_IntAlloc( Ivy_ManNodeNum(p) );
if ( Ivy_ManLatchNum(p) > 0 ) if ( Ivy_ManLatchNum(p) > 0 )
...@@ -107,7 +110,7 @@ void Ivy_ManDfsExt_rec( Ivy_Obj_t * pObj, Vec_Int_t * vNodes ) ...@@ -107,7 +110,7 @@ void Ivy_ManDfsExt_rec( Ivy_Obj_t * pObj, Vec_Int_t * vNodes )
// traverse the fanins // traverse the fanins
vFanins = Ivy_ObjGetFanins( pObj ); vFanins = Ivy_ObjGetFanins( pObj );
Vec_IntForEachEntry( vFanins, Fanin, i ) Vec_IntForEachEntry( vFanins, Fanin, i )
Ivy_ManDfsExt_rec( Ivy_ObjObj(pObj, Ivy_FanId(Fanin)), vNodes ); Ivy_ManDfsExt_rec( Ivy_ObjObj(pObj, Ivy_EdgeId(Fanin)), vNodes );
// add the node // add the node
Vec_IntPush( vNodes, pObj->Id ); Vec_IntPush( vNodes, pObj->Id );
} }
...@@ -134,7 +137,7 @@ Vec_Int_t * Ivy_ManDfsExt( Ivy_Man_t * p ) ...@@ -134,7 +137,7 @@ Vec_Int_t * Ivy_ManDfsExt( Ivy_Man_t * p )
vNodes = Vec_IntAlloc( 10 ); vNodes = Vec_IntAlloc( 10 );
Ivy_ManForEachPo( p, pObj, i ) Ivy_ManForEachPo( p, pObj, i )
{ {
pFanin = Ivy_ManObj( p, Ivy_FanId( Ivy_ObjReadFanin(pObj,0) ) ); pFanin = Ivy_ManObj( p, Ivy_EdgeId( Ivy_ObjReadFanin(pObj,0) ) );
Ivy_ManDfsExt_rec( pFanin, vNodes ); Ivy_ManDfsExt_rec( pFanin, vNodes );
} }
Ivy_ManForEachNodeVec( p, vNodes, pObj, i ) Ivy_ManForEachNodeVec( p, vNodes, pObj, i )
...@@ -145,6 +148,132 @@ Vec_Int_t * Ivy_ManDfsExt( Ivy_Man_t * p ) ...@@ -145,6 +148,132 @@ Vec_Int_t * Ivy_ManDfsExt( Ivy_Man_t * p )
return vNodes; return vNodes;
} }
/**Function*************************************************************
Synopsis [Collects nodes in the cone.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_ManCollectCone_rec( Ivy_Obj_t * pObj, Vec_Ptr_t * vCone )
{
if ( pObj->fMarkA )
return;
if ( Ivy_ObjIsBuf(pObj) )
{
Ivy_ManCollectCone_rec( Ivy_ObjFanin0(pObj), vCone );
Vec_PtrPush( vCone, pObj );
return;
}
assert( Ivy_ObjIsNode(pObj) );
Ivy_ManCollectCone_rec( Ivy_ObjFanin0(pObj), vCone );
Ivy_ManCollectCone_rec( Ivy_ObjFanin1(pObj), vCone );
Vec_PtrPushUnique( vCone, pObj );
}
/**Function*************************************************************
Synopsis [Collects nodes in the cone.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_ManCollectCone( Ivy_Obj_t * pObj, Vec_Ptr_t * vFront, Vec_Ptr_t * vCone )
{
Ivy_Obj_t * pTemp;
int i;
assert( !Ivy_IsComplement(pObj) );
assert( Ivy_ObjIsNode(pObj) );
// mark the nodes
Vec_PtrForEachEntry( vFront, pTemp, i )
Ivy_Regular(pTemp)->fMarkA = 1;
assert( pObj->fMarkA == 0 );
// collect the cone
Vec_PtrClear( vCone );
Ivy_ManCollectCone_rec( pObj, vCone );
// unmark the nodes
Vec_PtrForEachEntry( vFront, pTemp, i )
Ivy_Regular(pTemp)->fMarkA = 0;
}
/**Function*************************************************************
Synopsis [Returns the nodes by level.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Vec_t * Ivy_ManLevelize( Ivy_Man_t * p )
{
Vec_Vec_t * vNodes;
Ivy_Obj_t * pObj;
int i;
vNodes = Vec_VecAlloc( 100 );
Ivy_ManForEachObj( p, pObj, i )
{
assert( !Ivy_ObjIsBuf(pObj) );
if ( Ivy_ObjIsNode(pObj) )
Vec_VecPush( vNodes, pObj->Level, pObj );
}
return vNodes;
}
/**Function*************************************************************
Synopsis [Computes required levels for each node.]
Description [Assumes topological ordering of the nodes.]
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Ivy_ManRequiredLevels( Ivy_Man_t * p )
{
Ivy_Obj_t * pObj;
Vec_Int_t * vLevelsR;
Vec_Vec_t * vNodes;
int i, k, Level, LevelMax;
assert( p->vRequired == NULL );
// start the required times
vLevelsR = Vec_IntStart( Ivy_ManObjIdNext(p) );
// iterate through the nodes in the reverse order
vNodes = Ivy_ManLevelize( p );
Vec_VecForEachEntryReverseReverse( vNodes, pObj, i, k )
{
Level = Vec_IntEntry( vLevelsR, pObj->Id ) + 1 + Ivy_ObjIsExor(pObj);
if ( Vec_IntEntry( vLevelsR, Ivy_ObjFaninId0(pObj) ) < Level )
Vec_IntWriteEntry( vLevelsR, Ivy_ObjFaninId0(pObj), Level );
if ( Vec_IntEntry( vLevelsR, Ivy_ObjFaninId1(pObj) ) < Level )
Vec_IntWriteEntry( vLevelsR, Ivy_ObjFaninId1(pObj), Level );
}
Vec_VecFree( vNodes );
// convert it into the required times
LevelMax = Ivy_ManReadLevels( p );
//printf( "max %5d\n",LevelMax );
Ivy_ManForEachObj( p, pObj, i )
{
Level = Vec_IntEntry( vLevelsR, pObj->Id );
Vec_IntWriteEntry( vLevelsR, pObj->Id, LevelMax - Level );
//printf( "%5d : %5d %5d\n", pObj->Id, Level, LevelMax - Level );
}
p->vRequired = vLevelsR;
return vLevelsR;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -48,6 +48,7 @@ Ivy_Man_t * Ivy_ManStart( int nPis, int nPos, int nNodesMax ) ...@@ -48,6 +48,7 @@ Ivy_Man_t * Ivy_ManStart( int nPis, int nPos, int nNodesMax )
p = ALLOC( Ivy_Man_t, 1 ); p = ALLOC( Ivy_Man_t, 1 );
memset( p, 0, sizeof(Ivy_Man_t) ); memset( p, 0, sizeof(Ivy_Man_t) );
p->nTravIds = 1; p->nTravIds = 1;
p->fCatchExor = 1;
// AIG nodes // AIG nodes
p->nObjsAlloc = 1 + nPis + nPos + nNodesMax; p->nObjsAlloc = 1 + nPis + nPos + nNodesMax;
// p->nObjsAlloc += (p->nObjsAlloc & 1); // make it even // p->nObjsAlloc += (p->nObjsAlloc & 1); // make it even
...@@ -191,12 +192,13 @@ void Ivy_ManPrintStats( Ivy_Man_t * p ) ...@@ -191,12 +192,13 @@ void Ivy_ManPrintStats( Ivy_Man_t * p )
{ {
printf( "A = %d. ", Ivy_ManAndNum(p) ); printf( "A = %d. ", Ivy_ManAndNum(p) );
printf( "X = %d. ", Ivy_ManExorNum(p) ); printf( "X = %d. ", Ivy_ManExorNum(p) );
printf( "B = %d. ", Ivy_ManBufNum(p) ); printf( "B = %4d. ", Ivy_ManBufNum(p) );
} }
printf( "MaxID = %d. ", p->ObjIdNext-1 ); // printf( "MaxID = %d. ", p->ObjIdNext-1 );
printf( "All = %d. ", p->nObjsAlloc ); // printf( "All = %d. ", p->nObjsAlloc );
printf( "Cre = %d. ", p->nCreated ); printf( "Cre = %d. ", p->nCreated );
printf( "Del = %d. ", p->nDeleted ); printf( "Del = %d. ", p->nDeleted );
printf( "Lev = %d. ", Ivy_ManReadLevels(p) );
printf( "\n" ); printf( "\n" );
} }
......
...@@ -51,6 +51,7 @@ Ivy_Obj_t * Ivy_ObjCreate( Ivy_Obj_t * pGhost ) ...@@ -51,6 +51,7 @@ Ivy_Obj_t * Ivy_ObjCreate( Ivy_Obj_t * pGhost )
// realloc the node array // realloc the node array
if ( p->ObjIdNext == p->nObjsAlloc ) if ( p->ObjIdNext == p->nObjsAlloc )
{ {
printf( "AIG manager is being resized. In the current release, it is not allowed!\n" );
Ivy_ManGrow( p ); Ivy_ManGrow( p );
pGhost = Ivy_ManGhost( p ); pGhost = Ivy_ManGhost( p );
} }
......
...@@ -81,7 +81,7 @@ Ivy_Obj_t * Ivy_Oper( Ivy_Obj_t * p0, Ivy_Obj_t * p1, Ivy_Type_t Type ) ...@@ -81,7 +81,7 @@ Ivy_Obj_t * Ivy_Oper( Ivy_Obj_t * p0, Ivy_Obj_t * p1, Ivy_Type_t Type )
Ivy_Obj_t * Ivy_And( Ivy_Obj_t * p0, Ivy_Obj_t * p1 ) Ivy_Obj_t * Ivy_And( Ivy_Obj_t * p0, Ivy_Obj_t * p1 )
{ {
Ivy_Obj_t * pConst1 = Ivy_ObjConst1(Ivy_Regular(p0)); Ivy_Obj_t * pConst1 = Ivy_ObjConst1(Ivy_Regular(p0));
Ivy_Obj_t * pFan0, * pFan1; // Ivy_Obj_t * pFan0, * pFan1;
// check trivial cases // check trivial cases
if ( p0 == p1 ) if ( p0 == p1 )
return p0; return p0;
...@@ -92,8 +92,8 @@ Ivy_Obj_t * Ivy_And( Ivy_Obj_t * p0, Ivy_Obj_t * p1 ) ...@@ -92,8 +92,8 @@ Ivy_Obj_t * Ivy_And( Ivy_Obj_t * p0, Ivy_Obj_t * p1 )
if ( Ivy_Regular(p1) == pConst1 ) if ( Ivy_Regular(p1) == pConst1 )
return p1 == pConst1 ? p0 : Ivy_Not(pConst1); return p1 == pConst1 ? p0 : Ivy_Not(pConst1);
// check if it can be an EXOR gate // check if it can be an EXOR gate
if ( Ivy_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) ) // if ( Ivy_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
return Ivy_CanonExor( pFan0, pFan1 ); // return Ivy_CanonExor( pFan0, pFan1 );
return Ivy_CanonAnd( p0, p1 ); return Ivy_CanonAnd( p0, p1 );
} }
......
/**CFile****************************************************************
FileName [ivyResyn.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [And-Inverter Graph package.]
Synopsis [AIG rewriting script.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - May 11, 2006.]
Revision [$Id: ivyResyn.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ivy.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Performs several passes of rewriting on the AIG.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Man_t * Ivy_ManResyn( Ivy_Man_t * pMan, int fUpdateLevel )
{
int clk, fVerbose = 0;
Ivy_Man_t * pTemp;
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pMan, fUpdateLevel );
if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 0 );
clk = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, 0, 0 );
if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 1 );
clk = clock();
if ( fVerbose ) Ivy_ManRewritePre( pMan, fUpdateLevel, 1, 0 );
if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 1 );
clk = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, 1, 0 );
if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
return pMan;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -362,6 +362,222 @@ Vec_Int_t * Ivy_ManLatches( Ivy_Man_t * p ) ...@@ -362,6 +362,222 @@ Vec_Int_t * Ivy_ManLatches( Ivy_Man_t * p )
return vLatches; return vLatches;
} }
/**Function*************************************************************
Synopsis [Collect the latches.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ivy_ManReadLevels( Ivy_Man_t * p )
{
Ivy_Obj_t * pObj;
int i, LevelMax = 0;
Ivy_ManForEachPo( p, pObj, i )
{
pObj = Ivy_ObjFanin0(pObj);
LevelMax = IVY_MAX( LevelMax, (int)pObj->Level );
}
return LevelMax;
}
/**Function*************************************************************
Synopsis [Returns the real fanin.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Obj_t * Ivy_ObjReal( Ivy_Obj_t * pObj )
{
Ivy_Obj_t * pFanin;
if ( !Ivy_ObjIsBuf( Ivy_Regular(pObj) ) )
return pObj;
pFanin = Ivy_ObjReal( Ivy_ObjChild0(Ivy_Regular(pObj)) );
return Ivy_NotCond( pFanin, Ivy_IsComplement(pObj) );
}
/**Function*************************************************************
Synopsis [Checks if the cube has exactly one 1.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Ivy_TruthHasOneOne( unsigned uCube )
{
return (uCube & (uCube - 1)) == 0;
}
/**Function*************************************************************
Synopsis [Checks if two cubes are distance-1.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Ivy_TruthCubesDist1( unsigned uCube1, unsigned uCube2 )
{
unsigned uTemp = uCube1 | uCube2;
return Ivy_TruthHasOneOne( (uTemp >> 1) & uTemp & 0x55555555 );
}
/**Function*************************************************************
Synopsis [Checks if two cubes differ in only one literal.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Ivy_TruthCubesDiff1( unsigned uCube1, unsigned uCube2 )
{
unsigned uTemp = uCube1 ^ uCube2;
return Ivy_TruthHasOneOne( ((uTemp >> 1) | uTemp) & 0x55555555 );
}
/**Function*************************************************************
Synopsis [Combines two distance 1 cubes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline unsigned Ivy_TruthCubesMerge( unsigned uCube1, unsigned uCube2 )
{
unsigned uTemp;
uTemp = uCube1 | uCube2;
uTemp &= (uTemp >> 1) & 0x55555555;
assert( Ivy_TruthHasOneOne(uTemp) );
uTemp |= (uTemp << 1);
return (uCube1 | uCube2) ^ uTemp;
}
/**Function*************************************************************
Synopsis [Estimates the number of AIG nodes in the truth table.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ivy_TruthEstimateNodes( unsigned * pTruth, int nVars )
{
static unsigned short uResult[256];
static unsigned short uCover[81*81];
static char pVarCount[81*81];
int nMints, uCube, uCubeNew, i, k, c, nCubes, nRes, Counter;
assert( nVars <= 8 );
// create the cover
nCubes = 0;
nMints = (1 << nVars);
for ( i = 0; i < nMints; i++ )
if ( pTruth[i/32] & (1 << (i & 31)) )
{
uCube = 0;
for ( k = 0; k < nVars; k++ )
if ( i & (1 << k) )
uCube |= (1 << ((k<<1)+1));
else
uCube |= (1 << ((k<<1)+0));
uCover[nCubes] = uCube;
pVarCount[nCubes] = nVars;
nCubes++;
// Extra_PrintBinary( stdout, &uCube, 8 ); printf( "\n" );
}
assert( nCubes <= 256 );
// reduce the cover by building larger cubes
for ( i = 1; i < nCubes; i++ )
for ( k = 0; k < i; k++ )
if ( pVarCount[i] && pVarCount[i] == pVarCount[k] && Ivy_TruthCubesDist1(uCover[i], uCover[k]) )
{
uCubeNew = Ivy_TruthCubesMerge(uCover[i], uCover[k]);
for ( c = i; c < nCubes; c++ )
if ( uCubeNew == uCover[c] )
break;
if ( c != nCubes )
continue;
uCover[nCubes] = uCubeNew;
pVarCount[nCubes] = pVarCount[i] - 1;
nCubes++;
assert( nCubes < 81*81 );
// Extra_PrintBinary( stdout, &uCubeNew, 8 ); printf( "\n" );
// c = c;
}
// compact the cover
nRes = 0;
for ( i = nCubes -1; i >= 0; i-- )
{
for ( k = 0; k < nRes; k++ )
if ( (uCover[i] & uResult[k]) == uResult[k] )
break;
if ( k != nRes )
continue;
uResult[nRes++] = uCover[i];
}
// count the number of literals
Counter = 0;
for ( i = 0; i < nRes; i++ )
{
for ( k = 0; k < nVars; k++ )
if ( uResult[i] & (3 << (k<<1)) )
Counter++;
}
return Counter;
}
/**Function*************************************************************
Synopsis [Tests the cover procedure.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_TruthEstimateNodesTest()
{
unsigned uTruth[8];
int i;
for ( i = 0; i < 8; i++ )
uTruth[i] = ~(unsigned)0;
uTruth[3] ^= (1 << 13);
// uTruth[4] = 0xFFFFF;
// uTruth[0] = 0xFF;
// uTruth[0] ^= (1 << 3);
printf( "Number = %d.\n", Ivy_TruthEstimateNodes(uTruth, 8) );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -8,7 +8,8 @@ SRC += src/temp/ivy/ivyBalance.c \ ...@@ -8,7 +8,8 @@ SRC += src/temp/ivy/ivyBalance.c \
src/temp/ivy/ivyMulti.c \ src/temp/ivy/ivyMulti.c \
src/temp/ivy/ivyObj.c \ src/temp/ivy/ivyObj.c \
src/temp/ivy/ivyOper.c \ src/temp/ivy/ivyOper.c \
src/temp/ivy/ivyRewrite.c \ src/temp/ivy/ivyResyn.c \
src/temp/ivy/ivyRwrPre.c \
src/temp/ivy/ivySeq.c \ src/temp/ivy/ivySeq.c \
src/temp/ivy/ivyTable.c \ src/temp/ivy/ivyTable.c \
src/temp/ivy/ivyUndo.c \ src/temp/ivy/ivyUndo.c \
......
/**CFile****************************************************************
FileName [mem.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Memory management.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: mem.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __MEM_H__
#define __MEM_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
typedef struct Mem_Fixed_t_ Mem_Fixed_t;
typedef struct Mem_Flex_t_ Mem_Flex_t;
typedef struct Mem_Step_t_ Mem_Step_t;
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/*=== mem.c ===========================================================*/
// fixed-size-block memory manager
extern Mem_Fixed_t * Mem_FixedStart( int nEntrySize );
extern void Mem_FixedStop( Mem_Fixed_t * p, int fVerbose );
extern char * Mem_FixedEntryFetch( Mem_Fixed_t * p );
extern void Mem_FixedEntryRecycle( Mem_Fixed_t * p, char * pEntry );
extern void Mem_FixedRestart( Mem_Fixed_t * p );
extern int Mem_FixedReadMemUsage( Mem_Fixed_t * p );
// flexible-size-block memory manager
extern Mem_Flex_t * Mem_FlexStart();
extern void Mem_FlexStop( Mem_Flex_t * p, int fVerbose );
extern char * Mem_FlexEntryFetch( Mem_Flex_t * p, int nBytes );
extern int Mem_FlexReadMemUsage( Mem_Flex_t * p );
// hierarchical memory manager
extern Mem_Step_t * Mem_StepStart( int nSteps );
extern void Mem_StepStop( Mem_Step_t * p, int fVerbose );
extern char * Mem_StepEntryFetch( Mem_Step_t * p, int nBytes );
extern void Mem_StepEntryRecycle( Mem_Step_t * p, char * pEntry, int nBytes );
extern int Mem_StepReadMemUsage( Mem_Step_t * p );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
SRC += src/temp/mem/mem.c
...@@ -40,8 +40,8 @@ typedef struct Pla_Obj_t_ Pla_Obj_t; ...@@ -40,8 +40,8 @@ typedef struct Pla_Obj_t_ Pla_Obj_t;
struct Pla_Obj_t_ struct Pla_Obj_t_
{ {
unsigned fFixed : 1; // fixed node unsigned fFixed : 1; // fixed node
unsigned Depth : 7; // the depth in terms of LUTs/PLAs unsigned Depth : 31; // the depth in terms of LUTs/PLAs
unsigned nRefs : 24; // the number of references int nRefs; // the number of references
Vec_Int_t vSupp[2]; // supports in two frames Vec_Int_t vSupp[2]; // supports in two frames
Esop_Cube_t * pCover[2]; // esops in two frames Esop_Cube_t * pCover[2]; // esops in two frames
}; };
......
...@@ -45,8 +45,10 @@ static Abc_Ntk_t * Ivy_ManToAbc( Abc_Ntk_t * pNtkOld, Ivy_Man_t * p ); ...@@ -45,8 +45,10 @@ static Abc_Ntk_t * Ivy_ManToAbc( Abc_Ntk_t * pNtkOld, Ivy_Man_t * p );
***********************************************************************/ ***********************************************************************/
void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int fVerbose ) void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int fVerbose )
{ {
int fUseRewriting = 1;
Ivy_Man_t * pMan, * pManExt; Ivy_Man_t * pMan, * pManExt;
Abc_Ntk_t * pNtkAig; Abc_Ntk_t * pNtkAig;
if ( !Abc_NtkIsStrash(pNtk) ) if ( !Abc_NtkIsStrash(pNtk) )
return NULL; return NULL;
// convert to the new AIG manager // convert to the new AIG manager
...@@ -60,6 +62,14 @@ void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int fVerbose ) ...@@ -60,6 +62,14 @@ void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int fVerbose )
} }
if ( fVerbose ) if ( fVerbose )
Ivy_ManPrintStats( pMan ); Ivy_ManPrintStats( pMan );
if ( fUseRewriting )
{
// simplify
pMan = Ivy_ManResyn( pManExt = pMan, 1 );
Ivy_ManStop( pManExt );
if ( fVerbose )
Ivy_ManPrintStats( pMan );
}
// perform decomposition/mapping into PLAs/LUTs // perform decomposition/mapping into PLAs/LUTs
pManExt = Pla_ManDecompose( pMan, nLutMax, nPlaMax, fVerbose ); pManExt = Pla_ManDecompose( pMan, nLutMax, nPlaMax, fVerbose );
Ivy_ManStop( pMan ); Ivy_ManStop( pMan );
...@@ -150,10 +160,10 @@ Abc_Ntk_t * Ivy_ManToAbc( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan ) ...@@ -150,10 +160,10 @@ Abc_Ntk_t * Ivy_ManToAbc( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan )
pObjNew = Abc_NtkCreateNode( pNtkNew ); pObjNew = Abc_NtkCreateNode( pNtkNew );
Vec_IntForEachEntry( vIvyFanins, Fanin, k ) Vec_IntForEachEntry( vIvyFanins, Fanin, k )
{ {
pIvyFanin = Ivy_ObjObj( pIvyNode, Ivy_FanId(Fanin) ); pIvyFanin = Ivy_ObjObj( pIvyNode, Ivy_EdgeId(Fanin) );
pFaninNew = Abc_NtkObj( pNtkNew, pIvyFanin->TravId ); pFaninNew = Abc_NtkObj( pNtkNew, pIvyFanin->TravId );
Abc_ObjAddFanin( pObjNew, pFaninNew ); Abc_ObjAddFanin( pObjNew, pFaninNew );
pCompls[k] = Ivy_FanCompl(Fanin); pCompls[k] = Ivy_EdgeIsComplement(Fanin);
assert( Ivy_ObjIsAndMulti(pIvyNode) || nFanins == 1 || pCompls[k] == 0 ); // EXOR/LUT cannot have complemented fanins assert( Ivy_ObjIsAndMulti(pIvyNode) || nFanins == 1 || pCompls[k] == 0 ); // EXOR/LUT cannot have complemented fanins
} }
assert( k <= PLAYER_FANIN_LIMIT ); assert( k <= PLAYER_FANIN_LIMIT );
...@@ -176,10 +186,10 @@ Abc_Ntk_t * Ivy_ManToAbc( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan ) ...@@ -176,10 +186,10 @@ Abc_Ntk_t * Ivy_ManToAbc( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan )
// get the old fanin of the PO node // get the old fanin of the PO node
vIvyFanins = Ivy_ObjGetFanins( Ivy_ManPo(pMan, i) ); vIvyFanins = Ivy_ObjGetFanins( Ivy_ManPo(pMan, i) );
Fanin = Vec_IntEntry( vIvyFanins, 0 ); Fanin = Vec_IntEntry( vIvyFanins, 0 );
pIvyFanin = Ivy_ManObj( pMan, Ivy_FanId(Fanin) ); pIvyFanin = Ivy_ManObj( pMan, Ivy_EdgeId(Fanin) );
// get the new ABC node corresponding to the old fanin // get the new ABC node corresponding to the old fanin
pFaninNew = Abc_NtkObj( pNtkNew, pIvyFanin->TravId ); pFaninNew = Abc_NtkObj( pNtkNew, pIvyFanin->TravId );
if ( Ivy_FanCompl(Fanin) ) // complement if ( Ivy_EdgeIsComplement(Fanin) ) // complement
{ {
// pFaninNew = Abc_NodeCreateInv(pNtkNew, pFaninNew); // pFaninNew = Abc_NodeCreateInv(pNtkNew, pFaninNew);
if ( Abc_ObjIsCi(pFaninNew) ) if ( Abc_ObjIsCi(pFaninNew) )
......
...@@ -62,7 +62,7 @@ Ivy_Man_t * Pla_ManToAig( Ivy_Man_t * pOld ) ...@@ -62,7 +62,7 @@ Ivy_Man_t * Pla_ManToAig( Ivy_Man_t * pOld )
{ {
pObjNew = Pla_ManToAig_rec( pNew, Ivy_ObjFanin0(pObjOld) ); pObjNew = Pla_ManToAig_rec( pNew, Ivy_ObjFanin0(pObjOld) );
Ivy_ObjStartFanins( Ivy_ManPo(pNew, i), 1 ); Ivy_ObjStartFanins( Ivy_ManPo(pNew, i), 1 );
Ivy_ObjAddFanin( Ivy_ManPo(pNew, i), Ivy_FanCreate(pObjNew->Id, Ivy_ObjFaninC0(pObjOld)) ); Ivy_ObjAddFanin( Ivy_ManPo(pNew, i), Ivy_EdgeCreate(pObjNew->Id, Ivy_ObjFaninC0(pObjOld)) );
} }
// compute the LUT functions // compute the LUT functions
Pla_ManToAigLutFuncs( pNew, pOld ); Pla_ManToAigLutFuncs( pNew, pOld );
...@@ -118,7 +118,7 @@ Ivy_Obj_t * Pla_ManToAig_rec( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld ) ...@@ -118,7 +118,7 @@ Ivy_Obj_t * Pla_ManToAig_rec( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld )
Vec_IntForEachEntry( vSupp, Entry, i ) Vec_IntForEachEntry( vSupp, Entry, i )
{ {
pFaninOld = Ivy_ObjObj( pObjOld, Entry ); pFaninOld = Ivy_ObjObj( pObjOld, Entry );
Ivy_ObjAddFanin( Ivy_ManObj(pNew, ObjNewId), Ivy_FanCreate(pFaninOld->TravId, 0) ); Ivy_ObjAddFanin( Ivy_ManObj(pNew, ObjNewId), Ivy_EdgeCreate(pFaninOld->TravId, 0) );
} }
// get the new object // get the new object
pObjNew = Ivy_ManObj(pNew, ObjNewId); pObjNew = Ivy_ManObj(pNew, ObjNewId);
...@@ -140,7 +140,7 @@ Ivy_Obj_t * Pla_ManToAig_rec( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld ) ...@@ -140,7 +140,7 @@ Ivy_Obj_t * Pla_ManToAig_rec( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld )
Esop_CoverForEachCube( pCover, pCube ) Esop_CoverForEachCube( pCover, pCube )
{ {
pFaninNew = Ivy_ManToAigCube( pNew, pObjOld, pCube, vSupp ); pFaninNew = Ivy_ManToAigCube( pNew, pObjOld, pCube, vSupp );
Ivy_ObjAddFanin( Ivy_ManObj(pNew, ObjNewId), Ivy_FanCreate(pFaninNew->Id, 0) ); Ivy_ObjAddFanin( Ivy_ManObj(pNew, ObjNewId), Ivy_EdgeCreate(pFaninNew->Id, 0) );
} }
// get the new object // get the new object
pObjNew = Ivy_ManObj(pNew, ObjNewId); pObjNew = Ivy_ManObj(pNew, ObjNewId);
...@@ -168,7 +168,7 @@ Ivy_Obj_t * Ivy_ManToAigConst( Ivy_Man_t * pNew, int fConst1 ) ...@@ -168,7 +168,7 @@ Ivy_Obj_t * Ivy_ManToAigConst( Ivy_Man_t * pNew, int fConst1 )
Ivy_Obj_t * pObjNew; Ivy_Obj_t * pObjNew;
pObjNew = Ivy_ObjCreateExt( pNew, IVY_ANDM ); pObjNew = Ivy_ObjCreateExt( pNew, IVY_ANDM );
Ivy_ObjStartFanins( pObjNew, 1 ); Ivy_ObjStartFanins( pObjNew, 1 );
Ivy_ObjAddFanin( pObjNew, Ivy_FanCreate(0, !fConst1) ); Ivy_ObjAddFanin( pObjNew, Ivy_EdgeCreate(0, !fConst1) );
return pObjNew; return pObjNew;
} }
...@@ -201,7 +201,7 @@ Ivy_Obj_t * Ivy_ManToAigCube( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld, Esop_Cube_t ...@@ -201,7 +201,7 @@ Ivy_Obj_t * Ivy_ManToAigCube( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld, Esop_Cube_t
if ( Value == 3 ) if ( Value == 3 )
continue; continue;
pFaninOld = Ivy_ObjObj( pObjOld, Vec_IntEntry(vSupp, i) ); pFaninOld = Ivy_ObjObj( pObjOld, Vec_IntEntry(vSupp, i) );
Ivy_ObjAddFanin( pObjNew, Ivy_FanCreate( pFaninOld->TravId, Value==1 ) ); Ivy_ObjAddFanin( pObjNew, Ivy_EdgeCreate( pFaninOld->TravId, Value==1 ) );
} }
assert( Ivy_ObjFaninNum(pObjNew) == (int)pCube->nLits ); assert( Ivy_ObjFaninNum(pObjNew) == (int)pCube->nLits );
return pObjNew; return pObjNew;
...@@ -262,7 +262,7 @@ int Pla_ManToAigLutFuncs( Ivy_Man_t * pNew, Ivy_Man_t * pOld ) ...@@ -262,7 +262,7 @@ int Pla_ManToAigLutFuncs( Ivy_Man_t * pNew, Ivy_Man_t * pOld )
// point it to the constant 1 node // point it to the constant 1 node
vFanins = Ivy_ObjGetFanins( pObjNew ); vFanins = Ivy_ObjGetFanins( pObjNew );
Vec_IntClear( vFanins ); Vec_IntClear( vFanins );
Vec_IntPush( vFanins, Ivy_FanCreate(0, 1) ); Vec_IntPush( vFanins, Ivy_EdgeCreate(0, 1) );
} }
memcpy( pTruth, pComputed, sizeof(unsigned) * 8 ); memcpy( pTruth, pComputed, sizeof(unsigned) * 8 );
// Extra_PrintBinary( stdout, pTruth, 16 ); printf( "\n" ); // Extra_PrintBinary( stdout, pTruth, 16 ); printf( "\n" );
......
...@@ -221,6 +221,7 @@ int Pla_ManDecomposeNode( Pla_Man_t * p, Ivy_Obj_t * pObj ) ...@@ -221,6 +221,7 @@ int Pla_ManDecomposeNode( Pla_Man_t * p, Ivy_Obj_t * pObj )
if ( pStr1->fFixed == 0 ) Pla_ManCountDecNodes( p, pStr1 ); if ( pStr1->fFixed == 0 ) Pla_ManCountDecNodes( p, pStr1 );
pStr1->fFixed = 1; pStr1->fFixed = 1;
} }
assert( pStr->Depth );
// free some of the covers to save memory // free some of the covers to save memory
assert( pStr0->nRefs > 0 ); assert( pStr0->nRefs > 0 );
......
...@@ -309,7 +309,7 @@ void Pla_ManComputeStats( Ivy_Man_t * p, Vec_Int_t * vNodes ) ...@@ -309,7 +309,7 @@ void Pla_ManComputeStats( Ivy_Man_t * p, Vec_Int_t * vNodes )
vFanins = Ivy_ObjGetFanins( pObj ); vFanins = Ivy_ObjGetFanins( pObj );
Vec_IntForEachEntry( vFanins, Fanin, k ) Vec_IntForEachEntry( vFanins, Fanin, k )
{ {
pFanin = Ivy_ManObj(p, Ivy_FanId(Fanin)); pFanin = Ivy_ManObj(p, Ivy_EdgeId(Fanin));
pObj->Level = IVY_MAX( pObj->Level, pFanin->Level ); pObj->Level = IVY_MAX( pObj->Level, pFanin->Level );
} }
pObj->Level += 1; pObj->Level += 1;
...@@ -335,7 +335,7 @@ void Pla_ManComputeStats( Ivy_Man_t * p, Vec_Int_t * vNodes ) ...@@ -335,7 +335,7 @@ void Pla_ManComputeStats( Ivy_Man_t * p, Vec_Int_t * vNodes )
Ivy_ManForEachPo( p, pObj, i ) Ivy_ManForEachPo( p, pObj, i )
{ {
Fanin = Ivy_ObjReadFanin(pObj, 0); Fanin = Ivy_ObjReadFanin(pObj, 0);
pFanin = Ivy_ManObj( p, Ivy_FanId(Fanin) ); pFanin = Ivy_ManObj( p, Ivy_EdgeId(Fanin) );
pObj->Level = pFanin->Level; pObj->Level = pFanin->Level;
Delay = IVY_MAX( Delay, (int)pObj->Level ); Delay = IVY_MAX( Delay, (int)pObj->Level );
} }
......
SRC += src/temp/rwt/rwtDec.c \
src/temp/rwt/rwtMan.c \
src/temp/rwt/rwtUtil.c
/**CFile****************************************************************
FileName [rwt.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting package.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: rwt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __RWT_H__
#define __RWT_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "mem.h"
#include "vec.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
#define RWT_LIMIT 1048576/4 // ((1 << 20)
#define RWT_MIN(a,b) (((a) < (b))? (a) : (b))
#define RWT_MAX(a,b) (((a) > (b))? (a) : (b))
typedef struct Rwt_Man_t_ Rwt_Man_t;
typedef struct Rwt_Node_t_ Rwt_Node_t;
struct Rwt_Man_t_
{
// internal lookups
int nFuncs; // number of four var functions
unsigned short * puCanons; // canonical forms
char * pPhases; // canonical phases
char * pPerms; // canonical permutations
unsigned char * pMap; // mapping of functions into class numbers
unsigned short * pMapInv; // mapping of classes into functions
char * pPractical; // practical NPN classes
char ** pPerms4; // four-var permutations
// node space
Vec_Ptr_t * vForest; // all the nodes
Rwt_Node_t ** pTable; // the hash table of nodes by their canonical form
Vec_Vec_t * vClasses; // the nodes of the equivalence classes
Mem_Fixed_t * pMmNode; // memory for nodes and cuts
// statistical variables
int nTravIds; // the counter of traversal IDs
int nConsidered; // the number of nodes considered
int nAdded; // the number of nodes added to lists
int nClasses; // the number of NN classes
// the result of resynthesis
int fCompl; // indicates if the output of FF should be complemented
void * pGraph; // the decomposition tree (temporary)
Vec_Ptr_t * vFanins; // the fanins array (temporary)
Vec_Ptr_t * vFaninsCur; // the fanins array (temporary)
Vec_Int_t * vLevNums; // the array of levels (temporary)
Vec_Ptr_t * vNodesTemp; // the nodes in MFFC (temporary)
// node statistics
int nNodesConsidered;
int nNodesRewritten;
int nNodesGained;
int nScores[222];
int nCutsGood;
int nCutsBad;
int nSubgraphs;
// runtime statistics
int timeStart;
int timeTruth;
int timeCut;
int timeRes;
int timeEval;
int timeMffc;
int timeUpdate;
int timeTotal;
};
struct Rwt_Node_t_ // 24 bytes
{
int Id; // ID
int TravId; // traversal ID
unsigned uTruth : 16; // truth table
unsigned Volume : 8; // volume
unsigned Level : 6; // level
unsigned fUsed : 1; // mark
unsigned fExor : 1; // mark
Rwt_Node_t * p0; // first child
Rwt_Node_t * p1; // second child
Rwt_Node_t * pNext; // next in the table
};
// manipulation of complemented attributes
static inline int Rwt_IsComplement( Rwt_Node_t * p ) { return (int)(((unsigned)p) & 01); }
static inline Rwt_Node_t * Rwt_Regular( Rwt_Node_t * p ) { return (Rwt_Node_t *)((unsigned)(p) & ~01); }
static inline Rwt_Node_t * Rwt_Not( Rwt_Node_t * p ) { return (Rwt_Node_t *)((unsigned)(p) ^ 01); }
static inline Rwt_Node_t * Rwt_NotCond( Rwt_Node_t * p, int c ) { return (Rwt_Node_t *)((unsigned)(p) ^ (c)); }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== rwrDec.c ========================================================*/
extern void Rwt_ManPreprocess( Rwt_Man_t * p );
/*=== rwrMan.c ========================================================*/
extern Rwt_Man_t * Rwt_ManStart( int fPrecompute );
extern void Rwt_ManStop( Rwt_Man_t * p );
extern void Rwt_ManPrintStats( Rwt_Man_t * p );
extern void Rwt_ManPrintStatsFile( Rwt_Man_t * p );
extern void * Rwt_ManReadDecs( Rwt_Man_t * p );
extern Vec_Ptr_t * Rwt_ManReadLeaves( Rwt_Man_t * p );
extern int Rwt_ManReadCompl( Rwt_Man_t * p );
extern void Rwt_ManAddTimeCuts( Rwt_Man_t * p, int Time );
extern void Rwt_ManAddTimeUpdate( Rwt_Man_t * p, int Time );
extern void Rwt_ManAddTimeTotal( Rwt_Man_t * p, int Time );
/*=== rwrUtil.c ========================================================*/
extern void Rwt_ManLoadFromArray( Rwt_Man_t * p, int fVerbose );
extern char * Rwt_ManGetPractical( Rwt_Man_t * p );
extern Rwt_Node_t * Rwt_ManAddVar( Rwt_Man_t * p, unsigned uTruth, int fPrecompute );
extern void Rwt_ManIncTravId( Rwt_Man_t * p );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [rwtDec.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting package.]
Synopsis [Evaluation and decomposition procedures.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: rwtDec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "rwt.h"
#include "deco.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static Dec_Graph_t * Rwt_NodePreprocess( Rwt_Man_t * p, Rwt_Node_t * pNode );
static Dec_Edge_t Rwt_TravCollect_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, Dec_Graph_t * pGraph );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Preprocesses computed library of subgraphs.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManPreprocess( Rwt_Man_t * p )
{
Dec_Graph_t * pGraph;
Rwt_Node_t * pNode;
int i, k;
// put the nodes into the structure
p->pMapInv = ALLOC( unsigned short, 222 );
memset( p->pMapInv, 0, sizeof(unsigned short) * 222 );
p->vClasses = Vec_VecStart( 222 );
for ( i = 0; i < p->nFuncs; i++ )
{
if ( p->pTable[i] == NULL )
continue;
// consider all implementations of this function
for ( pNode = p->pTable[i]; pNode; pNode = pNode->pNext )
{
assert( pNode->uTruth == p->pTable[i]->uTruth );
assert( p->pMap[pNode->uTruth] >= 0 && p->pMap[pNode->uTruth] < 222 );
Vec_VecPush( p->vClasses, p->pMap[pNode->uTruth], pNode );
p->pMapInv[ p->pMap[pNode->uTruth] ] = p->puCanons[pNode->uTruth];
}
}
// compute decomposition forms for each node and verify them
Vec_VecForEachEntry( p->vClasses, pNode, i, k )
{
pGraph = Rwt_NodePreprocess( p, pNode );
pNode->pNext = (Rwt_Node_t *)pGraph;
// assert( pNode->uTruth == (Dec_GraphDeriveTruth(pGraph) & 0xFFFF) );
}
}
/**Function*************************************************************
Synopsis [Preprocesses subgraphs rooted at this node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dec_Graph_t * Rwt_NodePreprocess( Rwt_Man_t * p, Rwt_Node_t * pNode )
{
Dec_Graph_t * pGraph;
Dec_Edge_t eRoot;
assert( !Rwt_IsComplement(pNode) );
// consider constant
if ( pNode->uTruth == 0 )
return Dec_GraphCreateConst0();
// consider the case of elementary var
if ( pNode->uTruth == 0x00FF )
return Dec_GraphCreateLeaf( 3, 4, 1 );
// start the subgraphs
pGraph = Dec_GraphCreate( 4 );
// collect the nodes
Rwt_ManIncTravId( p );
eRoot = Rwt_TravCollect_rec( p, pNode, pGraph );
Dec_GraphSetRoot( pGraph, eRoot );
return pGraph;
}
/**Function*************************************************************
Synopsis [Adds one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dec_Edge_t Rwt_TravCollect_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, Dec_Graph_t * pGraph )
{
Dec_Edge_t eNode0, eNode1, eNode;
// elementary variable
if ( pNode->fUsed )
return Dec_EdgeCreate( pNode->Id - 1, 0 );
// previously visited node
if ( pNode->TravId == p->nTravIds )
return Dec_IntToEdge( pNode->Volume );
pNode->TravId = p->nTravIds;
// solve for children
eNode0 = Rwt_TravCollect_rec( p, Rwt_Regular(pNode->p0), pGraph );
if ( Rwt_IsComplement(pNode->p0) )
eNode0.fCompl = !eNode0.fCompl;
eNode1 = Rwt_TravCollect_rec( p, Rwt_Regular(pNode->p1), pGraph );
if ( Rwt_IsComplement(pNode->p1) )
eNode1.fCompl = !eNode1.fCompl;
// create the decomposition node(s)
if ( pNode->fExor )
eNode = Dec_GraphAddNodeXor( pGraph, eNode0, eNode1, 0 );
else
eNode = Dec_GraphAddNodeAnd( pGraph, eNode0, eNode1 );
// save the result
pNode->Volume = Dec_EdgeToInt( eNode );
return eNode;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [rwtMan.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting package.]
Synopsis [Rewriting manager.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: rwtMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "rwt.h"
#include "deco.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static unsigned short * s_puCanons = NULL;
static char * s_pPhases = NULL;
static char * s_pPerms = NULL;
static unsigned char * s_pMap = NULL;
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Starts residual rewriting manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManGlobalStart()
{
if ( s_puCanons == NULL )
Extra_Truth4VarNPN( &s_puCanons, &s_pPhases, &s_pPerms, &s_pMap );
}
/**Function*************************************************************
Synopsis [Starts residual rewriting manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManGlobalStop()
{
if ( s_puCanons == NULL ) free( s_puCanons );
if ( s_pPhases == NULL ) free( s_pPhases );
if ( s_pPerms == NULL ) free( s_pPerms );
if ( s_pMap == NULL ) free( s_pMap );
}
/**Function*************************************************************
Synopsis [Starts rewriting manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Rwt_Man_t * Rwt_ManStart( int fPrecompute )
{
Rwt_Man_t * p;
int clk = clock();
clk = clock();
p = ALLOC( Rwt_Man_t, 1 );
memset( p, 0, sizeof(Rwt_Man_t) );
p->nFuncs = (1<<16);
// copy the global tables
Rwt_ManGlobalStart();
p->puCanons = s_puCanons;
p->pPhases = s_pPhases;
p->pPerms = s_pPerms;
p->pMap = s_pMap;
// initialize practical NPN classes
p->pPractical = Rwt_ManGetPractical( p );
// create the table
p->pTable = ALLOC( Rwt_Node_t *, p->nFuncs );
memset( p->pTable, 0, sizeof(Rwt_Node_t *) * p->nFuncs );
// create the elementary nodes
p->pMmNode = Mem_FixedStart( sizeof(Rwt_Node_t) );
p->vForest = Vec_PtrAlloc( 100 );
Rwt_ManAddVar( p, 0x0000, fPrecompute ); // constant 0
Rwt_ManAddVar( p, 0xAAAA, fPrecompute ); // var A
Rwt_ManAddVar( p, 0xCCCC, fPrecompute ); // var B
Rwt_ManAddVar( p, 0xF0F0, fPrecompute ); // var C
Rwt_ManAddVar( p, 0xFF00, fPrecompute ); // var D
p->nClasses = 5;
// other stuff
p->nTravIds = 1;
p->pPerms4 = Extra_Permutations( 4 );
p->vLevNums = Vec_IntAlloc( 50 );
p->vFanins = Vec_PtrAlloc( 50 );
p->vFaninsCur = Vec_PtrAlloc( 50 );
p->vNodesTemp = Vec_PtrAlloc( 50 );
if ( fPrecompute )
{ // precompute subgraphs
// Rwt_ManPrecompute( p );
// Rwt_ManPrint( p );
// Rwt_ManWriteToArray( p );
}
else
{ // load saved subgraphs
Rwt_ManLoadFromArray( p, 0 );
// Rwt_ManPrint( p );
Rwt_ManPreprocess( p );
}
p->timeStart = clock() - clk;
return p;
}
/**Function*************************************************************
Synopsis [Stops rewriting manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManStop( Rwt_Man_t * p )
{
if ( p->vClasses )
{
Rwt_Node_t * pNode;
int i, k;
Vec_VecForEachEntry( p->vClasses, pNode, i, k )
Dec_GraphFree( (Dec_Graph_t *)pNode->pNext );
}
if ( p->vClasses ) Vec_VecFree( p->vClasses );
Vec_PtrFree( p->vNodesTemp );
Vec_PtrFree( p->vForest );
Vec_IntFree( p->vLevNums );
Vec_PtrFree( p->vFanins );
Vec_PtrFree( p->vFaninsCur );
Mem_FixedStop( p->pMmNode, 0 );
FREE( p->pMapInv );
free( p->pTable );
free( p->pPractical );
free( p->pPerms4 );
free( p );
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManPrintStats( Rwt_Man_t * p )
{
int i, Counter = 0;
for ( i = 0; i < 222; i++ )
Counter += (p->nScores[i] > 0);
printf( "Rewriting statistics:\n" );
printf( "Total cuts tries = %8d.\n", p->nCutsGood );
printf( "Bad cuts found = %8d.\n", p->nCutsBad );
printf( "Total subgraphs = %8d.\n", p->nSubgraphs );
printf( "Used NPN classes = %8d.\n", Counter );
printf( "Nodes considered = %8d.\n", p->nNodesConsidered );
printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten );
printf( "Calculated gain = %8d.\n", p->nNodesGained );
PRT( "Start ", p->timeStart );
PRT( "Cuts ", p->timeCut );
PRT( "Truth ", p->timeTruth );
PRT( "Resynthesis ", p->timeRes );
PRT( " Mffc ", p->timeMffc );
PRT( " Eval ", p->timeEval );
PRT( "Update ", p->timeUpdate );
PRT( "TOTAL ", p->timeTotal );
printf( "The scores are:\n" );
for ( i = 0; i < 222; i++ )
if ( p->nScores[i] > 0 )
{
extern void Ivy_TruthDsdComputePrint( unsigned uTruth );
printf( "%3d = %8d canon = %5d ", i, p->nScores[i], p->pMapInv[i] );
Ivy_TruthDsdComputePrint( (unsigned)p->pMapInv[i] | ((unsigned)p->pMapInv[i] << 16) );
}
printf( "\n" );
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManPrintStatsFile( Rwt_Man_t * p )
{
FILE * pTable;
pTable = fopen( "stats.txt", "a+" );
fprintf( pTable, "%d ", p->nCutsGood );
fprintf( pTable, "%d ", p->nSubgraphs );
fprintf( pTable, "%d ", p->nNodesRewritten );
fprintf( pTable, "%d", p->nNodesGained );
fprintf( pTable, "\n" );
fclose( pTable );
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void * Rwt_ManReadDecs( Rwt_Man_t * p )
{
return p->pGraph;
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Rwt_ManReadLeaves( Rwt_Man_t * p )
{
return p->vFanins;
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Rwt_ManReadCompl( Rwt_Man_t * p )
{
return p->fCompl;
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManAddTimeCuts( Rwt_Man_t * p, int Time )
{
p->timeCut += Time;
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManAddTimeUpdate( Rwt_Man_t * p, int Time )
{
p->timeUpdate += Time;
}
/**Function*************************************************************
Synopsis [Stops the resynthesis manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_ManAddTimeTotal( Rwt_Man_t * p, int Time )
{
p->timeTotal += Time;
}
/**Function*************************************************************
Synopsis [Precomputes AIG subgraphs.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rwt_Precompute()
{
Rwt_Man_t * p;
p = Rwt_ManStart( 1 );
Rwt_ManStop( p );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [vec.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resizable arrays.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: vec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __VEC_H__
#define __VEC_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
#include "vecInt.h"
#include "vecStr.h"
#include "vecPtr.h"
#include "vecVec.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [vecVec.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resizable arrays.]
Synopsis [Resizable vector of resizable vectors.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: vecVec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __VEC_VEC_H__
#define __VEC_VEC_H__
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "extra.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef struct Vec_Vec_t_ Vec_Vec_t;
struct Vec_Vec_t_
{
int nCap;
int nSize;
void ** pArray;
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
// iterators through levels
#define Vec_VecForEachLevel( vGlob, vVec, i ) \
for ( i = 0; (i < Vec_VecSize(vGlob)) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i++ )
#define Vec_VecForEachLevelStart( vGlob, vVec, i, LevelStart ) \
for ( i = LevelStart; (i < Vec_VecSize(vGlob)) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i++ )
#define Vec_VecForEachLevelStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
for ( i = LevelStart; (i <= LevelStop) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i++ )
#define Vec_VecForEachLevelReverse( vGlob, vVec, i ) \
for ( i = Vec_VecSize(vGlob) - 1; (i >= 0) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i-- )
// iteratores through entries
#define Vec_VecForEachEntry( vGlob, pEntry, i, k ) \
for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
#define Vec_VecForEachEntryStart( vGlob, pEntry, i, k, LevelStart ) \
for ( i = LevelStart; i < Vec_VecSize(vGlob); i++ ) \
Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
#define Vec_VecForEachEntryStartStop( vGlob, pEntry, i, k, LevelStart, LevelStop ) \
for ( i = LevelStart; i <= LevelStop; i++ ) \
Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
#define Vec_VecForEachEntryReverse( vGlob, pEntry, i, k ) \
for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
#define Vec_VecForEachEntryReverseReverse( vGlob, pEntry, i, k ) \
for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline Vec_Vec_t * Vec_VecAlloc( int nCap )
{
Vec_Vec_t * p;
p = ALLOC( Vec_Vec_t, 1 );
if ( nCap > 0 && nCap < 8 )
nCap = 8;
p->nSize = 0;
p->nCap = nCap;
p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL;
return p;
}
/**Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline Vec_Vec_t * Vec_VecStart( int nSize )
{
Vec_Vec_t * p;
int i;
p = Vec_VecAlloc( nSize );
for ( i = 0; i < nSize; i++ )
p->pArray[i] = Vec_PtrAlloc( 0 );
p->nSize = nSize;
return p;
}
/**Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_VecExpand( Vec_Vec_t * p, int Level )
{
int i;
if ( p->nSize >= Level + 1 )
return;
Vec_PtrGrow( (Vec_Ptr_t *)p, Level + 1 );
for ( i = p->nSize; i <= Level; i++ )
p->pArray[i] = Vec_PtrAlloc( 0 );
p->nSize = Level + 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Vec_VecSize( Vec_Vec_t * p )
{
return p->nSize;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void * Vec_VecEntry( Vec_Vec_t * p, int i )
{
assert( i >= 0 && i < p->nSize );
return p->pArray[i];
}
/**Function*************************************************************
Synopsis [Frees the vector.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_VecFree( Vec_Vec_t * p )
{
Vec_Ptr_t * vVec;
int i;
Vec_VecForEachLevel( p, vVec, i )
Vec_PtrFree( vVec );
Vec_PtrFree( (Vec_Ptr_t *)p );
}
/**Function*************************************************************
Synopsis [Frees the vector of vectors.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Vec_VecSizeSize( Vec_Vec_t * p )
{
Vec_Ptr_t * vVec;
int i, Counter = 0;
Vec_VecForEachLevel( p, vVec, i )
Counter += vVec->nSize;
return Counter;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_VecClear( Vec_Vec_t * p )
{
Vec_Ptr_t * vVec;
int i;
Vec_VecForEachLevel( p, vVec, i )
Vec_PtrClear( vVec );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_VecPush( Vec_Vec_t * p, int Level, void * Entry )
{
if ( p->nSize < Level + 1 )
{
int i;
Vec_PtrGrow( (Vec_Ptr_t *)p, Level + 1 );
for ( i = p->nSize; i < Level + 1; i++ )
p->pArray[i] = Vec_PtrAlloc( 0 );
p->nSize = Level + 1;
}
Vec_PtrPush( (Vec_Ptr_t*)p->pArray[Level], Entry );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_VecPushUnique( Vec_Vec_t * p, int Level, void * Entry )
{
if ( p->nSize < Level + 1 )
Vec_VecPush( p, Level, Entry );
else
Vec_PtrPushUnique( (Vec_Ptr_t*)p->pArray[Level], Entry );
}
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
SRC += src/opt/xyz/xyzBuild.c \ SRC += src/temp/xyz/xyzBuild.c \
src/opt/xyz/xyzCore.c \ src/temp/xyz/xyzCore.c \
src/opt/xyz/xyzMan.c \ src/temp/xyz/xyzMan.c \
src/opt/xyz/xyzMinEsop.c \ src/temp/xyz/xyzMinEsop.c \
src/opt/xyz/xyzMinMan.c \ src/temp/xyz/xyzMinMan.c \
src/opt/xyz/xyzMinSop.c \ src/temp/xyz/xyzMinSop.c \
src/opt/xyz/xyzMinUtil.c \ src/temp/xyz/xyzMinUtil.c \
src/opt/xyz/xyzTest.c src/temp/xyz/xyzTest.c
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