abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mapperMatch.c File Reference
#include "mapperInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Map_MatchClean (Map_Match_t *pMatch)
 DECLARATIONS ///. More...
 
int Map_MatchCompare (Map_Man_t *pMan, Map_Match_t *pM1, Map_Match_t *pM2, int fDoingArea)
 
int Map_MatchNodeCut (Map_Man_t *p, Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, float fWorstLimit)
 
int Map_MatchNodePhase (Map_Man_t *p, Map_Node_t *pNode, int fPhase)
 
void Map_MappingSetPiArrivalTimes (Map_Man_t *p)
 
float Map_TimeMatchWithInverter (Map_Man_t *p, Map_Match_t *pMatch)
 
void Map_NodeTryDroppingOnePhase (Map_Man_t *p, Map_Node_t *pNode)
 
void Map_NodeTransferArrivalTimes (Map_Man_t *p, Map_Node_t *pNode)
 
int Map_MappingMatches (Map_Man_t *p)
 

Function Documentation

int Map_MappingMatches ( Map_Man_t p)

Function*************************************************************

Synopsis [Computes the best matches of the nodes.]

Description [Uses parameter p->fMappingMode to decide how to assign the matches for both polarities of the node. While the matches are being assigned, one of them may turn out to be better than the other (in terms of delay, for example). In this case, the worse match can be permanently dropped, and the corresponding pointer set to NULL.]

SideEffects []

SeeAlso []

Definition at line 553 of file mapperMatch.c.

