src/map/mapper/mapper.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Map_TimeStruct_t_

Defines

#define Map_IsComplement(p)   (((int)((unsigned long) (p) & 01)))
#define Map_Regular(p)   ((Map_Node_t *)((unsigned long)(p) & ~01))
#define Map_Not(p)   ((Map_Node_t *)((unsigned long)(p) ^ 01))
#define Map_NotCond(p, c)   ((Map_Node_t *)((unsigned long)(p) ^ (c)))

Typedefs

typedef struct Map_ManStruct_t_ Map_Man_t
typedef struct Map_NodeStruct_t_ Map_Node_t
typedef struct Map_NodeVecStruct_t_ Map_NodeVec_t
typedef struct Map_CutStruct_t_ Map_Cut_t
typedef struct Map_MatchStruct_t_ Map_Match_t
typedef struct Map_SuperStruct_t_ Map_Super_t
typedef struct
Map_SuperLibStruct_t_ 
Map_SuperLib_t
typedef struct
Map_HashTableStruct_t_ 
Map_HashTable_t
typedef struct
Map_HashEntryStruct_t_ 
Map_HashEntry_t
typedef struct Map_TimeStruct_t_ Map_Time_t

Functions

Map_Man_tMap_ManCreate (int nInputs, int nOutputs, int fVerbose)
Map_Node_tMap_NodeCreate (Map_Man_t *p, Map_Node_t *p1, Map_Node_t *p2)
void Map_ManFree (Map_Man_t *pMan)
void Map_ManPrintTimeStats (Map_Man_t *p)
void Map_ManPrintStatsToFile (char *pName, float Area, float Delay, int Time)
int Map_ManReadInputNum (Map_Man_t *p)
int Map_ManReadOutputNum (Map_Man_t *p)
Map_Node_t ** Map_ManReadInputs (Map_Man_t *p)
Map_Node_t ** Map_ManReadOutputs (Map_Man_t *p)
Map_Node_tMap_ManReadConst1 (Map_Man_t *p)
Map_Time_tMap_ManReadInputArrivals (Map_Man_t *p)
Mio_Library_tMap_ManReadGenLib (Map_Man_t *p)
bool Map_ManReadVerbose (Map_Man_t *p)
float Map_ManReadAreaFinal (Map_Man_t *p)
float Map_ManReadRequiredGlo (Map_Man_t *p)
void Map_ManSetTimeToMap (Map_Man_t *p, int Time)
void Map_ManSetTimeToNet (Map_Man_t *p, int Time)
void Map_ManSetTimeSweep (Map_Man_t *p, int Time)
void Map_ManSetTimeTotal (Map_Man_t *p, int Time)
void Map_ManSetOutputNames (Map_Man_t *p, char **ppNames)
void Map_ManSetAreaRecovery (Map_Man_t *p, int fAreaRecovery)
void Map_ManSetDelayTarget (Map_Man_t *p, float DelayTarget)
void Map_ManSetInputArrivals (Map_Man_t *p, Map_Time_t *pArrivals)
void Map_ManSetObeyFanoutLimits (Map_Man_t *p, bool fObeyFanoutLimits)
void Map_ManSetNumIterations (Map_Man_t *p, int nNumIterations)
int Map_ManReadPass (Map_Man_t *p)
void Map_ManSetPass (Map_Man_t *p, int nPass)
int Map_ManReadFanoutViolations (Map_Man_t *p)
void Map_ManSetFanoutViolations (Map_Man_t *p, int nVio)
void Map_ManSetChoiceNodeNum (Map_Man_t *p, int nChoiceNodes)
void Map_ManSetChoiceNum (Map_Man_t *p, int nChoices)
void Map_ManSetVerbose (Map_Man_t *p, int fVerbose)
void Map_ManSetSwitching (Map_Man_t *p, int fSwitching)
Map_Man_tMap_NodeReadMan (Map_Node_t *p)
char * Map_NodeReadData (Map_Node_t *p, int fPhase)
int Map_NodeReadNum (Map_Node_t *p)
int Map_NodeReadLevel (Map_Node_t *p)
Map_Cut_tMap_NodeReadCuts (Map_Node_t *p)
Map_Cut_tMap_NodeReadCutBest (Map_Node_t *p, int fPhase)
Map_Node_tMap_NodeReadOne (Map_Node_t *p)
Map_Node_tMap_NodeReadTwo (Map_Node_t *p)
void Map_NodeSetData (Map_Node_t *p, int fPhase, char *pData)
void Map_NodeSetNextE (Map_Node_t *p, Map_Node_t *pNextE)
void Map_NodeSetRepr (Map_Node_t *p, Map_Node_t *pRepr)
void Map_NodeSetSwitching (Map_Node_t *p, float Switching)
int Map_NodeIsConst (Map_Node_t *p)
int Map_NodeIsVar (Map_Node_t *p)
int Map_NodeIsAnd (Map_Node_t *p)
int Map_NodeComparePhase (Map_Node_t *p1, Map_Node_t *p2)
Map_Super_tMap_CutReadSuperBest (Map_Cut_t *p, int fPhase)
Map_Super_tMap_CutReadSuper0 (Map_Cut_t *p)
Map_Super_tMap_CutReadSuper1 (Map_Cut_t *p)
int Map_CutReadLeavesNum (Map_Cut_t *p)
Map_Node_t ** Map_CutReadLeaves (Map_Cut_t *p)
unsigned Map_CutReadPhaseBest (Map_Cut_t *p, int fPhase)
unsigned Map_CutReadPhase0 (Map_Cut_t *p)
unsigned Map_CutReadPhase1 (Map_Cut_t *p)
Map_Cut_tMap_CutReadNext (Map_Cut_t *p)
char * Map_SuperReadFormula (Map_Super_t *p)
Mio_Gate_tMap_SuperReadRoot (Map_Super_t *p)
int Map_SuperReadNum (Map_Super_t *p)
Map_Super_t ** Map_SuperReadFanins (Map_Super_t *p)
int Map_SuperReadFaninNum (Map_Super_t *p)
Map_Super_tMap_SuperReadNext (Map_Super_t *p)
int Map_SuperReadNumPhases (Map_Super_t *p)
unsigned char * Map_SuperReadPhases (Map_Super_t *p)
int Map_SuperReadFanoutLimit (Map_Super_t *p)
Mio_Library_tMap_SuperLibReadGenLib (Map_SuperLib_t *p)
float Map_SuperLibReadAreaInv (Map_SuperLib_t *p)
Map_Time_t Map_SuperLibReadDelayInv (Map_SuperLib_t *p)
int Map_SuperLibReadVarsMax (Map_SuperLib_t *p)
Map_Node_tMap_NodeAnd (Map_Man_t *p, Map_Node_t *p1, Map_Node_t *p2)
Map_Node_tMap_NodeOr (Map_Man_t *p, Map_Node_t *p1, Map_Node_t *p2)
Map_Node_tMap_NodeExor (Map_Man_t *p, Map_Node_t *p1, Map_Node_t *p2)
Map_Node_tMap_NodeMux (Map_Man_t *p, Map_Node_t *pNode, Map_Node_t *pNodeT, Map_Node_t *pNodeE)
void Map_NodeSetChoice (Map_Man_t *pMan, Map_Node_t *pNodeOld, Map_Node_t *pNodeNew)
int Map_CanonComputeSlow (unsigned uTruths[][2], int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char *puPhases, unsigned uTruthRes[])
int Map_CanonComputeFast (Map_Man_t *p, int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char *puPhases, unsigned uTruthRes[])
Map_Cut_tMap_CutAlloc (Map_Man_t *p)
void Map_CutCreateFromNode (Map_Man_t *p, Map_Super_t *pSuper, int iRoot, unsigned uPhaseRoot, int *pLeaves, int nLeaves, unsigned uPhaseLeaves)
int Map_Mapping (Map_Man_t *p)
int Map_SuperLibDeriveFromGenlib (Mio_Library_t *pLib)
char * Map_LibraryReadFormulaStep (char *pFormula, char *pStrings[], int *pnStrings)
void Map_NetworkSweep (Abc_Ntk_t *pNet)
Map_Super_tMap_SuperTableLookupC (Map_SuperLib_t *pLib, unsigned uTruth[])
int Map_ManCheckConsistency (Map_Man_t *p)
st_tableMap_CreateTableGate2Super (Map_Man_t *p)
void Map_ManCleanData (Map_Man_t *p)
void Map_MappingSetupTruthTables (unsigned uTruths[][2])
void Map_MappingSetupTruthTablesLarge (unsigned uTruths[][32])

