summaryrefslogtreecommitdiffstats
path: root/src/map/if
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2008-03-27 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2008-03-27 08:01:00 -0700
commit416ffc117ab7d0ea2ec3b8aaeb4724f25031db7a (patch)
tree0d9c55c15e42c128a10a4da9be6140fa736a3249 /src/map/if
parente258fcb2cd0cb0bca2bb077b2e5954b7be02b1c3 (diff)
downloadabc-416ffc117ab7d0ea2ec3b8aaeb4724f25031db7a.tar.gz
abc-416ffc117ab7d0ea2ec3b8aaeb4724f25031db7a.tar.bz2
abc-416ffc117ab7d0ea2ec3b8aaeb4724f25031db7a.zip
Version abc80327
Diffstat (limited to 'src/map/if')
-rw-r--r--src/map/if/if.h7
-rw-r--r--src/map/if/ifLib.c273
-rw-r--r--src/map/if/ifMap.c7
-rw-r--r--src/map/if/ifUtil.c34
-rw-r--r--src/map/if/module.make1
5 files changed, 313 insertions, 9 deletions
diff --git a/src/map/if/if.h b/src/map/if/if.h
index d42dd0af..d97a1154 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -245,8 +245,9 @@ static inline If_Obj_t * If_ManObj( If_Man_t * p, int i ) { r
static inline int If_ObjIsConst1( If_Obj_t * pObj ) { return pObj->Type == IF_CONST1; }
static inline int If_ObjIsCi( If_Obj_t * pObj ) { return pObj->Type == IF_CI; }
static inline int If_ObjIsCo( If_Obj_t * pObj ) { return pObj->Type == IF_CO; }
-//static inline int If_ObjIsPi( If_Obj_t * pObj ) { return If_ObjIsCi(pObj) && pObj->pFanin0 == NULL; }
-static inline int If_ObjIsLatch( If_Obj_t * pObj ) { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL; }
+static inline int If_ObjIsTerm( If_Obj_t * pObj ) { return pObj->Type == IF_CI || pObj->Type == IF_CO; }
+//static inline int If_ObjIsPi( If_Obj_t * pObj ) { return If_ObjIsCi(pObj) && pObj->pFanin0 == NULL; }
+static inline int If_ObjIsLatch( If_Obj_t * pObj ) { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL; }
static inline int If_ObjIsAnd( If_Obj_t * pObj ) { return pObj->Type == IF_AND; }
static inline If_Obj_t * If_ObjFanin0( If_Obj_t * pObj ) { return pObj->pFanin0; }
@@ -402,6 +403,8 @@ extern int If_ManCrossCut( If_Man_t * p );
extern Vec_Ptr_t * If_ManReverseOrder( If_Man_t * p );
extern void If_ManMarkMapping( If_Man_t * p );
extern Vec_Ptr_t * If_ManCollectMappingDirect( If_Man_t * p );
+extern Vec_Int_t * If_ManCollectMappingInt( If_Man_t * p );
+
extern int If_ManCountSpecialPos( If_Man_t * p );
diff --git a/src/map/if/ifLib.c b/src/map/if/ifLib.c
new file mode 100644
index 00000000..2089ca3c
--- /dev/null
+++ b/src/map/if/ifLib.c
@@ -0,0 +1,273 @@
+/**CFile****************************************************************
+
+ FileName [ifLib.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [LUT library.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifLib.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline char * If_UtilStrsav( char *s ) { return !s ? s : strcpy(ALLOC(char, strlen(s)+1), s); }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Reads the description of LUTs from the LUT library file.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Lib_t * If_LutLibRead( char * FileName )
+{
+ char pBuffer[1000], * pToken;
+ If_Lib_t * p;
+ FILE * pFile;
+ int i, k;
+
+ pFile = fopen( FileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open LUT library file \"%s\".\n", FileName );
+ return NULL;
+ }
+
+ p = ALLOC( If_Lib_t, 1 );
+ memset( p, 0, sizeof(If_Lib_t) );
+ p->pName = If_UtilStrsav( FileName );
+
+ i = 1;
+ while ( fgets( pBuffer, 1000, pFile ) != NULL )
+ {
+ pToken = strtok( pBuffer, " \t\n" );
+ if ( pToken == NULL )
+ continue;
+ if ( pToken[0] == '#' )
+ continue;
+ if ( i != atoi(pToken) )
+ {
+ printf( "Error in the LUT library file \"%s\".\n", FileName );
+ free( p );
+ return NULL;
+ }
+
+ // read area
+ pToken = strtok( NULL, " \t\n" );
+ p->pLutAreas[i] = (float)atof(pToken);
+
+ // read delays
+ k = 0;
+ while ( pToken = strtok( NULL, " \t\n" ) )
+ p->pLutDelays[i][k++] = (float)atof(pToken);
+
+ // check for out-of-bound
+ if ( k > i )
+ {
+ printf( "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
+ return NULL;
+ }
+
+ // check if var delays are specifies
+ if ( k > 1 )
+ p->fVarPinDelays = 1;
+
+ if ( i == IF_MAX_LUTSIZE )
+ {
+ printf( "Skipping LUTs of size more than %d.\n", i );
+ return NULL;
+ }
+ i++;
+ }
+ p->LutMax = i-1;
+
+ // check the library
+ if ( p->fVarPinDelays )
+ {
+ for ( i = 1; i <= p->LutMax; i++ )
+ for ( k = 0; k < i; k++ )
+ {
+ if ( p->pLutDelays[i][k] <= 0.0 )
+ printf( "Warning: Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
+ k, i, p->pLutDelays[i][k] );
+ if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
+ printf( "Warning: Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
+ k-1, i, p->pLutDelays[i][k-1],
+ k, i, p->pLutDelays[i][k] );
+ }
+ }
+ else
+ {
+ for ( i = 1; i <= p->LutMax; i++ )
+ {
+ if ( p->pLutDelays[i][0] <= 0.0 )
+ printf( "Warning: LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
+ k, i, p->pLutDelays[i][0] );
+ }
+ }
+
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the LUT library.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Lib_t * If_LutLibDup( If_Lib_t * p )
+{
+ If_Lib_t * pNew;
+ pNew = ALLOC( If_Lib_t, 1 );
+ *pNew = *p;
+ pNew->pName = If_UtilStrsav( pNew->pName );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Frees the LUT library.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_LutLibFree( If_Lib_t * pLutLib )
+{
+ if ( pLutLib == NULL )
+ return;
+ FREE( pLutLib->pName );
+ FREE( pLutLib );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints the LUT library.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_LutLibPrint( If_Lib_t * pLutLib )
+{
+ int i, k;
+ printf( "# The area/delay of k-variable LUTs:\n" );
+ printf( "# k area delay\n" );
+ if ( pLutLib->fVarPinDelays )
+ {
+ for ( i = 1; i <= pLutLib->LutMax; i++ )
+ {
+ printf( "%d %7.2f ", i, pLutLib->pLutAreas[i] );
+ for ( k = 0; k < i; k++ )
+ printf( " %7.2f", pLutLib->pLutDelays[i][k] );
+ printf( "\n" );
+ }
+ }
+ else
+ for ( i = 1; i <= pLutLib->LutMax; i++ )
+ printf( "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if the delays are discrete.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_LutLibDelaysAreDiscrete( If_Lib_t * pLutLib )
+{
+ float Delay;
+ int i;
+ for ( i = 1; i <= pLutLib->LutMax; i++ )
+ {
+ Delay = pLutLib->pLutDelays[i][0];
+ if ( ((float)((int)Delay)) != Delay )
+ return 0;
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets simple LUT library.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Lib_t * If_SetSimpleLutLib( int nLutSize )
+{
+ If_Lib_t s_LutLib10= { "lutlib",10, 0, {0,1,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib9 = { "lutlib", 9, 0, {0,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib8 = { "lutlib", 8, 0, {0,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib7 = { "lutlib", 7, 0, {0,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib6 = { "lutlib", 6, 0, {0,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib5 = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib4 = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
+ If_Lib_t s_LutLib3 = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} };
+ If_Lib_t * pLutLib;
+ assert( nLutSize >= 3 && nLutSize <= 10 );
+ switch ( nLutSize )
+ {
+ case 3: pLutLib = &s_LutLib3; break;
+ case 4: pLutLib = &s_LutLib4; break;
+ case 5: pLutLib = &s_LutLib5; break;
+ case 6: pLutLib = &s_LutLib6; break;
+ case 7: pLutLib = &s_LutLib7; break;
+ case 8: pLutLib = &s_LutLib8; break;
+ case 9: pLutLib = &s_LutLib9; break;
+ case 10: pLutLib = &s_LutLib10; break;
+ default: pLutLib = NULL; break;
+ }
+ if ( pLutLib == NULL )
+ return NULL;
+ return If_LutLibDup(pLutLib);
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/ifMap.c b/src/map/if/ifMap.c
index fafd454d..81521abf 100644
--- a/src/map/if/ifMap.c
+++ b/src/map/if/ifMap.c
@@ -295,13 +295,6 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
{
arrTime = Tim_ManGetPiArrival( p->pManTim, pObj->IdPio );
If_ObjSetArrTime( pObj, arrTime );
-/*
- if ( pObj->IdPio >= 2000 )
- {
- int x = 0;
- printf( "+%d %6.3f ", pObj->IdPio, arrTime );
- }
-*/
}
else if ( If_ObjIsCo(pObj) )
{
diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c
index c114236d..74880409 100644
--- a/src/map/if/ifUtil.c
+++ b/src/map/if/ifUtil.c
@@ -653,6 +653,40 @@ Vec_Ptr_t * If_ManCollectMappingDirect( If_Man_t * p )
/**Function*************************************************************
+ Synopsis [Collects nodes used in the mapping in the topological order.]
+
+ Description [Represents mapping as an array of integers.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * If_ManCollectMappingInt( If_Man_t * p )
+{
+ Vec_Int_t * vOrder;
+ If_Cut_t * pCutBest;
+ If_Obj_t * pObj;
+ int i, k, nLeaves, * ppLeaves;
+ If_ManMarkMapping( p );
+ vOrder = Vec_IntAlloc( If_ManObjNum(p) );
+ If_ManForEachObj( p, pObj, i )
+ if ( If_ObjIsAnd(pObj) && pObj->nRefs )
+ {
+ pCutBest = If_ObjCutBest( pObj );
+ nLeaves = If_CutLeaveNum( pCutBest );
+ ppLeaves = If_CutLeaves( pCutBest );
+ // save the number of leaves, the leaves, and finally, the root
+ Vec_IntPush( vOrder, nLeaves );
+ for ( k = 0; k < nLeaves; k++ )
+ Vec_IntPush( vOrder, ppLeaves[k] );
+ Vec_IntPush( vOrder, pObj->Id );
+ }
+ return vOrder;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the number of POs pointing to the same internal nodes.]
Description []
diff --git a/src/map/if/module.make b/src/map/if/module.make
index c14428da..7489d3b4 100644
--- a/src/map/if/module.make
+++ b/src/map/if/module.make
@@ -1,5 +1,6 @@
SRC += src/map/if/ifCore.c \
src/map/if/ifCut.c \
+ src/map/if/ifLib.c \
src/map/if/ifMan.c \
src/map/if/ifMap.c \
src/map/if/ifReduce.c \