summaryrefslogtreecommitdiffstats
path: root/src/opt/fxch/Fxch.c
diff options
context:
space:
mode:
authorBruno Schmitt <bruno@oschmitt.com>2016-05-11 19:41:31 -0300
committerBruno Schmitt <bruno@oschmitt.com>2016-05-11 19:41:31 -0300
commit3cf495c83197f838580a6efd25e9d5a68e871fa6 (patch)
tree5e0dfd49da6764d829f9e43a0f6dbc746bb92007 /src/opt/fxch/Fxch.c
parent8745fa8163d94ffd90590cc052eb39bd5a866bff (diff)
downloadabc-3cf495c83197f838580a6efd25e9d5a68e871fa6.tar.gz
abc-3cf495c83197f838580a6efd25e9d5a68e871fa6.tar.bz2
abc-3cf495c83197f838580a6efd25e9d5a68e871fa6.zip
Add a new module which implements the fast extract with cube hashing (fxch) algorithm.
Removes old partial implementation of this algorithm from the "pla" module.
Diffstat (limited to 'src/opt/fxch/Fxch.c')
-rw-r--r--src/opt/fxch/Fxch.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/opt/fxch/Fxch.c b/src/opt/fxch/Fxch.c
new file mode 100644
index 00000000..9d674720
--- /dev/null
+++ b/src/opt/fxch/Fxch.c
@@ -0,0 +1,140 @@
+/**CFile****************************************************************
+
+ FileName [ Fxch.c ]
+
+ PackageName [ Fast eXtract with Cube Hashing (FXCH) ]
+
+ Synopsis [ The entrance into the fast extract module. ]
+
+ Author [ Bruno Schmitt - boschmitt at inf.ufrgs.br ]
+
+ Affiliation [ UFRGS ]
+
+ Date [ Ver. 1.0. Started - March 6, 2016. ]
+
+ Revision []
+
+***********************************************************************/
+
+#include "Fxch.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [ Performs fast extract with cube hashing on a set
+ of covers. ]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Fxch_FastExtract( Vec_Wec_t* vCubes,
+ int ObjIdMax,
+ int nMaxDivExt,
+ int SMode,
+ int fVerbose,
+ int fVeryVerbose )
+{
+ abctime TempTime;
+ Fxch_Man_t* pFxchMan = Fxch_ManAlloc( vCubes, SMode );
+
+ TempTime = Abc_Clock();
+ Fxch_ManMapLiteralsIntoCubes( pFxchMan, ObjIdMax );
+ Fxch_ManGenerateLitHashKeys( pFxchMan );
+ Fxch_ManComputeLevel( pFxchMan );
+ Fxch_ManSCHashTablesInit( pFxchMan );
+ Fxch_ManDivCreate( pFxchMan );
+ pFxchMan->timeInit = Abc_Clock() - TempTime;
+
+ if ( fVeryVerbose )
+ Fxch_ManPrintDivs( pFxchMan );
+
+ if ( fVerbose )
+ Fxch_ManPrintStats( pFxchMan );
+
+ TempTime = Abc_Clock();
+ for ( int i = 0; i < nMaxDivExt && Vec_QueTopPriority( pFxchMan->vDivPrio ) > 0.0; i++ )
+ {
+ int iDiv = Vec_QuePop( pFxchMan->vDivPrio );
+
+ if ( fVeryVerbose )
+ Fxch_DivPrint( pFxchMan, iDiv );
+
+ Fxch_ManUpdate( pFxchMan, iDiv );
+ }
+ pFxchMan->timeExt = Abc_Clock() - TempTime;
+
+ if ( fVerbose )
+ {
+ Fxch_ManPrintStats( pFxchMan );
+ Abc_PrintTime( 1, "\n[FXCH] Elapsed Time", pFxchMan->timeInit + pFxchMan->timeExt );
+ Abc_PrintTime( 1, "[FXCH] +-> Init", pFxchMan->timeInit );
+ Abc_PrintTime( 1, "[FXCH] +-> Extr", pFxchMan->timeExt );
+ }
+
+ Fxch_ManSCHashTablesFree( pFxchMan );
+ Fxch_ManFree( pFxchMan );
+ Vec_WecRemoveEmpty( vCubes );
+
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [ Retrives the necessary information for the fast extract
+ with cube hashing. ]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkFxchPerform( Abc_Ntk_t* pNtk,
+ int nMaxDivExt,
+ int SMode,
+ int fVerbose,
+ int fVeryVerbose )
+{
+ Vec_Wec_t* vCubes;
+
+ assert( Abc_NtkIsSopLogic( pNtk ) );
+
+ if ( !Abc_NtkFxCheck( pNtk ) )
+ {
+ printf( "Abc_NtkFxchPerform(): Nodes have duplicated fanins. FXCH is not performed.\n" );
+ return 0;
+ }
+
+ vCubes = Abc_NtkFxRetrieve( pNtk );
+ if ( Fxch_FastExtract( vCubes, Abc_NtkObjNumMax( pNtk ), nMaxDivExt, SMode, fVerbose, fVeryVerbose ) > 0 )
+ {
+ Abc_NtkFxInsert( pNtk, vCubes );
+ Vec_WecFree( vCubes );
+
+ if ( !Abc_NtkCheck( pNtk ) )
+ printf( "Abc_NtkFxchPerform(): The network check has failed.\n" );
+
+ return 1;
+ }
+ else
+ printf( "Warning: The network has not been changed by \"fxch\".\n" );
+
+ Vec_WecFree( vCubes );
+
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_IMPL_END