Define Documentation

#define Map_IsComplement (  )     (((int)((unsigned long) (p) & 01)))

GLOBAL VARIABLES /// MACRO DEFINITIONS ///

Definition at line 66 of file mapper.h.

#define Map_Not (  )     ((Map_Node_t *)((unsigned long)(p) ^ 01))

Definition at line 68 of file mapper.h.

#define Map_NotCond ( p,
 )     ((Map_Node_t *)((unsigned long)(p) ^ (c)))

Definition at line 69 of file mapper.h.

#define Map_Regular (  )     ((Map_Node_t *)((unsigned long)(p) & ~01))

Definition at line 67 of file mapper.h.


Typedef Documentation

typedef struct Map_CutStruct_t_ Map_Cut_t

Definition at line 42 of file mapper.h.

Definition at line 47 of file mapper.h.

Definition at line 46 of file mapper.h.

typedef struct Map_ManStruct_t_ Map_Man_t

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

FileName [mapper.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
mapper.h,v 1.11 2005/02/28 05:34:26 alanmi Exp

] INCLUDES /// PARAMETERS /// STRUCTURE DEFINITIONS ///

Definition at line 39 of file mapper.h.

Definition at line 43 of file mapper.h.

typedef struct Map_NodeStruct_t_ Map_Node_t

Definition at line 40 of file mapper.h.

Definition at line 41 of file mapper.h.

Definition at line 44 of file mapper.h.

Definition at line 45 of file mapper.h.

typedef struct Map_TimeStruct_t_ Map_Time_t

Definition at line 48 of file mapper.h.


Function Documentation

int Map_CanonComputeFast ( Map_Man_t p,
int  nVarsMax,
int  nVarsReal,
unsigned  uTruth[],
unsigned char *  puPhases,
unsigned  uTruthRes[] 
)

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

Synopsis [Computes the N-canonical form of the Boolean function.]

Description [The N-canonical form is defined as the truth table with the minimum integer value. This function exhaustively enumerates through the complete set of 2^N phase assignments.]

SideEffects []

SeeAlso []

Definition at line 170 of file mapperCanon.c.

00171 {
00172     unsigned uTruth0, uTruth1;
00173     unsigned uCanon0, uCanon1, uCanonBest, uPhaseBest;
00174     int i, Limit;
00175 
00176     if ( nVarsMax == 6 )
00177         return Map_CanonComputeSlow( p->uTruths, nVarsMax, nVarsReal, uTruth, puPhases, uTruthRes );
00178 
00179     if ( nVarsReal < 5 )
00180     {
00181 //        return Map_CanonComputeSlow( p->uTruths, nVarsMax, nVarsReal, uTruth, puPhases, uTruthRes );
00182 
00183         uTruth0 = uTruth[0] & 0xFFFF;
00184         assert( p->pCounters[uTruth0] > 0 );
00185         uTruthRes[0] = (p->uCanons[uTruth0] << 16) | p->uCanons[uTruth0];
00186         uTruthRes[1] = uTruthRes[0];
00187         puPhases[0] = p->uPhases[uTruth0][0];
00188         return 1;
00189     }
00190 
00191     assert( nVarsMax == 5 );
00192     assert( nVarsReal == 5 );
00193     uTruth0 = uTruth[0] & 0xFFFF;
00194     uTruth1 = (uTruth[0] >> 16);
00195     if ( uTruth1 == 0 )
00196     {
00197         uTruthRes[0] = p->uCanons[uTruth0];
00198         uTruthRes[1] = uTruthRes[0];
00199         Limit = (p->pCounters[uTruth0] > 4)? 4 : p->pCounters[uTruth0];
00200         for ( i = 0; i < Limit; i++ )
00201             puPhases[i] = p->uPhases[uTruth0][i];
00202         return Limit;
00203     }
00204     else if ( uTruth0 == 0 )
00205     {
00206         uTruthRes[0] = p->uCanons[uTruth1];
00207         uTruthRes[1] = uTruthRes[0];
00208         Limit = (p->pCounters[uTruth1] > 4)? 4 : p->pCounters[uTruth1];
00209         for ( i = 0; i < Limit; i++ )
00210         {
00211             puPhases[i] = p->uPhases[uTruth1][i];
00212             puPhases[i] |= (1 << 4);
00213         }
00214         return Limit;
00215     }
00216     uCanon0 = p->uCanons[uTruth0];
00217     uCanon1 = p->uCanons[uTruth1];
00218     if ( uCanon0 >= uCanon1 ) // using nCanon1 as the main one
00219     {
00220         assert( p->pCounters[uTruth1] > 0 );
00221         uCanonBest = 0xFFFFFFFF;
00222         for ( i = 0; i < p->pCounters[uTruth1]; i++ )
00223         {
00224             uCanon0 = Extra_TruthPolarize( uTruth0, p->uPhases[uTruth1][i], 4 );
00225             if ( uCanonBest > uCanon0 )
00226             {
00227                 uCanonBest = uCanon0;
00228                 uPhaseBest = p->uPhases[uTruth1][i];
00229                 assert( uPhaseBest < 16 );
00230             }
00231         }
00232         uTruthRes[0] = (uCanon1 << 16) | uCanonBest;
00233         uTruthRes[1] = uTruthRes[0];
00234         puPhases[0] = uPhaseBest;
00235         return 1;
00236     }
00237     else if ( uCanon0 < uCanon1 )
00238     {
00239         assert( p->pCounters[uTruth0] > 0 );
00240         uCanonBest = 0xFFFFFFFF;
00241         for ( i = 0; i < p->pCounters[uTruth0]; i++ )
00242         {
00243             uCanon1 = Extra_TruthPolarize( uTruth1, p->uPhases[uTruth0][i], 4 );
00244             if ( uCanonBest > uCanon1 )
00245             {
00246                 uCanonBest = uCanon1;
00247                 uPhaseBest = p->uPhases[uTruth0][i];
00248                 assert( uPhaseBest < 16 );
00249             }
00250         }
00251         uTruthRes[0] = (uCanon0 << 16) | uCanonBest;
00252         uTruthRes[1] = uTruthRes[0];
00253         puPhases[0] = uPhaseBest | (1 << 4);
00254         return 1;
00255     }
00256     else
00257     {
00258         assert( 0 );
00259         return Map_CanonComputeSlow( p->uTruths, nVarsMax, nVarsReal, uTruth, puPhases, uTruthRes );
00260     }
00261 }

