Commit 3712dd30 by Alan Mishchenko

Changes for delay-oriented computation.

parent 0f64f3b7
...@@ -526,6 +526,10 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At ...@@ -526,6 +526,10 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((pFanin) = Abc_ObjFanin(pObj, i)), 1); i++ ) for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((pFanin) = Abc_ObjFanin(pObj, i)), 1); i++ )
#define Abc_ObjForEachFanout( pObj, pFanout, i ) \ #define Abc_ObjForEachFanout( pObj, pFanout, i ) \
for ( i = 0; (i < Abc_ObjFanoutNum(pObj)) && (((pFanout) = Abc_ObjFanout(pObj, i)), 1); i++ ) for ( i = 0; (i < Abc_ObjFanoutNum(pObj)) && (((pFanout) = Abc_ObjFanout(pObj, i)), 1); i++ )
#define Abc_ObjForEachFaninId( pObj, iFanin, i ) \
for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((iFanin) = Abc_ObjFaninId(pObj, i)), 1); i++ )
#define Abc_ObjForEachFanoutId( pObj, iFanout, i ) \
for ( i = 0; (i < Abc_ObjFanoutNum(pObj)) && (((iFanout) = Abc_ObjFanoutId(pObj, i)), 1); i++ )
// cubes and literals // cubes and literals
#define Abc_CubeForEachVar( pCube, Value, i ) \ #define Abc_CubeForEachVar( pCube, Value, i ) \
for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ ) for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )
......
...@@ -880,7 +880,7 @@ Abc_Ntk_t * Abc_NtkFromCellMappedGia( Gia_Man_t * p ) ...@@ -880,7 +880,7 @@ Abc_Ntk_t * Abc_NtkFromCellMappedGia( Gia_Man_t * p )
Abc_Obj_t * pObjNew, * pObjNewLi, * pObjNewLo; Abc_Obj_t * pObjNew, * pObjNewLi, * pObjNewLo;
Gia_Obj_t * pObj, * pObjLi, * pObjLo; Gia_Obj_t * pObj, * pObjLi, * pObjLo;
int i, k, iLit, iFanLit, nCells, fNeedConst[2] = {0}; int i, k, iLit, iFanLit, nCells, fNeedConst[2] = {0};
Mio_Cell_t * pCells = Mio_CollectRootsNewDefault( 6, &nCells, 0 ); Mio_Cell2_t * pCells = Mio_CollectRootsNewDefault2( 6, &nCells, 0 );
assert( Gia_ManHasCellMapping(p) ); assert( Gia_ManHasCellMapping(p) );
// start network // start network
pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_MAP, 1 ); pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_MAP, 1 );
......
...@@ -65,10 +65,11 @@ struct Mio_Cell2_t_ ...@@ -65,10 +65,11 @@ struct Mio_Cell2_t_
word uTruth; // truth table word uTruth; // truth table
word DelayAve; // average delay word DelayAve; // average delay
word Delays[6]; // delay word Delays[6]; // delay
void * pMioGate; // gate pointer
}; };
#define MIO_NUM 1000000 #define MIO_NUM 1000
#define MIO_NUMINV 0.000001 #define MIO_NUMINV 0.001
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// GLOBAL VARIABLES /// /// GLOBAL VARIABLES ///
......
...@@ -635,6 +635,7 @@ static inline void Mio_CollectCopy2( Mio_Cell2_t * pCell, Mio_Gate_t * pGate ) ...@@ -635,6 +635,7 @@ static inline void Mio_CollectCopy2( Mio_Cell2_t * pCell, Mio_Gate_t * pGate )
pCell->uTruth = pGate->uTruth; pCell->uTruth = pGate->uTruth;
pCell->Area = (word)(MIO_NUM * pGate->dArea); pCell->Area = (word)(MIO_NUM * pGate->dArea);
pCell->nFanins = pGate->nInputs; pCell->nFanins = pGate->nInputs;
pCell->pMioGate = pGate;
pCell->DelayAve = 0; pCell->DelayAve = 0;
for ( k = 0, pPin = pGate->pPins; pPin; pPin = pPin->pNext, k++ ) for ( k = 0, pPin = pGate->pPins; pPin; pPin = pPin->pNext, k++ )
{ {
......
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
#include "misc/vec/vec.h" #include "misc/vec/vec.h"
#include "sat/bsat/satSolver.h" #include "sat/bsat/satSolver.h"
#include "misc/util/utilNam.h"
#include "map/scl/sclCon.h"
#include "misc/st/st.h"
#include "map/mio/mio.h"
#include "base/abc/abc.h"
#include "sfm.h" #include "sfm.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -56,6 +61,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -56,6 +61,7 @@ ABC_NAMESPACE_HEADER_START
typedef struct Sfm_Fun_t_ Sfm_Fun_t; typedef struct Sfm_Fun_t_ Sfm_Fun_t;
typedef struct Sfm_Lib_t_ Sfm_Lib_t; typedef struct Sfm_Lib_t_ Sfm_Lib_t;
typedef struct Sfm_Tim_t_ Sfm_Tim_t;
struct Sfm_Ntk_t_ struct Sfm_Ntk_t_
{ {
...@@ -195,6 +201,8 @@ extern int Sfm_LibFindComplInputGate( Vec_Wrd_t * vFuncs, int iGate, in ...@@ -195,6 +201,8 @@ extern int Sfm_LibFindComplInputGate( Vec_Wrd_t * vFuncs, int iGate, in
extern Sfm_Lib_t * Sfm_LibPrepare( int nVars, int fTwo, int fDelay, int fVerbose ); extern Sfm_Lib_t * Sfm_LibPrepare( int nVars, int fTwo, int fDelay, int fVerbose );
extern void Sfm_LibPrint( Sfm_Lib_t * p ); extern void Sfm_LibPrint( Sfm_Lib_t * p );
extern void Sfm_LibStop( Sfm_Lib_t * p ); extern void Sfm_LibStop( Sfm_Lib_t * p );
extern int Sfm_LibFindMatches( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, Vec_Ptr_t * vGates, Vec_Ptr_t * vFans );
extern int Sfm_LibAddNewGates( Sfm_Lib_t * p, int * pFanins, Mio_Gate_t * pGateB, Mio_Gate_t * pGateT, char * pFansB, char * pFansT, Vec_Int_t * vGates, Vec_Wec_t * vFanins );
extern int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins, int fZeroCost ); extern int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins, int fZeroCost );
/*=== sfmNtk.c ==========================================================*/ /*=== sfmNtk.c ==========================================================*/
extern Sfm_Ntk_t * Sfm_ConstructNetwork( Vec_Wec_t * vFanins, int nPis, int nPos ); extern Sfm_Ntk_t * Sfm_ConstructNetwork( Vec_Wec_t * vFanins, int nPis, int nPos );
...@@ -203,6 +211,16 @@ extern void Sfm_NtkUpdate( Sfm_Ntk_t * p, int iNode, int f, int iFaninNe ...@@ -203,6 +211,16 @@ extern void Sfm_NtkUpdate( Sfm_Ntk_t * p, int iNode, int f, int iFaninNe
/*=== sfmSat.c ==========================================================*/ /*=== sfmSat.c ==========================================================*/
extern int Sfm_NtkWindowToSolver( Sfm_Ntk_t * p ); extern int Sfm_NtkWindowToSolver( Sfm_Ntk_t * p );
extern word Sfm_ComputeInterpolant( Sfm_Ntk_t * p ); extern word Sfm_ComputeInterpolant( Sfm_Ntk_t * p );
/*=== sfmTime.c ==========================================================*/
extern Sfm_Tim_t * Sfm_TimStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk );
extern void Sfm_TimStop( Sfm_Tim_t * p );
extern int Sfm_TimReadNtkDelay( Sfm_Tim_t * p );
extern int Sfm_TimReadObjDelay( Sfm_Tim_t * p, int iObj );
extern void Sfm_TimUpdateTiming( Sfm_Tim_t * p, Vec_Int_t * vTimeNodes );
extern int Sfm_TimSortArrayByArrival( Sfm_Tim_t * p, Vec_Int_t * vNodes, int iPivot );
extern int Sfm_TimPriorityNodes( Sfm_Tim_t * p, Vec_Int_t * vCands );
extern int Sfm_TimNodeIsNonCritical( Sfm_Tim_t * p, Abc_Obj_t * pPivot, Abc_Obj_t * pNode );
extern int Sfm_TimEvalRemapping( Sfm_Tim_t * p, Vec_Int_t * vFanins, Mio_Gate_t * pGate1, char * pFans1, Mio_Gate_t * pGate2, char * pFans2 );
/*=== sfmWin.c ==========================================================*/ /*=== sfmWin.c ==========================================================*/
extern int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj ); extern int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj );
extern int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose ); extern int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose );
......
...@@ -548,6 +548,64 @@ void Sfm_LibTest() ...@@ -548,6 +548,64 @@ void Sfm_LibTest()
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Sfm_LibFindMatches( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, Vec_Ptr_t * vGates, Vec_Ptr_t * vFans )
{
Mio_Cell2_t * pCellB, * pCellT;
Sfm_Fun_t * pObj;
int iFunc;
Vec_PtrClear( vGates );
Vec_PtrClear( vFans );
// look for gate
assert( uTruth != 0 && uTruth != ~(word)0 && uTruth != s_Truths6[0] && uTruth != ~s_Truths6[0] );
iFunc = *Vec_MemHashLookup( p->vTtMem, &uTruth );
if ( iFunc == -1 )
return 0;
// collect matches
Sfm_LibForEachSuper( p, pObj, iFunc )
{
pCellB = p->pCells + (int)pObj->pFansB[0];
pCellT = p->pCells + (int)pObj->pFansT[0];
Vec_PtrPush( vGates, pCellB );
Vec_PtrPush( vGates, pCellT == p->pCells ? NULL : pCellT );
Vec_PtrPush( vFans, pObj->pFansB + 1 );
Vec_PtrPush( vFans, pCellT == p->pCells ? NULL : pObj->pFansT + 1 );
}
return Vec_PtrSize(vGates) / 2;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Sfm_LibAddNewGates( Sfm_Lib_t * p, int * pFanins, Mio_Gate_t * pGateB, Mio_Gate_t * pGateT, char * pFansB, char * pFansT, Vec_Int_t * vGates, Vec_Wec_t * vFanins )
{
Vec_Int_t * vLevel;
int i, nFanins;
// create bottom gate
Vec_IntPush( vGates, Mio_GateReadValue(pGateB) );
vLevel = Vec_WecPushLevel( vFanins );
nFanins = Mio_GateReadPinNum( pGateB );
for ( i = 0; i < nFanins; i++ )
Vec_IntPush( vLevel, pFanins[(int)pFansB[i]] );
if ( pGateT == NULL )
return 1;
// create top gate
Vec_IntPush( vGates, Mio_GateReadValue(pGateT) );
vLevel = Vec_WecPushLevel( vFanins );
for ( i = 0; i < nFanins; i++ )
if ( pFansT[i] == (char)16 )
Vec_IntPush( vLevel, Vec_WecSize(vFanins)-2 );
else
Vec_IntPush( vLevel, pFanins[(int)pFansT[i]] );
return 2;
}
int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins, int fZeroCost ) int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins, int fZeroCost )
{ {
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen(); Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
...@@ -587,6 +645,7 @@ int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, in ...@@ -587,6 +645,7 @@ int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, in
pCellT = p->pCells + (int)pObjMin->pFansT[0]; pCellT = p->pCells + (int)pObjMin->pFansT[0];
// create bottom gate // create bottom gate
pGate = Mio_LibraryReadGateByName( pLib, pCellB->pName, NULL ); pGate = Mio_LibraryReadGateByName( pLib, pCellB->pName, NULL );
assert( pGate == pCellB->pMioGate );
Vec_IntPush( vGates, Mio_GateReadValue(pGate) ); Vec_IntPush( vGates, Mio_GateReadValue(pGate) );
vLevel = Vec_WecPushLevel( vFanins ); vLevel = Vec_WecPushLevel( vFanins );
for ( i = 0; i < (int)pCellB->nFanins; i++ ) for ( i = 0; i < (int)pCellB->nFanins; i++ )
...@@ -595,6 +654,7 @@ int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, in ...@@ -595,6 +654,7 @@ int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, in
return 1; return 1;
// create top gate // create top gate
pGate = Mio_LibraryReadGateByName( pLib, pCellT->pName, NULL ); pGate = Mio_LibraryReadGateByName( pLib, pCellT->pName, NULL );
assert( pGate == pCellT->pMioGate );
Vec_IntPush( vGates, Mio_GateReadValue(pGate) ); Vec_IntPush( vGates, Mio_GateReadValue(pGate) );
vLevel = Vec_WecPushLevel( vFanins ); vLevel = Vec_WecPushLevel( vFanins );
for ( i = 0; i < (int)pCellT->nFanins; i++ ) for ( i = 0; i < (int)pCellT->nFanins; i++ )
......
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