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

Go to the source code of this file.

Macros

#define MAP_CO_LIST_SIZE   5
 DECLARATIONS ///. More...
 

Functions

static int Map_MappingCountLevels_rec (Map_Node_t *pNode)
 
static float Map_MappingSetRefsAndArea_rec (Map_Man_t *pMan, Map_Node_t *pNode)
 
static float Map_MappingSetRefsAndSwitch_rec (Map_Man_t *pMan, Map_Node_t *pNode)
 
static float Map_MappingSetRefsAndWire_rec (Map_Man_t *pMan, Map_Node_t *pNode)
 
static void Map_MappingDfsCuts_rec (Map_Node_t *pNode, Map_NodeVec_t *vNodes)
 
static float Map_MappingArea_rec (Map_Man_t *pMan, Map_Node_t *pNode, Map_NodeVec_t *vNodes)
 
static int Map_MappingCompareOutputDelay (Map_Node_t **ppNode1, Map_Node_t **ppNode2)
 
static void Map_MappingFindLatest (Map_Man_t *p, int *pNodes, int nNodesMax)
 
static unsigned Map_MappingExpandTruth_rec (unsigned uTruth, int nVars)
 
static int Map_MappingCountUsedNodes (Map_Man_t *pMan, int fChoices)
 
void Map_MappingDfs_rec (Map_Node_t *pNode, Map_NodeVec_t *vNodes, int fCollectEquiv)
 FUNCTION DEFINITIONS ///. More...
 
Map_NodeVec_tMap_MappingDfs (Map_Man_t *pMan, int fCollectEquiv)
 
int Map_MappingCountLevels (Map_Man_t *pMan)
 
void Map_MappingUnmark (Map_Man_t *pMan)
 
void Map_MappingUnmark_rec (Map_Node_t *pNode)
 
void Map_MappingMark_rec (Map_Node_t *pNode)
 
void Map_MappingPrintOutputArrivals (Map_Man_t *p)
 
void Map_MappingSetupTruthTables (unsigned uTruths[][2])
 
void Map_MappingSetupTruthTablesLarge (unsigned uTruths[][32])
 
void Map_MappingSetupMask (unsigned uMask[], int nVarsMax)
 
int Map_ManCheckConsistency (Map_Man_t *p)
 
int Map_MappingNodeIsViolator (Map_Node_t *pNode, Map_Cut_t *pCut, int fPosPol)
 
float Map_MappingGetAreaFlow (Map_Man_t *p)
 
int Map_CompareNodesByLevel (Map_Node_t **ppS1, Map_Node_t **ppS2)
 
void Map_MappingSortByLevel (Map_Man_t *pMan, Map_NodeVec_t *vNodes)
 
int Map_CompareNodesByPointer (Map_Node_t **ppS1, Map_Node_t **ppS2)
 
int Map_MappingCountDoubles (Map_Man_t *pMan, Map_NodeVec_t *vNodes)
 
st__tableMap_CreateTableGate2Super (Map_Man_t *pMan)
 
void Map_ManCleanData (Map_Man_t *p)
 
void Map_MappingExpandTruth (unsigned uTruth[2], int nVars)
 
float Map_MappingComputeDelayWithFanouts (Map_Man_t *p)
 
int Map_MappingGetMaxLevel (Map_Man_t *pMan)
 
int Map_MappingUpdateLevel_rec (Map_Man_t *pMan, Map_Node_t *pNode, int fMaximum)
 
void Map_MappingSetChoiceLevels (Map_Man_t *pMan)
 
void Map_MappingReportChoices (Map_Man_t *pMan)
 

Macro Definition Documentation

#define MAP_CO_LIST_SIZE   5

DECLARATIONS ///.

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

FileName [mapperUtils.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:
mapperUtils.c,v 1.8 2004/11/03 22:41:45 satrajit Exp

]

Definition at line 28 of file mapperUtils.c.

Function Documentation

int Map_CompareNodesByLevel ( Map_Node_t **  ppS1,
Map_Node_t **  ppS2 
)

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

Synopsis [Compares the supergates by their level.]

Description []

SideEffects []

SeeAlso []

Definition at line 522 of file mapperUtils.c.

523 {
524  Map_Node_t * pN1 = Map_Regular(*ppS1);
525  Map_Node_t * pN2 = Map_Regular(*ppS2);
526  if ( pN1->Level > pN2->Level )
527  return -1;
528  if ( pN1->Level < pN2->Level )
529  return 1;
530  return 0;
531 }
unsigned Level
Definition: mapperInt.h:214
#define Map_Regular(p)
Definition: mapper.h:68
int Map_CompareNodesByPointer ( Map_Node_t **  ppS1,
Map_Node_t **  ppS2 
)

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

