Commit 6f17c44e by Alan Mishchenko

Integrating barrier buffers into the mapper.

parent f6eb5262
......@@ -610,6 +610,7 @@ extern ABC_DLL int Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_NtkSupport( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
extern ABC_DLL Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll, int fCollectCos );
extern ABC_DLL Vec_Ptr_t * Abc_AigDfsMap( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, int fTfi );
extern ABC_DLL Vec_Vec_t * Abc_NtkLevelize( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkLevel( Abc_Ntk_t * pNtk );
......
......@@ -311,6 +311,70 @@ Abc_Ntk_t * Abc_NtkFromBarBufs( Abc_Ntk_t * pNtkBase, Abc_Ntk_t * pNtk )
return pNtkNew;
}
/**Function*************************************************************
Synopsis [Collect nodes in the barbuf-friendly order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkToBarBufsCollect_rec( Abc_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
Abc_Obj_t * pFanin;
int i;
if ( Abc_NodeIsTravIdCurrent( pObj ) )
return;
Abc_NodeSetTravIdCurrent( pObj );
assert( Abc_ObjIsNode(pObj) );
Abc_ObjForEachFanin( pObj, pFanin, i )
Abc_NtkToBarBufsCollect_rec( pFanin, vNodes );
Vec_PtrPush( vNodes, pObj );
}
Vec_Ptr_t * Abc_NtkToBarBufsCollect( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vNodes;
Abc_Obj_t * pObj;
int i;
assert( Abc_NtkIsLogic(pNtk) );
assert( pNtk->nBarBufs > 0 );
assert( pNtk->nBarBufs == Abc_NtkLatchNum(pNtk) );
vNodes = Vec_PtrAlloc( Abc_NtkObjNum(pNtk) );
Abc_NtkIncrementTravId( pNtk );
Abc_NtkForEachCi( pNtk, pObj, i )
{
if ( i >= Abc_NtkCiNum(pNtk) - pNtk->nBarBufs )
break;
Vec_PtrPush( vNodes, pObj );
Abc_NodeSetTravIdCurrent( pObj );
}
Abc_NtkForEachCo( pNtk, pObj, i )
{
if ( i < Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
continue;
Abc_NtkToBarBufsCollect_rec( Abc_ObjFanin0(pObj), vNodes );
Vec_PtrPush( vNodes, pObj );
Vec_PtrPush( vNodes, Abc_ObjFanout0(pObj) );
Vec_PtrPush( vNodes, Abc_ObjFanout0(Abc_ObjFanout0(pObj)) );
Abc_NodeSetTravIdCurrent( pObj );
Abc_NodeSetTravIdCurrent( Abc_ObjFanout0(pObj) );
Abc_NodeSetTravIdCurrent( Abc_ObjFanout0(Abc_ObjFanout0(pObj)) );
}
Abc_NtkForEachCo( pNtk, pObj, i )
{
if ( i >= Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
break;
Abc_NtkToBarBufsCollect_rec( Abc_ObjFanin0(pObj), vNodes );
Vec_PtrPush( vNodes, pObj );
Abc_NodeSetTravIdCurrent( pObj );
}
assert( Vec_PtrSize(vNodes) == Abc_NtkObjNum(pNtk) );
return vNodes;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -946,6 +946,50 @@ Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll, int fCollectCos )
return vNodes;
}
/**Function*************************************************************
Synopsis [Returns the DFS ordered array of logic nodes.]
Description [Collects only the internal nodes, leaving out CIs/COs.
However it marks both CIs and COs with the current TravId.]
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Abc_AigDfsMap( Abc_Ntk_t * pNtk )
{
Vec_Ptr_t * vNodes;
Abc_Obj_t * pNode;
int i;
assert( Abc_NtkIsStrash(pNtk) );
// set the traversal ID
Abc_NtkIncrementTravId( pNtk );
// start the array of nodes
vNodes = Vec_PtrAlloc( 100 );
// collect cones of barbufs
Abc_NtkForEachCo( pNtk, pNode, i )
{
if ( i < Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
continue;
Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
Abc_NodeSetTravIdCurrent( pNode );
// collect latch as a placeholder
assert( Abc_ObjIsLatch(Abc_ObjFanout0(pNode)) );
Vec_PtrPush( vNodes, Abc_ObjFanout0(pNode) );
}
// collect nodes of real POs
Abc_NtkForEachCo( pNtk, pNode, i )
{
if ( i >= Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
break;
Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
assert( Abc_ObjIsPo(pNode) );
Abc_NodeSetTravIdCurrent( pNode );
}
return vNodes;
}
/**Function*************************************************************
......
......@@ -82,8 +82,11 @@ extern void Map_ManPrintTimeStats( Map_Man_t * p );
extern void Map_ManPrintStatsToFile( char * pName, float Area, float Delay, abctime Time );
extern int Map_ManReadInputNum( Map_Man_t * p );
extern int Map_ManReadOutputNum( Map_Man_t * p );
extern int Map_ManReadBufNum( Map_Man_t * p );
extern Map_Node_t ** Map_ManReadInputs ( Map_Man_t * p );
extern Map_Node_t ** Map_ManReadOutputs( Map_Man_t * p );
extern Map_Node_t ** Map_ManReadBufs( Map_Man_t * p );
extern Map_Node_t * Map_ManReadBufDriver( Map_Man_t * p, int i );
extern Map_Node_t * Map_ManReadConst1 ( Map_Man_t * p );
extern Map_Time_t * Map_ManReadInputArrivals( Map_Man_t * p );
extern Mio_Library_t * Map_ManReadGenLib ( Map_Man_t * p );
......@@ -121,6 +124,7 @@ extern void Map_NodeSetSwitching( Map_Node_t * p, float Switching );
extern int Map_NodeIsConst( Map_Node_t * p );
extern int Map_NodeIsVar( Map_Node_t * p );
extern int Map_NodeIsBuf( Map_Node_t * p );
extern int Map_NodeIsAnd( Map_Node_t * p );
extern int Map_NodeComparePhase( Map_Node_t * p1, Map_Node_t * p2 );
......@@ -150,9 +154,7 @@ extern Map_Time_t Map_SuperLibReadDelayInv( Map_SuperLib_t * p );
extern int Map_SuperLibReadVarsMax( Map_SuperLib_t * p );
extern Map_Node_t * Map_NodeAnd( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 );
extern Map_Node_t * Map_NodeOr( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 );
extern Map_Node_t * Map_NodeExor( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 );
extern Map_Node_t * Map_NodeMux( Map_Man_t * p, Map_Node_t * pNode, Map_Node_t * pNodeT, Map_Node_t * pNodeE );
extern Map_Node_t * Map_NodeBuf( Map_Man_t * p, Map_Node_t * p1 );
extern void Map_NodeSetChoice( Map_Man_t * pMan, Map_Node_t * pNodeOld, Map_Node_t * pNodeNew );
/*=== resmCanon.c =============================================================*/
......
......@@ -57,8 +57,6 @@ int Map_Mapping( Map_Man_t * p )
//////////////////////////////////////////////////////////////////////
// perform pre-mapping computations
// collect the nodes reachable from POs in the DFS order (including the choices)
p->vAnds = Map_MappingDfs( p, 1 );
if ( p->fVerbose )
Map_MappingReportChoices( p );
Map_MappingSetChoiceLevels( p ); // should always be called before mapping!
......@@ -84,12 +82,12 @@ int Map_Mapping( Map_Man_t * p )
p->timeMatch = Abc_Clock() - clk;
// compute the references and collect the nodes used in the mapping
Map_MappingSetRefs( p );
p->AreaBase = Map_MappingGetArea( p, p->vMapping );
p->AreaBase = Map_MappingGetArea( p );
if ( p->fVerbose )
{
printf( "Delay : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
fShowSwitching? "Switch" : "Delay",
fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo,
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 );
ABC_PRT( "Time", p->timeMatch );
}
......@@ -114,12 +112,12 @@ ABC_PRT( "Time", p->timeMatch );
Map_MappingMatches( p );
// compute the references and collect the nodes used in the mapping
Map_MappingSetRefs( p );
p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
p->AreaFinal = Map_MappingGetArea( p );
if ( p->fVerbose )
{
printf( "AreaFlow : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
fShowSwitching? "Switch" : "Delay",
fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo,
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
Map_MappingGetAreaFlow(p), p->AreaFinal,
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
ABC_PRT( "Time", Abc_Clock() - clk );
......@@ -140,12 +138,12 @@ ABC_PRT( "Time", Abc_Clock() - clk );
Map_MappingMatches( p );
// compute the references and collect the nodes used in the mapping
Map_MappingSetRefs( p );
p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
p->AreaFinal = Map_MappingGetArea( p );
if ( p->fVerbose )
{
printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
fShowSwitching? "Switch" : "Delay",
fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo,
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
0.0, p->AreaFinal,
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
ABC_PRT( "Time", Abc_Clock() - clk );
......@@ -166,12 +164,12 @@ ABC_PRT( "Time", Abc_Clock() - clk );
Map_MappingMatches( p );
// compute the references and collect the nodes used in the mapping
Map_MappingSetRefs( p );
p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
p->AreaFinal = Map_MappingGetArea( p );
if ( p->fVerbose )
{
printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
fShowSwitching? "Switch" : "Delay",
fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo,
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
0.0, p->AreaFinal,
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
ABC_PRT( "Time", Abc_Clock() - clk );
......@@ -192,12 +190,12 @@ ABC_PRT( "Time", Abc_Clock() - clk );
Map_MappingMatches( p );
// compute the references and collect the nodes used in the mapping
Map_MappingSetRefs( p );
p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
p->AreaFinal = Map_MappingGetArea( p );
if ( p->fVerbose )
{
printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
fShowSwitching? "Switch" : "Delay",
fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo,
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
0.0, p->AreaFinal,
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
ABC_PRT( "Time", Abc_Clock() - clk );
......@@ -210,12 +208,12 @@ ABC_PRT( "Time", Abc_Clock() - clk );
Map_MappingMatches( p );
// compute the references and collect the nodes used in the mapping
Map_MappingSetRefs( p );
p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
p->AreaFinal = Map_MappingGetArea( p );
if ( p->fVerbose )
{
printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
fShowSwitching? "Switch" : "Delay",
fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo,
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
0.0, p->AreaFinal,
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
ABC_PRT( "Time", Abc_Clock() - clk );
......
......@@ -27,7 +27,6 @@ ABC_NAMESPACE_IMPL_START
static void Map_TableCreate( Map_Man_t * p );
static void Map_TableResize( Map_Man_t * p );
static Map_Node_t * Map_TableLookup( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 );
// hash key for the structural hash table
static inline unsigned Map_HashKey2( Map_Node_t * p0, Map_Node_t * p1, int TableSize ) { return (unsigned)(((ABC_PTRUINT_T)(p0) + (ABC_PTRUINT_T)(p1) * 12582917) % TableSize); }
......@@ -49,8 +48,11 @@ static inline unsigned Map_HashKey2( Map_Node_t * p0, Map_Node_t * p1, int Table
***********************************************************************/
int Map_ManReadInputNum( Map_Man_t * p ) { return p->nInputs; }
int Map_ManReadOutputNum( Map_Man_t * p ) { return p->nOutputs; }
int Map_ManReadBufNum( Map_Man_t * p ) { return Map_NodeVecReadSize(p->vMapBufs); }
Map_Node_t ** Map_ManReadInputs ( Map_Man_t * p ) { return p->pInputs; }
Map_Node_t ** Map_ManReadOutputs( Map_Man_t * p ) { return p->pOutputs; }
Map_Node_t ** Map_ManReadBufs( Map_Man_t * p ) { return Map_NodeVecReadArray(p->vMapBufs); }
Map_Node_t * Map_ManReadBufDriver( Map_Man_t * p, int i ) { return Map_ManReadBufs(p)[i]->p1; }
Map_Node_t * Map_ManReadConst1 ( Map_Man_t * p ) { return p->pConst1; }
Map_Time_t * Map_ManReadInputArrivals( Map_Man_t * p ) { return p->pInputArrivals; }
Map_Time_t * Map_ManReadOutputRequireds( Map_Man_t * p ) { return p->pOutputRequireds; }
......@@ -109,7 +111,8 @@ void Map_NodeSetSwitching( Map_Node_t * p, float Switching ) { p-
***********************************************************************/
int Map_NodeIsConst( Map_Node_t * p ) { return (Map_Regular(p))->Num == -1; }
int Map_NodeIsVar( Map_Node_t * p ) { return (Map_Regular(p))->p1 == NULL && (Map_Regular(p))->Num >= 0; }
int Map_NodeIsAnd( Map_Node_t * p ) { return (Map_Regular(p))->p1 != NULL; }
int Map_NodeIsBuf( Map_Node_t * p ) { return (Map_Regular(p))->p1 != NULL && (Map_Regular(p))->p2 == NULL; }
int Map_NodeIsAnd( Map_Node_t * p ) { return (Map_Regular(p))->p1 != NULL && (Map_Regular(p))->p2 != NULL; }
int Map_NodeComparePhase( Map_Node_t * p1, Map_Node_t * p2 ) { assert( !Map_IsComplement(p1) ); assert( !Map_IsComplement(p2) ); return p1->fInv ^ p2->fInv; }
/**Function*************************************************************
......@@ -214,9 +217,8 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose )
p->nNodes = -1;
// create the constant node
p->pConst1 = Map_NodeCreate( p, NULL, NULL );
p->vNodesAll = Map_NodeVecAlloc( 100 );
p->vNodesTemp = Map_NodeVecAlloc( 100 );
p->vMapping = Map_NodeVecAlloc( 100 );
p->vMapObjs = Map_NodeVecAlloc( 100 );
p->vMapBufs = Map_NodeVecAlloc( 100 );
p->vVisited = Map_NodeVecAlloc( 100 );
// create the PI nodes
......@@ -246,19 +248,12 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose )
void Map_ManFree( Map_Man_t * p )
{
// int i;
// for ( i = 0; i < p->vNodesAll->nSize; i++ )
// Map_NodeVecFree( p->vNodesAll->pArray[i]->vFanouts );
// for ( i = 0; i < p->vMapObjs->nSize; i++ )
// Map_NodeVecFree( p->vMapObjs->pArray[i]->vFanouts );
// Map_NodeVecFree( p->pConst1->vFanouts );
if ( p->vAnds )
Map_NodeVecFree( p->vAnds );
if ( p->vNodesAll )
Map_NodeVecFree( p->vNodesAll );
if ( p->vNodesTemp )
Map_NodeVecFree( p->vNodesTemp );
if ( p->vMapping )
Map_NodeVecFree( p->vMapping );
if ( p->vVisited )
Map_NodeVecFree( p->vVisited );
Map_NodeVecFree( p->vMapObjs );
Map_NodeVecFree( p->vMapBufs );
Map_NodeVecFree( p->vVisited );
if ( p->uCanons ) ABC_FREE( p->uCanons );
if ( p->uPhases ) ABC_FREE( p->uPhases );
if ( p->pCounters ) ABC_FREE( p->pCounters );
......@@ -291,10 +286,10 @@ void Map_ManCreateNodeDelays( Map_Man_t * p, int LogFan )
Map_Node_t * pNode;
int k;
assert( p->pNodeDelays == NULL );
p->pNodeDelays = ABC_CALLOC( float, p->vNodesAll->nSize );
for ( k = 0; k < p->vNodesAll->nSize; k++ )
p->pNodeDelays = ABC_CALLOC( float, p->vMapObjs->nSize );
for ( k = 0; k < p->vMapObjs->nSize; k++ )
{
pNode = p->vNodesAll->pArray[k];
pNode = p->vMapObjs->pArray[k];
if ( pNode->nRefs == 0 )
continue;
p->pNodeDelays[k] = 0.014426 * LogFan * p->pSuperLib->tDelayInv.Worst * log( (double)pNode->nRefs ); // 1.4426 = 1/ln(2)
......@@ -383,7 +378,7 @@ Map_Node_t * Map_NodeCreate( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 )
// pNode->vFanouts = Map_NodeVecAlloc( 5 );
// store this node in the internal array
if ( pNode->Num >= 0 )
Map_NodeVecPush( p->vNodesAll, pNode );
Map_NodeVecPush( p->vMapObjs, pNode );
else
pNode->fInv = 1;
// set the level of this node
......@@ -392,10 +387,20 @@ Map_Node_t * Map_NodeCreate( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 )
#ifdef MAP_ALLOCATE_FANOUT
// create the fanout info
Map_NodeAddFaninFanout( Map_Regular(p1), pNode );
if ( p2 )
Map_NodeAddFaninFanout( Map_Regular(p2), pNode );
#endif
pNode->Level = 1 + MAP_MAX(Map_Regular(pNode->p1)->Level, Map_Regular(pNode->p2)->Level);
pNode->fInv = Map_NodeIsSimComplement(p1) & Map_NodeIsSimComplement(p2);
if ( p2 )
{
pNode->Level = 1 + MAP_MAX(Map_Regular(pNode->p1)->Level, Map_Regular(pNode->p2)->Level);
pNode->fInv = Map_NodeIsSimComplement(p1) & Map_NodeIsSimComplement(p2);
}
else
{
pNode->Level = Map_Regular(pNode->p1)->Level;
pNode->fInv = Map_NodeIsSimComplement(p1);
}
}
// reference the inputs (will be used to compute the number of fanouts)
if ( p1 ) Map_NodeRef(p1);
......@@ -439,7 +444,7 @@ void Map_TableCreate( Map_Man_t * pMan )
SeeAlso []
***********************************************************************/
Map_Node_t * Map_TableLookup( Map_Man_t * pMan, Map_Node_t * p1, Map_Node_t * p2 )
Map_Node_t * Map_NodeAnd( Map_Man_t * pMan, Map_Node_t * p1, Map_Node_t * p2 )
{
Map_Node_t * pEnt;
unsigned Key;
......@@ -544,70 +549,15 @@ clk = Abc_Clock();
SeeAlso []
***********************************************************************/
Map_Node_t * Map_NodeAnd( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 )
{
Map_Node_t * pNode;
pNode = Map_TableLookup( p, p1, p2 );
return pNode;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Map_Node_t * Map_NodeOr( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 )
Map_Node_t * Map_NodeBuf( Map_Man_t * p, Map_Node_t * p1 )
{
Map_Node_t * pNode;
pNode = Map_Not( Map_TableLookup( p, Map_Not(p1), Map_Not(p2) ) );
Map_Node_t * pNode = Map_NodeCreate( p, p1, NULL );
Map_NodeVecPush( p->vMapBufs, pNode );
return pNode;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Map_Node_t * Map_NodeExor( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 )
{
return Map_NodeMux( p, p1, Map_Not(p2), p2 );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Map_Node_t * Map_NodeMux( Map_Man_t * p, Map_Node_t * pC, Map_Node_t * pT, Map_Node_t * pE )
{
Map_Node_t * pAnd1, * pAnd2, * pRes;
pAnd1 = Map_TableLookup( p, pC, pT );
pAnd2 = Map_TableLookup( p, Map_Not(pC), pE );
pRes = Map_NodeOr( p, pAnd1, pAnd2 );
return pRes;
}
/**Function*************************************************************
Synopsis [Sets the node to be equivalent to the given one.]
Description [This procedure is a work-around for the equivalence check.
......
......@@ -88,6 +88,51 @@ static unsigned Map_CutComputeTruth( Map_Man_t * p, Map_Cut_t * pCut, Ma
/**Function*************************************************************
Synopsis [Counts all the cuts.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Map_MappingCountAllCuts( Map_Man_t * pMan )
{
Map_Node_t * pNode;
Map_Cut_t * pCut;
int i, nCuts;
// int nCuts55 = 0, nCuts5x = 0, nCuts4x = 0, nCuts3x = 0;
// int pCounts[7] = {0};
nCuts = 0;
for ( i = 0; i < pMan->nBins; i++ )
for ( pNode = pMan->pBins[i]; pNode; pNode = pNode->pNext )
for ( pCut = pNode->pCuts; pCut; pCut = pCut->pNext )
if ( pCut->nLeaves > 1 ) // skip the elementary cuts
{
nCuts++;
/*
if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 && Map_CutRegular(pCut->pTwo)->nLeaves == 5 )
nCuts55++;
if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 || Map_CutRegular(pCut->pTwo)->nLeaves == 5 )
nCuts5x++;
else if ( Map_CutRegular(pCut->pOne)->nLeaves == 4 || Map_CutRegular(pCut->pTwo)->nLeaves == 4 )
nCuts4x++;
else if ( Map_CutRegular(pCut->pOne)->nLeaves == 3 || Map_CutRegular(pCut->pTwo)->nLeaves == 3 )
nCuts3x++;
*/
// pCounts[ Map_CutRegular(pCut->pOne)->nLeaves ]++;
// pCounts[ Map_CutRegular(pCut->pTwo)->nLeaves ]++;
}
// printf( "Total cuts = %6d. 55 = %6d. 5x = %6d. 4x = %6d. 3x = %6d.\n", nCuts, nCuts55, nCuts5x, nCuts4x, nCuts3x );
// printf( "Total cuts = %6d. 6= %6d. 5= %6d. 4= %6d. 3= %6d. 2= %6d. 1= %6d.\n",
// nCuts, pCounts[6], pCounts[5], pCounts[4], pCounts[3], pCounts[2], pCounts[1] );
return nCuts;
}
/**Function*************************************************************
Synopsis [Computes the cuts for each node in the object graph.]
Description [The cuts are computed in one sweep over the mapping graph.
......@@ -110,39 +155,44 @@ static unsigned Map_CutComputeTruth( Map_Man_t * p, Map_Cut_t * pCut, Ma
SeeAlso []
***********************************************************************/
void Map_MappingCutsInput( Map_Man_t * p, Map_Node_t * pNode )
{
Map_Cut_t * pCut;
assert( Map_NodeIsVar(pNode) || Map_NodeIsBuf(pNode) );
pCut = Map_CutAlloc( p );
pCut->nLeaves = 1;
pCut->ppLeaves[0] = pNode;
pNode->pCuts = pCut;
pNode->pCutBest[0] = NULL; // negative polarity is not mapped
pNode->pCutBest[1] = pCut; // positive polarity is a trivial cut
pCut->uTruth = 0xAAAAAAAA; // the first variable "1010"
pCut->M[0].AreaFlow = 0.0;
pCut->M[1].AreaFlow = 0.0;
}
void Map_MappingCuts( Map_Man_t * p )
{
ProgressBar * pProgress;
Map_CutTable_t * pTable;
Map_Node_t * pNode;
Map_Cut_t * pCut;
int nCuts, nNodes, i;
abctime clk = Abc_Clock();
// set the elementary cuts for the PI variables
assert( p->nVarsMax > 1 && p->nVarsMax < 7 );
for ( i = 0; i < p->nInputs; i++ )
{
pCut = Map_CutAlloc( p );
pCut->nLeaves = 1;
pCut->ppLeaves[0] = p->pInputs[i];
p->pInputs[i]->pCuts = pCut;
p->pInputs[i]->pCutBest[0] = NULL; // negative polarity is not mapped
p->pInputs[i]->pCutBest[1] = pCut; // positive polarity is a trivial cut
pCut->uTruth = 0xAAAAAAAA; // the first variable "10101010"
pCut->M[0].AreaFlow = 0.0;
pCut->M[1].AreaFlow = 0.0;
}
Map_MappingCutsInput( p, p->pInputs[i] );
// compute the cuts for the internal nodes
nNodes = p->vAnds->nSize;
nNodes = p->vMapObjs->nSize;
pProgress = Extra_ProgressBarStart( stdout, nNodes );
pTable = Map_CutTableStart( p );
for ( i = 0; i < nNodes; i++ )
{
pNode = p->vAnds->pArray[i];
if ( !Map_NodeIsAnd( pNode ) )
continue;
Map_CutCompute( p, pTable, pNode );
pNode = p->vMapObjs->pArray[i];
if ( Map_NodeIsBuf(pNode) )
Map_MappingCutsInput( p, pNode );
else if ( Map_NodeIsAnd(pNode) )
Map_CutCompute( p, pTable, pNode );
else continue;
Extra_ProgressBarUpdate( pProgress, i, "Cuts ..." );
}
Extra_ProgressBarStop( pProgress );
......@@ -679,51 +729,6 @@ int Map_CutBelongsToList( Map_Cut_t * pList, Map_Node_t * ppNodes[], int nNodes
return 0;
}
/**Function*************************************************************
Synopsis [Counts all the cuts.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Map_MappingCountAllCuts( Map_Man_t * pMan )
{
Map_Node_t * pNode;
Map_Cut_t * pCut;
int i, nCuts;
// int nCuts55 = 0, nCuts5x = 0, nCuts4x = 0, nCuts3x = 0;
// int pCounts[7] = {0};
nCuts = 0;
for ( i = 0; i < pMan->nBins; i++ )
for ( pNode = pMan->pBins[i]; pNode; pNode = pNode->pNext )
for ( pCut = pNode->pCuts; pCut; pCut = pCut->pNext )
if ( pCut->nLeaves > 1 ) // skip the elementary cuts
{
nCuts++;
/*
if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 && Map_CutRegular(pCut->pTwo)->nLeaves == 5 )
nCuts55++;
if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 || Map_CutRegular(pCut->pTwo)->nLeaves == 5 )
nCuts5x++;
else if ( Map_CutRegular(pCut->pOne)->nLeaves == 4 || Map_CutRegular(pCut->pTwo)->nLeaves == 4 )
nCuts4x++;
else if ( Map_CutRegular(pCut->pOne)->nLeaves == 3 || Map_CutRegular(pCut->pTwo)->nLeaves == 3 )
nCuts3x++;
*/
// pCounts[ Map_CutRegular(pCut->pOne)->nLeaves ]++;
// pCounts[ Map_CutRegular(pCut->pTwo)->nLeaves ]++;
}
// printf( "Total cuts = %6d. 55 = %6d. 5x = %6d. 4x = %6d. 3x = %6d.\n", nCuts, nCuts55, nCuts5x, nCuts4x, nCuts3x );
// printf( "Total cuts = %6d. 6= %6d. 5= %6d. 4= %6d. 3= %6d. 2= %6d. 1= %6d.\n",
// nCuts, pCounts[6], pCounts[5], pCounts[4], pCounts[3], pCounts[2], pCounts[1] );
return nCuts;
}
/**Function*************************************************************
......
......@@ -98,10 +98,8 @@ struct Map_ManStruct_t_
int nOutputs; // the number of outputs
int nNodes; // the total number of nodes
Map_Node_t * pConst1; // the constant 1 node
Map_NodeVec_t * vAnds; // the array of nodes in the DFS order
Map_NodeVec_t * vNodesAll; // the array of all nodes
Map_NodeVec_t * vNodesTemp; // the array of all nodes
Map_NodeVec_t * vMapping; // the array of internal nodes used in the mapping
Map_NodeVec_t * vMapObjs; // the array of all nodes
Map_NodeVec_t * vMapBufs; // the array of all nodes
float * pNodeDelays; // the array of node delays
// info about the original circuit
......@@ -358,10 +356,6 @@ struct Map_HashEntryStruct_t_
/*=== mapperCanon.c =============================================================*/
/*=== mapperCut.c ===============================================================*/
extern void Map_MappingCuts( Map_Man_t * p );
extern int Map_MappingCountAllCuts( Map_Man_t * p );
/*=== mapperCutDcs.c ===============================================================*/
extern void Map_ComputeDcs( Map_Man_t * p );
extern unsigned Map_ComputeIsop_rec( Map_Man_t * p, unsigned uF, unsigned uFD, int iVar, int nVars, int fDir );
/*=== mapperCutUtils.c ===============================================================*/
extern Map_Cut_t * Map_CutAlloc( Map_Man_t * p );
extern void Map_CutFree( Map_Man_t * p, Map_Cut_t * pCut );
......@@ -383,17 +377,7 @@ extern Map_SuperLib_t * Map_SuperLibCreate( Mio_Library_t * pGenlib, Vec_Str_t
extern void Map_SuperLibFree( Map_SuperLib_t * p );
/*=== mapperMatch.c ===============================================================*/
extern int Map_MappingMatches( Map_Man_t * p );
extern float Map_MappingCombinePhases( Map_Man_t * p );
extern void Map_MatchClean( Map_Match_t * pMatch );
extern int Map_MatchCompare( Map_Man_t * pMan, Map_Match_t * pM1, Map_Match_t * pM2, int fDoingArea );
/*=== mapperPower.c =============================================================*/
extern float Map_SwitchCutGetDerefed( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_SwitchCutRef( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_SwitchCutDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_MappingGetSwitching( Map_Man_t * pMan, Map_NodeVec_t * vMapping );
/*=== mapperRefs.c =============================================================*/
extern int Map_NodeReadRefPhaseAct( Map_Node_t * pNode, int fPhase );
extern float Map_NodeReadRefPhaseEst( Map_Node_t * pNode, int fPhase );
extern void Map_MappingEstimateRefsInit( Map_Man_t * p );
extern void Map_MappingEstimateRefs( Map_Man_t * p );
extern float Map_CutGetAreaFlow( Map_Cut_t * pCut, int fPhase );
......@@ -402,9 +386,12 @@ extern float Map_CutGetAreaDerefed( Map_Cut_t * pCut, int fPhase );
extern float Map_CutRef( Map_Cut_t * pCut, int fPhase );
extern float Map_CutDeref( Map_Cut_t * pCut, int fPhase );
extern void Map_MappingSetRefs( Map_Man_t * pMan );
extern float Map_MappingGetArea( Map_Man_t * pMan, Map_NodeVec_t * vMapping );
/*=== mapperShow.c =============================================================*/
extern void Map_MappingShow( Map_Man_t * pMan, char * pFileName );
extern float Map_MappingGetArea( Map_Man_t * pMan );
/*=== mapperSwitch.c =============================================================*/
extern float Map_SwitchCutGetDerefed( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_SwitchCutRef( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_SwitchCutDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_MappingGetSwitching( Map_Man_t * pMan );
/*=== mapperTree.c ===============================================================*/
extern int Map_LibraryDeriveGateInfo( Map_SuperLib_t * pLib, st__table * tExcludeGate );
extern int Map_LibraryReadFileTreeStr( Map_SuperLib_t * pLib, Mio_Library_t * pGenlib, Vec_Str_t * vStr, char * pFileName );
......@@ -423,13 +410,8 @@ extern void Map_SuperTableSortSupergates( Map_HashTable_t * p, int
extern void Map_SuperTableSortSupergatesByDelay( Map_HashTable_t * p, int nSupersMax );
/*=== mapperTime.c =============================================================*/
extern float Map_TimeCutComputeArrival( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, float tWorstCaseLimit );
extern void Map_TimeCutComputeArrival_rec( Map_Cut_t * pCut, int fPhase );
extern float Map_TimeComputeArrivalMax( Map_Man_t * p );
extern void Map_TimeComputeRequiredGlobal( Map_Man_t * p );
extern void Map_TimeComputeRequired( Map_Man_t * p, float fRequired );
extern float Map_TimeNodeFanoutDelay( Map_Node_t * pNode, int fPhase );
extern float Map_TimeCutFanoutDelay( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase );
extern float Map_TimeMatchWithInverter( Map_Man_t * p, Map_Match_t * pMatch );
/*=== mapperTruth.c ===============================================================*/
extern void Map_MappingTruths( Map_Man_t * pMan );
extern int Map_TruthsCutDontCare( Map_Man_t * pMan, Map_Cut_t * pCut, unsigned * uTruthDc );
......@@ -437,11 +419,6 @@ extern int Map_TruthCountOnes( unsigned * uTruth, int nLeaves );
extern int Map_TruthDetectTwoFirst( unsigned * uTruth, int nLeaves );
/*=== mapperUtils.c ===============================================================*/
extern Map_NodeVec_t * Map_MappingDfs( Map_Man_t * pMan, int fCollectEquiv );
extern Map_NodeVec_t * Map_MappingDfsNodes( Map_Man_t * pMan, Map_Node_t ** ppNodes, int nNodes, int fEquiv );
extern void Map_MappingDfsMarked1_rec( Map_Node_t * pNode, Map_NodeVec_t * vNodes, int fFirst );
extern void Map_MappingDfsMarked2_rec( Map_Node_t * pNode, Map_NodeVec_t * vNodes, Map_NodeVec_t * vBoundary, int fFirst );
extern int Map_MappingCountLevels( Map_Man_t * pMan );
extern void Map_MappingUnmark( Map_Man_t * pMan );
extern void Map_MappingMark_rec( Map_Node_t * pNode );
......@@ -464,6 +441,7 @@ extern void Map_MappingReportChoices( Map_Man_t * pMan );
/*=== mapperVec.c =============================================================*/
extern Map_NodeVec_t * Map_NodeVecAlloc( int nCap );
extern void Map_NodeVecFree( Map_NodeVec_t * p );
extern Map_NodeVec_t * Map_NodeVecDup( Map_NodeVec_t * p );
extern Map_Node_t ** Map_NodeVecReadArray( Map_NodeVec_t * p );
extern int Map_NodeVecReadSize( Map_NodeVec_t * p );
extern void Map_NodeVecGrow( Map_NodeVec_t * p, int nCapMin );
......
......@@ -184,15 +184,16 @@ float Map_SwitchCutRefDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, i
SeeAlso []
***********************************************************************/
float Map_MappingGetSwitching( Map_Man_t * pMan, Map_NodeVec_t * vMapping )
float Map_MappingGetSwitching( Map_Man_t * pMan )
{
Map_Node_t * pNode;
float Switch;
float Switch = 0.0;
int i;
Switch = 0.0;
for ( i = 0; i < vMapping->nSize; i++ )
for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
{
pNode = vMapping->pArray[i];
pNode = pMan->vMapObjs->pArray[i];
if ( pNode->nRefAct[2] == 0 )
continue;
// at least one phase has the best cut assigned
assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL );
// at least one phase is used in the mapping
......
......@@ -51,11 +51,11 @@ void Map_MappingTruths( Map_Man_t * pMan )
Map_Cut_t * pCut;
int nNodes, i;
// compute the cuts for the POs
nNodes = pMan->vAnds->nSize;
nNodes = pMan->vMapObjs->nSize;
pProgress = Extra_ProgressBarStart( stdout, nNodes );
for ( i = 0; i < nNodes; i++ )
{
pNode = pMan->vAnds->pArray[i];
pNode = pMan->vMapObjs->pArray[i];
if ( !Map_NodeIsAnd( pNode ) )
continue;
assert( pNode->pCuts );
......
......@@ -67,6 +67,8 @@ Map_NodeVec_t * Map_NodeVecAlloc( int nCap )
***********************************************************************/
void Map_NodeVecFree( Map_NodeVec_t * p )
{
if ( p == NULL )
return;
ABC_FREE( p->pArray );
ABC_FREE( p );
}
......@@ -82,6 +84,25 @@ void Map_NodeVecFree( Map_NodeVec_t * p )
SeeAlso []
***********************************************************************/
Map_NodeVec_t * Map_NodeVecDup( Map_NodeVec_t * p )
{
Map_NodeVec_t * pNew = Map_NodeVecAlloc( p->nSize );
memcpy( pNew->pArray, p->pArray, sizeof(int) * p->nSize );
pNew->nSize = p->nSize;
return pNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Map_Node_t ** Map_NodeVecReadArray( Map_NodeVec_t * p )
{
return p->pArray;
......
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