ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mapperRefs.c File Reference
#include "mapperInt.h"
Include dependency graph for mapperRefs.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Map_NodeReadRefPhaseAct (Map_Node_t *pNode, int fPhase)
 DECLARATIONS ///.
 
float Map_NodeReadRefPhaseEst (Map_Node_t *pNode, int fPhase)
 
int Map_NodeIncRefPhaseAct (Map_Node_t *pNode, int fPhase)
 
int Map_NodeDecRefPhaseAct (Map_Node_t *pNode, int fPhase)
 
void Map_MappingEstimateRefsInit (Map_Man_t *p)
 
void Map_MappingEstimateRefs (Map_Man_t *p)
 
float Map_CutGetAreaFlow (Map_Cut_t *pCut, int fPhase)
 
float Map_CutRefDeref (Map_Cut_t *pCut, int fPhase, int fReference, int fUpdateProf)
 
float Map_CutGetAreaRefed (Map_Cut_t *pCut, int fPhase)
 
float Map_CutGetAreaDerefed (Map_Cut_t *pCut, int fPhase)
 
float Map_CutRef (Map_Cut_t *pCut, int fPhase, int fProfile)
 
float Map_CutDeref (Map_Cut_t *pCut, int fPhase, int fProfile)
 
void Map_MappingSetRefs_rec (Map_Man_t *pMan, Map_Node_t *pNode)
 
void Map_MappingSetRefs (Map_Man_t *pMan)
 
float Map_MappingGetArea (Map_Man_t *pMan)
 

Function Documentation

◆ Map_CutDeref()

float Map_CutDeref ( Map_Cut_t * pCut,
int fPhase,
int fProfile )

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

synopsis [Dereferences the cut.]

description []

sideeffects []

seealso []

Definition at line 391 of file mapperRefs.c.

392{
393 return Map_CutRefDeref( pCut, fPhase, 0, fProfile ); // dereference
394}
float Map_CutRefDeref(Map_Cut_t *pCut, int fPhase, int fReference, int fUpdateProf)
Definition mapperRefs.c:229
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_CutGetAreaDerefed()

float Map_CutGetAreaDerefed ( Map_Cut_t * pCut,
int fPhase )

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

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

description []

sideeffects []

seealso []

Definition at line 355 of file mapperRefs.c.

356{
357 float aResult, aResult2;
358 aResult2 = Map_CutRefDeref( pCut, fPhase, 1, 0 ); // reference
359 aResult = Map_CutRefDeref( pCut, fPhase, 0, 0 ); // dereference
360// assert( aResult == aResult2 );
361 return aResult;
362}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_CutGetAreaFlow()

float Map_CutGetAreaFlow ( Map_Cut_t * pCut,
int fPhase )

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

synopsis [Computes the area flow of the cut.]

description [Computes the area flow of the cut if it is implemented using the best supergate with the best phase.]

sideeffects []

seealso []

Definition at line 179 of file mapperRefs.c.

180{
181 Map_Match_t * pM = pCut->M + fPhase;
182 Map_Super_t * pSuper = pM->pSuperBest;
183 unsigned uPhaseTot = pM->uPhaseBest;
184 Map_Cut_t * pCutFanin;
185 float aFlowRes, aFlowFanin, nRefs;
186 int i, fPinPhasePos;
187
188 // start the resulting area flow
189 aFlowRes = pSuper->Area;
190 // iterate through the leaves
191 for ( i = 0; i < pCut->nLeaves; i++ )
192 {
193 // get the phase of this fanin
194 fPinPhasePos = ((uPhaseTot & (1 << i)) == 0);
195 // get the cut implementing this phase of the fanin
196 pCutFanin = pCut->ppLeaves[i]->pCutBest[fPinPhasePos];
197 // if the cut is not available, we have to use the opposite phase
198 if ( pCutFanin == NULL )
199 {
200 fPinPhasePos = !fPinPhasePos;
201 pCutFanin = pCut->ppLeaves[i]->pCutBest[fPinPhasePos];
202 }
203 aFlowFanin = pCutFanin->M[fPinPhasePos].AreaFlow; // ignores the area of the interter
204 // get the fanout count of the cut in the given phase
205 nRefs = Map_NodeReadRefPhaseEst( pCut->ppLeaves[i], fPinPhasePos );
206 // if the node does no fanout, assume fanout count equal to 1
207 if ( nRefs == (float)0.0 )
208 nRefs = (float)1.0;
209 // add the area flow due to the fanin
210 aFlowRes += aFlowFanin / nRefs;
211 }
212 pM->AreaFlow = aFlowRes;
213 return aFlowRes;
214}
float Map_NodeReadRefPhaseEst(Map_Node_t *pNode, int fPhase)
Definition mapperRefs.c:63
struct Map_MatchStruct_t_ Map_Match_t
Definition mapper.h:44
struct Map_CutStruct_t_ Map_Cut_t
Definition mapper.h:43
struct Map_SuperStruct_t_ Map_Super_t
Definition mapper.h:45
Map_Match_t M[2]
Definition mapperInt.h:275
Map_Node_t * ppLeaves[6]
Definition mapperInt.h:269
Map_Super_t * pSuperBest
Definition mapperInt.h:257
unsigned uPhaseBest
Definition mapperInt.h:256
Map_Cut_t * pCutBest[2]
Definition mapperInt.h:243
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_CutGetAreaRefed()

