summaryrefslogtreecommitdiffstats
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mapper/mapper.h1
-rw-r--r--src/map/mapper/mapperCreate.c1
-rw-r--r--src/map/mapper/mapperInt.h5
-rw-r--r--src/map/mapper/mapperMatch.c29
-rw-r--r--src/map/mapper/mapperRefs.c41
-rw-r--r--src/map/mio/mio.h5
-rw-r--r--src/map/mio/mioApi.c54
-rw-r--r--src/map/mio/mioUtils.c42
-rw-r--r--src/map/scl/sclLibUtil.c79
9 files changed, 206 insertions, 51 deletions
diff --git a/src/map/mapper/mapper.h b/src/map/mapper/mapper.h
index 169223d8..f0fcea83 100644
--- a/src/map/mapper/mapper.h
+++ b/src/map/mapper/mapper.h
@@ -109,6 +109,7 @@ extern void Map_ManSetChoiceNum( Map_Man_t * p, int nChoices );
extern void Map_ManSetVerbose( Map_Man_t * p, int fVerbose );
extern void Map_ManSetSwitching( Map_Man_t * p, int fSwitching );
extern void Map_ManSetSkipFanout( Map_Man_t * p, int fSkipFanout );
+extern void Map_ManSetUseProfile( Map_Man_t * p );
extern Map_Man_t * Map_NodeReadMan( Map_Node_t * p );
extern char * Map_NodeReadData( Map_Node_t * p, int fPhase );
diff --git a/src/map/mapper/mapperCreate.c b/src/map/mapper/mapperCreate.c
index e7ad4819..d3e574f3 100644
--- a/src/map/mapper/mapperCreate.c
+++ b/src/map/mapper/mapperCreate.c
@@ -74,6 +74,7 @@ void Map_ManSetChoiceNum( Map_Man_t * p, int nChoices ) { p->
void Map_ManSetVerbose( Map_Man_t * p, int fVerbose ) { p->fVerbose = fVerbose; }
void Map_ManSetSwitching( Map_Man_t * p, int fSwitching ) { p->fSwitching = fSwitching; }
void Map_ManSetSkipFanout( Map_Man_t * p, int fSkipFanout ) { p->fSkipFanout = fSkipFanout; }
+void Map_ManSetUseProfile( Map_Man_t * p ) { p->fUseProfile = 1; }
/**Function*************************************************************
diff --git a/src/map/mapper/mapperInt.h b/src/map/mapper/mapperInt.h
index 28f40a82..79c8d61a 100644
--- a/src/map/mapper/mapperInt.h
+++ b/src/map/mapper/mapperInt.h
@@ -123,6 +123,7 @@ struct Map_ManStruct_t_
int nTravIds; // the traversal counter
int fSwitching; // use switching activity
int fSkipFanout; // skip large gates when mapping high-fanout nodes
+ int fUseProfile; // use standard-cell profile
// the supergate library
Map_SuperLib_t * pSuperLib; // the current supergate library
@@ -385,8 +386,8 @@ extern void Map_MappingEstimateRefs( Map_Man_t * p );
extern float Map_CutGetAreaFlow( Map_Cut_t * pCut, int fPhase );
extern float Map_CutGetAreaRefed( Map_Cut_t * pCut, int fPhase );
extern float Map_CutGetAreaDerefed( Map_Cut_t * pCut, int fPhase );
-extern float Map_CutRef( Map_Cut_t * pCut, int fPhase );
-extern float Map_CutDeref( Map_Cut_t * pCut, int fPhase );
+extern float Map_CutRef( Map_Cut_t * pCut, int fPhase, int fProfile );
+extern float Map_CutDeref( Map_Cut_t * pCut, int fPhase, int fProfile );
extern void Map_MappingSetRefs( Map_Man_t * pMan );
extern float Map_MappingGetArea( Map_Man_t * pMan );
/*=== mapperSwitch.c =============================================================*/
diff --git a/src/map/mapper/mapperMatch.c b/src/map/mapper/mapperMatch.c
index e5e12fa8..f7f6c613 100644
--- a/src/map/mapper/mapperMatch.c
+++ b/src/map/mapper/mapperMatch.c
@@ -76,6 +76,8 @@ void Map_MatchClean( Map_Match_t * pMatch )
***********************************************************************/
int Map_MatchCompare( Map_Man_t * pMan, Map_Match_t * pM1, Map_Match_t * pM2, int fDoingArea )
{
+// if ( pM1->pSuperBest == pM2->pSuperBest )
+// return 0;
if ( !fDoingArea )
{
// compare the arrival times
@@ -108,6 +110,21 @@ int Map_MatchCompare( Map_Man_t * pMan, Map_Match_t * pM1, Map_Match_t * pM2, in
return 0;
if ( pM1->AreaFlow > pM2->AreaFlow + pMan->fEpsilon )
return 1;
+
+ // make decision based on cell profile
+ if ( pMan->fUseProfile && pM1->pSuperBest && pM1->pSuperBest )
+ {
+ int M1req = Mio_GateReadProfile(pM1->pSuperBest->pRoot);
+ int M2req = Mio_GateReadProfile(pM2->pSuperBest->pRoot);
+ int M1act = Mio_GateReadProfile2(pM1->pSuperBest->pRoot);
+ int M2act = Mio_GateReadProfile2(pM2->pSuperBest->pRoot);
+ //printf( "%d %d ", M1req, M2req );
+ if ( M1act < M1req && M2act > M2req )
+ return 0;
+ if ( M2act < M2req && M1act > M1req )
+ return 1;
+ }
+
// compare the arrival times
if ( pM1->tArrive.Worst < pM2->tArrive.Worst - pMan->fEpsilon )
return 0;
@@ -266,7 +283,7 @@ int Map_MatchNodePhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase )
pMatch = pCutBest->M + fPhase;
if ( pNode->nRefAct[fPhase] > 0 ||
(pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0) )
- pMatch->AreaFlow = Area1 = Map_CutDeref( pCutBest, fPhase );
+ pMatch->AreaFlow = Area1 = Map_CutDeref( pCutBest, fPhase, p->fUseProfile );
else
pMatch->AreaFlow = Area1 = Map_CutGetAreaDerefed( pCutBest, fPhase );
}
@@ -326,7 +343,7 @@ int Map_MatchNodePhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase )
(pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0)) )
{
if ( p->fMappingMode == 2 || p->fMappingMode == 3 )
- Area2 = Map_CutRef( pNode->pCutBest[fPhase], fPhase );
+ Area2 = Map_CutRef( pNode->pCutBest[fPhase], fPhase, p->fUseProfile );
else if ( p->fMappingMode == 4 )
Area2 = Map_SwitchCutRef( pNode, pNode->pCutBest[fPhase], fPhase );
else
@@ -479,23 +496,23 @@ void Map_NodeTryDroppingOnePhase( Map_Man_t * p, Map_Node_t * pNode )
{
// deref phase 1 cut if necessary
if ( p->fMappingMode >= 2 && pNode->nRefAct[1] > 0 )
- Map_CutDeref( pNode->pCutBest[1], 1 );
+ Map_CutDeref( pNode->pCutBest[1], 1, p->fUseProfile );
// get rid of the cut
pNode->pCutBest[1] = NULL;
// ref phase 0 cut if necessary
if ( p->fMappingMode >= 2 && pNode->nRefAct[0] == 0 )
- Map_CutRef( pNode->pCutBest[0], 0 );
+ Map_CutRef( pNode->pCutBest[0], 0, p->fUseProfile );
}
else
{
// deref phase 0 cut if necessary
if ( p->fMappingMode >= 2 && pNode->nRefAct[0] > 0 )
- Map_CutDeref( pNode->pCutBest[0], 0 );
+ Map_CutDeref( pNode->pCutBest[0], 0, p->fUseProfile );
// get rid of the cut
pNode->pCutBest[0] = NULL;
// ref phase 1 cut if necessary
if ( p->fMappingMode >= 2 && pNode->nRefAct[1] == 0 )
- Map_CutRef( pNode->pCutBest[1], 1 );
+ Map_CutRef( pNode->pCutBest[1], 1, p->fUseProfile );
}
}
diff --git a/src/map/mapper/mapperRefs.c b/src/map/mapper/mapperRefs.c
index 6d6ff121..e1387262 100644
--- a/src/map/mapper/mapperRefs.c
+++ b/src/map/mapper/mapperRefs.c
@@ -226,7 +226,7 @@ float Map_CutGetAreaFlow( Map_Cut_t * pCut, int fPhase )
seealso []
***********************************************************************/
-float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference )
+float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference, int fUpdateProf )
{
Map_Node_t * pNodeChild;
Map_Cut_t * pCutChild;
@@ -239,6 +239,13 @@ float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference )
return 0;
// start the area of this cut
aArea = Map_CutGetRootArea( pCut, fPhase );
+ if ( fUpdateProf )
+ {
+ if ( fReference )
+ Mio_GateIncProfile2( pCut->M[fPhase].pSuperBest->pRoot );
+ else
+ Mio_GateDecProfile2( pCut->M[fPhase].pSuperBest->pRoot );
+ }
// go through the children
for ( i = 0; i < pCut->nLeaves; i++ )
{
@@ -309,7 +316,7 @@ float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference )
pCutChild = pNodeChild->pCutBest[fPhaseChild];
}
// reference and compute area recursively
- aArea += Map_CutRefDeref( pCutChild, fPhaseChild, fReference );
+ aArea += Map_CutRefDeref( pCutChild, fPhaseChild, fReference, fUpdateProf );
}
return aArea;
}
@@ -328,8 +335,8 @@ float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference )
float Map_CutGetAreaRefed( Map_Cut_t * pCut, int fPhase )
{
float aResult, aResult2;
- aResult2 = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference
- aResult = Map_CutRefDeref( pCut, fPhase, 1 ); // reference
+ aResult2 = Map_CutRefDeref( pCut, fPhase, 0, 0 ); // dereference
+ aResult = Map_CutRefDeref( pCut, fPhase, 1, 0 ); // reference
// assert( aResult == aResult2 );
return aResult;
}
@@ -348,8 +355,8 @@ float Map_CutGetAreaRefed( Map_Cut_t * pCut, int fPhase )
float Map_CutGetAreaDerefed( Map_Cut_t * pCut, int fPhase )
{
float aResult, aResult2;
- aResult2 = Map_CutRefDeref( pCut, fPhase, 1 ); // reference
- aResult = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference
+ aResult2 = Map_CutRefDeref( pCut, fPhase, 1, 0 ); // reference
+ aResult = Map_CutRefDeref( pCut, fPhase, 0, 0 ); // dereference
// assert( aResult == aResult2 );
return aResult;
}
@@ -365,9 +372,9 @@ float Map_CutGetAreaDerefed( Map_Cut_t * pCut, int fPhase )
seealso []
***********************************************************************/
-float Map_CutRef( Map_Cut_t * pCut, int fPhase )
+float Map_CutRef( Map_Cut_t * pCut, int fPhase, int fProfile )
{
- return Map_CutRefDeref( pCut, fPhase, 1 ); // reference
+ return Map_CutRefDeref( pCut, fPhase, 1, fProfile ); // reference
}
/**function*************************************************************
@@ -381,9 +388,9 @@ float Map_CutRef( Map_Cut_t * pCut, int fPhase )
seealso []
***********************************************************************/
-float Map_CutDeref( Map_Cut_t * pCut, int fPhase )
+float Map_CutDeref( Map_Cut_t * pCut, int fPhase, int fProfile )
{
- return Map_CutRefDeref( pCut, fPhase, 0 ); // dereference
+ return Map_CutRefDeref( pCut, fPhase, 0, fProfile ); // dereference
}
@@ -430,6 +437,8 @@ void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode )
fPhase = !fPhase;
pCut = pNodeR->pCutBest[fPhase];
}
+ if ( pMan->fUseProfile )
+ Mio_GateIncProfile2( pCut->M[fPhase].pSuperBest->pRoot );
// visit the transitive fanin
uPhase = pCut->M[fPhase].uPhaseBest;
for ( i = 0; i < pCut->nLeaves; i++ )
@@ -442,6 +451,8 @@ void Map_MappingSetRefs( Map_Man_t * pMan )
{
Map_Node_t * pNode;
int i;
+ if ( pMan->fUseProfile )
+ Mio_LibraryCleanProfile2( pMan->pSuperLib->pGenlib );
// clean all references
for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
{
@@ -476,6 +487,8 @@ float Map_MappingGetArea( Map_Man_t * pMan )
Map_Node_t * pNode;
float Area = 0.0;
int i;
+ if ( pMan->fUseProfile )
+ Mio_LibraryCleanProfile2( pMan->pSuperLib->pGenlib );
for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
{
pNode = pMan->vMapObjs->pArray[i];
@@ -492,10 +505,18 @@ float Map_MappingGetArea( Map_Man_t * pMan )
{
// count area of the negative phase
if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) )
+ {
Area += pNode->pCutBest[0]->M[0].pSuperBest->Area;
+ if ( pMan->fUseProfile )
+ Mio_GateIncProfile2( pNode->pCutBest[0]->M[0].pSuperBest->pRoot );
+ }
// count area of the positive phase
if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) )
+ {
Area += pNode->pCutBest[1]->M[1].pSuperBest->Area;
+ if ( pMan->fUseProfile )
+ Mio_GateIncProfile2( pNode->pCutBest[1]->M[1].pSuperBest->pRoot );
+ }
}
// count area of the interver if we need to implement one phase with another phase
if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) ||
diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h
index 35b5641c..e4e15c6f 100644
--- a/src/map/mio/mio.h
+++ b/src/map/mio/mio.h
@@ -162,6 +162,8 @@ extern void Mio_GateSetProfile ( Mio_Gate_t * pGate, int Pro
extern void Mio_GateSetProfile2 ( Mio_Gate_t * pGate, int Prof );
extern void Mio_GateIncProfile2 ( Mio_Gate_t * pGate );
extern void Mio_GateDecProfile2 ( Mio_Gate_t * pGate );
+extern void Mio_GateAddToProfile ( Mio_Gate_t * pGate, int Prof );
+extern void Mio_GateAddToProfile2 ( Mio_Gate_t * pGate, int Prof );
extern int Mio_GateIsInv ( Mio_Gate_t * pGate );
extern char * Mio_PinReadName ( Mio_Pin_t * pPin );
extern Mio_PinPhase_t Mio_PinReadPhase ( Mio_Pin_t * pPin );
@@ -209,12 +211,13 @@ extern void Mio_LibraryTransferCellIds();
extern void Mio_LibraryReadProfile( FILE * pFile, Mio_Library_t * pLib );
extern void Mio_LibraryWriteProfile( FILE * pFile, Mio_Library_t * pLib );
extern void Mio_LibraryTransferProfile( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc );
+extern void Mio_LibraryTransferProfile2( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc );
extern int Mio_LibraryHasProfile( Mio_Library_t * pLib );
extern void Mio_LibraryCleanProfile2( Mio_Library_t * pLib );
/*=== sclUtil.c =========================================================*/
extern Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl );
-extern Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin, int fVerbose );
+extern Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, void * pMio, float Slew, float Gain, int nGatesMin, int fVerbose );
extern int Abc_SclHasDelayInfo( void * pScl );
diff --git a/src/map/mio/mioApi.c b/src/map/mio/mioApi.c
index 3d24f4d6..82b76a27 100644
--- a/src/map/mio/mioApi.c
+++ b/src/map/mio/mioApi.c
@@ -163,31 +163,33 @@ char * Mio_LibraryReadSopByName( Mio_Library_t * pLib, char * pName )
SeeAlso []
***********************************************************************/
-char * Mio_GateReadName ( Mio_Gate_t * pGate ) { return pGate->pName; }
-char * Mio_GateReadOutName ( Mio_Gate_t * pGate ) { return pGate->pOutName; }
-double Mio_GateReadArea ( Mio_Gate_t * pGate ) { return pGate->dArea; }
-char * Mio_GateReadForm ( Mio_Gate_t * pGate ) { return pGate->pForm; }
-Mio_Pin_t * Mio_GateReadPins ( Mio_Gate_t * pGate ) { return pGate->pPins; }
-Mio_Library_t * Mio_GateReadLib ( Mio_Gate_t * pGate ) { return pGate->pLib; }
-Mio_Gate_t * Mio_GateReadNext ( Mio_Gate_t * pGate ) { return pGate->pNext; }
-Mio_Gate_t * Mio_GateReadTwin ( Mio_Gate_t * pGate ) { return pGate->pTwin; }
-int Mio_GateReadPinNum ( Mio_Gate_t * pGate ) { return pGate->nInputs; }
-double Mio_GateReadDelayMax( Mio_Gate_t * pGate ) { return pGate->dDelayMax; }
-char * Mio_GateReadSop ( Mio_Gate_t * pGate ) { return pGate->pSop; }
-Vec_Int_t * Mio_GateReadExpr ( Mio_Gate_t * pGate ) { return pGate->vExpr; }
-word Mio_GateReadTruth ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? pGate->uTruth : 0; }
-word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? NULL: pGate->pTruth; }
-int Mio_GateReadValue ( Mio_Gate_t * pGate ) { return pGate->Value; }
-int Mio_GateReadCell ( Mio_Gate_t * pGate ) { return pGate->Cell; }
-int Mio_GateReadProfile ( Mio_Gate_t * pGate ) { return pGate->Profile; }
-int Mio_GateReadProfile2( Mio_Gate_t * pGate ) { return pGate->Profile2; }
-void Mio_GateSetValue ( Mio_Gate_t * pGate, int Value ) { pGate->Value = Value; }
-void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell ) { pGate->Cell = Cell; }
-void Mio_GateSetProfile ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile = Prof; }
-void Mio_GateSetProfile2 ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile2 = Prof; }
-void Mio_GateIncProfile2 ( Mio_Gate_t * pGate ) { pGate->Profile2++; }
-void Mio_GateDecProfile2 ( Mio_Gate_t * pGate ) { pGate->Profile2--; }
-int Mio_GateIsInv ( Mio_Gate_t * pGate ) { return pGate->uTruth == ABC_CONST(0x5555555555555555); }
+char * Mio_GateReadName ( Mio_Gate_t * pGate ) { return pGate->pName; }
+char * Mio_GateReadOutName ( Mio_Gate_t * pGate ) { return pGate->pOutName; }
+double Mio_GateReadArea ( Mio_Gate_t * pGate ) { return pGate->dArea; }
+char * Mio_GateReadForm ( Mio_Gate_t * pGate ) { return pGate->pForm; }
+Mio_Pin_t * Mio_GateReadPins ( Mio_Gate_t * pGate ) { return pGate->pPins; }
+Mio_Library_t * Mio_GateReadLib ( Mio_Gate_t * pGate ) { return pGate->pLib; }
+Mio_Gate_t * Mio_GateReadNext ( Mio_Gate_t * pGate ) { return pGate->pNext; }
+Mio_Gate_t * Mio_GateReadTwin ( Mio_Gate_t * pGate ) { return pGate->pTwin; }
+int Mio_GateReadPinNum ( Mio_Gate_t * pGate ) { return pGate->nInputs; }
+double Mio_GateReadDelayMax ( Mio_Gate_t * pGate ) { return pGate->dDelayMax; }
+char * Mio_GateReadSop ( Mio_Gate_t * pGate ) { return pGate->pSop; }
+Vec_Int_t * Mio_GateReadExpr ( Mio_Gate_t * pGate ) { return pGate->vExpr; }
+word Mio_GateReadTruth ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? pGate->uTruth : 0; }
+word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? NULL: pGate->pTruth; }
+int Mio_GateReadValue ( Mio_Gate_t * pGate ) { return pGate->Value; }
+int Mio_GateReadCell ( Mio_Gate_t * pGate ) { return pGate->Cell; }
+int Mio_GateReadProfile ( Mio_Gate_t * pGate ) { return pGate->Profile; }
+int Mio_GateReadProfile2 ( Mio_Gate_t * pGate ) { return pGate->Profile2; }
+void Mio_GateSetValue ( Mio_Gate_t * pGate, int Value ) { pGate->Value = Value; }
+void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell ) { pGate->Cell = Cell; }
+void Mio_GateSetProfile ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile = Prof; }
+void Mio_GateSetProfile2 ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile2 = Prof; }
+void Mio_GateIncProfile2 ( Mio_Gate_t * pGate ) { pGate->Profile2++; }
+void Mio_GateDecProfile2 ( Mio_Gate_t * pGate ) { pGate->Profile2--; }
+void Mio_GateAddToProfile ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile += Prof; }
+void Mio_GateAddToProfile2( Mio_Gate_t * pGate, int Prof ) { pGate->Profile2 += Prof; }
+int Mio_GateIsInv ( Mio_Gate_t * pGate ) { return pGate->uTruth == ABC_CONST(0x5555555555555555); }
/**Function*************************************************************
@@ -208,7 +210,7 @@ double Mio_PinReadDelayBlockRise ( Mio_Pin_t * pPin ) { return p
double Mio_PinReadDelayFanoutRise( Mio_Pin_t * pPin ) { return pPin->dDelayFanoutRise;}
double Mio_PinReadDelayBlockFall ( Mio_Pin_t * pPin ) { return pPin->dDelayBlockFall; }
double Mio_PinReadDelayFanoutFall( Mio_Pin_t * pPin ) { return pPin->dDelayFanoutFall;}
-double Mio_PinReadDelayBlockMax ( Mio_Pin_t * pPin ) { return pPin->dDelayBlockMax; }
+double Mio_PinReadDelayBlockMax ( Mio_Pin_t * pPin ) { return pPin->dDelayBlockMax; }
Mio_Pin_t * Mio_PinReadNext ( Mio_Pin_t * pPin ) { return pPin->pNext; }
/**Function*************************************************************
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index 14b8b45d..c7c6c6dc 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -1403,19 +1403,55 @@ int Mio_LibraryHasProfile( Mio_Library_t * pLib )
return 0;
}
+
void Mio_LibraryTransferProfile( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc )
{
Mio_Gate_t * pGateSrc, * pGateDst;
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ Mio_GateSetProfile( pGateDst, 0 );
Mio_LibraryForEachGate( pLibSrc, pGateSrc )
if ( Mio_GateReadProfile(pGateSrc) > 0 )
{
+ // find gate by name
pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
if ( pGateDst == NULL )
{
- printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
- continue;
+ // find gate by function
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ if ( pGateDst->uTruth == pGateSrc->uTruth )
+ break;
+ if ( pGateDst == NULL )
+ {
+ printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
+ continue;
+ }
+ }
+ Mio_GateAddToProfile( pGateDst, Mio_GateReadProfile(pGateSrc) );
+ }
+}
+void Mio_LibraryTransferProfile2( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc )
+{
+ Mio_Gate_t * pGateSrc, * pGateDst;
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ Mio_GateSetProfile2( pGateDst, 0 );
+ Mio_LibraryForEachGate( pLibSrc, pGateSrc )
+ if ( Mio_GateReadProfile2(pGateSrc) > 0 )
+ {
+ // find gate by name
+ pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
+ if ( pGateDst == NULL )
+ {
+ // find gate by function
+ Mio_LibraryForEachGate( pLibDst, pGateDst )
+ if ( pGateDst->uTruth == pGateSrc->uTruth )
+ break;
+ if ( pGateDst == NULL )
+ {
+ printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
+ continue;
+ }
}
- Mio_GateSetProfile( pGateDst, Mio_GateReadProfile(pGateSrc) );
+ Mio_GateAddToProfile2( pGateDst, Mio_GateReadProfile2(pGateSrc) );
}
}
diff --git a/src/map/scl/sclLibUtil.c b/src/map/scl/sclLibUtil.c
index cb1655f6..ebd9cbc7 100644
--- a/src/map/scl/sclLibUtil.c
+++ b/src/map/scl/sclLibUtil.c
@@ -925,6 +925,74 @@ Vec_Str_t * Abc_SclProduceGenlibStr( SC_Lib * p, float Slew, float Gain, int nGa
*pnCellCount = Count;
return vStr;
}
+Vec_Str_t * Abc_SclProduceGenlibStrProfile( SC_Lib * p, Mio_Library_t * pLib, float Slew, float Gain, int nGatesMin, int * pnCellCount )
+{
+ char Buffer[200];
+ Vec_Str_t * vStr;
+ SC_Cell * pRepr;
+ SC_Pin * pPin;
+ int i, k, Count = 2, nClassMax = 0;
+ // find the largest number of cells in a class
+ SC_LibForEachCellClass( p, pRepr, i )
+ if ( pRepr->n_outputs == 1 )
+ nClassMax = Abc_MaxInt( nClassMax, Abc_SclClassCellNum(pRepr) );
+ // update the number
+ if ( nGatesMin && nGatesMin >= nClassMax )
+ nGatesMin = 0;
+ // mark skipped cells
+ Abc_SclMarkSkippedCells( p );
+ vStr = Vec_StrAlloc( 1000 );
+ Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
+ Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
+ SC_LibForEachCell( p, pRepr, i )
+ {
+ if ( pRepr->n_inputs == 0 )
+ continue;
+ if ( pRepr->n_outputs > 1 )
+ continue;
+ if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
+ continue;
+ // check if the gate is in the profile
+ if ( pRepr->n_inputs > 1 )
+ {
+ Mio_Gate_t * pGate = Mio_LibraryReadGateByName( pLib, pRepr->pName, NULL );
+ if ( pGate == NULL || Mio_GateReadProfile(pGate) == 0 )
+ continue;
+ }
+ // process gate
+ assert( strlen(pRepr->pName) < 200 );
+ Vec_StrPrintStr( vStr, "GATE " );
+ sprintf( Buffer, "%-16s", pRepr->pName );
+ Vec_StrPrintStr( vStr, Buffer );
+ Vec_StrPrintStr( vStr, " " );
+// sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
+ sprintf( Buffer, "%7.2f", pRepr->area );
+ Vec_StrPrintStr( vStr, Buffer );
+ Vec_StrPrintStr( vStr, " " );
+ Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, pRepr->n_inputs) );
+ Vec_StrPrintStr( vStr, "=" );
+ Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, 0) ? SC_CellPinOutFunc(pRepr, 0) : "?" );
+ Vec_StrPrintStr( vStr, ";\n" );
+ SC_CellForEachPinIn( pRepr, pPin, k )
+ {
+ float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
+ assert( Delay > 0 );
+ Vec_StrPrintStr( vStr, " PIN " );
+ sprintf( Buffer, "%-4s", pPin->pName );
+ Vec_StrPrintStr( vStr, Buffer );
+ sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
+ Vec_StrPrintStr( vStr, Buffer );
+ }
+ Count++;
+ }
+ Vec_StrPrintStr( vStr, "\n.end\n" );
+ Vec_StrPush( vStr, '\0' );
+// printf( "GENLIB library with %d gates is produced:\n", Count );
+// printf( "%s", Vec_StrArray(vStr) );
+ if ( pnCellCount )
+ *pnCellCount = Count;
+ return vStr;
+}
void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float SlewInit, float Gain, int nGatesMin )
{
int nCellCount = 0;
@@ -948,13 +1016,18 @@ void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float SlewInit, float Gain
fclose( pFile );
printf( "Written GENLIB library with %d gates into file \"%s\".\n", nCellCount, FileName );
}
-Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float SlewInit, float Gain, int nGatesMin, int fVerbose )
+Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, void * pMio, float SlewInit, float Gain, int nGatesMin, int fVerbose )
{
int nCellCount = 0;
SC_Lib * p = (SC_Lib *)pScl;
float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
- Vec_Str_t * vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
- Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
+ Vec_Str_t * vStr;
+ Mio_Library_t * pLib;
+ if ( pMio == NULL )
+ vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
+ else
+ vStr = Abc_SclProduceGenlibStrProfile( p, (Mio_Library_t *)pMio, Slew, Gain, nGatesMin, &nCellCount );
+ pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
Vec_StrFree( vStr );
if ( !pLib )
printf( "Reading library has filed.\n" );