summaryrefslogtreecommitdiffstats
path: root/src/map/if/ifCache.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-03-20 11:21:33 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-03-20 11:21:33 -0700
commitb581e16f32cd1ad68a65fd94d9f2b997da443721 (patch)
tree60550ee6a2254498f8e38b71b8f4347d8f0c5b1f /src/map/if/ifCache.c
parentd44d9e292788efa2d933ffdeeaa058e4bc416e90 (diff)
downloadabc-b581e16f32cd1ad68a65fd94d9f2b997da443721.tar.gz
abc-b581e16f32cd1ad68a65fd94d9f2b997da443721.tar.bz2
abc-b581e16f32cd1ad68a65fd94d9f2b997da443721.zip
Experiments with cut caching.
Diffstat (limited to 'src/map/if/ifCache.c')
-rw-r--r--src/map/if/ifCache.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/map/if/ifCache.c b/src/map/if/ifCache.c
new file mode 100644
index 00000000..231e495c
--- /dev/null
+++ b/src/map/if/ifCache.c
@@ -0,0 +1,121 @@
+/**CFile****************************************************************
+
+ FileName [ifCache.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifCache.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+#include "misc/vec/vecHsh.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd )
+{
+ if ( p->vCutData == NULL )
+ p->vCutData = Vec_IntAlloc( 10000 );
+ if ( iDsd0 > iDsd1 )
+ ABC_SWAP( int, iDsd0, iDsd1 );
+ Vec_IntPush( p->vCutData, iDsd0 );
+ Vec_IntPush( p->vCutData, iDsd1 );
+ Vec_IntPush( p->vCutData, nShared );
+ Vec_IntPush( p->vCutData, iDsd );
+// printf( "%6d %6d %6d %6d\n", iDsd0, iDsd1, nShared, iDsd );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_IntCountUnique( Vec_Int_t * p )
+{
+ int i, Count = 0, Max = Vec_IntFindMax(p);
+ unsigned char * pPres = ABC_CALLOC( unsigned char, Max+1 );
+ for ( i = 0; i < p->nSize; i++ )
+ if ( pPres[p->pArray[i]] == 0 )
+ pPres[p->pArray[i]] = 1, Count++;
+ ABC_FREE( pPres );
+ return Count;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCacheAnalize( If_Man_t * p )
+{
+ Vec_Int_t * vRes, * vTest[32];
+ int i, Entry, uUnique;
+ vRes = Hsh_IntManHashArray( p->vCutData, 4 );
+ for ( i = 0; i <= p->pPars->nLutSize; i++ )
+ vTest[i] = Vec_IntAlloc( 1000 );
+ Vec_IntForEachEntry( vRes, Entry, i )
+ Vec_IntPush( vTest[Vec_IntEntry(p->vCutData, 4*i+2)], Entry );
+ for ( i = 0; i <= p->pPars->nLutSize; i++ )
+ {
+ uUnique = Vec_IntCountUnique(vTest[i]);
+ printf( "%2d-var entries = %8d. (%6.2f %%) Unique entries = %8d. (%6.2f %%)\n",
+ i, Vec_IntSize(vTest[i]), 100.0*Vec_IntSize(vTest[i])/Vec_IntSize(vRes),
+ uUnique, 100.0*uUnique/Vec_IntSize(vTest[i]) );
+ }
+ for ( i = 0; i <= p->pPars->nLutSize; i++ )
+ Vec_IntFree( vTest[i] );
+ uUnique = Vec_IntCountUnique(vRes);
+ printf( "Total entries = %8d. (%6.2f %%) Unique entries = %8d. (%6.2f %%)\n",
+ Vec_IntSize(p->vCutData)/4, 100.0, uUnique, 100.0*uUnique/(Vec_IntSize(p->vCutData)/4) );
+ Vec_IntFree( vRes );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+