summaryrefslogtreecommitdiffstats
path: root/src/base/abci
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/abci')
-rw-r--r--src/base/abci/abc.c15
-rw-r--r--src/base/abci/abcDsdRes.c325
-rw-r--r--src/base/abci/abcReconv.c2
-rw-r--r--src/base/abci/abcRefactor.c2
-rw-r--r--src/base/abci/abcRestruct.c2
5 files changed, 268 insertions, 78 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 753a2fb7..216a737a 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -63,7 +63,7 @@ static int Abc_CommandSweep ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandFastExtract ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDisjoint ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandImfs ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandLutjam ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandLutpack ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -218,7 +218,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Synthesis", "fx", Abc_CommandFastExtract, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "dsd", Abc_CommandDisjoint, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "imfs", Abc_CommandImfs, 1 );
- Cmd_CommandAdd( pAbc, "Synthesis", "lutjam", Abc_CommandLutjam, 1 );
+ Cmd_CommandAdd( pAbc, "Synthesis", "lutpack", Abc_CommandLutpack, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 );
@@ -328,6 +328,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
// Abc_NtkPrint256();
// Kit_TruthCountMintermsPrecomp();
+// Kit_DsdPrecompute4Vars();
}
/**Function*************************************************************
@@ -1536,7 +1537,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
// convert it to truth table
{
Abc_Obj_t * pObj = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
- Vec_Int_t * vMemory = Vec_IntAlloc( 100 );
+ Vec_Int_t * vMemory = Vec_IntAlloc( 10000 );
unsigned * pTruth;
if ( !Abc_ObjIsNode(pObj) )
{
@@ -1548,7 +1549,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pErr, "Currently works only for up to 8 inputs.\n" );
return 1;
}
- pTruth = Abc_ConvertAigToTruth( pNtk->pManFunc, Hop_Regular(pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 1 );
+ pTruth = Abc_ConvertAigToTruth( pNtk->pManFunc, Hop_Regular(pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
if ( Hop_IsComplement(pObj->pData) )
Extra_TruthNot( pTruth, pTruth, Abc_ObjFaninNum(pObj) );
Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) );
@@ -2889,7 +2890,7 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandLutjam( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk;
@@ -2907,7 +2908,7 @@ int Abc_CommandLutjam( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults
memset( pPars, 0, sizeof(Lut_Par_t) );
pPars->nLutsMax = 4; // (N) the maximum number of LUTs in the structure
- pPars->nLutsOver = 1; // (Q) the maximum number of LUTs not in the MFFC
+ pPars->nLutsOver = 2; // (Q) the maximum number of LUTs not in the MFFC
pPars->nVarsShared = 0; // (S) the maximum number of shared variables (crossbars)
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0;
@@ -2982,7 +2983,7 @@ int Abc_CommandLutjam( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: lutjam [-N <num>] [-Q <num>] [-S <num>] [-vwh]\n" );
+ fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-vwh]\n" );
fprintf( pErr, "\t performs \"rewriting\" for LUT networks\n" );
fprintf( pErr, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
fprintf( pErr, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
diff --git a/src/base/abci/abcDsdRes.c b/src/base/abci/abcDsdRes.c
index 68748577..a76df9ce 100644
--- a/src/base/abci/abcDsdRes.c
+++ b/src/base/abci/abcDsdRes.c
@@ -41,6 +41,7 @@ struct Lut_Cut_t_
unsigned fMark : 1; // multipurpose mark
// unsigned uSign[2]; // the signature
float Weight; // the weight of the cut: (M - Q)/N(V) (the larger the better)
+ int Gain; // the gain achieved using this cut
int pLeaves[LUT_SIZE_MAX]; // the leaves of the cut
int pNodes[LUT_SIZE_MAX]; // the nodes of the cut
};
@@ -53,25 +54,35 @@ struct Lut_Man_t_
Abc_Ntk_t * pNtk; // the network
Abc_Obj_t * pObj; // the node to resynthesize
// cut representation
+ int nMffc; // the size of MFFC of the node
int nCuts; // the total number of cuts
int nCutsMax; // the largest possible number of cuts
int nEvals; // the number of good cuts
Lut_Cut_t pCuts[LUT_CUTS_MAX]; // the storage for cuts
- int pEvals[LUT_SIZE_MAX]; // the good cuts
+ int pEvals[LUT_CUTS_MAX]; // the good cuts
// temporary variables
int pRefs[LUT_SIZE_MAX]; // fanin reference counters
int pCands[LUT_SIZE_MAX]; // internal nodes pointing only to the leaves
// truth table representation
Vec_Ptr_t * vTtElems; // elementary truth tables
Vec_Ptr_t * vTtNodes; // storage for temporary truth tables of the nodes
+ // statistics
+ int nCutsTotal;
+ int nGainTotal;
+ // rutime
+ int timeCuts;
+ int timeTruth;
+ int timeEval;
+ int timeOther;
+ int timeTotal;
};
-static int Abc_LutResynthesizeNode( Lut_Man_t * p );
-
#define Abc_LutCutForEachLeaf( pNtk, pCut, pObj, i ) \
for ( i = 0; (i < (int)(pCut)->nLeaves) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pLeaves[i])), 1); i++ )
#define Abc_LutCutForEachNode( pNtk, pCut, pObj, i ) \
for ( i = 0; (i < (int)(pCut)->nNodes) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i++ )
+#define Abc_LutCutForEachNodeReverse( pNtk, pCut, pObj, i ) \
+ for ( i = (int)(pCut)->nNodes - 1; (i >= 0) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i-- )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -93,14 +104,15 @@ Lut_Man_t * Abc_LutManStart( Lut_Par_t * pPars )
Lut_Man_t * p;
int i;
assert( pPars->nLutsMax <= 16 );
+ assert( pPars->nVarsMax > 0 );
p = ALLOC( Lut_Man_t, 1 );
memset( p, 0, sizeof(Lut_Man_t) );
p->pPars = pPars;
p->nCutsMax = LUT_CUTS_MAX;
for ( i = 0; i < p->nCuts; i++ )
p->pCuts[i].nLeavesMax = p->pCuts[i].nNodesMax = LUT_SIZE_MAX;
- p->vTtElems = Vec_PtrAllocTruthTables( pPars->nLutsMax );
- p->vTtNodes = Vec_PtrAllocSimInfo( 256, Abc_TruthWordNum(pPars->nLutsMax) );
+ p->vTtElems = Vec_PtrAllocTruthTables( pPars->nVarsMax );
+ p->vTtNodes = Vec_PtrAllocSimInfo( 256, Abc_TruthWordNum(pPars->nVarsMax) );
return p;
}
@@ -124,51 +136,6 @@ void Abc_LutManStop( Lut_Man_t * p )
/**Function*************************************************************
- Synopsis [Performs resynthesis for one network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Abc_LutResynthesize( Abc_Ntk_t * pNtk, Lut_Par_t * pPars )
-{
- Lut_Man_t * p;
- Abc_Obj_t * pObj;
- int i;
- assert( Abc_NtkIsLogic(pNtk) );
- // convert logic to AIGs
- Abc_NtkToAig( pNtk );
- // compute the levels
- Abc_NtkLevel( pNtk );
- // start the manager
- p = Abc_LutManStart( pPars );
- p->pNtk = pNtk;
- // get the number of inputs
- p->pPars->nLutSize = Abc_NtkGetFaninMax( pNtk );
- p->pPars->nVarsMax = p->pPars->nLutsMax * (p->pPars->nLutSize - 1) + 1; // V = N * (K-1) + 1
- printf( "Resynthesis for %d %d-LUTs with %d non-MFFC LUTs, %d crossbars, and %d-input cuts.\n",
- p->pPars->nLutsMax, p->pPars->nLutSize, p->pPars->nLutsOver, p->pPars->nVarsShared, p->pPars->nVarsMax );
- // consider all nodes
- Abc_NtkForEachNode( pNtk, pObj, i )
- {
- p->pObj = pObj;
- Abc_LutResynthesizeNode( p );
- }
- Abc_LutManStop( p );
- // check the resulting network
- if ( !Abc_NtkCheck( pNtk ) )
- {
- printf( "Abc_LutResynthesize: The network check has failed.\n" );
- return 0;
- }
- return 1;
-}
-
-/**Function*************************************************************
-
Synopsis [Returns 1 if the cut has structural DSD.]
Description []
@@ -216,7 +183,7 @@ int Abc_LutNodeCutsCheckDsd( Lut_Man_t * p, Lut_Cut_t * pCut )
if ( p->pRefs[(int)pFanin->pCopy] > 1 )
break;
}
- if ( k == Abc_ObjFaninNum(pFanin) )
+ if ( k == Abc_ObjFaninNum(pObj) )
{
RetValue = 1;
break;
@@ -316,6 +283,36 @@ int Abc_LutNodeCutsOneFilter( Lut_Cut_t * pCuts, int nCuts, Lut_Cut_t * pCutNew
/**Function*************************************************************
+ Synopsis [Prints the given cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_LutNodePrintCut( Lut_Man_t * p, Lut_Cut_t * pCut )
+{
+ Abc_Obj_t * pObj;
+ int i;
+ printf( "LEAVES:\n" );
+ Abc_LutCutForEachLeaf( p->pNtk, pCut, pObj, i )
+ {
+ Abc_ObjPrint( stdout, pObj );
+ }
+ printf( "NODES:\n" );
+ Abc_LutCutForEachNode( p->pNtk, pCut, pObj, i )
+ {
+ Abc_ObjPrint( stdout, pObj );
+ assert( Abc_ObjIsNode(pObj) );
+ }
+ printf( "\n" );
+}
+
+
+/**Function*************************************************************
+
Synopsis [Computes the set of all cuts.]
Description []
@@ -335,8 +332,14 @@ void Abc_LutNodeCutsOne( Lut_Man_t * p, Lut_Cut_t * pCut, int Node )
if ( pCut->nNodes == LUT_SIZE_MAX )
return;
- // if the node is not in the MFFC, check the limit
+ // if the node is a PI, quit
pObj = Abc_NtkObj( p->pNtk, Node );
+ if ( Abc_ObjIsCi(pObj) )
+ return;
+ assert( Abc_ObjIsNode(pObj) );
+ assert( Abc_ObjFaninNum(pObj) <= p->pPars->nLutSize );
+
+ // if the node is not in the MFFC, check the limit
if ( !Abc_NodeIsTravIdCurrent(pObj) )
{
if ( (int)pCut->nNodesMarked == p->pPars->nLutsOver )
@@ -344,8 +347,17 @@ void Abc_LutNodeCutsOne( Lut_Man_t * p, Lut_Cut_t * pCut, int Node )
assert( (int)pCut->nNodesMarked < p->pPars->nLutsOver );
}
- // create the new set of leaves
+ // initialize the set of leaves to the nodes in the cut
+ assert( p->nCuts < LUT_CUTS_MAX );
pCutNew = p->pCuts + p->nCuts;
+/*
+if ( p->pObj->Id == 31 && Node == 38 && pCut->pNodes[0] == 31 && pCut->pNodes[1] == 34 && pCut->pNodes[2] == 35 )//p->nCuts == 48 )
+{
+ int x = 0;
+ printf( "Start:\n" );
+ Abc_LutNodePrintCut( p, pCut );
+}
+*/
pCutNew->nLeaves = 0;
for ( i = 0; i < (int)pCut->nLeaves; i++ )
if ( pCut->pLeaves[i] != Node )
@@ -358,7 +370,7 @@ void Abc_LutNodeCutsOne( Lut_Man_t * p, Lut_Cut_t * pCut, int Node )
for ( k = 0; k < (int)pCutNew->nLeaves; k++ )
if ( pCutNew->pLeaves[k] >= pFanin->Id )
break;
- if ( pCutNew->pLeaves[k] == pFanin->Id )
+ if ( k < (int)pCutNew->nLeaves && pCutNew->pLeaves[k] == pFanin->Id )
continue;
// check if there is room
if ( (int)pCutNew->nLeaves == p->pPars->nVarsMax )
@@ -371,22 +383,34 @@ void Abc_LutNodeCutsOne( Lut_Man_t * p, Lut_Cut_t * pCut, int Node )
assert( pCutNew->nLeaves <= LUT_SIZE_MAX );
}
+ for ( k = 0; k < (int)pCutNew->nLeaves - 1; k++ )
+ assert( pCutNew->pLeaves[k] < pCutNew->pLeaves[k+1] );
+
// skip the contained cuts
if ( Abc_LutNodeCutsOneFilter( p->pCuts, p->nCuts, pCutNew ) )
return;
// update the set of internal nodes
assert( pCut->nNodes < LUT_SIZE_MAX );
- memcpy( pCutNew->pNodes, pCutNew->pNodes, pCut->nNodes * sizeof(int) );
- pCutNew->pNodes[ pCut->nNodes++ ] = Node;
+ memcpy( pCutNew->pNodes, pCut->pNodes, pCut->nNodes * sizeof(int) );
+ pCutNew->nNodes = pCut->nNodes;
+ pCutNew->pNodes[ pCutNew->nNodes++ ] = Node;
// add the marked node
pCutNew->nNodesMarked = pCut->nNodesMarked + !Abc_NodeIsTravIdCurrent(pObj);
-
+/*
+if ( p->pObj->Id == 31 && Node == 38 )//p->nCuts == 48 )
+{
+ int x = 0;
+ printf( "Finish:\n" );
+ Abc_LutNodePrintCut( p, pCutNew );
+}
+*/
// add the cut to storage
assert( p->nCuts < LUT_CUTS_MAX );
p->nCuts++;
+ assert( pCut->nNodes <= p->nMffc + pCutNew->nNodesMarked );
}
/**Function*************************************************************
@@ -407,13 +431,13 @@ int Abc_LutNodeCuts( Lut_Man_t * p )
int i, k, Temp, nMffc, fChanges;
// mark the MFFC of the node with the current trav ID
- nMffc = Abc_NodeMffcLabel( p->pObj );
+ nMffc = p->nMffc = Abc_NodeMffcLabel( p->pObj );
assert( nMffc > 0 );
if ( nMffc == 1 )
return 0;
// initialize the first cut
- pCut = p->pCuts;
+ pCut = p->pCuts; p->nCuts = 1;
// assign internal nodes
pCut->nNodes = 1;
pCut->pNodes[0] = p->pObj->Id;
@@ -439,10 +463,10 @@ int Abc_LutNodeCuts( Lut_Man_t * p )
// perform the cut computation
for ( i = 0; i < p->nCuts; i++ )
{
- pCut = p->pCuts + p->pEvals[i];
+ pCut = p->pCuts + i;
if ( pCut->nLeaves == 0 )
continue;
- // try to expand each fanin of each cut
+ // try to expand the fanins of this cut
for ( k = 0; k < (int)pCut->nLeaves; k++ )
{
Abc_LutNodeCutsOne( p, pCut, pCut->pLeaves[k] );
@@ -457,10 +481,14 @@ int Abc_LutNodeCuts( Lut_Man_t * p )
p->nEvals = 0;
for ( i = 0; i < p->nCuts; i++ )
{
- pCut = p->pCuts + p->pEvals[i];
+ pCut = p->pCuts + i;
+ if ( pCut->nLeaves == 0 )
+ continue;
pCut->Weight = (float)1.0 * (pCut->nNodes - pCut->nNodesMarked) / p->pPars->nLutsMax;
+ if ( pCut->Weight <= 1.0 )
+ continue;
pCut->fHasDsd = Abc_LutNodeCutsCheckDsd( p, pCut );
- if ( pCut->nLeaves == 0 || pCut->Weight <= 1.0 || pCut->fHasDsd )
+ if ( pCut->fHasDsd )
continue;
p->pEvals[p->nEvals++] = i;
}
@@ -496,9 +524,77 @@ int Abc_LutNodeCuts( Lut_Man_t * p )
SeeAlso []
***********************************************************************/
+unsigned * Abc_LutCutTruth_rec( Hop_Man_t * pMan, Hop_Obj_t * pObj, int nVars, Vec_Ptr_t * vTtNodes, int * iCount )
+{
+ unsigned * pTruth, * pTruth0, * pTruth1;
+ assert( !Hop_IsComplement(pObj) );
+ if ( pObj->pData )
+ {
+ assert( ((unsigned)pObj->pData) & 0xffff0000 );
+ return pObj->pData;
+ }
+ // get the plan for a new truth table
+ pTruth = Vec_PtrEntry( vTtNodes, (*iCount)++ );
+ if ( Hop_ObjIsConst1(pObj) )
+ Extra_TruthFill( pTruth, nVars );
+ else
+ {
+ assert( Hop_ObjIsAnd(pObj) );
+ // compute the truth tables of the fanins
+ pTruth0 = Abc_LutCutTruth_rec( pMan, Hop_ObjFanin0(pObj), nVars, vTtNodes, iCount );
+ pTruth1 = Abc_LutCutTruth_rec( pMan, Hop_ObjFanin1(pObj), nVars, vTtNodes, iCount );
+ // creat the truth table of the node
+ Extra_TruthAndPhase( pTruth, pTruth0, pTruth1, nVars, Hop_ObjFaninC0(pObj), Hop_ObjFaninC1(pObj) );
+ }
+ pObj->pData = pTruth;
+ return pTruth;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the truth able of one cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
unsigned * Abc_LutCutTruth( Lut_Man_t * p, Lut_Cut_t * pCut )
{
- unsigned * pTruth = NULL;
+ Hop_Man_t * pManHop = p->pNtk->pManFunc;
+ Hop_Obj_t * pObjHop;
+ Abc_Obj_t * pObj, * pFanin;
+ unsigned * pTruth;
+ int i, k, iCount = 0;
+// Abc_LutNodePrintCut( p, pCut );
+
+ // initialize the leaves
+ Abc_LutCutForEachLeaf( p->pNtk, pCut, pObj, i )
+ pObj->pCopy = Vec_PtrEntry( p->vTtElems, i );
+
+ // construct truth table in the topological order
+ Abc_LutCutForEachNodeReverse( p->pNtk, pCut, pObj, i )
+ {
+ // get the local AIG
+ pObjHop = Hop_Regular(pObj->pData);
+ // clean the data field of the nodes in the AIG subgraph
+ Hop_ObjCleanData_rec( pObjHop );
+ // set the initial truth tables at the fanins
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ {
+ assert( ((unsigned)pFanin->pCopy) & 0xffff0000 );
+ Hop_ManPi( pManHop, k )->pData = pFanin->pCopy;
+ }
+ // compute the truth table of internal nodes
+ pTruth = Abc_LutCutTruth_rec( pManHop, pObjHop, pCut->nLeaves, p->vTtNodes, &iCount );
+ if ( Hop_IsComplement(pObj->pData) )
+ Extra_TruthNot( pTruth, pTruth, pCut->nLeaves );
+ // set the truth table at the node
+ pObj->pCopy = (Abc_Obj_t *)pTruth;
+ }
+
return pTruth;
}
@@ -531,28 +627,121 @@ int Abc_LutCutUpdate( Lut_Man_t * p, Lut_Cut_t * pCut, void * pDsd )
***********************************************************************/
int Abc_LutResynthesizeNode( Lut_Man_t * p )
{
+ extern void Kit_DsdTest( unsigned * pTruth, int nVars );
+ extern int Kit_DsdEval( unsigned * pTruth, int nVars, int nLutSize );
+
Lut_Cut_t * pCut;
unsigned * pTruth;
- void * pDsd;
- int i;
+ void * pDsd = NULL;
+ int i, Result, GainBest, Gain;
+ int clk;
// compute the cuts
+clk = clock();
if ( !Abc_LutNodeCuts( p ) )
+ {
+p->timeCuts += clock() - clk;
return 0;
+ }
+p->timeCuts += clock() - clk;
+
+ if ( p->pPars->fVeryVerbose )
+ printf( "Node %5d : Mffc size = %5d. Cuts = %5d.\n", p->pObj->Id, p->nMffc, p->nEvals );
// try the good cuts
+ p->nCutsTotal += p->nEvals;
+ GainBest = 0;
for ( i = 0; i < p->nEvals; i++ )
{
// get the cut
pCut = p->pCuts + p->pEvals[i];
// compute the truth table
+clk = clock();
pTruth = Abc_LutCutTruth( p, pCut );
- // check decomposition
- pDsd = /***/ NULL;
+p->timeTruth += clock() - clk;
+ // evaluate the result of decomposition
+clk = clock();
+// Kit_DsdTest( pTruth, pCut->nLeaves );
+ Result = Kit_DsdEval( pTruth, pCut->nLeaves, 3 );
+p->timeEval += clock() - clk;
+
+ // calculate the gain
+ Gain = Result < 0 ? 0 : pCut->nNodes - pCut->nNodesMarked - Result;
+ if ( GainBest < Gain )
+ GainBest = Gain;
+
+ if ( p->pPars->fVeryVerbose )
+ {
+ printf( " Cut %2d : Lvs = %2d. Supp = %2d. Vol = %2d. Q = %d. Weight = %4.2f. New = %2d. Gain = %2d.\n",
+ i, pCut->nLeaves, Extra_TruthSupportSize(pTruth, pCut->nLeaves), pCut->nNodes, pCut->nNodesMarked, pCut->Weight, Result, Gain );
+// for ( k = 0; k < pCut->nNodes; k++ )
+// printf( "%d(%d) ", pCut->pNodes[k], Abc_NodeIsTravIdCurrent( Abc_NtkObj(p->pNtk, pCut->pNodes[k]) ) );
+// printf( "\n" );
+ }
+// pTruth = NULL;
+//Extra_PrintHexadecimal( stdout, pTruth, pCut->nLeaves ); printf( "\n" );
+
// if it is not DSD decomposable, return
if ( pDsd == NULL )
continue;
// update the network
Abc_LutCutUpdate( p, pCut, pDsd );
}
+ p->nGainTotal += GainBest;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs resynthesis for one network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_LutResynthesize( Abc_Ntk_t * pNtk, Lut_Par_t * pPars )
+{
+ Lut_Man_t * p;
+ Abc_Obj_t * pObj;
+ int i, clk = clock();
+ assert( Abc_NtkIsLogic(pNtk) );
+ // convert logic to AIGs
+ Abc_NtkToAig( pNtk );
+ // compute the levels
+ Abc_NtkLevel( pNtk );
+ // get the number of inputs
+ pPars->nLutSize = Abc_NtkGetFaninMax( pNtk );
+ pPars->nVarsMax = pPars->nLutsMax * (pPars->nLutSize - 1) + 1; // V = N * (K-1) + 1
+ printf( "Resynthesis for %d %d-LUTs with %d non-MFFC LUTs, %d crossbars, and %d-input cuts.\n",
+ pPars->nLutsMax, pPars->nLutSize, pPars->nLutsOver, pPars->nVarsShared, pPars->nVarsMax );
+ // start the manager
+ p = Abc_LutManStart( pPars );
+ p->pNtk = pNtk;
+ // consider all nodes
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ {
+ p->pObj = pObj;
+ Abc_LutResynthesizeNode( p );
+ }
+ printf( "Total nodes = %5d. Total cuts = %5d. Total gain = %5d. (%5.2f %%)\n",
+ Abc_NtkNodeNum(pNtk), p->nCutsTotal, p->nGainTotal, 100.0 * p->nGainTotal / Abc_NtkNodeNum(pNtk) );
+
+ p->timeTotal = clock() - clk;
+ p->timeOther = p->timeTotal - p->timeCuts - p->timeTruth - p->timeEval;
+ PRTP( "Cuts ", p->timeCuts, p->timeTotal );
+ PRTP( "Truth ", p->timeTruth, p->timeTotal );
+ PRTP( "Eval ", p->timeEval, p->timeTotal );
+ PRTP( "Other ", p->timeOther, p->timeTotal );
+ PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+
+ Abc_LutManStop( p );
+ // check the resulting network
+ if ( !Abc_NtkCheck( pNtk ) )
+ {
+ printf( "Abc_LutResynthesize: The network check has failed.\n" );
+ return 0;
+ }
return 1;
}
diff --git a/src/base/abci/abcReconv.c b/src/base/abci/abcReconv.c
index a81e94ad..e77f055a 100644
--- a/src/base/abci/abcReconv.c
+++ b/src/base/abci/abcReconv.c
@@ -712,7 +712,7 @@ Vec_Ptr_t * Abc_NodeCollectTfoCands( Abc_ManCut_t * p, Abc_Obj_t * pRoot, Vec_Pt
// mark MFFC
if ( pRoot )
- Abc_NodeMffcLabel( pRoot );
+ Abc_NodeMffcLabelAig( pRoot );
// go through the levels up
Vec_PtrClear( p->vNodesTfo );
diff --git a/src/base/abci/abcRefactor.c b/src/base/abci/abcRefactor.c
index 834e33aa..872ffaf0 100644
--- a/src/base/abci/abcRefactor.c
+++ b/src/base/abci/abcRefactor.c
@@ -248,7 +248,7 @@ p->timeFact += clock() - clk;
pFanin->vFanouts.nSize++;
// label MFFC with current traversal ID
Abc_NtkIncrementTravId( pNode->pNtk );
- nNodesSaved = Abc_NodeMffcLabel( pNode );
+ nNodesSaved = Abc_NodeMffcLabelAig( pNode );
// unmark the fanin boundary and set the fanins as leaves in the form
Vec_PtrForEachEntry( vFanins, pFanin, i )
{
diff --git a/src/base/abci/abcRestruct.c b/src/base/abci/abcRestruct.c
index 2d4f50fb..b9ffd932 100644
--- a/src/base/abci/abcRestruct.c
+++ b/src/base/abci/abcRestruct.c
@@ -391,7 +391,7 @@ p->timeDsd += clock() - clk;
pLeaf->vFanouts.nSize++;
// label MFFC with current traversal ID
Abc_NtkIncrementTravId( pRoot->pNtk );
- nNodesSaved = Abc_NodeMffcLabel( pRoot );
+ nNodesSaved = Abc_NodeMffcLabelAig( pRoot );
// unmark the fanin boundary and set the fanins as leaves in the form
Vec_PtrForEachEntry( p->vLeaves, pLeaf, i )
pLeaf->vFanouts.nSize--;