2005-07-29 17:01:00 +02:00
|
|
|
/**CFile****************************************************************
|
|
|
|
|
|
|
|
|
|
FileName [mapperCore.c]
|
|
|
|
|
|
|
|
|
|
PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
|
|
|
|
|
|
|
|
|
|
Synopsis [Generic technology mapping engine.]
|
|
|
|
|
|
|
|
|
|
Author [MVSIS Group]
|
|
|
|
|
|
|
|
|
|
Affiliation [UC Berkeley]
|
|
|
|
|
|
|
|
|
|
Date [Ver. 2.0. Started - June 1, 2004.]
|
|
|
|
|
|
|
|
|
|
Revision [$Id: mapperCore.c,v 1.7 2004/10/01 23:41:04 satrajit Exp $]
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "mapperInt.h"
|
|
|
|
|
//#include "resm.h"
|
|
|
|
|
|
2010-11-01 09:35:04 +01:00
|
|
|
ABC_NAMESPACE_IMPL_START
|
|
|
|
|
|
|
|
|
|
|
2005-07-29 17:01:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// DECLARATIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
2008-01-31 05:01:00 +01:00
|
|
|
/// FUNCTION DEFINITIONS ///
|
2005-07-29 17:01:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Performs technology mapping for the given object graph.]
|
|
|
|
|
|
|
|
|
|
Description [The object graph is stored in the mapping manager.
|
|
|
|
|
First, the AND nodes that fanout into POs are collected in the DFS order.
|
|
|
|
|
Two preprocessing steps are performed: the k-feasible cuts are computed
|
|
|
|
|
for each node and the truth tables are computed for each cut. Next, the
|
|
|
|
|
delay-optimal matches are assigned for each node, followed by several
|
|
|
|
|
iterations of area recoveryd: using area flow (global optimization)
|
|
|
|
|
and using exact area at a node (local optimization).]
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
int Map_Mapping( Map_Man_t * p )
|
|
|
|
|
{
|
2012-03-22 07:19:49 +01:00
|
|
|
int fShowSwitching = 0;
|
2005-07-29 17:01:00 +02:00
|
|
|
int fUseAreaFlow = 1;
|
2005-09-04 17:01:00 +02:00
|
|
|
int fUseExactArea = !p->fSwitching;
|
|
|
|
|
int fUseExactAreaWithPhase = !p->fSwitching;
|
2013-05-28 00:09:23 +02:00
|
|
|
abctime clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// perform pre-mapping computations
|
|
|
|
|
if ( p->fVerbose )
|
|
|
|
|
Map_MappingReportChoices( p );
|
|
|
|
|
Map_MappingSetChoiceLevels( p ); // should always be called before mapping!
|
|
|
|
|
// return 1;
|
|
|
|
|
|
|
|
|
|
// compute the cuts of nodes in the DFS order
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-07-29 17:01:00 +02:00
|
|
|
Map_MappingCuts( p );
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeCuts = Abc_Clock() - clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
// derive the truth tables
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-07-29 17:01:00 +02:00
|
|
|
Map_MappingTruths( p );
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeTruth = Abc_Clock() - clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2013-05-28 00:09:23 +02:00
|
|
|
//ABC_PRT( "Truths", Abc_Clock() - clk );
|
2005-07-29 17:01:00 +02:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// compute the minimum-delay mapping
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-07-29 17:01:00 +02:00
|
|
|
p->fMappingMode = 0;
|
|
|
|
|
if ( !Map_MappingMatches( p ) )
|
|
|
|
|
return 0;
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeMatch = Abc_Clock() - clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
// compute the references and collect the nodes used in the mapping
|
|
|
|
|
Map_MappingSetRefs( p );
|
2014-03-24 00:52:40 +01:00
|
|
|
p->AreaBase = Map_MappingGetArea( p );
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( p->fVerbose )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
printf( "Delay : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
|
|
|
|
|
fShowSwitching? "Switch" : "Delay",
|
2014-03-24 00:52:40 +01:00
|
|
|
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
|
2005-09-04 17:01:00 +02:00
|
|
|
Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 );
|
2009-02-15 17:01:00 +01:00
|
|
|
ABC_PRT( "Time", p->timeMatch );
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2005-08-17 17:01:00 +02:00
|
|
|
if ( !p->fAreaRecovery )
|
2008-01-31 05:01:00 +01:00
|
|
|
{
|
|
|
|
|
if ( p->fVerbose )
|
|
|
|
|
Map_MappingPrintOutputArrivals( p );
|
2005-08-17 17:01:00 +02:00
|
|
|
return 1;
|
2008-01-31 05:01:00 +01:00
|
|
|
}
|
2005-08-17 17:01:00 +02:00
|
|
|
|
2005-07-29 17:01:00 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// perform area recovery using area flow
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( fUseAreaFlow )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
// compute the required times
|
2005-07-29 17:01:00 +02:00
|
|
|
Map_TimeComputeRequiredGlobal( p );
|
|
|
|
|
// recover area flow
|
|
|
|
|
p->fMappingMode = 1;
|
|
|
|
|
Map_MappingMatches( p );
|
|
|
|
|
// compute the references and collect the nodes used in the mapping
|
|
|
|
|
Map_MappingSetRefs( p );
|
2014-03-24 00:52:40 +01:00
|
|
|
p->AreaFinal = Map_MappingGetArea( p );
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( p->fVerbose )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
printf( "AreaFlow : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
|
|
|
|
|
fShowSwitching? "Switch" : "Delay",
|
2014-03-24 00:52:40 +01:00
|
|
|
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
|
2005-09-04 17:01:00 +02:00
|
|
|
Map_MappingGetAreaFlow(p), p->AreaFinal,
|
2005-07-29 17:01:00 +02:00
|
|
|
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
|
2013-05-28 00:09:23 +02:00
|
|
|
ABC_PRT( "Time", Abc_Clock() - clk );
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeArea += Abc_Clock() - clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// perform area recovery using exact area
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( fUseExactArea )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
// compute the required times
|
2005-07-29 17:01:00 +02:00
|
|
|
Map_TimeComputeRequiredGlobal( p );
|
2005-09-04 17:01:00 +02:00
|
|
|
// recover area
|
2005-07-29 17:01:00 +02:00
|
|
|
p->fMappingMode = 2;
|
|
|
|
|
Map_MappingMatches( p );
|
|
|
|
|
// compute the references and collect the nodes used in the mapping
|
|
|
|
|
Map_MappingSetRefs( p );
|
2014-03-24 00:52:40 +01:00
|
|
|
p->AreaFinal = Map_MappingGetArea( p );
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( p->fVerbose )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
|
|
|
|
|
fShowSwitching? "Switch" : "Delay",
|
2014-03-24 00:52:40 +01:00
|
|
|
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
|
2005-09-04 17:01:00 +02:00
|
|
|
0.0, p->AreaFinal,
|
2005-07-29 17:01:00 +02:00
|
|
|
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
|
2013-05-28 00:09:23 +02:00
|
|
|
ABC_PRT( "Time", Abc_Clock() - clk );
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeArea += Abc_Clock() - clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// perform area recovery using exact area
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( fUseExactAreaWithPhase )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
// compute the required times
|
2005-07-29 17:01:00 +02:00
|
|
|
Map_TimeComputeRequiredGlobal( p );
|
2005-09-04 17:01:00 +02:00
|
|
|
// recover area
|
2005-07-29 17:01:00 +02:00
|
|
|
p->fMappingMode = 3;
|
|
|
|
|
Map_MappingMatches( p );
|
|
|
|
|
// compute the references and collect the nodes used in the mapping
|
|
|
|
|
Map_MappingSetRefs( p );
|
2014-03-24 00:52:40 +01:00
|
|
|
p->AreaFinal = Map_MappingGetArea( p );
|
2005-07-29 17:01:00 +02:00
|
|
|
if ( p->fVerbose )
|
|
|
|
|
{
|
2005-09-04 17:01:00 +02:00
|
|
|
printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
|
|
|
|
|
fShowSwitching? "Switch" : "Delay",
|
2014-03-24 00:52:40 +01:00
|
|
|
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
|
2005-09-04 17:01:00 +02:00
|
|
|
0.0, p->AreaFinal,
|
|
|
|
|
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
|
2013-05-28 00:09:23 +02:00
|
|
|
ABC_PRT( "Time", Abc_Clock() - clk );
|
2005-09-04 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeArea += Abc_Clock() - clk;
|
2005-09-04 17:01:00 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// perform area recovery using exact area
|
2013-05-28 00:09:23 +02:00
|
|
|
clk = Abc_Clock();
|
2005-09-04 17:01:00 +02:00
|
|
|
if ( p->fSwitching )
|
|
|
|
|
{
|
|
|
|
|
// compute the required times
|
|
|
|
|
Map_TimeComputeRequiredGlobal( p );
|
|
|
|
|
// recover switching activity
|
|
|
|
|
p->fMappingMode = 4;
|
|
|
|
|
Map_MappingMatches( p );
|
|
|
|
|
// compute the references and collect the nodes used in the mapping
|
|
|
|
|
Map_MappingSetRefs( p );
|
2014-03-24 00:52:40 +01:00
|
|
|
p->AreaFinal = Map_MappingGetArea( p );
|
2005-09-04 17:01:00 +02:00
|
|
|
if ( p->fVerbose )
|
|
|
|
|
{
|
|
|
|
|
printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
|
|
|
|
|
fShowSwitching? "Switch" : "Delay",
|
2014-03-24 00:52:40 +01:00
|
|
|
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
|
2005-09-04 17:01:00 +02:00
|
|
|
0.0, p->AreaFinal,
|
|
|
|
|
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
|
2013-05-28 00:09:23 +02:00
|
|
|
ABC_PRT( "Time", Abc_Clock() - clk );
|
2005-09-04 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// compute the required times
|
|
|
|
|
Map_TimeComputeRequiredGlobal( p );
|
|
|
|
|
// recover switching activity
|
|
|
|
|
p->fMappingMode = 4;
|
|
|
|
|
Map_MappingMatches( p );
|
|
|
|
|
// compute the references and collect the nodes used in the mapping
|
|
|
|
|
Map_MappingSetRefs( p );
|
2014-03-24 00:52:40 +01:00
|
|
|
p->AreaFinal = Map_MappingGetArea( p );
|
2005-09-04 17:01:00 +02:00
|
|
|
if ( p->fVerbose )
|
|
|
|
|
{
|
|
|
|
|
printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
|
|
|
|
|
fShowSwitching? "Switch" : "Delay",
|
2014-03-24 00:52:40 +01:00
|
|
|
fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
|
2005-09-04 17:01:00 +02:00
|
|
|
0.0, p->AreaFinal,
|
2005-07-29 17:01:00 +02:00
|
|
|
100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
|
2013-05-28 00:09:23 +02:00
|
|
|
ABC_PRT( "Time", Abc_Clock() - clk );
|
2005-07-29 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-05-28 00:09:23 +02:00
|
|
|
p->timeArea += Abc_Clock() - clk;
|
2005-07-29 17:01:00 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// print the arrival times of the latest outputs
|
|
|
|
|
if ( p->fVerbose )
|
|
|
|
|
Map_MappingPrintOutputArrivals( p );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2010-11-01 09:35:04 +01:00
|
|
|
ABC_NAMESPACE_IMPL_END
|
|
|
|
|
|