2008-01-31 05:01:00 +01:00
|
|
|
/**CFile****************************************************************
|
|
|
|
|
|
|
|
|
|
FileName [ifTime.c]
|
|
|
|
|
|
|
|
|
|
SystemName [ABC: Logic synthesis and verification system.]
|
|
|
|
|
|
|
|
|
|
PackageName [FPGA mapping based on priority cuts.]
|
|
|
|
|
|
|
|
|
|
Synopsis [Computation of delay paramters depending on the library.]
|
|
|
|
|
|
|
|
|
|
Author [Alan Mishchenko]
|
|
|
|
|
|
|
|
|
|
Affiliation [UC Berkeley]
|
|
|
|
|
|
|
|
|
|
Date [Ver. 1.0. Started - November 21, 2006.]
|
|
|
|
|
|
|
|
|
|
Revision [$Id: ifTime.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "if.h"
|
2010-11-01 09:35:04 +01:00
|
|
|
|
|
|
|
|
ABC_NAMESPACE_IMPL_START
|
|
|
|
|
|
2008-01-31 05:01:00 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// DECLARATIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// FUNCTION DEFINITIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-11-01 09:35:04 +01:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
2014-04-07 00:21:07 +02:00
|
|
|
Synopsis [Sorts the pins in the decreasing order of delays.]
|
2010-11-01 09:35:04 +01:00
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2014-04-07 00:21:07 +02:00
|
|
|
void If_CutSortInputPins( If_Man_t * p, If_Cut_t * pCut, int * pPinPerm, float * pPinDelays )
|
2010-11-01 09:35:04 +01:00
|
|
|
{
|
|
|
|
|
If_Obj_t * pLeaf;
|
2014-04-07 00:21:07 +02:00
|
|
|
int i, j, best_i, temp;
|
|
|
|
|
// start the trivial permutation and collect pin delays
|
|
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
2010-11-01 09:35:04 +01:00
|
|
|
{
|
2014-04-07 00:21:07 +02:00
|
|
|
pPinPerm[i] = i;
|
|
|
|
|
pPinDelays[i] = If_ObjCutBest(pLeaf)->Delay;
|
2010-11-01 09:35:04 +01:00
|
|
|
}
|
2014-04-07 00:21:07 +02:00
|
|
|
// selection sort the pins in the decreasible order of delays
|
|
|
|
|
// this order will match the increasing order of LUT input pins
|
|
|
|
|
for ( i = 0; i < (int)pCut->nLeaves-1; i++ )
|
2011-04-21 08:15:05 +02:00
|
|
|
{
|
2014-04-07 00:21:07 +02:00
|
|
|
best_i = i;
|
|
|
|
|
for ( j = i+1; j < (int)pCut->nLeaves; j++ )
|
|
|
|
|
if ( pPinDelays[pPinPerm[j]] > pPinDelays[pPinPerm[best_i]] )
|
|
|
|
|
best_i = j;
|
|
|
|
|
if ( best_i == i )
|
|
|
|
|
continue;
|
|
|
|
|
temp = pPinPerm[i];
|
|
|
|
|
pPinPerm[i] = pPinPerm[best_i];
|
|
|
|
|
pPinPerm[best_i] = temp;
|
2011-04-21 08:15:05 +02:00
|
|
|
}
|
2014-04-06 07:51:01 +02:00
|
|
|
/*
|
2014-04-07 00:21:07 +02:00
|
|
|
// verify
|
|
|
|
|
assert( pPinPerm[0] < (int)pCut->nLeaves );
|
|
|
|
|
for ( i = 1; i < (int)pCut->nLeaves; i++ )
|
2014-04-06 07:51:01 +02:00
|
|
|
{
|
2014-04-07 00:21:07 +02:00
|
|
|
assert( pPinPerm[i] < (int)pCut->nLeaves );
|
|
|
|
|
assert( pPinDelays[pPinPerm[i-1]] >= pPinDelays[pPinPerm[i]] );
|
2014-04-06 07:51:01 +02:00
|
|
|
}
|
|
|
|
|
*/
|
2012-03-16 23:43:08 +01:00
|
|
|
}
|
2010-11-01 09:35:04 +01:00
|
|
|
|
|
|
|
|
|
2008-01-31 05:01:00 +01:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Computes delay.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2011-07-10 08:56:05 +02:00
|
|
|
float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut )
|
2008-01-31 05:01:00 +01:00
|
|
|
{
|
|
|
|
|
static int pPinPerm[IF_MAX_LUTSIZE];
|
|
|
|
|
static float pPinDelays[IF_MAX_LUTSIZE];
|
|
|
|
|
If_Obj_t * pLeaf;
|
|
|
|
|
float Delay, DelayCur;
|
|
|
|
|
float * pLutDelays;
|
2013-09-03 07:10:27 +02:00
|
|
|
int i, Shift, Pin2PinDelay;//, iLeaf;
|
2014-02-17 04:30:38 +01:00
|
|
|
// assert( p->pPars->fSeqMap || pCut->nLeaves > 1 );
|
2008-01-31 05:01:00 +01:00
|
|
|
Delay = -IF_FLOAT_LARGE;
|
|
|
|
|
if ( p->pPars->pLutLib )
|
|
|
|
|
{
|
|
|
|
|
assert( !p->pPars->fLiftLeaves );
|
|
|
|
|
pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
|
|
|
|
|
if ( p->pPars->pLutLib->fVarPinDelays )
|
|
|
|
|
{
|
|
|
|
|
// compute the delay using sorted pins
|
|
|
|
|
If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
|
|
|
|
|
for ( i = 0; i < (int)pCut->nLeaves; i++ )
|
|
|
|
|
{
|
|
|
|
|
DelayCur = pPinDelays[pPinPerm[i]] + pLutDelays[i];
|
|
|
|
|
Delay = IF_MAX( Delay, DelayCur );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
|
|
|
|
{
|
2013-09-03 07:14:20 +02:00
|
|
|
DelayCur = If_ObjCutBest(pLeaf)->Delay + pLutDelays[0];
|
2008-01-31 05:01:00 +01:00
|
|
|
Delay = IF_MAX( Delay, DelayCur );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( pCut->fUser )
|
|
|
|
|
{
|
|
|
|
|
assert( !p->pPars->fLiftLeaves );
|
|
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
|
|
|
|
{
|
2011-04-21 08:15:05 +02:00
|
|
|
Pin2PinDelay = pCut->pPerm ? (pCut->pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pCut->pPerm[i]) : 1;
|
|
|
|
|
DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)Pin2PinDelay;
|
2008-01-31 05:01:00 +01:00
|
|
|
Delay = IF_MAX( Delay, DelayCur );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( p->pPars->fLiftLeaves )
|
|
|
|
|
{
|
|
|
|
|
If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )
|
|
|
|
|
{
|
|
|
|
|
DelayCur = If_ObjCutBest(pLeaf)->Delay - Shift * p->Period;
|
2011-07-10 08:56:05 +02:00
|
|
|
Delay = IF_MAX( Delay, DelayCur + 1.0 );
|
2008-01-31 05:01:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
|
|
|
|
{
|
2013-09-03 07:14:20 +02:00
|
|
|
DelayCur = If_ObjCutBest(pLeaf)->Delay + 1.0;
|
2008-01-31 05:01:00 +01:00
|
|
|
Delay = IF_MAX( Delay, DelayCur );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Delay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis []
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2011-07-10 08:56:05 +02:00
|
|
|
void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float ObjRequired )
|
2008-01-31 05:01:00 +01:00
|
|
|
{
|
|
|
|
|
static int pPinPerm[IF_MAX_LUTSIZE];
|
|
|
|
|
static float pPinDelays[IF_MAX_LUTSIZE];
|
|
|
|
|
If_Obj_t * pLeaf;
|
|
|
|
|
float * pLutDelays;
|
|
|
|
|
float Required;
|
2013-09-03 07:10:27 +02:00
|
|
|
int i, Pin2PinDelay;//, iLeaf;
|
2008-01-31 05:01:00 +01:00
|
|
|
assert( !p->pPars->fLiftLeaves );
|
|
|
|
|
// compute the pins
|
|
|
|
|
if ( p->pPars->pLutLib )
|
|
|
|
|
{
|
|
|
|
|
pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
|
|
|
|
|
if ( p->pPars->pLutLib->fVarPinDelays )
|
|
|
|
|
{
|
|
|
|
|
// compute the delay using sorted pins
|
|
|
|
|
If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
|
|
|
|
|
for ( i = 0; i < (int)pCut->nLeaves; i++ )
|
|
|
|
|
{
|
|
|
|
|
Required = ObjRequired - pLutDelays[i];
|
|
|
|
|
pLeaf = If_ManObj( p, pCut->pLeaves[pPinPerm[i]] );
|
|
|
|
|
pLeaf->Required = IF_MIN( pLeaf->Required, Required );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-07-10 08:56:05 +02:00
|
|
|
Required = ObjRequired;
|
2008-01-31 05:01:00 +01:00
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
2013-09-03 07:14:20 +02:00
|
|
|
pLeaf->Required = IF_MIN( pLeaf->Required, Required - pLutDelays[0] );
|
2008-01-31 05:01:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( pCut->fUser )
|
|
|
|
|
{
|
2014-04-07 00:21:07 +02:00
|
|
|
char Perm[IF_MAX_FUNC_LUTSIZE];
|
|
|
|
|
char * pPerm = p->pPars->fDelayOpt ? Perm : pCut->pPerm;
|
2014-04-06 07:51:01 +02:00
|
|
|
if ( p->pPars->fDelayOpt )
|
2014-04-07 00:21:07 +02:00
|
|
|
If_CutSopBalancePinDelays( p, pCut, pPerm );
|
2008-01-31 05:01:00 +01:00
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
|
|
|
|
{
|
2014-04-07 00:21:07 +02:00
|
|
|
Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
|
2011-04-21 08:15:05 +02:00
|
|
|
Required = ObjRequired - (float)Pin2PinDelay;
|
2008-01-31 05:01:00 +01:00
|
|
|
pLeaf->Required = IF_MIN( pLeaf->Required, Required );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-07-10 08:56:05 +02:00
|
|
|
Required = ObjRequired;
|
2008-01-31 05:01:00 +01:00
|
|
|
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
2013-09-03 07:14:20 +02:00
|
|
|
pLeaf->Required = IF_MIN( pLeaf->Required, Required - (float)1.0 );
|
2008-01-31 05:01:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// END OF FILE ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
2010-11-01 09:35:04 +01:00
|
|
|
ABC_NAMESPACE_IMPL_END
|
|
|
|
|
|