abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mapperCutUtils.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mapperCutUtils.c]
4 
5  PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
6 
7  Synopsis [Generic technology mapping engine.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 2.0. Started - June 1, 2004.]
14 
15  Revision [$Id: mapperCutUtils.h,v 1.0 2003/09/08 00:00:00 alanmi Exp $]
16 
17 ***********************************************************************/
18 
19 #include "mapperInt.h"
20 
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 /// DECLARATIONS ///
26 ////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// FUNCTION DEFINITIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 /**Function*************************************************************
33 
34  Synopsis [Allocates the cut.]
35 
36  Description []
37 
38  SideEffects []
39 
40  SeeAlso []
41 
42 ***********************************************************************/
44 {
45  Map_Cut_t * pCut;
46  Map_Match_t * pMatch;
47  pCut = (Map_Cut_t *)Extra_MmFixedEntryFetch( p->mmCuts );
48  memset( pCut, 0, sizeof(Map_Cut_t) );
49 
50  pMatch = pCut->M;
51  pMatch->AreaFlow = MAP_FLOAT_LARGE; // unassigned
52  pMatch->tArrive.Rise = MAP_FLOAT_LARGE; // unassigned
53  pMatch->tArrive.Fall = MAP_FLOAT_LARGE; // unassigned
54  pMatch->tArrive.Worst = MAP_FLOAT_LARGE; // unassigned
55 
56  pMatch = pCut->M + 1;
57  pMatch->AreaFlow = MAP_FLOAT_LARGE; // unassigned
58  pMatch->tArrive.Rise = MAP_FLOAT_LARGE; // unassigned
59  pMatch->tArrive.Fall = MAP_FLOAT_LARGE; // unassigned
60  pMatch->tArrive.Worst = MAP_FLOAT_LARGE; // unassigned
61  return pCut;
62 }
63 
64 /**Function*************************************************************
65 
66  Synopsis [Deallocates the cut.]
67 
68  Description []
69 
70  SideEffects []
71 
72  SeeAlso []
73 
74 ***********************************************************************/
75 void Map_CutFree( Map_Man_t * p, Map_Cut_t * pCut )
76 {
77  if ( pCut )
78  Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
79 }
80 
81 /**Function*************************************************************
82 
83  Synopsis []
84 
85  Description []
86 
87  SideEffects []
88 
89  SeeAlso []
90 
91 ***********************************************************************/
92 void Map_CutPrint( Map_Man_t * p, Map_Node_t * pRoot, Map_Cut_t * pCut, int fPhase )
93 {
94  int i;
95  printf( "CUT: Delay = (%4.2f, %4.2f). Area = %4.2f. Nodes = %d -> {",
96  pCut->M[fPhase].tArrive.Rise, pCut->M[fPhase].tArrive.Fall, pCut->M[fPhase].AreaFlow, pRoot->Num );
97  for ( i = 0; i < pCut->nLeaves; i++ )
98  printf( " %d", pCut->ppLeaves[i]->Num );
99  printf( " } \n" );
100 }
101 
102 
103 /**function*************************************************************
104 
105  synopsis [Computes the exact area associated with the cut.]
106 
107  description []
108 
109  sideeffects []
110 
111  seealso []
112 
113 ***********************************************************************/
114 float Map_CutGetRootArea( Map_Cut_t * pCut, int fPhase )
115 {
116  assert( pCut->M[fPhase].pSuperBest );
117  return pCut->M[fPhase].pSuperBest->Area;
118 }
119 
120 /**function*************************************************************
121 
122  synopsis [Computes the exact area associated with the cut.]
123 
124  description []
125 
126  sideeffects []
127 
128  seealso []
129 
130 ***********************************************************************/
131 int Map_CutGetLeafPhase( Map_Cut_t * pCut, int fPhase, int iLeaf )
132 {
133  assert( pCut->M[fPhase].pSuperBest );
134  return (( pCut->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
135 }
136 
137 /**function*************************************************************
138 
139  synopsis [Computes the exact area associated with the cut.]
140 
141  description []
142 
143  sideeffects []
144 
145  seealso []
146 
147 ***********************************************************************/
148 int Map_NodeGetLeafPhase( Map_Node_t * pNode, int fPhase, int iLeaf )
149 {
150  assert( pNode->pCutBest[fPhase]->M[fPhase].pSuperBest );
151  return (( pNode->pCutBest[fPhase]->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
152 }
153 
154 /**Function*************************************************************
155 
156  Synopsis []
157 
158  Description []
159 
160  SideEffects []
161 
162  SeeAlso []
163 
164 ***********************************************************************/
166 {
167  Map_Cut_t * pPrev = NULL; // Suppress "might be used uninitialized"
168  Map_Cut_t * pTemp;
169  if ( pSetAll == NULL )
170  return pSets;
171  if ( pSets == NULL )
172  return pSetAll;
173  // find the last one
174  for ( pTemp = pSets; pTemp; pTemp = pTemp->pNext )
175  pPrev = pTemp;
176  // append all the end of the current set
177  assert( pPrev->pNext == NULL );
178  pPrev->pNext = pSetAll;
179  return pSets;
180 }
181 
182 /**Function*************************************************************
183 
184  Synopsis []
185 
186  Description []
187 
188  SideEffects []
189 
190  SeeAlso []
191 
192 ***********************************************************************/
193 void Map_CutListRecycle( Map_Man_t * p, Map_Cut_t * pSetList, Map_Cut_t * pSave )
194 {
195  Map_Cut_t * pNext, * pTemp;
196  for ( pTemp = pSetList, pNext = pTemp? pTemp->pNext : NULL;
197  pTemp;
198  pTemp = pNext, pNext = pNext? pNext->pNext : NULL )
199  if ( pTemp != pSave )
200  Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pTemp );
201 }
202 
203 /**Function*************************************************************
204 
205  Synopsis []
206 
207  Description []
208 
209  SideEffects []
210 
211  SeeAlso []
212 
213 ***********************************************************************/
215 {
216  Map_Cut_t * pTemp;
217  int i;
218  for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
219  return i;
220 }
221 
222 #if 0
223 
224 /**function*************************************************************
225 
226  synopsis [Removes the fanouts of the cut.]
227 
228  description []
229 
230  sideeffects []
231 
232  seealso []
233 
234 ***********************************************************************/
235 void Map_CutRemoveFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
236 {
237  Map_NodeVec_t * vFanouts;
238  int i, k;
239  for ( i = 0; i < pCut->nLeaves; i++ )
240  {
241  vFanouts = pCut->ppLeaves[i]->vFanouts;
242  for ( k = 0; k < vFanouts->nSize; k++ )
243  if ( vFanouts->pArray[k] == pNode )
244  break;
245  assert( k != vFanouts->nSize );
246  for ( k++; k < vFanouts->nSize; k++ )
247  vFanouts->pArray[k-1] = vFanouts->pArray[k];
248  vFanouts->nSize--;
249  }
250 }
251 
252 /**function*************************************************************
253 
254  synopsis [Removes the fanouts of the cut.]
255 
256  description []
257 
258  sideeffects []
259 
260  seealso []
261 
262 ***********************************************************************/
263 void Map_CutInsertFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
264 {
265  int i;
266  for ( i = 0; i < pCut->nLeaves; i++ )
267  Map_NodeVecPush( pCut->ppLeaves[i]->vFanouts, pNode );
268 }
269 
270 #endif
271 
272 
273 ////////////////////////////////////////////////////////////////////////
274 /// END OF FILE ///
275 ////////////////////////////////////////////////////////////////////////
276 
277 
279 
char * memset()
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
void Map_CutInsertFanouts(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
unsigned uPhaseBest
Definition: mapperInt.h:252
ABC_NAMESPACE_IMPL_START Map_Cut_t * Map_CutAlloc(Map_Man_t *p)
DECLARATIONS ///.
void Map_CutRemoveFanouts(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
Map_Cut_t * pNext
Definition: mapperInt.h:262
float Map_CutGetRootArea(Map_Cut_t *pCut, int fPhase)
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
int Map_NodeGetLeafPhase(Map_Node_t *pNode, int fPhase, int iLeaf)
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
Map_Time_t tArrive
Definition: mapperInt.h:255
void Map_CutListRecycle(Map_Man_t *p, Map_Cut_t *pSetList, Map_Cut_t *pSave)
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition: mapper.h:40
int Map_CutGetLeafPhase(Map_Cut_t *pCut, int fPhase, int iLeaf)
Map_Cut_t * Map_CutListAppend(Map_Cut_t *pSetAll, Map_Cut_t *pSets)
#define assert(ex)
Definition: util_old.h:213
int Map_CutListCount(Map_Cut_t *pSets)
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
void Map_CutPrint(Map_Man_t *p, Map_Node_t *pRoot, Map_Cut_t *pCut, int fPhase)
void Map_NodeVecPush(Map_NodeVec_t *p, Map_Node_t *Entry)
Definition: mapperVec.c:190
Map_Match_t M[2]
Definition: mapperInt.h:271
Map_Node_t * ppLeaves[6]
Definition: mapperInt.h:265
void Map_CutFree(Map_Man_t *p, Map_Cut_t *pCut)