Commit 204fac4d by Alan Mishchenko

Other changes to enable new features in the mapper.

parent ebfd70cd
......@@ -2039,6 +2039,10 @@ SOURCE=.\src\map\if\ifDec10.c
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifDec10f.c
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifLib.c
# End Source File
# Begin Source File
......
......@@ -12911,7 +12911,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
fLutMux = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrsdbugojikvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrsdbugojikcvh" ) ) != EOF )
{
switch ( c )
{
......@@ -13034,6 +13034,9 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'k':
pPars->fEnableCheck10 ^= 1;
break;
case 'c':
pPars->fEnableRealPos ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
break;
......@@ -13226,7 +13229,7 @@ usage:
sprintf( LutSize, "library" );
else
sprintf( LutSize, "%d", pPars->nLutSize );
Abc_Print( -2, "usage: if [-KCFA num] [-DE float] [-qarlepmsdbugojikvh]\n" );
Abc_Print( -2, "usage: if [-KCFA num] [-DE float] [-qarlepmsdbugojikcvh]\n" );
Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
......@@ -13251,6 +13254,7 @@ usage:
Abc_Print( -2, "\t-j : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck07? "yes": "no" );
Abc_Print( -2, "\t-i : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck08? "yes": "no" );
Abc_Print( -2, "\t-k : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck10? "yes": "no" );
Abc_Print( -2, "\t-c : toggles enabling additional feature [default = %s]\n", pPars->fEnableRealPos? "yes": "no" );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : prints the command usage\n");
return 1;
......
......@@ -40,7 +40,7 @@ extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose );
extern void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose );
extern void Abc_NtkCollectPoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk );
extern void Abc_NtkFreePoDrivers( If_Man_t * p );
extern void Abc_NtkFreePoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......@@ -137,14 +137,15 @@ Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
Abc_NtkIfComputeSwitching( pNtk, pIfMan );
// perform FPGA mapping
// Abc_NtkCollectPoDrivers( pIfMan, pNtk );
if ( pPars->fEnableRealPos )
Abc_NtkCollectPoDrivers( pIfMan, pNtk );
if ( !If_ManPerformMapping( pIfMan ) )
{
Abc_NtkFreePoDrivers( pIfMan );
Abc_NtkFreePoDrivers( pIfMan, pNtk );
If_ManStop( pIfMan );
return NULL;
}
Abc_NtkFreePoDrivers( pIfMan );
Abc_NtkFreePoDrivers( pIfMan, pNtk );
// transform the result of mapping into the new network
pNtkNew = Abc_NtkFromIf( pIfMan, pNtk );
......@@ -712,7 +713,6 @@ Vec_Ptr_t * Abc_NtkFindGoodOrder( Abc_Ntk_t * pNtk )
***********************************************************************/
void Abc_NtkCollectPoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk )
{
// 1 a 2 b 3 c 4 a+b+c 5 ab+ac+bc
Vec_Int_t * vTemp;
Abc_Obj_t * pObj;
If_Obj_t * pIfObj;
......@@ -729,7 +729,7 @@ void Abc_NtkCollectPoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk )
}
nGroups = (Abc_NtkPoNum(pNtk) - pNtk->nRealPos) / 5;
printf( "Processing %d groups of PO drivers.\n", nGroups );
// mark the drivers
// mark the drivers (0 a 1 b 2 c 3 s 4 c)
assert( p->pDriverCuts == NULL );
p->pDriverCuts = ABC_CALLOC( Vec_Int_t *, If_ManObjNum(p) );
for ( g = 0; g < nGroups; g++ )
......@@ -742,7 +742,7 @@ void Abc_NtkCollectPoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk )
pIfObj = If_Regular( ((If_Obj_t *)pObj->pCopy)->pFanin0 );
Vec_IntPush( vTemp, pIfObj->Id );
}
Vec_IntSort( vTemp, 0 );
// Vec_IntSort( vTemp, 0 );
// find output node
pObj = Abc_NtkPo( pNtk, pNtk->nRealPos + g * 5 + 3 );
pIfObj = If_Regular( ((If_Obj_t *)pObj->pCopy)->pFanin0 );
......@@ -755,9 +755,11 @@ void Abc_NtkCollectPoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk )
{
p->pDriverCuts[pIfObj->Id] = Vec_IntDup( vTemp );
pIfObj->fDriver = 1;
// printf( "%d ", pIfObj->Id );
}
Vec_IntFree( vTemp );
}
// printf( "\n" );
}
/**Function*************************************************************
......@@ -771,11 +773,26 @@ void Abc_NtkCollectPoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
void Abc_NtkFreePoDrivers( If_Man_t * p )
void Abc_NtkFreePoDrivers( If_Man_t * p, Abc_Ntk_t * pNtk )
{
If_Obj_t * pObj;
If_Cut_t * pCut;
int i;
if ( p->pDriverCuts == NULL )
return;
printf( "Actual delay after mapping = %.2f\n", p->RequiredGlo );
assert( Abc_NtkPoNum(pNtk) == If_ManCoNum(p) - Abc_NtkLatchNum(pNtk) );
// print the cut sizes of the drivers
for ( i = pNtk->nRealPos; i < Abc_NtkPoNum(pNtk); i += 5 )
{
pObj = If_ManCo( p, i + 4 );
pObj = If_Regular(pObj->pFanin0);
if ( !pObj->fDriver )
continue;
pCut = If_ObjCutBest(pObj);
// printf( "%d(%d) ", pObj->Id, pCut->nLeaves );
}
// printf( "\n" );
for ( i = 0; i < If_ManObjNum(p); i++ )
Vec_IntFreeP( &p->pDriverCuts[i] );
ABC_FREE( p->pDriverCuts );
......
......@@ -99,6 +99,7 @@ struct If_Par_t_
int fEnableCheck07;// enable additional checking
int fEnableCheck08;// enable additional checking
int fEnableCheck10;// enable additional checking
int fEnableRealPos;// enable additional feature
int fVerbose; // the verbosity flag
// internal parameters
int fDelayOpt; // special delay optimization
......@@ -449,8 +450,8 @@ extern int If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
extern int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut );
extern Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutDelay( If_Man_t * p, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float Required );
extern float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
extern void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
/*=== ifTruth.c ===========================================================*/
extern int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
......
......@@ -105,7 +105,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
else if ( Mode == 1 )
pObj->EstRefs = (float)((2.0 * pObj->EstRefs + pObj->nRefs) / 3.0);
}
/*
// process special cut
if ( p->pDriverCuts && p->pDriverCuts[pObj->Id] )
{
......@@ -137,7 +137,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
assert( pCutSet->nCuts == 2 );
return;
}
*/
// deref the selected cut
if ( Mode && pObj->nRefs > 0 )
If_CutAreaDeref( p, If_ObjCutBest(pObj) );
......@@ -153,7 +153,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( p->pPars->fDelayOpt )
pCut->Delay = If_CutDelaySopCost( p, pCut );
else
pCut->Delay = If_CutDelay( p, pCut );
pCut->Delay = If_CutDelay( p, pObj, pCut );
// assert( pCut->Delay <= pObj->Required + p->fEpsilon );
if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
......@@ -215,7 +215,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( p->pPars->fDelayOpt )
pCut->Delay = If_CutDelaySopCost( p, pCut );
else
pCut->Delay = If_CutDelay( p, pCut );
pCut->Delay = If_CutDelay( p, pObj, pCut );
// Abc_Print( 1, "%.2f ", pCut->Delay );
if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
continue;
......@@ -305,7 +305,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
if ( If_CutFilter( pCutSet, pCut ) )
continue;
// check if the cut satisfies the required times
assert( pCut->Delay == If_CutDelay( p, pCut ) );
assert( pCut->Delay == If_CutDelay( p, pObj, pCut ) );
if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
continue;
// set the phase attribute
......
......@@ -153,7 +153,7 @@ void If_ManImproveNodeExpand( If_Man_t * p, If_Obj_t * pObj, int nLimit, Vec_Ptr
int CostBef, CostAft, i;
float DelayOld, AreaBef, AreaAft;
pCut = If_ObjCutBest(pObj);
pCut->Delay = If_CutDelay( p, pCut );
pCut->Delay = If_CutDelay( p, pObj, pCut );
assert( pCut->Delay <= pObj->Required + p->fEpsilon );
if ( pObj->nRefs == 0 )
return;
......@@ -177,7 +177,7 @@ void If_ManImproveNodeExpand( If_Man_t * p, If_Obj_t * pObj, int nLimit, Vec_Ptr
pFanin->fMark = 0;
// update the node
If_ManImproveNodeUpdate( p, pObj, vFront );
pCut->Delay = If_CutDelay( p, pCut );
pCut->Delay = If_CutDelay( p, pObj, pCut );
// get the new area
AreaAft = If_CutAreaRefed( p, pCut );
if ( AreaAft > AreaBef || pCut->Delay > pObj->Required + p->fEpsilon )
......@@ -539,14 +539,14 @@ void If_ManImproveNodeReduce( If_Man_t * p, If_Obj_t * pObj, int nLimit )
}
if ( RetValue )
{
pCutR->Delay = If_CutDelay( p, pCutR );
pCutR->Delay = If_CutDelay( p, pObj, pCutR );
AreaAft = If_CutAreaDerefed( p, pCutR );
// update the best cut
if ( AreaAft < AreaBef - p->fEpsilon && pCutR->Delay < pObj->Required + p->fEpsilon )
If_CutCopy( p, pCut, pCutR );
}
// recompute the delay of the best cut
pCut->Delay = If_CutDelay( p, pCut );
pCut->Delay = If_CutDelay( p, pObj, pCut );
// ref the cut if the node is refed
if ( pObj->nRefs > 0 )
If_CutRef( p, pCut );
......
......@@ -30,6 +30,8 @@ ABC_NAMESPACE_IMPL_START
#define IF_BIG_CHAR 120
static float s_ExtraDel[2][3] = { {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0} };
static void If_CutSortInputPins( If_Man_t * p, If_Cut_t * pCut, int * pPinPerm, float * pPinDelays );
////////////////////////////////////////////////////////////////////////
......@@ -386,7 +388,7 @@ int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut )
}
// Vec_WrdFree( vAnds );
// verify the delay
// Delay = If_CutDelay( p, pCut );
// Delay = If_CutDelay( p, pObj, pCut );
// assert( (int)Leaf.Delay == Delay );
return Leaf.Delay;
}
......@@ -407,14 +409,14 @@ int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut )
SeeAlso []
***********************************************************************/
float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut )
{
static int pPinPerm[IF_MAX_LUTSIZE];
static float pPinDelays[IF_MAX_LUTSIZE];
If_Obj_t * pLeaf;
float Delay, DelayCur;
float * pLutDelays;
int i, Shift, Pin2PinDelay;
int i, Shift, Pin2PinDelay, iLeaf;
assert( p->pPars->fSeqMap || pCut->nLeaves > 1 );
Delay = -IF_FLOAT_LARGE;
if ( p->pPars->pLutLib )
......@@ -435,7 +437,10 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
{
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
DelayCur = If_ObjCutBest(pLeaf)->Delay + pLutDelays[0];
if ( p->pDriverCuts && p->pDriverCuts[pObj->Id] && (iLeaf = Vec_IntFind(p->pDriverCuts[pObj->Id], pLeaf->Id)) >= 0 )
DelayCur = If_ObjCutBest(pLeaf)->Delay + s_ExtraDel[pObj->fDriver][iLeaf];
else
DelayCur = If_ObjCutBest(pLeaf)->Delay + pLutDelays[0];
Delay = IF_MAX( Delay, DelayCur );
}
}
......@@ -459,18 +464,20 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )
{
DelayCur = If_ObjCutBest(pLeaf)->Delay - Shift * p->Period;
Delay = IF_MAX( Delay, DelayCur );
Delay = IF_MAX( Delay, DelayCur + 1.0 );
}
}
else
{
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
DelayCur = If_ObjCutBest(pLeaf)->Delay;
if ( p->pDriverCuts && p->pDriverCuts[pObj->Id] && (iLeaf = Vec_IntFind(p->pDriverCuts[pObj->Id], pLeaf->Id)) >= 0 )
DelayCur = If_ObjCutBest(pLeaf)->Delay + ((pObj->fDriver && iLeaf == 2) ? 0.0 : 1.0);
else
DelayCur = If_ObjCutBest(pLeaf)->Delay + 1.0;
Delay = IF_MAX( Delay, DelayCur );
}
}
Delay += 1.0;
}
}
return Delay;
......@@ -487,14 +494,14 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
SeeAlso []
***********************************************************************/
void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float ObjRequired )
void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float ObjRequired )
{
static int pPinPerm[IF_MAX_LUTSIZE];
static float pPinDelays[IF_MAX_LUTSIZE];
If_Obj_t * pLeaf;
float * pLutDelays;
float Required;
int i, Pin2PinDelay;
int i, Pin2PinDelay, iLeaf;
assert( !p->pPars->fLiftLeaves );
// compute the pins
if ( p->pPars->pLutLib )
......@@ -513,9 +520,14 @@ void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float ObjRequired )
}
else
{
Required = ObjRequired - pLutDelays[0];
Required = ObjRequired;
If_CutForEachLeaf( p, pCut, pLeaf, i )
pLeaf->Required = IF_MIN( pLeaf->Required, Required );
{
if ( p->pDriverCuts && p->pDriverCuts[pObj->Id] && (iLeaf = Vec_IntFind(p->pDriverCuts[pObj->Id], pLeaf->Id)) >= 0 )
pLeaf->Required = IF_MIN( pLeaf->Required, Required - s_ExtraDel[pObj->fDriver][iLeaf] );
else
pLeaf->Required = IF_MIN( pLeaf->Required, Required - pLutDelays[0] );
}
}
}
else
......@@ -531,9 +543,14 @@ void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float ObjRequired )
}
else
{
Required = ObjRequired - (float)1.0;
Required = ObjRequired;
If_CutForEachLeaf( p, pCut, pLeaf, i )
pLeaf->Required = IF_MIN( pLeaf->Required, Required );
{
if ( p->pDriverCuts && p->pDriverCuts[pObj->Id] && (iLeaf = Vec_IntFind(p->pDriverCuts[pObj->Id], pLeaf->Id)) >= 0 )
pLeaf->Required = IF_MIN( pLeaf->Required, Required - (float)((pObj->fDriver && iLeaf == 2) ? 0.0 : 1.0) );
else
pLeaf->Required = IF_MIN( pLeaf->Required, Required - (float)1.0 );
}
}
}
}
......
......@@ -344,6 +344,8 @@ static inline unsigned If_CutTruthPhase( If_Cut_t * pCut, If_Cut_t * pCut1 )
return uPhase;
}
//static FILE * pTruths;
/**Function*************************************************************
Synopsis [Performs truth table computation.]
......@@ -377,7 +379,15 @@ int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_
If_TruthNand( If_CutTruth(pCut), p->puTemp[2], p->puTemp[3], pCut->nLimit );
else
If_TruthAnd( If_CutTruth(pCut), p->puTemp[2], p->puTemp[3], pCut->nLimit );
/*
if ( pCut->nLeaves == 5 )
{
if ( pTruths == NULL )
pTruths = fopen( "fun5var.txt", "w" );
Extra_PrintHex( pTruths, If_CutTruth(pCut), pCut->nLeaves );
fprintf( pTruths, "\n" );
}
*/
// minimize the support of the cut
if ( p->pPars->fCutMin )
return If_CutTruthMinimize( p, pCut );
......
......@@ -223,12 +223,12 @@ void If_ManComputeRequired( If_Man_t * p )
}
// go through the nodes in the reverse topological order
// Vec_PtrForEachEntry( If_Obj_t *, p->vMapped, pObj, i )
// If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
// If_CutPropagateRequired( p, pObj, 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, pObj, If_ObjCutBest(pObj), pObj->Required );
}
}
else
......@@ -298,7 +298,7 @@ void If_ManComputeRequired( If_Man_t * p )
{
if ( pObj->nRefs == 0 )
continue;
If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
}
else if ( If_ObjIsCi(pObj) )
{
......
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