summaryrefslogtreecommitdiffstats
path: root/src/map/if/ifSelect.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-12-04 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2006-12-04 08:01:00 -0800
commit52e5b91cbbfe587bae80984bb3672e4c1a70203c (patch)
tree0aec31b1121e4eb690f1dc17b3c76617b723fe5e /src/map/if/ifSelect.c
parent44d220d28fa2ee56cb539e03684f021731814f17 (diff)
downloadabc-52e5b91cbbfe587bae80984bb3672e4c1a70203c.tar.gz
abc-52e5b91cbbfe587bae80984bb3672e4c1a70203c.tar.bz2
abc-52e5b91cbbfe587bae80984bb3672e4c1a70203c.zip
Version abc61204
Diffstat (limited to 'src/map/if/ifSelect.c')
-rw-r--r--src/map/if/ifSelect.c175
1 files changed, 175 insertions, 0 deletions
diff --git a/src/map/if/ifSelect.c b/src/map/if/ifSelect.c
new file mode 100644
index 00000000..d54abb29
--- /dev/null
+++ b/src/map/if/ifSelect.c
@@ -0,0 +1,175 @@
+/**CFile****************************************************************
+
+ FileName [ifSelect.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [Selects what mapping to use.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifSelect.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static void If_ManPerformMappingMoveBestCut( If_Man_t * p, int iPosNew, int iPosOld );
+static void If_ManPerformMappingAdjust( If_Man_t * p, int nCuts );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Merges the results of delay, relaxed delay and area-based mapping.]
+
+ Description [Delay target may be different from minimum delay!!!]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManPerformMappingPreprocess( If_Man_t * p )
+{
+ float delayArea, delayDelay, delayPure;
+ int clk = clock();
+ assert( p->pPars->nCutsMax >= 4 );
+
+ // perform min-area mapping and move the cut to the end
+ p->pPars->fArea = 1;
+ If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 0 );
+ p->pPars->fArea = 0;
+ delayArea = If_ManDelayMax( p );
+ if ( p->pPars->DelayTarget != -1 && delayArea < p->pPars->DelayTarget - p->fEpsilon )
+ delayArea = p->pPars->DelayTarget;
+ If_ManPerformMappingMoveBestCut( p, p->pPars->nCutsMax - 1, 1 );
+
+ // perfrom min-delay mapping and move the cut to the end
+ p->pPars->fFancy = 1;
+ If_ManPerformMappingRound( p, p->pPars->nCutsMax - 1, 0, 0 );
+ p->pPars->fFancy = 0;
+ delayDelay = If_ManDelayMax( p );
+ if ( p->pPars->DelayTarget != -1 && delayDelay < p->pPars->DelayTarget - p->fEpsilon )
+ delayDelay = p->pPars->DelayTarget;
+ If_ManPerformMappingMoveBestCut( p, p->pPars->nCutsMax - 2, 1 );
+
+ // perform min-area mapping
+ If_ManPerformMappingRound( p, p->pPars->nCutsMax - 2, 0, 0 );
+ delayPure = If_ManDelayMax( p );
+ if ( p->pPars->DelayTarget != -1 && delayPure < p->pPars->DelayTarget - p->fEpsilon )
+ delayPure = p->pPars->DelayTarget;
+
+ // decide what to do
+ if ( delayPure < delayDelay - p->fEpsilon && delayPure < delayArea - p->fEpsilon )
+ {
+ // copy the remaining two cuts
+ if ( p->pPars->nCutsMax > 4 )
+ {
+ If_ManPerformMappingMoveBestCut( p, 2, p->pPars->nCutsMax - 2 );
+ If_ManPerformMappingMoveBestCut( p, 3, p->pPars->nCutsMax - 1 );
+ }
+ If_ManComputeRequired( p, 1 );
+ If_ManPerformMappingAdjust( p, 4 );
+ }
+ else if ( delayDelay < delayArea - p->fEpsilon )
+ {
+ If_ManPerformMappingMoveBestCut( p, 1, p->pPars->nCutsMax - 2 );
+ If_ManPerformMappingMoveBestCut( p, 2, p->pPars->nCutsMax - 1 );
+ If_ManComputeRequired( p, 1 );
+ If_ManPerformMappingAdjust( p, 3 );
+ }
+ else
+ {
+ If_ManPerformMappingMoveBestCut( p, 1, p->pPars->nCutsMax - 1 );
+ If_ManComputeRequired( p, 1 );
+ If_ManPerformMappingAdjust( p, 2 );
+ }
+ If_ManComputeRequired( p, 1 );
+ if ( p->pPars->fVerbose )
+ {
+ printf( "S: Del = %6.2f. Area = %8.2f. Cuts = %6d. Lim = %2d. Ave = %5.2f. ",
+ p->RequiredGlo, p->AreaGlo, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
+ PRT( "T", clock() - clk );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Moves the best cut to the given position.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManPerformMappingMoveBestCut( If_Man_t * p, int iPosNew, int iPosOld )
+{
+ If_Obj_t * pObj;
+ int i;
+ assert( iPosOld != iPosNew );
+ assert( iPosOld > 0 && iPosOld < p->pPars->nCutsMax );
+ assert( iPosNew > 0 && iPosNew < p->pPars->nCutsMax );
+ If_ManForEachNode( p, pObj, i )
+ If_CutCopy( pObj->Cuts + iPosNew, pObj->Cuts + iPosOld );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adjusts mapping for the given cuts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManPerformMappingAdjust( If_Man_t * p, int nCuts )
+{
+ If_Cut_t * pCut, * pCutBest;
+ If_Obj_t * pObj;
+ int i, c;
+ assert( nCuts >= 2 && nCuts <= 4 );
+ If_ManForEachNode( p, pObj, i )
+ {
+ pCutBest = NULL;
+ for ( c = 1; c < nCuts; c++ )
+ {
+ pCut = pObj->Cuts + c;
+ pCut->Delay = If_CutDelay( p, pCut );
+ pCut->Area = If_CutFlow( p, pCut );
+ assert( pCutBest || pCut->Delay < pObj->Required + p->fEpsilon );
+ if ( pCutBest == NULL ||
+ (pCut->Delay < pObj->Required + p->fEpsilon &&
+ pCut->Area < pCutBest->Area - p->fEpsilon) )
+ pCutBest = pCut;
+ }
+ assert( pCutBest != NULL );
+ // check if we need to move
+ if ( pCutBest != pObj->Cuts + 1 )
+ If_CutCopy( pObj->Cuts + 1, pCutBest );
+ // set the number of cuts
+ pObj->nCuts = 2;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+