Improving ACD mapping

This commit is contained in:
aletempiac 2023-11-17 16:58:17 +01:00
parent 3d602e2f00
commit 1d7dfd25c6
7 changed files with 39 additions and 54 deletions

View File

@ -166,6 +166,7 @@ public:
/* try without the delay profile */
if ( best_multiplicity == UINT32_MAX && ps.try_no_late_arrival )
{
delay_profile = 0;
if ( ps.support_reducing_only )
{
start = std::max( 1u, num_vars - ps.lut_size );
@ -197,7 +198,8 @@ public:
pst->num_luts = best_multiplicity <= 2 ? 2 : best_multiplicity <= 4 ? 3 : best_multiplicity <= 8 ? 4 : 5;
best_free_set = free_set_size;
return 0;
/* return number of levels */
return delay_profile == 0 ? 2 : 1;
}
int compute_decomposition()

View File

@ -22,7 +22,6 @@ int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay,
ac_decomposition_impl acd( tt, nVars, ps, &st );
int val = acd.run( *pdelay );
// int val = acd.compute_decomposition();
if ( val < 0 )
{
@ -33,7 +32,7 @@ int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay,
*pdelay = acd.get_profile();
*cost = st.num_luts;
return 0;
return val;
}
int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition )

View File

@ -458,34 +458,10 @@ Hop_Obj_t * Abc_NodeBuildFromMini( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pC
// get the delay profile
unsigned delayProfile = pCutBest->acdDelay;
// If_Obj_t * pLeaf;
// int i, leafDelay;
// int DelayMax = -1, nLeafMax = 0;
// unsigned uLeafMask = 0;
// If_CutForEachLeaf( pIfMan, pCutBest, pLeaf, i )
// {
// leafDelay = If_ObjCutBest(pLeaf)->Delay;
// if ( DelayMax < leafDelay )
// {
// DelayMax = leafDelay;
// nLeafMax = 1;
// uLeafMask = (1 << i);
// }
// else if ( DelayMax == leafDelay )
// {
// nLeafMax++;
// uLeafMask |= (1 << i);
// }
// }
// perform LUT-decomposition and return the LUT-structure
unsigned char decompArray[92];
int val = acd_decompose( pTruth, pCutBest->nLeaves, 6, &(delayProfile), decompArray );
assert( val == 0 );
// assert( DelayMax + 2 >= pCutBest->Delay );
// convert the LUT-structure into a set of logic nodes in Abc_Ntk_t
unsigned char bytes_check = decompArray[0];
@ -561,8 +537,6 @@ Hop_Obj_t * Abc_NodeBuildFromMini( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pC
/* check correct read */
assert( byte_p == decompArray[0] );
// this is a placeholder, which takes the truth table and converts it into an AIG without LUT-decomposition
}
/**Function*************************************************************

View File

@ -570,7 +570,7 @@ extern int If_CutSopBalancePinDelaysInt( Vec_Int_t * vCover, int * p
extern int If_CutSopBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
extern int If_CutLutBalanceEval( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutLutBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
extern int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay );
extern int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay, int fFirst );
extern int If_AcdReEval( If_Man_t * p, If_Cut_t * pCut );
extern float If_AcdLeafProp( If_Man_t * p, If_Cut_t * pCut, int i, float required );
/*=== ifDsd.c =============================================================*/

View File

@ -128,16 +128,11 @@ int If_ManPerformMappingComb( If_Man_t * p )
if ( p->pPars->fPreprocess && !p->pPars->fArea )
{
// map for delay
If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 1, 1, "Delay" );
if ( p->pPars->fAcd )
{
// p->pPars->nLutSize = oldLutSize;
p->useLimitAdc = 0;
If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 1, 0, "Delay" );
If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 1, 1, "Delay" );
if ( p->pPars->fAcd )
p->useLimitAdc = 1;
// p->pPars->nLutSize = 6;
}
// map for delay second option
p->pPars->fFancy = 1;
@ -160,17 +155,33 @@ int If_ManPerformMappingComb( If_Man_t * p )
// area flow oriented mapping
for ( i = 0; i < p->pPars->nFlowIters; i++ )
{
// if ( p->pPars->fAcd && i == 0 )
// {
// p->useLimitAdc = 0;
// }
If_ManPerformMappingRound( p, p->pPars->nCutsMax, 1, 0, 0, "Flow" );
if ( p->pPars->fExpRed )
If_ManImproveMapping( p );
// if ( p->pPars->fAcd && i == 0 )
// {
// p->useLimitAdc = 1;
// }
}
// area oriented mapping
for ( i = 0; i < p->pPars->nAreaIters; i++ )
{
// if ( p->pPars->fAcd && i == 0 )
// {
// p->useLimitAdc = 0;
// }
If_ManPerformMappingRound( p, p->pPars->nCutsMax, 2, 0, 0, "Area" );
if ( p->pPars->fExpRed )
If_ManImproveMapping( p );
// if ( p->pPars->fAcd && i == 0 )
// {
// p->useLimitAdc = 1;
// }
}
if ( p->pPars->fVerbose )

View File

@ -412,7 +412,7 @@ int If_CutLutBalanceEval( If_Man_t * p, If_Cut_t * pCut )
}
}
int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay )
int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay, int fFirst )
{
pCut->fUser = 1;
pCut->Cost = pCut->nLeaves > 1 ? 1 : 0;
@ -428,7 +428,6 @@ int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay )
return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
}
// int LutSize = p->pPars->pLutStruct[0] - '0';
int LutSize = 6;
int i, leaf_delay;
int DelayMax = -1, nLeafMax = 0;
@ -454,24 +453,23 @@ int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay )
pCut->acdDelay = ( 1 << LutSize ) - 1;
return DelayMax + 1;
}
// else if ( DelayMax + 1 >= best_delay )
// {
// return DelayMax + 2;
// }
/* compute the decomposition */
int use_late_arrival;
int use_late_arrival = 0;
unsigned cost = 1;
if ( optDelay )
if ( !fFirst )
{
/* checks based on delay: must be better than the previous best cut */
use_late_arrival = DelayMax + 2 >= If_ObjCutBest(pObj)->Delay;
}
else
{
/* checks based on delay: look at the required time */
use_late_arrival = DelayMax + 2 > pObj->Required + p->fEpsilon;
if ( optDelay )
{
/* checks based on delay: must be better than the previous best cut */
use_late_arrival = DelayMax + 2 >= If_ObjCutBest(pObj)->Delay;
}
else
{
/* checks based on delay: look at the required time */
use_late_arrival = DelayMax + 2 > pObj->Required + p->fEpsilon;
}
}
/* Too many late-arriving signals */
@ -490,6 +488,7 @@ int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay )
}
}
/* returns the delay of the decomposition */
word *pTruth = If_CutTruthW( p, pCut );
int val = acd_evaluate( pTruth, pCut->nLeaves, LutSize, &uLeafMask, &cost, !use_late_arrival );
@ -503,7 +502,7 @@ int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pObj, int optDelay )
pCut->Cost = cost;
return DelayMax + ( use_late_arrival ? 1 : 2 );
return DelayMax + val;
}
int If_AcdReEval( If_Man_t * p, If_Cut_t * pCut )

View File

@ -431,7 +431,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
else if ( p->pPars->fAcd )
{
pCut->Delay = If_AcdEval( p, pCut, pObj, Mode == 0 );
pCut->Delay = If_AcdEval( p, pCut, pObj, Mode == 0, fFirst );
pCut->fUseless = pCut->Delay == ABC_INFINITY;
}
else if ( p->pPars->fUserSesLib )