Commit 6c68b76b by Alan Mishchenko

Version abc80123

parent d4fecf91
...@@ -1850,10 +1850,6 @@ SOURCE=.\src\map\if\ifReduce.c ...@@ -1850,10 +1850,6 @@ SOURCE=.\src\map\if\ifReduce.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\map\if\ifSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifTime.c SOURCE=.\src\map\if\ifTime.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -254,10 +254,11 @@ static inline Aig_Obj_t * Aig_ObjChild0( Aig_Obj_t * pObj ) { return pObj- ...@@ -254,10 +254,11 @@ static inline Aig_Obj_t * Aig_ObjChild0( Aig_Obj_t * pObj ) { return pObj-
static inline Aig_Obj_t * Aig_ObjChild1( Aig_Obj_t * pObj ) { return pObj->pFanin1; } static inline Aig_Obj_t * Aig_ObjChild1( Aig_Obj_t * pObj ) { return pObj->pFanin1; }
static inline Aig_Obj_t * Aig_ObjChild0Copy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj)) : NULL; } static inline Aig_Obj_t * Aig_ObjChild0Copy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj)) : NULL; }
static inline Aig_Obj_t * Aig_ObjChild1Copy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj)) : NULL; } static inline Aig_Obj_t * Aig_ObjChild1Copy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj)) : NULL; }
static inline void Aig_ObjChild0Flip( Aig_Obj_t * pObj ) { pObj->pFanin0 = Aig_Not(pObj->pFanin0); } static inline void Aig_ObjChild0Flip( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); pObj->pFanin0 = Aig_Not(pObj->pFanin0); }
static inline void Aig_ObjChild1Flip( Aig_Obj_t * pObj ) { pObj->pFanin1 = Aig_Not(pObj->pFanin1); } static inline void Aig_ObjChild1Flip( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); pObj->pFanin1 = Aig_Not(pObj->pFanin1); }
static inline int Aig_ObjLevel( Aig_Obj_t * pObj ) { return pObj->Level; } static inline int Aig_ObjLevel( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return pObj->Level; }
static inline int Aig_ObjLevelNew( Aig_Obj_t * pObj ) { return Aig_ObjFanin1(pObj)? 1 + Aig_ObjIsExor(pObj) + AIG_MAX(Aig_ObjFanin0(pObj)->Level, Aig_ObjFanin1(pObj)->Level) : Aig_ObjFanin0(pObj)->Level; } static inline int Aig_ObjLevelNew( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? 1 + Aig_ObjIsExor(pObj) + AIG_MAX(Aig_ObjFanin0(pObj)->Level, Aig_ObjFanin1(pObj)->Level) : Aig_ObjFanin0(pObj)->Level; }
static inline int Aig_ObjSetLevel( Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return pObj->Level = i; }
static inline void Aig_ObjClean( Aig_Obj_t * pObj ) { memset( pObj, 0, sizeof(Aig_Obj_t) ); } static inline void Aig_ObjClean( Aig_Obj_t * pObj ) { memset( pObj, 0, sizeof(Aig_Obj_t) ); }
static inline Aig_Obj_t * Aig_ObjFanout0( Aig_Man_t * p, Aig_Obj_t * pObj ) { assert(p->pFanData && pObj->Id < p->nFansAlloc); return Aig_ManObj(p, p->pFanData[5*pObj->Id] >> 1); } static inline Aig_Obj_t * Aig_ObjFanout0( Aig_Man_t * p, Aig_Obj_t * pObj ) { assert(p->pFanData && pObj->Id < p->nFansAlloc); return Aig_ManObj(p, p->pFanData[5*pObj->Id] >> 1); }
static inline Aig_Obj_t * Aig_ObjEquiv( Aig_Man_t * p, Aig_Obj_t * pObj ) { return p->pEquivs? p->pEquivs[pObj->Id] : NULL; } static inline Aig_Obj_t * Aig_ObjEquiv( Aig_Man_t * p, Aig_Obj_t * pObj ) { return p->pEquivs? p->pEquivs[pObj->Id] : NULL; }
......
...@@ -158,6 +158,7 @@ Aig_Man_t * Aig_ManDup( Aig_Man_t * p, int fOrdered ) ...@@ -158,6 +158,7 @@ Aig_Man_t * Aig_ManDup( Aig_Man_t * p, int fOrdered )
{ {
pObjNew = Aig_ObjCreatePi( pNew ); pObjNew = Aig_ObjCreatePi( pNew );
pObjNew->pHaig = pObj->pHaig; pObjNew->pHaig = pObj->pHaig;
pObjNew->Level = pObj->Level;
pObj->pData = pObjNew; pObj->pData = pObjNew;
} }
// duplicate internal nodes // duplicate internal nodes
......
...@@ -70,6 +70,7 @@ struct Ntl_Man_t_ ...@@ -70,6 +70,7 @@ struct Ntl_Man_t_
Vec_Ptr_t * vCis; // the primary inputs of the extracted part Vec_Ptr_t * vCis; // the primary inputs of the extracted part
Vec_Ptr_t * vCos; // the primary outputs of the extracted part Vec_Ptr_t * vCos; // the primary outputs of the extracted part
Vec_Ptr_t * vNodes; // the nodes of the abstracted part Vec_Ptr_t * vNodes; // the nodes of the abstracted part
Vec_Int_t * vBox1Cos; // the first COs of the boxes
Aig_Man_t * pAig; // the extracted AIG Aig_Man_t * pAig; // the extracted AIG
Tim_Man_t * pManTime; // the timing manager Tim_Man_t * pManTime; // the timing manager
}; };
...@@ -143,6 +144,8 @@ static inline int Ntl_ModelPoNum( Ntl_Mod_t * p ) { return p->nO ...@@ -143,6 +144,8 @@ static inline int Ntl_ModelPoNum( Ntl_Mod_t * p ) { return p->nO
static inline int Ntl_ModelNodeNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_NODE]; } static inline int Ntl_ModelNodeNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_NODE]; }
static inline int Ntl_ModelLatchNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_LATCH]; } static inline int Ntl_ModelLatchNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_LATCH]; }
static inline int Ntl_ModelBoxNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_BOX]; } static inline int Ntl_ModelBoxNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_BOX]; }
static inline int Ntl_ModelCiNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_PI] + p->nObjs[NTL_OBJ_LATCH]; }
static inline int Ntl_ModelCoNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_PO] + p->nObjs[NTL_OBJ_LATCH]; }
static inline Ntl_Obj_t * Ntl_ModelPi( Ntl_Mod_t * p, int i ) { return Vec_PtrEntry(p->vPis, i); } static inline Ntl_Obj_t * Ntl_ModelPi( Ntl_Mod_t * p, int i ) { return Vec_PtrEntry(p->vPis, i); }
static inline Ntl_Obj_t * Ntl_ModelPo( Ntl_Mod_t * p, int i ) { return Vec_PtrEntry(p->vPos, i); } static inline Ntl_Obj_t * Ntl_ModelPo( Ntl_Mod_t * p, int i ) { return Vec_PtrEntry(p->vPos, i); }
...@@ -217,6 +220,7 @@ static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int ...@@ -217,6 +220,7 @@ static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/*=== ntlAig.c ==========================================================*/ /*=== ntlAig.c ==========================================================*/
extern Aig_Obj_t * Ntl_ManExtractAigNode( Ntl_Obj_t * pNode );
extern int Ntl_ManExtract( Ntl_Man_t * p ); extern int Ntl_ManExtract( Ntl_Man_t * p );
extern int Ntl_ManInsert( Ntl_Man_t * p, Vec_Ptr_t * vMapping ); extern int Ntl_ManInsert( Ntl_Man_t * p, Vec_Ptr_t * vMapping );
extern int Ntl_ManInsertTest( Ntl_Man_t * p ); extern int Ntl_ManInsertTest( Ntl_Man_t * p );
...@@ -239,7 +243,7 @@ extern void Ntl_ModelFree( Ntl_Mod_t * p ); ...@@ -239,7 +243,7 @@ extern void Ntl_ModelFree( Ntl_Mod_t * p );
extern Vec_Ptr_t * Ntl_MappingAlloc( int nLuts, int nVars ); extern Vec_Ptr_t * Ntl_MappingAlloc( int nLuts, int nVars );
extern Vec_Ptr_t * Ntl_MappingFromAig( Aig_Man_t * p ); extern Vec_Ptr_t * Ntl_MappingFromAig( Aig_Man_t * p );
extern Vec_Ptr_t * Ntl_MappingFpga( Aig_Man_t * p ); extern Vec_Ptr_t * Ntl_MappingFpga( Aig_Man_t * p );
extern Vec_Ptr_t * Ntl_MappingIf( Aig_Man_t * p ); extern Vec_Ptr_t * Ntl_MappingIf( Ntl_Man_t * pMan, Aig_Man_t * p );
/*=== ntlObj.c ============================================================*/ /*=== ntlObj.c ============================================================*/
extern Ntl_Obj_t * Ntl_ModelCreatePi( Ntl_Mod_t * pModel ); extern Ntl_Obj_t * Ntl_ModelCreatePi( Ntl_Mod_t * pModel );
extern Ntl_Obj_t * Ntl_ModelCreatePo( Ntl_Mod_t * pModel, Ntl_Net_t * pNet ); extern Ntl_Obj_t * Ntl_ModelCreatePo( Ntl_Mod_t * pModel, Ntl_Net_t * pNet );
...@@ -254,6 +258,8 @@ extern Ntl_Net_t * Ntl_ModelFindNet( Ntl_Mod_t * p, char * pName ); ...@@ -254,6 +258,8 @@ extern Ntl_Net_t * Ntl_ModelFindNet( Ntl_Mod_t * p, char * pName );
extern Ntl_Net_t * Ntl_ModelFindOrCreateNet( Ntl_Mod_t * p, char * pName ); extern Ntl_Net_t * Ntl_ModelFindOrCreateNet( Ntl_Mod_t * p, char * pName );
extern int Ntl_ModelSetNetDriver( Ntl_Obj_t * pObj, Ntl_Net_t * pNet ); extern int Ntl_ModelSetNetDriver( Ntl_Obj_t * pObj, Ntl_Net_t * pNet );
extern int Ntl_ModelFindPioNumber( Ntl_Mod_t * p, char * pName, int * pNumber ); extern int Ntl_ModelFindPioNumber( Ntl_Mod_t * p, char * pName, int * pNumber );
/*=== ntlTime.c ==========================================================*/
extern Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p );
/*=== ntlReadBlif.c ==========================================================*/ /*=== ntlReadBlif.c ==========================================================*/
extern Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck ); extern Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck );
/*=== ntlWriteBlif.c ==========================================================*/ /*=== ntlWriteBlif.c ==========================================================*/
......
...@@ -367,7 +367,7 @@ Aig_Obj_t * Ntl_ManExtractAigNode( Ntl_Obj_t * pNode ) ...@@ -367,7 +367,7 @@ Aig_Obj_t * Ntl_ManExtractAigNode( Ntl_Obj_t * pNode )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ntl_ManExtract( Ntl_Man_t * p ) int Ntl_ManExtract_old( Ntl_Man_t * p )
{ {
Ntl_Obj_t * pNode; Ntl_Obj_t * pNode;
Ntl_Net_t * pNet; Ntl_Net_t * pNet;
...@@ -394,6 +394,30 @@ int Ntl_ManExtract( Ntl_Man_t * p ) ...@@ -394,6 +394,30 @@ int Ntl_ManExtract( Ntl_Man_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Extracts AIG from the netlist.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ntl_ManExtract( Ntl_Man_t * p )
{
// start the AIG manager
assert( p->pAig == NULL );
p->pAig = Aig_ManStart( 10000 );
// check the DFS traversal
if ( !Ntl_ManDfs( p ) )
return 0;
// cleanup the AIG
Aig_ManCleanup( p->pAig );
return 1;
}
/**Function*************************************************************
Synopsis [Inserts the given mapping into the netlist.] Synopsis [Inserts the given mapping into the netlist.]
Description [] Description []
...@@ -557,8 +581,8 @@ int Ntl_ManInsertTestIf( Ntl_Man_t * p ) ...@@ -557,8 +581,8 @@ int Ntl_ManInsertTestIf( Ntl_Man_t * p )
if ( !Ntl_ManExtract( p ) ) if ( !Ntl_ManExtract( p ) )
return 0; return 0;
assert( p->pAig != NULL ); assert( p->pAig != NULL );
Ntl_ManPerformSynthesis( p ); // Ntl_ManPerformSynthesis( p );
vMapping = Ntl_MappingIf( p->pAig ); vMapping = Ntl_MappingIf( p, p->pAig );
RetValue = Ntl_ManInsert( p, vMapping ); RetValue = Ntl_ManInsert( p, vMapping );
Vec_PtrFree( vMapping ); Vec_PtrFree( vMapping );
return RetValue; return RetValue;
......
...@@ -63,13 +63,27 @@ int Ntl_ManDfs_rec( Ntl_Man_t * p, Ntl_Net_t * pNet ) ...@@ -63,13 +63,27 @@ int Ntl_ManDfs_rec( Ntl_Man_t * p, Ntl_Net_t * pNet )
// add box inputs/outputs to COs/CIs // add box inputs/outputs to COs/CIs
if ( Ntl_ObjIsBox(pObj) ) if ( Ntl_ObjIsBox(pObj) )
{ {
int LevelCur, LevelMax = -AIG_INFINITY;
Vec_IntPush( p->vBox1Cos, Aig_ManPoNum(p->pAig) );
Ntl_ObjForEachFanin( pObj, pNetFanin, i ) Ntl_ObjForEachFanin( pObj, pNetFanin, i )
{
LevelCur = Aig_ObjLevel( Aig_Regular(pNetFanin->pFunc) );
LevelMax = AIG_MAX( LevelMax, LevelCur );
Vec_PtrPush( p->vCos, pNetFanin ); Vec_PtrPush( p->vCos, pNetFanin );
Aig_ObjCreatePo( p->pAig, pNetFanin->pFunc );
}
Ntl_ObjForEachFanout( pObj, pNetFanin, i ) Ntl_ObjForEachFanout( pObj, pNetFanin, i )
{
Vec_PtrPush( p->vCis, pNetFanin ); Vec_PtrPush( p->vCis, pNetFanin );
pNetFanin->pFunc = Aig_ObjCreatePi( p->pAig );
Aig_ObjSetLevel( pNetFanin->pFunc, LevelMax + 1 );
}
//printf( "Creating fake PO with ID = %d.\n", Aig_ManPo(p->pAig, Vec_IntEntryLast(p->vBox1Cos))->Id );
} }
// store the node // store the node
Vec_PtrPush( p->vNodes, pObj ); Vec_PtrPush( p->vNodes, pObj );
if ( Ntl_ObjIsNode(pObj) )
pNet->pFunc = Ntl_ManExtractAigNode( pObj );
pNet->nVisits = 2; pNet->nVisits = 2;
return 1; return 1;
} }
...@@ -95,6 +109,7 @@ int Ntl_ManDfs( Ntl_Man_t * p ) ...@@ -95,6 +109,7 @@ int Ntl_ManDfs( Ntl_Man_t * p )
assert( Vec_PtrSize(p->vCis) == 0 ); assert( Vec_PtrSize(p->vCis) == 0 );
assert( Vec_PtrSize(p->vCos) == 0 ); assert( Vec_PtrSize(p->vCos) == 0 );
assert( Vec_PtrSize(p->vNodes) == 0 ); assert( Vec_PtrSize(p->vNodes) == 0 );
assert( Vec_IntSize(p->vBox1Cos) == 0 );
// get the root model // get the root model
pRoot = Vec_PtrEntry( p->vModels, 0 ); pRoot = Vec_PtrEntry( p->vModels, 0 );
// collect primary inputs // collect primary inputs
...@@ -103,6 +118,7 @@ int Ntl_ManDfs( Ntl_Man_t * p ) ...@@ -103,6 +118,7 @@ int Ntl_ManDfs( Ntl_Man_t * p )
assert( Ntl_ObjFanoutNum(pObj) == 1 ); assert( Ntl_ObjFanoutNum(pObj) == 1 );
pNet = Ntl_ObjFanout0(pObj); pNet = Ntl_ObjFanout0(pObj);
Vec_PtrPush( p->vCis, pNet ); Vec_PtrPush( p->vCis, pNet );
pNet->pFunc = Aig_ObjCreatePi( p->pAig );
if ( pNet->nVisits ) if ( pNet->nVisits )
{ {
printf( "Ntl_ManDfs(): Primary input appears twice in the list.\n" ); printf( "Ntl_ManDfs(): Primary input appears twice in the list.\n" );
...@@ -116,6 +132,7 @@ int Ntl_ManDfs( Ntl_Man_t * p ) ...@@ -116,6 +132,7 @@ int Ntl_ManDfs( Ntl_Man_t * p )
assert( Ntl_ObjFanoutNum(pObj) == 1 ); assert( Ntl_ObjFanoutNum(pObj) == 1 );
pNet = Ntl_ObjFanout0(pObj); pNet = Ntl_ObjFanout0(pObj);
Vec_PtrPush( p->vCis, pNet ); Vec_PtrPush( p->vCis, pNet );
pNet->pFunc = Aig_ObjCreatePi( p->pAig );
if ( pNet->nVisits ) if ( pNet->nVisits )
{ {
printf( "Ntl_ManDfs(): Latch output is duplicated or defined as a primary input.\n" ); printf( "Ntl_ManDfs(): Latch output is duplicated or defined as a primary input.\n" );
...@@ -136,6 +153,7 @@ int Ntl_ManDfs( Ntl_Man_t * p ) ...@@ -136,6 +153,7 @@ int Ntl_ManDfs( Ntl_Man_t * p )
return 0; return 0;
} }
Vec_PtrPush( p->vCos, pNet ); Vec_PtrPush( p->vCos, pNet );
Aig_ObjCreatePo( p->pAig, pNet->pFunc );
} }
// visit the nodes starting from latch inputs outputs // visit the nodes starting from latch inputs outputs
Ntl_ModelForEachLatch( pRoot, pObj, i ) Ntl_ModelForEachLatch( pRoot, pObj, i )
...@@ -150,6 +168,7 @@ int Ntl_ManDfs( Ntl_Man_t * p ) ...@@ -150,6 +168,7 @@ int Ntl_ManDfs( Ntl_Man_t * p )
return 0; return 0;
} }
Vec_PtrPush( p->vCos, pNet ); Vec_PtrPush( p->vCos, pNet );
Aig_ObjCreatePo( p->pAig, pNet->pFunc );
} }
// report the number of dangling objects // report the number of dangling objects
nUselessObjects = Ntl_ModelNodeNum(pRoot) + Ntl_ModelBoxNum(pRoot) - Vec_PtrSize(p->vNodes); nUselessObjects = Ntl_ModelNodeNum(pRoot) + Ntl_ModelBoxNum(pRoot) - Vec_PtrSize(p->vNodes);
......
...@@ -49,6 +49,7 @@ Ntl_Man_t * Ntl_ManAlloc( char * pFileName ) ...@@ -49,6 +49,7 @@ Ntl_Man_t * Ntl_ManAlloc( char * pFileName )
p->vCis = Vec_PtrAlloc( 1000 ); p->vCis = Vec_PtrAlloc( 1000 );
p->vCos = Vec_PtrAlloc( 1000 ); p->vCos = Vec_PtrAlloc( 1000 );
p->vNodes = Vec_PtrAlloc( 1000 ); p->vNodes = Vec_PtrAlloc( 1000 );
p->vBox1Cos = Vec_IntAlloc( 1000 );
// start the manager // start the manager
p->pMemObjs = Aig_MmFlexStart(); p->pMemObjs = Aig_MmFlexStart();
p->pMemSops = Aig_MmFlexStart(); p->pMemSops = Aig_MmFlexStart();
...@@ -82,6 +83,7 @@ void Ntl_ManFree( Ntl_Man_t * p ) ...@@ -82,6 +83,7 @@ void Ntl_ManFree( Ntl_Man_t * p )
if ( p->vCis ) Vec_PtrFree( p->vCis ); if ( p->vCis ) Vec_PtrFree( p->vCis );
if ( p->vCos ) Vec_PtrFree( p->vCos ); if ( p->vCos ) Vec_PtrFree( p->vCos );
if ( p->vNodes ) Vec_PtrFree( p->vNodes ); if ( p->vNodes ) Vec_PtrFree( p->vNodes );
if ( p->vBox1Cos ) Vec_IntFree( p->vBox1Cos );
if ( p->pMemObjs ) Aig_MmFlexStop( p->pMemObjs, 0 ); if ( p->pMemObjs ) Aig_MmFlexStop( p->pMemObjs, 0 );
if ( p->pMemSops ) Aig_MmFlexStop( p->pMemSops, 0 ); if ( p->pMemSops ) Aig_MmFlexStop( p->pMemSops, 0 );
if ( p->pAig ) Aig_ManStop( p->pAig ); if ( p->pAig ) Aig_ManStop( p->pAig );
......
...@@ -412,7 +412,7 @@ void Ntk_ManSetIfParsDefault( If_Par_t * pPars ) ...@@ -412,7 +412,7 @@ void Ntk_ManSetIfParsDefault( If_Par_t * pPars )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
If_Man_t * Ntk_ManToIf( Aig_Man_t * p, If_Par_t * pPars ) If_Man_t * Ntk_ManToIf_old( Aig_Man_t * p, If_Par_t * pPars )
{ {
If_Man_t * pIfMan; If_Man_t * pIfMan;
Aig_Obj_t * pNode;//, * pFanin, * pPrev; Aig_Obj_t * pNode;//, * pFanin, * pPrev;
...@@ -455,6 +455,58 @@ If_Man_t * Ntk_ManToIf( Aig_Man_t * p, If_Par_t * pPars ) ...@@ -455,6 +455,58 @@ If_Man_t * Ntk_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Load the network into FPGA manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
If_Man_t * Ntk_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
{
If_Man_t * pIfMan;
Aig_Obj_t * pNode;//, * pFanin, * pPrev;
int i;
// start the mapping manager and set its parameters
pIfMan = If_ManStart( pPars );
// print warning about excessive memory usage
if ( 1.0 * Aig_ManObjNum(p) * pIfMan->nObjBytes / (1<<30) > 1.0 )
printf( "Warning: The mapper will allocate %.1f Gb for to represent the subject graph with %d AIG nodes.\n",
1.0 * Aig_ManObjNum(p) * pIfMan->nObjBytes / (1<<30), Aig_ManObjNum(p) );
// load the AIG into the mapper
Aig_ManForEachObj( p, pNode, i )
{
if ( Aig_ObjIsAnd(pNode) )
pNode->pData = (Aig_Obj_t *)If_ManCreateAnd( pIfMan,
If_NotCond( (If_Obj_t *)Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ),
If_NotCond( (If_Obj_t *)Aig_ObjFanin1(pNode)->pData, Aig_ObjFaninC1(pNode) ) );
else if ( Aig_ObjIsPi(pNode) )
{
pNode->pData = If_ManCreateCi( pIfMan );
((If_Obj_t *)pNode->pData)->Level = pNode->Level;
}
else if ( Aig_ObjIsPo(pNode) )
If_ManCreateCo( pIfMan, If_NotCond( Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ) );
else if ( Aig_ObjIsConst1(pNode) )
Aig_ManConst1(p)->pData = If_ManConst1( pIfMan );
else // add the node to the mapper
assert( 0 );
// set up the choice node
// if ( Aig_AigNodeIsChoice( pNode ) )
// {
// pIfMan->nChoices++;
// for ( pPrev = pNode, pFanin = pNode->pData; pFanin; pPrev = pFanin, pFanin = pFanin->pData )
// If_ObjSetChoice( (If_Obj_t *)pPrev->pData, (If_Obj_t *)pFanin->pData );
// If_ManCreateChoice( pIfMan, (If_Obj_t *)pNode->pData );
// }
}
return pIfMan;
}
/**Function*************************************************************
Synopsis [Creates the mapped network.] Synopsis [Creates the mapped network.]
Description [] Description []
...@@ -491,10 +543,9 @@ Vec_Ptr_t * Ntk_ManFromIf( Aig_Man_t * p, If_Man_t * pMan ) ...@@ -491,10 +543,9 @@ Vec_Ptr_t * Ntk_ManFromIf( Aig_Man_t * p, If_Man_t * pMan )
Vec_IntWriteEntry( vIfToAig, pNode->Id, pObj->Id ); Vec_IntWriteEntry( vIfToAig, pNode->Id, pObj->Id );
} }
// create the mapping // create the mapping
If_ManScanMappingDirect( pMan ); vIfMap = If_ManCollectMappingDirect( pMan );
nVarsMax = pMan->pPars->nLutSize; nVarsMax = pMan->pPars->nLutSize;
nWords = Aig_TruthWordNum( nVarsMax ); nWords = Aig_TruthWordNum( nVarsMax );
vIfMap = pMan->vMapped;
vMapping = Ntl_MappingAlloc( Vec_PtrSize(vIfMap) + (int)(Aig_ManConst1(p)->nRefs > 0), nVarsMax ); vMapping = Ntl_MappingAlloc( Vec_PtrSize(vIfMap) + (int)(Aig_ManConst1(p)->nRefs > 0), nVarsMax );
nLuts = 0; nLuts = 0;
if ( Aig_ManConst1(p)->nRefs > 0 ) if ( Aig_ManConst1(p)->nRefs > 0 )
...@@ -521,6 +572,7 @@ Vec_Ptr_t * Ntk_ManFromIf( Aig_Man_t * p, If_Man_t * pMan ) ...@@ -521,6 +572,7 @@ Vec_Ptr_t * Ntk_ManFromIf( Aig_Man_t * p, If_Man_t * pMan )
} }
assert( nLuts == Vec_PtrSize(vMapping) ); assert( nLuts == Vec_PtrSize(vMapping) );
Vec_IntFree( vIfToAig ); Vec_IntFree( vIfToAig );
Vec_PtrFree( vIfMap );
return vMapping; return vMapping;
} }
...@@ -535,7 +587,7 @@ Vec_Ptr_t * Ntk_ManFromIf( Aig_Man_t * p, If_Man_t * pMan ) ...@@ -535,7 +587,7 @@ Vec_Ptr_t * Ntk_ManFromIf( Aig_Man_t * p, If_Man_t * pMan )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Ptr_t * Ntl_MappingIf( Aig_Man_t * p ) Vec_Ptr_t * Ntl_MappingIf( Ntl_Man_t * pMan, Aig_Man_t * p )
{ {
Vec_Ptr_t * vMapping; Vec_Ptr_t * vMapping;
If_Par_t Pars, * pPars = &Pars; If_Par_t Pars, * pPars = &Pars;
...@@ -549,6 +601,7 @@ Vec_Ptr_t * Ntl_MappingIf( Aig_Man_t * p ) ...@@ -549,6 +601,7 @@ Vec_Ptr_t * Ntl_MappingIf( Aig_Man_t * p )
pIfMan = Ntk_ManToIf( p, pPars ); pIfMan = Ntk_ManToIf( p, pPars );
if ( pIfMan == NULL ) if ( pIfMan == NULL )
return NULL; return NULL;
pIfMan->pManTim = Ntl_ManCreateTiming( pMan );
if ( !If_ManPerformMapping( pIfMan ) ) if ( !If_ManPerformMapping( pIfMan ) )
{ {
If_ManStop( pIfMan ); If_ManStop( pIfMan );
......
...@@ -82,26 +82,19 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p ) ...@@ -82,26 +82,19 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p )
Vec_Ptr_t * vDelayTables; Vec_Ptr_t * vDelayTables;
Ntl_Mod_t * pRoot, * pModel; Ntl_Mod_t * pRoot, * pModel;
Ntl_Obj_t * pObj; Ntl_Obj_t * pObj;
int i, curPi, curPo, Entry; int i, curPi, iBox, Entry;
assert( p->pAig != NULL ); assert( p->pAig != NULL );
pRoot = Vec_PtrEntry( p->vModels, 0 );
// start the timing manager // start the timing manager
pMan = Tim_ManStart( Aig_ManPiNum(p->pAig), Aig_ManPoNum(p->pAig) ); pMan = Tim_ManStart( Aig_ManPiNum(p->pAig), Aig_ManPoNum(p->pAig) );
// add arrival time info for the true PIs
pRoot = Vec_PtrEntry( p->vModels, 0 );
Ntl_ModelForEachPi( pRoot, pObj, i )
Tim_ManInitPiArrival( pMan, i, 0.0 );
// unpack the data in the arrival times // unpack the data in the arrival times
if ( pRoot->vArrivals ) if ( pRoot->vArrivals )
Vec_IntForEachEntry( pRoot->vArrivals, Entry, i ) Vec_IntForEachEntry( pRoot->vArrivals, Entry, i )
Tim_ManInitPiArrival( pMan, Entry, Vec_IntEntry(pRoot->vArrivals,++i) ); Tim_ManInitPiArrival( pMan, Entry, Aig_Int2Float(Vec_IntEntry(pRoot->vArrivals,++i)) );
// add the required time into for the true POs
pRoot = Vec_PtrEntry( p->vModels, 0 );
Ntl_ModelForEachPo( pRoot, pObj, i )
Tim_ManInitPoRequired( pMan, i, AIG_INFINITY );
// unpack the data in the required times // unpack the data in the required times
if ( pRoot->vRequireds ) if ( pRoot->vRequireds )
Vec_IntForEachEntry( pRoot->vRequireds, Entry, i ) Vec_IntForEachEntry( pRoot->vRequireds, Entry, i )
Tim_ManInitPoRequired( pMan, Entry, Vec_IntEntry(pRoot->vRequireds,++i) ); Tim_ManInitPoRequired( pMan, Entry, Aig_Int2Float(Vec_IntEntry(pRoot->vRequireds,++i)) );
// derive timing tables // derive timing tables
vDelayTables = Vec_PtrAlloc( Vec_PtrSize(p->vModels) ); vDelayTables = Vec_PtrAlloc( Vec_PtrSize(p->vModels) );
Ntl_ManForEachModel( p, pModel, i ) Ntl_ManForEachModel( p, pModel, i )
...@@ -112,17 +105,18 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p ) ...@@ -112,17 +105,18 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p )
} }
Tim_ManSetDelayTables( pMan, vDelayTables ); Tim_ManSetDelayTables( pMan, vDelayTables );
// set up the boxes // set up the boxes
curPi = Ntl_ModelPiNum(pRoot); iBox = 0;
curPo = Ntl_ModelPoNum(pRoot); curPi = Ntl_ModelCiNum(pRoot);
Ntl_ManForEachBox( p, pObj, i ) Ntl_ManForEachBox( p, pObj, i )
{ {
Tim_ManCreateBoxFirst( pMan, curPo, Ntl_ObjFanoutNum(pObj), curPi, Ntl_ObjFaninNum(pObj), pObj->pImplem->pDelayTable ); Tim_ManCreateBoxFirst( pMan, Vec_IntEntry(p->vBox1Cos, iBox), Ntl_ObjFaninNum(pObj), curPi, Ntl_ObjFanoutNum(pObj), pObj->pImplem->pDelayTable );
curPo += Ntl_ObjFanoutNum(pObj); curPi += Ntl_ObjFanoutNum(pObj);
curPi += Ntl_ObjFaninNum(pObj); iBox++;
} }
// forget refs to the delay tables in the network // forget refs to the delay tables in the network
Ntl_ManForEachModel( p, pModel, i ) Ntl_ManForEachModel( p, pModel, i )
pModel->pDelayTable = NULL; pModel->pDelayTable = NULL;
// Tim_ManPrint( pMan );
return pMan; return pMan;
} }
......
...@@ -67,6 +67,7 @@ struct Tim_Box_t_ ...@@ -67,6 +67,7 @@ struct Tim_Box_t_
// timing object // timing object
struct Tim_Obj_t_ struct Tim_Obj_t_
{ {
int Id; // the ID of this object
int TravId; // traversal ID of this object int TravId; // traversal ID of this object
int iObj2Box; // mapping of the object into its box int iObj2Box; // mapping of the object into its box
int iObj2Num; // mapping of the object into its number in the box int iObj2Num; // mapping of the object into its number in the box
...@@ -80,14 +81,23 @@ static inline Tim_Obj_t * Tim_ManPo( Tim_Man_t * p, int i ) ...@@ -80,14 +81,23 @@ static inline Tim_Obj_t * Tim_ManPo( Tim_Man_t * p, int i )
static inline Tim_Box_t * Tim_ManPiBox( Tim_Man_t * p, int i ) { return Tim_ManPi(p,i)->iObj2Box < 0 ? NULL : Vec_PtrEntry( p->vBoxes, Tim_ManPi(p,i)->iObj2Box ); } static inline Tim_Box_t * Tim_ManPiBox( Tim_Man_t * p, int i ) { return Tim_ManPi(p,i)->iObj2Box < 0 ? NULL : Vec_PtrEntry( p->vBoxes, Tim_ManPi(p,i)->iObj2Box ); }
static inline Tim_Box_t * Tim_ManPoBox( Tim_Man_t * p, int i ) { return Tim_ManPo(p,i)->iObj2Box < 0 ? NULL : Vec_PtrEntry( p->vBoxes, Tim_ManPo(p,i)->iObj2Box ); } static inline Tim_Box_t * Tim_ManPoBox( Tim_Man_t * p, int i ) { return Tim_ManPo(p,i)->iObj2Box < 0 ? NULL : Vec_PtrEntry( p->vBoxes, Tim_ManPo(p,i)->iObj2Box ); }
static inline Tim_Obj_t * Tim_ManBoxInput( Tim_Man_t * p, Tim_Box_t * pBox, int i ) { return p->pPos + pBox->Inouts[i]; } static inline Tim_Obj_t * Tim_ManBoxInput( Tim_Man_t * p, Tim_Box_t * pBox, int i ) { assert( i < pBox->nInputs ); return p->pPos + pBox->Inouts[i]; }
static inline Tim_Obj_t * Tim_ManBoxOutput( Tim_Man_t * p, Tim_Box_t * pBox, int i ) { return p->pPis + pBox->Inouts[pBox->nInputs+i]; } static inline Tim_Obj_t * Tim_ManBoxOutput( Tim_Man_t * p, Tim_Box_t * pBox, int i ) { assert( i < pBox->nOutputs ); return p->pPis + pBox->Inouts[pBox->nInputs+i]; }
#define Tim_ManBoxForEachInput( p, pBox, pObj, i ) \ #define Tim_ManBoxForEachInput( p, pBox, pObj, i ) \
for ( i = 0; (i < (pBox)->nInputs) && ((pObj) = Tim_ManBoxInput(p, pBox, i)); i++ ) for ( i = 0; (i < (pBox)->nInputs) && ((pObj) = Tim_ManBoxInput(p, pBox, i)); i++ )
#define Tim_ManBoxForEachOutput( p, pBox, pObj, i ) \ #define Tim_ManBoxForEachOutput( p, pBox, pObj, i ) \
for ( i = 0; (i < (pBox)->nOutputs) && ((pObj) = Tim_ManBoxOutput(p, pBox, i)); i++ ) for ( i = 0; (i < (pBox)->nOutputs) && ((pObj) = Tim_ManBoxOutput(p, pBox, i)); i++ )
#define Tim_ManForEachPi( p, pObj, i ) \
for ( i = 0; (i < (p)->nPis) && ((pObj) = (p)->pPis + i); i++ ) \
if ( pObj->iObj2Box >= 0 ) {} else
#define Tim_ManForEachPo( p, pObj, i ) \
for ( i = 0; (i < (p)->nPos) && ((pObj) = (p)->pPos + i); i++ ) \
if ( pObj->iObj2Box >= 0 ) {} else
#define Tim_ManForEachBox( p, pBox, i ) \
Vec_PtrForEachEntry( p->vBoxes, pBox, i )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -111,7 +121,6 @@ Tim_Man_t * Tim_ManStart( int nPis, int nPos ) ...@@ -111,7 +121,6 @@ Tim_Man_t * Tim_ManStart( int nPis, int nPos )
memset( p, 0, sizeof(Tim_Man_t) ); memset( p, 0, sizeof(Tim_Man_t) );
p->pMemObj = Mem_FlexStart(); p->pMemObj = Mem_FlexStart();
p->vBoxes = Vec_PtrAlloc( 100 ); p->vBoxes = Vec_PtrAlloc( 100 );
Vec_PtrPush( p->vBoxes, NULL );
p->nPis = nPis; p->nPis = nPis;
p->nPos = nPos; p->nPos = nPos;
p->pPis = ALLOC( Tim_Obj_t, nPis ); p->pPis = ALLOC( Tim_Obj_t, nPis );
...@@ -119,9 +128,21 @@ Tim_Man_t * Tim_ManStart( int nPis, int nPos ) ...@@ -119,9 +128,21 @@ Tim_Man_t * Tim_ManStart( int nPis, int nPos )
p->pPos = ALLOC( Tim_Obj_t, nPos ); p->pPos = ALLOC( Tim_Obj_t, nPos );
memset( p->pPos, 0, sizeof(Tim_Obj_t) * nPos ); memset( p->pPos, 0, sizeof(Tim_Obj_t) * nPos );
for ( i = 0; i < nPis; i++ ) for ( i = 0; i < nPis; i++ )
{
p->pPis[i].Id = i;
p->pPis[i].iObj2Box = p->pPis[i].iObj2Num = -1; p->pPis[i].iObj2Box = p->pPis[i].iObj2Num = -1;
p->pPis[i].timeReq = AIG_INFINITY;
p->pPis[i].timeArr = 0.0;
p->pPis[i].TravId = 0;
}
for ( i = 0; i < nPos; i++ ) for ( i = 0; i < nPos; i++ )
{
p->pPos[i].Id = i;
p->pPos[i].iObj2Box = p->pPos[i].iObj2Num = -1; p->pPos[i].iObj2Box = p->pPos[i].iObj2Num = -1;
p->pPos[i].timeReq = AIG_INFINITY;
p->pPos[i].timeArr = 0.0;
p->pPos[i].TravId = 0;
}
return p; return p;
} }
...@@ -155,6 +176,42 @@ void Tim_ManStop( Tim_Man_t * p ) ...@@ -155,6 +176,42 @@ void Tim_ManStop( Tim_Man_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Stops the timing manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Tim_ManPrint( Tim_Man_t * p )
{
Tim_Box_t * pBox;
Tim_Obj_t * pObj;
int i;
printf( "TIMING INFORMATION:\n" );
Tim_ManForEachPi( p, pObj, i )
printf( "pi%5d : arr = %5.3f req = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
Tim_ManForEachPo( p, pObj, i )
printf( "po%5d : arr = %5.3f req = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
Tim_ManForEachBox( p, pBox, i )
{
printf( "*** Box %3d : Ins = %d. Outs = %d.\n", i, pBox->nInputs, pBox->nOutputs );
printf( "Delay table:" );
for ( i = 0; i < pBox->nInputs * pBox->nOutputs; i++ )
printf( " %5.3f", pBox->pDelayTable[i] );
printf( "\n" );
Tim_ManBoxForEachInput( p, pBox, pObj, i )
printf( "box-inp%3d : arr = %5.3f req = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
Tim_ManBoxForEachOutput( p, pBox, pObj, i )
printf( "box-out%3d : arr = %5.3f req = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
}
printf( "\n" );
}
/**Function*************************************************************
Synopsis [Sets the vector of timing tables associated with the manager.] Synopsis [Sets the vector of timing tables associated with the manager.]
Description [] Description []
...@@ -295,12 +352,12 @@ void Tim_ManInitPiArrival( Tim_Man_t * p, int iPi, float Delay ) ...@@ -295,12 +352,12 @@ void Tim_ManInitPiArrival( Tim_Man_t * p, int iPi, float Delay )
void Tim_ManInitPoRequired( Tim_Man_t * p, int iPo, float Delay ) void Tim_ManInitPoRequired( Tim_Man_t * p, int iPo, float Delay )
{ {
assert( iPo < p->nPos ); assert( iPo < p->nPos );
p->pPos[iPo].timeArr = Delay; p->pPos[iPo].timeReq = Delay;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Updates arrival time of the PO.] Synopsis [Updates required time of the PO.]
Description [] Description []
...@@ -319,7 +376,7 @@ void Tim_ManSetPoArrival( Tim_Man_t * p, int iPo, float Delay ) ...@@ -319,7 +376,7 @@ void Tim_ManSetPoArrival( Tim_Man_t * p, int iPo, float Delay )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Updates required time of the PI.] Synopsis [Updates arrival time of the PI.]
Description [] Description []
...@@ -336,6 +393,44 @@ void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay ) ...@@ -336,6 +393,44 @@ void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay )
p->pPis[iPi].TravId = p->nTravIds; p->pPis[iPi].TravId = p->nTravIds;
} }
/**Function*************************************************************
Synopsis [Updates required time of the PO.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Tim_ManSetPoRequired( Tim_Man_t * p, int iPo, float Delay )
{
assert( iPo < p->nPos );
assert( p->pPos[iPo].TravId != p->nTravIds );
p->pPos[iPo].timeReq = Delay;
p->pPos[iPo].TravId = p->nTravIds;
}
/**Function*************************************************************
Synopsis [Sets the correct required times for all POs.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Tim_ManSetPoRequiredAll( Tim_Man_t * p, float Delay )
{
Tim_Obj_t * pObj;
int i;
Tim_ManForEachPo( p, pObj, i )
Tim_ManSetPoRequired( p, i, Delay );
}
/**Function************************************************************* /**Function*************************************************************
...@@ -351,20 +446,25 @@ void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay ) ...@@ -351,20 +446,25 @@ void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay )
float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi ) float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi )
{ {
Tim_Box_t * pBox; Tim_Box_t * pBox;
Tim_Obj_t * pObj, * pObjRes; Tim_Obj_t * pObjThis, * pObj, * pObjRes;
float * pDelays, DelayBest; float * pDelays, DelayBest;
int i, k; int i, k;
// consider the main PI or the already processed PI // consider the already processed PI
pObjThis = Tim_ManPi( p, iPi );
if ( pObjThis->TravId == p->nTravIds )
return pObjThis->timeArr;
pObjThis->TravId = p->nTravIds;
// consider the main PI
pBox = Tim_ManPiBox( p, iPi ); pBox = Tim_ManPiBox( p, iPi );
if ( pBox == NULL || pBox->TravId == p->nTravIds ) if ( pBox == NULL )
return Tim_ManPi(p, iPi)->timeArr; return pObjThis->timeArr;
// update box timing // update box timing
pBox->TravId = p->nTravIds; pBox->TravId = p->nTravIds;
// get the arrival times of the inputs of the box (POs) // get the arrival times of the inputs of the box (POs)
Tim_ManBoxForEachInput( p, pBox, pObj, i ) Tim_ManBoxForEachInput( p, pBox, pObj, i )
if ( pObj->TravId != p->nTravIds ) if ( pObj->TravId != p->nTravIds )
printf( "Tim_ManGetPiArrival(): PO arrival times of the box are not up to date!\n" ); printf( "Tim_ManGetPiArrival(): PO arrival times of the box are not up to date!\n" );
// compute the required times for each output of the box (PIs) // compute the arrival times for each output of the box (PIs)
Tim_ManBoxForEachOutput( p, pBox, pObjRes, i ) Tim_ManBoxForEachOutput( p, pBox, pObjRes, i )
{ {
pDelays = pBox->pDelayTable + i * pBox->nInputs; pDelays = pBox->pDelayTable + i * pBox->nInputs;
...@@ -374,7 +474,7 @@ float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi ) ...@@ -374,7 +474,7 @@ float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi )
pObjRes->timeArr = DelayBest; pObjRes->timeArr = DelayBest;
pObjRes->TravId = p->nTravIds; pObjRes->TravId = p->nTravIds;
} }
return Tim_ManPi(p, iPi)->timeArr; return pObjThis->timeArr;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -391,16 +491,21 @@ float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi ) ...@@ -391,16 +491,21 @@ float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi )
float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo ) float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo )
{ {
Tim_Box_t * pBox; Tim_Box_t * pBox;
Tim_Obj_t * pObj, * pObjRes; Tim_Obj_t * pObjThis, * pObj, * pObjRes;
float * pDelays, DelayBest; float * pDelays, DelayBest;
int i, k; int i, k;
// consider the main PO or the already processed PO // consider the already processed PO
pObjThis = Tim_ManPo( p, iPo );
if ( pObjThis->TravId == p->nTravIds )
return pObjThis->timeReq;
pObjThis->TravId = p->nTravIds;
// consider the main PO
pBox = Tim_ManPoBox( p, iPo ); pBox = Tim_ManPoBox( p, iPo );
if ( pBox == NULL || pBox->TravId == p->nTravIds ) if ( pBox == NULL )
return Tim_ManPo(p, iPo)->timeReq; return pObjThis->timeReq;
// update box timing // update box timing
pBox->TravId = p->nTravIds; pBox->TravId = p->nTravIds;
// get the arrival times of the inputs of the box (POs) // get the required times of the inputs of the box (POs)
Tim_ManBoxForEachOutput( p, pBox, pObj, i ) Tim_ManBoxForEachOutput( p, pBox, pObj, i )
if ( pObj->TravId != p->nTravIds ) if ( pObj->TravId != p->nTravIds )
printf( "Tim_ManGetPoRequired(): PI required times of the box are not up to date!\n" ); printf( "Tim_ManGetPoRequired(): PI required times of the box are not up to date!\n" );
...@@ -411,12 +516,12 @@ float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo ) ...@@ -411,12 +516,12 @@ float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo )
Tim_ManBoxForEachOutput( p, pBox, pObj, k ) Tim_ManBoxForEachOutput( p, pBox, pObj, k )
{ {
pDelays = pBox->pDelayTable + k * pBox->nInputs; pDelays = pBox->pDelayTable + k * pBox->nInputs;
DelayBest = AIG_MIN( DelayBest, pObj->timeReq + pDelays[i] ); DelayBest = AIG_MIN( DelayBest, pObj->timeReq - pDelays[i] );
} }
pObjRes->timeReq = DelayBest; pObjRes->timeReq = DelayBest;
pObjRes->TravId = p->nTravIds; pObjRes->TravId = p->nTravIds;
} }
return Tim_ManPo(p, iPo)->timeReq; return pObjThis->timeReq;
} }
......
...@@ -59,6 +59,7 @@ typedef struct Tim_Man_t_ Tim_Man_t; ...@@ -59,6 +59,7 @@ typedef struct Tim_Man_t_ Tim_Man_t;
/*=== time.c ===========================================================*/ /*=== time.c ===========================================================*/
extern Tim_Man_t * Tim_ManStart( int nPis, int nPos ); extern Tim_Man_t * Tim_ManStart( int nPis, int nPos );
extern void Tim_ManStop( Tim_Man_t * p ); extern void Tim_ManStop( Tim_Man_t * p );
extern void Tim_ManPrint( Tim_Man_t * p );
extern void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables ); extern void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables );
extern void Tim_ManCreateBox( Tim_Man_t * p, int * pIns, int nIns, int * pOuts, int nOuts, float * pDelayTable ); extern void Tim_ManCreateBox( Tim_Man_t * p, int * pIns, int nIns, int * pOuts, int nOuts, float * pDelayTable );
extern void Tim_ManCreateBoxFirst( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, float * pDelayTable ); extern void Tim_ManCreateBoxFirst( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, float * pDelayTable );
...@@ -67,6 +68,8 @@ extern void Tim_ManInitPiArrival( Tim_Man_t * p, int iPi, float Delay ...@@ -67,6 +68,8 @@ extern void Tim_ManInitPiArrival( Tim_Man_t * p, int iPi, float Delay
extern void Tim_ManInitPoRequired( Tim_Man_t * p, int iPo, float Delay ); extern void Tim_ManInitPoRequired( Tim_Man_t * p, int iPo, float Delay );
extern void Tim_ManSetPoArrival( Tim_Man_t * p, int iPo, float Delay ); extern void Tim_ManSetPoArrival( Tim_Man_t * p, int iPo, float Delay );
extern void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay ); extern void Tim_ManSetPiRequired( Tim_Man_t * p, int iPi, float Delay );
extern void Tim_ManSetPoRequired( Tim_Man_t * p, int iPo, float Delay );
extern void Tim_ManSetPoRequiredAll( Tim_Man_t * p, float Delay );
extern float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi ); extern float Tim_ManGetPiArrival( Tim_Man_t * p, int iPi );
extern float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo ); extern float Tim_ManGetPoRequired( Tim_Man_t * p, int iPo );
......
...@@ -6367,7 +6367,7 @@ usage: ...@@ -6367,7 +6367,7 @@ usage:
int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
FILE * pOut, * pErr; FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes; Abc_Ntk_t * pNtk;//, * pNtkRes;
int c; int c;
int fBmc; int fBmc;
int nFrames; int nFrames;
...@@ -6544,7 +6544,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -6544,7 +6544,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
} }
*/ */
/*
// pNtkRes = Abc_NtkDar( pNtk ); // pNtkRes = Abc_NtkDar( pNtk );
// pNtkRes = Abc_NtkDarRetime( pNtk, nLevels, 1 ); // pNtkRes = Abc_NtkDarRetime( pNtk, nLevels, 1 );
pNtkRes = Abc_NtkPcmTest( pNtk, fVerbose ); pNtkRes = Abc_NtkPcmTest( pNtk, fVerbose );
...@@ -6556,18 +6556,18 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -6556,18 +6556,18 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// replace the current network // replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
*/
// Abc_NtkDarHaigRecord( pNtk ); // Abc_NtkDarHaigRecord( pNtk );
// Abc_NtkDarClau( pNtk, nFrames, nLevels, fBmc, fVerbose, fVeryVerbose ); // Abc_NtkDarClau( pNtk, nFrames, nLevels, fBmc, fVerbose, fVeryVerbose );
/*
if ( globalUtilOptind != 1 ) if ( globalUtilOptind != 1 )
{ {
fprintf( pErr, "Command has failed.\n" ); fprintf( pErr, "Command has failed.\n" );
return 1; return 1;
} }
Abc_NtkDarTestBlif( argv[globalUtilOptind] ); Abc_NtkDarTestBlif( argv[globalUtilOptind] );
*/
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: test [-vwh]\n" ); fprintf( pErr, "usage: test [-vwh]\n" );
......
...@@ -36,6 +36,7 @@ extern "C" { ...@@ -36,6 +36,7 @@ extern "C" {
#include <time.h> #include <time.h>
#include "vec.h" #include "vec.h"
#include "mem.h" #include "mem.h"
#include "tim.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// PARAMETERS /// /// PARAMETERS ///
...@@ -127,7 +128,8 @@ struct If_Man_t_ ...@@ -127,7 +128,8 @@ struct If_Man_t_
Vec_Ptr_t * vCis; // the primary inputs Vec_Ptr_t * vCis; // the primary inputs
Vec_Ptr_t * vCos; // the primary outputs Vec_Ptr_t * vCos; // the primary outputs
Vec_Ptr_t * vObjs; // all objects Vec_Ptr_t * vObjs; // all objects
Vec_Ptr_t * vMapped; // objects used in the mapping Vec_Ptr_t * vObjsRev; // reverse topological order of objects
// Vec_Ptr_t * vMapped; // objects used in the mapping
Vec_Ptr_t * vTemp; // temporary array Vec_Ptr_t * vTemp; // temporary array
int nObjs[IF_VOID];// the number of objects by type int nObjs[IF_VOID];// the number of objects by type
// various data // various data
...@@ -161,6 +163,8 @@ struct If_Man_t_ ...@@ -161,6 +163,8 @@ struct If_Man_t_
If_Set_t * pMemAnd; // memory for AND cutsets If_Set_t * pMemAnd; // memory for AND cutsets
If_Set_t * pFreeList; // the list of free cutsets If_Set_t * pFreeList; // the list of free cutsets
int nSmallSupp; // the small support int nSmallSupp; // the small support
// timing manager
Tim_Man_t * pManTim;
}; };
// priority cut // priority cut
...@@ -202,6 +206,7 @@ struct If_Obj_t_ ...@@ -202,6 +206,7 @@ struct If_Obj_t_
unsigned fVisit : 1; // multipurpose mark unsigned fVisit : 1; // multipurpose mark
unsigned Level : 22; // logic level of the node unsigned Level : 22; // logic level of the node
int Id; // integer ID int Id; // integer ID
int IdPio; // integer ID of PIs/POs
int nRefs; // the number of references int nRefs; // the number of references
int nVisits; // the number of visits to this node int nVisits; // the number of visits to this node
int nVisitsCopy; // the number of visits to this node int nVisitsCopy; // the number of visits to this node
...@@ -236,7 +241,7 @@ static inline If_Obj_t * If_ManObj( If_Man_t * p, int i ) { r ...@@ -236,7 +241,7 @@ 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_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_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_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_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_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_ObjIsAnd( If_Obj_t * pObj ) { return pObj->Type == IF_AND; }
...@@ -298,9 +303,12 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r ...@@ -298,9 +303,12 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r
Vec_PtrForEachEntryStart( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches ) Vec_PtrForEachEntryStart( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
#define If_ManForEachLatchOutput( p, pObj, i ) \ #define If_ManForEachLatchOutput( p, pObj, i ) \
Vec_PtrForEachEntryStart( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches ) Vec_PtrForEachEntryStart( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
// iterator over all objects, including those currently not used // iterator over all objects in topological order
#define If_ManForEachObj( p, pObj, i ) \ #define If_ManForEachObj( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjs, pObj, i ) Vec_PtrForEachEntry( p->vObjs, pObj, i )
// iterator over all objects in reverse topological order
#define If_ManForEachObjReverse( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjsRev, pObj, i )
// iterator over logic nodes // iterator over logic nodes
#define If_ManForEachNode( p, pObj, i ) \ #define If_ManForEachNode( p, pObj, i ) \
If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
...@@ -385,6 +393,11 @@ extern float If_ManScanMappingSeq( If_Man_t * p ); ...@@ -385,6 +393,11 @@ extern float If_ManScanMappingSeq( If_Man_t * p );
extern void If_ManResetOriginalRefs( If_Man_t * p ); extern void If_ManResetOriginalRefs( If_Man_t * p );
extern int If_ManCrossCut( If_Man_t * p ); 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 );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -49,13 +49,15 @@ int If_ManPerformMapping( If_Man_t * p ) ...@@ -49,13 +49,15 @@ int If_ManPerformMapping( If_Man_t * p )
If_ManSetupCiCutSets( p ); If_ManSetupCiCutSets( p );
// allocate memory for other cutsets // allocate memory for other cutsets
If_ManSetupSetAll( p, If_ManCrossCut(p) ); If_ManSetupSetAll( p, If_ManCrossCut(p) );
// derive reverse top order
p->vObjsRev = If_ManReverseOrder( p );
// try sequential mapping // try sequential mapping
if ( p->pPars->fSeqMap ) if ( p->pPars->fSeqMap )
{ {
int RetValue; int RetValue = 1;
// printf( "Currently sequential mapping is not performed.\n" ); printf( "Currently sequential mapping is not performed.\n" );
RetValue = If_ManPerformMappingSeq( p ); // RetValue = If_ManPerformMappingSeq( p );
return RetValue; return RetValue;
// return 1; // return 1;
} }
......
...@@ -56,7 +56,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ...@@ -56,7 +56,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->vCis = Vec_PtrAlloc( 100 ); p->vCis = Vec_PtrAlloc( 100 );
p->vCos = Vec_PtrAlloc( 100 ); p->vCos = Vec_PtrAlloc( 100 );
p->vObjs = Vec_PtrAlloc( 100 ); p->vObjs = Vec_PtrAlloc( 100 );
p->vMapped = Vec_PtrAlloc( 100 ); // p->vMapped = Vec_PtrAlloc( 100 );
p->vTemp = Vec_PtrAlloc( 100 ); p->vTemp = Vec_PtrAlloc( 100 );
// prepare the memory manager // prepare the memory manager
p->nTruthWords = p->pPars->fTruth? If_CutTruthWords( p->pPars->nLutSize ) : 0; p->nTruthWords = p->pPars->fTruth? If_CutTruthWords( p->pPars->nLutSize ) : 0;
...@@ -100,7 +100,7 @@ void If_ManRestart( If_Man_t * p ) ...@@ -100,7 +100,7 @@ void If_ManRestart( If_Man_t * p )
Vec_PtrClear( p->vCis ); Vec_PtrClear( p->vCis );
Vec_PtrClear( p->vCos ); Vec_PtrClear( p->vCos );
Vec_PtrClear( p->vObjs ); Vec_PtrClear( p->vObjs );
Vec_PtrClear( p->vMapped ); // Vec_PtrClear( p->vMapped );
Vec_PtrClear( p->vTemp ); Vec_PtrClear( p->vTemp );
Mem_FixedRestart( p->pMemObj ); Mem_FixedRestart( p->pMemObj );
// create the constant node // create the constant node
...@@ -128,8 +128,9 @@ void If_ManStop( If_Man_t * p ) ...@@ -128,8 +128,9 @@ void If_ManStop( If_Man_t * p )
Vec_PtrFree( p->vCis ); Vec_PtrFree( p->vCis );
Vec_PtrFree( p->vCos ); Vec_PtrFree( p->vCos );
Vec_PtrFree( p->vObjs ); Vec_PtrFree( p->vObjs );
Vec_PtrFree( p->vMapped ); // Vec_PtrFree( p->vMapped );
Vec_PtrFree( p->vTemp ); Vec_PtrFree( p->vTemp );
if ( p->vObjsRev ) Vec_PtrFree( p->vObjsRev );
if ( p->vLatchOrder ) Vec_PtrFree( p->vLatchOrder ); if ( p->vLatchOrder ) Vec_PtrFree( p->vLatchOrder );
if ( p->vLags ) Vec_IntFree( p->vLags ); if ( p->vLags ) Vec_IntFree( p->vLags );
Mem_FixedStop( p->pMemObj, 0 ); Mem_FixedStop( p->pMemObj, 0 );
...@@ -141,6 +142,8 @@ void If_ManStop( If_Man_t * p ) ...@@ -141,6 +142,8 @@ void If_ManStop( If_Man_t * p )
FREE( p->pPars->pTimesArr ); FREE( p->pPars->pTimesArr );
if ( p->pPars->pTimesReq ) if ( p->pPars->pTimesReq )
FREE( p->pPars->pTimesReq ); FREE( p->pPars->pTimesReq );
if ( p->pManTim )
Tim_ManStop( p->pManTim );
free( p ); free( p );
} }
...@@ -160,6 +163,7 @@ If_Obj_t * If_ManCreateCi( If_Man_t * p ) ...@@ -160,6 +163,7 @@ If_Obj_t * If_ManCreateCi( If_Man_t * p )
If_Obj_t * pObj; If_Obj_t * pObj;
pObj = If_ManSetupObj( p ); pObj = If_ManSetupObj( p );
pObj->Type = IF_CI; pObj->Type = IF_CI;
pObj->IdPio = Vec_PtrSize( p->vCis );
Vec_PtrPush( p->vCis, pObj ); Vec_PtrPush( p->vCis, pObj );
p->nObjs[IF_CI]++; p->nObjs[IF_CI]++;
return pObj; return pObj;
...@@ -180,10 +184,12 @@ If_Obj_t * If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver ) ...@@ -180,10 +184,12 @@ If_Obj_t * If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver )
{ {
If_Obj_t * pObj; If_Obj_t * pObj;
pObj = If_ManSetupObj( p ); pObj = If_ManSetupObj( p );
pObj->IdPio = Vec_PtrSize( p->vCos );
Vec_PtrPush( p->vCos, pObj ); Vec_PtrPush( p->vCos, pObj );
pObj->Type = IF_CO; pObj->Type = IF_CO;
pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver); pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver);
pObj->pFanin0 = pDriver; pDriver->nRefs++; pObj->pFanin0 = pDriver; pDriver->nRefs++;
pObj->Level = pDriver->Level;
p->nObjs[IF_CO]++; p->nObjs[IF_CO]++;
return pObj; return pObj;
} }
......
...@@ -260,6 +260,7 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr ...@@ -260,6 +260,7 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
// ProgressBar * pProgress; // ProgressBar * pProgress;
If_Obj_t * pObj; If_Obj_t * pObj;
int i, clk = clock(); int i, clk = clock();
float arrTime;
assert( Mode >= 0 && Mode <= 2 ); assert( Mode >= 0 && Mode <= 2 );
// set the sorting function // set the sorting function
if ( Mode || p->pPars->fArea ) // area if ( Mode || p->pPars->fArea ) // area
...@@ -271,21 +272,64 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr ...@@ -271,21 +272,64 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
// set the cut number // set the cut number
p->nCutsUsed = nCutsUsed; p->nCutsUsed = nCutsUsed;
p->nCutsMerged = 0; p->nCutsMerged = 0;
// make sure the visit counters are all zero
If_ManForEachNode( p, pObj, i )
assert( pObj->nVisits == pObj->nVisitsCopy );
// map the internal nodes // map the internal nodes
// pProgress = Extra_ProgressBarStart( stdout, If_ManObjNum(p) ); if ( p->pManTim != NULL )
{
Tim_ManIncrementTravId( p->pManTim );
If_ManForEachObj( p, pObj, i )
{
if ( If_ObjIsAnd(pObj) )
{
If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess );
if ( pObj->fRepr )
If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
}
else if ( If_ObjIsCi(pObj) )
{
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) )
{
arrTime = If_ObjArrTime( If_ObjFanin0(pObj) );
Tim_ManSetPoArrival( p->pManTim, pObj->IdPio, arrTime );
}
else if ( If_ObjIsConst1(pObj) )
{
}
else
assert( 0 );
}
// Tim_ManPrint( p->pManTim );
}
else
{
// pProgress = Extra_ProgressBarStart( stdout, If_ManObjNum(p) );
If_ManForEachNode( p, pObj, i ) If_ManForEachNode( p, pObj, i )
{ {
// Extra_ProgressBarUpdate( pProgress, i, pLabel ); // Extra_ProgressBarUpdate( pProgress, i, pLabel );
If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess ); If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess );
if ( pObj->fRepr ) if ( pObj->fRepr )
If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess ); If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
} }
}
// Extra_ProgressBarStop( pProgress ); // Extra_ProgressBarStop( pProgress );
// make sure the visit counters are all zero // make sure the visit counters are all zero
If_ManForEachNode( p, pObj, i ) If_ManForEachNode( p, pObj, i )
assert( pObj->nVisits == 0 ); assert( pObj->nVisits == 0 );
// compute required times and stats // compute required times and stats
If_ManComputeRequired( p ); If_ManComputeRequired( p );
// Tim_ManPrint( p->pManTim );
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
{ {
char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A')); char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
......
...@@ -99,6 +99,13 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut ) ...@@ -99,6 +99,13 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
{ {
If_CutForEachLeaf( p, pCut, pLeaf, i ) If_CutForEachLeaf( p, pCut, pLeaf, i )
{ {
/*
if ( pLeaf->IdPio > 2000 )
{
int x = 0;
printf( "-%d %6.3f ", pLeaf->IdPio, If_ObjCutBest(pLeaf)->Delay );
}
*/
DelayCur = If_ObjCutBest(pLeaf)->Delay; DelayCur = If_ObjCutBest(pLeaf)->Delay;
Delay = IF_MAX( Delay, DelayCur ); Delay = IF_MAX( Delay, DelayCur );
} }
......
...@@ -144,11 +144,14 @@ void If_ManComputeRequired( If_Man_t * p ) ...@@ -144,11 +144,14 @@ void If_ManComputeRequired( If_Man_t * p )
{ {
If_Obj_t * pObj; If_Obj_t * pObj;
int i, Counter; int i, Counter;
float reqTime;
// compute area, clean required times, collect nodes used in the mapping // compute area, clean required times, collect nodes used in the mapping
p->nNets = 0; // p->AreaGlo = If_ManScanMapping( p );
p->AreaGlo = If_ManScanMapping( p ); If_ManMarkMapping( p );
if ( p->pManTim == NULL )
{
// consider the case when the required times are given // consider the case when the required times are given
if ( p->pPars->pTimesReq ) if ( p->pPars->pTimesReq )
{ {
...@@ -160,8 +163,8 @@ void If_ManComputeRequired( If_Man_t * p ) ...@@ -160,8 +163,8 @@ void If_ManComputeRequired( If_Man_t * p )
if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon ) if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
{ {
Counter++; Counter++;
// printf( "Required times are violated for output %d (arr = %d; req = %d).\n", // printf( "Required times are violated for output %d (arr = %d; req = %d).\n",
// i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] ); // i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
} }
If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i]; If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
} }
...@@ -209,10 +212,68 @@ void If_ManComputeRequired( If_Man_t * p ) ...@@ -209,10 +212,68 @@ void If_ManComputeRequired( If_Man_t * p )
} }
} }
// go through the nodes in the reverse topological order // go through the nodes in the reverse topological order
Vec_PtrForEachEntry( p->vMapped, pObj, i ) // Vec_PtrForEachEntry( p->vMapped, pObj, i )
// If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
If_ManForEachObjReverse( p, pObj, i )
{
if ( pObj->nRefs == 0 )
continue;
If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required ); If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
}
}
else
{
// get the global required times
p->RequiredGlo = If_ManDelayMax( p, 0 );
// do not propagate required times if area minimization is requested
if ( p->pPars->fAreaOnly )
return;
// set the required times for the POs
Tim_ManIncrementTravId( p->pManTim );
if ( p->pPars->fLatchPaths )
{
assert( 0 );
If_ManForEachPo( p, pObj, i )
Tim_ManSetPoRequired( p->pManTim, pObj->IdPio, IF_FLOAT_LARGE );
If_ManForEachLatchInput( p, pObj, i )
Tim_ManSetPoRequired( p->pManTim, pObj->IdPio, p->RequiredGlo );
}
else
{
Tim_ManSetPoRequiredAll( p->pManTim, p->RequiredGlo );
// If_ManForEachCo( p, pObj, i )
// Tim_ManSetPoRequired( p->pManTim, pObj->IdPio, p->RequiredGlo );
}
// go through the nodes in the reverse topological order
If_ManForEachObjReverse( p, pObj, i )
{
if ( If_ObjIsAnd(pObj) )
{
if ( pObj->nRefs == 0 )
continue;
If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
}
else if ( If_ObjIsCi(pObj) )
{
reqTime = pObj->Required;
Tim_ManSetPiRequired( p->pManTim, pObj->IdPio, reqTime );
}
else if ( If_ObjIsCo(pObj) )
{
reqTime = Tim_ManGetPoRequired( p->pManTim, pObj->IdPio );
If_ObjFanin0(pObj)->Required = IF_MIN( reqTime, If_ObjFanin0(pObj)->Required );
}
else if ( If_ObjIsConst1(pObj) )
{
}
else // add the node to the mapper
assert( 0 );
}
}
} }
#if 0
/**Function************************************************************* /**Function*************************************************************
Synopsis [Computes area, references, and nodes used in the mapping.] Synopsis [Computes area, references, and nodes used in the mapping.]
...@@ -264,6 +325,7 @@ float If_ManScanMapping( If_Man_t * p ) ...@@ -264,6 +325,7 @@ float If_ManScanMapping( If_Man_t * p )
int i; int i;
assert( !p->pPars->fLiftLeaves ); assert( !p->pPars->fLiftLeaves );
// clean all references // clean all references
p->nNets = 0;
If_ManForEachObj( p, pObj, i ) If_ManForEachObj( p, pObj, i )
{ {
pObj->Required = IF_FLOAT_LARGE; pObj->Required = IF_FLOAT_LARGE;
...@@ -392,6 +454,8 @@ float If_ManScanMappingSeq( If_Man_t * p ) ...@@ -392,6 +454,8 @@ float If_ManScanMappingSeq( If_Man_t * p )
return aArea; return aArea;
} }
#endif
/**Function************************************************************* /**Function*************************************************************
Synopsis [Computes area, references, and nodes used in the mapping.] Synopsis [Computes area, references, and nodes used in the mapping.]
...@@ -471,7 +535,44 @@ int If_ManCrossCut( If_Man_t * p ) ...@@ -471,7 +535,44 @@ int If_ManCrossCut( If_Man_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Computes cross-cut of the circuit.] Synopsis [Computes the reverse topological order of nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * If_ManReverseOrder( If_Man_t * p )
{
Vec_Ptr_t * vOrder;
If_Obj_t * pObj, ** ppStore;
int i;
// allocate place to store the nodes
ppStore = ALLOC( If_Obj_t *, p->nLevelMax + 1 );
memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) );
// add the nodes
If_ManForEachObj( p, pObj, i )
{
assert( pObj->Level >= 0 && pObj->Level <= (unsigned)p->nLevelMax );
pObj->pCopy = (char *)ppStore[pObj->Level];
ppStore[pObj->Level] = pObj;
}
vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
for ( i = p->nLevelMax; i >= 0; i-- )
for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy )
Vec_PtrPush( vOrder, pObj );
free( ppStore );
// print the order
// Vec_PtrForEachEntry( vOrder, pObj, i )
// printf( "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
return vOrder;
}
/**Function*************************************************************
Synopsis [Computes area, references, and nodes used in the mapping.]
Description [] Description []
...@@ -480,13 +581,74 @@ int If_ManCrossCut( If_Man_t * p ) ...@@ -480,13 +581,74 @@ int If_ManCrossCut( If_Man_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int If_ManCountTrueArea( If_Man_t * p ) float If_ManMarkMapping_rec( If_Man_t * p, If_Obj_t * pObj )
{ {
If_Obj_t * pLeaf;
If_Cut_t * pCutBest;
float aArea;
int i;
if ( pObj->nRefs++ || If_ObjIsCi(pObj) || If_ObjIsConst1(pObj) )
return 0.0;
// store the node in the structure by level
assert( If_ObjIsAnd(pObj) );
// visit the transitive fanin of the selected cut
pCutBest = If_ObjCutBest(pObj);
p->nNets += pCutBest->nLeaves;
aArea = If_CutLutArea( p, pCutBest );
If_CutForEachLeaf( p, pCutBest, pLeaf, i )
aArea += If_ManMarkMapping_rec( p, pLeaf );
return aArea;
}
/**Function*************************************************************
Synopsis [Computes area, references, and nodes used in the mapping.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void If_ManMarkMapping( If_Man_t * p )
{
If_Obj_t * pObj;
int i;
If_ManForEachObj( p, pObj, i )
{
pObj->Required = IF_FLOAT_LARGE;
pObj->nVisits = pObj->nVisitsCopy;
pObj->nRefs = 0;
}
p->nNets = 0;
p->AreaGlo = 0.0;
If_ManForEachCo( p, pObj, i )
p->AreaGlo += If_ManMarkMapping_rec( p, If_ObjFanin0(pObj) );
}
/**Function*************************************************************
Synopsis [Collects nodes used in the mapping in the topological order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * If_ManCollectMappingDirect( If_Man_t * p )
{
Vec_Ptr_t * vOrder;
If_Obj_t * pObj; If_Obj_t * pObj;
int i, Area = 0; int i;
Vec_PtrForEachEntry( p->vMapped, pObj, i ) If_ManMarkMapping( p );
Area += 1 + (If_ObjCutBest(pObj)->nLeaves > (unsigned)p->pPars->nLutSize / 2); vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
return Area; If_ManForEachObj( p, pObj, i )
if ( If_ObjIsAnd(pObj) && pObj->nRefs )
Vec_PtrPush( vOrder, pObj );
return vOrder;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -3,7 +3,6 @@ SRC += src/map/if/ifCore.c \ ...@@ -3,7 +3,6 @@ SRC += src/map/if/ifCore.c \
src/map/if/ifMan.c \ src/map/if/ifMan.c \
src/map/if/ifMap.c \ src/map/if/ifMap.c \
src/map/if/ifReduce.c \ src/map/if/ifReduce.c \
src/map/if/ifSeq.c \
src/map/if/ifTime.c \ src/map/if/ifTime.c \
src/map/if/ifTruth.c \ src/map/if/ifTruth.c \
src/map/if/ifUtil.c src/map/if/ifUtil.c
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