Synopsis [Compares the supergates by their pointer.]

Description []

SideEffects []

SeeAlso []

Definition at line 563 of file mapperUtils.c.

564 {
565  if ( *ppS1 < *ppS2 )
566  return -1;
567  if ( *ppS1 > *ppS2 )
568  return 1;
569  return 0;
570 }
st__table* Map_CreateTableGate2Super ( Map_Man_t pMan)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 613 of file mapperUtils.c.

614 {
615  Map_Super_t * pSuper;
616  st__table * tTable;
617  int i, nInputs, v;
618  tTable = st__init_table(strcmp, st__strhash);
619  for ( i = 0; i < pMan->pSuperLib->nSupersAll; i++ )
620  {
621  pSuper = pMan->pSuperLib->ppSupers[i];
622  if ( pSuper->nGates == 1 )
623  {
624  // skip different versions of the same root gate
625  nInputs = Mio_GateReadPinNum(pSuper->pRoot);
626  for ( v = 0; v < nInputs; v++ )
627  if ( pSuper->pFanins[v]->Num != nInputs - 1 - v )
628  break;
629  if ( v != nInputs )
630  continue;
631 // printf( "%s\n", Mio_GateReadName(pSuper->pRoot) );
632  if ( st__insert( tTable, (char *)pSuper->pRoot, (char *)pSuper ) )
633  {
634  assert( 0 );
635  }
636  }
637  }
638  return tTable;
639 }
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
int strcmp()
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition: mioApi.c:151
Mio_Gate_t * pRoot
Definition: mapperInt.h:288
int st__strhash(const char *string, int modulus)
Definition: st.c:449
Definition: st.h:52
Map_Super_t * pFanins[6]
Definition: mapperInt.h:287
#define assert(ex)
Definition: util_old.h:213
int Map_ManCheckConsistency ( Map_Man_t p)

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

Synopsis [Verify one useful property.]

Description [This procedure verifies one useful property. After the FRAIG construction with choice nodes is over, each primary node should have fanins that are primary nodes. The primary nodes is the one that does not have pNode->pRepr set to point to another node.]

SideEffects []

SeeAlso []

Definition at line 427 of file mapperUtils.c.

