abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mapperInt.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include "base/main/main.h"
#include "map/mio/mio.h"
#include "mapper.h"
#include "misc/extra/extraBdd.h"

Go to the source code of this file.

Data Structures

struct  Map_ManStruct_t_
 STRUCTURE DEFINITIONS ///. More...
 
struct  Map_SuperLibStruct_t_
 
struct  Map_NodeStruct_t_
 
struct  Map_MatchStruct_t_
 
struct  Map_CutStruct_t_
 
struct  Map_SuperStruct_t_
 
struct  Map_NodeVecStruct_t_
 
struct  Map_HashTableStruct_t_
 
struct  Map_HashEntryStruct_t_
 

Macros

#define MAP_MASK(n)   ((~((unsigned)0)) >> (32-(n)))
 INCLUDES ///. More...
 
#define MAP_FULL   (~((unsigned)0))
 
#define MAP_NO_VAR   (-9999.0)
 
#define MAP_MIN(a, b)   (((a) < (b))? (a) : (b))
 
#define MAP_MAX(a, b)   (((a) > (b))? (a) : (b))
 
#define MAP_FLOAT_LARGE   ((float)(FLT_MAX/10))
 
#define MAP_FLOAT_SMALL   ((float)1.0e-03)
 
#define MAP_RANDOM_UNSIGNED   ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))
 
#define Map_CutIsComplement(p)   (((int)((ABC_PTRUINT_T) (p) & 01)))
 
#define Map_CutRegular(p)   ((Map_Cut_t *)((ABC_PTRUINT_T)(p) & ~01))
 
#define Map_CutNot(p)   ((Map_Cut_t *)((ABC_PTRUINT_T)(p) ^ 01))
 
#define Map_CutNotCond(p, c)   ((Map_Cut_t *)((ABC_PTRUINT_T)(p) ^ (c)))
 
#define Map_NodeReadRef(p)   ((Map_Regular(p))->nRefs)
 
#define Map_NodeRef(p)   ((Map_Regular(p))->nRefs++)
 
#define Map_InfoSetVar(p, i)   (p[(i)>>5] |= (1<<((i) & 31)))
 
#define Map_InfoRemVar(p, i)   (p[(i)>>5] &= ~(1<<((i) & 31)))
 
#define Map_InfoFlipVar(p, i)   (p[(i)>>5] ^= (1<<((i) & 31)))
 
#define Map_InfoReadVar(p, i)   ((p[(i)>>5] & (1<<((i) & 31))) > 0)
 
#define Map_NodeIsSimComplement(p)   (Map_IsComplement(p)? !(Map_Regular(p)->fInv) : (p)->fInv)
 
#define Map_NodeReadNextFanout(pNode, pFanout)
 
#define Map_NodeReadNextFanoutPlace(pNode, pFanout)
 
#define Map_NodeForEachFanout(pNode, pFanout)
 
#define Map_NodeForEachFanoutSafe(pNode, pFanout, pFanout2)
 

Functions

void Map_MappingCuts (Map_Man_t *p)
 GLOBAL VARIABLES ///. More...
 
Map_Cut_tMap_CutAlloc (Map_Man_t *p)
 DECLARATIONS ///. More...
 
void Map_CutFree (Map_Man_t *p, Map_Cut_t *pCut)
 
void Map_CutPrint (Map_Man_t *p, Map_Node_t *pRoot, Map_Cut_t *pCut, int fPhase)
 
float Map_CutGetRootArea (Map_Cut_t *pCut, int fPhase)
 
int Map_CutGetLeafPhase (Map_Cut_t *pCut, int fPhase, int iLeaf)
 
int Map_NodeGetLeafPhase (Map_Node_t *pNode, int fPhase, int iLeaf)
 
Map_Cut_tMap_CutListAppend (Map_Cut_t *pSetAll, Map_Cut_t *pSets)
 
void Map_CutListRecycle (Map_Man_t *p, Map_Cut_t *pSetList, Map_Cut_t *pSave)
 
int Map_CutListCount (Map_Cut_t *pSets)
 
void Map_CutRemoveFanouts (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 
void Map_CutInsertFanouts (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 
void Map_NodeAddFaninFanout (Map_Node_t *pFanin, Map_Node_t *pFanout)
 
void Map_NodeRemoveFaninFanout (Map_Node_t *pFanin, Map_Node_t *pFanoutToRemove)
 
int Map_NodeGetFanoutNum (Map_Node_t *pNode)
 
Map_SuperLib_tMap_SuperLibCreate (Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName, char *pExcludeFile, int fAlgorithm, int fVerbose)
 DECLARATIONS ///. More...
 
void Map_SuperLibFree (Map_SuperLib_t *p)
 
int Map_MappingMatches (Map_Man_t *p)
 
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_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)
 
float Map_CutDeref (Map_Cut_t *pCut, int fPhase)
 
void Map_MappingSetRefs (Map_Man_t *pMan)
 
float Map_MappingGetArea (Map_Man_t *pMan)
 
float Map_SwitchCutGetDerefed (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 FUNCTION DEFINITIONS ///. More...
 
float Map_SwitchCutRef (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 
float Map_SwitchCutDeref (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 
float Map_MappingGetSwitching (Map_Man_t *pMan)
 
int Map_LibraryDeriveGateInfo (Map_SuperLib_t *pLib, st__table *tExcludeGate)
 
int Map_LibraryReadFileTreeStr (Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName)
 
int Map_LibraryReadTree (Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, char *pFileName, char *pExcludeFile)
 
void Map_LibraryPrintTree (Map_SuperLib_t *pLib)
 
int Map_LibraryRead (Map_SuperLib_t *p, char *pFileName)
 FUNCTION DEFINITIONS ///. More...
 
void Map_LibraryPrintSupergate (Map_Super_t *pGate)
 
Map_HashTable_tMap_SuperTableCreate (Map_SuperLib_t *pLib)
 FUNCTION DEFINITIONS ///. More...
 
void Map_SuperTableFree (Map_HashTable_t *p)
 
int Map_SuperTableInsertC (Map_HashTable_t *pLib, unsigned uTruthC[], Map_Super_t *pGate)
 
int Map_SuperTableInsert (Map_HashTable_t *pLib, unsigned uTruth[], Map_Super_t *pGate, unsigned uPhase)
 
Map_Super_tMap_SuperTableLookup (Map_HashTable_t *p, unsigned uTruth[], unsigned *puPhase)
 
void Map_SuperTableSortSupergates (Map_HashTable_t *p, int nSupersMax)
 
void Map_SuperTableSortSupergatesByDelay (Map_HashTable_t *p, int nSupersMax)
 
float Map_TimeCutComputeArrival (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, float tWorstCaseLimit)
 
float Map_TimeComputeArrivalMax (Map_Man_t *p)
 DECLARATIONS ///. More...
 
void Map_TimeComputeRequiredGlobal (Map_Man_t *p)
 
void Map_MappingTruths (Map_Man_t *pMan)
 FUNCTION DEFINITIONS ///. More...
 
int Map_TruthsCutDontCare (Map_Man_t *pMan, Map_Cut_t *pCut, unsigned *uTruthDc)
 
int Map_TruthCountOnes (unsigned *uTruth, int nLeaves)
 
int Map_TruthDetectTwoFirst (unsigned *uTruth, int nLeaves)
 
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_MappingMark_rec (Map_Node_t *pNode)
 
void Map_MappingUnmark_rec (Map_Node_t *pNode)
 
void Map_MappingPrintOutputArrivals (Map_Man_t *p)
 
void Map_MappingSetupMask (unsigned uMask[], int nVarsMax)
 
int Map_MappingNodeIsViolator (Map_Node_t *pNode, Map_Cut_t *pCut, int fPosPol)
 
float Map_MappingGetAreaFlow (Map_Man_t *p)
 
void Map_MappingSortByLevel (Map_Man_t *pMan, Map_NodeVec_t *vNodes)
 
int Map_MappingCountDoubles (Map_Man_t *pMan, Map_NodeVec_t *vNodes)
 
void Map_MappingExpandTruth (unsigned uTruth[2], int nVars)
 
float Map_MappingPrintSwitching (Map_Man_t *pMan)
 
void Map_MappingSetPlacementInfo (Map_Man_t *p)
 
float Map_MappingPrintWirelength (Map_Man_t *p)
 
void Map_MappingWireReport (Map_Man_t *p)
 
float Map_MappingComputeDelayWithFanouts (Map_Man_t *p)
 
int Map_MappingGetMaxLevel (Map_Man_t *pMan)
 
void Map_MappingSetChoiceLevels (Map_Man_t *pMan)
 
void Map_MappingReportChoices (Map_Man_t *pMan)
 
Map_NodeVec_tMap_NodeVecAlloc (int nCap)
 FUNCTION DEFINITIONS ///. More...
 
void Map_NodeVecFree (Map_NodeVec_t *p)
 
Map_NodeVec_tMap_NodeVecDup (Map_NodeVec_t *p)
 
Map_Node_t ** Map_NodeVecReadArray (Map_NodeVec_t *p)
 
int Map_NodeVecReadSize (Map_NodeVec_t *p)
 
void Map_NodeVecGrow (Map_NodeVec_t *p, int nCapMin)
 
void Map_NodeVecShrink (Map_NodeVec_t *p, int nSizeNew)
 
void Map_NodeVecClear (Map_NodeVec_t *p)
 
void Map_NodeVecPush (Map_NodeVec_t *p, Map_Node_t *Entry)
 
int Map_NodeVecPushUnique (Map_NodeVec_t *p, Map_Node_t *Entry)
 
Map_Node_tMap_NodeVecPop (Map_NodeVec_t *p)
 
void Map_NodeVecRemove (Map_NodeVec_t *p, Map_Node_t *Entry)
 
void Map_NodeVecWriteEntry (Map_NodeVec_t *p, int i, Map_Node_t *Entry)
 
Map_Node_tMap_NodeVecReadEntry (Map_NodeVec_t *p, int i)
 
void Map_NodeVecSortByLevel (Map_NodeVec_t *p)
 

Macro Definition Documentation

#define Map_CutIsComplement (   p)    (((int)((ABC_PTRUINT_T) (p) & 01)))

Definition at line 67 of file mapperInt.h.

#define Map_CutNot (   p)    ((Map_Cut_t *)((ABC_PTRUINT_T)(p) ^ 01))

Definition at line 69 of file mapperInt.h.

#define Map_CutNotCond (   p,
 
)    ((Map_Cut_t *)((ABC_PTRUINT_T)(p) ^ (c)))

Definition at line 70 of file mapperInt.h.

#define Map_CutRegular (   p)    ((Map_Cut_t *)((ABC_PTRUINT_T)(p) & ~01))

Definition at line 68 of file mapperInt.h.

#define MAP_FLOAT_LARGE   ((float)(FLT_MAX/10))

Definition at line 60 of file mapperInt.h.

#define MAP_FLOAT_SMALL   ((float)1.0e-03)

Definition at line 61 of file mapperInt.h.

#define MAP_FULL   (~((unsigned)0))

Definition at line 52 of file mapperInt.h.

#define Map_InfoFlipVar (   p,
 
)    (p[(i)>>5] ^= (1<<((i) & 31)))

Definition at line 79 of file mapperInt.h.

#define Map_InfoReadVar (   p,
 
)    ((p[(i)>>5] & (1<<((i) & 31))) > 0)

Definition at line 80 of file mapperInt.h.

#define Map_InfoRemVar (   p,
 
)    (p[(i)>>5] &= ~(1<<((i) & 31)))

Definition at line 78 of file mapperInt.h.

#define Map_InfoSetVar (   p,
 
)    (p[(i)>>5] |= (1<<((i) & 31)))

Definition at line 77 of file mapperInt.h.

#define MAP_MASK (   n)    ((~((unsigned)0)) >> (32-(n)))

INCLUDES ///.

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

FileName [mapperInt.h]

PackageName [MVSIS 2.0: 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:
mapperInt.h,v 1.8 2004/09/30 21:18:10 satrajit Exp

]PARAMETERS ///MACRO DEFINITIONS ///

Definition at line 51 of file mapperInt.h.

#define MAP_MAX (   a,
 
)    (((a) > (b))? (a) : (b))

Definition at line 57 of file mapperInt.h.

#define MAP_MIN (   a,
 
)    (((a) < (b))? (a) : (b))

Definition at line 56 of file mapperInt.h.

#define MAP_NO_VAR   (-9999.0)

Definition at line 53 of file mapperInt.h.

#define Map_NodeForEachFanout (   pNode,
  pFanout 
)
Value:
for ( pFanout = (pNode)->pFanPivot; pFanout; \
pFanout = Map_NodeReadNextFanout(pNode, pFanout) )
#define Map_NodeReadNextFanout(pNode, pFanout)
Definition: mapperInt.h:325

Definition at line 336 of file mapperInt.h.

#define Map_NodeForEachFanoutSafe (   pNode,
  pFanout,
  pFanout2 
)
Value:
for ( pFanout = (pNode)->pFanPivot, \
pFanout2 = Map_NodeReadNextFanout(pNode, pFanout); \
pFanout; \
pFanout = pFanout2, \
pFanout2 = Map_NodeReadNextFanout(pNode, pFanout) )
#define Map_NodeReadNextFanout(pNode, pFanout)
Definition: mapperInt.h:325

Definition at line 341 of file mapperInt.h.

#define Map_NodeIsSimComplement (   p)    (Map_IsComplement(p)? !(Map_Regular(p)->fInv) : (p)->fInv)

Definition at line 83 of file mapperInt.h.

#define Map_NodeReadNextFanout (   pNode,
  pFanout 
)
Value:
( ( pFanout == NULL )? NULL : \
((Map_Regular((pFanout)->p1) == (pNode))? \
(pFanout)->pFanFanin1 : (pFanout)->pFanFanin2) )
#define Map_Regular(p)
Definition: mapper.h:68

Definition at line 325 of file mapperInt.h.

#define Map_NodeReadNextFanoutPlace (   pNode,
  pFanout 
)
Value:
( (Map_Regular((pFanout)->p1) == (pNode))? \
&(pFanout)->pFanFanin1 : &(pFanout)->pFanFanin2 )
#define Map_Regular(p)
Definition: mapper.h:68

Definition at line 331 of file mapperInt.h.

#define Map_NodeReadRef (   p)    ((Map_Regular(p))->nRefs)

Definition at line 73 of file mapperInt.h.

#define Map_NodeRef (   p)    ((Map_Regular(p))->nRefs++)

Definition at line 74 of file mapperInt.h.

#define MAP_RANDOM_UNSIGNED   ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))

Definition at line 64 of file mapperInt.h.

Function Documentation

Map_Cut_t* Map_CutAlloc ( Map_Man_t p)

DECLARATIONS ///.

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

