summaryrefslogtreecommitdiffstats
path: root/src/map/if/if.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/if/if.h')
-rw-r--r--src/map/if/if.h101
1 files changed, 63 insertions, 38 deletions
diff --git a/src/map/if/if.h b/src/map/if/if.h
index f867e85e..1bbed29d 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -50,8 +50,8 @@ extern "C" {
typedef enum {
IF_NONE, // 0: non-existent object
IF_CONST1, // 1: constant 1
- IF_PI, // 2: primary input
- IF_PO, // 3: primary output
+ IF_CI, // 2: combinational input
+ IF_CO, // 3: combinational output
IF_AND, // 4: AND node
IF_BI, // 5: box input
IF_BO, // 6: box output
@@ -63,9 +63,9 @@ typedef enum {
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
+typedef struct If_Man_t_ If_Man_t;
typedef struct If_Par_t_ If_Par_t;
typedef struct If_Lib_t_ If_Lib_t;
-typedef struct If_Man_t_ If_Man_t;
typedef struct If_Obj_t_ If_Obj_t;
typedef struct If_Cut_t_ If_Cut_t;
@@ -81,7 +81,7 @@ struct If_Par_t_
int fFancy; // a fancy feature
int fExpRed; // expand/reduce of the best cuts
int fLatchPaths; // reset timing on latch paths
- int fSeq; // sequential mapping
+ int fSeqMap; // sequential mapping
int fVerbose; // the verbosity flag
// internal parameters
int fTruth; // truth table computation enabled
@@ -89,6 +89,7 @@ struct If_Par_t_
int fUseBdds; // sets local BDDs at the nodes
int fUseSops; // sets local SOPs at the nodes
int nLatches; // the number of latches in seq mapping
+ int fLiftLeaves; // shift the leaves for seq mapping
If_Lib_t * pLutLib; // the LUT library
float * pTimesArr; // arrival times
float * pTimesReq; // required times
@@ -113,8 +114,8 @@ struct If_Man_t_
If_Par_t * pPars;
// mapping nodes
If_Obj_t * pConst1; // the constant 1 node
- Vec_Ptr_t * vPis; // the primary inputs
- Vec_Ptr_t * vPos; // the primary outputs
+ Vec_Ptr_t * vCis; // the primary inputs
+ Vec_Ptr_t * vCos; // the primary outputs
Vec_Ptr_t * vObjs; // all objects
Vec_Ptr_t * vMapped; // objects used in the mapping
Vec_Ptr_t * vTemp; // temporary array
@@ -126,10 +127,13 @@ struct If_Man_t_
float AreaGlo; // global area
int nCutsUsed; // the number of cuts currently used
int nCutsMerged; // the total number of cuts merged
- int nCutsSaved; // the total number of cuts saved
- int nCutsMax; // the maximum number of cuts at a node
- float Fi; // the current value of the clock period (for seq mapping)
unsigned * puTemp[4]; // used for the truth table computation
+ // sequential mapping
+ Vec_Ptr_t * vLatchOrder; // topological ordering of latches
+ Vec_Int_t * vLags; // sequentail lags of all nodes
+ int nAttempts; // the number of attempts in binary search
+ int nMaxIters; // the maximum number of iterations
+ int Period; // the current value of the clock period (for seq mapping)
// memory management
Mem_Fixed_t * pMem; // memory manager
int nEntrySize; // the size of the entry
@@ -168,7 +172,8 @@ struct If_Obj_t_
unsigned fPhase : 1; // phase of the node
unsigned fRepr : 1; // representative of the equivalence class
unsigned fMark : 1; // multipurpose mark
- unsigned Level : 23; // logic level of the node
+ unsigned fVisit : 1; // multipurpose mark
+ unsigned Level : 22; // logic level of the node
int Id; // integer ID
int nRefs; // the number of references
int nCuts; // the number of cuts
@@ -182,19 +187,21 @@ struct If_Obj_t_
};
static inline If_Obj_t * If_ManConst1( If_Man_t * p ) { return p->pConst1; }
-static inline If_Obj_t * If_ManPi( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vPis, i ); }
-static inline If_Obj_t * If_ManPo( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vPos, i ); }
+static inline If_Obj_t * If_ManCi( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vCis, i ); }
+static inline If_Obj_t * If_ManCo( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vCos, i ); }
static inline If_Obj_t * If_ManObj( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }
static inline If_Cut_t * If_ManCut( If_Man_t * p, int i ) { return p->ppCuts[i]; }
-static inline int If_ManPiNum( If_Man_t * p ) { return p->nObjs[IF_PI]; }
-static inline int If_ManPoNum( If_Man_t * p ) { return p->nObjs[IF_PO]; }
+static inline int If_ManCiNum( If_Man_t * p ) { return p->nObjs[IF_CI]; }
+static inline int If_ManCoNum( If_Man_t * p ) { return p->nObjs[IF_CO]; }
static inline int If_ManAndNum( If_Man_t * p ) { return p->nObjs[IF_AND]; }
static inline int If_ManObjNum( If_Man_t * p ) { return Vec_PtrSize(p->vObjs); }
static inline int If_ObjIsConst1( If_Obj_t * pObj ) { return pObj->Type == IF_CONST1; }
-static inline int If_ObjIsPi( If_Obj_t * pObj ) { return pObj->Type == IF_PI; }
-static inline int If_ObjIsPo( If_Obj_t * pObj ) { return pObj->Type == IF_PO; }
+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_ObjIsAnd( If_Obj_t * pObj ) { return pObj->Type == IF_AND; }
static inline int If_ObjIsBi( If_Obj_t * pObj ) { return pObj->Type == IF_BI; }
static inline int If_ObjIsBo( If_Obj_t * pObj ) { return pObj->Type == IF_BO; }
@@ -210,9 +217,12 @@ static inline void If_ObjSetChoice( If_Obj_t * pObj, If_Obj_t * pEqu ) { p
static inline If_Cut_t * If_ObjCut( If_Obj_t * pObj, int iCut ) { return pObj->Cuts + iCut; }
static inline If_Cut_t * If_ObjCutTriv( If_Obj_t * pObj ) { return pObj->Cuts; }
-static inline If_Cut_t * If_ObjCutBest( If_Obj_t * pObj ) { return pObj->Cuts + 1; }
+static inline If_Cut_t * If_ObjCutBest( If_Obj_t * pObj ) { return pObj->Cuts + (int)(pObj->nCuts > 1); }
static inline unsigned If_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId % 31)); }
+static inline float If_ObjLValue( If_Obj_t * pObj ) { return If_ObjCutTriv(pObj)->Delay; }
+static inline void If_ObjSetLValue( If_Obj_t * pObj, float LValue ) { If_ObjCutTriv(pObj)->Delay = LValue; }
+
static inline void * If_CutData( If_Cut_t * pCut ) { return *(void **)pCut; }
static inline void If_CutSetData( If_Cut_t * pCut, void * pData ) { *(void **)pCut = pData; }
@@ -227,8 +237,8 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-#define IF_MIN(a,b) (((a) < (b))? (a) : (b))
-#define IF_MAX(a,b) (((a) > (b))? (a) : (b))
+#define IF_MIN(a,b) (((a) < (b))? (a) : (b))
+#define IF_MAX(a,b) (((a) > (b))? (a) : (b))
// the small and large numbers (min/max float are 1.17e-38/3.40e+38)
#define IF_FLOAT_LARGE ((float)1.0e+20)
@@ -236,14 +246,20 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r
#define IF_INT_LARGE (10000000)
// iterator over the primary inputs
+#define If_ManForEachCi( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vCis, pObj, i )
+// iterator over the primary outputs
+#define If_ManForEachCo( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vCos, pObj, i )
+// iterator over the primary inputs
#define If_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntryStop( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
// iterator over the primary outputs
#define If_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntryStop( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
// iterator over the latches
#define If_ManForEachLatch( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vPos, pObj, i, If_ManPoNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStart( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
// iterator over all objects, including those currently not used
#define If_ManForEachObj( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjs, pObj, i )
@@ -256,17 +272,22 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r
// iterator over cuts of the node
#define If_ObjForEachCutStart( pObj, pCut, i, Start ) \
for ( i = Start; (i < (int)(pObj)->nCuts) && ((pCut) = (pObj)->Cuts + i); i++ )
-// iterator leaves of the cut
+// iterator over the leaves of the cut
+//#define If_CutForEachLeaf( p, pCut, pLeaf, i ) \
+// for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )
#define If_CutForEachLeaf( p, pCut, pLeaf, i ) \
- for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )
+ for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, p->pPars->fLiftLeaves? (pCut)->pLeaves[i] >> 8 : (pCut)->pLeaves[i])); i++ )
+// iterator over the leaves of the sequential cut
+#define If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i ) \
+ for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i] >> 8)) && (((Shift) = ((pCut)->pLeaves[i] & 255)) >= 0); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-/*=== ifCore.c ==========================================================*/
+/*=== ifCore.c ===========================================================*/
extern int If_ManPerformMapping( If_Man_t * p );
-/*=== ifCut.c ==========================================================*/
+/*=== ifCut.c ============================================================*/
extern float If_CutAreaDerefed( If_Man_t * p, If_Cut_t * pCut, int nLevels );
extern float If_CutAreaRefed( If_Man_t * p, If_Cut_t * pCut, int nLevels );
extern float If_CutDeref( If_Man_t * p, If_Cut_t * pCut, int nLevels );
@@ -277,35 +298,39 @@ extern float If_CutFlow( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutAverageRefs( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutFilter( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutMerge( If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut );
+extern void If_CutLift( If_Cut_t * pCut );
extern void If_CutCopy( If_Cut_t * pCutDest, If_Cut_t * pCutSrc );
extern void If_ManSortCuts( If_Man_t * p, int Mode );
-/*=== ifLib.c ==========================================================*/
-extern float If_CutDelay( If_Man_t * p, If_Cut_t * pCut );
-extern void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float Required );
-/*=== ifMan.c ==========================================================*/
+/*=== ifMan.c =============================================================*/
extern If_Man_t * If_ManStart( If_Par_t * pPars );
extern void If_ManStop( If_Man_t * p );
-extern If_Obj_t * If_ManCreatePi( If_Man_t * p );
-extern If_Obj_t * If_ManCreatePo( If_Man_t * p, If_Obj_t * pDriver, int fCompl0 );
+extern If_Obj_t * If_ManCreateCi( If_Man_t * p );
+extern If_Obj_t * If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver, int fCompl0 );
extern If_Obj_t * If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, int fCompl0, If_Obj_t * pFan1, int fCompl1 );
extern void If_ManCreateChoice( If_Man_t * p, If_Obj_t * pRepr );
-/*=== ifMap.c ==========================================================*/
-extern void If_ObjPerformMapping( If_Man_t * p, If_Obj_t * pObj, int Mode );
+/*=== ifMap.c =============================================================*/
+extern void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode );
+extern void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode );
extern int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fRequired, char * pLabel );
/*=== ifPrepro.c ==========================================================*/
extern void If_ManPerformMappingPreprocess( If_Man_t * p );
/*=== ifReduce.c ==========================================================*/
extern void If_ManImproveMapping( If_Man_t * p );
-/*=== ifSeq.c ==========================================================*/
+/*=== ifSeq.c =============================================================*/
extern int If_ManPerformMappingSeq( If_Man_t * p );
-/*=== ifTruth.c ==========================================================*/
+/*=== ifTime.c ============================================================*/
+extern float If_CutDelay( If_Man_t * p, If_Cut_t * pCut );
+extern void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float Required );
+/*=== ifTruth.c ===========================================================*/
extern void If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
-/*=== ifUtil.c ==========================================================*/
-extern float If_ManDelayMax( If_Man_t * p );
+/*=== ifUtil.c ============================================================*/
extern void If_ManCleanNodeCopy( If_Man_t * p );
extern void If_ManCleanCutData( If_Man_t * p );
+extern void If_ManCleanMarkV( If_Man_t * p );
+extern float If_ManDelayMax( If_Man_t * p, int fSeq );
extern void If_ManComputeRequired( If_Man_t * p, int fFirstTime );
extern float If_ManScanMapping( If_Man_t * p );
+extern float If_ManScanMappingSeq( If_Man_t * p );
#ifdef __cplusplus
}