mirror of https://github.com/YosysHQ/abc.git
Changes in the LUT mapper data-structures.
This commit is contained in:
parent
5cd9145046
commit
02cf869391
|
|
@ -906,6 +906,7 @@ static inline int If_CutFindBestStruct( If_Man_t * pIfMan, If_Cut_t * pCut, char
|
|||
int i, * pTruthId, iFirstPo, iFirstPoNext, iBestPo;
|
||||
int BestDelay = ABC_INFINITY, BestArea = ABC_INFINITY, Delay, Area;
|
||||
int uSupport, nLeaves = If_CutLeaveNum( pCut );
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
word DelayProfile;
|
||||
abctime clk;
|
||||
pCut->fUser = 1;
|
||||
|
|
@ -915,7 +916,7 @@ static inline int If_CutFindBestStruct( If_Man_t * pIfMan, If_Cut_t * pCut, char
|
|||
{
|
||||
pCut->Cost = 1;
|
||||
for ( i = 0; i < nLeaves; i++ )
|
||||
pCut->pPerm[i] = IF_BIG_CHAR;
|
||||
pPerm[i] = IF_BIG_CHAR;
|
||||
return 0;
|
||||
}
|
||||
if ( !Abc_TtSuppIsMinBase(uSupport) || uSupport == 1 )
|
||||
|
|
@ -923,8 +924,8 @@ static inline int If_CutFindBestStruct( If_Man_t * pIfMan, If_Cut_t * pCut, char
|
|||
assert( Abc_TtSuppOnlyOne(uSupport) );
|
||||
pCut->Cost = 1;
|
||||
for ( i = 0; i < nLeaves; i++ )
|
||||
pCut->pPerm[i] = IF_BIG_CHAR;
|
||||
pCut->pPerm[Abc_TtSuppFindFirst(uSupport)] = 0;
|
||||
pPerm[i] = IF_BIG_CHAR;
|
||||
pPerm[Abc_TtSuppFindFirst(uSupport)] = 0;
|
||||
return If_ObjCutBest(If_ManObj(pIfMan, pCut->pLeaves[Abc_TtSuppFindFirst(uSupport)]))->Delay;
|
||||
}
|
||||
assert( Gia_WordCountOnes(uSupport) == nLeaves );
|
||||
|
|
@ -977,7 +978,7 @@ p->timeCanon += Abc_Clock() - clk;
|
|||
DelayProfile = Vec_WrdEntry(p->vDelays, iBestPo);
|
||||
pCut->Cost = Vec_StrEntry(p->vAreas, iBestPo);
|
||||
for ( i = 0; i < nLeaves; i++ )
|
||||
pCut->pPerm[(int)pCanonPerm[i]] = Lms_DelayGet(DelayProfile, i);
|
||||
pPerm[(int)pCanonPerm[i]] = Lms_DelayGet(DelayProfile, i);
|
||||
return BestDelay;
|
||||
}
|
||||
int If_CutDelayRecCost3( If_Man_t * pIfMan, If_Cut_t * pCut, If_Obj_t * pObj )
|
||||
|
|
|
|||
|
|
@ -163,26 +163,19 @@ Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nFaninMax, int nCubeMax, int nF
|
|||
***********************************************************************/
|
||||
int Abc_NtkRenodeEvalAig( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
Kit_Graph_t * pGraph;
|
||||
int i, nNodes;
|
||||
/*
|
||||
extern void Kit_DsdTest( unsigned * pTruth, int nVars );
|
||||
if ( If_CutLeaveNum(pCut) == 8 )
|
||||
{
|
||||
nDsdCounter++;
|
||||
Kit_DsdTest( If_CutTruth(p, pCut), If_CutLeaveNum(pCut) );
|
||||
}
|
||||
*/
|
||||
pGraph = Kit_TruthToGraph( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory );
|
||||
if ( pGraph == NULL )
|
||||
{
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pCut->pPerm[i] = 100;
|
||||
pPerm[i] = 100;
|
||||
return IF_COST_MAX;
|
||||
}
|
||||
nNodes = Kit_GraphNodeNum( pGraph );
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pCut->pPerm[i] = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeLast(pGraph), Kit_GraphNode(pGraph, i) );
|
||||
pPerm[i] = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeLast(pGraph), Kit_GraphNode(pGraph, i) );
|
||||
Kit_GraphFree( pGraph );
|
||||
return nNodes;
|
||||
}
|
||||
|
|
@ -200,16 +193,17 @@ if ( If_CutLeaveNum(pCut) == 8 )
|
|||
***********************************************************************/
|
||||
int Abc_NtkRenodeEvalBdd( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
int pOrder[IF_MAX_LUTSIZE];
|
||||
DdNode * bFunc, * bFuncNew;
|
||||
int i, k, nNodes;
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pCut->pPerm[i] = pOrder[i] = -100;
|
||||
pPerm[i] = pOrder[i] = -100;
|
||||
bFunc = Kit_TruthToBdd( s_pDd, If_CutTruth(p, pCut), If_CutLeaveNum(pCut), 0 ); Cudd_Ref( bFunc );
|
||||
bFuncNew = Extra_Reorder( s_pReo, s_pDd, bFunc, pOrder ); Cudd_Ref( bFuncNew );
|
||||
for ( i = k = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
if ( pOrder[i] >= 0 )
|
||||
pCut->pPerm[pOrder[i]] = ++k; // double-check this!
|
||||
pPerm[pOrder[i]] = ++k; // double-check this!
|
||||
nNodes = -1 + Cudd_DagSize( bFuncNew );
|
||||
Cudd_RecursiveDeref( s_pDd, bFuncNew );
|
||||
Cudd_RecursiveDeref( s_pDd, bFunc );
|
||||
|
|
@ -229,9 +223,10 @@ int Abc_NtkRenodeEvalBdd( If_Man_t * p, If_Cut_t * pCut )
|
|||
***********************************************************************/
|
||||
int Abc_NtkRenodeEvalSop( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
int i, RetValue;
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pCut->pPerm[i] = 1;
|
||||
pPerm[i] = 1;
|
||||
RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 1 );
|
||||
if ( RetValue == -1 )
|
||||
return IF_COST_MAX;
|
||||
|
|
@ -252,10 +247,11 @@ int Abc_NtkRenodeEvalSop( If_Man_t * p, If_Cut_t * pCut )
|
|||
***********************************************************************/
|
||||
int Abc_NtkRenodeEvalCnf( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
int i, RetValue, nClauses;
|
||||
// set internal mapper parameters
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pCut->pPerm[i] = 1;
|
||||
pPerm[i] = 1;
|
||||
// compute ISOP for the positive phase
|
||||
RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 0 );
|
||||
if ( RetValue == -1 )
|
||||
|
|
@ -286,10 +282,11 @@ int Abc_NtkRenodeEvalCnf( If_Man_t * p, If_Cut_t * pCut )
|
|||
***********************************************************************/
|
||||
int Abc_NtkRenodeEvalMv( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
int i, RetValue;
|
||||
// set internal mapper parameters
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pCut->pPerm[i] = 1;
|
||||
pPerm[i] = 1;
|
||||
// compute ISOP for the positive phase
|
||||
RetValue = Kit_TruthIsop( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), s_vMemory, 0 );
|
||||
if ( RetValue == -1 )
|
||||
|
|
|
|||
|
|
@ -282,8 +282,7 @@ struct If_Cut_t_
|
|||
unsigned fUseless: 1; // using the user's area and delay
|
||||
unsigned nLimit : 8; // the maximum number of leaves
|
||||
unsigned nLeaves : 8; // the number of leaves
|
||||
int * pLeaves; // array of fanins
|
||||
char * pPerm; // permutation
|
||||
int pLeaves[0];
|
||||
};
|
||||
|
||||
// set of priority cut
|
||||
|
|
@ -390,6 +389,9 @@ static inline unsigned If_CutSuppMask( If_Cut_t * pCut ) { r
|
|||
static inline int If_CutTruthWords( int nVarsMax ) { return nVarsMax <= 5 ? 2 : (1 << (nVarsMax - 5)); }
|
||||
static inline int If_CutPermWords( int nVarsMax ) { return nVarsMax / sizeof(int) + ((nVarsMax % sizeof(int)) > 0); }
|
||||
static inline int If_CutLeafBit( If_Cut_t * pCut, int i ) { return (pCut->uMaskFunc >> i) & 1; }
|
||||
static inline char * If_CutPerm( If_Cut_t * pCut ) { return (char *)(pCut->pLeaves + pCut->nLeaves); }
|
||||
static inline void If_CutCopy( If_Man_t * p, If_Cut_t * pDst, If_Cut_t * pSrc ) { memcpy( pDst, pSrc, p->nCutBytes ); }
|
||||
static inline void If_CutSetup( If_Man_t * p, If_Cut_t * pCut ) { memset(pCut, 0, p->nCutBytes); pCut->nLimit = p->pPars->nLutSize; }
|
||||
|
||||
static inline If_Cut_t * If_ObjCutBest( If_Obj_t * pObj ) { return &pObj->CutBest; }
|
||||
static inline unsigned If_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId % 31)); }
|
||||
|
|
|
|||
|
|
@ -905,34 +905,6 @@ void If_CutLift( If_Cut_t * pCut )
|
|||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes area of the first level.]
|
||||
|
||||
Description [The cut need to be derefed.]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void If_CutCopy( If_Man_t * p, If_Cut_t * pCutDest, If_Cut_t * pCutSrc )
|
||||
{
|
||||
int * pLeaves;
|
||||
char * pPerm;
|
||||
// unsigned * pTruth;
|
||||
// save old arrays
|
||||
pLeaves = pCutDest->pLeaves;
|
||||
pPerm = pCutDest->pPerm;
|
||||
// pTruth = pCutDest->pTruth;
|
||||
// copy the cut info
|
||||
memcpy( pCutDest, pCutSrc, p->nCutBytes );
|
||||
// restore the arrays
|
||||
pCutDest->pLeaves = pLeaves;
|
||||
pCutDest->pPerm = pPerm;
|
||||
// pCutDest->pTruth = pTruth;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
|
|||
|
|
@ -2141,10 +2141,11 @@ float If_CutDelayLutStruct( If_Man_t * p, If_Cut_t * pCut, char * pStr, float Wi
|
|||
// consider easy case
|
||||
if ( nLeaves <= Abc_MaxInt( nLutLeaf, nLutRoot ) )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
assert( nLeaves <= 6 );
|
||||
for ( i = 0; i < nLeaves; i++ )
|
||||
{
|
||||
pCut->pPerm[i] = 1;
|
||||
pPerm[i] = 1;
|
||||
G1.pVars[i] = i;
|
||||
}
|
||||
G1.nVars = nLeaves;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ static inline int If_CutMaxCubeSize( Vec_Int_t * vCover, int nVars )
|
|||
}
|
||||
int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
// delay is calculated using 1+log2(NumFanins)
|
||||
static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
|
||||
Vec_Int_t * vCover;
|
||||
|
|
@ -90,7 +91,7 @@ int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut )
|
|||
Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + 0.5);
|
||||
DelayMax = 0;
|
||||
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
||||
DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pCut->pPerm[i] = (char)Delay) );
|
||||
DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pPerm[i] = (char)Delay) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -98,7 +99,7 @@ int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut )
|
|||
Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + GateDelays[nLitMax] + 0.5);
|
||||
DelayMax = 0;
|
||||
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
||||
DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pCut->pPerm[i] = (char)Delay) );
|
||||
DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pPerm[i] = (char)Delay) );
|
||||
}
|
||||
return DelayMax;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1919,7 +1919,7 @@ int If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm )
|
|||
int i, Delay, nSupp = 0, pTimes[IF_MAX_FUNC_LUTSIZE];
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
|
||||
Delay = If_CutDsdBalancePinDelays_rec( p->pIfDsdMan, Abc_Lit2Var(If_CutDsdLit(p, pCut)), pTimes, &Result, &nSupp, If_CutLeaveNum(pCut), pCut->pPerm );
|
||||
Delay = If_CutDsdBalancePinDelays_rec( p->pIfDsdMan, Abc_Lit2Var(If_CutDsdLit(p, pCut)), pTimes, &Result, &nSupp, If_CutLeaveNum(pCut), If_CutDsdPerm(p, pCut) );
|
||||
assert( nSupp == If_CutLeaveNum(pCut) );
|
||||
If_CutPinDelayTranslate( Result, If_CutLeaveNum(pCut), pPerm );
|
||||
return Delay;
|
||||
|
|
@ -2033,7 +2033,7 @@ int If_CutDsdBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig )
|
|||
int Delay, Area = 0;
|
||||
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
|
||||
pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
|
||||
Delay = If_CutDsdBalanceEvalInt( p->pIfDsdMan, If_CutDsdLit(p, pCut), pTimes, vAig, &Area, pCut->pPerm );
|
||||
Delay = If_CutDsdBalanceEvalInt( p->pIfDsdMan, If_CutDsdLit(p, pCut), pTimes, vAig, &Area, If_CutDsdPerm(p, pCut) );
|
||||
pCut->Cost = Area;
|
||||
return Delay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,26 +417,6 @@ void If_ManCreateChoice( If_Man_t * p, If_Obj_t * pObj )
|
|||
p->nChoices++;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Prepares memory for one cut.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void If_ManSetupCut( If_Man_t * p, If_Cut_t * pCut )
|
||||
{
|
||||
memset( pCut, 0, sizeof(If_Cut_t) );
|
||||
pCut->nLimit = p->pPars->nLutSize;
|
||||
pCut->pLeaves = (int *)(pCut + 1);
|
||||
if ( p->pPars->fUsePerm )
|
||||
pCut->pPerm = (char *)(pCut->pLeaves + p->pPars->nLutSize);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Prepares memory for one cutset.]
|
||||
|
|
@ -459,7 +439,7 @@ void If_ManSetupSet( If_Man_t * p, If_Set_t * pSet )
|
|||
for ( i = 0; i <= pSet->nCutsMax; i++ )
|
||||
{
|
||||
pSet->ppCuts[i] = (If_Cut_t *)(pArray + i * p->nCutBytes);
|
||||
If_ManSetupCut( p, pSet->ppCuts[i] );
|
||||
If_CutSetup( p, pSet->ppCuts[i] );
|
||||
}
|
||||
// pArray += (pSet->nCutsMax + 1) * p->nCutBytes;
|
||||
// assert( ((char *)pArray) - ((char *)pSet) == p->nSetBytes );
|
||||
|
|
@ -505,7 +485,7 @@ If_Obj_t * If_ManSetupObj( If_Man_t * p )
|
|||
// get memory for the object
|
||||
pObj = (If_Obj_t *)Mem_FixedEntryFetch( p->pMemObj );
|
||||
memset( pObj, 0, sizeof(If_Obj_t) );
|
||||
If_ManSetupCut( p, &pObj->CutBest );
|
||||
If_CutSetup( p, &pObj->CutBest );
|
||||
// assign ID and save
|
||||
pObj->Id = Vec_PtrSize(p->vObjs);
|
||||
Vec_PtrPush( p->vObjs, pObj );
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ 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];
|
||||
char * pPerm = If_CutPerm( pCut );
|
||||
If_Obj_t * pLeaf;
|
||||
float Delay, DelayCur;
|
||||
float * pLutDelays;
|
||||
|
|
@ -127,7 +128,7 @@ float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut )
|
|||
assert( !p->pPars->fLiftLeaves );
|
||||
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
||||
{
|
||||
Pin2PinDelay = pCut->pPerm ? (pCut->pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pCut->pPerm[i]) : 1;
|
||||
Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
|
||||
DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)Pin2PinDelay;
|
||||
Delay = IF_MAX( Delay, DelayCur );
|
||||
}
|
||||
|
|
@ -218,7 +219,7 @@ void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, fl
|
|||
assert( Delay == (int)pCut->Delay );
|
||||
}
|
||||
else
|
||||
pPerm = pCut->pPerm;
|
||||
pPerm = If_CutPerm(pCut);
|
||||
If_CutForEachLeaf( p, pCut, pLeaf, i )
|
||||
{
|
||||
Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue