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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Mpm_CutAlloc (Mpm_Man_t *p, int nLeaves, Mpm_Cut_t **ppCut)
 DECLARATIONS ///. More...
 
static int Mpm_CutCreateZero (Mpm_Man_t *p)
 
static int Mpm_CutCreateUnit (Mpm_Man_t *p, int Id)
 
static int Mpm_CutCreate (Mpm_Man_t *p, Mpm_Cut_t *pUni, Mpm_Cut_t **ppCut)
 
static int Mpm_CutDup (Mpm_Man_t *p, Mpm_Cut_t *pCut, int fCompl)
 
static int Mpm_CutCopySet (Mpm_Man_t *p, Mig_Obj_t *pObj, int fCompl)
 
void Mpm_CutPrint (Mpm_Cut_t *pCut)
 
static void Mpm_CutPrintAll (Mpm_Man_t *p)
 
static int Mpm_CutFindLeaf (Mpm_Cut_t *pNew, int iObj)
 
static int Mpm_CutIsContained (Mpm_Man_t *p, Mpm_Cut_t *pBase, Mpm_Cut_t *pCut)
 
static int Mpm_CutGetArea (Mpm_Man_t *p, Mpm_Cut_t *pCut)
 
static word Mpm_CutGetSign (Mpm_Cut_t *pCut)
 
static int Mpm_CutGetArrTime (Mpm_Man_t *p, Mpm_Cut_t *pCut)
 
static Mpm_Uni_tMpm_CutSetupInfo (Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
 
int Mpm_ObjAddCutToStore (Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
 
static Mpm_Cut_tMpm_ManMergeCuts (Mpm_Man_t *p, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCut2)
 
static int Mpm_ManExploreNewCut (Mpm_Man_t *p, Mig_Obj_t *pObj, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCut2, int Required)
 
static void Mpm_ObjRecycleCuts (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
static void Mpm_ObjDerefFaninCuts (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
static void Mpm_ObjCollectFaninsAndSigns (Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
 
static void Mpm_ObjPrepareFanins (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
void Mpm_ObjAddChoiceCutsToStore (Mpm_Man_t *p, Mig_Obj_t *pRoot, Mig_Obj_t *pObj, int ReqTime)
 
void Mpm_ObjTranslateCutsFromStore (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
int Mpm_ManDeriveCuts (Mpm_Man_t *p, Mig_Obj_t *pObj)
 
static int Mpm_ManFindArrivalMax (Mpm_Man_t *p)
 
static void Mpm_ManFinalizeRound (Mpm_Man_t *p)
 
static void Mpm_ManComputeEstRefs (Mpm_Man_t *p)
 
int Mpm_CutCompareDelay (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
int Mpm_CutCompareDelay2 (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
int Mpm_CutCompareArea (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
int Mpm_CutCompareArea2 (Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
 
void Mpm_ManPrepare (Mpm_Man_t *p)
 
void Mpm_ManPerformRound (Mpm_Man_t *p)
 
void Mpm_ManPerform (Mpm_Man_t *p)
 

Function Documentation

static ABC_NAMESPACE_IMPL_START int Mpm_CutAlloc ( Mpm_Man_t p,
int  nLeaves,
Mpm_Cut_t **  ppCut 
)
inlinestatic

DECLARATIONS ///.

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

FileName [mpmMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Configurable technology mapper.]

Synopsis [Mapping algorithm.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 1, 2013.]

Revision [

Id:
mpmMap.c,v 1.00 2013/06/01 00:00:00 alanmi Exp

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

Synopsis [Cut manipulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file mpmMap.c.

47 {
48  int hHandle = Mmr_StepFetch( p->pManCuts, Mpm_CutWordNum(nLeaves) );
49  *ppCut = (Mpm_Cut_t *)Mmr_StepEntry( p->pManCuts, hHandle );
50  (*ppCut)->nLeaves = nLeaves;
51  (*ppCut)->hNext = 0;
52  (*ppCut)->fUseless = 0;
53  (*ppCut)->fCompl = 0;
54  return hHandle;
55 }
static int Mmr_StepFetch(Mmr_Step_t *p, int nWords)
Definition: mem2.h:241
static word * Mmr_StepEntry(Mmr_Step_t *p, int h)
Definition: mem2.h:236
Mmr_Step_t * pManCuts
Definition: mpmInt.h:110
static int Mpm_CutWordNum(int nLeaves)
Definition: mpmInt.h:174
int Mpm_CutCompareArea ( Mpm_Uni_t pOld,
Mpm_Uni_t pNew 
)

Definition at line 764 of file mpmMap.c.

765 {
766  if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
767  if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
768  if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
769  if ( pOld->mAveRefs != pNew->mAveRefs ) return pOld->mAveRefs - pNew->mAveRefs;
770  if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
771  return 0;
772 }
int mTime
Definition: mpmInt.h:74
int mArea
Definition: mpmInt.h:75
Mpm_Cut_t pCut
Definition: mpmInt.h:80
int mAveRefs
Definition: mpmInt.h:77
int mEdge
Definition: mpmInt.h:76
unsigned nLeaves
Definition: mpmInt.h:68
int Mpm_CutCompareArea2 ( Mpm_Uni_t pOld,
Mpm_Uni_t pNew 
)

Definition at line 773 of file mpmMap.c.

774 {
775  if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
776  if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
777  if ( pOld->mAveRefs != pNew->mAveRefs ) return pOld->mAveRefs - pNew->mAveRefs;
778  if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
779  if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
780  return 0;
781 }
int mTime
Definition: mpmInt.h:74
int mArea
Definition: mpmInt.h:75
Mpm_Cut_t pCut
Definition: mpmInt.h:80
int mAveRefs
Definition: mpmInt.h:77
int mEdge
Definition: mpmInt.h:76
unsigned nLeaves
Definition: mpmInt.h:68
int Mpm_CutCompareDelay ( Mpm_Uni_t pOld,
Mpm_Uni_t pNew 
)

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

Synopsis [Cut comparison.]

Description [Returns positive number if new one is better than old one.]

SideEffects []

SeeAlso []

Definition at line 748 of file mpmMap.c.

749 {
750  if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
751  if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
752  if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
753  if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
754  return 0;
755 }
int mTime
Definition: mpmInt.h:74
int mArea
Definition: mpmInt.h:75
Mpm_Cut_t pCut
Definition: mpmInt.h:80
int mEdge
Definition: mpmInt.h:76
unsigned nLeaves
Definition: mpmInt.h:68
int Mpm_CutCompareDelay2 ( Mpm_Uni_t pOld,
Mpm_Uni_t pNew 
)

Definition at line 756 of file mpmMap.c.

757 {
758  if ( pOld->mTime != pNew->mTime ) return pOld->mTime - pNew->mTime;
759  if ( pOld->mArea != pNew->mArea ) return pOld->mArea - pNew->mArea;
760  if ( pOld->mEdge != pNew->mEdge ) return pOld->mEdge - pNew->mEdge;
761  if ( pOld->pCut.nLeaves != pNew->pCut.nLeaves ) return pOld->pCut.nLeaves - pNew->pCut.nLeaves;
762  return 0;
763 }
int mTime
Definition: mpmInt.h:74
int mArea
Definition: mpmInt.h:75
Mpm_Cut_t pCut
Definition: mpmInt.h:80
int mEdge
Definition: mpmInt.h:76
unsigned nLeaves
Definition: mpmInt.h:68
static int Mpm_CutCopySet ( Mpm_Man_t p,
Mig_Obj_t pObj,
int  fCompl 
)
inlinestatic

Definition at line 91 of file mpmMap.c.

92 {
93  Mpm_Cut_t * pCut;
94  int hCut, iList = 0, * pList = &iList;
95  Mpm_ObjForEachCut( p, pObj, hCut, pCut )
96  {
97  *pList = Mpm_CutDup( p, pCut, fCompl );
98  pList = &Mpm_CutFetch( p, *pList )->hNext;
99  }
100  *pList = 0;
101  return iList;
102 }
static int Mpm_CutDup(Mpm_Man_t *p, Mpm_Cut_t *pCut, int fCompl)
Definition: mpmMap.c:81
static Mpm_Cut_t * Mpm_CutFetch(Mpm_Man_t *p, int h)
Definition: mpmInt.h:175
int hNext
Definition: mpmInt.h:64
#define Mpm_ObjForEachCut(p, pObj, hCut, pCut)
Definition: mpmInt.h:212
static int Mpm_CutCreate ( Mpm_Man_t p,
Mpm_Cut_t pUni,
Mpm_Cut_t **  ppCut 
)
inlinestatic

Definition at line 71 of file mpmMap.c.

72 {
73  int hCutNew = Mpm_CutAlloc( p, pUni->nLeaves, ppCut );
74  (*ppCut)->iFunc = pUni->iFunc;
75  (*ppCut)->fCompl = pUni->fCompl;
76  (*ppCut)->fUseless = pUni->fUseless;
77  (*ppCut)->nLeaves = pUni->nLeaves;
78  memcpy( (*ppCut)->pLeaves, pUni->pLeaves, sizeof(int) * pUni->nLeaves );
79  return hCutNew;
80 }
static ABC_NAMESPACE_IMPL_START int Mpm_CutAlloc(Mpm_Man_t *p, int nLeaves, Mpm_Cut_t **ppCut)
DECLARATIONS ///.
Definition: mpmMap.c:46
unsigned fCompl
Definition: mpmInt.h:66
char * memcpy()
unsigned fUseless
Definition: mpmInt.h:67
int pLeaves[1]
Definition: mpmInt.h:69
unsigned nLeaves
Definition: mpmInt.h:68
unsigned iFunc
Definition: mpmInt.h:65
static int Mpm_CutCreateUnit ( Mpm_Man_t p,
int  Id 
)
inlinestatic

Definition at line 63 of file mpmMap.c.

64 {
65  Mpm_Cut_t * pCut;
66  int hCut = Mpm_CutAlloc( p, 1, &pCut );
67  pCut->iFunc = Abc_Var2Lit( p->funcVar0, 0 ); // var
68  pCut->pLeaves[0] = Abc_Var2Lit( Id, 0 );
69  return hCut;
70 }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static ABC_NAMESPACE_IMPL_START int Mpm_CutAlloc(Mpm_Man_t *p, int nLeaves, Mpm_Cut_t **ppCut)
DECLARATIONS ///.
Definition: mpmMap.c:46
int funcVar0
Definition: mpmInt.h:126
int pLeaves[1]
Definition: mpmInt.h:69
unsigned iFunc
Definition: mpmInt.h:65
static int Mpm_CutCreateZero ( Mpm_Man_t p)
inlinestatic

Definition at line 56 of file mpmMap.c.

57 {
58  Mpm_Cut_t * pCut;
59  int hCut = Mpm_CutAlloc( p, 0, &pCut );
60  pCut->iFunc = 0; // const0
61  return hCut;
62 }
static ABC_NAMESPACE_IMPL_START int Mpm_CutAlloc(Mpm_Man_t *p, int nLeaves, Mpm_Cut_t **ppCut)
DECLARATIONS ///.
Definition: mpmMap.c:46
unsigned iFunc
Definition: mpmInt.h:65
static int Mpm_CutDup ( Mpm_Man_t p,
Mpm_Cut_t pCut,
int  fCompl 
)
inlinestatic

Definition at line 81 of file mpmMap.c.

82 {
83  Mpm_Cut_t * pCutNew;
84  int hCutNew = Mpm_CutAlloc( p, pCut->nLeaves, &pCutNew );
85  pCutNew->iFunc = Abc_LitNotCond( pCut->iFunc, fCompl );
86  pCutNew->fUseless = pCut->fUseless;
87  pCutNew->nLeaves = pCut->nLeaves;
88  memcpy( pCutNew->pLeaves, pCut->pLeaves, sizeof(int) * pCut->nLeaves );
89  return hCutNew;
90 }
static ABC_NAMESPACE_IMPL_START int Mpm_CutAlloc(Mpm_Man_t *p, int nLeaves, Mpm_Cut_t **ppCut)
DECLARATIONS ///.
Definition: mpmMap.c:46
char * memcpy()
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
unsigned fUseless
Definition: mpmInt.h:67
int pLeaves[1]
Definition: mpmInt.h:69
unsigned nLeaves
Definition: mpmInt.h:68
unsigned iFunc
Definition: mpmInt.h:65
static int Mpm_CutFindLeaf ( Mpm_Cut_t pNew,
int  iObj 
)
inlinestatic

Definition at line 120 of file mpmMap.c.

121 {
122  int i;
123  for ( i = 0; i < (int)pNew->nLeaves; i++ )
124  if ( Abc_Lit2Var(pNew->pLeaves[i]) == iObj )
125  return i;
126  return i;
127 }
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int pLeaves[1]
Definition: mpmInt.h:69
unsigned nLeaves
Definition: mpmInt.h:68
static int Mpm_CutGetArea ( Mpm_Man_t p,
Mpm_Cut_t pCut 
)
inlinestatic

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

Synopsis [Cut attibutes.]

Description []

SideEffects []

SeeAlso []

Definition at line 148 of file mpmMap.c.

149 {
150  if ( p->pPars->fMap4Cnf )
151  return MPM_UNIT_AREA * p->pDsd6[Abc_Lit2Var(pCut->iFunc)].nClauses;
152  if ( p->pPars->fMap4Aig )
153  return MPM_UNIT_AREA * p->pDsd6[Abc_Lit2Var(pCut->iFunc)].nAnds;
154  if ( p->pPars->fMap4Gates )
155  return MPM_UNIT_AREA * 1;
156  return p->pLibLut->pLutAreas[pCut->nLeaves];
157 }
Mpm_Par_t * pPars
Definition: mpmInt.h:98
int nClauses
Definition: mpmInt.h:89
Mpm_LibLut_t * pLibLut
Definition: mpmInt.h:103
int fMap4Cnf
Definition: mpm.h:69
int fMap4Gates
Definition: mpm.h:71
int fMap4Aig
Definition: mpm.h:70
int nAnds
Definition: mpmInt.h:88
#define MPM_UNIT_AREA
Definition: mpmInt.h:53
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned nLeaves
Definition: mpmInt.h:68
int pLutAreas[MPM_VAR_MAX+1]
Definition: mpm.h:52
unsigned iFunc
Definition: mpmInt.h:65
Mpm_Dsd_t * pDsd6
Definition: mpmInt.h:132
static int Mpm_CutGetArrTime ( Mpm_Man_t p,
Mpm_Cut_t pCut 
)
inlinestatic

Definition at line 166 of file mpmMap.c.

167 {
168  int * pmTimes = Vec_IntArray( &p->vTimes );
169  int * pDelays = p->pLibLut->pLutDelays[pCut->nLeaves];
170  int i, iLeaf, ArrTime = 0;
171  Mpm_CutForEachLeafId( pCut, iLeaf, i )
172  ArrTime = Abc_MaxInt( ArrTime, pmTimes[iLeaf] + pDelays[i] );
173  return ArrTime;
174 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
#define Mpm_CutForEachLeafId(pCut, iLeafId, i)
Definition: mpmInt.h:218
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Mpm_LibLut_t * pLibLut
Definition: mpmInt.h:103
Vec_Int_t vTimes
Definition: mpmInt.h:148
int pLutDelays[MPM_VAR_MAX+1][MPM_VAR_MAX+1]
Definition: mpm.h:53
unsigned nLeaves
Definition: mpmInt.h:68
static word Mpm_CutGetSign ( Mpm_Cut_t pCut)
inlinestatic

Definition at line 158 of file mpmMap.c.

159 {
160  int i, iLeaf;
161  word uSign = 0;
162  Mpm_CutForEachLeafId( pCut, iLeaf, i )
163  uSign |= ((word)1 << (iLeaf & 0x3F));
164  return uSign;
165 }
#define Mpm_CutForEachLeafId(pCut, iLeafId, i)
Definition: mpmInt.h:218
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Mpm_CutIsContained ( Mpm_Man_t p,
Mpm_Cut_t pBase,
Mpm_Cut_t pCut 
)
inlinestatic

Definition at line 128 of file mpmMap.c.

129 {
130  int i;
131  for ( i = 0; i < (int)pCut->nLeaves; i++ )
132  if ( Mpm_CutFindLeaf( pBase, Abc_Lit2Var(pCut->pLeaves[i]) ) == (int)pBase->nLeaves )
133  return 0;
134  return 1;
135 }
static int Mpm_CutFindLeaf(Mpm_Cut_t *pNew, int iObj)
Definition: mpmMap.c:120
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int pLeaves[1]
Definition: mpmInt.h:69
unsigned nLeaves
Definition: mpmInt.h:68
void Mpm_CutPrint ( Mpm_Cut_t pCut)

Definition at line 103 of file mpmMap.c.

104 {
105  int i;
106  printf( "%d : { ", pCut->nLeaves );
107  for ( i = 0; i < (int)pCut->nLeaves; i++ )
108  printf( "%d ", pCut->pLeaves[i] );
109  printf( "}\n" );
110 }
int pLeaves[1]
Definition: mpmInt.h:69
unsigned nLeaves
Definition: mpmInt.h:68
static void Mpm_CutPrintAll ( Mpm_Man_t p)
inlinestatic

Definition at line 111 of file mpmMap.c.

112 {
113  int i;
114  for ( i = 0; i < p->nCutStore; i++ )
115  {
116  printf( "%2d : ", i );
117  Mpm_CutPrint( &p->pCutStore[i]->pCut );
118  }
119 }
int nCutStore
Definition: mpmInt.h:112
Mpm_Uni_t * pCutStore[MPM_CUT_MAX+1]
Definition: mpmInt.h:113
void Mpm_CutPrint(Mpm_Cut_t *pCut)
Definition: mpmMap.c:103
Mpm_Cut_t pCut
Definition: mpmInt.h:80
static Mpm_Uni_t* Mpm_CutSetupInfo ( Mpm_Man_t p,
Mpm_Cut_t pCut,
int  ArrTime 
)
inlinestatic

Definition at line 175 of file mpmMap.c.

176 {
177  int * pMigRefs = Vec_IntArray( &p->vMigRefs );
178  int * pMapRefs = Vec_IntArray( &p->vMapRefs );
179  int * pEstRefs = Vec_IntArray( &p->vEstRefs );
180  int * pmArea = Vec_IntArray( &p->vAreas );
181  int * pmEdge = Vec_IntArray( &p->vEdges );
182  int i, iLeaf;
184  assert( &pUnit->pCut == pCut );
185  pUnit->mTime = ArrTime;
186  pUnit->mArea = Mpm_CutGetArea( p, pCut );
187  pUnit->mEdge = MPM_UNIT_EDGE * pCut->nLeaves;
188  pUnit->mAveRefs = 0;
189  pUnit->Cost = 0;
190  pUnit->uSign = 0;
191  Mpm_CutForEachLeafId( pCut, iLeaf, i )
192  {
193  if ( p->fMainRun && pMapRefs[iLeaf] == 0 ) // not used in the mapping
194  {
195  pUnit->mArea += pmArea[iLeaf];
196  pUnit->mEdge += pmEdge[iLeaf];
197  }
198  else
199  {
200  assert( pEstRefs[iLeaf] > 0 );
201  pUnit->mArea += MPM_UNIT_REFS * pmArea[iLeaf] / pEstRefs[iLeaf];
202  pUnit->mEdge += MPM_UNIT_REFS * pmEdge[iLeaf] / pEstRefs[iLeaf];
203  pUnit->mAveRefs += p->fMainRun ? pMapRefs[iLeaf] : pMigRefs[iLeaf];
204  }
205  pUnit->uSign |= ((word)1 << (iLeaf & 0x3F));
206  }
207  pUnit->mAveRefs = pUnit->mAveRefs * MPM_UNIT_EDGE / Abc_MaxInt(pCut->nLeaves, 1);
208  assert( pUnit->mTime <= 0x3FFFFFFF );
209  assert( pUnit->mArea <= 0x3FFFFFFF );
210  assert( pUnit->mEdge <= 0x3FFFFFFF );
211  return pUnit;
212 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
#define MPM_UNIT_REFS
Definition: mpmInt.h:55
static int Mpm_CutGetArea(Mpm_Man_t *p, Mpm_Cut_t *pCut)
Definition: mpmMap.c:148
Vec_Int_t vMapRefs
Definition: mpmInt.h:145
#define Mpm_CutForEachLeafId(pCut, iLeafId, i)
Definition: mpmInt.h:218
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int fMainRun
Definition: mpmInt.h:105
int mTime
Definition: mpmInt.h:74
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
int mArea
Definition: mpmInt.h:75
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Vec_Int_t vAreas
Definition: mpmInt.h:149
Vec_Int_t vEdges
Definition: mpmInt.h:150
word uSign
Definition: mpmInt.h:78
int Cost
Definition: mpmInt.h:79
#define MPM_UNIT_EDGE
Definition: mpmInt.h:54
Vec_Int_t vEstRefs
Definition: mpmInt.h:146
Vec_Int_t vMigRefs
Definition: mpmInt.h:144
Mpm_Cut_t pCut
Definition: mpmInt.h:80
int mAveRefs
Definition: mpmInt.h:77
int mEdge
Definition: mpmInt.h:76
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t vFreeUnits
Definition: mpmInt.h:115
unsigned nLeaves
Definition: mpmInt.h:68
static void Mpm_ManComputeEstRefs ( Mpm_Man_t p)
inlinestatic

Definition at line 726 of file mpmMap.c.

727 {
728  int * pMapRefs = Vec_IntArray( &p->vMapRefs );
729  int * pEstRefs = Vec_IntArray( &p->vEstRefs );
730  int i;
731  assert( p->fMainRun );
732 // pObj->EstRefs = (float)((2.0 * pObj->EstRefs + pObj->nRefs) / 3.0);
733  for ( i = 0; i < Mig_ManObjNum(p->pMig); i++ )
734  pEstRefs[i] = (1 * pEstRefs[i] + MPM_UNIT_REFS * pMapRefs[i]) / 2;
735 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Mig_ManObjNum(Mig_Man_t *p)
Definition: mpmMig.h:109
#define MPM_UNIT_REFS
Definition: mpmInt.h:55
Vec_Int_t vMapRefs
Definition: mpmInt.h:145
int fMainRun
Definition: mpmInt.h:105
Mig_Man_t * pMig
Definition: mpmInt.h:97
Vec_Int_t vEstRefs
Definition: mpmInt.h:146
#define assert(ex)
Definition: util_old.h:213
int Mpm_ManDeriveCuts ( Mpm_Man_t p,
Mig_Obj_t pObj 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 580 of file mpmMap.c.

581 {
582  Mpm_Cut_t * pCut0, * pCut1, * pCut2;
583  int Required = Mpm_ObjRequired( p, pObj );
584  int hCutBest = Mpm_ObjCutBest( p, pObj );
585  int c0, c1, c2;
586 #ifdef MIG_RUNTIME
587 abctime clk;
588 #endif
589 
590  assert( Vec_PtrSize( &p->vFreeUnits ) == p->nNumCuts + 1 );
591  assert( Mpm_ObjCutList(p, pObj) == 0 );
592  p->nCutStore = 0;
593  if ( hCutBest > 0 ) // cut list is assigned
594  {
595  Mpm_Cut_t * pCut = Mpm_ObjCutBestP( p, pObj );
596  int Times = Mpm_CutGetArrTime( p, pCut );
597  assert( pCut->hNext == 0 );
598  if ( Times > Required )
599  printf( "Arrival time (%d) exceeds required time (%d) at object %d.\n", Times, Required, Mig_ObjId(pObj) );
600  if ( p->fMainRun )
601  Mpm_ObjAddCutToStore( p, Mpm_ManMergeCuts(p, pCut, NULL, NULL), Times );
602  else
603  Mpm_ObjSetTime( p, pObj, Times );
604  }
605  // start storage with choice cuts
606  if ( Mig_ManChoiceNum(p->pMig) && Mig_ObjSiblId(pObj) )
607  Mpm_ObjAddChoiceCutsToStore( p, pObj, Mig_ObjSibl(pObj), Required );
608 
609 #ifdef MIG_RUNTIME
610 clk = Abc_Clock();
611 #endif
612  Mpm_ObjPrepareFanins( p, pObj );
613  if ( Mig_ObjIsNode2(pObj) )
614  {
615  // go through cut pairs
616  for ( c0 = 0; c0 < p->nCuts[0] && (pCut0 = p->pCuts[0][c0]); c0++ )
617  for ( c1 = 0; c1 < p->nCuts[1] && (pCut1 = p->pCuts[1][c1]); c1++ )
618  if ( Abc_TtCountOnes(p->pSigns[0][c0] | p->pSigns[1][c1]) <= p->nLutSize )
619  if ( !Mpm_ManExploreNewCut( p, pObj, pCut0, pCut1, NULL, Required ) )
620  goto finish;
621  }
622  else if ( Mig_ObjIsNode3(pObj) )
623  {
624  // go through cut triples
625  for ( c0 = 0; c0 < p->nCuts[0] && (pCut0 = p->pCuts[0][c0]); c0++ )
626  for ( c1 = 0; c1 < p->nCuts[1] && (pCut1 = p->pCuts[1][c1]); c1++ )
627  for ( c2 = 0; c2 < p->nCuts[2] && (pCut2 = p->pCuts[2][c2]); c2++ )
628  if ( Abc_TtCountOnes(p->pSigns[0][c0] | p->pSigns[1][c1] | p->pSigns[2][c2]) <= p->nLutSize )
629  if ( !Mpm_ManExploreNewCut( p, pObj, pCut0, pCut1, pCut2, Required ) )
630  goto finish;
631  }
632  else assert( 0 );
633 #ifdef MIG_RUNTIME
634 p->timeDerive += Abc_Clock() - clk;
635 #endif
636 
637 finish:
638  // save best cut
639  assert( p->nCutStore > 0 );
640  if ( p->pCutStore[0]->mTime <= Required )
641  {
642  Mpm_Cut_t * pCut;
643  if ( hCutBest )
644  Mmr_StepRecycle( p->pManCuts, hCutBest );
645  hCutBest = Mpm_CutCreate( p, &p->pCutStore[0]->pCut, &pCut );
646  Mpm_ObjSetCutBest( p, pObj, hCutBest );
647  Mpm_ObjSetTime( p, pObj, p->pCutStore[0]->mTime );
648  Mpm_ObjSetArea( p, pObj, p->pCutStore[0]->mArea );
649  Mpm_ObjSetEdge( p, pObj, p->pCutStore[0]->mEdge );
650  }
651  else assert( !p->fMainRun );
652  assert( hCutBest > 0 );
653  // transform internal storage into regular cuts
655  // dereference fanin cuts and reference node
656  Mpm_ObjDerefFaninCuts( p, pObj );
657  return 1;
658 }
void Mpm_ObjTranslateCutsFromStore(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmMap.c:547
static int Mig_ManChoiceNum(Mig_Man_t *p)
Definition: mpmMig.h:112
static int Mpm_ManExploreNewCut(Mpm_Man_t *p, Mig_Obj_t *pObj, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCut2, int Required)
Definition: mpmMap.c:401
static int Mig_ObjIsNode3(Mig_Obj_t *p)
Definition: mpmMig.h:139
static int Mig_ObjIsNode2(Mig_Obj_t *p)
Definition: mpmMig.h:138
static int Mpm_CutCreate(Mpm_Man_t *p, Mpm_Cut_t *pUni, Mpm_Cut_t **ppCut)
Definition: mpmMap.c:71
static int Mpm_ObjCutBest(Mpm_Man_t *p, Mig_Obj_t *pObj)
MACRO DEFINITIONS ///.
Definition: mpmInt.h:171
static int Mpm_ObjCutList(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:178
int nCuts[3]
Definition: mpmInt.h:120
static void Mpm_ObjSetCutBest(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:172
static Mig_Obj_t * Mig_ObjSibl(Mig_Obj_t *p)
Definition: mpmMig.h:190
static int Abc_TtCountOnes(word x)
Definition: utilTruth.h:1470
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Mpm_CutGetArrTime(Mpm_Man_t *p, Mpm_Cut_t *pCut)
Definition: mpmMap.c:166
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
abctime timeDerive
Definition: mpmInt.h:158
int fMainRun
Definition: mpmInt.h:105
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
int mTime
Definition: mpmInt.h:74
int nCutStore
Definition: mpmInt.h:112
Mpm_Uni_t * pCutStore[MPM_CUT_MAX+1]
Definition: mpmInt.h:113
int Mpm_ObjAddCutToStore(Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
Definition: mpmMap.c:225
static void Mpm_ObjSetTime(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:200
static Mpm_Cut_t * Mpm_ManMergeCuts(Mpm_Man_t *p, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCut2)
Definition: mpmMap.c:330
Mpm_Cut_t * pCuts[3][MPM_CUT_MAX+1]
Definition: mpmInt.h:121
static void Mpm_ObjDerefFaninCuts(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmMap.c:497
int mArea
Definition: mpmInt.h:75
static int Mpm_ObjRequired(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:196
int hNext
Definition: mpmInt.h:64
static void Mmr_StepRecycle(Mmr_Step_t *p, int h)
Definition: mem2.h:249
static int Mig_ObjSiblId(Mig_Obj_t *p)
Definition: mpmMig.h:188
static void Mpm_ObjSetEdge(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:206
int nNumCuts
Definition: mpmInt.h:101
static void Mpm_ObjSetArea(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:203
word pSigns[3][MPM_CUT_MAX+1]
Definition: mpmInt.h:122
Mig_Man_t * pMig
Definition: mpmInt.h:97
Mmr_Step_t * pManCuts
Definition: mpmInt.h:110
Mpm_Cut_t pCut
Definition: mpmInt.h:80
static Mpm_Cut_t * Mpm_ObjCutBestP(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:176
int mEdge
Definition: mpmInt.h:76
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t vFreeUnits
Definition: mpmInt.h:115
int nLutSize
Definition: mpmInt.h:100
ABC_INT64_T abctime
Definition: abc_global.h:278
void Mpm_ObjAddChoiceCutsToStore(Mpm_Man_t *p, Mig_Obj_t *pRoot, Mig_Obj_t *pObj, int ReqTime)
Definition: mpmMap.c:529
static void Mpm_ObjPrepareFanins(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmMap.c:521
static int Mpm_ManExploreNewCut ( Mpm_Man_t p,
Mig_Obj_t pObj,
Mpm_Cut_t pCut0,
Mpm_Cut_t pCut1,
Mpm_Cut_t pCut2,
int  Required 
)
inlinestatic

Definition at line 401 of file mpmMap.c.

402 {
403  Mpm_Cut_t * pCut;
404  int ArrTime;
405 #ifdef MIG_RUNTIME
406 abctime clk = clock();
407 #endif
408 
409  if ( pCut0->nLeaves >= pCut1->nLeaves )
410  {
411  pCut = Mpm_ManMergeCuts( p, pCut0, pCut1, pCut2 );
412 #ifdef MIG_RUNTIME
413 p->timeMerge += clock() - clk;
414 #endif
415  if ( pCut == NULL )
416  return 1;
417  if ( p->pPars->fUseTruth )
418  Mpm_CutComputeTruth( p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
419  else if ( p->pPars->fUseDsd )
420  {
421  if ( !Mpm_CutComputeDsd6( p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) )
422  return 1;
423  }
424  }
425  else
426  {
427  pCut = Mpm_ManMergeCuts( p, pCut1, pCut0, pCut2 );
428 #ifdef MIG_RUNTIME
429 p->timeMerge += clock() - clk;
430 #endif
431  if ( pCut == NULL )
432  return 1;
433  if ( p->pPars->fUseTruth )
434  Mpm_CutComputeTruth( p, pCut, pCut1, pCut0, pCut2, Mig_ObjFaninC1(pObj), Mig_ObjFaninC0(pObj), 1 ^ Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
435  else if ( p->pPars->fUseDsd )
436  {
437  if ( !Mpm_CutComputeDsd6( p, pCut, pCut1, pCut0, pCut2, Mig_ObjFaninC1(pObj), Mig_ObjFaninC0(pObj), 1 ^ Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) )
438  return 1;
439  }
440  }
441 
442 #ifdef MIG_RUNTIME
443 clk = clock();
444 #endif
445  ArrTime = Mpm_CutGetArrTime( p, pCut );
446 #ifdef MIG_RUNTIME
447 p->timeEval += clock() - clk;
448 #endif
449  if ( p->fMainRun && ArrTime > Required )
450  return 1;
451 
452 #ifdef MIG_RUNTIME
453 clk = Abc_Clock();
454 #endif
455  Mpm_ObjAddCutToStore( p, pCut, ArrTime );
456 #ifdef MIG_RUNTIME
457 p->timeStore += Abc_Clock() - clk;
458 #endif
459 
460 /*
461  // return 0 if const or buffer cut is derived - reset all cuts to contain only one --- does not work
462 // if ( pCut->nLeaves < 2 && p->nCutStore == 1 )
463 // return 0;
464  if ( pCut->nLeaves < 2 )
465  {
466  int i;
467  assert( p->nCutStore >= 1 );
468  for ( i = 1; i < p->nCutStore; i++ )
469  Vec_PtrPush( &p->vFreeUnits, p->pCutStore[i] );
470  p->nCutStore = 1;
471  return 0;
472  }
473 */
474  return 1;
475 }
Mpm_Par_t * pPars
Definition: mpmInt.h:98
int Mpm_CutComputeDsd6(Mpm_Man_t *p, Mpm_Cut_t *pCut, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, int Type)
Definition: mpmDsd.c:930
static int Mig_ObjFaninC0(Mig_Obj_t *p)
Definition: mpmMig.h:180
int Mpm_CutComputeTruth(Mpm_Man_t *p, Mpm_Cut_t *pCut, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, int Type)
Definition: mpmTruth.c:215
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Mpm_CutGetArrTime(Mpm_Man_t *p, Mpm_Cut_t *pCut)
Definition: mpmMap.c:166
int fMainRun
Definition: mpmInt.h:105
int Mpm_ObjAddCutToStore(Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
Definition: mpmMap.c:225
static Mpm_Cut_t * Mpm_ManMergeCuts(Mpm_Man_t *p, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCut2)
Definition: mpmMap.c:330
abctime timeStore
Definition: mpmInt.h:162
static int Mig_ObjFaninC1(Mig_Obj_t *p)
Definition: mpmMig.h:181
abctime timeMerge
Definition: mpmInt.h:159
static int Mig_ObjFaninC2(Mig_Obj_t *p)
Definition: mpmMig.h:182
abctime timeEval
Definition: mpmInt.h:160
unsigned nLeaves
Definition: mpmInt.h:68
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Mig_ObjNodeType(Mig_Obj_t *p)
Definition: mpmMig.h:144
int fUseTruth
Definition: mpm.h:64
int fUseDsd
Definition: mpm.h:65
static void Mpm_ManFinalizeRound ( Mpm_Man_t p)
inlinestatic

Definition at line 681 of file mpmMap.c.

682 {
683  int * pMapRefs = Vec_IntArray( &p->vMapRefs );
684  int * pRequired = Vec_IntArray( &p->vRequireds );
685  Mig_Obj_t * pObj;
686  Mpm_Cut_t * pCut;
687  int * pDelays;
688  int i, iLeaf;
689  p->GloArea = 0;
690  p->GloEdge = 0;
692  if ( p->pPars->DelayTarget != -1 )
694  Mpm_ManCleanMapRefs( p );
696  Mig_ManForEachObjReverse( p->pMig, pObj )
697  {
698  if ( Mig_ObjIsCo(pObj) )
699  {
700  pRequired[Mig_ObjFaninId0(pObj)] = p->GloRequired;
701  pMapRefs [Mig_ObjFaninId0(pObj)]++;
702  }
703  else if ( Mig_ObjIsNode(pObj) )
704  {
705  int Required = pRequired[Mig_ObjId(pObj)];
706  assert( Required > 0 );
707  if ( pMapRefs[Mig_ObjId(pObj)] > 0 )
708  {
709  pCut = Mpm_ObjCutBestP( p, pObj );
710  pDelays = p->pLibLut->pLutDelays[pCut->nLeaves];
711  Mpm_CutForEachLeafId( pCut, iLeaf, i )
712  {
713  pRequired[iLeaf] = Abc_MinInt( pRequired[iLeaf], Required - pDelays[i] );
714  pMapRefs [iLeaf]++;
715  }
716  p->GloArea += Mpm_CutGetArea( p, pCut );
717  p->GloEdge += pCut->nLeaves;
718  }
719  }
720  else if ( Mig_ObjIsBuf(pObj) )
721  {
722  }
723  }
724  p->GloArea /= MPM_UNIT_AREA;
725 }
word GloArea
Definition: mpmInt.h:107
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
Mpm_Par_t * pPars
Definition: mpmInt.h:98
int DelayTarget
Definition: mpm.h:62
static int Mpm_CutGetArea(Mpm_Man_t *p, Mpm_Cut_t *pCut)
Definition: mpmMap.c:148
#define Mig_ManForEachObjReverse(p, pObj)
Definition: mpmMig.h:312
Vec_Int_t vRequireds
Definition: mpmInt.h:147
Vec_Int_t vMapRefs
Definition: mpmInt.h:145
#define Mpm_CutForEachLeafId(pCut, iLeafId, i)
Definition: mpmInt.h:218
static int Mig_ObjIsNode(Mig_Obj_t *p)
Definition: mpmMig.h:137
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
Mpm_LibLut_t * pLibLut
Definition: mpmInt.h:103
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static int Mig_ObjIsBuf(Mig_Obj_t *p)
Definition: mpmMig.h:136
word GloEdge
Definition: mpmInt.h:108
static void Mpm_ManCleanRequired(Mpm_Man_t *p)
Definition: mpmInt.h:195
int pLutDelays[MPM_VAR_MAX+1][MPM_VAR_MAX+1]
Definition: mpm.h:53
#define MPM_UNIT_AREA
Definition: mpmInt.h:53
static void Mpm_ManCleanMapRefs(Mpm_Man_t *p)
Definition: mpmInt.h:188
Mig_Man_t * pMig
Definition: mpmInt.h:97
static int Mig_ObjFaninId0(Mig_Obj_t *p)
Definition: mpmMig.h:171
static int Mpm_ManFindArrivalMax(Mpm_Man_t *p)
Definition: mpmMap.c:672
static Mpm_Cut_t * Mpm_ObjCutBestP(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:176
#define assert(ex)
Definition: util_old.h:213
int GloRequired
Definition: mpmInt.h:106
unsigned nLeaves
Definition: mpmInt.h:68
static int Mig_ObjIsCo(Mig_Obj_t *p)
Definition: mpmMig.h:135
static int Mpm_ManFindArrivalMax ( Mpm_Man_t p)
inlinestatic

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

Synopsis [Required times.]

Description []

SideEffects []

SeeAlso []

Definition at line 672 of file mpmMap.c.

673 {
674  int * pmTimes = Vec_IntArray( &p->vTimes );
675  Mig_Obj_t * pObj;
676  int i, ArrMax = 0;
677  Mig_ManForEachCo( p->pMig, pObj, i )
678  ArrMax = Abc_MaxInt( ArrMax, pmTimes[ Mig_ObjFaninId0(pObj) ] );
679  return ArrMax;
680 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
#define Mig_ManForEachCo(p, pObj, i)
Definition: mpmMig.h:329
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Vec_Int_t vTimes
Definition: mpmInt.h:148
Mig_Man_t * pMig
Definition: mpmInt.h:97
static int Mig_ObjFaninId0(Mig_Obj_t *p)
Definition: mpmMig.h:171
static Mpm_Cut_t* Mpm_ManMergeCuts ( Mpm_Man_t p,
Mpm_Cut_t pCut0,
Mpm_Cut_t pCut1,
Mpm_Cut_t pCut2 
)
inlinestatic

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

Synopsis [Cut enumeration.]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file mpmMap.c.

331 {
332  Mpm_Cut_t * pTemp, * pCut = &((Mpm_Uni_t *)Vec_PtrEntryLast(&p->vFreeUnits))->pCut;
333  int i, c, iPlace;
334  // base cut
335  memcpy( pCut->pLeaves, pCut0->pLeaves, sizeof(int) * pCut0->nLeaves );
336  pCut->nLeaves = pCut0->nLeaves;
337  // remaining cuts
338  if ( p->pPars->fUseDsd )
339  {
340  for ( c = 1; c < 3; c++ )
341  {
342  pTemp = (c == 1) ? pCut1 : pCut2;
343  if ( pTemp == NULL )
344  break;
345  p->uPermMask[c] = 0x3FFFF; // 18 bits
346  p->uComplMask[c] = 0;
347  for ( i = 0; i < (int)pTemp->nLeaves; i++ )
348  {
349  iPlace = Mpm_CutFindLeaf( pCut, Abc_Lit2Var(pTemp->pLeaves[i]) );
350  if ( iPlace == (int)pCut->nLeaves )
351  {
352  if ( (int)pCut->nLeaves == p->nLutSize )
353  return NULL;
354  pCut->pLeaves[pCut->nLeaves++] = pTemp->pLeaves[i];
355  }
356  p->uPermMask[c] ^= (((i & 7) ^ 7) << (3*iPlace));
357  if ( pTemp->pLeaves[i] != pCut->pLeaves[iPlace] )
358  p->uComplMask[c] |= (1 << iPlace);
359  }
360  }
361  }
362  else
363  {
364  for ( c = 1; c < 3; c++ )
365  {
366  pTemp = (c == 1) ? pCut1 : pCut2;
367  if ( pTemp == NULL )
368  break;
369  for ( i = 0; i < (int)pTemp->nLeaves; i++ )
370  {
371  iPlace = Mpm_CutFindLeaf( pCut, Abc_Lit2Var(pTemp->pLeaves[i]) );
372  if ( iPlace == (int)pCut->nLeaves )
373  {
374  if ( (int)pCut->nLeaves == p->nLutSize )
375  return NULL;
376  pCut->pLeaves[pCut->nLeaves++] = pTemp->pLeaves[i];
377  }
378  }
379  }
380  }
381  if ( pCut1 == NULL )
382  {
383  pCut->hNext = 0;
384  pCut->iFunc = pCut0->iFunc;
385  pCut->fUseless = pCut0->fUseless;
386  pCut->fCompl = pCut0->fCompl;
387  }
388  else
389  {
390  pCut->hNext = 0;
391  pCut->iFunc = 0; pCut->iFunc = ~pCut->iFunc;
392  pCut->fUseless = 0;
393  pCut->fCompl = 0;
394  }
395  p->nCutsMerged++;
396  p->nCutsMergedAll++;
397  if ( p->pPars->fUseTruth )
398  Vec_IntSelectSort( pCut->pLeaves, pCut->nLeaves );
399  return pCut;
400 }
Mpm_Par_t * pPars
Definition: mpmInt.h:98
unsigned fCompl
Definition: mpmInt.h:66
int nCutsMergedAll
Definition: mpmInt.h:156
char * memcpy()
unsigned fUseless
Definition: mpmInt.h:67
static void Vec_IntSelectSort(int *pArray, int nSize)
Definition: vecInt.h:1740
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
static int Mpm_CutFindLeaf(Mpm_Cut_t *pNew, int iObj)
Definition: mpmMap.c:120
int hNext
Definition: mpmInt.h:64
unsigned uComplMask[3]
Definition: mpmInt.h:139
int nCutsMerged
Definition: mpmInt.h:155
unsigned uPermMask[3]
Definition: mpmInt.h:138
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int pLeaves[1]
Definition: mpmInt.h:69
Vec_Ptr_t vFreeUnits
Definition: mpmInt.h:115
unsigned nLeaves
Definition: mpmInt.h:68
int nLutSize
Definition: mpmInt.h:100
int fUseTruth
Definition: mpm.h:64
unsigned iFunc
Definition: mpmInt.h:65
int fUseDsd
Definition: mpm.h:65
void Mpm_ManPerform ( Mpm_Man_t p)

Definition at line 833 of file mpmMap.c.

834 {
835  if ( p->pPars->fMap4Cnf )
836  {
838  Mpm_ManPerformRound( p );
839  }
840  else
841  {
843  Mpm_ManPerformRound( p );
844  if ( p->pPars->fOneRound )
845  return;
846 
848  Mpm_ManPerformRound( p );
849 
851  Mpm_ManPerformRound( p );
852 
853  p->fMainRun = 1;
854 
857  Mpm_ManPerformRound( p );
858 
861  Mpm_ManPerformRound( p );
862  }
863 }
Mpm_Par_t * pPars
Definition: mpmInt.h:98
int Mpm_CutCompareDelay2(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition: mpmMap.c:756
int fOneRound
Definition: mpm.h:67
int Mpm_CutCompareArea(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition: mpmMap.c:764
int fMainRun
Definition: mpmInt.h:105
int(* pCutCmp)(Mpm_Uni_t *, Mpm_Uni_t *)
Definition: mpmInt.h:118
void Mpm_ManPerformRound(Mpm_Man_t *p)
Definition: mpmMap.c:807
int fMap4Cnf
Definition: mpm.h:69
int Mpm_CutCompareArea2(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition: mpmMap.c:773
int Mpm_CutCompareDelay(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
Definition: mpmMap.c:748
static void Mpm_ManComputeEstRefs(Mpm_Man_t *p)
Definition: mpmMap.c:726
void Mpm_ManPerformRound ( Mpm_Man_t p)

Definition at line 807 of file mpmMap.c.

808 {
809  Mig_Obj_t * pObj;
810  abctime clk = Abc_Clock();
811  int i;
812  // copy references
813  assert( Vec_IntSize(&p->vMigRefs) == Vec_IntSize(&p->pMig->vRefs) );
814  memcpy( Vec_IntArray(&p->vMigRefs), Vec_IntArray(&p->pMig->vRefs), sizeof(int) * Mig_ManObjNum(p->pMig) );
815  Mig_ManForEachCo( p->pMig, pObj, i )
816  Mig_ObjMigRefDec( p, Mig_ObjFanin0(pObj) );
817  // derive cuts
818  p->nCutsMerged = 0;
819  Mig_ManForEachNode( p->pMig, pObj )
820  Mpm_ManDeriveCuts( p, pObj );
821  assert( Mig_ManCandNum(p->pMig) == p->pManCuts->nEntries );
823  // report results
824  if ( p->pPars->fVerbose )
825  {
826  printf( "Del =%5d. Ar =%8d. Edge =%8d. Cut =%10d. Max =%8d. Tru =%8d. Small =%6d. ",
827  p->GloRequired, (int)p->GloArea, (int)p->GloEdge,
828  p->nCutsMerged, p->pManCuts->nEntriesMax,
829  p->vTtMem ? p->vTtMem->nEntries : 0, p->nSmallSupp );
830  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
831  }
832 }
#define Mig_ManForEachNode(p, pObj)
Definition: mpmMig.h:322
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Mig_ObjMigRefDec(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:186
static int Mig_ManObjNum(Mig_Man_t *p)
Definition: mpmMig.h:109
#define Mig_ManForEachCo(p, pObj, i)
Definition: mpmMig.h:329
Vec_Int_t vRefs
Definition: mpmMig.h:78
static int Mig_ManCandNum(Mig_Man_t *p)
Definition: mpmMig.h:111
char * memcpy()
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Mpm_ManFinalizeRound(Mpm_Man_t *p)
Definition: mpmMap.c:681
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
if(last==0)
Definition: sparse_int.h:34
static Mig_Obj_t * Mig_ObjFanin0(Mig_Obj_t *p)
Definition: mpmMig.h:176
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Mig_Man_t * pMig
Definition: mpmInt.h:97
Vec_Int_t vMigRefs
Definition: mpmInt.h:144
#define assert(ex)
Definition: util_old.h:213
int Mpm_ManDeriveCuts(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmMap.c:580
ABC_INT64_T abctime
Definition: abc_global.h:278
void Mpm_ManPrepare ( Mpm_Man_t p)

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

Synopsis [Technology mapping experiment.]

Description []

SideEffects []

SeeAlso []

Definition at line 794 of file mpmMap.c.

795 {
796  Mig_Obj_t * pObj;
797  int i, hCut;
798  Mig_ManForEachCi( p->pMig, pObj, i )
799  {
800  hCut = Mpm_CutCreateUnit( p, Mig_ObjId(pObj) );
801  Mpm_ObjSetCutBest( p, pObj, hCut );
802  Mpm_ObjSetCutList( p, pObj, hCut );
803  }
804  Mig_ManForEachCand( p->pMig, pObj )
805  Mpm_ObjSetEstRef( p, pObj, MPM_UNIT_REFS * Mig_ObjRefNum(pObj) );
806 }
#define MPM_UNIT_REFS
Definition: mpmInt.h:55
static void Mpm_ObjSetEstRef(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:193
static int Mig_ObjRefNum(Mig_Obj_t *p)
Definition: mpmMig.h:191
static void Mpm_ObjSetCutBest(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:172
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
#define Mig_ManForEachCand(p, pObj)
Definition: mpmMig.h:324
static int Mpm_CutCreateUnit(Mpm_Man_t *p, int Id)
Definition: mpmMap.c:63
Mig_Man_t * pMig
Definition: mpmInt.h:97
#define Mig_ManForEachCi(p, pObj, i)
Definition: mpmMig.h:327
static void Mpm_ObjSetCutList(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:180
void Mpm_ObjAddChoiceCutsToStore ( Mpm_Man_t p,
Mig_Obj_t pRoot,
Mig_Obj_t pObj,
int  ReqTime 
)

Definition at line 529 of file mpmMap.c.

530 {
531  Mpm_Cut_t * pCut;
532  int hCut, hNext, ArrTime;
533  int fCompl = Mig_ObjPhase(pRoot) ^ Mig_ObjPhase(pObj);
534  Mpm_ObjForEachCutSafe( p, pObj, hCut, pCut, hNext )
535  {
536  if ( Abc_Lit2Var(pCut->pLeaves[0]) == Mig_ObjId(pObj) )
537  continue;
538  ArrTime = Mpm_CutGetArrTime( p, pCut );
539  if ( ArrTime > ReqTime )
540  continue;
541  pCut->fCompl ^= fCompl;
542  pCut = Mpm_ManMergeCuts( p, pCut, NULL, NULL );
543  Mpm_ObjAddCutToStore( p, pCut, ArrTime );
544  }
545 }
unsigned fCompl
Definition: mpmInt.h:66
static int Mig_ObjPhase(Mig_Obj_t *p)
Definition: mpmMig.h:150
static int Mpm_CutGetArrTime(Mpm_Man_t *p, Mpm_Cut_t *pCut)
Definition: mpmMap.c:166
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
int Mpm_ObjAddCutToStore(Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
Definition: mpmMap.c:225
static Mpm_Cut_t * Mpm_ManMergeCuts(Mpm_Man_t *p, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCut2)
Definition: mpmMap.c:330
#define Mpm_ObjForEachCutSafe(p, pObj, hCut, pCut, hNext)
Definition: mpmInt.h:214
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int pLeaves[1]
Definition: mpmInt.h:69
int Mpm_ObjAddCutToStore ( Mpm_Man_t p,
Mpm_Cut_t pCut,
int  ArrTime 
)

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

Synopsis [Compares cut against those present in the store.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file mpmMap.c.

226 {
227  int fEnableContainment = 1;
228  Mpm_Uni_t * pUnit, * pUnitNew;
229  int k, iPivot, last;
230  // create new unit
231 #ifdef MIG_RUNTIME
232  abctime clk;
233 clk = Abc_Clock();
234 #endif
235  pUnitNew = Mpm_CutSetupInfo( p, pCut, ArrTime );
236 #ifdef MIG_RUNTIME
237 p->timeEval += Abc_Clock() - clk;
238 #endif
239  // special case when the cut store is empty
240  if ( p->nCutStore == 0 )
241  {
242  p->pCutStore[p->nCutStore++] = pUnitNew;
243  Vec_PtrPop( &p->vFreeUnits );
244  return 1;
245  }
246  // special case when the cut store is full and last cut is better than new cut
247  if ( p->nCutStore == p->nNumCuts-1 && p->pCutCmp(pUnitNew, p->pCutStore[p->nCutStore-1]) > 0 )
248  return 0;
249 
250  // find place of the given cut in the store
251  assert( p->nCutStore <= p->nNumCuts );
252  for ( iPivot = p->nCutStore - 1; iPivot >= 0; iPivot-- )
253  if ( p->pCutCmp(pUnitNew, p->pCutStore[iPivot]) > 0 ) // iPivot-th cut is better than new cut
254  break;
255 
256  if ( fEnableContainment )
257  {
258 #ifdef MIG_RUNTIME
259 clk = Abc_Clock();
260 #endif
261  // filter this cut using other cuts
262  for ( k = 0; k <= iPivot; k++ )
263  {
264  pUnit = p->pCutStore[k];
265  if ( pUnitNew->pCut.nLeaves >= pUnit->pCut.nLeaves &&
266  (pUnitNew->uSign & pUnit->uSign) == pUnit->uSign &&
267  Mpm_CutIsContained(p, &pUnitNew->pCut, &pUnit->pCut) )
268  {
269 #ifdef MIG_RUNTIME
270 p->timeCompare += Abc_Clock() - clk;
271 #endif
272  return 0;
273  }
274  }
275  }
276 
277  // special case when the best cut is useless while the new cut is not
278  if ( p->pCutStore[0]->pCut.fUseless && !pUnitNew->pCut.fUseless )
279  iPivot = -1;
280 
281  // add the cut to storage
282  assert( pUnitNew == (Mpm_Uni_t *)Vec_PtrEntryLast(&p->vFreeUnits) );
283  Vec_PtrPop( &p->vFreeUnits );
284 
285  // insert this cut at location iPivot
286  iPivot++;
287  for ( k = p->nCutStore++; k > iPivot; k-- )
288  p->pCutStore[k] = p->pCutStore[k-1];
289  p->pCutStore[iPivot] = pUnitNew;
290 
291  if ( fEnableContainment )
292  {
293  // filter other cuts using this cut
294  for ( k = last = iPivot+1; k < p->nCutStore; k++ )
295  {
296  pUnit = p->pCutStore[k];
297  if ( pUnitNew->pCut.nLeaves <= pUnit->pCut.nLeaves &&
298  (pUnitNew->uSign & pUnit->uSign) == pUnitNew->uSign &&
299  Mpm_CutIsContained(p, &pUnit->pCut, &pUnitNew->pCut) )
300  {
301  Vec_PtrPush( &p->vFreeUnits, pUnit );
302  continue;
303  }
304  p->pCutStore[last++] = p->pCutStore[k];
305  }
306  p->nCutStore = last;
307 #ifdef MIG_RUNTIME
308 p->timeCompare += Abc_Clock() - clk;
309 #endif
310  }
311 
312  // remove the last cut if too many
313  if ( p->nCutStore == p->nNumCuts )
314  Vec_PtrPush( &p->vFreeUnits, p->pCutStore[--p->nCutStore] );
315  assert( p->nCutStore < p->nNumCuts );
316  return 1;
317 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static abctime Abc_Clock()
Definition: abc_global.h:279
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
int nCutStore
Definition: mpmInt.h:112
int(* pCutCmp)(Mpm_Uni_t *, Mpm_Uni_t *)
Definition: mpmInt.h:118
Mpm_Uni_t * pCutStore[MPM_CUT_MAX+1]
Definition: mpmInt.h:113
unsigned fUseless
Definition: mpmInt.h:67
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
abctime timeCompare
Definition: mpmInt.h:161
static Mpm_Uni_t * Mpm_CutSetupInfo(Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
Definition: mpmMap.c:175
static int Mpm_CutIsContained(Mpm_Man_t *p, Mpm_Cut_t *pBase, Mpm_Cut_t *pCut)
Definition: mpmMap.c:128
int nNumCuts
Definition: mpmInt.h:101
word uSign
Definition: mpmInt.h:78
abctime timeEval
Definition: mpmInt.h:160
Mpm_Cut_t pCut
Definition: mpmInt.h:80
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t vFreeUnits
Definition: mpmInt.h:115
unsigned nLeaves
Definition: mpmInt.h:68
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Mpm_ObjCollectFaninsAndSigns ( Mpm_Man_t p,
Mig_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 510 of file mpmMap.c.

511 {
512  Mpm_Cut_t * pCut;
513  int hCut, nCuts = 0;
514  Mpm_ObjForEachCut( p, pObj, hCut, pCut )
515  {
516  p->pCuts[i][nCuts] = pCut;
517  p->pSigns[i][nCuts++] = Mpm_CutGetSign( pCut );
518  }
519  p->nCuts[i] = nCuts;
520 }
int nCuts[3]
Definition: mpmInt.h:120
Mpm_Cut_t * pCuts[3][MPM_CUT_MAX+1]
Definition: mpmInt.h:121
word pSigns[3][MPM_CUT_MAX+1]
Definition: mpmInt.h:122
#define Mpm_ObjForEachCut(p, pObj, hCut, pCut)
Definition: mpmInt.h:212
static word Mpm_CutGetSign(Mpm_Cut_t *pCut)
Definition: mpmMap.c:158
static void Mpm_ObjDerefFaninCuts ( Mpm_Man_t p,
Mig_Obj_t pObj 
)
inlinestatic

Definition at line 497 of file mpmMap.c.

498 {
499  Mig_Obj_t * pFanin;
500  int i;
501  Mig_ObjForEachFanin( pObj, pFanin, i )
502  if ( Mig_ObjIsNode(pFanin) && Mig_ObjMigRefDec(p, pFanin) == 0 )
503  Mpm_ObjRecycleCuts( p, pFanin );
504  pFanin = Mig_ObjSibl(pObj);
505  if ( pFanin && Mig_ObjMigRefDec(p, pFanin) == 0 )
506  Mpm_ObjRecycleCuts( p, pFanin );
507  if ( Mig_ObjMigRefNum(p, pObj) == 0 )
508  Mpm_ObjRecycleCuts( p, pObj );
509 }
static int Mig_ObjMigRefDec(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:186
static int Mig_ObjIsNode(Mig_Obj_t *p)
Definition: mpmMig.h:137
static Mig_Obj_t * Mig_ObjSibl(Mig_Obj_t *p)
Definition: mpmMig.h:190
if(last==0)
Definition: sparse_int.h:34
#define Mig_ObjForEachFanin(p, pFanin, i)
Definition: mpmMig.h:335
static int Mig_ObjMigRefNum(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:185
static void Mpm_ObjRecycleCuts(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmMap.c:489
static void Mpm_ObjPrepareFanins ( Mpm_Man_t p,
Mig_Obj_t pObj 
)
inlinestatic

Definition at line 521 of file mpmMap.c.

522 {
523  Mig_Obj_t * pFanin;
524  int i;
525  Mig_ObjForEachFanin( pObj, pFanin, i )
526  Mpm_ObjCollectFaninsAndSigns( p, pFanin, i );
527 }
static void Mpm_ObjCollectFaninsAndSigns(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmMap.c:510
#define Mig_ObjForEachFanin(p, pFanin, i)
Definition: mpmMig.h:335
static void Mpm_ObjRecycleCuts ( Mpm_Man_t p,
Mig_Obj_t pObj 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file mpmMap.c.

490 {
491  Mpm_Cut_t * pCut;
492  int hCut, hNext;
493  Mpm_ObjForEachCutSafe( p, pObj, hCut, pCut, hNext )
494  Mmr_StepRecycle( p->pManCuts, hCut );
495  Mpm_ObjSetCutList( p, pObj, 0 );
496 }
static void Mmr_StepRecycle(Mmr_Step_t *p, int h)
Definition: mem2.h:249
#define Mpm_ObjForEachCutSafe(p, pObj, hCut, pCut, hNext)
Definition: mpmInt.h:214
static void Mpm_ObjSetCutList(Mpm_Man_t *p, Mig_Obj_t *pObj, int i)
Definition: mpmInt.h:180
void Mpm_ObjTranslateCutsFromStore ( Mpm_Man_t p,
Mig_Obj_t pObj 
)

Definition at line 547 of file mpmMap.c.

548 {
549  Mpm_Cut_t * pCut = NULL;
550  Mpm_Uni_t * pUnit;
551  int i, *pList = Mpm_ObjCutListP( p, pObj );
552  assert( p->nCutStore > 0 && p->nCutStore <= p->nNumCuts );
553  assert( *pList == 0 );
554  // translate cuts
555  for ( i = 0; i < p->nCutStore; i++ )
556  {
557  pUnit = p->pCutStore[i];
558  *pList = Mpm_CutCreate( p, &pUnit->pCut, &pCut );
559  pList = &pCut->hNext;
560  Vec_PtrPush( &p->vFreeUnits, pUnit );
561  }
562  assert( Vec_PtrSize(&p->vFreeUnits) == p->nNumCuts + 1 );
563  if ( p->nCutStore == 1 && pCut->nLeaves < 2 )
564  *pList = 0;
565  else
566  *pList = Mpm_CutCreateUnit( p, Mig_ObjId(pObj) );
567 }
static int Mpm_CutCreate(Mpm_Man_t *p, Mpm_Cut_t *pUni, Mpm_Cut_t **ppCut)
Definition: mpmMap.c:71
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Mig_ObjId(Mig_Obj_t *p)
Definition: mpmMig.h:146
int nCutStore
Definition: mpmInt.h:112
static int * Mpm_ObjCutListP(Mpm_Man_t *p, Mig_Obj_t *pObj)
Definition: mpmInt.h:179
Mpm_Uni_t * pCutStore[MPM_CUT_MAX+1]
Definition: mpmInt.h:113
static int Mpm_CutCreateUnit(Mpm_Man_t *p, int Id)
Definition: mpmMap.c:63
int hNext
Definition: mpmInt.h:64
int nNumCuts
Definition: mpmInt.h:101
Mpm_Cut_t pCut
Definition: mpmInt.h:80
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t vFreeUnits
Definition: mpmInt.h:115
unsigned nLeaves
Definition: mpmInt.h:68