int Map_CanonComputeSlow ( unsigned  uTruths[][2],
int  nVarsMax,
int  nVarsReal,
unsigned  uTruth[],
unsigned char *  puPhases,
unsigned  uTruthRes[] 
)

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

Synopsis [Computes the N-canonical form of the Boolean function.]

Description [The N-canonical form is defined as the truth table with the minimum integer value. This function exhaustively enumerates through the complete set of 2^N phase assignments.]

SideEffects []

SeeAlso []

Definition at line 45 of file mapperCanon.c.

00046 {
00047     unsigned  uTruthPerm[2];
00048     int nMints, nPhases, m;
00049 
00050     nPhases = 0;
00051     nMints = (1 << nVarsReal);
00052     if ( nVarsMax < 6 )
00053     {
00054         uTruthRes[0] = MAP_MASK(32);
00055         for ( m = 0; m < nMints; m++ )
00056         {
00057             uTruthPerm[0] = Map_CanonComputePhase( uTruths, nVarsMax, uTruth[0], m );
00058             if ( uTruthRes[0] > uTruthPerm[0] )
00059             {
00060                 uTruthRes[0] = uTruthPerm[0];
00061                 nPhases      = 0;
00062                 puPhases[nPhases++] = (unsigned char)m;
00063             }
00064             else if ( uTruthRes[0] == uTruthPerm[0] )
00065             {
00066                 if ( nPhases < 4 ) // the max number of phases in Map_Super_t
00067                     puPhases[nPhases++] = (unsigned char)m;
00068             }
00069         }
00070         uTruthRes[1] = uTruthRes[0];
00071     }
00072     else
00073     {
00074         uTruthRes[0] = MAP_MASK(32);
00075         uTruthRes[1] = MAP_MASK(32);
00076         for ( m = 0; m < nMints; m++ )
00077         {
00078             Map_CanonComputePhase6( uTruths, nVarsMax, uTruth, m, uTruthPerm );
00079             if ( uTruthRes[1] > uTruthPerm[1] || uTruthRes[1] == uTruthPerm[1] && uTruthRes[0] > uTruthPerm[0] )
00080             {
00081                 uTruthRes[0] = uTruthPerm[0];
00082                 uTruthRes[1] = uTruthPerm[1];
00083                 nPhases      = 0;
00084                 puPhases[nPhases++] = (unsigned char)m;
00085             }
00086             else if ( uTruthRes[1] == uTruthPerm[1] && uTruthRes[0] == uTruthPerm[0] )
00087             {
00088                 if ( nPhases < 4 ) // the max number of phases in Map_Super_t
00089                     puPhases[nPhases++] = (unsigned char)m;
00090             }
00091         }
00092     }
00093     assert( nPhases > 0 );
00094 //    printf( "%d ", nPhases );
00095     return nPhases;
00096 }