float Map_CutGetAreaRefed ( Map_Cut_t * pCut,
int fPhase )

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

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

description [Assumes that the cut is referenced.]

sideeffects []

seealso []

Definition at line 335 of file mapperRefs.c.

336{
337 float aResult, aResult2;
338 aResult2 = Map_CutRefDeref( pCut, fPhase, 0, 0 ); // dereference
339 aResult = Map_CutRefDeref( pCut, fPhase, 1, 0 ); // reference
340// assert( aResult == aResult2 );
341 return aResult;
342}
Here is the call graph for this function:

◆ Map_CutRef()

float Map_CutRef ( Map_Cut_t * pCut,
int fPhase,
int fProfile )

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

synopsis [References the cut.]

description []

sideeffects []

seealso []

Definition at line 375 of file mapperRefs.c.

376{
377 return Map_CutRefDeref( pCut, fPhase, 1, fProfile ); // reference
378}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_CutRefDeref()

float Map_CutRefDeref ( Map_Cut_t * pCut,
int fPhase,
int fReference,
int fUpdateProf )

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

synopsis [References or dereferences the cut.]

description [This reference part is similar to Cudd_NodeReclaim(). The dereference part is similar to Cudd_RecursiveDeref().]

sideeffects []

seealso []

Definition at line 229 of file mapperRefs.c.

