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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Amap_Cut_t
Amap_ManDupCut (Amap_Man_t *p, Amap_Cut_t *pCut)
 DECLARATIONS ///. More...
 
static void Amap_ManMatchStart (Amap_Mat_t *p, Amap_Cut_t *pCut, Amap_Set_t *pSet)
 
void Amap_ManCleanRefs (Amap_Man_t *p)
 
float Amap_ManMaxDelay (Amap_Man_t *p)
 
void Amap_ManCleanData (Amap_Man_t *p)
 
float Amap_ManComputeMapping_rec (Amap_Man_t *p, Amap_Obj_t *pObj, int fCompl)
 
float Amap_ManComputeMapping (Amap_Man_t *p)
 
int Amap_ManCountInverters (Amap_Man_t *p)
 
static int Amap_CutCompareDelay (Amap_Man_t *p, Amap_Mat_t *pM0, Amap_Mat_t *pM1)
 
static int Amap_CutCompareArea (Amap_Man_t *p, Amap_Mat_t *pM0, Amap_Mat_t *pM1)
 
static float Amap_CutAreaDeref (Amap_Man_t *p, Amap_Mat_t *pM)
 
static float Amap_CutAreaRef (Amap_Man_t *p, Amap_Mat_t *pM)
 
static float Amap_CutAreaDerefed (Amap_Man_t *p, Amap_Obj_t *pNode, Amap_Mat_t *pM)
 
static void Amap_CutAreaTest (Amap_Man_t *p, Amap_Obj_t *pNode)
 
static void Amap_ManMatchGetFlows (Amap_Man_t *p, Amap_Mat_t *pM)
 
static void Amap_ManMatchGetExacts (Amap_Man_t *p, Amap_Obj_t *pNode, Amap_Mat_t *pM)
 
void Amap_ManMatchNode (Amap_Man_t *p, Amap_Obj_t *pNode, int fFlow, int fRefs)
 
void Amap_ManMatch (Amap_Man_t *p, int fFlow, int fRefs)
 
void Amap_ManMap (Amap_Man_t *p)
 

Function Documentation

static float Amap_CutAreaDeref ( Amap_Man_t p,
Amap_Mat_t pM 
)
inlinestatic

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

Synopsis [Counts area while dereferencing the match.]

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file amapMatch.c.