428 {
429  Map_Node_t * pNode;
430  Map_NodeVec_t * pVec;
431  int i;
432  pVec = Map_MappingDfs( p, 0 );
433  for ( i = 0; i < pVec->nSize; i++ )
434  {
435  pNode = pVec->pArray[i];
436  if ( Map_NodeIsVar(pNode) )
437  {
438  if ( pNode->pRepr )
439  printf( "Primary input %d is a secondary node.\n", pNode->Num );
440  }
441  else if ( Map_NodeIsConst(pNode) )
442  {
443  if ( pNode->pRepr )
444  printf( "Constant 1 %d is a secondary node.\n", pNode->Num );
445  }
446  else
447  {
448  if ( pNode->pRepr )
449  printf( "Internal node %d is a secondary node.\n", pNode->Num );
450  if ( Map_Regular(pNode->p1)->pRepr )
451  printf( "Internal node %d has first fanin that is a secondary node.\n", pNode->Num );
452  if ( Map_Regular(pNode->p2)->pRepr )
453  printf( "Internal node %d has second fanin that is a secondary node.\n", pNode->Num );
454  }
455  }
456  Map_NodeVecFree( pVec );
457  return 1;
458 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Map_NodeIsConst(Map_Node_t *p)
Definition: mapperCreate.c:112
Map_Node_t ** pArray
Definition: mapperInt.h:301
int Map_NodeIsVar(Map_Node_t *p)
Definition: mapperCreate.c:113
Map_NodeVec_t * Map_MappingDfs(Map_Man_t *pMan, int fCollectEquiv)
Definition: mapperUtils.c:77
Map_Node_t * p2
Definition: mapperInt.h:222
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
void Map_NodeVecFree(Map_NodeVec_t *p)
Definition: mapperVec.c:68
Map_Node_t * pRepr
Definition: mapperInt.h:224
void Map_ManCleanData ( Map_Man_t p)

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

Synopsis [Get the FRAIG node with phase.]

Description []

SideEffects []

SeeAlso []

Definition at line 652 of file mapperUtils.c.

653 {
654  int i;
655  for ( i = 0; i < p->vMapObjs->nSize; i++ )
656  p->vMapObjs->pArray[i]->pData0 = p->vMapObjs->pArray[i]->pData1 = 0;
657 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static float Map_MappingArea_rec ( Map_Man_t pMan,
Map_Node_t pNode,
Map_NodeVec_t vNodes 
)
static
int Map_MappingCompareOutputDelay ( Map_Node_t **  ppNode1,
Map_Node_t **  ppNode2 
)
static

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

Synopsis [Compares the outputs by their arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file mapperUtils.c.

232 {
233  Map_Node_t * pNode1 = Map_Regular(*ppNode1);
234  Map_Node_t * pNode2 = Map_Regular(*ppNode2);
235  int fPhase1 = !Map_IsComplement(*ppNode1);
236  int fPhase2 = !Map_IsComplement(*ppNode2);
237  float Arrival1 = pNode1->tArrival[fPhase1].Worst;
238  float Arrival2 = pNode2->tArrival[fPhase2].Worst;
239  if ( Arrival1 < Arrival2 )
240  return -1;
241  if ( Arrival1 > Arrival2 )
242  return 1;
243  return 0;
244 }
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
#define Map_Regular(p)
Definition: mapper.h:68
float Map_MappingComputeDelayWithFanouts ( Map_Man_t p)

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

Synopsis [Compute the arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 713 of file mapperUtils.c.

714 {
715  Map_Node_t * pNode;
716  float Result;
717  int i;
718  for ( i = 0; i < p->vMapObjs->nSize; i++ )
719  {
720  // skip primary inputs
721  pNode = p->vMapObjs->pArray[i];
722  if ( !Map_NodeIsAnd( pNode ) )
723  continue;
724  // skip a secondary node
725  if ( pNode->pRepr )
726  continue;
727  // count the switching nodes
728  if ( pNode->nRefAct[0] > 0 )
729  Map_TimeCutComputeArrival( pNode, pNode->pCutBest[0], 0, MAP_FLOAT_LARGE );
730  if ( pNode->nRefAct[1] > 0 )
731  Map_TimeCutComputeArrival( pNode, pNode->pCutBest[1], 1, MAP_FLOAT_LARGE );
732  }
733  Result = Map_TimeComputeArrivalMax(p);
734  printf( "Max arrival times with fanouts = %10.2f.\n", Result );
735  return Result;
736 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
#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
float Map_TimeComputeArrivalMax(Map_Man_t *p)
DECLARATIONS ///.
Definition: mapperTime.c:42
float Map_TimeCutComputeArrival(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, float tWorstCaseLimit)
Definition: mapperTime.c:72
Map_Node_t * pRepr
Definition: mapperInt.h:224
int Map_MappingCountDoubles ( Map_Man_t pMan,
Map_NodeVec_t vNodes 
)

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

Synopsis [Counts how many AIG nodes are mapped in both polarities.]

Description []

SideEffects []

SeeAlso []

Definition at line 583 of file mapperUtils.c.

584 {
585  Map_Node_t * pNode;
586  int Counter, i;
587  // count the number of equal adjacent nodes
588  Counter = 0;
589  for ( i = 0; i < vNodes->nSize; i++ )
590  {
591  pNode = vNodes->pArray[i];
592  if ( !Map_NodeIsAnd(pNode) )
593  continue;
594  if ( (pNode->nRefAct[0] && pNode->pCutBest[0]) &&
595  (pNode->nRefAct[1] && pNode->pCutBest[1]) )
596  Counter++;
597  }
598  return Counter;
599 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
Map_Node_t ** pArray
Definition: mapperInt.h:301
static int Counter
int Map_MappingCountLevels ( Map_Man_t pMan)

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description []

SideEffects [Note that this procedure will reassign the levels assigned originally by NodeCreate() because it counts the number of levels with choices differently!]

SeeAlso []

Definition at line 105 of file mapperUtils.c.

106 {
107  int i, LevelsMax, LevelsCur;
108  // perform the traversal
109  LevelsMax = -1;
110  for ( i = 0; i < pMan->nOutputs; i++ )
111  {
112  LevelsCur = Map_MappingCountLevels_rec( Map_Regular(pMan->pOutputs[i]) );
113  if ( LevelsMax < LevelsCur )
114  LevelsMax = LevelsCur;
115  }
116  for ( i = 0; i < pMan->nOutputs; i++ )
117  Map_MappingUnmark_rec( Map_Regular(pMan->pOutputs[i]) );
118  return LevelsMax;
119 }
void Map_MappingUnmark_rec(Map_Node_t *pNode)
Definition: mapperUtils.c:181
#define Map_Regular(p)
Definition: mapper.h:68
static int Map_MappingCountLevels_rec(Map_Node_t *pNode)
Definition: mapperUtils.c:132
int Map_MappingCountLevels_rec ( Map_Node_t pNode)
static

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

Synopsis [Recursively computes the number of logic levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file mapperUtils.c.

133 {
134  int Level1, Level2;
135  assert( !Map_IsComplement(pNode) );
136  if ( !Map_NodeIsAnd(pNode) )
137  {
138  pNode->Level = 0;
139  return 0;
140  }
141  if ( pNode->fMark0 )
142  return pNode->Level;
143  pNode->fMark0 = 1;
144  // visit the transitive fanin
145  Level1 = Map_MappingCountLevels_rec( Map_Regular(pNode->p1) );
146  Level2 = Map_MappingCountLevels_rec( Map_Regular(pNode->p2) );
147  // set the number of levels
148  pNode->Level = 1 + ((Level1>Level2)? Level1: Level2);
149  return pNode->Level;
150 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
unsigned Level
Definition: mapperInt.h:214
Map_Node_t * p2
Definition: mapperInt.h:222
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
#define assert(ex)
Definition: util_old.h:213
unsigned fMark0
Definition: mapperInt.h:209
static int Map_MappingCountLevels_rec(Map_Node_t *pNode)
Definition: mapperUtils.c:132
int Map_MappingCountUsedNodes ( Map_Man_t pMan,
int  fChoices 
)
static

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

Synopsis [Computes the maximum and minimum levels of the choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 882 of file mapperUtils.c.

883 {
884  Map_NodeVec_t * vNodes;
885  int Result;
886  vNodes = Map_MappingDfs( pMan, fChoices );
887  Result = vNodes->nSize;
888  Map_NodeVecFree( vNodes );
889  return Result;
890 }
Map_NodeVec_t * Map_MappingDfs(Map_Man_t *pMan, int fCollectEquiv)
Definition: mapperUtils.c:77
void Map_NodeVecFree(Map_NodeVec_t *p)
Definition: mapperVec.c:68
Map_NodeVec_t* Map_MappingDfs ( Map_Man_t pMan,
int  fCollectEquiv 
)

Definition at line 77 of file mapperUtils.c.

78 {
79  Map_NodeVec_t * vNodes;
80  int i;
81  // perform the traversal
82  vNodes = Map_NodeVecAlloc( 100 );
83  for ( i = 0; i < pMan->nOutputs; i++ )
84  Map_MappingDfs_rec( Map_Regular(pMan->pOutputs[i]), vNodes, fCollectEquiv );
85  for ( i = 0; i < vNodes->nSize; i++ )
86  vNodes->pArray[i]->fMark0 = 0;
87 // for ( i = 0; i < pMan->nOutputs; i++ )
88 // Map_MappingUnmark_rec( Map_Regular(pMan->pOutputs[i]) );
89  return vNodes;
90 }
Map_NodeVec_t * Map_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: mapperVec.c:45
void Map_MappingDfs_rec(Map_Node_t *pNode, Map_NodeVec_t *vNodes, int fCollectEquiv)
FUNCTION DEFINITIONS ///.
Definition: mapperUtils.c:56
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define Map_Regular(p)
Definition: mapper.h:68
unsigned fMark0
Definition: mapperInt.h:209
void Map_MappingDfs_rec ( Map_Node_t pNode,
Map_NodeVec_t vNodes,
int  fCollectEquiv 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 56 of file mapperUtils.c.

57 {
58  assert( !Map_IsComplement(pNode) );
59  if ( pNode->fMark0 )
60  return;
61  // visit the transitive fanin
62  if ( Map_NodeIsAnd(pNode) )
63  {
64  Map_MappingDfs_rec( Map_Regular(pNode->p1), vNodes, fCollectEquiv );
65  Map_MappingDfs_rec( Map_Regular(pNode->p2), vNodes, fCollectEquiv );
66  }
67  // visit the equivalent nodes
68  if ( fCollectEquiv && pNode->pNextE )
69  Map_MappingDfs_rec( pNode->pNextE, vNodes, fCollectEquiv );
70  // make sure the node is not visited through the equivalent nodes
71  assert( pNode->fMark0 == 0 );
72  // mark the node as visited
73  pNode->fMark0 = 1;
74  // add the node to the list
75  Map_NodeVecPush( vNodes, pNode );
76 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Node_t * pNextE
Definition: mapperInt.h:223
void Map_MappingDfs_rec(Map_Node_t *pNode, Map_NodeVec_t *vNodes, int fCollectEquiv)
FUNCTION DEFINITIONS ///.
Definition: mapperUtils.c:56
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
Map_Node_t * p2
Definition: mapperInt.h:222
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
#define assert(ex)
Definition: util_old.h:213
unsigned fMark0
Definition: mapperInt.h:209
void Map_NodeVecPush(Map_NodeVec_t *p, Map_Node_t *Entry)
Definition: mapperVec.c:190
static void Map_MappingDfsCuts_rec ( Map_Node_t pNode,
Map_NodeVec_t vNodes 
)
static
void Map_MappingExpandTruth ( unsigned  uTruth[2],
int  nVars 
)

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

Synopsis [Expand the truth table]

Description []

SideEffects []

SeeAlso []

Definition at line 670 of file mapperUtils.c.

671 {
672  assert( nVars < 7 );
673  if ( nVars == 6 )
674  return;
675  if ( nVars < 5 )
676  {
677  uTruth[0] &= MAP_MASK( (1<<nVars) );
678  uTruth[0] = Map_MappingExpandTruth_rec( uTruth[0], nVars );
679  }
680  uTruth[1] = uTruth[0];
681 }
#define MAP_MASK(n)
INCLUDES ///.
Definition: mapperInt.h:51
static unsigned Map_MappingExpandTruth_rec(unsigned uTruth, int nVars)
Definition: mapperUtils.c:694
#define assert(ex)
Definition: util_old.h:213
unsigned Map_MappingExpandTruth_rec ( unsigned  uTruth,
int  nVars 
)
static

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

Synopsis [Expand the truth table]

Description []

SideEffects []

SeeAlso []

Definition at line 694 of file mapperUtils.c.

695 {
696  assert( nVars < 6 );
697  if ( nVars == 5 )
698  return uTruth;
699  return Map_MappingExpandTruth_rec( uTruth | (uTruth << (1 << nVars)), nVars + 1 );
700 }
static unsigned Map_MappingExpandTruth_rec(unsigned uTruth, int nVars)
Definition: mapperUtils.c:694
#define assert(ex)
Definition: util_old.h:213
void Map_MappingFindLatest ( Map_Man_t p,
int *  pNodes,
int  nNodesMax 
)
static

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

Synopsis [Finds given number of latest arriving COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 257 of file mapperUtils.c.

258 {
259  int nNodes, i, k, v;
260  assert( p->nOutputs >= nNodesMax );
261  pNodes[0] = 0;
262  nNodes = 1;
263  for ( i = 1; i < p->nOutputs; i++ )
264  {
265  for ( k = nNodes - 1; k >= 0; k-- )
266  if ( Map_MappingCompareOutputDelay( &p->pOutputs[pNodes[k]], &p->pOutputs[i] ) >= 0 )
267  break;
268  if ( k == nNodesMax - 1 )
269  continue;
270  if ( nNodes < nNodesMax )
271  nNodes++;
272  for ( v = nNodes - 1; v > k+1; v-- )
273  pNodes[v] = pNodes[v-1];
274  pNodes[k+1] = i;
275  }
276 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Map_MappingCompareOutputDelay(Map_Node_t **ppNode1, Map_Node_t **ppNode2)
Definition: mapperUtils.c:231
#define assert(ex)
Definition: util_old.h:213
float Map_MappingGetAreaFlow ( Map_Man_t p)

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

Synopsis [Computes the total are flow of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 487 of file mapperUtils.c.

488 {
489  Map_Node_t * pNode;
490  Map_Cut_t * pCut;
491  float aFlowFlowTotal = 0;
492  int fPosPol, i;
493  for ( i = 0; i < p->nOutputs; i++ )
494  {
495  pNode = Map_Regular(p->pOutputs[i]);
496  if ( !Map_NodeIsAnd(pNode) )
497  continue;
498  fPosPol = !Map_IsComplement(p->pOutputs[i]);
499  pCut = pNode->pCutBest[fPosPol];
500  if ( pCut == NULL )
501  {
502  fPosPol = !fPosPol;
503  pCut = pNode->pCutBest[fPosPol];
504  }
505  aFlowFlowTotal += pNode->pCutBest[fPosPol]->M[fPosPol].AreaFlow;
506  }
507  return aFlowFlowTotal;
508 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
#define Map_Regular(p)
Definition: mapper.h:68
Map_Match_t M[2]
Definition: mapperInt.h:271
int Map_MappingGetMaxLevel ( Map_Man_t pMan)

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

Synopsis [Sets up the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 750 of file mapperUtils.c.

751 {
752  int nLevelMax, i;
753  nLevelMax = 0;
754  for ( i = 0; i < pMan->nOutputs; i++ )
755  nLevelMax = ((unsigned)nLevelMax) > Map_Regular(pMan->pOutputs[i])->Level?
756  nLevelMax : Map_Regular(pMan->pOutputs[i])->Level;
757  return nLevelMax;
758 }
#define Map_Regular(p)
Definition: mapper.h:68
void Map_MappingMark_rec ( Map_Node_t pNode)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 207 of file mapperUtils.c.

208 {
209  assert( !Map_IsComplement(pNode) );
210  if ( pNode->fMark0 == 1 )
211  return;
212  pNode->fMark0 = 1;
213  if ( !Map_NodeIsAnd(pNode) )
214  return;
215  // visit the transitive fanin of the selected cut
218 }
void Map_MappingMark_rec(Map_Node_t *pNode)
Definition: mapperUtils.c:207
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
Map_Node_t * p2
Definition: mapperInt.h:222
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
#define assert(ex)
Definition: util_old.h:213
unsigned fMark0
Definition: mapperInt.h:209
int Map_MappingNodeIsViolator ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPosPol 
)

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

Synopsis [Returns 1 if current mapping of the node violates fanout limits.]

Description []

SideEffects []

SeeAlso []

Definition at line 471 of file mapperUtils.c.

472 {
473  return pNode->nRefAct[fPosPol] > (int)pCut->M[fPosPol].pSuperBest->nFanLimit;
474 }
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
unsigned nFanLimit
Definition: mapperInt.h:282
Map_Match_t M[2]
Definition: mapperInt.h:271
void Map_MappingPrintOutputArrivals ( Map_Man_t p)

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

Synopsis [Prints a bunch of latest arriving outputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file mapperUtils.c.

290 {
291  int pSorted[MAP_CO_LIST_SIZE];
292  Map_Time_t * pTimes;
293  Map_Node_t * pNode;
294  int fPhase, Limit, i;
295  int MaxNameSize;
296 
297  // determine the number of nodes to print
298  Limit = (p->nOutputs > MAP_CO_LIST_SIZE)? MAP_CO_LIST_SIZE : p->nOutputs;
299 
300  // determine the order
301  Map_MappingFindLatest( p, pSorted, Limit );
302 
303  // determine max size of the node's name
304  MaxNameSize = 0;
305  for ( i = 0; i < Limit; i++ )
306  if ( MaxNameSize < (int)strlen(p->ppOutputNames[pSorted[i]]) )
307  MaxNameSize = strlen(p->ppOutputNames[pSorted[i]]);
308 
309  // print the latest outputs
310  for ( i = 0; i < Limit; i++ )
311  {
312  // get the i-th latest output
313  pNode = Map_Regular(p->pOutputs[pSorted[i]]);
314  fPhase =!Map_IsComplement(p->pOutputs[pSorted[i]]);
315  pTimes = pNode->tArrival + fPhase;
316  // print out the best arrival time
317  printf( "Output %-*s : ", MaxNameSize + 3, p->ppOutputNames[pSorted[i]] );
318  printf( "Delay = (%5.2f, %5.2f) ", (double)pTimes->Rise, (double)pTimes->Fall );
319  printf( "%s", fPhase? "POS" : "NEG" );
320  printf( "\n" );
321  }
322 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
static void Map_MappingFindLatest(Map_Man_t *p, int *pNodes, int nNodesMax)
Definition: mapperUtils.c:257
#define MAP_CO_LIST_SIZE
DECLARATIONS ///.
Definition: mapperUtils.c:28
#define Map_Regular(p)
Definition: mapper.h:68
int strlen()
void Map_MappingReportChoices ( Map_Man_t pMan)

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

Synopsis [Reports statistics on choice nodes.]

Description [The number of choice nodes is the number of primary nodes, which has pNextE set to a pointer. The number of choices is the number of entries in the equivalent-node lists of the primary nodes.]

SideEffects []

SeeAlso []

Definition at line 842 of file mapperUtils.c.

843 {
844  Map_Node_t * pNode, * pTemp;
845  int nChoiceNodes, nChoices;
846  int i, LevelMax1, LevelMax2;
847 
848  // report the number of levels
849  LevelMax1 = Map_MappingGetMaxLevel( pMan );
850  pMan->nTravIds++;
851  for ( i = 0; i < pMan->nOutputs; i++ )
852  Map_MappingUpdateLevel_rec( pMan, Map_Regular(pMan->pOutputs[i]), 0 );
853  LevelMax2 = Map_MappingGetMaxLevel( pMan );
854 
855  // report statistics about choices
856  nChoiceNodes = nChoices = 0;
857  for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
858  {
859  pNode = pMan->vMapObjs->pArray[i];
860  if ( pNode->pRepr == NULL && pNode->pNextE != NULL )
861  { // this is a choice node = the primary node that has equivalent nodes
862  nChoiceNodes++;
863  for ( pTemp = pNode; pTemp; pTemp = pTemp->pNextE )
864  nChoices++;
865  }
866  }
867  printf( "Maximum level: Original = %d. Reduced due to choices = %d.\n", LevelMax1, LevelMax2 );
868  printf( "Choice stats: Choice nodes = %d. Total choices = %d.\n", nChoiceNodes, nChoices );
869 }
Map_Node_t * pNextE
Definition: mapperInt.h:223
int Map_MappingGetMaxLevel(Map_Man_t *pMan)
Definition: mapperUtils.c:750
#define Map_Regular(p)
Definition: mapper.h:68
Map_Node_t * pRepr
Definition: mapperInt.h:224
int Map_MappingUpdateLevel_rec(Map_Man_t *pMan, Map_Node_t *pNode, int fMaximum)
Definition: mapperUtils.c:771
void Map_MappingSetChoiceLevels ( Map_Man_t pMan)

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

Synopsis [Resets the levels of the nodes in the choice graph.]

Description [Makes the level of the choice nodes to be equal to the maximum of the level of the nodes in the equivalence class. This way sorting by level leads to the reverse topological order, which is needed for the required time computation.]

SideEffects []

SeeAlso []

Definition at line 821 of file mapperUtils.c.

822 {
823  int i;
824  pMan->nTravIds++;
825  for ( i = 0; i < pMan->nOutputs; i++ )
826  Map_MappingUpdateLevel_rec( pMan, Map_Regular(pMan->pOutputs[i]), 1 );
827 }
#define Map_Regular(p)
Definition: mapper.h:68
int Map_MappingUpdateLevel_rec(Map_Man_t *pMan, Map_Node_t *pNode, int fMaximum)
Definition: mapperUtils.c:771
static float Map_MappingSetRefsAndArea_rec ( Map_Man_t pMan,
Map_Node_t pNode 
)
static
static float Map_MappingSetRefsAndSwitch_rec ( Map_Man_t pMan,
Map_Node_t pNode 
)
static
static float Map_MappingSetRefsAndWire_rec ( Map_Man_t pMan,
Map_Node_t pNode 
)
static
void Map_MappingSetupMask ( unsigned  uMask[],
int  nVarsMax 
)

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

Synopsis [Sets up the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file mapperUtils.c.

403 {
404  if ( nVarsMax == 6 )
405  uMask[0] = uMask[1] = MAP_FULL;
406  else
407  {
408  uMask[0] = MAP_MASK(1 << nVarsMax);
409  uMask[1] = 0;
410  }
411 }
#define MAP_MASK(n)
INCLUDES ///.
Definition: mapperInt.h:51
#define MAP_FULL
Definition: mapperInt.h:52
void Map_MappingSetupTruthTables ( unsigned  uTruths[][2])

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

Synopsis [Sets up the truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file mapperUtils.c.

336 {
337  int m, v;
338  // set up the truth tables
339  for ( m = 0; m < 32; m++ )
340  for ( v = 0; v < 5; v++ )
341  if ( m & (1 << v) )
342  uTruths[v][0] |= (1 << m);
343  // make adjustments for the case of 6 variables
344  for ( v = 0; v < 5; v++ )
345  uTruths[v][1] = uTruths[v][0];
346  uTruths[5][0] = 0;
347  uTruths[5][1] = MAP_FULL;
348 }
#define MAP_FULL
Definition: mapperInt.h:52
void Map_MappingSetupTruthTablesLarge ( unsigned  uTruths[][32])

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

Synopsis [Sets up the truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 361 of file mapperUtils.c.

362 {
363  int m, v;
364  // clean everything
365  for ( m = 0; m < 32; m++ )
366  for ( v = 0; v < 10; v++ )
367  uTruths[v][m] = 0;
368  // set up the truth tables
369  for ( m = 0; m < 32; m++ )
370  for ( v = 0; v < 5; v++ )
371  if ( m & (1 << v) )
372  {
373  uTruths[v][0] |= (1 << m);
374  uTruths[v+5][m] = MAP_FULL;
375  }
376  // extend this info for the rest of the first 5 variables
377  for ( m = 0; m < 32; m++ )
378  for ( v = 0; v < 5; v++ )
379  uTruths[v][m] = uTruths[v][0];
380 /*
381  // verify
382  for ( m = 0; m < 1024; m++, printf("\n") )
383  for ( v = 0; v < 10; v++ )
384  if ( Map_InfoReadVar( uTruths[v], m ) )
385  printf( "1" );
386  else
387  printf( "0" );
388 */
389 }
#define MAP_FULL
Definition: mapperInt.h:52
void Map_MappingSortByLevel ( Map_Man_t pMan,
Map_NodeVec_t vNodes 
)

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

Synopsis [Orders the nodes in the decreasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 544 of file mapperUtils.c.

545 {
546  qsort( (void *)vNodes->pArray, vNodes->nSize, sizeof(Map_Node_t *),
547  (int (*)(const void *, const void *)) Map_CompareNodesByLevel );
548 // assert( Map_CompareNodesByLevel( vNodes->pArray, vNodes->pArray + vNodes->nSize - 1 ) <= 0 );
549 }
int Map_CompareNodesByLevel(Map_Node_t **ppS1, Map_Node_t **ppS2)
Definition: mapperUtils.c:522
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_MappingUnmark ( Map_Man_t pMan)

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

Synopsis [Unmarks the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file mapperUtils.c.

164 {
165  int i;
166  for ( i = 0; i < pMan->nOutputs; i++ )
167  Map_MappingUnmark_rec( Map_Regular(pMan->pOutputs[i]) );
168 }
void Map_MappingUnmark_rec(Map_Node_t *pNode)
Definition: mapperUtils.c:181
#define Map_Regular(p)
Definition: mapper.h:68
void Map_MappingUnmark_rec ( Map_Node_t pNode)

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

Synopsis [Recursively unmarks the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file mapperUtils.c.

182 {
183  assert( !Map_IsComplement(pNode) );
184  if ( pNode->fMark0 == 0 )
185  return;
186  pNode->fMark0 = 0;
187  if ( !Map_NodeIsAnd(pNode) )
188  return;
191  // visit the equivalent nodes
192  if ( pNode->pNextE )
193  Map_MappingUnmark_rec( pNode->pNextE );
194 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Node_t * pNextE
Definition: mapperInt.h:223
void Map_MappingUnmark_rec(Map_Node_t *pNode)
Definition: mapperUtils.c:181
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
Map_Node_t * p2
Definition: mapperInt.h:222
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
#define assert(ex)
Definition: util_old.h:213
unsigned fMark0
Definition: mapperInt.h:209
int Map_MappingUpdateLevel_rec ( Map_Man_t pMan,
Map_Node_t pNode,
int  fMaximum 
)

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

Synopsis [Analyses choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 771 of file mapperUtils.c.

772 {
773  Map_Node_t * pTemp;
774  int Level1, Level2, LevelE;
775  assert( !Map_IsComplement(pNode) );
776  if ( !Map_NodeIsAnd(pNode) )
777  return pNode->Level;
778  // skip the visited node
779  if ( pNode->TravId == pMan->nTravIds )
780  return pNode->Level;
781  pNode->TravId = pMan->nTravIds;
782  // compute levels of the children nodes
783  Level1 = Map_MappingUpdateLevel_rec( pMan, Map_Regular(pNode->p1), fMaximum );
784  Level2 = Map_MappingUpdateLevel_rec( pMan, Map_Regular(pNode->p2), fMaximum );
785  pNode->Level = 1 + MAP_MAX( Level1, Level2 );
786  if ( pNode->pNextE )
787  {
788  LevelE = Map_MappingUpdateLevel_rec( pMan, pNode->pNextE, fMaximum );
789  if ( fMaximum )
790  {
791  if ( pNode->Level < (unsigned)LevelE )
792  pNode->Level = LevelE;
793  }
794  else
795  {
796  if ( pNode->Level > (unsigned)LevelE )
797  pNode->Level = LevelE;
798  }
799  // set the level of all equivalent nodes to be the same minimum
800  if ( pNode->pRepr == NULL ) // the primary node
801  for ( pTemp = pNode->pNextE; pTemp; pTemp = pTemp->pNextE )
802  pTemp->Level = pNode->Level;
803  }
804  return pNode->Level;
805 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Node_t * pNextE
Definition: mapperInt.h:223
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
unsigned Level
Definition: mapperInt.h:214
Map_Node_t * p2
Definition: mapperInt.h:222
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
Map_Node_t * pRepr
Definition: mapperInt.h:224
int Map_MappingUpdateLevel_rec(Map_Man_t *pMan, Map_Node_t *pNode, int fMaximum)
Definition: mapperUtils.c:771
#define assert(ex)
Definition: util_old.h:213
#define MAP_MAX(a, b)
Definition: mapperInt.h:57