230{
231 Map_Node_t * pNodeChild;
232 Map_Cut_t * pCutChild;
233 float aArea;
234 int i, fPhaseChild;
235// int nRefs;
236
237 // consider the elementary variable
238 if ( pCut->nLeaves == 1 )
239 return 0;
240 // start the area of this cut
241 aArea = Map_CutGetRootArea( pCut, fPhase );
242 if ( fUpdateProf )
243 {
244 if ( fReference )
245 Mio_GateIncProfile2( pCut->M[fPhase].pSuperBest->pRoot );
246 else
247 Mio_GateDecProfile2( pCut->M[fPhase].pSuperBest->pRoot );
248 }
249 // go through the children
250 for ( i = 0; i < pCut->nLeaves; i++ )
251 {
252 pNodeChild = pCut->ppLeaves[i];
253 fPhaseChild = Map_CutGetLeafPhase( pCut, fPhase, i );
254 // get the reference counter of the child
255/*
256 // this code does not take inverters into account
257 // the quality of area recovery seems to always be a little worse
258 if ( fReference )
259 nRefs = Map_NodeIncRefPhaseAct( pNodeChild, fPhaseChild );
260 else
261 nRefs = Map_NodeDecRefPhaseAct( pNodeChild, fPhaseChild );
262 assert( nRefs >= 0 );
263 // skip if the child was already reference before
264 if ( nRefs > 0 )
265 continue;
266*/
267
268 if ( fReference )
269 {
270 if ( pNodeChild->pCutBest[0] && pNodeChild->pCutBest[1] ) // both phases are present
271 {
272 // if this phase of the node is referenced, there is no recursive call
273 pNodeChild->nRefAct[2]++;
274 if ( pNodeChild->nRefAct[fPhaseChild]++ > 0 )
275 continue;
276 }
277 else // only one phase is present
278 {
279 // inverter should be added if the phase
280 // (a) has no reference and (b) is implemented using other phase
281 if ( pNodeChild->nRefAct[fPhaseChild]++ == 0 && pNodeChild->pCutBest[fPhaseChild] == NULL )
282 aArea += pNodeChild->p->pSuperLib->AreaInv;
283 // if the node is referenced, there is no recursive call
284 if ( pNodeChild->nRefAct[2]++ > 0 )
285 continue;
286 }
287 }
288 else
289 {
290 if ( pNodeChild->pCutBest[0] && pNodeChild->pCutBest[1] ) // both phases are present
291 {
292 // if this phase of the node is referenced, there is no recursive call
293 --pNodeChild->nRefAct[2];
294 if ( --pNodeChild->nRefAct[fPhaseChild] > 0 )
295 continue;
296 }
297 else // only one phase is present
298 {
299 // inverter should be added if the phase
300 // (a) has no reference and (b) is implemented using other phase
301 if ( --pNodeChild->nRefAct[fPhaseChild] == 0 && pNodeChild->pCutBest[fPhaseChild] == NULL )
302 aArea += pNodeChild->p->pSuperLib->AreaInv;
303 // if the node is referenced, there is no recursive call
304 if ( --pNodeChild->nRefAct[2] > 0 )
305 continue;
306 }
307 assert( pNodeChild->nRefAct[fPhaseChild] >= 0 );
308 }
309
310 // get the child cut
311 pCutChild = pNodeChild->pCutBest[fPhaseChild];
312 // if the child does not have this phase mapped, take the opposite phase
313 if ( pCutChild == NULL )
314 {
315 fPhaseChild = !fPhaseChild;
316 pCutChild = pNodeChild->pCutBest[fPhaseChild];
317 }
318 // reference and compute area recursively
319 aArea += Map_CutRefDeref( pCutChild, fPhaseChild, fReference, fUpdateProf );
320 }
321 return aArea;
322}
int Map_CutGetLeafPhase(Map_Cut_t *pCut, int fPhase, int iLeaf)
float Map_CutGetRootArea(Map_Cut_t *pCut, int fPhase)
struct Map_NodeStruct_t_ Map_Node_t
Definition mapper.h:41
void Mio_GateDecProfile2(Mio_Gate_t *pGate)
Definition mioApi.c:192
void Mio_GateIncProfile2(Mio_Gate_t *pGate)
Definition mioApi.c:191
Map_Man_t * p
Definition mapperInt.h:208
Mio_Gate_t * pRoot
Definition mapperInt.h:292
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_MappingEstimateRefs()

void Map_MappingEstimateRefs ( Map_Man_t * p)

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

Synopsis [Sets the estimated reference counter.]

Description [When this procedure is called for the first time, the reference counter is estimated from the AIG. Otherwise, it is a linear combination of reference counters in the last two iterations.]

SideEffects []

SeeAlso []

Definition at line 151 of file mapperRefs.c.

152{
153 Map_Node_t * pNode;
154 int i;
155 for ( i = 0; i < p->vMapObjs->nSize; i++ )
156 {
157 pNode = p->vMapObjs->pArray[i];
158// pNode->nRefEst[0] = (float)((2.0 * pNode->nRefEst[0] + 1.0 * pNode->nRefAct[0]) / 3.0);
159// pNode->nRefEst[1] = (float)((2.0 * pNode->nRefEst[1] + 1.0 * pNode->nRefAct[1]) / 3.0);
160// pNode->nRefEst[2] = (float)((2.0 * pNode->nRefEst[2] + 1.0 * pNode->nRefAct[2]) / 3.0);
161 pNode->nRefEst[0] = (float)((3.0 * pNode->nRefEst[0] + 1.0 * pNode->nRefAct[0]) / 4.0);
162 pNode->nRefEst[1] = (float)((3.0 * pNode->nRefEst[1] + 1.0 * pNode->nRefAct[1]) / 4.0);
163 pNode->nRefEst[2] = (float)((3.0 * pNode->nRefEst[2] + 1.0 * pNode->nRefAct[2]) / 4.0);
164 }
165}
Cube * p
Definition exorList.c:222
Here is the caller graph for this function:

◆ Map_MappingEstimateRefsInit()

void Map_MappingEstimateRefsInit ( Map_Man_t * p)

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