276 {
277  Amap_Obj_t * pFanin;
278  int i, fCompl;
279  float Area = Amap_LibGate( p->pLib, pM->pSet->iGate )->dArea;
280  Amap_MatchForEachFaninCompl( p, pM, pFanin, fCompl, i )
281  {
282  assert( Amap_ObjRefsTotal(pFanin) > 0 );
283  if ( (int)pFanin->fPolar != fCompl && pFanin->nFouts[fCompl] == 1 )
284  Area += p->fAreaInv;
285  if ( --pFanin->nFouts[fCompl] + pFanin->nFouts[!fCompl] == 0 && Amap_ObjIsNode(pFanin) )
286  Area += Amap_CutAreaDeref( p, &pFanin->Best );
287  }
288  return Area;
289 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
Amap_Mat_t Best
Definition: amapInt.h:218
static float Amap_CutAreaDeref(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:275
int nFouts[2]
Definition: amapInt.h:217
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
Definition: amapInt.h:309
static int Amap_ObjIsNode(Amap_Obj_t *pObj)
Definition: amapInt.h:245
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
float fAreaInv
Definition: amapInt.h:82
Amap_Lib_t * pLib
Definition: amapInt.h:79
double dArea
Definition: amapInt.h:156
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
unsigned fPolar
Definition: amapInt.h:205
Amap_Set_t * pSet
Definition: amapInt.h:193
static float Amap_CutAreaDerefed ( Amap_Man_t p,
Amap_Obj_t pNode,
Amap_Mat_t pM 
)
inlinestatic

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

Synopsis [Derives area of the match for a non-referenced node.]

Description []

SideEffects []

SeeAlso []

Definition at line 329 of file amapMatch.c.

330 {
331  float aResult, aResult2;
332  int fComplNew;
333  aResult2 = Amap_CutAreaRef( p, pM );
334  aResult = Amap_CutAreaDeref( p, pM );
335  assert( aResult > aResult2 - p->fEpsilonInternal );
336  assert( aResult < aResult2 + p->fEpsilonInternal );
337  // if node is needed in another polarity, add inverter
338  fComplNew = pM->pCut->fInv ^ pM->pSet->fInv;
339  if ( pNode->nFouts[fComplNew] == 0 && pNode->nFouts[!fComplNew] > 0 )
340  aResult += p->fAreaInv;
341  return aResult;
342 }
unsigned fInv
Definition: amapInt.h:168
static float Amap_CutAreaDeref(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:275
int nFouts[2]
Definition: amapInt.h:217
Amap_Cut_t * pCut
Definition: amapInt.h:192
float fAreaInv
Definition: amapInt.h:82
unsigned fInv
Definition: amapInt.h:186
#define assert(ex)
Definition: util_old.h:213
static float Amap_CutAreaRef(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:302
Amap_Set_t * pSet
Definition: amapInt.h:193
float fEpsilonInternal
Definition: amapInt.h:81
static float Amap_CutAreaRef ( Amap_Man_t p,
Amap_Mat_t pM 
)
inlinestatic

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

Synopsis [Counts area while referencing the match.]

Description []

SideEffects []

SeeAlso []

Definition at line 302 of file amapMatch.c.

303 {
304  Amap_Obj_t * pFanin;
305  int i, fCompl;
306  float Area = Amap_LibGate( p->pLib, pM->pSet->iGate )->dArea;
307  Amap_MatchForEachFaninCompl( p, pM, pFanin, fCompl, i )
308  {
309  assert( Amap_ObjRefsTotal(pFanin) >= 0 );
310  if ( (int)pFanin->fPolar != fCompl && pFanin->nFouts[fCompl] == 0 )
311  Area += p->fAreaInv;
312  if ( pFanin->nFouts[fCompl]++ + pFanin->nFouts[!fCompl] == 0 && Amap_ObjIsNode(pFanin) )
313  Area += Amap_CutAreaRef( p, &pFanin->Best );
314  }
315  return Area;
316 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
Amap_Mat_t Best
Definition: amapInt.h:218
int nFouts[2]
Definition: amapInt.h:217
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
Definition: amapInt.h:309
static int Amap_ObjIsNode(Amap_Obj_t *pObj)
Definition: amapInt.h:245
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
float fAreaInv
Definition: amapInt.h:82
Amap_Lib_t * pLib
Definition: amapInt.h:79
double dArea
Definition: amapInt.h:156
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
static float Amap_CutAreaRef(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:302
unsigned fPolar
Definition: amapInt.h:205
Amap_Set_t * pSet
Definition: amapInt.h:193
static void Amap_CutAreaTest ( Amap_Man_t p,
Amap_Obj_t pNode 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 355 of file amapMatch.c.

356 {
357  float aResult, aResult2;
358  if ( Amap_ObjRefsTotal(pNode) == 0 )
359  {
360  aResult2 = Amap_CutAreaRef( p, &pNode->Best );
361  aResult = Amap_CutAreaDeref( p, &pNode->Best );
362  assert( aResult > aResult2 - p->fEpsilonInternal );
363  assert( aResult < aResult2 + p->fEpsilonInternal );
364  }
365  else
366  {
367  aResult = Amap_CutAreaDeref( p, &pNode->Best );
368  aResult2 = Amap_CutAreaRef( p, &pNode->Best );
369  assert( aResult > aResult2 - p->fEpsilonInternal );
370  assert( aResult < aResult2 + p->fEpsilonInternal );
371  }
372 }
Amap_Mat_t Best
Definition: amapInt.h:218
static float Amap_CutAreaDeref(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:275
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
#define assert(ex)
Definition: util_old.h:213
static float Amap_CutAreaRef(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:302
float fEpsilonInternal
Definition: amapInt.h:81
static int Amap_CutCompareArea ( Amap_Man_t p,
Amap_Mat_t pM0,
Amap_Mat_t pM1 
)
inlinestatic

Definition at line 242 of file amapMatch.c.

243 {
244  // compare area flows
245  if ( pM0->Area < pM1->Area - p->pPars->fEpsilon )
246  return -1;
247  if ( pM0->Area > pM1->Area + p->pPars->fEpsilon )
248  return 1;
249 
250  // compare average fanouts
251  if ( pM0->AveFan > pM1->AveFan - p->pPars->fEpsilon )
252  return -1;
253  if ( pM0->AveFan < pM1->AveFan + p->pPars->fEpsilon )
254  return 1;
255 
256  // compare delay
257  if ( pM0->Delay < pM1->Delay - p->pPars->fEpsilon )
258  return -1;
259  if ( pM0->Delay > pM1->Delay + p->pPars->fEpsilon )
260  return 1;
261  return 1;
262 }
float AveFan
Definition: amapInt.h:195
float Delay
Definition: amapInt.h:196
float Area
Definition: amapInt.h:194
Amap_Par_t * pPars
Definition: amapInt.h:78
float fEpsilon
Definition: amap.h:53
static int Amap_CutCompareDelay ( Amap_Man_t p,
Amap_Mat_t pM0,
Amap_Mat_t pM1 
)
inlinestatic

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

Synopsis [Compare two matches.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file amapMatch.c.

222 {
223  // compare delay
224  if ( pM0->Delay < pM1->Delay - p->pPars->fEpsilon )
225  return -1;
226  if ( pM0->Delay > pM1->Delay + p->pPars->fEpsilon )
227  return 1;
228 
229  // compare area flows
230  if ( pM0->Area < pM1->Area - p->pPars->fEpsilon )
231  return -1;
232  if ( pM0->Area > pM1->Area + p->pPars->fEpsilon )
233  return 1;
234 
235  // compare average fanouts
236  if ( pM0->AveFan > pM1->AveFan - p->pPars->fEpsilon )
237  return -1;
238  if ( pM0->AveFan < pM1->AveFan + p->pPars->fEpsilon )
239  return 1;
240  return 1;
241 }
float AveFan
Definition: amapInt.h:195
float Delay
Definition: amapInt.h:196
float Area
Definition: amapInt.h:194
Amap_Par_t * pPars
Definition: amapInt.h:78
float fEpsilon
Definition: amap.h:53
void Amap_ManCleanData ( Amap_Man_t p)

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

Synopsis [Cleans reference counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file amapMatch.c.

124 {
125  Amap_Obj_t * pObj;
126  int i;
127 // Amap_ManForEachNode( p, pObj, i )
128 // ABC_FREE( pObj->pData );
129  Amap_ManForEachObj( p, pObj, i )
130  pObj->pData = NULL;
131 }
#define Amap_ManForEachObj(p, pObj, i)
Definition: amapInt.h:286
void Amap_ManCleanRefs ( Amap_Man_t p)

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

Synopsis [Cleans reference counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file amapMatch.c.

84 {
85  Amap_Obj_t * pObj;
86  int i;
87  Amap_ManForEachObj( p, pObj, i )
88  pObj->nFouts[0] = pObj->nFouts[1] = 0;
89 }
#define Amap_ManForEachObj(p, pObj, i)
Definition: amapInt.h:286
float Amap_ManComputeMapping ( Amap_Man_t p)

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

Synopsis [Compute nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 179 of file amapMatch.c.

180 {
181  Amap_Obj_t * pObj;
182  float Area = 0.0;
183  int i;
184  Amap_ManCleanRefs( p );
185  Amap_ManForEachPo( p, pObj, i )
186  Area += Amap_ManComputeMapping_rec( p, Amap_ObjFanin0(p, pObj), Amap_ObjFaninC0(pObj) );
187  return Area;
188 }
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
void Amap_ManCleanRefs(Amap_Man_t *p)
Definition: amapMatch.c:83
float Amap_ManComputeMapping_rec(Amap_Man_t *p, Amap_Obj_t *pObj, int fCompl)
Definition: amapMatch.c:144
static int Amap_ObjFaninC0(Amap_Obj_t *pObj)
Definition: amapInt.h:251
#define Amap_ManForEachPo(p, pObj, i)
Definition: amapInt.h:283
float Amap_ManComputeMapping_rec ( Amap_Man_t p,
Amap_Obj_t pObj,
int  fCompl 
)

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

Synopsis [Compute nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 144 of file amapMatch.c.

145 {
146  Amap_Mat_t * pM = &pObj->Best;
147  Amap_Obj_t * pFanin;
148  Amap_Gat_t * pGate;
149  int i, iFanin, fComplFanin;
150  float Area;
151  if ( pObj->nFouts[fCompl]++ + pObj->nFouts[!fCompl] > 0 )
152  return 0.0;
153  if ( Amap_ObjIsPi(pObj) || Amap_ObjIsConst1(pObj) )
154  return 0.0;
155  pGate = Amap_LibGate( p->pLib, pM->pSet->iGate );
156  assert( pGate->nPins == pM->pCut->nFans );
157  Area = pGate->dArea;
158  for ( i = 0; i < (int)pGate->nPins; i++ )
159  {
160  iFanin = Abc_Lit2Var( pM->pSet->Ins[i] );
161  pFanin = Amap_ManObj( p, Abc_Lit2Var(pM->pCut->Fans[iFanin]) );
162  fComplFanin = Abc_LitIsCompl( pM->pSet->Ins[i] ) ^ Abc_LitIsCompl( pM->pCut->Fans[iFanin] );
163  Area += Amap_ManComputeMapping_rec( p, pFanin, fComplFanin );
164  }
165  return Area;
166 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
Amap_Mat_t Best
Definition: amapInt.h:218
int nFouts[2]
Definition: amapInt.h:217
static int Amap_ObjIsPi(Amap_Obj_t *pObj)
Definition: amapInt.h:240
Amap_Cut_t * pCut
Definition: amapInt.h:192
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
char Ins[AMAP_MAXINS]
Definition: amapInt.h:170
Amap_Lib_t * pLib
Definition: amapInt.h:79
static int Amap_ObjIsConst1(Amap_Obj_t *pObj)
Definition: amapInt.h:239
unsigned nPins
Definition: amapInt.h:161
double dArea
Definition: amapInt.h:156
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
unsigned nFans
Definition: amapInt.h:187
float Amap_ManComputeMapping_rec(Amap_Man_t *p, Amap_Obj_t *pObj, int fCompl)
Definition: amapMatch.c:144
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
Amap_Set_t * pSet
Definition: amapInt.h:193
int Fans[0]
Definition: amapInt.h:188
int Amap_ManCountInverters ( Amap_Man_t p)

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

Synopsis [Counts the number of inverters to be added.]

Description [Should be called after mapping has been set.]

SideEffects []

SeeAlso []

Definition at line 201 of file amapMatch.c.

202 {
203  Amap_Obj_t * pObj;
204  int i, Counter = 0;
205  Amap_ManForEachObj( p, pObj, i )
206  Counter += (int)(pObj->nFouts[!pObj->fPolar] > 0);
207  return Counter;
208 }
#define Amap_ManForEachObj(p, pObj, i)
Definition: amapInt.h:286
static int Counter
ABC_NAMESPACE_IMPL_START Amap_Cut_t* Amap_ManDupCut ( Amap_Man_t p,
Amap_Cut_t pCut 
)

DECLARATIONS ///.

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

FileName [amapMatch.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
amapMatch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

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

Synopsis [Duplicates the cut using new memory manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapMatch.c.

46 {
47  Amap_Cut_t * pNew;
48  int nBytes = sizeof(Amap_Cut_t) + sizeof(int) * pCut->nFans;
49  pNew = (Amap_Cut_t *)Aig_MmFlexEntryFetch( p->pMemCutBest, nBytes );
50  memcpy( pNew, pCut, nBytes );
51  return pNew;
52 }
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * memcpy()
Aig_MmFlex_t * pMemCutBest
Definition: amapInt.h:91
unsigned nFans
Definition: amapInt.h:187
struct Amap_Cut_t_ Amap_Cut_t
Definition: amapInt.h:72
void Amap_ManMap ( Amap_Man_t p)

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

Synopsis [Performs mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 593 of file amapMatch.c.

594 {
595  int i;
596  Amap_ManMerge( p );
597  for ( i = 0; i < p->pPars->nIterFlow; i++ )
598  Amap_ManMatch( p, 1, i>0 );
599  for ( i = 0; i < p->pPars->nIterArea; i++ )
600  Amap_ManMatch( p, 0, p->pPars->nIterFlow>0||i>0 );
601 /*
602  for ( i = 0; i < p->pPars->nIterFlow; i++ )
603  Amap_ManMatch( p, 1, 1 );
604  for ( i = 0; i < p->pPars->nIterArea; i++ )
605  Amap_ManMatch( p, 0, 1 );
606 */
607  Amap_ManCleanData( p );
608 }
void Amap_ManMerge(Amap_Man_t *p)
Definition: amapMerge.c:514
int nIterArea
Definition: amap.h:48
void Amap_ManCleanData(Amap_Man_t *p)
Definition: amapMatch.c:123
int nIterFlow
Definition: amap.h:47
Amap_Par_t * pPars
Definition: amapInt.h:78
void Amap_ManMatch(Amap_Man_t *p, int fFlow, int fRefs)
Definition: amapMatch.c:554
void Amap_ManMatch ( Amap_Man_t p,
int  fFlow,
int  fRefs 
)

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

Synopsis [Performs one round of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 554 of file amapMatch.c.

555 {
556  Aig_MmFlex_t * pMemOld;
557  Amap_Obj_t * pObj;
558  float Area;
559  int i, nInvs;
560  abctime clk = Abc_Clock();
561  pMemOld = p->pMemCutBest;
563  Amap_ManForEachNode( p, pObj, i )
564  if ( pObj->pData )
565  Amap_ManMatchNode( p, pObj, fFlow, fRefs );
566  Aig_MmFlexStop( pMemOld, 0 );
567  Area = Amap_ManComputeMapping( p );
568  nInvs = Amap_ManCountInverters( p );
569 if ( p->pPars->fVerbose )
570 {
571  printf( "Area =%9.2f. Gate =%9.2f. Inv =%9.2f. (%6d.) Delay =%6.2f. ",
572  Area + nInvs * p->fAreaInv,
573  Area, nInvs * p->fAreaInv, nInvs,
574  Amap_ManMaxDelay(p) );
575 ABC_PRT( "Time ", Abc_Clock() - clk );
576 }
577  // test procedures
578 // Amap_ManForEachNode( p, pObj, i )
579 // Amap_CutAreaTest( p, pObj );
580 }
static abctime Abc_Clock()
Definition: abc_global.h:279
Aig_MmFlex_t * pMemCutBest
Definition: amapInt.h:91
#define Amap_ManForEachNode(p, pObj, i)
Definition: amapInt.h:289
float Amap_ManMaxDelay(Amap_Man_t *p)
Definition: amapMatch.c:102
if(last==0)
Definition: sparse_int.h:34
Aig_MmFlex_t * Aig_MmFlexStart()
Definition: aigMem.c:305
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition: aigMem.c:337
int Amap_ManCountInverters(Amap_Man_t *p)
Definition: amapMatch.c:201
ABC_INT64_T abctime
Definition: abc_global.h:278
void Amap_ManMatchNode(Amap_Man_t *p, Amap_Obj_t *pNode, int fFlow, int fRefs)
Definition: amapMatch.c:455
float Amap_ManComputeMapping(Amap_Man_t *p)
Definition: amapMatch.c:179
static void Amap_ManMatchGetExacts ( Amap_Man_t p,
Amap_Obj_t pNode,
Amap_Mat_t pM 
)
inlinestatic

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

Synopsis [Derives parameters for the match.]

Description []

SideEffects []

SeeAlso []

Definition at line 422 of file amapMatch.c.

423 {
424  Amap_Mat_t * pMFanin;
425  Amap_Obj_t * pFanin;
426  Amap_Gat_t * pGate;
427  int i;
428  pGate = Amap_LibGate( p->pLib, pM->pSet->iGate );
429  assert( pGate->nPins == pM->pCut->nFans );
430  assert( pM->Area == 0.0 );
431  pM->AveFan = 0.0;
432  pM->Delay = 0.0;
433  Amap_MatchForEachFanin( p, pM, pFanin, i )
434  {
435  pMFanin = &pFanin->Best;
436  pM->Delay = Abc_MaxInt( pM->Delay, pMFanin->Delay );
437  pM->AveFan += Amap_ObjRefsTotal(pFanin);
438  }
439  pM->AveFan /= pGate->nPins;
440  pM->Delay += 1.0;
441  pM->Area = Amap_CutAreaDerefed( p, pNode, pM );
442 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
Amap_Mat_t Best
Definition: amapInt.h:218
float AveFan
Definition: amapInt.h:195
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Amap_Cut_t * pCut
Definition: amapInt.h:192
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
Amap_Lib_t * pLib
Definition: amapInt.h:79
float Delay
Definition: amapInt.h:196
unsigned nPins
Definition: amapInt.h:161
float Area
Definition: amapInt.h:194
unsigned nFans
Definition: amapInt.h:187
static float Amap_CutAreaDerefed(Amap_Man_t *p, Amap_Obj_t *pNode, Amap_Mat_t *pM)
Definition: amapMatch.c:329
#define Amap_MatchForEachFanin(p, pM, pFanin, i)
Definition: amapInt.h:316
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
Amap_Set_t * pSet
Definition: amapInt.h:193
static void Amap_ManMatchGetFlows ( Amap_Man_t p,
Amap_Mat_t pM 
)
inlinestatic

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

Synopsis [Derives parameters for the match.]

Description []

SideEffects []

SeeAlso []

Definition at line 385 of file amapMatch.c.

386 {
387  Amap_Mat_t * pMFanin;
388  Amap_Obj_t * pFanin;
389  Amap_Gat_t * pGate;
390  int i;
391  pGate = Amap_LibGate( p->pLib, pM->pSet->iGate );
392  assert( pGate->nPins == pM->pCut->nFans );
393  assert( pM->Area == 0.0 );
394  pM->Area = pGate->dArea;
395  pM->AveFan = 0.0;
396  pM->Delay = 0.0;
397  Amap_MatchForEachFanin( p, pM, pFanin, i )
398  {
399  pMFanin = &pFanin->Best;
400  pM->Delay = Abc_MaxInt( pM->Delay, pMFanin->Delay );
401  pM->AveFan += Amap_ObjRefsTotal(pFanin);
402  if ( Amap_ObjRefsTotal(pFanin) == 0 )
403  pM->Area += pMFanin->Area;
404  else
405  pM->Area += pMFanin->Area / pFanin->EstRefs;
406  }
407  pM->AveFan /= pGate->nPins;
408  pM->Delay += 1.0;
409 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
float EstRefs
Definition: amapInt.h:216
Amap_Mat_t Best
Definition: amapInt.h:218
float AveFan
Definition: amapInt.h:195
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Amap_Cut_t * pCut
Definition: amapInt.h:192
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
Amap_Lib_t * pLib
Definition: amapInt.h:79
float Delay
Definition: amapInt.h:196
unsigned nPins
Definition: amapInt.h:161
float Area
Definition: amapInt.h:194
double dArea
Definition: amapInt.h:156
unsigned nFans
Definition: amapInt.h:187
#define Amap_MatchForEachFanin(p, pM, pFanin, i)
Definition: amapInt.h:316
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
Amap_Set_t * pSet
Definition: amapInt.h:193
void Amap_ManMatchNode ( Amap_Man_t p,
Amap_Obj_t pNode,
int  fFlow,
int  fRefs 
)

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

Synopsis [Computes the best match at each node.]

Description []

SideEffects []

SeeAlso []

Definition at line 455 of file amapMatch.c.

456 {
457  int fVerbose = 0; //(pNode->Level == 2 || pNode->Level == 4);
458  int fVeryVerbose = fVerbose;
459 
460  Amap_Mat_t MA = {0}, MD = {0}, M = {0};
461  Amap_Mat_t * pMBestA = &MA, * pMBestD = &MD, * pMThis = &M, * pMBest;
462  Amap_Cut_t * pCut;
463  Amap_Set_t * pSet;
464  Amap_Nod_t * pNod;
465  int i;
466 
467  if ( fRefs )
468  pNode->EstRefs = (float)((2.0 * pNode->EstRefs + Amap_ObjRefsTotal(pNode)) / 3.0);
469  else
470  pNode->EstRefs = (float)pNode->nRefs;
471  if ( fRefs && Amap_ObjRefsTotal(pNode) > 0 )
472  Amap_CutAreaDeref( p, &pNode->Best );
473 
474  if ( fVerbose )
475  printf( "\nNode %d (%d)\n", pNode->Id, pNode->Level );
476 
477  pMBestA->pCut = pMBestD->pCut = NULL;
478  Amap_NodeForEachCut( pNode, pCut, i )
479  {
480  if ( pCut->iMat == 0 )
481  continue;
482  pNod = Amap_LibNod( p->pLib, pCut->iMat );
483  Amap_LibNodeForEachSet( pNod, pSet )
484  {
485  Amap_ManMatchStart( pMThis, pCut, pSet );
486  if ( fFlow )
487  Amap_ManMatchGetFlows( p, pMThis );
488  else
489  Amap_ManMatchGetExacts( p, pNode, pMThis );
490  if ( pMBestD->pCut == NULL || Amap_CutCompareDelay(p, pMBestD, pMThis) == 1 )
491  *pMBestD = *pMThis;
492  if ( pMBestA->pCut == NULL || Amap_CutCompareArea(p, pMBestA, pMThis) == 1 )
493  *pMBestA = *pMThis;
494 
495  if ( fVeryVerbose )
496  {
497  printf( "Cut %2d (%d) : ", i, pCut->nFans );
498  printf( "Gate %10s ", Amap_LibGate(p->pLib, pMThis->pSet->iGate)->pName );
499  printf( "%s ", pMThis->pSet->fInv ? "inv" : " " );
500  printf( "Delay %5.2f ", pMThis->Delay );
501  printf( "Area %5.2f ", pMThis->Area );
502  printf( "\n" );
503  }
504  }
505  }
506 
507  if ( Abc_AbsFloat(pMBestA->Area - pMBestD->Area) / pMBestD->Area >= p->pPars->fADratio * Abc_AbsFloat(pMBestA->Delay - pMBestD->Delay) / pMBestA->Delay )
508  pMBest = pMBestA;
509  else
510  pMBest = pMBestD;
511 
512  if ( fVerbose )
513  {
514  printf( "BEST MATCHA: " );
515  printf( "Gate %10s ", Amap_LibGate(p->pLib, pMBestA->pSet->iGate)->pName );
516  printf( "%s ", pMBestA->pSet->fInv ? "inv" : " " );
517  printf( "Delay %5.2f ", pMBestA->Delay );
518  printf( "Area %5.2f ", pMBestA->Area );
519  printf( "\n" );
520 
521  printf( "BEST MATCHD: " );
522  printf( "Gate %10s ", Amap_LibGate(p->pLib, pMBestD->pSet->iGate)->pName );
523  printf( "%s ", pMBestD->pSet->fInv ? "inv" : " " );
524  printf( "Delay %5.2f ", pMBestD->Delay );
525  printf( "Area %5.2f ", pMBestD->Area );
526  printf( "\n" );
527 
528  printf( "BEST MATCH : " );
529  printf( "Gate %10s ", Amap_LibGate(p->pLib, pMBest->pSet->iGate)->pName );
530  printf( "%s ", pMBest->pSet->fInv ? "inv" : " " );
531  printf( "Delay %5.2f ", pMBest->Delay );
532  printf( "Area %5.2f ", pMBest->Area );
533  printf( "\n" );
534  }
535 
536  pNode->fPolar = pMBest->pCut->fInv ^ pMBest->pSet->fInv;
537  pNode->Best = *pMBest;
538  pNode->Best.pCut = Amap_ManDupCut( p, pNode->Best.pCut );
539  if ( fRefs && Amap_ObjRefsTotal(pNode) > 0 )
540  Amap_CutAreaRef( p, &pNode->Best );
541 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
float EstRefs
Definition: amapInt.h:216
static float Abc_AbsFloat(float a)
Definition: abc_global.h:242
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
Amap_Mat_t Best
Definition: amapInt.h:218
unsigned fInv
Definition: amapInt.h:168
static float Amap_CutAreaDeref(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:275
static int Amap_CutCompareArea(Amap_Man_t *p, Amap_Mat_t *pM0, Amap_Mat_t *pM1)
Definition: amapMatch.c:242
ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManDupCut(Amap_Man_t *p, Amap_Cut_t *pCut)
DECLARATIONS ///.
Definition: amapMatch.c:45
unsigned Level
Definition: amapInt.h:206
unsigned Id
Definition: amapInt.h:201
word M(word f1, word f2, int n)
Definition: kitPerm.c:240
Amap_Cut_t * pCut
Definition: amapInt.h:192
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
static void Amap_ManMatchStart(Amap_Mat_t *p, Amap_Cut_t *pCut, Amap_Set_t *pSet)
Definition: amapMatch.c:65
int nRefs
Definition: amapInt.h:208
Amap_Lib_t * pLib
Definition: amapInt.h:79
float Delay
Definition: amapInt.h:196
if(last==0)
Definition: sparse_int.h:34
float Area
Definition: amapInt.h:194
#define Amap_LibNodeForEachSet(pNod, pSet)
Definition: amapInt.h:305
unsigned nFans
Definition: amapInt.h:187
static void Amap_ManMatchGetExacts(Amap_Man_t *p, Amap_Obj_t *pNode, Amap_Mat_t *pM)
Definition: amapMatch.c:422
Amap_Par_t * pPars
Definition: amapInt.h:78
unsigned iMat
Definition: amapInt.h:185
static void Amap_ManMatchGetFlows(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:385
unsigned iGate
Definition: amapInt.h:167
static float Amap_CutAreaRef(Amap_Man_t *p, Amap_Mat_t *pM)
Definition: amapMatch.c:302
unsigned fPolar
Definition: amapInt.h:205
Amap_Set_t * pSet
Definition: amapInt.h:193
char * pName
Definition: amapInt.h:154
static Amap_Nod_t * Amap_LibNod(Amap_Lib_t *p, int i)
Definition: amapInt.h:264
static int Amap_CutCompareDelay(Amap_Man_t *p, Amap_Mat_t *pM0, Amap_Mat_t *pM1)
Definition: amapMatch.c:221
float fADratio
Definition: amap.h:54
static void Amap_ManMatchStart ( Amap_Mat_t p,
Amap_Cut_t pCut,
Amap_Set_t pSet 
)
inlinestatic

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

Synopsis [Starts the match with cut and set.]

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file amapMatch.c.

66 {
67  memset( p, 0, sizeof(Amap_Mat_t) );
68  p->pCut = pCut;
69  p->pSet = pSet;
70 }
char * memset()
Amap_Cut_t * pCut
Definition: amapInt.h:192
Amap_Set_t * pSet
Definition: amapInt.h:193
float Amap_ManMaxDelay ( Amap_Man_t p)

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

Synopsis [Computes delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file amapMatch.c.

103 {
104  Amap_Obj_t * pObj;
105  float Delay = 0.0;
106  int i;
107  Amap_ManForEachPo( p, pObj, i )
108  Delay = Abc_MaxInt( Delay, Amap_ObjFanin0(p,pObj)->Best.Delay );
109  return Delay;
110 }
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
#define Amap_ManForEachPo(p, pObj, i)
Definition: amapInt.h:283