554 {
555  ProgressBar * pProgress;
556  Map_Node_t * pNode;
557  int i;
558 
559  assert( p->fMappingMode >= 0 && p->fMappingMode <= 4 );
560 
561  // use the externally given PI arrival times
562  if ( p->fMappingMode == 0 )
564 
565  // estimate the fanouts
566  if ( p->fMappingMode == 0 )
568  else if ( p->fMappingMode == 1 )
570 
571  // the PI cuts are matched in the cut computation package
572  // in the loop below we match the internal nodes
573  pProgress = Extra_ProgressBarStart( stdout, p->vMapObjs->nSize );
574  for ( i = 0; i < p->vMapObjs->nSize; i++ )
575  {
576  pNode = p->vMapObjs->pArray[i];
577  if ( Map_NodeIsBuf(pNode) )
578  {
579  assert( pNode->p2 == NULL );
580  pNode->tArrival[0] = Map_Regular(pNode->p1)->tArrival[ Map_IsComplement(pNode->p1)];
581  pNode->tArrival[1] = Map_Regular(pNode->p1)->tArrival[!Map_IsComplement(pNode->p1)];
582  continue;
583  }
584 
585  // skip primary inputs and secondary nodes if mapping with choices
586  if ( !Map_NodeIsAnd( pNode ) || pNode->pRepr )
587  continue;
588 
589  // make sure that at least one non-trival cut is present
590  if ( pNode->pCuts->pNext == NULL )
591  {
592  Extra_ProgressBarStop( pProgress );
593  printf( "\nError: A node in the mapping graph does not have feasible cuts.\n" );
594  return 0;
595  }
596 
597  // match negative phase
598  if ( !Map_MatchNodePhase( p, pNode, 0 ) )
599  {
600  Extra_ProgressBarStop( pProgress );
601  return 0;
602  }
603  // match positive phase
604  if ( !Map_MatchNodePhase( p, pNode, 1 ) )
605  {
606  Extra_ProgressBarStop( pProgress );
607  return 0;
608  }
609 
610  // make sure that at least one phase is mapped
611  if ( pNode->pCutBest[0] == NULL && pNode->pCutBest[1] == NULL )
612  {
613  printf( "\nError: Could not match both phases of AIG node %d.\n", pNode->Num );
614  printf( "Please make sure that the supergate library has equivalents of AND2 or NAND2.\n" );
615  printf( "If such supergates exist in the library, report a bug.\n" );
616  Extra_ProgressBarStop( pProgress );
617  return 0;
618  }
619 
620  // if both phases are assigned, check if one of them can be dropped
621  Map_NodeTryDroppingOnePhase( p, pNode );
622  // set the arrival times of the node using the best cuts
624 
625  // update the progress bar
626  Extra_ProgressBarUpdate( pProgress, i, "Matches ..." );
627  }
628  Extra_ProgressBarStop( pProgress );
629  return 1;
630 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Map_MatchNodePhase(Map_Man_t *p, Map_Node_t *pNode, int fPhase)
Definition: mapperMatch.c:235
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
int Map_NodeIsBuf(Map_Node_t *p)
Definition: mapperCreate.c:114
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
Map_Cut_t * pNext
Definition: mapperInt.h:262
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
DECLARATIONS ///.
void Map_MappingEstimateRefs(Map_Man_t *p)
Definition: mapperRefs.c:151
Map_Cut_t * pCuts
Definition: mapperInt.h:240
void Map_MappingSetPiArrivalTimes(Map_Man_t *p)
Definition: mapperMatch.c:351
void Map_MappingEstimateRefsInit(Map_Man_t *p)
Definition: mapperRefs.c:126
Map_Node_t * p2
Definition: mapperInt.h:222
void Extra_ProgressBarStop(ProgressBar *p)
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
Map_Node_t * pRepr
Definition: mapperInt.h:224
void Map_NodeTransferArrivalTimes(Map_Man_t *p, Map_Node_t *pNode)
Definition: mapperMatch.c:503
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
void Map_NodeTryDroppingOnePhase(Map_Man_t *p, Map_Node_t *pNode)
Definition: mapperMatch.c:401
void Map_MappingSetPiArrivalTimes ( Map_Man_t p)

Function*************************************************************

Synopsis [Sets the PI arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 351 of file mapperMatch.c.

352 {
353  Map_Node_t * pNode;
354  int i;
355  for ( i = 0; i < p->nInputs; i++ )
356  {
357  pNode = p->pInputs[i];
358  // set the arrival time of the positive phase
359  pNode->tArrival[1] = p->pInputArrivals[i];
360  pNode->tArrival[1].Rise += p->pNodeDelays ? p->pNodeDelays[pNode->Num] : 0;
361  pNode->tArrival[1].Fall += p->pNodeDelays ? p->pNodeDelays[pNode->Num] : 0;
362  pNode->tArrival[1].Worst += p->pNodeDelays ? p->pNodeDelays[pNode->Num] : 0;
363  // set the arrival time of the negative phase
364  pNode->tArrival[0].Rise = pNode->tArrival[1].Fall + p->pSuperLib->tDelayInv.Rise;
365  pNode->tArrival[0].Fall = pNode->tArrival[1].Rise + p->pSuperLib->tDelayInv.Fall;
366  pNode->tArrival[0].Worst = MAP_MAX(pNode->tArrival[0].Rise, pNode->tArrival[0].Fall);
367  }
368 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
ABC_NAMESPACE_IMPL_START void Map_MatchClean ( Map_Match_t pMatch)

DECLARATIONS ///.

CFile****************************************************************

FileName [mapperMatch.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:
mapperMatch.c,v 1.7 2004/09/30 21:18:10 satrajit Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Cleans the match.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file mapperMatch.c.

55 {
56  memset( pMatch, 0, sizeof(Map_Match_t) );
57  pMatch->AreaFlow = MAP_FLOAT_LARGE; // unassigned
58  pMatch->tArrive.Rise = MAP_FLOAT_LARGE; // unassigned
59  pMatch->tArrive.Fall = MAP_FLOAT_LARGE; // unassigned
60  pMatch->tArrive.Worst = MAP_FLOAT_LARGE; // unassigned
61 }
char * memset()
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
Map_Time_t tArrive
Definition: mapperInt.h:255
int Map_MatchCompare ( Map_Man_t pMan,
Map_Match_t pM1,
Map_Match_t pM2,
int  fDoingArea 
)

Function*************************************************************

Synopsis [Compares two matches.]

Description [Returns 1 if the second match is better. Otherwise returns 0.]

SideEffects []

SeeAlso []

Definition at line 74 of file mapperMatch.c.

75 {
76  if ( !fDoingArea )
77  {
78  // compare the arrival times
79  if ( pM1->tArrive.Worst < pM2->tArrive.Worst - pMan->fEpsilon )
80  return 0;
81  if ( pM1->tArrive.Worst > pM2->tArrive.Worst + pMan->fEpsilon )
82  return 1;
83  // compare the areas or area flows
84  if ( pM1->AreaFlow < pM2->AreaFlow - pMan->fEpsilon )
85  return 0;
86  if ( pM1->AreaFlow > pM2->AreaFlow + pMan->fEpsilon )
87  return 1;
88  // compare the fanout limits
89  if ( pM1->pSuperBest->nFanLimit > pM2->pSuperBest->nFanLimit )
90  return 0;
91  if ( pM1->pSuperBest->nFanLimit < pM2->pSuperBest->nFanLimit )
92  return 1;
93  // compare the number of leaves
94  if ( pM1->pSuperBest->nFanins < pM2->pSuperBest->nFanins )
95  return 0;
96  if ( pM1->pSuperBest->nFanins > pM2->pSuperBest->nFanins )
97  return 1;
98  // otherwise prefer the old cut
99  return 0;
100  }
101  else
102  {
103  // compare the areas or area flows
104  if ( pM1->AreaFlow < pM2->AreaFlow - pMan->fEpsilon )
105  return 0;
106  if ( pM1->AreaFlow > pM2->AreaFlow + pMan->fEpsilon )
107  return 1;
108  // compare the arrival times
109  if ( pM1->tArrive.Worst < pM2->tArrive.Worst - pMan->fEpsilon )
110  return 0;
111  if ( pM1->tArrive.Worst > pM2->tArrive.Worst + pMan->fEpsilon )
112  return 1;
113  // compare the fanout limits
114  if ( pM1->pSuperBest->nFanLimit > pM2->pSuperBest->nFanLimit )
115  return 0;
116  if ( pM1->pSuperBest->nFanLimit < pM2->pSuperBest->nFanLimit )
117  return 1;
118  // compare the number of leaves
119  if ( pM1->pSuperBest->nFanins < pM2->pSuperBest->nFanins )
120  return 0;
121  if ( pM1->pSuperBest->nFanins > pM2->pSuperBest->nFanins )
122  return 1;
123  // otherwise prefer the old cut
124  return 0;
125  }
126 }
unsigned nFanins
Definition: mapperInt.h:280
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
Map_Time_t tArrive
Definition: mapperInt.h:255
unsigned nFanLimit
Definition: mapperInt.h:282
int Map_MatchNodeCut ( Map_Man_t p,
Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase,
float  fWorstLimit 
)

Function*************************************************************

Synopsis [Find the best matching of the cut.]

Description [The parameters: the node (pNode), the cut (pCut), the phase to be matched (fPhase), and the upper bound on the arrival times of the cut (fWorstLimit). This procedure goes through the matching supergates up to the phase assignment, and selects the best supergate, which will be used to map the cut. As a result of calling this procedure the matching information is written into pMatch.]

SideEffects []

SeeAlso []

Definition at line 143 of file mapperMatch.c.

144 {
145  Map_Match_t MatchBest, * pMatch = pCut->M + fPhase;
146  Map_Super_t * pSuper;
147  int i, Counter;
148 
149  // save the current match of the cut
150  MatchBest = *pMatch;
151  // go through the supergates
152  for ( pSuper = pMatch->pSupers, Counter = 0; pSuper; pSuper = pSuper->pNext, Counter++ )
153  {
154  p->nMatches++;
155  // this is an attempt to reduce the runtime of matching and area
156  // at the cost of rare and very minor increase in delay
157  // (the supergates are sorted by increasing area)
158  if ( Counter == 30 )
159  break;
160 
161  // go through different phases of the given match and supergate
162  pMatch->pSuperBest = pSuper;
163  for ( i = 0; i < (int)pSuper->nPhases; i++ )
164  {
165  p->nPhases++;
166  // find the overall phase of this match
167  pMatch->uPhaseBest = pMatch->uPhase ^ pSuper->uPhases[i];
168  if ( p->fMappingMode == 0 )
169  {
170  // get the arrival time
171  Map_TimeCutComputeArrival( pNode, pCut, fPhase, fWorstLimit );
172  // skip the cut if the arrival times exceed the required times
173  if ( pMatch->tArrive.Worst > fWorstLimit + p->fEpsilon )
174  continue;
175  // get the area (area flow)
176  pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase );
177  }
178  else
179  {
180  // get the area (area flow)
181  if ( p->fMappingMode == 2 || p->fMappingMode == 3 )
182  pMatch->AreaFlow = Map_CutGetAreaDerefed( pCut, fPhase );
183  else if ( p->fMappingMode == 4 )
184  pMatch->AreaFlow = Map_SwitchCutGetDerefed( pNode, pCut, fPhase );
185  else
186  pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase );
187  // skip if the cut is too large
188  if ( pMatch->AreaFlow > MatchBest.AreaFlow + p->fEpsilon )
189  continue;
190  // get the arrival time
191  Map_TimeCutComputeArrival( pNode, pCut, fPhase, fWorstLimit );
192  // skip the cut if the arrival times exceed the required times
193  if ( pMatch->tArrive.Worst > fWorstLimit + p->fEpsilon )
194  continue;
195  }
196 
197  // if the cut is non-trivial, compare it
198  if ( Map_MatchCompare( p, &MatchBest, pMatch, p->fMappingMode ) )
199  {
200  MatchBest = *pMatch;
201  // if we are mapping for delay, the worst-case limit should be reduced
202  if ( p->fMappingMode == 0 )
203  fWorstLimit = MatchBest.tArrive.Worst;
204  }
205  }
206  }
207  // set the best match
208  *pMatch = MatchBest;
209 
210  // recompute the arrival time and area (area flow) of this cut
211  if ( pMatch->pSuperBest )
212  {
213  Map_TimeCutComputeArrival( pNode, pCut, fPhase, MAP_FLOAT_LARGE );
214  if ( p->fMappingMode == 2 || p->fMappingMode == 3 )
215  pMatch->AreaFlow = Map_CutGetAreaDerefed( pCut, fPhase );
216  else if ( p->fMappingMode == 4 )
217  pMatch->AreaFlow = Map_SwitchCutGetDerefed( pNode, pCut, fPhase );
218  else
219  pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase );
220  }
221  return 1;
222 }
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned uPhaseBest
Definition: mapperInt.h:252
unsigned char uPhases[4]
Definition: mapperInt.h:285
int Map_MatchCompare(Map_Man_t *pMan, Map_Match_t *pM1, Map_Match_t *pM2, int fDoingArea)
Definition: mapperMatch.c:74
Map_Super_t * pSupers
Definition: mapperInt.h:249
float Map_CutGetAreaDerefed(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:348
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
Map_Time_t tArrive
Definition: mapperInt.h:255
float Map_TimeCutComputeArrival(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, float tWorstCaseLimit)
Definition: mapperTime.c:72
static int Counter
unsigned nPhases
Definition: mapperInt.h:284
float Map_CutGetAreaFlow(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:179
float Map_SwitchCutGetDerefed(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
FUNCTION DEFINITIONS ///.
Definition: mapperSwitch.c:45
Map_Match_t M[2]
Definition: mapperInt.h:271
Map_Super_t * pNext
Definition: mapperInt.h:295
int Map_MatchNodePhase ( Map_Man_t p,
Map_Node_t pNode,
int  fPhase 
)

Function*************************************************************

Synopsis [Find the matching of one polarity of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file mapperMatch.c.

236 {
237  Map_Match_t MatchBest, * pMatch;
238  Map_Cut_t * pCut, * pCutBest;
239  float Area1 = 0.0; // Suppress "might be used uninitialized
240  float Area2, fWorstLimit;
241 
242  // skip the cuts that have been unassigned during area recovery
243  pCutBest = pNode->pCutBest[fPhase];
244  if ( p->fMappingMode != 0 && pCutBest == NULL )
245  return 1;
246 
247  // recompute the arrival times of the current best match
248  // because the arrival times of the fanins may have changed
249  // as a result of remapping fanins in the topological order
250  if ( p->fMappingMode != 0 )
251  {
252  Map_TimeCutComputeArrival( pNode, pCutBest, fPhase, MAP_FLOAT_LARGE );
253  // make sure that the required times are met
254 // assert( pCutBest->M[fPhase].tArrive.Rise < pNode->tRequired[fPhase].Rise + p->fEpsilon );
255 // assert( pCutBest->M[fPhase].tArrive.Fall < pNode->tRequired[fPhase].Fall + p->fEpsilon );
256  }
257 
258  // recompute the exact area of the current best match
259  // because the exact area of the fanins may have changed
260  // as a result of remapping fanins in the topological order
261  if ( p->fMappingMode == 2 || p->fMappingMode == 3 )
262  {
263  pMatch = pCutBest->M + fPhase;
264  if ( pNode->nRefAct[fPhase] > 0 ||
265  (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0) )
266  pMatch->AreaFlow = Area1 = Map_CutDeref( pCutBest, fPhase );
267  else
268  pMatch->AreaFlow = Area1 = Map_CutGetAreaDerefed( pCutBest, fPhase );
269  }
270  else if ( p->fMappingMode == 4 )
271  {
272  pMatch = pCutBest->M + fPhase;
273  if ( pNode->nRefAct[fPhase] > 0 ||
274  (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0) )
275  pMatch->AreaFlow = Area1 = Map_SwitchCutDeref( pNode, pCutBest, fPhase );
276  else
277  pMatch->AreaFlow = Area1 = Map_SwitchCutGetDerefed( pNode, pCutBest, fPhase );
278  }
279 
280  // save the old mapping
281  if ( pCutBest )
282  MatchBest = pCutBest->M[fPhase];
283  else
284  Map_MatchClean( &MatchBest );
285 
286  // select the new best cut
287  fWorstLimit = pNode->tRequired[fPhase].Worst;
288  for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext )
289  {
290  // limit gate sizes based on fanout count
291  if ( (pNode->nRefs > 3 && pCut->nLeaves > 2) || (pNode->nRefs > 1 && pCut->nLeaves > 3) )
292  continue;
293  pMatch = pCut->M + fPhase;
294  if ( pMatch->pSupers == NULL )
295  continue;
296 
297  // find the matches for the cut
298  Map_MatchNodeCut( p, pNode, pCut, fPhase, fWorstLimit );
299  if ( pMatch->pSuperBest == NULL || pMatch->tArrive.Worst > fWorstLimit + p->fEpsilon )
300  continue;
301 
302  // if the cut can be matched compare the matchings
303  if ( Map_MatchCompare( p, &MatchBest, pMatch, p->fMappingMode ) )
304  {
305  pCutBest = pCut;
306  MatchBest = *pMatch;
307  // if we are mapping for delay, the worst-case limit should be tightened
308  if ( p->fMappingMode == 0 )
309  fWorstLimit = MatchBest.tArrive.Worst;
310  }
311  }
312 
313  if ( pCutBest == NULL )
314  return 1;
315 
316  // set the new mapping
317  pNode->pCutBest[fPhase] = pCutBest;
318  pCutBest->M[fPhase] = MatchBest;
319 
320  // reference the new cut if it used
321  if ( p->fMappingMode >= 2 &&
322  (pNode->nRefAct[fPhase] > 0 ||
323  (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0)) )
324  {
325  if ( p->fMappingMode == 2 || p->fMappingMode == 3 )
326  Area2 = Map_CutRef( pNode->pCutBest[fPhase], fPhase );
327  else if ( p->fMappingMode == 4 )
328  Area2 = Map_SwitchCutRef( pNode, pNode->pCutBest[fPhase], fPhase );
329  else
330  assert( 0 );
331 // assert( Area2 < Area1 + p->fEpsilon );
332  }
333 
334  // make sure that the requited times are met
335 // assert( MatchBest.tArrive.Rise < pNode->tRequired[fPhase].Rise + p->fEpsilon );
336 // assert( MatchBest.tArrive.Fall < pNode->tRequired[fPhase].Fall + p->fEpsilon );
337  return 1;
338 }
float Map_CutDeref(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:384
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
float Map_SwitchCutRef(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
Definition: mapperSwitch.c:66
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Time_t tRequired[2]
Definition: mapperInt.h:236
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
int Map_MatchCompare(Map_Man_t *pMan, Map_Match_t *pM1, Map_Match_t *pM2, int fDoingArea)
Definition: mapperMatch.c:74
Map_Cut_t * pNext
Definition: mapperInt.h:262
Map_Super_t * pSupers
Definition: mapperInt.h:249
float Map_CutGetAreaDerefed(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:348
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
float Map_CutRef(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:368
Map_Time_t tArrive
Definition: mapperInt.h:255
Map_Cut_t * pCuts
Definition: mapperInt.h:240
ABC_NAMESPACE_IMPL_START void Map_MatchClean(Map_Match_t *pMatch)
DECLARATIONS ///.
Definition: mapperMatch.c:54
float Map_TimeCutComputeArrival(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, float tWorstCaseLimit)
Definition: mapperTime.c:72
float Map_SwitchCutDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
Definition: mapperSwitch.c:82
float Map_SwitchCutGetDerefed(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
FUNCTION DEFINITIONS ///.
Definition: mapperSwitch.c:45
int Map_MatchNodeCut(Map_Man_t *p, Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, float fWorstLimit)
Definition: mapperMatch.c:143
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
void Map_NodeTransferArrivalTimes ( Map_Man_t p,
Map_Node_t pNode 
)

Function*************************************************************

Synopsis [Transfers the arrival times from the best cuts to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 503 of file mapperMatch.c.

504 {
505  // if both phases are available, set their arrival times
506  if ( pNode->pCutBest[0] && pNode->pCutBest[1] )
507  {
508  pNode->tArrival[0] = pNode->pCutBest[0]->M[0].tArrive;
509  pNode->tArrival[1] = pNode->pCutBest[1]->M[1].tArrive;
510  }
511  // if only one phase is available, compute the arrival time of other phase
512  else if ( pNode->pCutBest[0] )
513  {
514  pNode->tArrival[0] = pNode->pCutBest[0]->M[0].tArrive;
515  pNode->tArrival[1].Rise = pNode->tArrival[0].Fall + p->pSuperLib->tDelayInv.Rise;
516  pNode->tArrival[1].Fall = pNode->tArrival[0].Rise + p->pSuperLib->tDelayInv.Fall;
517  pNode->tArrival[1].Worst = MAP_MAX(pNode->tArrival[1].Rise, pNode->tArrival[1].Fall);
518  }
519  else if ( pNode->pCutBest[1] )
520  {
521  pNode->tArrival[1] = pNode->pCutBest[1]->M[1].tArrive;
522  pNode->tArrival[0].Rise = pNode->tArrival[1].Fall + p->pSuperLib->tDelayInv.Rise;
523  pNode->tArrival[0].Fall = pNode->tArrival[1].Rise + p->pSuperLib->tDelayInv.Fall;
524  pNode->tArrival[0].Worst = MAP_MAX(pNode->tArrival[0].Rise, pNode->tArrival[0].Fall);
525  }
526  else
527  {
528  assert( 0 );
529  }
530 
531 // assert( pNode->tArrival[0].Rise < pNode->tRequired[0].Rise + p->fEpsilon );
532 // assert( pNode->tArrival[0].Fall < pNode->tRequired[0].Fall + p->fEpsilon );
533 
534 // assert( pNode->tArrival[1].Rise < pNode->tRequired[1].Rise + p->fEpsilon );
535 // assert( pNode->tArrival[1].Fall < pNode->tRequired[1].Fall + p->fEpsilon );
536 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
Map_Time_t tArrive
Definition: mapperInt.h:255
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
void Map_NodeTryDroppingOnePhase ( Map_Man_t p,
Map_Node_t pNode 
)

Function*************************************************************

Synopsis [Attempts dropping one phase of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 401 of file mapperMatch.c.

402 {
403  Map_Match_t * pMatchBest0, * pMatchBest1;
404  float tWorst0Using1, tWorst1Using0;
405  int fUsePhase1, fUsePhase0;
406 
407  // nothing to do if one of the phases is already dropped
408  if ( pNode->pCutBest[0] == NULL || pNode->pCutBest[1] == NULL )
409  return;
410 
411  // do not drop while recovering area flow
412  if ( p->fMappingMode == 1 )//|| p->fMappingMode == 2 )
413  return;
414 
415  // get the pointers to the matches of the best cuts
416  pMatchBest0 = pNode->pCutBest[0]->M + 0;
417  pMatchBest1 = pNode->pCutBest[1]->M + 1;
418 
419  // get the worst arrival times of each phase
420  // implemented using the other phase with inverter added
421  tWorst0Using1 = Map_TimeMatchWithInverter( p, pMatchBest1 );
422  tWorst1Using0 = Map_TimeMatchWithInverter( p, pMatchBest0 );
423 
424  // consider the case of mapping for delay
425  if ( p->fMappingMode == 0 && p->DelayTarget < ABC_INFINITY )
426  {
427  // if the arrival time of a phase is larger than the arrival time
428  // of the opposite phase plus the inverter, drop this phase
429  if ( pMatchBest0->tArrive.Worst > tWorst0Using1 + p->fEpsilon )
430  pNode->pCutBest[0] = NULL;
431  else if ( pMatchBest1->tArrive.Worst > tWorst1Using0 + p->fEpsilon )
432  pNode->pCutBest[1] = NULL;
433  return;
434  }
435 
436  // do not perform replacement if one of the phases is unused
437  if ( pNode->nRefAct[0] == 0 || pNode->nRefAct[1] == 0 )
438  return;
439 
440  // check if replacement of each phase is possible using required times
441  fUsePhase0 = fUsePhase1 = 0;
442  if ( p->fMappingMode == 2 )
443  {
444  fUsePhase0 = (pNode->tRequired[1].Worst > tWorst1Using0 + 3*p->pSuperLib->tDelayInv.Worst + p->fEpsilon);
445  fUsePhase1 = (pNode->tRequired[0].Worst > tWorst0Using1 + 3*p->pSuperLib->tDelayInv.Worst + p->fEpsilon);
446  }
447  else if ( p->fMappingMode == 3 || p->fMappingMode == 4 )
448  {
449  fUsePhase0 = (pNode->tRequired[1].Worst > tWorst1Using0 + p->fEpsilon);
450  fUsePhase1 = (pNode->tRequired[0].Worst > tWorst0Using1 + p->fEpsilon);
451  }
452  if ( !fUsePhase0 && !fUsePhase1 )
453  return;
454 
455  // if replacement is possible both ways, use the one that works better
456  if ( fUsePhase0 && fUsePhase1 )
457  {
458  if ( pMatchBest0->AreaFlow < pMatchBest1->AreaFlow )
459  fUsePhase1 = 0;
460  else
461  fUsePhase0 = 0;
462  }
463  // only one phase should be used
464  assert( fUsePhase0 ^ fUsePhase1 );
465 
466  // set the corresponding cut to NULL
467  if ( fUsePhase0 )
468  {
469  // deref phase 1 cut if necessary
470  if ( p->fMappingMode >= 2 && pNode->nRefAct[1] > 0 )
471  Map_CutDeref( pNode->pCutBest[1], 1 );
472  // get rid of the cut
473  pNode->pCutBest[1] = NULL;
474  // ref phase 0 cut if necessary
475  if ( p->fMappingMode >= 2 && pNode->nRefAct[0] == 0 )
476  Map_CutRef( pNode->pCutBest[0], 0 );
477  }
478  else
479  {
480  // deref phase 0 cut if necessary
481  if ( p->fMappingMode >= 2 && pNode->nRefAct[0] > 0 )
482  Map_CutDeref( pNode->pCutBest[0], 0 );
483  // get rid of the cut
484  pNode->pCutBest[0] = NULL;
485  // ref phase 1 cut if necessary
486  if ( p->fMappingMode >= 2 && pNode->nRefAct[1] == 0 )
487  Map_CutRef( pNode->pCutBest[1], 1 );
488  }
489 }
float Map_CutDeref(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:384
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Time_t tRequired[2]
Definition: mapperInt.h:236
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
float Map_CutRef(Map_Cut_t *pCut, int fPhase)
Definition: mapperRefs.c:368
Map_Time_t tArrive
Definition: mapperInt.h:255
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
float Map_TimeMatchWithInverter(Map_Man_t *p, Map_Match_t *pMatch)
Definition: mapperMatch.c:381
Map_Match_t M[2]
Definition: mapperInt.h:271
float Map_TimeMatchWithInverter ( Map_Man_t p,
Map_Match_t pMatch 
)

function*************************************************************

synopsis [Computes the exact area associated with the cut.]

description []

sideeffects []

seealso []

Definition at line 381 of file mapperMatch.c.

382 {
383  Map_Time_t tArrInv;
384  tArrInv.Fall = pMatch->tArrive.Rise + p->pSuperLib->tDelayInv.Fall;
385  tArrInv.Rise = pMatch->tArrive.Fall + p->pSuperLib->tDelayInv.Rise;
386  tArrInv.Worst = MAP_MAX( tArrInv.Rise, tArrInv.Fall );
387  return tArrInv.Worst;
388 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Time_t tArrive
Definition: mapperInt.h:255
#define MAP_MAX(a, b)
Definition: mapperInt.h:57