Synopsis [Sets the estimated reference counter for the PIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file mapperRefs.c.

127{
128 Map_Node_t * pNode;
129 int i;
130 for ( i = 0; i < p->vMapObjs->nSize; i++ )
131 {
132 pNode = p->vMapObjs->pArray[i];
133// pNode->nRefEst[0] = pNode->nRefEst[1] = ((float)pNode->nRefs)*(float)2.0;
134 pNode->nRefEst[0] = pNode->nRefEst[1] = pNode->nRefEst[2] = ((float)pNode->nRefs);
135 }
136}
Here is the caller graph for this function:

◆ Map_MappingGetArea()

float Map_MappingGetArea ( Map_Man_t * pMan)

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

Synopsis [Computes the array of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 485 of file mapperRefs.c.

486{
487 Map_Node_t * pNode;
488 float Area = 0.0;
489 int i;
490 if ( pMan->fUseProfile )
491 Mio_LibraryCleanProfile2( pMan->pSuperLib->pGenlib );
492 for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
493 {
494 pNode = pMan->vMapObjs->pArray[i];
495 if ( pNode->nRefAct[2] == 0 )
496 continue;
497 if ( Map_NodeIsBuf(pNode) )
498 continue;
499 // at least one phase has the best cut assigned
500 assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL );
501 // at least one phase is used in the mapping
502 assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 );
503 // compute the array due to the supergate
504 if ( Map_NodeIsAnd(pNode) )
505 {
506 // count area of the negative phase
507 if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) )
508 {
509 Area += pNode->pCutBest[0]->M[0].pSuperBest->Area;
510 if ( pMan->fUseProfile )
512 }
513 // count area of the positive phase
514 if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) )
515 {
516 Area += pNode->pCutBest[1]->M[1].pSuperBest->Area;
517 if ( pMan->fUseProfile )
519 }
520 }
521 // count area of the interver if we need to implement one phase with another phase
522 if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) ||
523 (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) )
524 Area += pMan->pSuperLib->AreaInv;
525 }
526 // add buffers for each CO driven by a CI
527 for ( i = 0; i < pMan->nOutputs; i++ )
528 if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) )
529 Area += pMan->pSuperLib->AreaBuf;
530 return Area;
531}
int Map_NodeIsBuf(Map_Node_t *p)
int Map_NodeIsVar(Map_Node_t *p)
int Map_NodeIsAnd(Map_Node_t *p)
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition mapper.h:67
void Mio_LibraryCleanProfile2(Mio_Library_t *pLib)
Definition mioUtils.c:1616
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_MappingSetRefs()

void Map_MappingSetRefs ( Map_Man_t * pMan)

Definition at line 450 of file mapperRefs.c.