FileName [mapperCutUtils.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:
mapperCutUtils.h,v 1.0 2003/09/08 00:00:00 alanmi Exp

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

Synopsis [Allocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 43 of file mapperCutUtils.c.

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 }
char * memset()
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
Map_Time_t tArrive
Definition: mapperInt.h:255
Map_Match_t M[2]
Definition: mapperInt.h:271
float Map_CutDeref ( Map_Cut_t pCut,
int  fPhase 
)

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

synopsis [Dereferences the cut.]

description []

sideeffects []

seealso []

Definition at line 384 of file mapperRefs.c.

385 {
386  return Map_CutRefDeref( pCut, fPhase, 0 ); // dereference
387 }
float Map_CutRefDeref(Map_Cut_t *pCut, int fPhase, int fReference)
Definition: mapperRefs.c:229
void Map_CutFree ( Map_Man_t p,
Map_Cut_t pCut 
)

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

Synopsis [Deallocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file mapperCutUtils.c.

76 {
77  if ( pCut )
78  Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
79 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
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 348 of file mapperRefs.c.

349 {
350  float aResult, aResult2;
351  aResult2 = Map_CutRefDeref( pCut, fPhase, 1 ); // reference
352  aResult = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference
353 // assert( aResult == aResult2 );
354  return aResult;
355 }
float Map_CutRefDeref(Map_Cut_t *pCut, int fPhase, int fReference)
Definition: mapperRefs.c:229
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 }
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
unsigned uPhaseBest
Definition: mapperInt.h:252
float Map_NodeReadRefPhaseEst(Map_Node_t *pNode, int fPhase)
Definition: mapperRefs.c:63
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
Map_Match_t M[2]
Definition: mapperInt.h:271
Map_Node_t * ppLeaves[6]
Definition: mapperInt.h:265
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 328 of file mapperRefs.c.

329 {
330  float aResult, aResult2;
331  aResult2 = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference
332  aResult = Map_CutRefDeref( pCut, fPhase, 1 ); // reference
333 // assert( aResult == aResult2 );
334  return aResult;
335 }
float Map_CutRefDeref(Map_Cut_t *pCut, int fPhase, int fReference)
Definition: mapperRefs.c:229
int Map_CutGetLeafPhase ( Map_Cut_t pCut,
int  fPhase,
int  iLeaf 
)

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

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

description []

sideeffects []

seealso []

Definition at line 131 of file mapperCutUtils.c.

132 {
133  assert( pCut->M[fPhase].pSuperBest );
134  return (( pCut->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
135 }
unsigned uPhaseBest
Definition: mapperInt.h:252
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
float Map_CutGetRootArea ( Map_Cut_t pCut,
int  fPhase 
)

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

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

description []

sideeffects []

seealso []

Definition at line 114 of file mapperCutUtils.c.

115 {
116  assert( pCut->M[fPhase].pSuperBest );
117  return pCut->M[fPhase].pSuperBest->Area;
118 }
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
void Map_CutInsertFanouts ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)
Map_Cut_t* Map_CutListAppend ( Map_Cut_t pSetAll,
Map_Cut_t pSets 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file mapperCutUtils.c.

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 }
Map_Cut_t * pNext
Definition: mapperInt.h:262
#define assert(ex)
Definition: util_old.h:213
int Map_CutListCount ( Map_Cut_t pSets)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 214 of file mapperCutUtils.c.

215 {
216  Map_Cut_t * pTemp;
217  int i;
218  for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
219  return i;
220 }
Map_Cut_t * pNext
Definition: mapperInt.h:262
void Map_CutListRecycle ( Map_Man_t p,
Map_Cut_t pSetList,
Map_Cut_t pSave 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file mapperCutUtils.c.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Map_Cut_t * pNext
Definition: mapperInt.h:262
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 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file mapperCutUtils.c.

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 }
Map_Time_t tArrive
Definition: mapperInt.h:255
Map_Match_t M[2]
Definition: mapperInt.h:271
Map_Node_t * ppLeaves[6]
Definition: mapperInt.h:265
float Map_CutRef ( Map_Cut_t pCut,
int  fPhase 
)

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

synopsis [References the cut.]

description []

sideeffects []

seealso []

Definition at line 368 of file mapperRefs.c.

369 {
370  return Map_CutRefDeref( pCut, fPhase, 1 ); // reference
371 }
float Map_CutRefDeref(Map_Cut_t *pCut, int fPhase, int fReference)
Definition: mapperRefs.c:229
void Map_CutRemoveFanouts ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)
int Map_LibraryDeriveGateInfo ( Map_SuperLib_t pLib,
st__table tExcludeGate 
)

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

Synopsis [Derives information about the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 586 of file mapperTree.c.

587 {
588  Map_Super_t * pGate, * pFanin;
589  Mio_Pin_t * pPin;
590  unsigned uCanon[2];
591  unsigned uTruths[6][2];
592  int i, k, nRealVars;
593 
594  // set all the derivable info related to the supergates
595  for ( i = pLib->nVarsMax; i < (int)pLib->nLines; i++ )
596  {
597  pGate = pLib->ppSupers[i];
598 
599  if ( tExcludeGate )
600  {
601  if ( st__is_member( tExcludeGate, Mio_GateReadName( pGate->pRoot ) ) )
602  pGate->fExclude = 1;
603  for ( k = 0; k < (int)pGate->nFanins; k++ )
604  {
605  pFanin = pGate->pFanins[k];
606  if ( pFanin->fExclude )
607  {
608  pGate->fExclude = 1;
609  continue;
610  }
611  }
612  }
613 
614  // collect the truth tables of the fanins
615  for ( k = 0; k < (int)pGate->nFanins; k++ )
616  {
617  pFanin = pGate->pFanins[k];
618  uTruths[k][0] = pFanin->uTruth[0];
619  uTruths[k][1] = pFanin->uTruth[1];
620  }
621  // derive the new truth table
622  Mio_DeriveTruthTable( pGate->pRoot, uTruths, pGate->nFanins, 6, pGate->uTruth );
623 
624  // set the initial delays of the supergate
625  for ( k = 0; k < pLib->nVarsMax; k++ )
626  {
627  pGate->tDelaysR[k].Rise = pGate->tDelaysR[k].Fall = MAP_NO_VAR;
628  pGate->tDelaysF[k].Rise = pGate->tDelaysF[k].Fall = MAP_NO_VAR;
629  }
630  // get the linked list of pins for the given root gate
631  pPin = Mio_GateReadPins( pGate->pRoot );
632  // update the initial delay of the supergate using info from the corresponding pin
633  for ( k = 0; k < (int)pGate->nFanins; k++, pPin = Mio_PinReadNext(pPin) )
634  {
635  // if there is no corresponding pin, this is a bug, return fail
636  if ( pPin == NULL )
637  {
638  printf( "There are less pins than gate inputs.\n" );
639  return 0;
640  }
641  // update the delay information of k-th fanins info from the corresponding pin
642  Map_LibraryAddFaninDelays( pLib, pGate, pGate->pFanins[k], pPin );
643  }
644  // if there are some pins left, this is a bug, return fail
645  if ( pPin != NULL )
646  {
647  printf( "There are more pins than gate inputs.\n" );
648  return 0;
649  }
650  // find the max delay
651  pGate->tDelayMax.Rise = pGate->tDelayMax.Fall = MAP_NO_VAR;
652  for ( k = 0; k < pLib->nVarsMax; k++ )
653  {
654  // the rise of the output depends on the rise and fall of the output
655  if ( pGate->tDelayMax.Rise < pGate->tDelaysR[k].Rise )
656  pGate->tDelayMax.Rise = pGate->tDelaysR[k].Rise;
657  if ( pGate->tDelayMax.Rise < pGate->tDelaysR[k].Fall )
658  pGate->tDelayMax.Rise = pGate->tDelaysR[k].Fall;
659  // the fall of the output depends on the rise and fall of the output
660  if ( pGate->tDelayMax.Fall < pGate->tDelaysF[k].Rise )
661  pGate->tDelayMax.Fall = pGate->tDelaysF[k].Rise;
662  if ( pGate->tDelayMax.Fall < pGate->tDelaysF[k].Fall )
663  pGate->tDelayMax.Fall = pGate->tDelaysF[k].Fall;
664 
665  pGate->tDelaysF[k].Worst = MAP_MAX( pGate->tDelaysF[k].Fall, pGate->tDelaysF[k].Rise );
666  pGate->tDelaysR[k].Worst = MAP_MAX( pGate->tDelaysR[k].Fall, pGate->tDelaysR[k].Rise );
667  }
668 
669  // count gates and area of the supergate
670  pGate->nGates = 1;
671  pGate->Area = (float)Mio_GateReadArea(pGate->pRoot);
672  for ( k = 0; k < (int)pGate->nFanins; k++ )
673  {
674  pGate->nGates += pGate->pFanins[k]->nGates;
675  pGate->Area += pGate->pFanins[k]->Area;
676  }
677  // do not add the gate to the table, if this gate is an internal gate
678  // of some supegate and does not correspond to a supergate output
679  if ( ( !pGate->fSuper ) || pGate->fExclude )
680  continue;
681 
682  // find the maximum index of a variable in the support of the supergates
683  // this is important for two reasons:
684  // (1) to limit the number of permutations considered for canonicization
685  // (2) to get rid of equivalence phases to speed-up matching
686  nRealVars = Map_LibraryGetMaxSuperPi_rec( pGate ) + 1;
687  assert( nRealVars > 0 && nRealVars <= pLib->nVarsMax );
688  // if there are some problems with this code, try this instead
689 // nRealVars = pLib->nVarsMax;
690 
691  // find the N-canonical form of this supergate
692  pGate->nPhases = Map_CanonComputeSlow( pLib->uTruths, pLib->nVarsMax, nRealVars, pGate->uTruth, pGate->uPhases, uCanon );
693  // add the supergate into the table by its N-canonical table
694  Map_SuperTableInsertC( pLib->tTableC, uCanon, pGate );
695 /*
696  {
697  int uCanon1, uCanon2;
698  uCanon1 = uCanon[0];
699  pGate->uTruth[0] = ~pGate->uTruth[0];
700  pGate->uTruth[1] = ~pGate->uTruth[1];
701  Map_CanonComputeSlow( pLib->uTruths, pLib->nVarsMax, nRealVars, pGate->uTruth, pGate->uPhases, uCanon );
702  uCanon2 = uCanon[0];
703 Rwt_Man5ExploreCount( uCanon1 < uCanon2 ? uCanon1 : uCanon2 );
704  }
705 */
706  }
707  // sort the gates in each line
709 
710  // let the glory be manifest
711 // Map_LibraryPrintTree( pLib );
712  return 1;
713 }
#define MAP_NO_VAR
Definition: mapperInt.h:53
void Map_SuperTableSortSupergatesByDelay(Map_HashTable_t *p, int nSupersMax)
Definition: mapperTable.c:362
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
unsigned nFanins
Definition: mapperInt.h:280
Map_Time_t tDelaysF[6]
Definition: mapperInt.h:291
unsigned char uPhases[4]
Definition: mapperInt.h:285
#define st__is_member(table, key)
Definition: st.h:70
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
Map_Time_t tDelayMax
Definition: mapperInt.h:292
unsigned uTruths[6][2]
Definition: mapperInt.h:184
Mio_Gate_t * pRoot
Definition: mapperInt.h:288
unsigned uTruth[2]
Definition: mapperInt.h:289
unsigned fExclude
Definition: mapperInt.h:279
Map_Super_t * pFanins[6]
Definition: mapperInt.h:287
unsigned nPhases
Definition: mapperInt.h:284
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
Definition: mioUtils.c:608
double Mio_GateReadArea(Mio_Gate_t *pGate)
Definition: mioApi.c:145
int Map_CanonComputeSlow(unsigned uTruths[][2], int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char *puPhases, unsigned uTruthRes[])
FUNCTION DEFINITIONS ///.
Definition: mapperCanon.c:48
#define assert(ex)
Definition: util_old.h:213
static ABC_NAMESPACE_IMPL_START void Map_LibraryAddFaninDelays(Map_SuperLib_t *pLib, Map_Super_t *pGate, Map_Super_t *pFanin, Mio_Pin_t *pPin)
DECLARATIONS ///.
Definition: mapperTree.c:774
Map_Time_t tDelaysR[6]
Definition: mapperInt.h:290
int Map_SuperTableInsertC(Map_HashTable_t *pLib, unsigned uTruthC[], Map_Super_t *pGate)
Definition: mapperTable.c:92
Map_HashTable_t * tTableC
Definition: mapperInt.h:180
static int Map_LibraryGetMaxSuperPi_rec(Map_Super_t *pGate)
Definition: mapperTree.c:726
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
void Map_LibraryPrintSupergate ( Map_Super_t pGate)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 403 of file mapperSuper.c.

404 {
405  printf( "%5d : ", pGate->nUsed );
406  printf( "%5d ", pGate->Num );
407  printf( "A = %5.2f ", pGate->Area );
408  printf( "D = %5.2f/%5.2f/%5.2f ", pGate->tDelayMax.Rise, pGate->tDelayMax.Fall, pGate->tDelayMax.Worst );
409  printf( "%s", pGate->pFormula );
410  printf( "\n" );
411 }
Map_Time_t tDelayMax
Definition: mapperInt.h:292
void Map_LibraryPrintTree ( Map_SuperLib_t pLib)

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

Synopsis [Prints the supergate library after deriving parameters.]

Description [This procedure is very useful to see the library after it has been read into the mapper by "read_super" and all the information about the supergates derived.]

SideEffects []

SeeAlso []

Definition at line 979 of file mapperTree.c.

980 {
981  Map_Super_t * pGate;
982  int i, k;
983 
984  // print all the info related to the supergates
985 // for ( i = pLib->nVarsMax; i < (int)pLib->nLines; i++ )
986  for ( i = pLib->nVarsMax; i < 20; i++ )
987  {
988  pGate = pLib->ppSupers[i];
989 
990  // write the gate's fanin info and formula
991  printf( "%6d ", pGate->Num );
992  printf( "%c ", pGate->fSuper? '*' : ' ' );
993  printf( "%6s", Mio_GateReadName(pGate->pRoot) );
994  for ( k = 0; k < (int)pGate->nFanins; k++ )
995  printf( " %6d", pGate->pFanins[k]->Num );
996  printf( " %s", pGate->pFormula );
997  printf( "\n" );
998 
999  // write the gate's derived info
1000  Extra_PrintBinary( stdout, pGate->uTruth, 64 );
1001  printf( " %3d", pGate->nGates );
1002  printf( " %6.2f", pGate->Area );
1003  printf( " (%4.2f, %4.2f)", pGate->tDelayMax.Rise, pGate->tDelayMax.Fall );
1004  printf( "\n" );
1005  for ( k = 0; k < pLib->nVarsMax; k++ )
1006  {
1007  // print the constraint on the rise of the gate in the form (D1, D2),
1008  // where D1 is the constraint related to the rise of the k-th PI
1009  // where D2 is the constraint related to the fall of the k-th PI
1010  if ( pGate->tDelaysR[k].Rise < 0 && pGate->tDelaysR[k].Fall < 0 )
1011  printf( " (----, ----)" );
1012  else if ( pGate->tDelaysR[k].Fall < 0 )
1013  printf( " (%4.2f, ----)", pGate->tDelaysR[k].Rise );
1014  else if ( pGate->tDelaysR[k].Rise < 0 )
1015  printf( " (----, %4.2f)", pGate->tDelaysR[k].Fall );
1016  else
1017  printf( " (%4.2f, %4.2f)", pGate->tDelaysR[k].Rise, pGate->tDelaysR[k].Fall );
1018 
1019  // print the constraint on the fall of the gate in the form (D1, D2),
1020  // where D1 is the constraint related to the rise of the k-th PI
1021  // where D2 is the constraint related to the fall of the k-th PI
1022  if ( pGate->tDelaysF[k].Rise < 0 && pGate->tDelaysF[k].Fall < 0 )
1023  printf( " (----, ----)" );
1024  else if ( pGate->tDelaysF[k].Fall < 0 )
1025  printf( " (%4.2f, ----)", pGate->tDelaysF[k].Rise );
1026  else if ( pGate->tDelaysF[k].Rise < 0 )
1027  printf( " (----, %4.2f)", pGate->tDelaysF[k].Fall );
1028  else
1029  printf( " (%4.2f, %4.2f)", pGate->tDelaysF[k].Rise, pGate->tDelaysF[k].Fall );
1030  printf( "\n" );
1031  }
1032  printf( "\n" );
1033  }
1034 }
unsigned nFanins
Definition: mapperInt.h:280
Map_Time_t tDelaysF[6]
Definition: mapperInt.h:291
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
Map_Time_t tDelayMax
Definition: mapperInt.h:292
Mio_Gate_t * pRoot
Definition: mapperInt.h:288
unsigned uTruth[2]
Definition: mapperInt.h:289
Map_Super_t * pFanins[6]
Definition: mapperInt.h:287
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
Map_Time_t tDelaysR[6]
Definition: mapperInt.h:290
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
int Map_LibraryRead ( Map_SuperLib_t pLib,
char *  pFileName 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the supergate library from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file mapperSuper.c.

51 {
52  FILE * pFile;
53  int Status;
54  // read the beginning of the file
55  assert( pLib->pGenlib == NULL );
56  pFile = fopen( pFileName, "r" );
57  if ( pFile == NULL )
58  {
59  printf( "Cannot open input file \"%s\".\n", pFileName );
60  return 0;
61  }
62  Status = Map_LibraryReadFile( pLib, pFile );
63  fclose( pFile );
64 // Map_LibraryPrintClasses( pLib );
65  return Status;
66 }
static ABC_NAMESPACE_IMPL_START int Map_LibraryReadFile(Map_SuperLib_t *pLib, FILE *pFile)
DECLARATIONS ///.
Definition: mapperSuper.c:80
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
#define assert(ex)
Definition: util_old.h:213
int Map_LibraryReadFileTreeStr ( Map_SuperLib_t pLib,
Mio_Library_t pGenlib,
Vec_Str_t vStr,
char *  pFileName 
)

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

Synopsis [Reads the supergate library from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 391 of file mapperTree.c.

392 {
393  ProgressBar * pProgress;
394  char pBuffer[5000];
395  Map_Super_t * pGate;
396  char * pTemp = 0, * pLibName;
397  int nCounter, k, i;
398  int RetValue, nPos = 0;
399 
400  // skip empty and comment lines
401 // while ( fgets( pBuffer, 5000, pFile ) != NULL )
402  while ( 1 )
403  {
404  RetValue = Vec_StrGets( pBuffer, 5000, vStr, &nPos );
405  if ( RetValue == 0 )
406  return 0;
407  // skip leading spaces
408  for ( pTemp = pBuffer; *pTemp == ' ' || *pTemp == '\r' || *pTemp == '\n'; pTemp++ );
409  // skip comment lines and empty lines
410  if ( *pTemp != 0 && *pTemp != '#' )
411  break;
412  }
413 
414  pLibName = strtok( pTemp, " \t\r\n" );
415 // pLib->pGenlib = (Mio_Library_t *)Abc_FrameReadLibGen();
416  pLib->pGenlib = pGenlib;
417 // if ( pLib->pGenlib == NULL || strcmp( , pLibName ) )
418  if ( pLib->pGenlib == NULL || Map_LibraryCompareLibNames(Mio_LibraryReadName(pLib->pGenlib), pLibName) )
419  {
420  printf( "Supergate library \"%s\" requires the use of genlib library \"%s\".\n", pFileName, pLibName );
421  return 0;
422  }
423 
424  // read the number of variables
425  RetValue = Vec_StrGets( pBuffer, 5000, vStr, &nPos );
426  if ( RetValue == 0 )
427  return 0;
428  RetValue = sscanf( pBuffer, "%d\n", &pLib->nVarsMax );
429  if ( pLib->nVarsMax < 2 || pLib->nVarsMax > 10 )
430  {
431  printf( "Suspicious number of variables (%d).\n", pLib->nVarsMax );
432  return 0;
433  }
434 
435  // read the number of gates
436  RetValue = Vec_StrGets( pBuffer, 5000, vStr, &nPos );
437  if ( RetValue == 0 )
438  return 0;
439  RetValue = sscanf( pBuffer, "%d\n", &pLib->nSupersReal );
440  if ( pLib->nSupersReal < 1 || pLib->nSupersReal > 10000000 )
441  {
442  printf( "Suspicious number of gates (%d).\n", pLib->nSupersReal );
443  return 0;
444  }
445 
446  // read the number of lines
447  RetValue = Vec_StrGets( pBuffer, 5000, vStr, &nPos );
448  if ( RetValue == 0 )
449  return 0;
450  RetValue = sscanf( pBuffer, "%d\n", &pLib->nLines );
451  if ( pLib->nLines < 1 || pLib->nLines > 10000000 )
452  {
453  printf( "Suspicious number of lines (%d).\n", pLib->nLines );
454  return 0;
455  }
456 
457  // allocate room for supergate pointers
458  pLib->ppSupers = ABC_ALLOC( Map_Super_t *, pLib->nLines + 10000 );
459 
460  // create the elementary supergates
461  for ( i = 0; i < pLib->nVarsMax; i++ )
462  {
463  // get a new gate
464  pGate = (Map_Super_t *)Extra_MmFixedEntryFetch( pLib->mmSupers );
465  memset( pGate, 0, sizeof(Map_Super_t) );
466  // assign the elementary variable, the truth table, and the delays
467  pGate->Num = i;
468  // set the truth table
469  pGate->uTruth[0] = pLib->uTruths[i][0];
470  pGate->uTruth[1] = pLib->uTruths[i][1];
471  // set the arrival times of all input to non-existent delay
472  for ( k = 0; k < pLib->nVarsMax; k++ )
473  {
474  pGate->tDelaysR[k].Rise = pGate->tDelaysR[k].Fall = MAP_NO_VAR;
475  pGate->tDelaysF[k].Rise = pGate->tDelaysF[k].Fall = MAP_NO_VAR;
476  }
477  // set an existent arrival time for rise and fall
478  pGate->tDelaysR[i].Rise = 0.0;
479  pGate->tDelaysF[i].Fall = 0.0;
480  // set the gate
481  pLib->ppSupers[i] = pGate;
482  }
483 
484  // read the lines
485  nCounter = pLib->nVarsMax;
486  pProgress = Extra_ProgressBarStart( stdout, pLib->nLines );
487 // while ( fgets( pBuffer, 5000, pFile ) != NULL )
488  while ( Vec_StrGets( pBuffer, 5000, vStr, &nPos ) )
489  {
490  for ( pTemp = pBuffer; *pTemp == ' ' || *pTemp == '\r' || *pTemp == '\n'; pTemp++ );
491  if ( pTemp[0] == '\0' )
492  continue;
493 // if ( pTemp[0] == 'a' || pTemp[2] == 'a' )
494 // {
495 // pLib->nLines--;
496 // continue;
497 // }
498 
499  // get the gate
500  pGate = Map_LibraryReadGateTree( pLib, pTemp, nCounter, pLib->nVarsMax );
501  if ( pGate == NULL )
502  {
503  Extra_ProgressBarStop( pProgress );
504  return 0;
505  }
506  pLib->ppSupers[nCounter++] = pGate;
507  // later we will derive: truth table, delays, area, number of component gates, etc
508 
509  // update the progress bar
510  Extra_ProgressBarUpdate( pProgress, nCounter, NULL );
511  }
512  Extra_ProgressBarStop( pProgress );
513  if ( nCounter != pLib->nLines )
514  printf( "The number of lines read (%d) is different from what the file says (%d).\n", nCounter, pLib->nLines );
515  pLib->nSupersAll = nCounter;
516  // count the number of real supergates
517  nCounter = 0;
518  for ( k = 0; k < pLib->nLines; k++ )
519  nCounter += pLib->ppSupers[k]->fSuper;
520  if ( nCounter != pLib->nSupersReal )
521  printf( "The number of gates read (%d) is different what the file says (%d).\n", nCounter, pLib->nSupersReal );
522  pLib->nSupersReal = nCounter;
523  return 1;
524 }
char * memset()
#define MAP_NO_VAR
Definition: mapperInt.h:53
int Vec_StrGets(char *pBuffer, int nBufferSize, Vec_Str_t *vStr, int *pPos)
Definition: mapperTree.c:316
char * strtok()
Map_Time_t tDelaysF[6]
Definition: mapperInt.h:291
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
int Map_LibraryCompareLibNames(char *pName1, char *pName2)
Definition: mapperTree.c:363
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioApi.c:43
unsigned uTruths[6][2]
Definition: mapperInt.h:184
DECLARATIONS ///.
unsigned uTruth[2]
Definition: mapperInt.h:289
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
Extra_MmFixed_t * mmSupers
Definition: mapperInt.h:195
if(last==0)
Definition: sparse_int.h:34
void Extra_ProgressBarStop(ProgressBar *p)
Map_Super_t * Map_LibraryReadGateTree(Map_SuperLib_t *pLib, char *pBuffer, int Number, int nVarsMax)
FUNCTION DEFINITIONS ///.
Definition: mapperTree.c:54
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Map_Time_t tDelaysR[6]
Definition: mapperInt.h:290
int Map_LibraryReadTree ( Map_SuperLib_t pLib,
Mio_Library_t pGenlib,
char *  pFileName,
char *  pExcludeFile 
)

Definition at line 525 of file mapperTree.c.

526 {
527  char * pBuffer;
528  Vec_Str_t * vStr;
529  int Status, num;
530  Abc_Frame_t * pAbc;
531  st__table * tExcludeGate = 0;
532 
533  // read the beginning of the file
534  assert( pLib->pGenlib == NULL );
535 // pFile = Io_FileOpen( pFileName, "open_path", "r", 1 );
536  pBuffer = Mio_ReadFile( pFileName, 0 );
537  if ( pBuffer == NULL )
538  {
539  printf( "Cannot open input file \"%s\".\n", pFileName );
540  return 0;
541  }
542  vStr = Vec_StrAllocArray( pBuffer, strlen(pBuffer) );
543 
544  if ( pExcludeFile )
545  {
546  pAbc = Abc_FrameGetGlobalFrame();
547 
548  tExcludeGate = st__init_table(strcmp, st__strhash);
549  if ( (num = Mio_LibraryReadExclude( pExcludeFile, tExcludeGate )) == -1 )
550  {
551  st__free_table( tExcludeGate );
552  tExcludeGate = 0;
553  Vec_StrFree( vStr );
554  return 0;
555  }
556 
557  fprintf ( Abc_FrameReadOut( pAbc ), "Read %d gates from exclude file\n", num );
558  }
559 
560  Status = Map_LibraryReadFileTreeStr( pLib, pGenlib, vStr, pFileName );
561  Vec_StrFree( vStr );
562  if ( Status == 0 )
563  return 0;
564  // prepare the info about the library
565  return Map_LibraryDeriveGateInfo( pLib, tExcludeGate );
566 }
void st__free_table(st__table *table)
Definition: st.c:81
int Map_LibraryDeriveGateInfo(Map_SuperLib_t *pLib, st__table *tExcludeGate)
Definition: mapperTree.c:586
int strcmp()
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int st__strhash(const char *string, int modulus)
Definition: st.c:449
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
int Map_LibraryReadFileTreeStr(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName)
Definition: mapperTree.c:391
Definition: st.h:52
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
char * Mio_ReadFile(char *FileName, int fAddEnd)
Definition: mioRead.c:111
#define assert(ex)
Definition: util_old.h:213
int strlen()
int Mio_LibraryReadExclude(char *ExcludeFile, st__table *tExcludeGate)
Definition: mioRead.c:654
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
static Vec_Str_t * Vec_StrAllocArray(char *pArray, int nSize)
Definition: bblif.c:518
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
void Map_MappingCuts ( Map_Man_t p)

GLOBAL VARIABLES ///.

FUNCTION DEFINITIONS ///

Definition at line 172 of file mapperCut.c.

173 {
174  ProgressBar * pProgress;
175  Map_CutTable_t * pTable;
176  Map_Node_t * pNode;
177  int nCuts, nNodes, i;
178  abctime clk = Abc_Clock();
179  // set the elementary cuts for the PI variables
180  assert( p->nVarsMax > 1 && p->nVarsMax < 7 );
181  for ( i = 0; i < p->nInputs; i++ )
182  Map_MappingCutsInput( p, p->pInputs[i] );
183 
184  // compute the cuts for the internal nodes
185  nNodes = p->vMapObjs->nSize;
186  pProgress = Extra_ProgressBarStart( stdout, nNodes );
187  pTable = Map_CutTableStart( p );
188  for ( i = 0; i < nNodes; i++ )
189  {
190  pNode = p->vMapObjs->pArray[i];
191  if ( Map_NodeIsBuf(pNode) )
192  Map_MappingCutsInput( p, pNode );
193  else if ( Map_NodeIsAnd(pNode) )
194  Map_CutCompute( p, pTable, pNode );
195  else continue;
196  Extra_ProgressBarUpdate( pProgress, i, "Cuts ..." );
197  }
198  Extra_ProgressBarStop( pProgress );
199  Map_CutTableStop( pTable );
200 
201  // report the stats
202  if ( p->fVerbose )
203  {
204  nCuts = Map_MappingCountAllCuts(p);
205  printf( "Nodes = %6d. Total %d-feasible cuts = %10d. Per node = %.1f. ",
206  p->nNodes, p->nVarsMax, nCuts, ((float)nCuts)/p->nNodes );
207  ABC_PRT( "Time", Abc_Clock() - clk );
208  }
209 
210  // print the cuts for the first primary output
211 // Map_CutListPrint( p, Map_Regular(p->pOutputs[0]) );
212 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
int Map_MappingCountAllCuts(Map_Man_t *pMan)
FUNCTION DEFINITIONS ///.
Definition: mapperCut.c:100
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Map_Cut_t * Map_CutCompute(Map_Man_t *p, Map_CutTable_t *pTable, Map_Node_t *pNode)
Definition: mapperCut.c:225
static Map_CutTable_t * Map_CutTableStart(Map_Man_t *pMan)
Definition: mapperCut.c:816
int Map_NodeIsBuf(Map_Node_t *p)
Definition: mapperCreate.c:114
static abctime Abc_Clock()
Definition: abc_global.h:279
DECLARATIONS ///.
void Extra_ProgressBarStop(ProgressBar *p)
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Map_CutTableStop(Map_CutTable_t *p)
Definition: mapperCut.c:843
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
void Map_MappingCutsInput(Map_Man_t *p, Map_Node_t *pNode)
Definition: mapperCut.c:158
ABC_INT64_T abctime
Definition: abc_global.h:278
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_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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float nRefEst[3]
Definition: mapperInt.h:217
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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float nRefEst[3]
Definition: mapperInt.h:217
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
float Map_MappingGetArea ( Map_Man_t pMan)

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

Synopsis [Computes the array of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 474 of file mapperRefs.c.

475 {
476  Map_Node_t * pNode;
477  float Area = 0.0;
478  int i;
479  for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
480  {
481  pNode = pMan->vMapObjs->pArray[i];
482  if ( pNode->nRefAct[2] == 0 )
483  continue;
484  if ( Map_NodeIsBuf(pNode) )
485  continue;
486  // at least one phase has the best cut assigned
487  assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL );
488  // at least one phase is used in the mapping
489  assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 );
490  // compute the array due to the supergate
491  if ( Map_NodeIsAnd(pNode) )
492  {
493  // count area of the negative phase
494  if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) )
495  Area += pNode->pCutBest[0]->M[0].pSuperBest->Area;
496  // count area of the positive phase
497  if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) )
498  Area += pNode->pCutBest[1]->M[1].pSuperBest->Area;
499  }
500  // count area of the interver if we need to implement one phase with another phase
501  if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) ||
502  (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) )
503  Area += pMan->pSuperLib->AreaInv;
504  }
505  // add buffers for each CO driven by a CI
506  for ( i = 0; i < pMan->nOutputs; i++ )
507  if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) )
508  Area += pMan->pSuperLib->AreaBuf;
509  return Area;
510 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
int Map_NodeIsBuf(Map_Node_t *p)
Definition: mapperCreate.c:114
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
int Map_NodeIsVar(Map_Node_t *p)
Definition: mapperCreate.c:113
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
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
float Map_MappingGetSwitching ( Map_Man_t pMan)

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