st_table* Map_CreateTableGate2Super ( Map_Man_t pMan  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 788 of file mapperUtils.c.

00789 {
00790     Map_Super_t * pSuper;
00791     st_table * tTable;
00792     int i, nInputs, v;
00793     tTable = st_init_table(strcmp, st_strhash);
00794     for ( i = 0; i < pMan->pSuperLib->nSupersAll; i++ )
00795     {
00796         pSuper = pMan->pSuperLib->ppSupers[i];
00797         if ( pSuper->nGates == 1 )
00798         {
00799             // skip different versions of the same root gate
00800             nInputs = Mio_GateReadInputs(pSuper->pRoot);
00801             for ( v = 0; v < nInputs; v++ )
00802                 if ( pSuper->pFanins[v]->Num != nInputs - 1 - v )
00803                     break;
00804             if ( v != nInputs )
00805                 continue;
00806 //            printf( "%s\n", Mio_GateReadName(pSuper->pRoot) );
00807             if ( st_insert( tTable, (char *)pSuper->pRoot, (char *)pSuper ) )
00808             {
00809                 assert( 0 );
00810             }
00811         }
00812     }
00813     return tTable;
00814 }

Map_Cut_t* Map_CutAlloc ( Map_Man_t p  ) 

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

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

Synopsis [Allocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 40 of file mapperCutUtils.c.

00041 {
00042     Map_Cut_t * pCut;
00043     Map_Match_t * pMatch;
00044     pCut = (Map_Cut_t *)Extra_MmFixedEntryFetch( p->mmCuts );
00045     memset( pCut, 0, sizeof(Map_Cut_t) );
00046 
00047     pMatch = pCut->M;
00048     pMatch->AreaFlow       = MAP_FLOAT_LARGE; // unassigned
00049     pMatch->tArrive.Rise   = MAP_FLOAT_LARGE; // unassigned
00050     pMatch->tArrive.Fall   = MAP_FLOAT_LARGE; // unassigned
00051     pMatch->tArrive.Worst  = MAP_FLOAT_LARGE; // unassigned
00052 
00053     pMatch = pCut->M + 1;
00054     pMatch->AreaFlow       = MAP_FLOAT_LARGE; // unassigned
00055     pMatch->tArrive.Rise   = MAP_FLOAT_LARGE; // unassigned
00056     pMatch->tArrive.Fall   = MAP_FLOAT_LARGE; // unassigned
00057     pMatch->tArrive.Worst  = MAP_FLOAT_LARGE; // unassigned
00058     return pCut;
00059 }

void Map_CutCreateFromNode ( Map_Man_t p,
Map_Super_t pSuper,
int  iRoot,
unsigned  uPhaseRoot,
int *  pLeaves,
int  nLeaves,
unsigned  uPhaseLeaves 
)
Map_Node_t** Map_CutReadLeaves ( Map_Cut_t p  ) 

Definition at line 129 of file mapperCreate.c.

00129 { return p->ppLeaves; }

int Map_CutReadLeavesNum ( Map_Cut_t p  ) 

Definition at line 128 of file mapperCreate.c.

00128 { return p->nLeaves;  }

Map_Cut_t* Map_CutReadNext ( Map_Cut_t p  ) 

Definition at line 133 of file mapperCreate.c.

00133 { return p->pNext;          }

unsigned Map_CutReadPhase0 ( Map_Cut_t p  ) 

Definition at line 131 of file mapperCreate.c.

00131 { return p->M[0].uPhaseBest;}

unsigned Map_CutReadPhase1 ( Map_Cut_t p  ) 

Definition at line 132 of file mapperCreate.c.

00132 { return p->M[1].uPhaseBest;}

unsigned Map_CutReadPhaseBest ( Map_Cut_t p,
int  fPhase 
)

Definition at line 130 of file mapperCreate.c.

00130 { return p->M[fPhase].uPhaseBest;}

Map_Super_t* Map_CutReadSuper0 ( Map_Cut_t p  ) 

Definition at line 126 of file mapperCreate.c.

00126 { return p->M[0].pSuperBest;}

Map_Super_t* Map_CutReadSuper1 ( Map_Cut_t p  ) 

Definition at line 127 of file mapperCreate.c.

00127 { return p->M[1].pSuperBest;}

Map_Super_t* Map_CutReadSuperBest ( Map_Cut_t p,
int  fPhase 
)

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

Synopsis [Reads parameters from the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file mapperCreate.c.

00125 { return p->M[fPhase].pSuperBest;}

char* Map_LibraryReadFormulaStep ( char *  pFormula,
char *  pStrings[],
int *  pnStrings 
)

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

Synopsis [Performs one step of parsing the formula into parts.]

Description [This function will eventually be replaced when the tree-supergate library representation will become standard.]

SideEffects []

SeeAlso []

Definition at line 251 of file mapperSuper.c.

00252 {
00253     char * pName, * pPar1, * pPar2, * pCur;
00254     int nStrings, CountPars;
00255 
00256     // skip leading spaces
00257     for ( pName = pFormula; *pName && *pName == ' '; pName++ );
00258     assert( *pName );
00259     // find the first opening paranthesis
00260     for ( pPar1 = pName; *pPar1 && *pPar1 != '('; pPar1++ );
00261     if ( *pPar1 == 0 )
00262     {
00263         *pnStrings = 0;
00264         return pName;
00265     }
00266     // overwrite it with space
00267     assert( *pPar1 == '(' );
00268     *pPar1 = 0;
00269     // find the corresponding closing paranthesis
00270     for ( CountPars = 1, pPar2 = pPar1 + 1; *pPar2 && CountPars; pPar2++ )
00271         if ( *pPar2 == '(' )
00272             CountPars++;
00273         else if ( *pPar2 == ')' )
00274             CountPars--;
00275     pPar2--;
00276     assert( CountPars == 0 );
00277     // overwrite it with space
00278     assert( *pPar2 == ')' );
00279     *pPar2 = 0;
00280     // save the intervals between the commas
00281     nStrings = 0;
00282     pCur = pPar1 + 1;
00283     while ( 1 )
00284     {
00285         // save the current string
00286         pStrings[ nStrings++ ] = pCur;
00287         // find the beginning of the next string
00288         for ( CountPars = 0; *pCur && (CountPars || *pCur != ','); pCur++ )
00289             if ( *pCur == '(' )
00290                 CountPars++;
00291             else if ( *pCur == ')' )
00292                 CountPars--;
00293         if ( *pCur == 0 )
00294             break;
00295         assert( *pCur == ',' );
00296         *pCur = 0;
00297         pCur++;
00298     }
00299     // save the results and return
00300     *pnStrings = nStrings;
00301     return pName;
00302 }

int Map_ManCheckConsistency ( Map_Man_t p  ) 

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

Synopsis [Verify one useful property.]

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

SideEffects []

SeeAlso []

Definition at line 602 of file mapperUtils.c.

00603 {
00604     Map_Node_t * pNode;
00605     Map_NodeVec_t * pVec;
00606     int i;
00607     pVec = Map_MappingDfs( p, 0 );
00608     for ( i = 0; i < pVec->nSize; i++ )
00609     {
00610         pNode = pVec->pArray[i];
00611         if ( Map_NodeIsVar(pNode) )
00612         {
00613             if ( pNode->pRepr )
00614                 printf( "Primary input %d is a secondary node.\n", pNode->Num );
00615         }
00616         else if ( Map_NodeIsConst(pNode) )
00617         {
00618             if ( pNode->pRepr )
00619                 printf( "Constant 1 %d is a secondary node.\n", pNode->Num );
00620         }
00621         else
00622         {
00623             if ( pNode->pRepr )
00624                 printf( "Internal node %d is a secondary node.\n", pNode->Num );
00625             if ( Map_Regular(pNode->p1)->pRepr )
00626                 printf( "Internal node %d has first fanin that is a secondary node.\n", pNode->Num );
00627             if ( Map_Regular(pNode->p2)->pRepr )
00628                 printf( "Internal node %d has second fanin that is a secondary node.\n", pNode->Num );
00629         }
00630     }
00631     Map_NodeVecFree( pVec );
00632     return 1;
00633 }

void Map_ManCleanData ( Map_Man_t p  ) 

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

Synopsis [Get the FRAIG node with phase.]

Description []

SideEffects []

SeeAlso []

Definition at line 827 of file mapperUtils.c.

00828 {
00829     int i;
00830     for ( i = 0; i < p->vNodesAll->nSize; i++ )
00831         p->vNodesAll->pArray[i]->pData0 = p->vNodesAll->pArray[i]->pData1 = 0;
00832 }

Map_Man_t* Map_ManCreate ( int  nInputs,
int  nOutputs,
int  fVerbose 
)

FUNCTION DEFINITIONS ///

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

Synopsis [Create the mapping manager.]

Description [The number of inputs and outputs is assumed to be known is advance. It is much simpler to have them fixed upfront. When it comes to representing the object graph in the form of AIG, the resulting manager is similar to the regular AIG manager, except that it does not use reference counting (and therefore does not have garbage collections). It does have table resizing. The data structure is more flexible to represent additional information needed for mapping.]

SideEffects []

SeeAlso []

Definition at line 180 of file mapperCreate.c.

00181 {
00182     Map_Man_t * p;
00183     int i;
00184 
00185     // derive the supergate library
00186     if ( Abc_FrameReadLibSuper() == NULL )
00187     {
00188         printf( "The supergate library is not specified. Use \"read_library\" or \"read_super\".\n" );
00189         return NULL;
00190     }
00191 
00192     // start the manager
00193     p = ALLOC( Map_Man_t, 1 );
00194     memset( p, 0, sizeof(Map_Man_t) );
00195     p->pSuperLib = Abc_FrameReadLibSuper();
00196     p->nVarsMax  = p->pSuperLib->nVarsMax;
00197     p->fVerbose  = fVerbose;
00198     p->fEpsilon  = (float)0.001;
00199     assert( p->nVarsMax > 0 );
00200 
00201     if ( p->nVarsMax == 5 )
00202         Extra_Truth4VarN( &p->uCanons, &p->uPhases, &p->pCounters, 8 );
00203 
00204     // start various data structures
00205     Map_TableCreate( p );
00206     Map_MappingSetupTruthTables( p->uTruths );
00207     Map_MappingSetupTruthTablesLarge( p->uTruthsLarge );
00208 //    printf( "Node = %d bytes. Cut = %d bytes. Super = %d bytes.\n", sizeof(Map_Node_t), sizeof(Map_Cut_t), sizeof(Map_Super_t) ); 
00209     p->mmNodes    = Extra_MmFixedStart( sizeof(Map_Node_t) );
00210     p->mmCuts     = Extra_MmFixedStart( sizeof(Map_Cut_t) );
00211 
00212     // make sure the constant node will get index -1
00213     p->nNodes = -1;
00214     // create the constant node
00215     p->pConst1    = Map_NodeCreate( p, NULL, NULL );
00216     p->vNodesAll  = Map_NodeVecAlloc( 100 );
00217     p->vNodesTemp = Map_NodeVecAlloc( 100 );
00218     p->vMapping   = Map_NodeVecAlloc( 100 );
00219     p->vVisited   = Map_NodeVecAlloc( 100 );
00220 
00221     // create the PI nodes
00222     p->nInputs = nInputs;
00223     p->pInputs = ALLOC( Map_Node_t *, nInputs );
00224     for ( i = 0; i < nInputs; i++ )
00225         p->pInputs[i] = Map_NodeCreate( p, NULL, NULL );
00226 
00227     // create the place for the output nodes
00228     p->nOutputs = nOutputs;
00229     p->pOutputs = ALLOC( Map_Node_t *, nOutputs );
00230     memset( p->pOutputs, 0, sizeof(Map_Node_t *) * nOutputs );
00231     return p;
00232 }

void Map_ManFree ( Map_Man_t p  ) 

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

Synopsis [Deallocates the mapping manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file mapperCreate.c.

00246 {
00247 //    int i;
00248 //    for ( i = 0; i < p->vNodesAll->nSize; i++ )
00249 //        Map_NodeVecFree( p->vNodesAll->pArray[i]->vFanouts );
00250 //    Map_NodeVecFree( p->pConst1->vFanouts );
00251     if ( p->vAnds )    
00252         Map_NodeVecFree( p->vAnds );
00253     if ( p->vNodesAll )    
00254         Map_NodeVecFree( p->vNodesAll );
00255     if ( p->vNodesTemp )    
00256         Map_NodeVecFree( p->vNodesTemp );
00257     if ( p->vMapping )    
00258         Map_NodeVecFree( p->vMapping );
00259     if ( p->vVisited )    
00260         Map_NodeVecFree( p->vVisited );
00261     if ( p->uCanons )   free( p->uCanons );
00262     if ( p->uPhases )   free( p->uPhases );
00263     if ( p->pCounters ) free( p->pCounters );
00264     Extra_MmFixedStop( p->mmNodes );
00265     Extra_MmFixedStop( p->mmCuts );
00266     FREE( p->pInputArrivals );
00267     FREE( p->pInputs );
00268     FREE( p->pOutputs );
00269     FREE( p->pBins );
00270     FREE( p->ppOutputNames );
00271     FREE( p );
00272 }

void Map_ManPrintStatsToFile ( char *  pName,
float  Area,
float  Delay,
int  Time 
)

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

Synopsis [Prints the mapping stats.]

Description []

SideEffects []

SeeAlso []

Definition at line 314 of file mapperCreate.c.

00315 {
00316     FILE * pTable;
00317     pTable = fopen( "map_stats.txt", "a+" );
00318     fprintf( pTable, "%s ", pName );
00319     fprintf( pTable, "%4.2f ", Area );
00320     fprintf( pTable, "%4.2f ", Delay );
00321     fprintf( pTable, "%4.2f\n", (float)(Time)/(float)(CLOCKS_PER_SEC) );
00322     fclose( pTable );
00323 }

void Map_ManPrintTimeStats ( Map_Man_t p  ) 

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

Synopsis [Deallocates the mapping manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 286 of file mapperCreate.c.

00287 {
00288     printf( "N-canonical = %d. Matchings = %d.  Phases = %d.  ", p->nCanons, p->nMatches, p->nPhases );
00289     printf( "Choice nodes = %d. Choices = %d.\n", p->nChoiceNodes, p->nChoices );
00290     PRT( "ToMap", p->timeToMap );
00291     PRT( "Cuts ", p->timeCuts  );
00292     PRT( "Truth", p->timeTruth );
00293     PRT( "Match", p->timeMatch );
00294     PRT( "Area ", p->timeArea  );
00295     PRT( "Sweep", p->timeSweep );
00296     PRT( "ToNet", p->timeToNet );
00297     PRT( "TOTAL", p->timeTotal );
00298     if ( p->time1 ) { PRT( "time1", p->time1 ); }
00299     if ( p->time2 ) { PRT( "time2", p->time2 ); }
00300     if ( p->time3 ) { PRT( "time3", p->time3 ); }
00301 }

float Map_ManReadAreaFinal ( Map_Man_t p  ) 

Definition at line 55 of file mapperCreate.c.

00055 { return p->AreaFinal;  }

Map_Node_t* Map_ManReadConst1 ( Map_Man_t p  ) 

Definition at line 51 of file mapperCreate.c.

00051 { return p->pConst1;    }

int Map_ManReadFanoutViolations ( Map_Man_t p  ) 

Definition at line 67 of file mapperCreate.c.

00067 { return p->nFanoutViolations; }  

Mio_Library_t* Map_ManReadGenLib ( Map_Man_t p  ) 

Definition at line 53 of file mapperCreate.c.

00053 { return p->pSuperLib->pGenlib; }

Map_Time_t* Map_ManReadInputArrivals ( Map_Man_t p  ) 

Definition at line 52 of file mapperCreate.c.

00052 { return p->pInputArrivals;}

int Map_ManReadInputNum ( Map_Man_t p  ) 

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

Synopsis [Reads parameters from the mapping manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file mapperCreate.c.

00047 { return p->nInputs;    }

Map_Node_t** Map_ManReadInputs ( Map_Man_t p  ) 

Definition at line 49 of file mapperCreate.c.

00049 { return p->pInputs;    }

int Map_ManReadOutputNum ( Map_Man_t p  ) 

Definition at line 48 of file mapperCreate.c.

00048 { return p->nOutputs;   }

Map_Node_t** Map_ManReadOutputs ( Map_Man_t p  ) 

Definition at line 50 of file mapperCreate.c.

00050 { return p->pOutputs;   }

int Map_ManReadPass ( Map_Man_t p  ) 
float Map_ManReadRequiredGlo ( Map_Man_t p  ) 

Definition at line 56 of file mapperCreate.c.

00056 { return p->fRequiredGlo;  }

bool Map_ManReadVerbose ( Map_Man_t p  ) 

Definition at line 54 of file mapperCreate.c.

00054 { return p->fVerbose;   }

void Map_ManSetAreaRecovery ( Map_Man_t p,
int  fAreaRecovery 
)

Definition at line 62 of file mapperCreate.c.

00062 { p->fAreaRecovery = fAreaRecovery;}

void Map_ManSetChoiceNodeNum ( Map_Man_t p,
int  nChoiceNodes 
)

Definition at line 69 of file mapperCreate.c.

00069 { p->nChoiceNodes = nChoiceNodes; }  

void Map_ManSetChoiceNum ( Map_Man_t p,
int  nChoices 
)

Definition at line 70 of file mapperCreate.c.

00070 { p->nChoices = nChoices; }   

void Map_ManSetDelayTarget ( Map_Man_t p,
float  DelayTarget 
)

Definition at line 63 of file mapperCreate.c.

00063 { p->DelayTarget = DelayTarget;}

void Map_ManSetFanoutViolations ( Map_Man_t p,
int  nVio 
)

Definition at line 68 of file mapperCreate.c.

00068 { p->nFanoutViolations = nVio; }  

void Map_ManSetInputArrivals ( Map_Man_t p,
Map_Time_t pArrivals 
)

Definition at line 64 of file mapperCreate.c.

00064 { p->pInputArrivals = pArrivals;}

void Map_ManSetNumIterations ( Map_Man_t p,
int  nNumIterations 
)

Definition at line 66 of file mapperCreate.c.

00066 { p->nIterations = nIterations;     }

void Map_ManSetObeyFanoutLimits ( Map_Man_t p,
bool  fObeyFanoutLimits 
)

Definition at line 65 of file mapperCreate.c.

00065 { p->fObeyFanoutLimits = fObeyFanoutLimits;     }

void Map_ManSetOutputNames ( Map_Man_t p,
char **  ppNames 
)

Definition at line 61 of file mapperCreate.c.

00061 { p->ppOutputNames = ppNames; }

void Map_ManSetPass ( Map_Man_t p,
int  nPass 
)
void Map_ManSetSwitching ( Map_Man_t p,
int  fSwitching 
)

Definition at line 72 of file mapperCreate.c.

00072 { p->fSwitching = fSwitching; }   

void Map_ManSetTimeSweep ( Map_Man_t p,
int  Time 
)

Definition at line 59 of file mapperCreate.c.

00059 { p->timeSweep = Time;  }

void Map_ManSetTimeToMap ( Map_Man_t p,
int  Time 
)

Definition at line 57 of file mapperCreate.c.

00057 { p->timeToMap = Time;  }

void Map_ManSetTimeToNet ( Map_Man_t p,
int  Time 
)

Definition at line 58 of file mapperCreate.c.

00058 { p->timeToNet = Time;  }

void Map_ManSetTimeTotal ( Map_Man_t p,
int  Time 
)

Definition at line 60 of file mapperCreate.c.

00060 { p->timeTotal = Time;  }

void Map_ManSetVerbose ( Map_Man_t p,
int  fVerbose 
)

Definition at line 71 of file mapperCreate.c.

00071 { p->fVerbose = fVerbose; }   

int Map_Mapping ( Map_Man_t p  ) 

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

FileName [mapperCore.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
mapperCore.c,v 1.7 2004/10/01 23:41:04 satrajit Exp

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

Synopsis [Performs technology mapping for the given object graph.]

Description [The object graph is stored in the mapping manager. First, the AND nodes that fanout into POs are collected in the DFS order. Two preprocessing steps are performed: the k-feasible cuts are computed for each node and the truth tables are computed for each cut. Next, the delay-optimal matches are assigned for each node, followed by several iterations of area recoveryd: using area flow (global optimization) and using exact area at a node (local optimization).]

SideEffects []

SeeAlso []

Definition at line 47 of file mapperCore.c.

00048 {
00049     int fShowSwitching         = 1;
00050     int fUseAreaFlow           = 1;
00051     int fUseExactArea          = !p->fSwitching;
00052     int fUseExactAreaWithPhase = !p->fSwitching;
00053     int clk;
00054 
00056     // perform pre-mapping computations
00057     // collect the nodes reachable from POs in the DFS order (including the choices)
00058     p->vAnds = Map_MappingDfs( p, 1 );
00059     if ( p->fVerbose )
00060         Map_MappingReportChoices( p ); 
00061     Map_MappingSetChoiceLevels( p ); // should always be called before mapping!
00062 //    return 1;
00063 
00064     // compute the cuts of nodes in the DFS order
00065     clk = clock();
00066     Map_MappingCuts( p );
00067     p->timeCuts = clock() - clk;
00068     // derive the truth tables 
00069     clk = clock();
00070     Map_MappingTruths( p );
00071     p->timeTruth = clock() - clk;
00073 //PRT( "Truths", clock() - clk );
00074 
00076     // compute the minimum-delay mapping
00077     clk = clock();
00078     p->fMappingMode = 0;
00079     if ( !Map_MappingMatches( p ) )
00080         return 0;
00081     p->timeMatch = clock() - clk;
00082     // compute the references and collect the nodes used in the mapping
00083     Map_MappingSetRefs( p );
00084     p->AreaBase = Map_MappingGetArea( p, p->vMapping );
00085 if ( p->fVerbose )
00086 {
00087 printf( "Delay    : %s = %8.2f  Flow = %11.1f  Area = %11.1f  %4.1f %%   ", 
00088                     fShowSwitching? "Switch" : "Delay", 
00089                     fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 
00090                     Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 );
00091 PRT( "Time", p->timeMatch );
00092 }
00094 
00095     if ( !p->fAreaRecovery )
00096     {
00097         if ( p->fVerbose )
00098             Map_MappingPrintOutputArrivals( p );
00099         return 1;
00100     }
00101 
00103     // perform area recovery using area flow
00104     clk = clock();
00105     if ( fUseAreaFlow )
00106     {
00107         // compute the required times
00108         Map_TimeComputeRequiredGlobal( p );
00109         // recover area flow
00110         p->fMappingMode = 1;
00111         Map_MappingMatches( p );
00112         // compute the references and collect the nodes used in the mapping
00113         Map_MappingSetRefs( p );
00114         p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
00115 if ( p->fVerbose )
00116 {
00117 printf( "AreaFlow : %s = %8.2f  Flow = %11.1f  Area = %11.1f  %4.1f %%   ", 
00118                     fShowSwitching? "Switch" : "Delay", 
00119                     fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 
00120                     Map_MappingGetAreaFlow(p), p->AreaFinal, 
00121                     100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
00122 PRT( "Time", clock() - clk );
00123 }
00124     }
00125     p->timeArea += clock() - clk;
00127 
00129     // perform area recovery using exact area
00130     clk = clock();
00131     if ( fUseExactArea )
00132     {
00133         // compute the required times
00134         Map_TimeComputeRequiredGlobal( p );
00135         // recover area
00136         p->fMappingMode = 2;
00137         Map_MappingMatches( p );
00138         // compute the references and collect the nodes used in the mapping
00139         Map_MappingSetRefs( p );
00140         p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
00141 if ( p->fVerbose )
00142 {
00143 printf( "Area     : %s = %8.2f  Flow = %11.1f  Area = %11.1f  %4.1f %%   ", 
00144                     fShowSwitching? "Switch" : "Delay", 
00145                     fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 
00146                     0.0, p->AreaFinal, 
00147                     100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
00148 PRT( "Time", clock() - clk );
00149 }
00150     }
00151     p->timeArea += clock() - clk;
00153 
00155     // perform area recovery using exact area
00156     clk = clock();
00157     if ( fUseExactAreaWithPhase )
00158     {
00159         // compute the required times
00160         Map_TimeComputeRequiredGlobal( p );
00161         // recover area
00162         p->fMappingMode = 3;
00163         Map_MappingMatches( p );
00164         // compute the references and collect the nodes used in the mapping
00165         Map_MappingSetRefs( p );
00166         p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
00167 if ( p->fVerbose )
00168 {
00169 printf( "Area     : %s = %8.2f  Flow = %11.1f  Area = %11.1f  %4.1f %%   ", 
00170                     fShowSwitching? "Switch" : "Delay", 
00171                     fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 
00172                     0.0, p->AreaFinal, 
00173                     100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
00174 PRT( "Time", clock() - clk );
00175 }
00176     }
00177     p->timeArea += clock() - clk;
00179 
00181     // perform area recovery using exact area
00182     clk = clock();
00183     if ( p->fSwitching )
00184     {
00185         // compute the required times
00186         Map_TimeComputeRequiredGlobal( p );
00187         // recover switching activity
00188         p->fMappingMode = 4;
00189         Map_MappingMatches( p );
00190         // compute the references and collect the nodes used in the mapping
00191         Map_MappingSetRefs( p );
00192         p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
00193 if ( p->fVerbose )
00194 {
00195 printf( "Switching: %s = %8.2f  Flow = %11.1f  Area = %11.1f  %4.1f %%   ", 
00196                     fShowSwitching? "Switch" : "Delay", 
00197                     fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 
00198                     0.0, p->AreaFinal, 
00199                     100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
00200 PRT( "Time", clock() - clk );
00201 }
00202 
00203         // compute the required times
00204         Map_TimeComputeRequiredGlobal( p );
00205         // recover switching activity
00206         p->fMappingMode = 4;
00207         Map_MappingMatches( p );
00208         // compute the references and collect the nodes used in the mapping
00209         Map_MappingSetRefs( p );
00210         p->AreaFinal = Map_MappingGetArea( p, p->vMapping );
00211 if ( p->fVerbose )
00212 {
00213 printf( "Switching: %s = %8.2f  Flow = %11.1f  Area = %11.1f  %4.1f %%   ", 
00214                     fShowSwitching? "Switch" : "Delay", 
00215                     fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 
00216                     0.0, p->AreaFinal, 
00217                     100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
00218 PRT( "Time", clock() - clk );
00219 }
00220     }
00221     p->timeArea += clock() - clk;
00223 
00224     // print the arrival times of the latest outputs
00225     if ( p->fVerbose )
00226         Map_MappingPrintOutputArrivals( p );
00227     return 1;
00228 }

void Map_MappingSetupTruthTables ( unsigned  uTruths[][2]  ) 

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

Synopsis [Sets up the truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 510 of file mapperUtils.c.

00511 {
00512     int m, v;
00513     // set up the truth tables
00514     for ( m = 0; m < 32; m++ )
00515         for ( v = 0; v < 5; v++ )
00516             if ( m & (1 << v) )
00517                 uTruths[v][0] |= (1 << m);
00518     // make adjustments for the case of 6 variables
00519     for ( v = 0; v < 5; v++ )
00520         uTruths[v][1] = uTruths[v][0];
00521     uTruths[5][0] = 0;
00522     uTruths[5][1] = MAP_FULL;
00523 }

void Map_MappingSetupTruthTablesLarge ( unsigned  uTruths[][32]  ) 

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

Synopsis [Sets up the truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 536 of file mapperUtils.c.

00537 {
00538     int m, v;
00539     // clean everything
00540     for ( m = 0; m < 32; m++ )
00541         for ( v = 0; v < 10; v++ )
00542             uTruths[v][m] = 0;
00543     // set up the truth tables
00544     for ( m = 0; m < 32; m++ )
00545         for ( v = 0; v < 5; v++ )
00546             if ( m & (1 << v) )
00547             {
00548                 uTruths[v][0] |= (1 << m);
00549                 uTruths[v+5][m] = MAP_FULL;
00550             }
00551     // extend this info for the rest of the first 5 variables
00552     for ( m = 0; m < 32; m++ )
00553         for ( v = 0; v < 5; v++ )
00554             uTruths[v][m] = uTruths[v][0];
00555 /*
00556     // verify
00557     for ( m = 0; m < 1024; m++, printf("\n") )
00558         for ( v = 0; v < 10; v++ )
00559             if ( Map_InfoReadVar( uTruths[v], m ) )
00560                 printf( "1" );
00561             else
00562                 printf( "0" );
00563 */
00564 }

void Map_NetworkSweep ( Abc_Ntk_t pNet  ) 
Map_Node_t* Map_NodeAnd ( Map_Man_t p,
Map_Node_t p1,
Map_Node_t p2 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 514 of file mapperCreate.c.

00515 {
00516     Map_Node_t * pNode;
00517     pNode = Map_TableLookup( p, p1, p2 );    
00518     return pNode;
00519 }

int Map_NodeComparePhase ( Map_Node_t p1,
Map_Node_t p2 
)

Definition at line 112 of file mapperCreate.c.

00112 { assert( !Map_IsComplement(p1) ); assert( !Map_IsComplement(p2) ); return p1->fInv ^ p2->fInv; }

Map_Node_t* Map_NodeCreate ( Map_Man_t p,
Map_Node_t p1,
Map_Node_t p2 
)

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

Synopsis [Creates a new node.]

Description [This procedure should be called to create the constant node and the PI nodes first.]

SideEffects []

SeeAlso []

Definition at line 337 of file mapperCreate.c.

00338 {
00339     Map_Node_t * pNode;
00340     // create the node
00341     pNode = (Map_Node_t *)Extra_MmFixedEntryFetch( p->mmNodes );
00342     memset( pNode, 0, sizeof(Map_Node_t) );
00343     pNode->tRequired[0].Rise = pNode->tRequired[0].Fall = pNode->tRequired[0].Worst = MAP_FLOAT_LARGE;
00344     pNode->tRequired[1].Rise = pNode->tRequired[1].Fall = pNode->tRequired[1].Worst = MAP_FLOAT_LARGE;
00345     pNode->p1  = p1; 
00346     pNode->p2  = p2;
00347     pNode->p = p;
00348     // set the number of this node
00349     pNode->Num = p->nNodes++;
00350     // place to store the fanouts
00351 //    pNode->vFanouts = Map_NodeVecAlloc( 5 );
00352     // store this node in the internal array
00353     if ( pNode->Num >= 0 )
00354         Map_NodeVecPush( p->vNodesAll, pNode );
00355     else
00356         pNode->fInv = 1;
00357     // set the level of this node
00358     if ( p1 ) 
00359     {
00360 #ifdef MAP_ALLOCATE_FANOUT
00361         // create the fanout info
00362         Map_NodeAddFaninFanout( Map_Regular(p1), pNode );
00363         Map_NodeAddFaninFanout( Map_Regular(p2), pNode );
00364 #endif
00365         pNode->Level = 1 + MAP_MAX(Map_Regular(pNode->p1)->Level, Map_Regular(pNode->p2)->Level);
00366         pNode->fInv  = Map_NodeIsSimComplement(p1) & Map_NodeIsSimComplement(p2);
00367     }
00368     // reference the inputs (will be used to compute the number of fanouts)
00369     if ( p1 ) Map_NodeRef(p1);
00370     if ( p2 ) Map_NodeRef(p2);
00371 
00372     pNode->nRefEst[0] = pNode->nRefEst[1] = -1;
00373     return pNode;
00374 }

Map_Node_t* Map_NodeExor ( Map_Man_t p,
Map_Node_t p1,
Map_Node_t p2 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 550 of file mapperCreate.c.

00551 {
00552     return Map_NodeMux( p, p1, Map_Not(p2), p2 );
00553 }

int Map_NodeIsAnd ( Map_Node_t p  ) 

Definition at line 111 of file mapperCreate.c.

00111 {  return (Map_Regular(p))->p1 != NULL;  }

int Map_NodeIsConst ( Map_Node_t p  ) 

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

Synopsis [Checks the type of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file mapperCreate.c.

00109 {  return (Map_Regular(p))->Num == -1;    }

int Map_NodeIsVar ( Map_Node_t p  ) 

Definition at line 110 of file mapperCreate.c.

00110 {  return (Map_Regular(p))->p1 == NULL && (Map_Regular(p))->Num >= 0; }

Map_Node_t* Map_NodeMux ( Map_Man_t p,
Map_Node_t pC,
Map_Node_t pT,
Map_Node_t pE 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 566 of file mapperCreate.c.

00567 {
00568     Map_Node_t * pAnd1, * pAnd2, * pRes;
00569     pAnd1 = Map_TableLookup( p, pC,          pT ); 
00570     pAnd2 = Map_TableLookup( p, Map_Not(pC), pE ); 
00571     pRes  = Map_NodeOr( p, pAnd1, pAnd2 );                 
00572     return pRes;
00573 }

Map_Node_t* Map_NodeOr ( Map_Man_t p,
Map_Node_t p1,
Map_Node_t p2 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 532 of file mapperCreate.c.

00533 {
00534     Map_Node_t * pNode;
00535     pNode = Map_Not( Map_TableLookup( p, Map_Not(p1), Map_Not(p2) ) ); 
00536     return pNode;
00537 }

Map_Cut_t* Map_NodeReadCutBest ( Map_Node_t p,
int  fPhase 
)

Definition at line 90 of file mapperCreate.c.

00090 { return p->pCutBest[fPhase];   }

Map_Cut_t* Map_NodeReadCuts ( Map_Node_t p  ) 

Definition at line 89 of file mapperCreate.c.

00089 { return p->pCuts;              }

char* Map_NodeReadData ( Map_Node_t p,
int  fPhase 
)

Definition at line 86 of file mapperCreate.c.

00086 { return fPhase? p->pData1 : p->pData0;  }

int Map_NodeReadLevel ( Map_Node_t p  ) 

Definition at line 88 of file mapperCreate.c.

00088 { return Map_Regular(p)->Level; }

Map_Man_t* Map_NodeReadMan ( Map_Node_t p  ) 

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

Synopsis [Reads parameters from the mapping node.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file mapperCreate.c.

00085 { return p->p;                  }

int Map_NodeReadNum ( Map_Node_t p  ) 

Definition at line 87 of file mapperCreate.c.

00087 { return p->Num;                }

Map_Node_t* Map_NodeReadOne ( Map_Node_t p  ) 

Definition at line 91 of file mapperCreate.c.

00091 { return p->p1;                 }

Map_Node_t* Map_NodeReadTwo ( Map_Node_t p  ) 

Definition at line 92 of file mapperCreate.c.

00092 { return p->p2;                 }

void Map_NodeSetChoice ( Map_Man_t pMan,
Map_Node_t pNodeOld,
Map_Node_t pNodeNew 
)

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

Synopsis [Sets the node to be equivalent to the given one.]

Description [This procedure is a work-around for the equivalence check. Does not verify the equivalence. Use at the user's risk.]

SideEffects []

SeeAlso []

Definition at line 588 of file mapperCreate.c.

00589 {
00590     pNodeNew->pNextE = pNodeOld->pNextE;
00591     pNodeOld->pNextE = pNodeNew;
00592     pNodeNew->pRepr  = pNodeOld;
00593 }

void Map_NodeSetData ( Map_Node_t p,
int  fPhase,
char *  pData 
)

Definition at line 93 of file mapperCreate.c.

00093 { if (fPhase) p->pData1 = pData; else p->pData0 = pData; }

void Map_NodeSetNextE ( Map_Node_t p,
Map_Node_t pNextE 
)

Definition at line 94 of file mapperCreate.c.

00094 { p->pNextE = pNextE;       }

void Map_NodeSetRepr ( Map_Node_t p,
Map_Node_t pRepr 
)

Definition at line 95 of file mapperCreate.c.

00095 { p->pRepr = pRepr;         }

void Map_NodeSetSwitching ( Map_Node_t p,
float  Switching 
)

Definition at line 96 of file mapperCreate.c.

00096 { p->Switching = Switching; }

int Map_SuperLibDeriveFromGenlib ( Mio_Library_t pLib  ) 

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

Synopsis [Derives the library from the genlib library.]

Description []

SideEffects []

SeeAlso []

Definition at line 168 of file mapperLib.c.

00169 {
00170     Abc_Frame_t * pAbc = Abc_FrameGetGlobalFrame();
00171     char * pNameGeneric;
00172     char FileNameGenlib[100];
00173     char FileNameSuper[100];
00174     char CommandSuper[500];
00175     char CommandRead[500];
00176     FILE * pFile;
00177 
00178     if ( pLib == NULL )
00179         return 0;
00180 
00181     // write the current library into the file
00182     sprintf( FileNameGenlib, "%s_temp", Mio_LibraryReadName(pLib) );
00183     pFile = fopen( FileNameGenlib, "w" );
00184     Mio_WriteLibrary( pFile, pLib, 0 );
00185     fclose( pFile );
00186 
00187     // get the file name with the library
00188     pNameGeneric = Extra_FileNameGeneric( Mio_LibraryReadName(pLib) );
00189     sprintf( FileNameSuper, "%s.super", pNameGeneric );
00190     free( pNameGeneric );
00191 
00192     sprintf( CommandSuper,  "super -l 1 -i 5 -d 10000000 -a 10000000 -t 100 %s", FileNameGenlib ); 
00193     if ( Cmd_CommandExecute( pAbc, CommandSuper ) )
00194     {
00195         fprintf( stdout, "Cannot execute command \"%s\".\n", CommandSuper );
00196         return 0;
00197     }
00198 //#ifdef WIN32
00199 //        _unlink( FileNameGenlib );
00200 //#else
00201 //        unlink( FileNameGenlib );
00202 //#endif
00203 
00204     sprintf( CommandRead,  "read_super %s", FileNameSuper ); 
00205     if ( Cmd_CommandExecute( pAbc, CommandRead ) )
00206     {
00207 #ifdef WIN32
00208         _unlink( FileNameSuper );
00209 #else
00210         unlink( FileNameSuper );
00211 #endif
00212         fprintf( stdout, "Cannot execute command \"%s\".\n", CommandRead );
00213         return 0;
00214     }
00215 
00216 /* // don't remove the intermediate file
00217 #ifdef WIN32
00218     _unlink( FileNameSuper );
00219 #else
00220     unlink( FileNameSuper );
00221 #endif
00222 */
00223      return 1;
00224 }

float Map_SuperLibReadAreaInv ( Map_SuperLib_t p  ) 

Definition at line 157 of file mapperCreate.c.

00157 {  return p->AreaInv;  }

Map_Time_t Map_SuperLibReadDelayInv ( Map_SuperLib_t p  ) 

Definition at line 158 of file mapperCreate.c.

00158 {  return p->tDelayInv;}

Mio_Library_t* Map_SuperLibReadGenLib ( Map_SuperLib_t p  ) 

Definition at line 156 of file mapperCreate.c.

00156 {  return p->pGenlib;  }

int Map_SuperLibReadVarsMax ( Map_SuperLib_t p  ) 

Definition at line 159 of file mapperCreate.c.

00159 {  return p->nVarsMax; }

int Map_SuperReadFaninNum ( Map_Super_t p  ) 

Definition at line 150 of file mapperCreate.c.

00150 {  return p->nFanins;  }

Map_Super_t** Map_SuperReadFanins ( Map_Super_t p  ) 

Definition at line 149 of file mapperCreate.c.

00149 {  return p->pFanins;  }

int Map_SuperReadFanoutLimit ( Map_Super_t p  ) 

Definition at line 154 of file mapperCreate.c.

00154 {  return p->nFanLimit;}

char* Map_SuperReadFormula ( Map_Super_t p  ) 

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

Synopsis [Reads parameters from the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file mapperCreate.c.

00146 {  return p->pFormula; }

Map_Super_t* Map_SuperReadNext ( Map_Super_t p  ) 

Definition at line 151 of file mapperCreate.c.

00151 {  return p->pNext;    }

int Map_SuperReadNum ( Map_Super_t p  ) 

Definition at line 148 of file mapperCreate.c.

00148 {  return p->Num;      }

int Map_SuperReadNumPhases ( Map_Super_t p  ) 

Definition at line 152 of file mapperCreate.c.

00152 {  return p->nPhases;  }

unsigned char* Map_SuperReadPhases ( Map_Super_t p  ) 

Definition at line 153 of file mapperCreate.c.

00153 {  return p->uPhases;  }

Mio_Gate_t* Map_SuperReadRoot ( Map_Super_t p  ) 

Definition at line 147 of file mapperCreate.c.

00147 {  return p->pRoot;    }

Map_Super_t* Map_SuperTableLookupC ( Map_SuperLib_t p,
unsigned  uTruth[] 
)

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 180 of file mapperTable.c.

00181 {
00182     Map_HashEntry_t * pEnt;
00183     unsigned Key;
00184     Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->tTableC->nBins );
00185     for ( pEnt = p->tTableC->pBins[Key]; pEnt; pEnt = pEnt->pNext )
00186         if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] )
00187             return pEnt->pGates;
00188     return NULL;
00189 }


Generated on Tue Jan 5 12:19:05 2010 for abc70930 by  doxygen 1.6.1