abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ifMap.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [ifMap.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [FPGA mapping based on priority cuts.]
8 
9  Synopsis [Mapping procedures.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - November 21, 2006.]
16 
17  Revision [$Id: ifMap.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "if.h"
22 
23 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 extern char * Dau_DsdMerge( char * pDsd0i, int * pPerm0, char * pDsd1i, int * pPerm1, int fCompl0, int fCompl1, int nVars );
31 extern int If_CutDelayRecCost3(If_Man_t* p, If_Cut_t* pCut, If_Obj_t * pObj);
32 
33 ////////////////////////////////////////////////////////////////////////
34 /// FUNCTION DEFINITIONS ///
35 ////////////////////////////////////////////////////////////////////////
36 
37 /**Function*************************************************************
38 
39  Synopsis [Counts the number of 1s in the signature.]
40 
41  Description []
42 
43  SideEffects []
44 
45  SeeAlso []
46 
47 ***********************************************************************/
48 static inline int If_WordCountOnes( unsigned uWord )
49 {
50  uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
51  uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
52  uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
53  uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
54  return (uWord & 0x0000FFFF) + (uWord>>16);
55 }
56 
57 /**Function*************************************************************
58 
59  Synopsis [Counts the number of 1s in the signature.]
60 
61  Description []
62 
63  SideEffects []
64 
65  SeeAlso []
66 
67 ***********************************************************************/
68 float If_CutDelaySpecial( If_Man_t * p, If_Cut_t * pCut, int fCarry )
69 {
70  static float Pin2Pin[2][3] = { {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0} };
71  If_Obj_t * pLeaf;
72  float DelayCur, Delay = -IF_FLOAT_LARGE;
73  int i;
74  assert( pCut->nLeaves <= 3 );
75  If_CutForEachLeaf( p, pCut, pLeaf, i )
76  {
77  DelayCur = If_ObjCutBest(pLeaf)->Delay;
78  Delay = IF_MAX( Delay, Pin2Pin[fCarry][i] + DelayCur );
79  }
80  return Delay;
81 }
82 
83 
84 /**Function*************************************************************
85 
86  Synopsis [Finds the best cut for the given node.]
87 
88  Description [Mapping modes: delay (0), area flow (1), area (2).]
89 
90  SideEffects []
91 
92  SeeAlso []
93 
94 ***********************************************************************/
95 void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess, int fFirst )
96 {
97  If_Set_t * pCutSet;
98  If_Cut_t * pCut0, * pCut1, * pCut;
99  If_Cut_t * pCut0R, * pCut1R;
100  int fFunc0R, fFunc1R;
101  int i, k, v, iCutDsd, fChange;
102  int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->pLutStruct != NULL;
103  assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
104  assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
105 
106  // prepare
107  if ( Mode == 0 )
108  pObj->EstRefs = (float)pObj->nRefs;
109  else if ( Mode == 1 )
110  pObj->EstRefs = (float)((2.0 * pObj->EstRefs + pObj->nRefs) / 3.0);
111  // deref the selected cut
112  if ( Mode && pObj->nRefs > 0 )
113  If_CutAreaDeref( p, If_ObjCutBest(pObj) );
114 
115  // prepare the cutset
116  pCutSet = If_ManSetupNodeCutSet( p, pObj );
117 
118  // get the current assigned best cut
119  pCut = If_ObjCutBest(pObj);
120  if ( !fFirst )
121  {
122  // recompute the parameters of the best cut
123  if ( p->pPars->fDelayOpt )
124  pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
125  else if ( p->pPars->fDsdBalance )
126  pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
127  else if ( p->pPars->fUserRecLib )
128  pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
129  else if ( p->pPars->fDelayOptLut )
130  pCut->Delay = If_CutLutBalanceEval( p, pCut );
131  else if( p->pPars->nGateSize > 0 )
132  pCut->Delay = If_CutDelaySop( p, pCut );
133  else
134  pCut->Delay = If_CutDelay( p, pObj, pCut );
135  assert( pCut->Delay != -1 );
136 // assert( pCut->Delay <= pObj->Required + p->fEpsilon );
137  if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
138  Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
139  pObj->Id, pCut->Delay, pObj->Required + p->fEpsilon );
140  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
141  if ( p->pPars->fEdge )
142  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
143  if ( p->pPars->fPower )
144  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
145  // save the best cut from the previous iteration
146  if ( !fPreprocess )
147  If_CutCopy( p, pCutSet->ppCuts[pCutSet->nCuts++], pCut );
148  }
149 
150  // generate cuts
151  If_ObjForEachCut( pObj->pFanin0, pCut0, i )
152  If_ObjForEachCut( pObj->pFanin1, pCut1, k )
153  {
154  // get the next free cut
155  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
156  pCut = pCutSet->ppCuts[pCutSet->nCuts];
157  // make sure K-feasible cut exists
158  if ( If_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->pPars->nLutSize )
159  continue;
160 
161  pCut0R = pCut0;
162  pCut1R = pCut1;
163  fFunc0R = pCut0->iCutFunc ^ pCut0->fCompl ^ pObj->fCompl0;
164  fFunc1R = pCut1->iCutFunc ^ pCut1->fCompl ^ pObj->fCompl1;
165  if ( !p->pPars->fUseTtPerm || pCut0->nLeaves > pCut1->nLeaves || (pCut0->nLeaves == pCut1->nLeaves && fFunc0R > fFunc1R) )
166  {
167  }
168  else
169  {
170  ABC_SWAP( If_Cut_t *, pCut0R, pCut1R );
171  ABC_SWAP( int, fFunc0R, fFunc1R );
172  }
173 
174  // merge the cuts
175  if ( p->pPars->fUseTtPerm )
176  {
177  if ( !If_CutMerge( p, pCut0R, pCut1R, pCut ) )
178  continue;
179  }
180  else
181  {
182  if ( !If_CutMergeOrdered( p, pCut0, pCut1, pCut ) )
183  continue;
184  }
185  if ( pObj->fSpec && pCut->nLeaves == (unsigned)p->pPars->nLutSize )
186  continue;
187  p->nCutsMerged++;
188  p->nCutsTotal++;
189  // check if this cut is contained in any of the available cuts
190  if ( !p->pPars->fSkipCutFilter && If_CutFilter( pCutSet, pCut, fSave0 ) )
191  continue;
192  // compute the truth table
193  pCut->iCutFunc = -1;
194  pCut->fCompl = 0;
195  if ( p->pPars->fTruth )
196  {
197 // int nShared = pCut0->nLeaves + pCut1->nLeaves - pCut->nLeaves;
198  abctime clk = 0;
199  if ( p->pPars->fVerbose )
200  clk = Abc_Clock();
201  if ( p->pPars->fUseTtPerm )
202  fChange = If_CutComputeTruthPerm( p, pCut, pCut0R, pCut1R, fFunc0R, fFunc1R );
203  else
204  fChange = If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
205  if ( p->pPars->fVerbose )
206  p->timeCache[4] += Abc_Clock() - clk;
207  if ( !p->pPars->fSkipCutFilter && fChange && If_CutFilter( pCutSet, pCut, fSave0 ) )
208  continue;
209  if ( p->pPars->fUseDsd )
210  {
211  extern void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd );
212  int truthId = Abc_Lit2Var(pCut->iCutFunc);
213  if ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) || Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId) == -1 )
214  {
215  while ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) )
216  {
217  Vec_IntPush( p->vTtDsds[pCut->nLeaves], -1 );
218  for ( v = 0; v < Abc_MaxInt(6, pCut->nLeaves); v++ )
219  Vec_StrPush( p->vTtPerms[pCut->nLeaves], IF_BIG_CHAR );
220  }
221  iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthWR(p, pCut), pCut->nLeaves, (unsigned char *)If_CutDsdPerm(p, pCut), p->pPars->pLutStruct );
222  Vec_IntWriteEntry( p->vTtDsds[pCut->nLeaves], truthId, iCutDsd );
223  }
224  assert( If_DsdManSuppSize(p->pIfDsdMan, If_CutDsdLit(p, pCut)) == (int)pCut->nLeaves );
225  //If_ManCacheRecord( p, If_CutDsdLit(p, pCut0), If_CutDsdLit(p, pCut1), nShared, If_CutDsdLit(p, pCut) );
226  }
227  // run user functions
228  pCut->fUseless = 0;
229  if ( p->pPars->pFuncCell )
230  {
231  assert( p->pPars->fUseTtPerm == 0 );
232  assert( pCut->nLimit >= 4 && pCut->nLimit <= 16 );
233  if ( p->pPars->fUseDsd )
234  pCut->fUseless = If_DsdManCheckDec( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
235  else
236  pCut->fUseless = !p->pPars->pFuncCell( p, If_CutTruth(p, pCut), Abc_MaxInt(6, pCut->nLeaves), pCut->nLeaves, p->pPars->pLutStruct );
237  p->nCutsUselessAll += pCut->fUseless;
238  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
239  p->nCutsCountAll++;
240  p->nCutsCount[pCut->nLeaves]++;
241  // skip 5-input cuts, which cannot be decomposed
242  if ( (p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u) && pCut->nLeaves == 5 && pCut->nLimit == 5 )
243  {
244  extern int If_CluCheckDecInAny( word t, int nVars );
245  extern int If_CluCheckDecOut( word t, int nVars );
246  unsigned TruthU = *If_CutTruth(p, pCut);
247  word Truth = (((word)TruthU << 32) | (word)TruthU);
248  p->nCuts5++;
249  if ( If_CluCheckDecInAny( Truth, 5 ) )
250  p->nCuts5a++;
251  else
252  continue;
253  }
254  else if ( p->pPars->fVerbose && pCut->nLeaves == 5 )
255  {
256  extern int If_CluCheckDecInAny( word t, int nVars );
257  extern int If_CluCheckDecOut( word t, int nVars );
258  unsigned TruthU = *If_CutTruth(p, pCut);
259  word Truth = (((word)TruthU << 32) | (word)TruthU);
260  p->nCuts5++;
261  if ( If_CluCheckDecInAny( Truth, 5 ) || If_CluCheckDecOut( Truth, 5 ) )
262  p->nCuts5a++;
263  }
264  }
265  else if ( p->pPars->fUseDsdTune )
266  {
267  pCut->fUseless = If_DsdManReadMark( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
268  p->nCutsUselessAll += pCut->fUseless;
269  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
270  p->nCutsCountAll++;
271  p->nCutsCount[pCut->nLeaves]++;
272  }
273  else
274  {
275  if ( p->pPars->fUseAndVars )
276  {
277  int iDecMask = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
278  if ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) || Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId) == -1 )
279  {
280  while ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) )
281  Vec_IntPush( p->vTtDecs[pCut->nLeaves], -1 );
282  if ( (int)pCut->nLeaves > p->pPars->nLutSize / 2 )
283  iDecMask = Abc_TtProcessBiDec( If_CutTruthW(p, pCut), (int)pCut->nLeaves, p->pPars->nLutSize / 2 );
284  else
285  iDecMask = 0;
286  Vec_IntWriteEntry( p->vTtDecs[pCut->nLeaves], truthId, iDecMask );
287  }
288  iDecMask = Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId);
289  assert( iDecMask >= 0 );
290  pCut->fUseless = (int)(iDecMask == 0 && (int)pCut->nLeaves > p->pPars->nLutSize / 2);
291  p->nCutsUselessAll += pCut->fUseless;
292  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
293  p->nCutsCountAll++;
294  p->nCutsCount[pCut->nLeaves]++;
295  }
296  if ( p->pPars->fUseCofVars && (!p->pPars->fUseAndVars || pCut->fUseless) )
297  {
298  int iCofVar = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
299  if ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) || Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId) == (char)-1 )
300  {
301  while ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) )
302  Vec_StrPush( p->vTtVars[pCut->nLeaves], (char)-1 );
303  iCofVar = Abc_TtCheckCondDep( If_CutTruthWR(p, pCut), pCut->nLeaves, p->pPars->nLutSize / 2 );
304  Vec_StrWriteEntry( p->vTtVars[pCut->nLeaves], truthId, (char)iCofVar );
305  }
306  iCofVar = Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId);
307  assert( iCofVar >= 0 && iCofVar <= (int)pCut->nLeaves );
308  pCut->fUseless = (int)(iCofVar == (int)pCut->nLeaves && pCut->nLeaves > 0);
309  p->nCutsUselessAll += pCut->fUseless;
310  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
311  p->nCutsCountAll++;
312  p->nCutsCount[pCut->nLeaves]++;
313  }
314  }
315  }
316 
317  // compute the application-specific cost and depth
318  pCut->fUser = (p->pPars->pFuncCost != NULL);
319  pCut->Cost = p->pPars->pFuncCost? p->pPars->pFuncCost(p, pCut) : 0;
320  if ( pCut->Cost == IF_COST_MAX )
321  continue;
322  // check if the cut satisfies the required times
323  if ( p->pPars->fDelayOpt )
324  {
325  pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
326 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
327 // pCut->Delay += 1;
328  }
329  else if ( p->pPars->fDsdBalance )
330  {
331  pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
332 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
333 // pCut->Delay += 1;
334  }
335  else if ( p->pPars->fUserRecLib )
336  {
337  pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
338 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
339 // pCut->Delay += 1;
340  }
341  else if ( p->pPars->fDelayOptLut )
342  pCut->Delay = If_CutLutBalanceEval( p, pCut );
343  else if( p->pPars->nGateSize > 0 )
344  pCut->Delay = If_CutDelaySop( p, pCut );
345  else
346  pCut->Delay = If_CutDelay( p, pObj, pCut );
347  if ( pCut->Delay == -1 )
348  continue;
349  if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
350  continue;
351  // compute area of the cut (this area may depend on the application specific cost)
352  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
353  if ( p->pPars->fEdge )
354  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
355  if ( p->pPars->fPower )
356  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
357 // pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
358  // insert the cut into storage
359  If_CutSort( p, pCutSet, pCut );
360 // If_CutTraverse( p, pObj, pCut );
361  }
362  assert( pCutSet->nCuts > 0 );
363 // If_CutVerifyCuts( pCutSet, !p->pPars->fUseTtPerm );
364 
365  // update the best cut
366  if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
367  {
368  If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
369  if(p->pPars->fUserRecLib)
370  assert(If_ObjCutBest(pObj)->Cost < IF_COST_MAX && If_ObjCutBest(pObj)->Delay < ABC_INFINITY);
371  }
372  // add the trivial cut to the set
373  if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
374  {
375  If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
376  assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
377  }
378 // if ( If_ObjCutBest(pObj)->nLeaves == 0 )
379 // p->nBestCutSmall[0]++;
380 // else if ( If_ObjCutBest(pObj)->nLeaves == 1 )
381 // p->nBestCutSmall[1]++;
382 
383  // ref the selected cut
384  if ( Mode && pObj->nRefs > 0 )
385  If_CutAreaRef( p, If_ObjCutBest(pObj) );
386  if ( If_ObjCutBest(pObj)->fUseless )
387  Abc_Print( 1, "The best cut is useless.\n" );
388  // call the user specified function for each cut
389  if ( p->pPars->pFuncUser )
390  If_ObjForEachCut( pObj, pCut, i )
391  p->pPars->pFuncUser( p, pObj, pCut );
392  // free the cuts
393  If_ManDerefNodeCutSet( p, pObj );
394 }
395 
396 /**Function*************************************************************
397 
398  Synopsis [Finds the best cut for the choice node.]
399 
400  Description []
401 
402  SideEffects []
403 
404  SeeAlso []
405 
406 ***********************************************************************/
407 void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess )
408 {
409  If_Set_t * pCutSet;
410  If_Obj_t * pTemp;
411  If_Cut_t * pCutTemp, * pCut;
412  int i, fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib;
413  assert( pObj->pEquiv != NULL );
414 
415  // prepare
416  if ( Mode && pObj->nRefs > 0 )
417  If_CutAreaDeref( p, If_ObjCutBest(pObj) );
418 
419  // remove elementary cuts
420  for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
421  pTemp->pCutSet->nCuts--;
422 
423  // update the cutset of the node
424  pCutSet = pObj->pCutSet;
425 
426  // generate cuts
427  for ( pTemp = pObj->pEquiv; pTemp; pTemp = pTemp->pEquiv )
428  {
429  if ( pTemp->pCutSet->nCuts == 0 )
430  continue;
431  // go through the cuts of this node
432  If_ObjForEachCut( pTemp, pCutTemp, i )
433  {
434  if ( pCutTemp->fUseless )
435  continue;
436  // get the next free cut
437  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
438  pCut = pCutSet->ppCuts[pCutSet->nCuts];
439  // copy the cut into storage
440  If_CutCopy( p, pCut, pCutTemp );
441  // check if this cut is contained in any of the available cuts
442  if ( If_CutFilter( pCutSet, pCut, fSave0 ) )
443  continue;
444  // check if the cut satisfies the required times
445 // assert( pCut->Delay == If_CutDelay( p, pTemp, pCut ) );
446  if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
447  continue;
448  // set the phase attribute
449  pCut->fCompl = pObj->fPhase ^ pTemp->fPhase;
450  // compute area of the cut (this area may depend on the application specific cost)
451  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
452  if ( p->pPars->fEdge )
453  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
454  if ( p->pPars->fPower )
455  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
456 // pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
457  // insert the cut into storage
458  If_CutSort( p, pCutSet, pCut );
459  }
460  }
461  assert( pCutSet->nCuts > 0 );
462 
463  // update the best cut
464  if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
465  If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
466  // add the trivial cut to the set
467  if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
468  {
469  If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
470  assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
471  }
472 
473  // ref the selected cut
474  if ( Mode && pObj->nRefs > 0 )
475  If_CutAreaRef( p, If_ObjCutBest(pObj) );
476  // free the cuts
477  If_ManDerefChoiceCutSet( p, pObj );
478 }
479 
480 /**Function*************************************************************
481 
482  Synopsis [Performs one mapping pass over all nodes.]
483 
484  Description []
485 
486  SideEffects []
487 
488  SeeAlso []
489 
490 ***********************************************************************/
491 int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char * pLabel )
492 {
493 // ProgressBar * pProgress;
494  If_Obj_t * pObj;
495  int i;
496  abctime clk = Abc_Clock();
497  float arrTime;
498  assert( Mode >= 0 && Mode <= 2 );
499  p->nBestCutSmall[0] = p->nBestCutSmall[1] = 0;
500  // set the sorting function
501  if ( Mode || p->pPars->fArea ) // area
502  p->SortMode = 1;
503  else if ( p->pPars->fFancy )
504  p->SortMode = 2;
505  else
506  p->SortMode = 0;
507  // set the cut number
508  p->nCutsUsed = nCutsUsed;
509  p->nCutsMerged = 0;
510  // make sure the visit counters are all zero
511  If_ManForEachNode( p, pObj, i )
512  assert( pObj->nVisits == pObj->nVisitsCopy );
513  // map the internal nodes
514  if ( p->pManTim != NULL )
515  {
517  If_ManForEachObj( p, pObj, i )
518  {
519  if ( If_ObjIsAnd(pObj) )
520  {
521  If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
522  if ( pObj->fRepr )
523  If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
524  }
525  else if ( If_ObjIsCi(pObj) )
526  {
527 //Abc_Print( 1, "processing CI %d\n", pObj->Id );
528  arrTime = Tim_ManGetCiArrival( p->pManTim, pObj->IdPio );
529  If_ObjSetArrTime( pObj, arrTime );
530  }
531  else if ( If_ObjIsCo(pObj) )
532  {
533  arrTime = If_ObjArrTime( If_ObjFanin0(pObj) );
534  Tim_ManSetCoArrival( p->pManTim, pObj->IdPio, arrTime );
535  }
536  else if ( If_ObjIsConst1(pObj) )
537  {
538  }
539  else
540  assert( 0 );
541  }
542 // Tim_ManPrint( p->pManTim );
543  }
544  else
545  {
546  // pProgress = Extra_ProgressBarStart( stdout, If_ManObjNum(p) );
547  If_ManForEachNode( p, pObj, i )
548  {
549  // Extra_ProgressBarUpdate( pProgress, i, pLabel );
550  If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
551  if ( pObj->fRepr )
552  If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
553  }
554  }
555 // Extra_ProgressBarStop( pProgress );
556  // make sure the visit counters are all zero
557  If_ManForEachNode( p, pObj, i )
558  assert( pObj->nVisits == 0 );
559  // compute required times and stats
561 // Tim_ManPrint( p->pManTim );
562  if ( p->pPars->fVerbose )
563  {
564  char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
565  Abc_Print( 1, "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. ",
566  Symb, p->RequiredGlo, p->AreaGlo, p->nNets );
567  if ( p->dPower )
568  Abc_Print( 1, "Switch = %7.2f. ", p->dPower );
569  Abc_Print( 1, "Cut = %8d. ", p->nCutsMerged );
570  Abc_PrintTime( 1, "T", Abc_Clock() - clk );
571 // Abc_Print( 1, "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
572 // p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
573  }
574  return 1;
575 }
576 
577 
578 ////////////////////////////////////////////////////////////////////////
579 /// END OF FILE ///
580 ////////////////////////////////////////////////////////////////////////
581 
582 
584 
If_Obj_t * pFanin0
Definition: if.h:321
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
#define IF_MAX(a, b)
Definition: if.h:437
int If_DsdManCheckDec(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:185
If_Set_t * pCutSet
Definition: if.h:332
unsigned nLeaves
Definition: if.h:289
int Id
Definition: if.h:316
float If_CutPowerFlow(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:979
float dPower
Definition: if.h:200
int If_DsdManCompute(If_DsdMan_t *p, word *pTruth, int nLeaves, unsigned char *pPerm, char *pLutStruct)
Definition: ifDsd.c:2032
int nBestCutSmall[2]
Definition: if.h:258
int nCutsUsed
Definition: if.h:201
int If_CutMerge(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition: ifCut.c:364
unsigned nLimit
Definition: if.h:288
Vec_Str_t * vTtVars[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:248
#define If_ManForEachNode(p, pObj, i)
Definition: if.h:468
int nLutSize
Definition: if.h:103
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition: timTrav.c:44
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float Edge
Definition: if.h:278
float If_CutAreaFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:919
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Int_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:249
int If_CluCheckDecOut(word t, int nVars)
Definition: ifDec16.c:1840
Definition: if.h:303
#define IF_BIG_CHAR
Definition: if.h:60
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
Definition: if.h:275
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
float Required
Definition: if.h:325
unsigned fRepr
Definition: if.h:309
int fDelayOptLut
Definition: if.h:122
int fVerbose
Definition: if.h:140
void If_ManComputeRequired(If_Man_t *p)
Definition: ifTime.c:294
int fSkipCutFilter
Definition: if.h:144
int nCutsCountAll
Definition: if.h:240
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:116
static void If_CutCopy(If_Man_t *p, If_Cut_t *pDst, If_Cut_t *pSrc)
Definition: if.h:398
char * pLutStruct
Definition: if.h:141
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
int nCutsMerged
Definition: if.h:202
float If_CutDelaySpecial(If_Man_t *p, If_Cut_t *pCut, int fCarry)
Definition: ifMap.c:68
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:247
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
int nCutsTotal
Definition: if.h:237
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
Definition: if.h:163
static int Abc_TtProcessBiDec(word *pTruth, int nVars, int nSuppLim)
Definition: utilTruth.h:2431
static int If_WordCountOnes(unsigned uWord)
FUNCTION DEFINITIONS ///.
Definition: ifMap.c:48
unsigned fUser
Definition: if.h:286
float If_CutEdgeDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1187
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int(* pFuncUser)(If_Man_t *, If_Obj_t *, If_Cut_t *)
Definition: if.h:164
ABC_NAMESPACE_IMPL_START void If_ManCacheRecord(If_Man_t *p, int iDsd0, int iDsd1, int nShared, int iDsd)
DECLARATIONS ///.
Definition: ifCache.c:45
void If_ObjPerformMappingAnd(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
Definition: ifMap.c:95
for(p=first;p->value< newval;p=p->next)
int nRefs
Definition: if.h:318
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
int fUseCofVars
Definition: if.h:135
int fEnableCheck75u
Definition: if.h:132
#define If_ObjForEachCut(pObj, pCut, i)
Definition: if.h:471
int nCuts5a
Definition: if.h:242
int nCuts5
Definition: if.h:242
Tim_Man_t * pManTim
Definition: if.h:263
int nGateSize
Definition: if.h:107
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
unsigned Cost
Definition: if.h:284
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
If_Set_t * If_ManSetupNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:579
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
int fEnableCheck75
Definition: if.h:131
float AreaGlo
Definition: if.h:198
int fEdge
Definition: if.h:118
int nCutsUseless[32]
Definition: if.h:238
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
int If_CutDelayRecCost3(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj)
Definition: abcRec3.c:1004
float Power
Definition: if.h:279
int fDsdBalance
Definition: if.h:123
float RequiredGlo
Definition: if.h:196
int fTruth
Definition: if.h:146
static word * If_CutTruthWR(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:419
Definition: if.h:180
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition: ifMan.c:499
float If_CutAreaDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1086
if(last==0)
Definition: sparse_int.h:34
unsigned fSkipCut
Definition: if.h:314
int nCutsUselessAll
Definition: if.h:241
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
int If_CluCheckDecInAny(word t, int nVars)
Definition: ifDec16.c:1767
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
If_Obj_t * pFanin1
Definition: if.h:322
static void If_ObjSetArrTime(If_Obj_t *pObj, float ArrTime)
Definition: if.h:406
int If_CutMergeOrdered(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition: ifCut.c:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
If_Obj_t * pEquiv
Definition: if.h:323
int fUseAndVars
Definition: if.h:136
int If_CutSopBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDelay.c:248
float fEpsilon
Definition: if.h:195
int If_CutComputeTruth(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition: ifTruth.c:98
int If_DsdManSuppSize(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:181
int nVisitsCopy
Definition: if.h:320
static float If_ObjArrTime(If_Obj_t *pObj)
Definition: if.h:405
abctime timeCache[6]
Definition: if.h:257
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
int fFancy
Definition: if.h:115
#define IF_FLOAT_LARGE
Definition: if.h:440
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
int fUseDsd
Definition: if.h:133
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
If_Par_t * pPars
Definition: if.h:184
#define IF_COST_MAX
Definition: if.h:58
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:246
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
short nCuts
Definition: if.h:297
float If_CutDelay(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition: ifTime.c:91
int(* pFuncCell)(If_Man_t *, unsigned *, int, int, char *)
Definition: if.h:165
int If_CutFilter(If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
Definition: ifCut.c:146
int fUseDsdTune
Definition: if.h:134
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
static int Abc_TtCheckCondDep(word *pTruth, int nVars, int nSuppLim)
Definition: utilTruth.h:1055
int fUserRecLib
Definition: if.h:124
int fPower
Definition: if.h:119
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int fDelayOpt
Definition: if.h:121
Definition: if.h:294
unsigned uSign
Definition: if.h:283
int nVisits
Definition: if.h:319
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
int fUseTtPerm
Definition: if.h:137
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
int nCutsCount[32]
Definition: if.h:239
int nNets
Definition: if.h:199
If_Cut_t ** ppCuts
Definition: if.h:299
int If_CutDsdBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDsd.c:2288
unsigned fCompl
Definition: if.h:285
int SortMode
Definition: if.h:205
unsigned fSpec
Definition: if.h:312
int If_CutLutBalanceEval(If_Man_t *p, If_Cut_t *pCut)
Definition: ifDelay.c:369
int fArea
Definition: if.h:114
ABC_INT64_T abctime
Definition: abc_global.h:278
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition: timTime.c:174
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
ABC_NAMESPACE_IMPL_START char * Dau_DsdMerge(char *pDsd0i, int *pPerm0, char *pDsd1i, int *pPerm1, int fCompl0, int fCompl1, int nVars)
DECLARATIONS ///.
Definition: dauMerge.c:587
float If_CutEdgeFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:949
unsigned fCompl1
Definition: if.h:307
int If_DsdManReadMark(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:189
unsigned fCompl0
Definition: if.h:306
int iCutFunc
Definition: if.h:281
unsigned fPhase
Definition: if.h:308
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
float Delay
Definition: if.h:280
int If_CutComputeTruthPerm(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition: ifTruth.c:263
float If_CutPowerDerefed(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1290
int If_CutDelaySop(If_Man_t *p, If_Cut_t *pCut)
Definition: ifDelay.c:64
void If_ManDerefNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:602
int IdPio
Definition: if.h:317
void If_ManDerefChoiceCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:645
float Area
Definition: if.h:277
void If_ObjPerformMappingChoice(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
Definition: ifMap.c:407
int If_ManPerformMappingRound(If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
Definition: ifMap.c:491