Synopsis [Computes the array of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file mapperSwitch.c.

188 {
189  Map_Node_t * pNode;
190  float Switch = 0.0;
191  int i;
192  for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
193  {
194  pNode = pMan->vMapObjs->pArray[i];
195  if ( pNode->nRefAct[2] == 0 )
196  continue;
197  // at least one phase has the best cut assigned
198  assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL );
199  // at least one phase is used in the mapping
200  assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 );
201  // compute the array due to the supergate
202  if ( Map_NodeIsAnd(pNode) )
203  {
204  // count switching of the negative phase
205  if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) )
206  Switch += pNode->Switching;
207  // count switching of the positive phase
208  if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) )
209  Switch += pNode->Switching;
210  }
211  // count switching of the interver if we need to implement one phase with another phase
212  if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) ||
213  (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) )
214  Switch += pNode->Switching; // inverter switches the same as the node
215  }
216  // add buffers for each CO driven by a CI
217  for ( i = 0; i < pMan->nOutputs; i++ )
218  if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) )
219  Switch += pMan->pOutputs[i]->Switching;
220  return Switch;
221 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
int Map_NodeIsVar(Map_Node_t *p)
Definition: mapperCreate.c:113
#define assert(ex)
Definition: util_old.h:213
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_MappingMatches ( Map_Man_t p)

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

Synopsis [Computes the best matches of the nodes.]

Description [Uses parameter p->fMappingMode to decide how to assign the matches for both polarities of the node. While the matches are being assigned, one of them may turn out to be better than the other (in terms of delay, for example). In this case, the worse match can be permanently dropped, and the corresponding pointer set to NULL.]

SideEffects []

SeeAlso []

Definition at line 553 of file mapperMatch.c.

554 {
555  ProgressBar * pProgress;
556  Map_Node_t * pNode;
557  int i;
558 
559  assert( p->fMappingMode >= 0 && p->fMappingMode <= 4 );
560 
561  // use the externally given PI arrival times
562  if ( p->fMappingMode == 0 )
564 
565  // estimate the fanouts
566  if ( p->fMappingMode == 0 )
568  else if ( p->fMappingMode == 1 )
570 
571  // the PI cuts are matched in the cut computation package
572  // in the loop below we match the internal nodes
573  pProgress = Extra_ProgressBarStart( stdout, p->vMapObjs->nSize );
574  for ( i = 0; i < p->vMapObjs->nSize; i++ )
575  {
576  pNode = p->vMapObjs->pArray[i];
577  if ( Map_NodeIsBuf(pNode) )
578  {
579  assert( pNode->p2 == NULL );
580  pNode->tArrival[0] = Map_Regular(pNode->p1)->tArrival[ Map_IsComplement(pNode->p1)];
581  pNode->tArrival[1] = Map_Regular(pNode->p1)->tArrival[!Map_IsComplement(pNode->p1)];
582  continue;
583  }
584 
585  // skip primary inputs and secondary nodes if mapping with choices
586  if ( !Map_NodeIsAnd( pNode ) || pNode->pRepr )
587  continue;
588 
589  // make sure that at least one non-trival cut is present
590  if ( pNode->pCuts->pNext == NULL )
591  {
592  Extra_ProgressBarStop( pProgress );
593  printf( "\nError: A node in the mapping graph does not have feasible cuts.\n" );
594  return 0;
595  }
596 
597  // match negative phase
598  if ( !Map_MatchNodePhase( p, pNode, 0 ) )
599  {
600  Extra_ProgressBarStop( pProgress );
601  return 0;
602  }
603  // match positive phase
604  if ( !Map_MatchNodePhase( p, pNode, 1 ) )
605  {
606  Extra_ProgressBarStop( pProgress );
607  return 0;
608  }
609 
610  // make sure that at least one phase is mapped
611  if ( pNode->pCutBest[0] == NULL && pNode->pCutBest[1] == NULL )
612  {
613  printf( "\nError: Could not match both phases of AIG node %d.\n", pNode->Num );
614  printf( "Please make sure that the supergate library has equivalents of AND2 or NAND2.\n" );
615  printf( "If such supergates exist in the library, report a bug.\n" );
616  Extra_ProgressBarStop( pProgress );
617  return 0;
618  }
619 
620  // if both phases are assigned, check if one of them can be dropped
621  Map_NodeTryDroppingOnePhase( p, pNode );
622  // set the arrival times of the node using the best cuts
624 
625  // update the progress bar
626  Extra_ProgressBarUpdate( pProgress, i, "Matches ..." );
627  }
628  Extra_ProgressBarStop( pProgress );
629  return 1;
630 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Map_MatchNodePhase(Map_Man_t *p, Map_Node_t *pNode, int fPhase)
Definition: mapperMatch.c:235
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
int Map_NodeIsBuf(Map_Node_t *p)
Definition: mapperCreate.c:114
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
Map_Cut_t * pNext
Definition: mapperInt.h:262
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
DECLARATIONS ///.
void Map_MappingEstimateRefs(Map_Man_t *p)
Definition: mapperRefs.c:151
Map_Cut_t * pCuts
Definition: mapperInt.h:240
void Map_MappingSetPiArrivalTimes(Map_Man_t *p)
Definition: mapperMatch.c:351
void Map_MappingEstimateRefsInit(Map_Man_t *p)
Definition: mapperRefs.c:126
Map_Node_t * p2
Definition: mapperInt.h:222
void Extra_ProgressBarStop(ProgressBar *p)
Map_Node_t * p1
Definition: mapperInt.h:221
#define Map_Regular(p)
Definition: mapper.h:68
Map_Node_t * pRepr
Definition: mapperInt.h:224
void Map_NodeTransferArrivalTimes(Map_Man_t *p, Map_Node_t *pNode)
Definition: mapperMatch.c:503
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
void Map_NodeTryDroppingOnePhase(Map_Man_t *p, Map_Node_t *pNode)
Definition: mapperMatch.c:401
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()
float Map_MappingPrintSwitching ( Map_Man_t pMan)
float Map_MappingPrintWirelength ( Map_Man_t p)
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
void Map_MappingSetPlacementInfo ( Map_Man_t p)
void Map_MappingSetRefs ( Map_Man_t pMan)

Definition at line 441 of file mapperRefs.c.

442 {
443  Map_Node_t * pNode;
444  int i;
445  // clean all references
446  for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
447  {
448  pNode = pMan->vMapObjs->pArray[i];
449  pNode->nRefAct[0] = 0;
450  pNode->nRefAct[1] = 0;
451  pNode->nRefAct[2] = 0;
452  }
453  // visit nodes reachable from POs in the DFS order through the best cuts
454  for ( i = 0; i < pMan->nOutputs; i++ )
455  {
456  pNode = pMan->pOutputs[i];
457  if ( !Map_NodeIsConst(pNode) )
458  Map_MappingSetRefs_rec( pMan, pNode );
459  }
460 }
int Map_NodeIsConst(Map_Node_t *p)
Definition: mapperCreate.c:112
void Map_MappingSetRefs_rec(Map_Man_t *pMan, Map_Node_t *pNode)
Definition: mapperRefs.c:403
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_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_MappingTruths ( Map_Man_t pMan)

FUNCTION DEFINITIONS ///.

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

Synopsis [Derives truth tables for each cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file mapperTruth.c.

48 {
49  ProgressBar * pProgress;
50  Map_Node_t * pNode;
51  Map_Cut_t * pCut;
52  int nNodes, i;
53  // compute the cuts for the POs
54  nNodes = pMan->vMapObjs->nSize;
55  pProgress = Extra_ProgressBarStart( stdout, nNodes );
56  for ( i = 0; i < nNodes; i++ )
57  {
58  pNode = pMan->vMapObjs->pArray[i];
59  if ( !Map_NodeIsAnd( pNode ) )
60  continue;
61  assert( pNode->pCuts );
62  assert( pNode->pCuts->nLeaves == 1 );
63 
64  // match the simple cut
65  pNode->pCuts->M[0].uPhase = 0;
66  pNode->pCuts->M[0].pSupers = pMan->pSuperLib->pSuperInv;
67  pNode->pCuts->M[0].uPhaseBest = 0;
68  pNode->pCuts->M[0].pSuperBest = pMan->pSuperLib->pSuperInv;
69 
70  pNode->pCuts->M[1].uPhase = 0;
71  pNode->pCuts->M[1].pSupers = pMan->pSuperLib->pSuperInv;
72  pNode->pCuts->M[1].uPhaseBest = 1;
73  pNode->pCuts->M[1].pSuperBest = pMan->pSuperLib->pSuperInv;
74 
75  // match the rest of the cuts
76  for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext )
77  Map_TruthsCut( pMan, pCut );
78  Extra_ProgressBarUpdate( pProgress, i, "Tables ..." );
79  }
80  Extra_ProgressBarStop( pProgress );
81 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
unsigned uPhaseBest
Definition: mapperInt.h:252
static ABC_NAMESPACE_IMPL_START void Map_TruthsCut(Map_Man_t *pMan, Map_Cut_t *pCut)
DECLARATIONS ///.
Definition: mapperTruth.c:94
Map_Cut_t * pNext
Definition: mapperInt.h:262
Map_Super_t * pSupers
Definition: mapperInt.h:249
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
DECLARATIONS ///.
Map_Cut_t * pCuts
Definition: mapperInt.h:240
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Map_Match_t M[2]
Definition: mapperInt.h:271
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
void Map_MappingWireReport ( Map_Man_t p)
void Map_NodeAddFaninFanout ( Map_Node_t pFanin,
Map_Node_t pFanout 
)
int Map_NodeGetFanoutNum ( Map_Node_t pNode)
int Map_NodeGetLeafPhase ( Map_Node_t pNode,
int  fPhase,
int  iLeaf 
)

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

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

description []

sideeffects []

seealso []

Definition at line 148 of file mapperCutUtils.c.

149 {
150  assert( pNode->pCutBest[fPhase]->M[fPhase].pSuperBest );
151  return (( pNode->pCutBest[fPhase]->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
152 }
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
unsigned uPhaseBest
Definition: mapperInt.h:252
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
void Map_NodeRemoveFaninFanout ( Map_Node_t pFanin,
Map_Node_t pFanoutToRemove 
)
Map_NodeVec_t* Map_NodeVecAlloc ( int  nCap)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file mapperVec.c.

46 {
47  Map_NodeVec_t * p;
48  p = ABC_ALLOC( Map_NodeVec_t, 1 );
49  if ( nCap > 0 && nCap < 16 )
50  nCap = 16;
51  p->nSize = 0;
52  p->nCap = nCap;
53  p->pArray = p->nCap? ABC_ALLOC( Map_Node_t *, p->nCap ) : NULL;
54  return p;
55 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecClear ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file mapperVec.c.

175 {
176  p->nSize = 0;
177 }
Map_NodeVec_t* Map_NodeVecDup ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file mapperVec.c.

88 {
89  Map_NodeVec_t * pNew = Map_NodeVecAlloc( p->nSize );
90  memcpy( pNew->pArray, p->pArray, sizeof(int) * p->nSize );
91  pNew->nSize = p->nSize;
92  return pNew;
93 }
Map_NodeVec_t * Map_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: mapperVec.c:45
char * memcpy()
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecFree ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file mapperVec.c.

69 {
70  if ( p == NULL )
71  return;
72  ABC_FREE( p->pArray );
73  ABC_FREE( p );
74 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Map_NodeVecGrow ( Map_NodeVec_t p,
int  nCapMin 
)

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 138 of file mapperVec.c.

139 {
140  if ( p->nCap >= nCapMin )
141  return;
142  p->pArray = ABC_REALLOC( Map_Node_t *, p->pArray, nCapMin );
143  p->nCap = nCapMin;
144 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
Map_Node_t ** pArray
Definition: mapperInt.h:301
Map_Node_t* Map_NodeVecPop ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file mapperVec.c.

235 {
236  return p->pArray[--p->nSize];
237 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecPush ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file mapperVec.c.

191 {
192  if ( p->nSize == p->nCap )
193  {
194  if ( p->nCap < 16 )
195  Map_NodeVecGrow( p, 16 );
196  else
197  Map_NodeVecGrow( p, 2 * p->nCap );
198  }
199  p->pArray[p->nSize++] = Entry;
200 }
void Map_NodeVecGrow(Map_NodeVec_t *p, int nCapMin)
Definition: mapperVec.c:138
Map_Node_t ** pArray
Definition: mapperInt.h:301
int Map_NodeVecPushUnique ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis [Add the element while ensuring uniqueness.]

Description [Returns 1 if the element was found, and 0 if it was new. ]

SideEffects []

SeeAlso []

Definition at line 213 of file mapperVec.c.

214 {
215  int i;
216  for ( i = 0; i < p->nSize; i++ )
217  if ( p->pArray[i] == Entry )
218  return 1;
219  Map_NodeVecPush( p, Entry );
220  return 0;
221 }
void Map_NodeVecPush(Map_NodeVec_t *p, Map_Node_t *Entry)
Definition: mapperVec.c:190
Map_Node_t ** pArray
Definition: mapperInt.h:301
Map_Node_t** Map_NodeVecReadArray ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file mapperVec.c.

107 {
108  return p->pArray;
109 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
Map_Node_t* Map_NodeVecReadEntry ( Map_NodeVec_t p,
int  i 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 290 of file mapperVec.c.

291 {
292  assert( i >= 0 && i < p->nSize );
293  return p->pArray[i];
294 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define assert(ex)
Definition: util_old.h:213
int Map_NodeVecReadSize ( Map_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 122 of file mapperVec.c.

123 {
124  return p->nSize;
125 }
void Map_NodeVecRemove ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file mapperVec.c.

251 {
252  int i;
253  for ( i = 0; i < p->nSize; i++ )
254  if ( p->pArray[i] == Entry )
255  break;
256  assert( i < p->nSize );
257  for ( i++; i < p->nSize; i++ )
258  p->pArray[i-1] = p->pArray[i];
259  p->nSize--;
260 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define assert(ex)
Definition: util_old.h:213
void Map_NodeVecShrink ( Map_NodeVec_t p,
int  nSizeNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 157 of file mapperVec.c.

158 {
159  assert( p->nSize >= nSizeNew );
160  p->nSize = nSizeNew;
161 }
#define assert(ex)
Definition: util_old.h:213
void Map_NodeVecSortByLevel ( Map_NodeVec_t p)

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

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file mapperVec.c.

308 {
309  qsort( (void *)p->pArray, p->nSize, sizeof(Map_Node_t *),
310  (int (*)(const void *, const void *)) Map_NodeVecCompareLevels );
311 }
static ABC_NAMESPACE_IMPL_START int Map_NodeVecCompareLevels(Map_Node_t **pp1, Map_Node_t **pp2)
DECLARATIONS ///.
Definition: mapperVec.c:324
Map_Node_t ** pArray
Definition: mapperInt.h:301
void Map_NodeVecWriteEntry ( Map_NodeVec_t p,
int  i,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file mapperVec.c.

274 {
275  assert( i >= 0 && i < p->nSize );
276  p->pArray[i] = Entry;
277 }
Map_Node_t ** pArray
Definition: mapperInt.h:301
#define assert(ex)
Definition: util_old.h:213
Map_SuperLib_t* Map_SuperLibCreate ( Mio_Library_t pGenlib,
Vec_Str_t vStr,
char *  pFileName,
char *  pExcludeFile,
int  fAlgorithm,
int  fVerbose 
)

DECLARATIONS ///.

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

Synopsis [Reads in the supergate library and prepares it for use.]

Description [The supergates library comes in a .super file. This file contains descriptions of supergates along with some relevant information. This procedure reads the supergate file, canonicizes the supergates, and constructs an additional lookup table, which can be used to map truth tables of the cuts into the pair (phase, supergate). The phase indicates how the current truth table should be phase assigned to match the canonical form of the supergate. The resulting phase is the bitwise EXOR of the phase needed to canonicize the supergate and the phase needed to transform the truth table into its canonical form.]

SideEffects []

SeeAlso []

Definition at line 58 of file mapperLib.c.

59 {
60  Map_SuperLib_t * p;
61  abctime clk;
62 
63  // start the supergate library
64  p = ABC_ALLOC( Map_SuperLib_t, 1 );
65  memset( p, 0, sizeof(Map_SuperLib_t) );
66  p->pName = Abc_UtilStrsav(pFileName);
67  p->fVerbose = fVerbose;
68  p->mmSupers = Extra_MmFixedStart( sizeof(Map_Super_t) );
72 
73  // start the hash table
74  p->tTableC = Map_SuperTableCreate( p );
75  p->tTable = Map_SuperTableCreate( p );
76 
77  // read the supergate library from file
78 clk = Abc_Clock();
79  if ( vStr != NULL )
80  {
81  // read the supergate library from file
82  int Status = Map_LibraryReadFileTreeStr( p, pGenlib, vStr, pFileName );
83  if ( Status == 0 )
84  {
85  Map_SuperLibFree( p );
86  return NULL;
87  }
88  // prepare the info about the library
89  Status = Map_LibraryDeriveGateInfo( p, NULL );
90  if ( Status == 0 )
91  {
92  Map_SuperLibFree( p );
93  return NULL;
94  }
95  assert( p->nVarsMax > 0 );
96  }
97  else if ( fAlgorithm )
98  {
99  if ( !Map_LibraryReadTree( p, pGenlib, pFileName, pExcludeFile ) )
100  {
101  Map_SuperLibFree( p );
102  return NULL;
103  }
104  }
105  else
106  {
107  if ( pExcludeFile != 0 )
108  {
109  Map_SuperLibFree( p );
110  printf ("Error: Exclude file support not present for old format. Stop.\n");
111  return NULL;
112  }
113  if ( !Map_LibraryRead( p, pFileName ) )
114  {
115  Map_SuperLibFree( p );
116  return NULL;
117  }
118  }
119  assert( p->nVarsMax > 0 );
120 
121  // report the stats
122  if ( fVerbose )
123  {
124  printf( "Loaded %d unique %d-input supergates from \"%s\". ",
125  p->nSupersReal, p->nVarsMax, pFileName );
126  ABC_PRT( "Time", Abc_Clock() - clk );
127  }
128 
129  // assign the interver parameters
136 
137  // assign the interver supergate
139  memset( p->pSuperInv, 0, sizeof(Map_Super_t) );
140  p->pSuperInv->Num = -1;
141  p->pSuperInv->nGates = 1;
142  p->pSuperInv->nFanins = 1;
143  p->pSuperInv->nFanLimit = 10;
144  p->pSuperInv->pFanins[0] = p->ppSupers[0];
145  p->pSuperInv->pRoot = p->pGateInv;
146  p->pSuperInv->Area = p->AreaInv;
147  p->pSuperInv->tDelayMax = p->tDelayInv;
149  p->pSuperInv->tDelaysR[0].Fall = p->tDelayInv.Rise;
150  p->pSuperInv->tDelaysF[0].Rise = p->tDelayInv.Fall;
152  return p;
153 }
char * memset()
#define MAP_NO_VAR
Definition: mapperInt.h:53
float Mio_LibraryReadAreaBuf(Mio_Library_t *pLib)
Definition: mioApi.c:61
int Map_LibraryDeriveGateInfo(Map_SuperLib_t *pLib, st__table *tExcludeGate)
Definition: mapperTree.c:586
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned nFanins
Definition: mapperInt.h:280
Map_Super_t * pSuperInv
Definition: mapperInt.h:192
Extra_MmFlex_t * Extra_MmFlexStart()
Map_Time_t tDelaysF[6]
Definition: mapperInt.h:291
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
float Mio_LibraryReadAreaInv(Mio_Library_t *pLib)
Definition: mioApi.c:60
float Mio_LibraryReadDelayInvFall(Mio_Library_t *pLib)
Definition: mioApi.c:54
static abctime Abc_Clock()
Definition: abc_global.h:279
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
Map_Time_t tDelayMax
Definition: mapperInt.h:292
int Map_LibraryReadTree(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, char *pFileName, char *pExcludeFile)
Definition: mapperTree.c:525
unsigned uTruths[6][2]
Definition: mapperInt.h:184
Mio_Gate_t * pRoot
Definition: mapperInt.h:288
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
Map_HashTable_t * Map_SuperTableCreate(Map_SuperLib_t *pLib)
FUNCTION DEFINITIONS ///.
Definition: mapperTable.c:48
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
unsigned nFanLimit
Definition: mapperInt.h:282
int Map_LibraryRead(Map_SuperLib_t *p, char *pFileName)
FUNCTION DEFINITIONS ///.
Definition: mapperSuper.c:50
Extra_MmFixed_t * mmSupers
Definition: mapperInt.h:195
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
Map_Super_t * pFanins[6]
Definition: mapperInt.h:287
Map_HashTable_t * tTable
Definition: mapperInt.h:181
Mio_Gate_t * pGateInv
Definition: mapperInt.h:188
float Mio_LibraryReadDelayInvRise(Mio_Library_t *pLib)
Definition: mioApi.c:53
Extra_MmFixed_t * mmEntries
Definition: mapperInt.h:196
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define assert(ex)
Definition: util_old.h:213
Map_Time_t tDelaysR[6]
Definition: mapperInt.h:290
int Map_LibraryReadFileTreeStr(Map_SuperLib_t *pLib, Mio_Library_t *pGenlib, Vec_Str_t *vStr, char *pFileName)
Definition: mapperTree.c:391
Map_HashTable_t * tTableC
Definition: mapperInt.h:180
ABC_INT64_T abctime
Definition: abc_global.h:278
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition: mioApi.c:48
Extra_MmFlex_t * mmForms
Definition: mapperInt.h:197
void Map_MappingSetupTruthTables(unsigned uTruths[][2])
Definition: mapperUtils.c:335
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
Map_Time_t tDelayInv
Definition: mapperInt.h:189
void Map_SuperLibFree ( Map_SuperLib_t p)

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

Synopsis [Deallocates the supergate library.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file mapperLib.c.

168 {
169  if ( p == NULL ) return;
170  if ( p->pGenlib )
171  {
172  if ( p->pGenlib != Abc_FrameReadLibGen() )
174  p->pGenlib = NULL;
175  }
176  if ( p->tTableC )
178  if ( p->tTable )
183  ABC_FREE( p->ppSupers );
184  ABC_FREE( p->pName );
185  ABC_FREE( p );
186 }
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioUtils.c:48
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Map_Super_t ** ppSupers
Definition: mapperInt.h:179
Mio_Library_t * pGenlib
Definition: mapperInt.h:169
Extra_MmFixed_t * mmSupers
Definition: mapperInt.h:195
Map_HashTable_t * tTable
Definition: mapperInt.h:181
Extra_MmFixed_t * mmEntries
Definition: mapperInt.h:196
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Map_SuperTableFree(Map_HashTable_t *p)
Definition: mapperTable.c:74
Map_HashTable_t * tTableC
Definition: mapperInt.h:180
Extra_MmFlex_t * mmForms
Definition: mapperInt.h:197
void Extra_MmFlexStop(Extra_MmFlex_t *p)
Map_HashTable_t* Map_SuperTableCreate ( Map_SuperLib_t pLib)

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates the hash table for supergates.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file mapperTable.c.

49 {
51  // allocate the table
52  p = ABC_ALLOC( Map_HashTable_t, 1 );
53  memset( p, 0, sizeof(Map_HashTable_t) );
54  p->mmMan = pLib->mmEntries;
55  // allocate and clean the bins
56  p->nBins = Abc_PrimeCudd(20000);
57  p->pBins = ABC_ALLOC( Map_HashEntry_t *, p->nBins );
58  memset( p->pBins, 0, sizeof(Map_HashEntry_t *) * p->nBins );
59  return p;
60 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
Extra_MmFixed_t * mmEntries
Definition: mapperInt.h:196
Extra_MmFixed_t * mmMan
Definition: mapperInt.h:312
void Map_SuperTableFree ( Map_HashTable_t p)

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

Synopsis [Deallocates the supergate hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file mapperTable.c.

75 {
76  ABC_FREE( p->pBins );
77  ABC_FREE( p );
78 }
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Map_SuperTableInsert ( Map_HashTable_t p,
unsigned  uTruth[],
Map_Super_t pGate,
unsigned  uPhase 
)

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

Synopsis [Inserts a new entry into the library.]

Description [This function inserts the new gate (pGate), which will be accessible through its unfolded function (uTruth).]

SideEffects []

SeeAlso []

Definition at line 137 of file mapperTable.c.

138 {
139  Map_HashEntry_t * pEnt;
140  unsigned Key;
141  // resize the table
142  if ( p->nEntries >= 2 * p->nBins )
144  // check if this entry already exists
145  Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->nBins );
146  for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext )
147  if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] )
148  return 1;
149  // add the new hash table entry to the table
151  memset( pEnt, 0, sizeof(Map_HashEntry_t) );
152  pEnt->uTruth[0] = uTruth[0];
153  pEnt->uTruth[1] = uTruth[1];
154  pEnt->pGates = pGate;
155  pEnt->uPhase = uPhase;
156  // add the hash table to the corresponding linked list in the table
157  pEnt->pNext = p->pBins[Key];
158  p->pBins[Key] = pEnt;
159  p->nEntries++;
160 /*
161 printf( "Adding gate: %10u ", Key );
162 Map_LibraryPrintSupergate( pGate );
163 Extra_PrintBinary( stdout, uTruth, 32 );
164 printf( "\n" );
165 */
166  return 0;
167 }
Map_HashEntry_t * pNext
Definition: mapperInt.h:321
char * memset()
#define MAP_TABLE_HASH(u1, u2, nSize)
DECLARATIONS ///.
Definition: mapperTable.c:29
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
static void Map_SuperTableResize(Map_HashTable_t *pLib)
Definition: mapperTable.c:233
unsigned uTruth[2]
Definition: mapperInt.h:318
Map_Super_t * pGates
Definition: mapperInt.h:320
Extra_MmFixed_t * mmMan
Definition: mapperInt.h:312
int Map_SuperTableInsertC ( Map_HashTable_t p,
unsigned  uTruthC[],
Map_Super_t pGate 
)

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

Synopsis [Inserts a new entry into the hash table.]

Description [This function inserts the new gate (pGate), which will be accessible through its canonical form (uTruthC).]

SideEffects []

SeeAlso []

Definition at line 92 of file mapperTable.c.

93 {
94  Map_HashEntry_t * pEnt;
95  unsigned Key;
96  // resize the table
97  if ( p->nEntries >= 2 * p->nBins )
99  // check if another supergate with the same canonical form exists
100  Key = MAP_TABLE_HASH( uTruthC[0], uTruthC[1], p->nBins );
101  for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext )
102  if ( pEnt->uTruth[0] == uTruthC[0] && pEnt->uTruth[1] == uTruthC[1] )
103  break;
104  // create a new entry if it does not exist
105  if ( pEnt == NULL )
106  {
107  // add the new entry to the table
109  memset( pEnt, 0, sizeof(Map_HashEntry_t) );
110  pEnt->uTruth[0] = uTruthC[0];
111  pEnt->uTruth[1] = uTruthC[1];
112  // add the hash table entry to the corresponding linked list in the table
113  pEnt->pNext = p->pBins[Key];
114  p->pBins[Key] = pEnt;
115  p->nEntries++;
116  }
117  // add the supergate to the entry
118  pGate->pNext = pEnt->pGates;
119  pEnt->pGates = pGate;
120  return 0;
121 }
Map_HashEntry_t * pNext
Definition: mapperInt.h:321
char * memset()
#define MAP_TABLE_HASH(u1, u2, nSize)
DECLARATIONS ///.
Definition: mapperTable.c:29
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
static void Map_SuperTableResize(Map_HashTable_t *pLib)
Definition: mapperTable.c:233
unsigned uTruth[2]
Definition: mapperInt.h:318
Map_Super_t * pGates
Definition: mapperInt.h:320
Extra_MmFixed_t * mmMan
Definition: mapperInt.h:312
Map_Super_t * pNext
Definition: mapperInt.h:295
Map_Super_t* Map_SuperTableLookup ( Map_HashTable_t p,
unsigned  uTruth[],
unsigned *  puPhase 
)

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

Synopsis [Looks up an entry in the library.]

Description [This function looks up the function, given by its truth table, and return two things: (1) the linked list of supergates, which can implement the functions of this N-class; (2) the phase, which should be applied to the given function, in order to derive the canonical form of this N-class.]

SideEffects []

SeeAlso []

Definition at line 208 of file mapperTable.c.

209 {
210  Map_HashEntry_t * pEnt;
211  unsigned Key;
212  Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->nBins );
213  for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext )
214  if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] )
215  {
216  *puPhase = pEnt->uPhase;
217  return pEnt->pGates;
218  }
219  return NULL;
220 }
Map_HashEntry_t * pNext
Definition: mapperInt.h:321
#define MAP_TABLE_HASH(u1, u2, nSize)
DECLARATIONS ///.
Definition: mapperTable.c:29
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
unsigned uTruth[2]
Definition: mapperInt.h:318
Map_Super_t * pGates
Definition: mapperInt.h:320
void Map_SuperTableSortSupergates ( Map_HashTable_t p,
int  nSupersMax 
)

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

Synopsis [Sorts supergates by usefulness and prints out most useful.]

Description []

SideEffects []

SeeAlso []

Definition at line 315 of file mapperTable.c.

316 {
317  Map_HashEntry_t * pEnt;
318  Map_Super_t ** ppSupers;
319  Map_Super_t * pSuper;
320  int nSupers, i;
321 
322  // copy all the supergates into one array
323  ppSupers = ABC_ALLOC( Map_Super_t *, nSupersMax );
324  nSupers = 0;
325  for ( i = 0; i < p->nBins; i++ )
326  for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext )
327  for ( pSuper = pEnt->pGates; pSuper; pSuper = pSuper->pNext )
328  ppSupers[nSupers++] = pSuper;
329 
330  // sort by usage
331  qsort( (void *)ppSupers, nSupers, sizeof(Map_Super_t *),
332  (int (*)(const void *, const void *)) Map_SuperTableCompareSupergates );
333  assert( Map_SuperTableCompareSupergates( ppSupers, ppSupers + nSupers - 1 ) <= 0 );
334 
335  // print out the "top ten"
336 // for ( i = 0; i < nSupers; i++ )
337  for ( i = 0; i < 10; i++ )
338  {
339  if ( ppSupers[i]->nUsed == 0 )
340  break;
341  printf( "%5d : ", ppSupers[i]->nUsed );
342  printf( "%5d ", ppSupers[i]->Num );
343  printf( "A = %5.2f ", ppSupers[i]->Area );
344  printf( "D = %5.2f ", ppSupers[i]->tDelayMax.Rise );
345  printf( "%s", ppSupers[i]->pFormula );
346  printf( "\n" );
347  }
348  ABC_FREE( ppSupers );
349 }
Map_HashEntry_t * pNext
Definition: mapperInt.h:321
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
#define ABC_FREE(obj)
Definition: abc_global.h:232
Map_Super_t * pGates
Definition: mapperInt.h:320
#define assert(ex)
Definition: util_old.h:213
int Map_SuperTableCompareSupergates(Map_Super_t **ppS1, Map_Super_t **ppS2)
Definition: mapperTable.c:273
Map_Super_t * pNext
Definition: mapperInt.h:295
void Map_SuperTableSortSupergatesByDelay ( Map_HashTable_t p,
int  nSupersMax 
)

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

Synopsis [Sorts supergates by max delay for each truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 362 of file mapperTable.c.

363 {
364  Map_HashEntry_t * pEnt;
365  Map_Super_t ** ppSupers;
366  Map_Super_t * pSuper;
367  int nSupers, i, k;
368 
369  ppSupers = ABC_ALLOC( Map_Super_t *, nSupersMax );
370  for ( i = 0; i < p->nBins; i++ )
371  for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext )
372  {
373  // collect the gates in this entry
374  nSupers = 0;
375  for ( pSuper = pEnt->pGates; pSuper; pSuper = pSuper->pNext )
376  {
377  // skip supergates, whose root is the AND gate
378 // if ( strcmp( Mio_GateReadName(pSuper->pRoot), "and" ) == 0 )
379 // continue;
380  ppSupers[nSupers++] = pSuper;
381  }
382  pEnt->pGates = NULL;
383  if ( nSupers == 0 )
384  continue;
385  // sort the gates by delay
386  qsort( (void *)ppSupers, nSupers, sizeof(Map_Super_t *),
387  (int (*)(const void *, const void *)) Map_SuperTableCompareGatesInList );
388  assert( Map_SuperTableCompareGatesInList( ppSupers, ppSupers + nSupers - 1 ) <= 0 );
389  // link them in the reverse order
390  for ( k = 0; k < nSupers; k++ )
391  {
392  ppSupers[k]->pNext = pEnt->pGates;
393  pEnt->pGates = ppSupers[k];
394  }
395  // save the number of supergates in the list
396  pEnt->pGates->nSupers = nSupers;
397  }
398  ABC_FREE( ppSupers );
399 }
Map_HashEntry_t * pNext
Definition: mapperInt.h:321
unsigned nSupers
Definition: mapperInt.h:283
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Map_HashEntry_t ** pBins
Definition: mapperInt.h:309
int Map_SuperTableCompareGatesInList(Map_Super_t **ppS1, Map_Super_t **ppS2)
Definition: mapperTable.c:293
#define ABC_FREE(obj)
Definition: abc_global.h:232
Map_Super_t * pGates
Definition: mapperInt.h:320
#define assert(ex)
Definition: util_old.h:213
Map_Super_t * pNext
Definition: mapperInt.h:295
float Map_SwitchCutDeref ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)

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

synopsis [References the cut.]

description []

sideeffects []

seealso []

Definition at line 82 of file mapperSwitch.c.

83 {
84  return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference
85 }
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
float Map_SwitchCutGetDerefed ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)

FUNCTION DEFINITIONS ///.

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

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

description []

sideeffects []

seealso []

Definition at line 45 of file mapperSwitch.c.

46 {
47  float aResult, aResult2;
48 // assert( pNode->Switching > 0 );
49  aResult2 = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference
50  aResult = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference
51 // assert( aResult == aResult2 );
52  return aResult;
53 }
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
float Map_SwitchCutRef ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)

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

synopsis [References the cut.]

description []

sideeffects []

seealso []

Definition at line 66 of file mapperSwitch.c.

67 {
68  return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference
69 }
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
float Map_TimeComputeArrivalMax ( Map_Man_t p)

DECLARATIONS ///.

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

FileName [mapperTime.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:
mapperTime.c,v 1.3 2005/03/02 02:35:54 alanmi Exp

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

Synopsis [Computes the maximum arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file mapperTime.c.

43 {
44  float tReqMax, tReq;
45  int i, fPhase;
46  // get the critical PO arrival time
47  tReqMax = -MAP_FLOAT_LARGE;
48  for ( i = 0; i < p->nOutputs; i++ )
49  {
50  if ( Map_NodeIsConst(p->pOutputs[i]) )
51  continue;
52  fPhase = !Map_IsComplement(p->pOutputs[i]);
53  tReq = Map_Regular(p->pOutputs[i])->tArrival[fPhase].Worst;
54  tReqMax = MAP_MAX( tReqMax, tReq );
55  }
56  return tReqMax;
57 }
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Map_NodeIsConst(Map_Node_t *p)
Definition: mapperCreate.c:112
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
#define Map_Regular(p)
Definition: mapper.h:68
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
void Map_TimeComputeRequiredGlobal ( Map_Man_t p)

Definition at line 381 of file mapperTime.c.

382 {
383  Map_Time_t * ptTime, * ptTimeA;
384  int fPhase, i;
385  // update the required times according to the target
386  p->fRequiredGlo = Map_TimeComputeArrivalMax( p );
387  if ( p->DelayTarget != -1 )
388  {
389  if ( p->fRequiredGlo > p->DelayTarget + p->fEpsilon )
390  {
391  if ( p->fMappingMode == 1 )
392  printf( "Cannot meet the target required times (%4.2f). Continue anyway.\n", p->DelayTarget );
393  }
394  else if ( p->fRequiredGlo < p->DelayTarget - p->fEpsilon )
395  {
396  if ( p->fMappingMode == 1 && p->fVerbose )
397  printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->fRequiredGlo, p->DelayTarget );
398  p->fRequiredGlo = p->DelayTarget;
399  }
400  }
401  // clean the required times
402  for ( i = 0; i < p->vMapObjs->nSize; i++ )
403  {
404  p->vMapObjs->pArray[i]->tRequired[0].Rise = MAP_FLOAT_LARGE;
405  p->vMapObjs->pArray[i]->tRequired[0].Fall = MAP_FLOAT_LARGE;
406  p->vMapObjs->pArray[i]->tRequired[0].Worst = MAP_FLOAT_LARGE;
407  p->vMapObjs->pArray[i]->tRequired[1].Rise = MAP_FLOAT_LARGE;
408  p->vMapObjs->pArray[i]->tRequired[1].Fall = MAP_FLOAT_LARGE;
409  p->vMapObjs->pArray[i]->tRequired[1].Worst = MAP_FLOAT_LARGE;
410  }
411  // set the required times for the POs
412  for ( i = 0; i < p->nOutputs; i++ )
413  {
414  fPhase = !Map_IsComplement(p->pOutputs[i]);
415  ptTime = Map_Regular(p->pOutputs[i])->tRequired + fPhase;
416  ptTimeA = Map_Regular(p->pOutputs[i])->tArrival + fPhase;
417 
418  // if external required time can be achieved, use it
419  if ( p->pOutputRequireds && p->pOutputRequireds[i].Worst > 0 && ptTimeA->Worst <= p->pOutputRequireds[i].Worst )//&& p->pOutputRequireds[i].Worst <= p->fRequiredGlo )
420  ptTime->Rise = ptTime->Fall = ptTime->Worst = p->pOutputRequireds[i].Worst;
421  // if external required cannot be achieved, set the earliest possible arrival time
422  else if ( p->pOutputRequireds && p->pOutputRequireds[i].Worst > 0 && ptTimeA->Worst > p->pOutputRequireds[i].Worst )
423  ptTime->Rise = ptTime->Fall = ptTime->Worst = ptTimeA->Worst;
424  // otherwise, set the global required time
425  else
426  ptTime->Rise = ptTime->Fall = ptTime->Worst = p->fRequiredGlo;
427  }
428  // visit nodes in the reverse topological order
430 }
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
#define Map_Regular(p)
Definition: mapper.h:68
void Map_TimePropagateRequired(Map_Man_t *p)
Definition: mapperTime.c:285
ABC_NAMESPACE_IMPL_START 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  tWorstLimit 
)

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

Synopsis [Computes the arrival times of the cut.]

Description [Computes the arrival times of the cut if it is implemented using the given supergate with the given phase. Uses the constraint-type specification of rise/fall arrival times.]

SideEffects []

SeeAlso []

Definition at line 72 of file mapperTime.c.

73 {
74  Map_Match_t * pM = pCut->M + fPhase;
75  Map_Super_t * pSuper = pM->pSuperBest;
76  unsigned uPhaseTot = pM->uPhaseBest;
77  Map_Time_t * ptArrRes = &pM->tArrive;
78  Map_Time_t * ptArrIn;
79  int fPinPhase;
80  float tDelay, tExtra;
81  int i;
82 
83  tExtra = pNode->p->pNodeDelays ? pNode->p->pNodeDelays[pNode->Num] : 0;
84  ptArrRes->Rise = ptArrRes->Fall = 0.0;
85  ptArrRes->Worst = MAP_FLOAT_LARGE;
86  for ( i = pCut->nLeaves - 1; i >= 0; i-- )
87  {
88  // get the phase of the given pin
89  fPinPhase = ((uPhaseTot & (1 << i)) == 0);
90  ptArrIn = pCut->ppLeaves[i]->tArrival + fPinPhase;
91 
92  // get the rise of the output due to rise of the inputs
93  if ( pSuper->tDelaysR[i].Rise > 0 )
94  {
95  tDelay = ptArrIn->Rise + pSuper->tDelaysR[i].Rise + tExtra;
96  if ( tDelay > tWorstLimit )
97  return MAP_FLOAT_LARGE;
98  if ( ptArrRes->Rise < tDelay )
99  ptArrRes->Rise = tDelay;
100  }
101 
102  // get the rise of the output due to fall of the inputs
103  if ( pSuper->tDelaysR[i].Fall > 0 )
104  {
105  tDelay = ptArrIn->Fall + pSuper->tDelaysR[i].Fall + tExtra;
106  if ( tDelay > tWorstLimit )
107  return MAP_FLOAT_LARGE;
108  if ( ptArrRes->Rise < tDelay )
109  ptArrRes->Rise = tDelay;
110  }
111 
112  // get the fall of the output due to rise of the inputs
113  if ( pSuper->tDelaysF[i].Rise > 0 )
114  {
115  tDelay = ptArrIn->Rise + pSuper->tDelaysF[i].Rise + tExtra;
116  if ( tDelay > tWorstLimit )
117  return MAP_FLOAT_LARGE;
118  if ( ptArrRes->Fall < tDelay )
119  ptArrRes->Fall = tDelay;
120  }
121 
122  // get the fall of the output due to fall of the inputs
123  if ( pSuper->tDelaysF[i].Fall > 0 )
124  {
125  tDelay = ptArrIn->Fall + pSuper->tDelaysF[i].Fall + tExtra;
126  if ( tDelay > tWorstLimit )
127  return MAP_FLOAT_LARGE;
128  if ( ptArrRes->Fall < tDelay )
129  ptArrRes->Fall = tDelay;
130  }
131  }
132  // return the worst-case of rise/fall arrival times
133  ptArrRes->Worst = MAP_MAX(ptArrRes->Rise, ptArrRes->Fall);
134  return ptArrRes->Worst;
135 }
Map_Man_t * p
Definition: mapperInt.h:204
#define MAP_FLOAT_LARGE
Definition: mapperInt.h:60
unsigned uPhaseBest
Definition: mapperInt.h:252
Map_Time_t tDelaysF[6]
Definition: mapperInt.h:291
Map_Time_t tArrival[2]
Definition: mapperInt.h:235
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
Map_Time_t tArrive
Definition: mapperInt.h:255
Map_Time_t tDelaysR[6]
Definition: mapperInt.h:290
Map_Match_t M[2]
Definition: mapperInt.h:271
#define MAP_MAX(a, b)
Definition: mapperInt.h:57
Map_Node_t * ppLeaves[6]
Definition: mapperInt.h:265
int Map_TruthCountOnes ( unsigned *  uTruth,
int  nLeaves 
)
int Map_TruthDetectTwoFirst ( unsigned *  uTruth,
int  nLeaves 
)
int Map_TruthsCutDontCare ( Map_Man_t pMan,
Map_Cut_t pCut,
unsigned *  uTruthDc 
)