451{
452 Map_Node_t * pNode;
453 int i;
454 if ( pMan->fUseProfile )
455 Mio_LibraryCleanProfile2( pMan->pSuperLib->pGenlib );
456 // clean all references
457 for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
458 {
459 pNode = pMan->vMapObjs->pArray[i];
460 pNode->nRefAct[0] = 0;
461 pNode->nRefAct[1] = 0;
462 pNode->nRefAct[2] = 0;
463 }
464 // visit nodes reachable from POs in the DFS order through the best cuts
465 for ( i = 0; i < pMan->nOutputs; i++ )
466 {
467 pNode = pMan->pOutputs[i];
468 if ( !Map_NodeIsConst(pNode) )
469 Map_MappingSetRefs_rec( pMan, pNode );
470 }
471}
void Map_MappingSetRefs_rec(Map_Man_t *pMan, Map_Node_t *pNode)
Definition mapperRefs.c:410
int Map_NodeIsConst(Map_Node_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_MappingSetRefs_rec()

void Map_MappingSetRefs_rec ( Map_Man_t * pMan,
Map_Node_t * pNode )

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

Synopsis [Computes actual reference counters.]

Description [Collects the nodes used in the mapping in array pMan->vMapping. Nodes are collected in reverse topological order to facilitate the computation of required times.]

SideEffects []

SeeAlso []

Definition at line 410 of file mapperRefs.c.

411{
412 Map_Cut_t * pCut;
413 Map_Node_t * pNodeR;
414 unsigned uPhase;
415 int i, fPhase, fInvPin;
416 // get the regular node and its phase
417 pNodeR = Map_Regular(pNode);
418 fPhase = !Map_IsComplement(pNode);
419 pNodeR->nRefAct[2]++;
420 // quit if the node was already visited in this phase
421 if ( pNodeR->nRefAct[fPhase]++ )
422 return;
423 // quit if this is a PI node
424 if ( Map_NodeIsVar(pNodeR) )
425 return;
426 // propagate through buffer
427 if ( Map_NodeIsBuf(pNodeR) )
428 {
429 Map_MappingSetRefs_rec( pMan, Map_NotCond(pNodeR->p1, Map_IsComplement(pNode)) );
430 return;
431 }
432 assert( Map_NodeIsAnd(pNode) );
433 // get the cut implementing this or opposite polarity
434 pCut = pNodeR->pCutBest[fPhase];
435 if ( pCut == NULL )
436 {
437 fPhase = !fPhase;
438 pCut = pNodeR->pCutBest[fPhase];
439 }
440 if ( pMan->fUseProfile )
441 Mio_GateIncProfile2( pCut->M[fPhase].pSuperBest->pRoot );
442 // visit the transitive fanin
443 uPhase = pCut->M[fPhase].uPhaseBest;
444 for ( i = 0; i < pCut->nLeaves; i++ )
445 {
446 fInvPin = ((uPhase & (1 << i)) > 0);
447 Map_MappingSetRefs_rec( pMan, Map_NotCond(pCut->ppLeaves[i], fInvPin) );
448 }
449}
#define Map_NotCond(p, c)
Definition mapper.h:70
#define Map_Regular(p)
Definition mapper.h:68
Map_Node_t * p1
Definition mapperInt.h:225
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Map_NodeDecRefPhaseAct()

int Map_NodeDecRefPhaseAct ( Map_Node_t * pNode,
int fPhase )

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

Synopsis [Decrements the actual reference counter of a phase.]

Description [Returns the new reference counter.]

SideEffects []

SeeAlso []

Definition at line 105 of file mapperRefs.c.

106{
107 assert( !Map_IsComplement(pNode) );
108 if ( pNode->pCutBest[0] && pNode->pCutBest[1] ) // both assigned
109 return --pNode->nRefAct[fPhase];
110 assert( pNode->pCutBest[0] || pNode->pCutBest[1] ); // at least one assigned
111 return --pNode->nRefAct[2];
112}

◆ Map_NodeIncRefPhaseAct()

int Map_NodeIncRefPhaseAct ( Map_Node_t * pNode,
int fPhase )

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

Synopsis [Increments the actual reference counter of a phase.]

Description [Returns the old reference counter.]

SideEffects []

SeeAlso []

Definition at line 85 of file mapperRefs.c.

86{
87 assert( !Map_IsComplement(pNode) );
88 if ( pNode->pCutBest[0] && pNode->pCutBest[1] ) // both assigned
89 return pNode->nRefAct[fPhase]++;
90 assert( pNode->pCutBest[0] || pNode->pCutBest[1] ); // at least one assigned
91 return pNode->nRefAct[2]++;
92}

◆ Map_NodeReadRefPhaseAct()

ABC_NAMESPACE_IMPL_START int Map_NodeReadRefPhaseAct ( Map_Node_t * pNode,
int fPhase )

DECLARATIONS ///.

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

FileName [mapperRefs.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - June 1, 2004.]

Revision [

Id
mapperRefs.h,v 1.0 2003/09/08 00:00:00 alanmi Exp

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

Synopsis [Reads the actual reference counter of a phase.]

Description []

SideEffects []

SeeAlso []

Definition at line 43 of file mapperRefs.c.

44{
45 assert( !Map_IsComplement(pNode) );
46 if ( pNode->pCutBest[0] && pNode->pCutBest[1] ) // both assigned
47 return pNode->nRefAct[fPhase];
48 assert( pNode->pCutBest[0] || pNode->pCutBest[1] ); // at least one assigned
49 return pNode->nRefAct[2];
50}

◆ Map_NodeReadRefPhaseEst()

float Map_NodeReadRefPhaseEst ( Map_Node_t * pNode,
int fPhase )

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

Synopsis [Reads the estimated reference counter of a phase.]

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file mapperRefs.c.

64{
65 assert( !Map_IsComplement(pNode) );
66 if ( pNode->pCutBest[0] && pNode->pCutBest[1] ) // both assigned
67 return pNode->nRefEst[fPhase];
68 assert( pNode->pCutBest[0] || pNode->pCutBest[1] ); // at least one assigned
69// return pNode->nRefEst[0] + pNode->nRefEst[1];
70 return pNode->nRefEst[2];
71}
Here is the caller graph for this function: