#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include "cuddInt.h"
#include "main.h"
#include "mio.h"
#include "mapper.h"
Go to the source code of this file.
#define Map_CutIsComplement | ( | p | ) | (((int)((unsigned long) (p) & 01))) |
Definition at line 64 of file mapperInt.h.
#define Map_CutNot | ( | p | ) | ((Map_Cut_t *)((unsigned long)(p) ^ 01)) |
Definition at line 66 of file mapperInt.h.
#define Map_CutNotCond | ( | p, | |||
c | ) | ((Map_Cut_t *)((unsigned long)(p) ^ (c))) |
Definition at line 67 of file mapperInt.h.
#define Map_CutRegular | ( | p | ) | ((Map_Cut_t *)((unsigned long)(p) & ~01)) |
Definition at line 65 of file mapperInt.h.
#define MAP_FLOAT_LARGE ((float)(FLT_MAX/10)) |
Definition at line 57 of file mapperInt.h.
#define MAP_FLOAT_SMALL ((float)1.0e-03) |
Definition at line 58 of file mapperInt.h.
#define MAP_FULL (~((unsigned)0)) |
Definition at line 49 of file mapperInt.h.
#define Map_InfoFlipVar | ( | p, | |||
i | ) | (p[(i)>>5] ^= (1<<((i) & 31))) |
Definition at line 76 of file mapperInt.h.
#define Map_InfoReadVar | ( | p, | |||
i | ) | ((p[(i)>>5] & (1<<((i) & 31))) > 0) |
Definition at line 77 of file mapperInt.h.
#define Map_InfoRemVar | ( | p, | |||
i | ) | (p[(i)>>5] &= ~(1<<((i) & 31))) |
Definition at line 75 of file mapperInt.h.
#define Map_InfoSetVar | ( | p, | |||
i | ) | (p[(i)>>5] |= (1<<((i) & 31))) |
Definition at line 74 of file mapperInt.h.
#define MAP_MASK | ( | n | ) | ((~((unsigned)0)) >> (32-(n))) |
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 [
] INCLUDES /// PARAMETERS /// MACRO DEFINITIONS ///
Definition at line 48 of file mapperInt.h.
#define MAP_MAX | ( | a, | |||
b | ) | (((a) > (b))? (a) : (b)) |
Definition at line 54 of file mapperInt.h.
#define MAP_MIN | ( | a, | |||
b | ) | (((a) < (b))? (a) : (b)) |
Definition at line 53 of file mapperInt.h.
#define MAP_NO_VAR (-9999.0) |
Definition at line 50 of file mapperInt.h.
#define Map_NodeForEachFanout | ( | pNode, | |||
pFanout | ) |
for ( pFanout = (pNode)->pFanPivot; pFanout; \ pFanout = Map_NodeReadNextFanout(pNode, pFanout) )
Definition at line 333 of file mapperInt.h.
#define Map_NodeForEachFanoutSafe | ( | pNode, | |||
pFanout, | |||||
pFanout2 | ) |
for ( pFanout = (pNode)->pFanPivot, \ pFanout2 = Map_NodeReadNextFanout(pNode, pFanout); \ pFanout; \ pFanout = pFanout2, \ pFanout2 = Map_NodeReadNextFanout(pNode, pFanout) )
Definition at line 338 of file mapperInt.h.
#define Map_NodeIsSimComplement | ( | p | ) | (Map_IsComplement(p)? !(Map_Regular(p)->fInv) : (p)->fInv) |
Definition at line 80 of file mapperInt.h.
#define Map_NodeReadNextFanout | ( | pNode, | |||
pFanout | ) |
( ( pFanout == NULL )? NULL : \ ((Map_Regular((pFanout)->p1) == (pNode))? \ (pFanout)->pFanFanin1 : (pFanout)->pFanFanin2) )
Definition at line 322 of file mapperInt.h.
#define Map_NodeReadNextFanoutPlace | ( | pNode, | |||
pFanout | ) |
( (Map_Regular((pFanout)->p1) == (pNode))? \ &(pFanout)->pFanFanin1 : &(pFanout)->pFanFanin2 )
Definition at line 328 of file mapperInt.h.
#define Map_NodeReadRef | ( | p | ) | ((Map_Regular(p))->nRefs) |
Definition at line 70 of file mapperInt.h.
#define Map_NodeRef | ( | p | ) | ((Map_Regular(p))->nRefs++) |
Definition at line 71 of file mapperInt.h.
#define MAP_RANDOM_UNSIGNED ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand())) |
Definition at line 61 of file mapperInt.h.
void Map_ComputeDcs | ( | Map_Man_t * | p | ) |
unsigned Map_ComputeIsop_rec | ( | Map_Man_t * | p, | |
unsigned | uF, | |||
unsigned | uFD, | |||
int | iVar, | |||
int | nVars, | |||
int | fDir | |||
) |
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 [
] 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 }
float Map_CutDeref | ( | Map_Cut_t * | pCut, | |
int | fPhase | |||
) |
function*************************************************************
synopsis [Dereferences the cut.]
description []
sideeffects []
seealso []
Definition at line 291 of file mapperRefs.c.
00292 { 00293 return Map_CutRefDeref( pCut, fPhase, 0 ); // dereference 00294 }
Function*************************************************************
Synopsis [Deallocates the cut.]
Description []
SideEffects []
SeeAlso []
Definition at line 72 of file mapperCutUtils.c.
00073 { 00074 if ( pCut ) 00075 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut ); 00076 }
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 255 of file mapperRefs.c.
00256 { 00257 float aResult, aResult2; 00258 aResult2 = Map_CutRefDeref( pCut, fPhase, 1 ); // reference 00259 aResult = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference 00260 // assert( aResult == aResult2 ); 00261 return aResult; 00262 }
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 185 of file mapperRefs.c.
00186 { 00187 Map_Match_t * pM = pCut->M + fPhase; 00188 Map_Super_t * pSuper = pM->pSuperBest; 00189 unsigned uPhaseTot = pM->uPhaseBest; 00190 Map_Cut_t * pCutFanin; 00191 float aFlowRes, aFlowFanin, nRefs; 00192 int i, fPinPhasePos; 00193 00194 // start the resulting area flow 00195 aFlowRes = pSuper->Area; 00196 // iterate through the leaves 00197 for ( i = 0; i < pCut->nLeaves; i++ ) 00198 { 00199 // get the phase of this fanin 00200 fPinPhasePos = ((uPhaseTot & (1 << i)) == 0); 00201 // get the cut implementing this phase of the fanin 00202 pCutFanin = pCut->ppLeaves[i]->pCutBest[fPinPhasePos]; 00203 // if the cut is not available, we have to use the opposite phase 00204 if ( pCutFanin == NULL ) 00205 { 00206 fPinPhasePos = !fPinPhasePos; 00207 pCutFanin = pCut->ppLeaves[i]->pCutBest[fPinPhasePos]; 00208 } 00209 aFlowFanin = pCutFanin->M[fPinPhasePos].AreaFlow; // ignores the area of the interter 00210 // get the fanout count of the cut in the given phase 00211 nRefs = Map_NodeReadRefPhaseEst( pCut->ppLeaves[i], fPinPhasePos ); 00212 // if the node does no fanout, assume fanout count equal to 1 00213 if ( nRefs == (float)0.0 ) 00214 nRefs = (float)1.0; 00215 // add the area flow due to the fanin 00216 aFlowRes += aFlowFanin / nRefs; 00217 } 00218 pM->AreaFlow = aFlowRes; 00219 return aFlowRes; 00220 }
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 235 of file mapperRefs.c.
00236 { 00237 float aResult, aResult2; 00238 aResult2 = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference 00239 aResult = Map_CutRefDeref( pCut, fPhase, 1 ); // reference 00240 // assert( aResult == aResult2 ); 00241 return aResult; 00242 }
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 128 of file mapperCutUtils.c.
00129 { 00130 assert( pCut->M[fPhase].pSuperBest ); 00131 return (( pCut->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0); 00132 }
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 111 of file mapperCutUtils.c.
00112 { 00113 assert( pCut->M[fPhase].pSuperBest ); 00114 return pCut->M[fPhase].pSuperBest->Area; 00115 }
void Map_CutInsertFanouts | ( | Map_Node_t * | pNode, | |
Map_Cut_t * | pCut, | |||
int | fPhase | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 162 of file mapperCutUtils.c.
00163 { 00164 Map_Cut_t * pPrev, * pTemp; 00165 if ( pSetAll == NULL ) 00166 return pSets; 00167 if ( pSets == NULL ) 00168 return pSetAll; 00169 // find the last one 00170 for ( pTemp = pSets; pTemp; pTemp = pTemp->pNext ) 00171 pPrev = pTemp; 00172 // append all the end of the current set 00173 assert( pPrev->pNext == NULL ); 00174 pPrev->pNext = pSetAll; 00175 return pSets; 00176 }
int Map_CutListCount | ( | Map_Cut_t * | pSets | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 210 of file mapperCutUtils.c.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 189 of file mapperCutUtils.c.
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 89 of file mapperCutUtils.c.
00090 { 00091 int i; 00092 printf( "CUT: Delay = (%4.2f, %4.2f). Area = %4.2f. Nodes = %d -> {", 00093 pCut->M[fPhase].tArrive.Rise, pCut->M[fPhase].tArrive.Fall, pCut->M[fPhase].AreaFlow, pRoot->Num ); 00094 for ( i = 0; i < pCut->nLeaves; i++ ) 00095 printf( " %d", pCut->ppLeaves[i]->Num ); 00096 printf( " } \n" ); 00097 }
float Map_CutRef | ( | Map_Cut_t * | pCut, | |
int | fPhase | |||
) |
function*************************************************************
synopsis [References the cut.]
description []
sideeffects []
seealso []
Definition at line 275 of file mapperRefs.c.
00276 { 00277 return Map_CutRefDeref( pCut, fPhase, 1 ); // reference 00278 }
void Map_CutRemoveFanouts | ( | Map_Node_t * | pNode, | |
Map_Cut_t * | pCut, | |||
int | fPhase | |||
) |
void Map_LibraryPrintSupergate | ( | Map_Super_t * | pGate | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 398 of file mapperSuper.c.
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 757 of file mapperTree.c.
00758 { 00759 Map_Super_t * pGate; 00760 int i, k; 00761 00762 // print all the info related to the supergates 00763 // for ( i = pLib->nVarsMax; i < (int)pLib->nLines; i++ ) 00764 for ( i = pLib->nVarsMax; i < 20; i++ ) 00765 { 00766 pGate = pLib->ppSupers[i]; 00767 00768 // write the gate's fanin info and formula 00769 printf( "%6d ", pGate->Num ); 00770 printf( "%c ", pGate->fSuper? '*' : ' ' ); 00771 printf( "%6s", Mio_GateReadName(pGate->pRoot) ); 00772 for ( k = 0; k < (int)pGate->nFanins; k++ ) 00773 printf( " %6d", pGate->pFanins[k]->Num ); 00774 printf( " %s", pGate->pFormula ); 00775 printf( "\n" ); 00776 00777 // write the gate's derived info 00778 Extra_PrintBinary( stdout, pGate->uTruth, 64 ); 00779 printf( " %3d", pGate->nGates ); 00780 printf( " %6.2f", pGate->Area ); 00781 printf( " (%4.2f, %4.2f)", pGate->tDelayMax.Rise, pGate->tDelayMax.Fall ); 00782 printf( "\n" ); 00783 for ( k = 0; k < pLib->nVarsMax; k++ ) 00784 { 00785 // print the constraint on the rise of the gate in the form (D1, D2), 00786 // where D1 is the constraint related to the rise of the k-th PI 00787 // where D2 is the constraint related to the fall of the k-th PI 00788 if ( pGate->tDelaysR[k].Rise < 0 && pGate->tDelaysR[k].Fall < 0 ) 00789 printf( " (----, ----)" ); 00790 else if ( pGate->tDelaysR[k].Fall < 0 ) 00791 printf( " (%4.2f, ----)", pGate->tDelaysR[k].Rise ); 00792 else if ( pGate->tDelaysR[k].Rise < 0 ) 00793 printf( " (----, %4.2f)", pGate->tDelaysR[k].Fall ); 00794 else 00795 printf( " (%4.2f, %4.2f)", pGate->tDelaysR[k].Rise, pGate->tDelaysR[k].Fall ); 00796 00797 // print the constraint on the fall of the gate in the form (D1, D2), 00798 // where D1 is the constraint related to the rise of the k-th PI 00799 // where D2 is the constraint related to the fall of the k-th PI 00800 if ( pGate->tDelaysF[k].Rise < 0 && pGate->tDelaysF[k].Fall < 0 ) 00801 printf( " (----, ----)" ); 00802 else if ( pGate->tDelaysF[k].Fall < 0 ) 00803 printf( " (%4.2f, ----)", pGate->tDelaysF[k].Rise ); 00804 else if ( pGate->tDelaysF[k].Rise < 0 ) 00805 printf( " (----, %4.2f)", pGate->tDelaysF[k].Fall ); 00806 else 00807 printf( " (%4.2f, %4.2f)", pGate->tDelaysF[k].Rise, pGate->tDelaysF[k].Fall ); 00808 printf( "\n" ); 00809 } 00810 printf( "\n" ); 00811 } 00812 }
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 47 of file mapperSuper.c.
00048 { 00049 FILE * pFile; 00050 int Status; 00051 // read the beginning of the file 00052 assert( pLib->pGenlib == NULL ); 00053 pFile = fopen( pFileName, "r" ); 00054 if ( pFile == NULL ) 00055 { 00056 printf( "Cannot open input file \"%s\".\n", pFileName ); 00057 return 0; 00058 } 00059 Status = Map_LibraryReadFile( pLib, pFile ); 00060 fclose( pFile ); 00061 // Map_LibraryPrintClasses( pLib ); 00062 return Status; 00063 }
int Map_LibraryReadTree | ( | Map_SuperLib_t * | pLib, | |
char * | pFileName, | |||
char * | pExcludeFile | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Reads the supergate library from file.]
Description []
SideEffects []
SeeAlso []
Definition at line 54 of file mapperTree.c.
00055 { 00056 FILE * pFile; 00057 int Status, num; 00058 Abc_Frame_t * pAbc; 00059 st_table * tExcludeGate = 0; 00060 00061 // read the beginning of the file 00062 assert( pLib->pGenlib == NULL ); 00063 pFile = Io_FileOpen( pFileName, "open_path", "r", 1 ); 00064 // pFile = fopen( pFileName, "r" ); 00065 if ( pFile == NULL ) 00066 { 00067 printf( "Cannot open input file \"%s\".\n", pFileName ); 00068 return 0; 00069 } 00070 00071 if ( pExcludeFile ) 00072 { 00073 pAbc = Abc_FrameGetGlobalFrame(); 00074 00075 tExcludeGate = st_init_table(strcmp, st_strhash); 00076 if ( (num = Mio_LibraryReadExclude( pAbc, pExcludeFile, tExcludeGate )) == -1 ) 00077 { 00078 st_free_table( tExcludeGate ); 00079 tExcludeGate = 0; 00080 return 0; 00081 } 00082 00083 fprintf ( Abc_FrameReadOut( pAbc ), "Read %d gates from exclude file\n", num ); 00084 } 00085 00086 Status = Map_LibraryReadFileTree( pLib, pFile, pFileName ); 00087 fclose( pFile ); 00088 if ( Status == 0 ) 00089 return 0; 00090 // prepare the info about the library 00091 return Map_LibraryDeriveGateInfo( pLib, tExcludeGate ); 00092 }
float Map_MappingCombinePhases | ( | Map_Man_t * | p | ) |
float Map_MappingComputeDelayWithFanouts | ( | Map_Man_t * | p | ) |
Function*************************************************************
Synopsis [Compute the arrival times.]
Description []
SideEffects []
SeeAlso []
Definition at line 888 of file mapperUtils.c.
00889 { 00890 Map_Node_t * pNode; 00891 float Result; 00892 int i; 00893 for ( i = 0; i < p->vAnds->nSize; i++ ) 00894 { 00895 // skip primary inputs 00896 pNode = p->vAnds->pArray[i]; 00897 if ( !Map_NodeIsAnd( pNode ) ) 00898 continue; 00899 // skip a secondary node 00900 if ( pNode->pRepr ) 00901 continue; 00902 // count the switching nodes 00903 if ( pNode->nRefAct[0] > 0 ) 00904 Map_TimeCutComputeArrival( pNode, pNode->pCutBest[0], 0, MAP_FLOAT_LARGE ); 00905 if ( pNode->nRefAct[1] > 0 ) 00906 Map_TimeCutComputeArrival( pNode, pNode->pCutBest[1], 1, MAP_FLOAT_LARGE ); 00907 } 00908 Result = Map_TimeComputeArrivalMax(p); 00909 printf( "Max arrival times with fanouts = %10.2f.\n", Result ); 00910 return Result; 00911 }
int Map_MappingCountAllCuts | ( | Map_Man_t * | pMan | ) |
Function*************************************************************
Synopsis [Counts all the cuts.]
Description []
SideEffects []
SeeAlso []
Definition at line 690 of file mapperCut.c.
00691 { 00692 Map_Node_t * pNode; 00693 Map_Cut_t * pCut; 00694 int i, nCuts; 00695 // int nCuts55 = 0, nCuts5x = 0, nCuts4x = 0, nCuts3x = 0; 00696 // int pCounts[7] = {0}; 00697 nCuts = 0; 00698 for ( i = 0; i < pMan->nBins; i++ ) 00699 for ( pNode = pMan->pBins[i]; pNode; pNode = pNode->pNext ) 00700 for ( pCut = pNode->pCuts; pCut; pCut = pCut->pNext ) 00701 if ( pCut->nLeaves > 1 ) // skip the elementary cuts 00702 { 00703 nCuts++; 00704 /* 00705 if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 && Map_CutRegular(pCut->pTwo)->nLeaves == 5 ) 00706 nCuts55++; 00707 if ( Map_CutRegular(pCut->pOne)->nLeaves == 5 || Map_CutRegular(pCut->pTwo)->nLeaves == 5 ) 00708 nCuts5x++; 00709 else if ( Map_CutRegular(pCut->pOne)->nLeaves == 4 || Map_CutRegular(pCut->pTwo)->nLeaves == 4 ) 00710 nCuts4x++; 00711 else if ( Map_CutRegular(pCut->pOne)->nLeaves == 3 || Map_CutRegular(pCut->pTwo)->nLeaves == 3 ) 00712 nCuts3x++; 00713 */ 00714 // pCounts[ Map_CutRegular(pCut->pOne)->nLeaves ]++; 00715 // pCounts[ Map_CutRegular(pCut->pTwo)->nLeaves ]++; 00716 } 00717 // printf( "Total cuts = %6d. 55 = %6d. 5x = %6d. 4x = %6d. 3x = %6d.\n", nCuts, nCuts55, nCuts5x, nCuts4x, nCuts3x ); 00718 00719 // printf( "Total cuts = %6d. 6= %6d. 5= %6d. 4= %6d. 3= %6d. 2= %6d. 1= %6d.\n", 00720 // nCuts, pCounts[6], pCounts[5], pCounts[4], pCounts[3], pCounts[2], pCounts[1] ); 00721 return nCuts; 00722 }
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 758 of file mapperUtils.c.
00759 { 00760 Map_Node_t * pNode; 00761 int Counter, i; 00762 // count the number of equal adjacent nodes 00763 Counter = 0; 00764 for ( i = 0; i < vNodes->nSize; i++ ) 00765 { 00766 pNode = vNodes->pArray[i]; 00767 if ( !Map_NodeIsAnd(pNode) ) 00768 continue; 00769 if ( (pNode->nRefAct[0] && pNode->pCutBest[0]) && 00770 (pNode->nRefAct[1] && pNode->pCutBest[1]) ) 00771 Counter++; 00772 } 00773 return Counter; 00774 }
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 280 of file mapperUtils.c.
00281 { 00282 int i, LevelsMax, LevelsCur; 00283 // perform the traversal 00284 LevelsMax = -1; 00285 for ( i = 0; i < pMan->nOutputs; i++ ) 00286 { 00287 LevelsCur = Map_MappingCountLevels_rec( Map_Regular(pMan->pOutputs[i]) ); 00288 if ( LevelsMax < LevelsCur ) 00289 LevelsMax = LevelsCur; 00290 } 00291 for ( i = 0; i < pMan->nOutputs; i++ ) 00292 Map_MappingUnmark_rec( Map_Regular(pMan->pOutputs[i]) ); 00293 return LevelsMax; 00294 }
void Map_MappingCuts | ( | Map_Man_t * | p | ) |
GLOBAL VARIABLES /// FUNCTION DEFINITIONS ///
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Computes the cuts for each node in the object graph.]
Description [The cuts are computed in one sweep over the mapping graph. First, the elementary cuts, which include the node itself, are assigned to the PI nodes. The internal nodes are considered in the DFS order. Each node is two-input AND-gate. So to compute the cuts at a node, we need to merge the sets of cuts of its two predecessors. The merged set contains only unique cuts with the number of inputs equal to k or less. Finally, the elementary cut, composed of the node itself, is added to the set of cuts for the node.
This procedure is pretty fast for 5-feasible cuts, but it dramatically slows down on some "dense" networks when computing 6-feasible cuts. The problem is that there are too many cuts in this case. We should think how to heuristically trim the number of cuts in such cases, to have reasonable runtime.]
SideEffects []
SeeAlso []
Definition at line 110 of file mapperCut.c.
00111 { 00112 ProgressBar * pProgress; 00113 Map_CutTable_t * pTable; 00114 Map_Node_t * pNode; 00115 Map_Cut_t * pCut; 00116 int nCuts, nNodes, i; 00117 int clk = clock(); 00118 // set the elementary cuts for the PI variables 00119 assert( p->nVarsMax > 1 && p->nVarsMax < 7 ); 00120 for ( i = 0; i < p->nInputs; i++ ) 00121 { 00122 pCut = Map_CutAlloc( p ); 00123 pCut->nLeaves = 1; 00124 pCut->ppLeaves[0] = p->pInputs[i]; 00125 p->pInputs[i]->pCuts = pCut; 00126 p->pInputs[i]->pCutBest[0] = NULL; // negative polarity is not mapped 00127 p->pInputs[i]->pCutBest[1] = pCut; // positive polarity is a trivial cut 00128 pCut->uTruth = 0xAAAAAAAA; // the first variable "10101010" 00129 pCut->M[0].AreaFlow = 0.0; 00130 pCut->M[1].AreaFlow = 0.0; 00131 } 00132 00133 // compute the cuts for the internal nodes 00134 nNodes = p->vAnds->nSize; 00135 pProgress = Extra_ProgressBarStart( stdout, nNodes ); 00136 pTable = Map_CutTableStart( p ); 00137 for ( i = 0; i < nNodes; i++ ) 00138 { 00139 pNode = p->vAnds->pArray[i]; 00140 if ( !Map_NodeIsAnd( pNode ) ) 00141 continue; 00142 Map_CutCompute( p, pTable, pNode ); 00143 Extra_ProgressBarUpdate( pProgress, i, "Cuts ..." ); 00144 } 00145 Extra_ProgressBarStop( pProgress ); 00146 Map_CutTableStop( pTable ); 00147 00148 // report the stats 00149 if ( p->fVerbose ) 00150 { 00151 nCuts = Map_MappingCountAllCuts(p); 00152 printf( "Nodes = %6d. Total %d-feasible cuts = %10d. Per node = %.1f. ", 00153 p->nNodes, p->nVarsMax, nCuts, ((float)nCuts)/p->nNodes ); 00154 PRT( "Time", clock() - clk ); 00155 } 00156 00157 // print the cuts for the first primary output 00158 // Map_CutListPrint( p, Map_Regular(p->pOutputs[0]) ); 00159 }
Map_NodeVec_t* Map_MappingDfs | ( | Map_Man_t * | pMan, | |
int | fCollectEquiv | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Computes the DFS ordering of the nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 58 of file mapperUtils.c.
00059 { 00060 Map_NodeVec_t * vNodes; 00061 int i; 00062 // perform the traversal 00063 vNodes = Map_NodeVecAlloc( 100 ); 00064 for ( i = 0; i < pMan->nOutputs; i++ ) 00065 Map_MappingDfs_rec( Map_Regular(pMan->pOutputs[i]), vNodes, fCollectEquiv ); 00066 for ( i = 0; i < vNodes->nSize; i++ ) 00067 vNodes->pArray[i]->fMark0 = 0; 00068 // for ( i = 0; i < pMan->nOutputs; i++ ) 00069 // Map_MappingUnmark_rec( Map_Regular(pMan->pOutputs[i]) ); 00070 return vNodes; 00071 }
void Map_MappingDfsMarked1_rec | ( | Map_Node_t * | pNode, | |
Map_NodeVec_t * | vNodes, | |||
int | fFirst | |||
) |
Function*************************************************************
Synopsis [Recursively computes the DFS ordering of the nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 143 of file mapperUtils.c.
00144 { 00145 assert( !Map_IsComplement(pNode) ); 00146 if ( pNode->fMark0 ) 00147 return; 00148 // visit the transitive fanin 00149 if ( Map_NodeIsAnd(pNode) ) 00150 { 00151 Map_MappingDfsMarked1_rec( Map_Regular(pNode->p1), vNodes, 0 ); 00152 Map_MappingDfsMarked1_rec( Map_Regular(pNode->p2), vNodes, 0 ); 00153 } 00154 // visit the equivalent nodes 00155 if ( !fFirst && pNode->pNextE ) 00156 Map_MappingDfsMarked1_rec( pNode->pNextE, vNodes, 0 ); 00157 // make sure the node is not visited through the equivalent nodes 00158 assert( pNode->fMark0 == 0 ); 00159 // mark the node as visited 00160 pNode->fMark0 = 1; 00161 // add the node to the list 00162 Map_NodeVecPush( vNodes, pNode ); 00163 }
void Map_MappingDfsMarked2_rec | ( | Map_Node_t * | pNode, | |
Map_NodeVec_t * | vNodes, | |||
Map_NodeVec_t * | vBoundary, | |||
int | fFirst | |||
) |
Function*************************************************************
Synopsis [Recursively computes the DFS ordering of the nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 176 of file mapperUtils.c.
00177 { 00178 assert( !Map_IsComplement(pNode) ); 00179 if ( pNode->fMark1 ) 00180 return; 00181 if ( pNode->fMark0 || Map_NodeIsVar(pNode) ) 00182 { 00183 pNode->fMark1 = 1; 00184 Map_NodeVecPush(vBoundary, pNode); 00185 return; 00186 } 00187 // visit the transitive fanin 00188 if ( Map_NodeIsAnd(pNode) ) 00189 { 00190 Map_MappingDfsMarked2_rec( Map_Regular(pNode->p1), vNodes, vBoundary, 0 ); 00191 Map_MappingDfsMarked2_rec( Map_Regular(pNode->p2), vNodes, vBoundary, 0 ); 00192 } 00193 // visit the equivalent nodes 00194 if ( !fFirst && pNode->pNextE ) 00195 Map_MappingDfsMarked2_rec( pNode->pNextE, vNodes, vBoundary, 0 ); 00196 // make sure the node is not visited through the equivalent nodes 00197 assert( pNode->fMark1 == 0 ); 00198 // mark the node as visited 00199 pNode->fMark1 = 1; 00200 // add the node to the list 00201 Map_NodeVecPush( vNodes, pNode ); 00202 }
Map_NodeVec_t* Map_MappingDfsNodes | ( | Map_Man_t * | pMan, | |
Map_Node_t ** | ppCuts, | |||
int | nNodes, | |||
int | fEquiv | |||
) |
Function*************************************************************
Synopsis [Computes the DFS ordering of the nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 84 of file mapperUtils.c.
00085 { 00086 Map_NodeVec_t * vNodes; 00087 int i; 00088 // perform the traversal 00089 vNodes = Map_NodeVecAlloc( 200 ); 00090 for ( i = 0; i < nNodes; i++ ) 00091 Map_MappingDfs_rec( ppCuts[i], vNodes, fEquiv ); 00092 for ( i = 0; i < vNodes->nSize; i++ ) 00093 vNodes->pArray[i]->fMark0 = 0; 00094 return vNodes; 00095 }
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 153 of file mapperRefs.c.
00154 { 00155 Map_Node_t * pNode; 00156 int i; 00157 for ( i = 0; i < p->vAnds->nSize; i++ ) 00158 { 00159 pNode = p->vAnds->pArray[i]; 00160 // pNode->nRefEst[0] = (float)((2.0 * pNode->nRefEst[0] + 1.0 * pNode->nRefAct[0]) / 3.0); 00161 // pNode->nRefEst[1] = (float)((2.0 * pNode->nRefEst[1] + 1.0 * pNode->nRefAct[1]) / 3.0); 00162 // pNode->nRefEst[2] = (float)((2.0 * pNode->nRefEst[2] + 1.0 * pNode->nRefAct[2]) / 3.0); 00163 pNode->nRefEst[0] = (float)((3.0 * pNode->nRefEst[0] + 1.0 * pNode->nRefAct[0]) / 4.0); 00164 pNode->nRefEst[1] = (float)((3.0 * pNode->nRefEst[1] + 1.0 * pNode->nRefAct[1]) / 4.0); 00165 pNode->nRefEst[2] = (float)((3.0 * pNode->nRefEst[2] + 1.0 * pNode->nRefAct[2]) / 4.0); 00166 } 00167 }
void Map_MappingEstimateRefsInit | ( | Map_Man_t * | p | ) |
Function*************************************************************
Synopsis [Sets the estimated reference counter for the PIs.]
Description []
SideEffects []
SeeAlso []
Definition at line 128 of file mapperRefs.c.
00129 { 00130 Map_Node_t * pNode; 00131 int i; 00132 for ( i = 0; i < p->vAnds->nSize; i++ ) 00133 { 00134 pNode = p->vAnds->pArray[i]; 00135 // pNode->nRefEst[0] = pNode->nRefEst[1] = ((float)pNode->nRefs)*(float)2.0; 00136 pNode->nRefEst[0] = pNode->nRefEst[1] = pNode->nRefEst[2] = ((float)pNode->nRefs); 00137 } 00138 }
void Map_MappingExpandTruth | ( | unsigned | uTruth[2], | |
int | nVars | |||
) |
Function*************************************************************
Synopsis [Expand the truth table]
Description []
SideEffects []
SeeAlso []
Definition at line 845 of file mapperUtils.c.
00846 { 00847 assert( nVars < 7 ); 00848 if ( nVars == 6 ) 00849 return; 00850 if ( nVars < 5 ) 00851 { 00852 uTruth[0] &= MAP_MASK( (1<<nVars) ); 00853 uTruth[0] = Map_MappingExpandTruth_rec( uTruth[0], nVars ); 00854 } 00855 uTruth[1] = uTruth[0]; 00856 }
float Map_MappingGetArea | ( | Map_Man_t * | pMan, | |
Map_NodeVec_t * | vMapping | |||
) |
Function*************************************************************
Synopsis [Computes the array of mapping.]
Description []
SideEffects []
SeeAlso []
Definition at line 517 of file mapperRefs.c.
00518 { 00519 Map_Node_t * pNode; 00520 float Area; 00521 int i; 00522 Area = 0.0; 00523 for ( i = 0; i < vMapping->nSize; i++ ) 00524 { 00525 pNode = vMapping->pArray[i]; 00526 // at least one phase has the best cut assigned 00527 assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL ); 00528 // at least one phase is used in the mapping 00529 assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 ); 00530 // compute the array due to the supergate 00531 if ( Map_NodeIsAnd(pNode) ) 00532 { 00533 // count area of the negative phase 00534 if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) ) 00535 Area += pNode->pCutBest[0]->M[0].pSuperBest->Area; 00536 // count area of the positive phase 00537 if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) ) 00538 Area += pNode->pCutBest[1]->M[1].pSuperBest->Area; 00539 } 00540 // count area of the interver if we need to implement one phase with another phase 00541 if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) || 00542 (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) ) 00543 Area += pMan->pSuperLib->AreaInv; 00544 } 00545 // add buffers for each CO driven by a CI 00546 for ( i = 0; i < pMan->nOutputs; i++ ) 00547 if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) ) 00548 Area += pMan->pSuperLib->AreaBuf; 00549 return Area; 00550 }
float Map_MappingGetAreaFlow | ( | Map_Man_t * | p | ) |
Function*************************************************************
Synopsis [Computes the total are flow of the network.]
Description []
SideEffects []
SeeAlso []
Definition at line 662 of file mapperUtils.c.
00663 { 00664 Map_Node_t * pNode; 00665 Map_Cut_t * pCut; 00666 float aFlowFlowTotal = 0; 00667 int fPosPol, i; 00668 for ( i = 0; i < p->nOutputs; i++ ) 00669 { 00670 pNode = Map_Regular(p->pOutputs[i]); 00671 if ( !Map_NodeIsAnd(pNode) ) 00672 continue; 00673 fPosPol = !Map_IsComplement(p->pOutputs[i]); 00674 pCut = pNode->pCutBest[fPosPol]; 00675 if ( pCut == NULL ) 00676 { 00677 fPosPol = !fPosPol; 00678 pCut = pNode->pCutBest[fPosPol]; 00679 } 00680 aFlowFlowTotal += pNode->pCutBest[fPosPol]->M[fPosPol].AreaFlow; 00681 } 00682 return aFlowFlowTotal; 00683 }
int Map_MappingGetMaxLevel | ( | Map_Man_t * | pMan | ) |
Function*************************************************************
Synopsis [Sets up the mask.]
Description []
SideEffects []
SeeAlso []
Definition at line 925 of file mapperUtils.c.
00926 { 00927 int nLevelMax, i; 00928 nLevelMax = 0; 00929 for ( i = 0; i < pMan->nOutputs; i++ ) 00930 nLevelMax = ((unsigned)nLevelMax) > Map_Regular(pMan->pOutputs[i])->Level? 00931 nLevelMax : Map_Regular(pMan->pOutputs[i])->Level; 00932 return nLevelMax; 00933 }
float Map_MappingGetSwitching | ( | Map_Man_t * | pMan, | |
Map_NodeVec_t * | vMapping | |||
) |
Function*************************************************************
Synopsis [Computes the array of mapping.]
Description []
SideEffects []
SeeAlso []
Definition at line 184 of file mapperSwitch.c.
00185 { 00186 Map_Node_t * pNode; 00187 float Switch; 00188 int i; 00189 Switch = 0.0; 00190 for ( i = 0; i < vMapping->nSize; i++ ) 00191 { 00192 pNode = vMapping->pArray[i]; 00193 // at least one phase has the best cut assigned 00194 assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL ); 00195 // at least one phase is used in the mapping 00196 assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 ); 00197 // compute the array due to the supergate 00198 if ( Map_NodeIsAnd(pNode) ) 00199 { 00200 // count switching of the negative phase 00201 if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) ) 00202 Switch += pNode->Switching; 00203 // count switching of the positive phase 00204 if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) ) 00205 Switch += pNode->Switching; 00206 } 00207 // count switching of the interver if we need to implement one phase with another phase 00208 if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) || 00209 (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) ) 00210 Switch += pNode->Switching; // inverter switches the same as the node 00211 } 00212 // add buffers for each CO driven by a CI 00213 for ( i = 0; i < pMan->nOutputs; i++ ) 00214 if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) ) 00215 Switch += pMan->pOutputs[i]->Switching; 00216 return Switch; 00217 }
void Map_MappingMark_rec | ( | Map_Node_t * | pNode | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 382 of file mapperUtils.c.
00383 { 00384 assert( !Map_IsComplement(pNode) ); 00385 if ( pNode->fMark0 == 1 ) 00386 return; 00387 pNode->fMark0 = 1; 00388 if ( !Map_NodeIsAnd(pNode) ) 00389 return; 00390 // visit the transitive fanin of the selected cut 00391 Map_MappingMark_rec( Map_Regular(pNode->p1) ); 00392 Map_MappingMark_rec( Map_Regular(pNode->p2) ); 00393 }
int Map_MappingMatches | ( | Map_Man_t * | p | ) |
FUNCTION DEFINITIONS ///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 62 of file mapperMatch.c.
00063 { 00064 ProgressBar * pProgress; 00065 Map_Node_t * pNode; 00066 int i; 00067 00068 assert( p->fMappingMode >= 0 && p->fMappingMode <= 4 ); 00069 00070 // use the externally given PI arrival times 00071 if ( p->fMappingMode == 0 ) 00072 Map_MappingSetPiArrivalTimes( p ); 00073 00074 // estimate the fanouts 00075 if ( p->fMappingMode == 0 ) 00076 Map_MappingEstimateRefsInit( p ); 00077 else if ( p->fMappingMode == 1 ) 00078 Map_MappingEstimateRefs( p ); 00079 00080 // the PI cuts are matched in the cut computation package 00081 // in the loop below we match the internal nodes 00082 pProgress = Extra_ProgressBarStart( stdout, p->vAnds->nSize ); 00083 for ( i = 0; i < p->vAnds->nSize; i++ ) 00084 { 00085 // skip primary inputs and secondary nodes if mapping with choices 00086 pNode = p->vAnds->pArray[i]; 00087 if ( !Map_NodeIsAnd( pNode ) || pNode->pRepr ) 00088 continue; 00089 00090 // make sure that at least one non-trival cut is present 00091 if ( pNode->pCuts->pNext == NULL ) 00092 { 00093 printf( "\nError: A node in the mapping graph does not have feasible cuts.\n" ); 00094 return 0; 00095 } 00096 00097 // match negative phase 00098 if ( !Map_MatchNodePhase( p, pNode, 0 ) ) 00099 return 0; 00100 // match positive phase 00101 if ( !Map_MatchNodePhase( p, pNode, 1 ) ) 00102 return 0; 00103 00104 // make sure that at least one phase is mapped 00105 if ( pNode->pCutBest[0] == NULL && pNode->pCutBest[1] == NULL ) 00106 { 00107 printf( "\nError: Could not match both phases of AIG node %d.\n", pNode->Num ); 00108 printf( "Please make sure that the supergate library has equivalents of AND2 or NAND2.\n" ); 00109 printf( "If such supergates exist in the library, report a bug.\n" ); 00110 return 0; 00111 } 00112 00113 // if both phases are assigned, check if one of them can be dropped 00114 Map_NodeTryDroppingOnePhase( p, pNode ); 00115 // set the arrival times of the node using the best cuts 00116 Map_NodeTransferArrivalTimes( p, pNode ); 00117 00118 // update the progress bar 00119 Extra_ProgressBarUpdate( pProgress, i, "Matches ..." ); 00120 } 00121 Extra_ProgressBarStop( pProgress ); 00122 return 1; 00123 }
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 646 of file mapperUtils.c.
00647 { 00648 return pNode->nRefAct[fPosPol] > (int)pCut->M[fPosPol].pSuperBest->nFanLimit; 00649 }
void Map_MappingPrintOutputArrivals | ( | Map_Man_t * | p | ) |
Function*************************************************************
Synopsis [Prints a bunch of latest arriving outputs.]
Description []
SideEffects []
SeeAlso []
Definition at line 464 of file mapperUtils.c.
00465 { 00466 int pSorted[MAP_CO_LIST_SIZE]; 00467 Map_Time_t * pTimes; 00468 Map_Node_t * pNode; 00469 int fPhase, Limit, i; 00470 int MaxNameSize; 00471 00472 // determine the number of nodes to print 00473 Limit = (p->nOutputs > MAP_CO_LIST_SIZE)? MAP_CO_LIST_SIZE : p->nOutputs; 00474 00475 // determine the order 00476 Map_MappingFindLatest( p, pSorted, Limit ); 00477 00478 // determine max size of the node's name 00479 MaxNameSize = 0; 00480 for ( i = 0; i < Limit; i++ ) 00481 if ( MaxNameSize < (int)strlen(p->ppOutputNames[pSorted[i]]) ) 00482 MaxNameSize = strlen(p->ppOutputNames[pSorted[i]]); 00483 00484 // print the latest outputs 00485 for ( i = 0; i < Limit; i++ ) 00486 { 00487 // get the i-th latest output 00488 pNode = Map_Regular(p->pOutputs[pSorted[i]]); 00489 fPhase =!Map_IsComplement(p->pOutputs[pSorted[i]]); 00490 pTimes = pNode->tArrival + fPhase; 00491 // print out the best arrival time 00492 printf( "Output %-*s : ", MaxNameSize + 3, p->ppOutputNames[pSorted[i]] ); 00493 printf( "Delay = (%5.2f, %5.2f) ", (double)pTimes->Rise, (double)pTimes->Fall ); 00494 printf( "%s", fPhase? "POS" : "NEG" ); 00495 printf( "\n" ); 00496 } 00497 }
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 1017 of file mapperUtils.c.
01018 { 01019 Map_Node_t * pNode, * pTemp; 01020 int nChoiceNodes, nChoices; 01021 int i, LevelMax1, LevelMax2; 01022 01023 // report the number of levels 01024 LevelMax1 = Map_MappingGetMaxLevel( pMan ); 01025 pMan->nTravIds++; 01026 for ( i = 0; i < pMan->nOutputs; i++ ) 01027 Map_MappingUpdateLevel_rec( pMan, Map_Regular(pMan->pOutputs[i]), 0 ); 01028 LevelMax2 = Map_MappingGetMaxLevel( pMan ); 01029 01030 // report statistics about choices 01031 nChoiceNodes = nChoices = 0; 01032 for ( i = 0; i < pMan->vAnds->nSize; i++ ) 01033 { 01034 pNode = pMan->vAnds->pArray[i]; 01035 if ( pNode->pRepr == NULL && pNode->pNextE != NULL ) 01036 { // this is a choice node = the primary node that has equivalent nodes 01037 nChoiceNodes++; 01038 for ( pTemp = pNode; pTemp; pTemp = pTemp->pNextE ) 01039 nChoices++; 01040 } 01041 } 01042 printf( "Maximum level: Original = %d. Reduced due to choices = %d.\n", LevelMax1, LevelMax2 ); 01043 printf( "Choice stats: Choice nodes = %d. Total choices = %d.\n", nChoiceNodes, nChoices ); 01044 }
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 996 of file mapperUtils.c.
00997 { 00998 int i; 00999 pMan->nTravIds++; 01000 for ( i = 0; i < pMan->nOutputs; i++ ) 01001 Map_MappingUpdateLevel_rec( pMan, Map_Regular(pMan->pOutputs[i]), 1 ); 01002 }
void Map_MappingSetPlacementInfo | ( | Map_Man_t * | p | ) |
void Map_MappingSetRefs | ( | Map_Man_t * | pMan | ) |
Function*************************************************************
Synopsis [Computes actual reference counters.]
Description [Collects the nodes used in the mapping in array pMan->vMapping. Nodes are collected in reverse topological order to facilitate the computation of required times.]
SideEffects []
SeeAlso []
Definition at line 412 of file mapperRefs.c.
00413 { 00414 Map_Node_t * pNode, ** ppStore; 00415 int i, fPhase, LevelMax; 00416 00417 // clean all references 00418 for ( i = 0; i < pMan->vNodesAll->nSize; i++ ) 00419 { 00420 pNode = pMan->vNodesAll->pArray[i]; 00421 pNode->nRefAct[0] = 0; 00422 pNode->nRefAct[1] = 0; 00423 pNode->nRefAct[2] = 0; 00424 } 00425 00426 // find the largest level of a node 00427 LevelMax = 0; 00428 for ( i = 0; i < pMan->nOutputs; i++ ) 00429 if ( LevelMax < (int)Map_Regular(pMan->pOutputs[i])->Level ) 00430 LevelMax = Map_Regular(pMan->pOutputs[i])->Level; 00431 00432 // allocate place to store the nodes 00433 ppStore = ALLOC( Map_Node_t *, LevelMax + 1 ); 00434 memset( ppStore, 0, sizeof(Map_Node_t *) * (LevelMax + 1) ); 00435 00436 // visit nodes reachable from POs in the DFS order through the best cuts 00437 for ( i = 0; i < pMan->nOutputs; i++ ) 00438 { 00439 pNode = pMan->pOutputs[i]; 00440 fPhase = !Map_IsComplement(pNode); 00441 if ( !Map_NodeIsConst(pNode) ) 00442 Map_MappingSetRefs_rec( pMan, pNode, ppStore ); 00443 } 00444 00445 // reconnect the nodes in reverse topological order 00446 pMan->vMapping->nSize = 0; 00447 for ( i = LevelMax; i >= 0; i-- ) 00448 for ( pNode = ppStore[i]; pNode; pNode = (Map_Node_t *)pNode->pData0 ) 00449 Map_NodeVecPush( pMan->vMapping, pNode ); 00450 free( ppStore ); 00451 }
void Map_MappingSetupMask | ( | unsigned | uMask[], | |
int | nVarsMax | |||
) |
Function*************************************************************
Synopsis [Sets up the mask.]
Description []
SideEffects []
SeeAlso []
Definition at line 577 of file mapperUtils.c.
void Map_MappingShow | ( | Map_Man_t * | pMan, | |
char * | pFileName | |||
) |
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 719 of file mapperUtils.c.
00720 { 00721 qsort( (void *)vNodes->pArray, vNodes->nSize, sizeof(Map_Node_t *), 00722 (int (*)(const void *, const void *)) Map_CompareNodesByLevel ); 00723 // assert( Map_CompareNodesByLevel( vNodes->pArray, vNodes->pArray + vNodes->nSize - 1 ) <= 0 ); 00724 }
void Map_MappingTruths | ( | Map_Man_t * | pMan | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Derives truth tables for each cut.]
Description []
SideEffects []
SeeAlso []
Definition at line 44 of file mapperTruth.c.
00045 { 00046 ProgressBar * pProgress; 00047 Map_Node_t * pNode; 00048 Map_Cut_t * pCut; 00049 int nNodes, i; 00050 // compute the cuts for the POs 00051 nNodes = pMan->vAnds->nSize; 00052 pProgress = Extra_ProgressBarStart( stdout, nNodes ); 00053 for ( i = 0; i < nNodes; i++ ) 00054 { 00055 pNode = pMan->vAnds->pArray[i]; 00056 if ( !Map_NodeIsAnd( pNode ) ) 00057 continue; 00058 assert( pNode->pCuts ); 00059 assert( pNode->pCuts->nLeaves == 1 ); 00060 00061 // match the simple cut 00062 pNode->pCuts->M[0].uPhase = 0; 00063 pNode->pCuts->M[0].pSupers = pMan->pSuperLib->pSuperInv; 00064 pNode->pCuts->M[0].uPhaseBest = 0; 00065 pNode->pCuts->M[0].pSuperBest = pMan->pSuperLib->pSuperInv; 00066 00067 pNode->pCuts->M[1].uPhase = 0; 00068 pNode->pCuts->M[1].pSupers = pMan->pSuperLib->pSuperInv; 00069 pNode->pCuts->M[1].uPhaseBest = 1; 00070 pNode->pCuts->M[1].pSuperBest = pMan->pSuperLib->pSuperInv; 00071 00072 // match the rest of the cuts 00073 for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext ) 00074 Map_TruthsCut( pMan, pCut ); 00075 Extra_ProgressBarUpdate( pProgress, i, "Tables ..." ); 00076 } 00077 Extra_ProgressBarStop( pProgress ); 00078 }
void Map_MappingUnmark | ( | Map_Man_t * | pMan | ) |
Function*************************************************************
Synopsis [Unmarks the nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 338 of file mapperUtils.c.
00339 { 00340 int i; 00341 for ( i = 0; i < pMan->nOutputs; i++ ) 00342 Map_MappingUnmark_rec( Map_Regular(pMan->pOutputs[i]) ); 00343 }
void Map_MappingUnmark_rec | ( | Map_Node_t * | pNode | ) |
Function*************************************************************
Synopsis [Recursively unmarks the nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 356 of file mapperUtils.c.
00357 { 00358 assert( !Map_IsComplement(pNode) ); 00359 if ( pNode->fMark0 == 0 ) 00360 return; 00361 pNode->fMark0 = 0; 00362 if ( !Map_NodeIsAnd(pNode) ) 00363 return; 00364 Map_MappingUnmark_rec( Map_Regular(pNode->p1) ); 00365 Map_MappingUnmark_rec( Map_Regular(pNode->p2) ); 00366 // visit the equivalent nodes 00367 if ( pNode->pNextE ) 00368 Map_MappingUnmark_rec( pNode->pNextE ); 00369 }
void Map_MappingWireReport | ( | Map_Man_t * | p | ) |
void Map_MatchClean | ( | Map_Match_t * | pMatch | ) |
Function*************************************************************
Synopsis [Cleans the match.]
Description []
SideEffects []
SeeAlso []
Definition at line 344 of file mapperMatch.c.
00345 { 00346 memset( pMatch, 0, sizeof(Map_Match_t) ); 00347 pMatch->AreaFlow = MAP_FLOAT_LARGE; // unassigned 00348 pMatch->tArrive.Rise = MAP_FLOAT_LARGE; // unassigned 00349 pMatch->tArrive.Fall = MAP_FLOAT_LARGE; // unassigned 00350 pMatch->tArrive.Worst = MAP_FLOAT_LARGE; // unassigned 00351 }
int Map_MatchCompare | ( | Map_Man_t * | pMan, | |
Map_Match_t * | pM1, | |||
Map_Match_t * | pM2, | |||
int | fDoingArea | |||
) |
Function*************************************************************
Synopsis [Compares two matches.]
Description [Returns 1 if the second match is better. Otherwise returns 0.]
SideEffects []
SeeAlso []
Definition at line 364 of file mapperMatch.c.
00365 { 00366 if ( !fDoingArea ) 00367 { 00368 // compare the arrival times 00369 if ( pM1->tArrive.Worst < pM2->tArrive.Worst - pMan->fEpsilon ) 00370 return 0; 00371 if ( pM1->tArrive.Worst > pM2->tArrive.Worst + pMan->fEpsilon ) 00372 return 1; 00373 // compare the areas or area flows 00374 if ( pM1->AreaFlow < pM2->AreaFlow - pMan->fEpsilon ) 00375 return 0; 00376 if ( pM1->AreaFlow > pM2->AreaFlow + pMan->fEpsilon ) 00377 return 1; 00378 // compare the fanout limits 00379 if ( pM1->pSuperBest->nFanLimit > pM2->pSuperBest->nFanLimit ) 00380 return 0; 00381 if ( pM1->pSuperBest->nFanLimit < pM2->pSuperBest->nFanLimit ) 00382 return 1; 00383 // compare the number of leaves 00384 if ( pM1->pSuperBest->nFanins < pM2->pSuperBest->nFanins ) 00385 return 0; 00386 if ( pM1->pSuperBest->nFanins > pM2->pSuperBest->nFanins ) 00387 return 1; 00388 // otherwise prefer the old cut 00389 return 0; 00390 } 00391 else 00392 { 00393 // compare the areas or area flows 00394 if ( pM1->AreaFlow < pM2->AreaFlow - pMan->fEpsilon ) 00395 return 0; 00396 if ( pM1->AreaFlow > pM2->AreaFlow + pMan->fEpsilon ) 00397 return 1; 00398 // compare the arrival times 00399 if ( pM1->tArrive.Worst < pM2->tArrive.Worst - pMan->fEpsilon ) 00400 return 0; 00401 if ( pM1->tArrive.Worst > pM2->tArrive.Worst + pMan->fEpsilon ) 00402 return 1; 00403 // compare the fanout limits 00404 if ( pM1->pSuperBest->nFanLimit > pM2->pSuperBest->nFanLimit ) 00405 return 0; 00406 if ( pM1->pSuperBest->nFanLimit < pM2->pSuperBest->nFanLimit ) 00407 return 1; 00408 // compare the number of leaves 00409 if ( pM1->pSuperBest->nFanins < pM2->pSuperBest->nFanins ) 00410 return 0; 00411 if ( pM1->pSuperBest->nFanins > pM2->pSuperBest->nFanins ) 00412 return 1; 00413 // otherwise prefer the old cut 00414 return 0; 00415 } 00416 }
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 145 of file mapperCutUtils.c.
00146 { 00147 assert( pNode->pCutBest[fPhase]->M[fPhase].pSuperBest ); 00148 return (( pNode->pCutBest[fPhase]->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0); 00149 }
int Map_NodeReadRefPhaseAct | ( | Map_Node_t * | pNode, | |
int | fPhase | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Reads the actual reference counter of a phase.]
Description []
SideEffects []
SeeAlso []
Definition at line 45 of file mapperRefs.c.
float Map_NodeReadRefPhaseEst | ( | Map_Node_t * | pNode, | |
int | fPhase | |||
) |
Function*************************************************************
Synopsis [Reads the estimated reference counter of a phase.]
Description []
SideEffects []
SeeAlso []
Definition at line 65 of file mapperRefs.c.
00066 { 00067 assert( !Map_IsComplement(pNode) ); 00068 if ( pNode->pCutBest[0] && pNode->pCutBest[1] ) // both assigned 00069 return pNode->nRefEst[fPhase]; 00070 assert( pNode->pCutBest[0] || pNode->pCutBest[1] ); // at least one assigned 00071 // return pNode->nRefEst[0] + pNode->nRefEst[1]; 00072 return pNode->nRefEst[2]; 00073 }
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 42 of file mapperVec.c.
00043 { 00044 Map_NodeVec_t * p; 00045 p = ALLOC( Map_NodeVec_t, 1 ); 00046 if ( nCap > 0 && nCap < 16 ) 00047 nCap = 16; 00048 p->nSize = 0; 00049 p->nCap = nCap; 00050 p->pArray = p->nCap? ALLOC( Map_Node_t *, p->nCap ) : NULL; 00051 return p; 00052 }
void Map_NodeVecClear | ( | Map_NodeVec_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 150 of file mapperVec.c.
00151 { 00152 p->nSize = 0; 00153 }
void Map_NodeVecFree | ( | Map_NodeVec_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 65 of file mapperVec.c.
void Map_NodeVecGrow | ( | Map_NodeVec_t * | p, | |
int | nCapMin | |||
) |
Function*************************************************************
Synopsis [Resizes the vector to the given capacity.]
Description []
SideEffects []
SeeAlso []
Definition at line 114 of file mapperVec.c.
Map_Node_t* Map_NodeVecPop | ( | Map_NodeVec_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 210 of file mapperVec.c.
void Map_NodeVecPush | ( | Map_NodeVec_t * | p, | |
Map_Node_t * | Entry | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 166 of file mapperVec.c.
00167 { 00168 if ( p->nSize == p->nCap ) 00169 { 00170 if ( p->nCap < 16 ) 00171 Map_NodeVecGrow( p, 16 ); 00172 else 00173 Map_NodeVecGrow( p, 2 * p->nCap ); 00174 } 00175 p->pArray[p->nSize++] = Entry; 00176 }
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 189 of file mapperVec.c.
00190 { 00191 int i; 00192 for ( i = 0; i < p->nSize; i++ ) 00193 if ( p->pArray[i] == Entry ) 00194 return 1; 00195 Map_NodeVecPush( p, Entry ); 00196 return 0; 00197 }
Map_Node_t** Map_NodeVecReadArray | ( | Map_NodeVec_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 82 of file mapperVec.c.
00083 { 00084 return p->pArray; 00085 }
Map_Node_t* Map_NodeVecReadEntry | ( | Map_NodeVec_t * | p, | |
int | i | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 266 of file mapperVec.c.
int Map_NodeVecReadSize | ( | Map_NodeVec_t * | p | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 98 of file mapperVec.c.
00099 { 00100 return p->nSize; 00101 }
void Map_NodeVecRemove | ( | Map_NodeVec_t * | p, | |
Map_Node_t * | Entry | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 226 of file mapperVec.c.
void Map_NodeVecShrink | ( | Map_NodeVec_t * | p, | |
int | nSizeNew | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 133 of file mapperVec.c.
void Map_NodeVecSortByLevel | ( | Map_NodeVec_t * | p | ) |
Function*************************************************************
Synopsis [Sorting the entries by their integer value.]
Description []
SideEffects []
SeeAlso []
Definition at line 283 of file mapperVec.c.
00284 { 00285 qsort( (void *)p->pArray, p->nSize, sizeof(Map_Node_t *), 00286 (int (*)(const void *, const void *)) Map_NodeVecCompareLevels ); 00287 }
void Map_NodeVecWriteEntry | ( | Map_NodeVec_t * | p, | |
int | i, | |||
Map_Node_t * | Entry | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 249 of file mapperVec.c.
Map_SuperLib_t* Map_SuperLibCreate | ( | char * | pFileName, | |
char * | pExcludeFile, | |||
bool | fAlgorithm, | |||
bool | fVerbose | |||
) |
CFile****************************************************************
FileName [mapperLib.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 [
] 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 48 of file mapperLib.c.
00049 { 00050 Map_SuperLib_t * p; 00051 int clk; 00052 00053 // start the supergate library 00054 p = ALLOC( Map_SuperLib_t, 1 ); 00055 memset( p, 0, sizeof(Map_SuperLib_t) ); 00056 p->pName = pFileName; 00057 p->fVerbose = fVerbose; 00058 p->mmSupers = Extra_MmFixedStart( sizeof(Map_Super_t) ); 00059 p->mmEntries = Extra_MmFixedStart( sizeof(Map_HashEntry_t) ); 00060 p->mmForms = Extra_MmFlexStart(); 00061 Map_MappingSetupTruthTables( p->uTruths ); 00062 00063 // start the hash table 00064 p->tTableC = Map_SuperTableCreate( p ); 00065 p->tTable = Map_SuperTableCreate( p ); 00066 00067 // read the supergate library from file 00068 clk = clock(); 00069 if ( fAlgorithm ) 00070 { 00071 if ( !Map_LibraryReadTree( p, pFileName, pExcludeFile ) ) 00072 { 00073 Map_SuperLibFree( p ); 00074 return NULL; 00075 } 00076 } 00077 else 00078 { 00079 if ( pExcludeFile != 0 ) 00080 { 00081 printf ("Error: Exclude file support not present for old format. Stop.\n"); 00082 return NULL; 00083 } 00084 if ( !Map_LibraryRead( p, pFileName ) ) 00085 { 00086 Map_SuperLibFree( p ); 00087 return NULL; 00088 } 00089 } 00090 assert( p->nVarsMax > 0 ); 00091 00092 // report the stats 00093 if ( fVerbose ) { 00094 printf( "Loaded %d unique %d-input supergates from \"%s\". ", 00095 p->nSupersReal, p->nVarsMax, pFileName ); 00096 PRT( "Time", clock() - clk ); 00097 } 00098 00099 // assign the interver parameters 00100 p->pGateInv = Mio_LibraryReadInv( p->pGenlib ); 00101 p->tDelayInv.Rise = Mio_LibraryReadDelayInvRise( p->pGenlib ); 00102 p->tDelayInv.Fall = Mio_LibraryReadDelayInvFall( p->pGenlib ); 00103 p->tDelayInv.Worst = MAP_MAX( p->tDelayInv.Rise, p->tDelayInv.Fall ); 00104 p->AreaInv = Mio_LibraryReadAreaInv( p->pGenlib ); 00105 p->AreaBuf = Mio_LibraryReadAreaBuf( p->pGenlib ); 00106 00107 // assign the interver supergate 00108 p->pSuperInv = (Map_Super_t *)Extra_MmFixedEntryFetch( p->mmSupers ); 00109 memset( p->pSuperInv, 0, sizeof(Map_Super_t) ); 00110 p->pSuperInv->Num = -1; 00111 p->pSuperInv->nGates = 1; 00112 p->pSuperInv->nFanins = 1; 00113 p->pSuperInv->nFanLimit = 10; 00114 p->pSuperInv->pFanins[0] = p->ppSupers[0]; 00115 p->pSuperInv->pRoot = p->pGateInv; 00116 p->pSuperInv->Area = p->AreaInv; 00117 p->pSuperInv->tDelayMax = p->tDelayInv; 00118 p->pSuperInv->tDelaysR[0].Rise = MAP_NO_VAR; 00119 p->pSuperInv->tDelaysR[0].Fall = p->tDelayInv.Rise; 00120 p->pSuperInv->tDelaysF[0].Rise = p->tDelayInv.Fall; 00121 p->pSuperInv->tDelaysF[0].Fall = MAP_NO_VAR; 00122 return p; 00123 }
void Map_SuperLibFree | ( | Map_SuperLib_t * | p | ) |
Function*************************************************************
Synopsis [Deallocates the supergate library.]
Description []
SideEffects []
SeeAlso []
Definition at line 137 of file mapperLib.c.
00138 { 00139 if ( p == NULL ) return; 00140 if ( p->pGenlib ) 00141 { 00142 assert( p->pGenlib == Abc_FrameReadLibGen() ); 00143 Mio_LibraryDelete( p->pGenlib ); 00144 Abc_FrameSetLibGen( NULL ); 00145 } 00146 if ( p->tTableC ) 00147 Map_SuperTableFree( p->tTableC ); 00148 if ( p->tTable ) 00149 Map_SuperTableFree( p->tTable ); 00150 Extra_MmFixedStop( p->mmSupers ); 00151 Extra_MmFixedStop( p->mmEntries ); 00152 Extra_MmFlexStop( p->mmForms ); 00153 FREE( p->ppSupers ); 00154 FREE( p ); 00155 }
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 45 of file mapperTable.c.
00046 { 00047 Map_HashTable_t * p; 00048 // allocate the table 00049 p = ALLOC( Map_HashTable_t, 1 ); 00050 memset( p, 0, sizeof(Map_HashTable_t) ); 00051 p->mmMan = pLib->mmEntries; 00052 // allocate and clean the bins 00053 p->nBins = Cudd_Prime(20000); 00054 p->pBins = ALLOC( Map_HashEntry_t *, p->nBins ); 00055 memset( p->pBins, 0, sizeof(Map_HashEntry_t *) * p->nBins ); 00056 return p; 00057 }
void Map_SuperTableFree | ( | Map_HashTable_t * | p | ) |
Function*************************************************************
Synopsis [Deallocates the supergate hash table.]
Description []
SideEffects []
SeeAlso []
Definition at line 71 of file mapperTable.c.
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 134 of file mapperTable.c.
00135 { 00136 Map_HashEntry_t * pEnt; 00137 unsigned Key; 00138 // resize the table 00139 if ( p->nEntries >= 2 * p->nBins ) 00140 Map_SuperTableResize( p ); 00141 // check if this entry already exists 00142 Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->nBins ); 00143 for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext ) 00144 if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] ) 00145 return 1; 00146 // add the new hash table entry to the table 00147 pEnt = (Map_HashEntry_t *)Extra_MmFixedEntryFetch( p->mmMan ); 00148 memset( pEnt, 0, sizeof(Map_HashEntry_t) ); 00149 pEnt->uTruth[0] = uTruth[0]; 00150 pEnt->uTruth[1] = uTruth[1]; 00151 pEnt->pGates = pGate; 00152 pEnt->uPhase = uPhase; 00153 // add the hash table to the corresponding linked list in the table 00154 pEnt->pNext = p->pBins[Key]; 00155 p->pBins[Key] = pEnt; 00156 p->nEntries++; 00157 /* 00158 printf( "Adding gate: %10u ", Key ); 00159 Map_LibraryPrintSupergate( pGate ); 00160 Extra_PrintBinary( stdout, uTruth, 32 ); 00161 printf( "\n" ); 00162 */ 00163 return 0; 00164 }
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 89 of file mapperTable.c.
00090 { 00091 Map_HashEntry_t * pEnt; 00092 unsigned Key; 00093 // resize the table 00094 if ( p->nEntries >= 2 * p->nBins ) 00095 Map_SuperTableResize( p ); 00096 // check if another supergate with the same canonical form exists 00097 Key = MAP_TABLE_HASH( uTruthC[0], uTruthC[1], p->nBins ); 00098 for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext ) 00099 if ( pEnt->uTruth[0] == uTruthC[0] && pEnt->uTruth[1] == uTruthC[1] ) 00100 break; 00101 // create a new entry if it does not exist 00102 if ( pEnt == NULL ) 00103 { 00104 // add the new entry to the table 00105 pEnt = (Map_HashEntry_t *)Extra_MmFixedEntryFetch( p->mmMan ); 00106 memset( pEnt, 0, sizeof(Map_HashEntry_t) ); 00107 pEnt->uTruth[0] = uTruthC[0]; 00108 pEnt->uTruth[1] = uTruthC[1]; 00109 // add the hash table entry to the corresponding linked list in the table 00110 pEnt->pNext = p->pBins[Key]; 00111 p->pBins[Key] = pEnt; 00112 p->nEntries++; 00113 } 00114 // add the supergate to the entry 00115 pGate->pNext = pEnt->pGates; 00116 pEnt->pGates = pGate; 00117 return 0; 00118 }
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 205 of file mapperTable.c.
00206 { 00207 Map_HashEntry_t * pEnt; 00208 unsigned Key; 00209 Key = MAP_TABLE_HASH( uTruth[0], uTruth[1], p->nBins ); 00210 for ( pEnt = p->pBins[Key]; pEnt; pEnt = pEnt->pNext ) 00211 if ( pEnt->uTruth[0] == uTruth[0] && pEnt->uTruth[1] == uTruth[1] ) 00212 { 00213 *puPhase = pEnt->uPhase; 00214 return pEnt->pGates; 00215 } 00216 return NULL; 00217 }
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 312 of file mapperTable.c.
00313 { 00314 Map_HashEntry_t * pEnt; 00315 Map_Super_t ** ppSupers; 00316 Map_Super_t * pSuper; 00317 int nSupers, i; 00318 00319 // copy all the supergates into one array 00320 ppSupers = ALLOC( Map_Super_t *, nSupersMax ); 00321 nSupers = 0; 00322 for ( i = 0; i < p->nBins; i++ ) 00323 for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext ) 00324 for ( pSuper = pEnt->pGates; pSuper; pSuper = pSuper->pNext ) 00325 ppSupers[nSupers++] = pSuper; 00326 00327 // sort by usage 00328 qsort( (void *)ppSupers, nSupers, sizeof(Map_Super_t *), 00329 (int (*)(const void *, const void *)) Map_SuperTableCompareSupergates ); 00330 assert( Map_SuperTableCompareSupergates( ppSupers, ppSupers + nSupers - 1 ) <= 0 ); 00331 00332 // print out the "top ten" 00333 // for ( i = 0; i < nSupers; i++ ) 00334 for ( i = 0; i < 10; i++ ) 00335 { 00336 if ( ppSupers[i]->nUsed == 0 ) 00337 break; 00338 printf( "%5d : ", ppSupers[i]->nUsed ); 00339 printf( "%5d ", ppSupers[i]->Num ); 00340 printf( "A = %5.2f ", ppSupers[i]->Area ); 00341 printf( "D = %5.2f ", ppSupers[i]->tDelayMax.Rise ); 00342 printf( "%s", ppSupers[i]->pFormula ); 00343 printf( "\n" ); 00344 } 00345 free( ppSupers ); 00346 }
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 359 of file mapperTable.c.
00360 { 00361 Map_HashEntry_t * pEnt; 00362 Map_Super_t ** ppSupers; 00363 Map_Super_t * pSuper; 00364 int nSupers, i, k; 00365 00366 ppSupers = ALLOC( Map_Super_t *, nSupersMax ); 00367 for ( i = 0; i < p->nBins; i++ ) 00368 for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext ) 00369 { 00370 // collect the gates in this entry 00371 nSupers = 0; 00372 for ( pSuper = pEnt->pGates; pSuper; pSuper = pSuper->pNext ) 00373 { 00374 // skip supergates, whose root is the AND gate 00375 // if ( strcmp( Mio_GateReadName(pSuper->pRoot), "and" ) == 0 ) 00376 // continue; 00377 ppSupers[nSupers++] = pSuper; 00378 } 00379 pEnt->pGates = NULL; 00380 if ( nSupers == 0 ) 00381 continue; 00382 // sort the gates by delay 00383 qsort( (void *)ppSupers, nSupers, sizeof(Map_Super_t *), 00384 (int (*)(const void *, const void *)) Map_SuperTableCompareGatesInList ); 00385 assert( Map_SuperTableCompareGatesInList( ppSupers, ppSupers + nSupers - 1 ) <= 0 ); 00386 // link them in the reverse order 00387 for ( k = 0; k < nSupers; k++ ) 00388 { 00389 ppSupers[k]->pNext = pEnt->pGates; 00390 pEnt->pGates = ppSupers[k]; 00391 } 00392 // save the number of supergates in the list 00393 pEnt->pGates->nSupers = nSupers; 00394 } 00395 FREE( ppSupers ); 00396 }
float Map_SwitchCutDeref | ( | Map_Node_t * | pNode, | |
Map_Cut_t * | pCut, | |||
int | fPhase | |||
) |
function*************************************************************
synopsis [References the cut.]
description []
sideeffects []
seealso []
Definition at line 79 of file mapperSwitch.c.
00080 { 00081 return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference 00082 }
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 42 of file mapperSwitch.c.
00043 { 00044 float aResult, aResult2; 00045 // assert( pNode->Switching > 0 ); 00046 aResult2 = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference 00047 aResult = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference 00048 // assert( aResult == aResult2 ); 00049 return aResult; 00050 }
float Map_SwitchCutRef | ( | Map_Node_t * | pNode, | |
Map_Cut_t * | pCut, | |||
int | fPhase | |||
) |
function*************************************************************
synopsis [References the cut.]
description []
sideeffects []
seealso []
Definition at line 63 of file mapperSwitch.c.
00064 { 00065 return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference 00066 }
float Map_TimeComputeArrivalMax | ( | Map_Man_t * | p | ) |
Function*************************************************************
Synopsis [Computes the maximum arrival times.]
Description []
SideEffects []
SeeAlso []
Definition at line 168 of file mapperTime.c.
00169 { 00170 float tReqMax, tReq; 00171 int i, fPhase; 00172 // get the critical PO arrival time 00173 tReqMax = -MAP_FLOAT_LARGE; 00174 for ( i = 0; i < p->nOutputs; i++ ) 00175 { 00176 if ( Map_NodeIsConst(p->pOutputs[i]) ) 00177 continue; 00178 fPhase = !Map_IsComplement(p->pOutputs[i]); 00179 tReq = Map_Regular(p->pOutputs[i])->tArrival[fPhase].Worst; 00180 tReqMax = MAP_MAX( tReqMax, tReq ); 00181 } 00182 return tReqMax; 00183 }
void Map_TimeComputeRequired | ( | Map_Man_t * | p, | |
float | fRequired | |||
) |
Function*************************************************************
Synopsis [Computes the required times of all nodes.]
Description [This procedure assumes that the nodes used in the mapping are collected in p->vMapping.]
SideEffects []
SeeAlso []
Definition at line 229 of file mapperTime.c.
00230 { 00231 Map_Time_t * ptTime; 00232 int fPhase, i; 00233 00234 // clean the required times 00235 for ( i = 0; i < p->vAnds->nSize; i++ ) 00236 { 00237 p->vAnds->pArray[i]->tRequired[0].Rise = MAP_FLOAT_LARGE; 00238 p->vAnds->pArray[i]->tRequired[0].Fall = MAP_FLOAT_LARGE; 00239 p->vAnds->pArray[i]->tRequired[0].Worst = MAP_FLOAT_LARGE; 00240 p->vAnds->pArray[i]->tRequired[1].Rise = MAP_FLOAT_LARGE; 00241 p->vAnds->pArray[i]->tRequired[1].Fall = MAP_FLOAT_LARGE; 00242 p->vAnds->pArray[i]->tRequired[1].Worst = MAP_FLOAT_LARGE; 00243 } 00244 00245 // set the required times for the POs 00246 for ( i = 0; i < p->nOutputs; i++ ) 00247 { 00248 fPhase = !Map_IsComplement(p->pOutputs[i]); 00249 ptTime = Map_Regular(p->pOutputs[i])->tRequired + fPhase; 00250 ptTime->Rise = ptTime->Fall = ptTime->Worst = fRequired; 00251 } 00252 00253 // sorts the nodes in the decreasing order of levels 00254 // this puts the nodes in reverse topological order 00255 // Map_MappingSortByLevel( p, p->vMapping ); 00256 // the array is already sorted by construction in Map_MappingSetRefs() 00257 00258 Map_TimePropagateRequired( p, p->vMapping ); 00259 }
void Map_TimeComputeRequiredGlobal | ( | Map_Man_t * | p | ) |
Function*************************************************************
Synopsis [Computes the required times of all nodes.]
Description []
SideEffects []
SeeAlso []
Definition at line 196 of file mapperTime.c.
00197 { 00198 p->fRequiredGlo = Map_TimeComputeArrivalMax( p ); 00199 // update the required times according to the target 00200 if ( p->DelayTarget != -1 ) 00201 { 00202 if ( p->fRequiredGlo > p->DelayTarget + p->fEpsilon ) 00203 { 00204 if ( p->fMappingMode == 1 ) 00205 printf( "Cannot meet the target required times (%4.2f). Continue anyway.\n", p->DelayTarget ); 00206 } 00207 else if ( p->fRequiredGlo < p->DelayTarget - p->fEpsilon ) 00208 { 00209 if ( p->fMappingMode == 1 ) 00210 printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->fRequiredGlo, p->DelayTarget ); 00211 p->fRequiredGlo = p->DelayTarget; 00212 } 00213 } 00214 Map_TimeComputeRequired( p, p->fRequiredGlo ); 00215 }
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 92 of file mapperTime.c.
00093 { 00094 Map_Match_t * pM = pCut->M + fPhase; 00095 Map_Super_t * pSuper = pM->pSuperBest; 00096 unsigned uPhaseTot = pM->uPhaseBest; 00097 Map_Time_t * ptArrRes = &pM->tArrive; 00098 Map_Time_t * ptArrIn; 00099 bool fPinPhase; 00100 float tDelay; 00101 int i; 00102 00103 ptArrRes->Rise = ptArrRes->Fall = 0.0; 00104 ptArrRes->Worst = MAP_FLOAT_LARGE; 00105 for ( i = pCut->nLeaves - 1; i >= 0; i-- ) 00106 { 00107 // get the phase of the given pin 00108 fPinPhase = ((uPhaseTot & (1 << i)) == 0); 00109 ptArrIn = pCut->ppLeaves[i]->tArrival + fPinPhase; 00110 00111 // get the rise of the output due to rise of the inputs 00112 if ( pSuper->tDelaysR[i].Rise > 0 ) 00113 { 00114 tDelay = ptArrIn->Rise + pSuper->tDelaysR[i].Rise; 00115 if ( tDelay > tWorstLimit ) 00116 return MAP_FLOAT_LARGE; 00117 if ( ptArrRes->Rise < tDelay ) 00118 ptArrRes->Rise = tDelay; 00119 } 00120 00121 // get the rise of the output due to fall of the inputs 00122 if ( pSuper->tDelaysR[i].Fall > 0 ) 00123 { 00124 tDelay = ptArrIn->Fall + pSuper->tDelaysR[i].Fall; 00125 if ( tDelay > tWorstLimit ) 00126 return MAP_FLOAT_LARGE; 00127 if ( ptArrRes->Rise < tDelay ) 00128 ptArrRes->Rise = tDelay; 00129 } 00130 00131 // get the fall of the output due to rise of the inputs 00132 if ( pSuper->tDelaysF[i].Rise > 0 ) 00133 { 00134 tDelay = ptArrIn->Rise + pSuper->tDelaysF[i].Rise; 00135 if ( tDelay > tWorstLimit ) 00136 return MAP_FLOAT_LARGE; 00137 if ( ptArrRes->Fall < tDelay ) 00138 ptArrRes->Fall = tDelay; 00139 } 00140 00141 // get the fall of the output due to fall of the inputs 00142 if ( pSuper->tDelaysF[i].Fall > 0 ) 00143 { 00144 tDelay = ptArrIn->Fall + pSuper->tDelaysF[i].Fall; 00145 if ( tDelay > tWorstLimit ) 00146 return MAP_FLOAT_LARGE; 00147 if ( ptArrRes->Fall < tDelay ) 00148 ptArrRes->Fall = tDelay; 00149 } 00150 } 00151 // return the worst-case of rise/fall arrival times 00152 ptArrRes->Worst = MAP_MAX(ptArrRes->Rise, ptArrRes->Fall); 00153 return ptArrRes->Worst; 00154 }
void Map_TimeCutComputeArrival_rec | ( | Map_Cut_t * | pCut, | |
int | fPhase | |||
) |
Function*************************************************************
Synopsis [Computes the arrival times of the cut recursively.]
Description [When computing the arrival time for the previously unused cuts, their arrival time may be incorrect because their fanins have incorrect arrival time. This procedure is called to fix this problem.]
SideEffects []
SeeAlso []
Definition at line 66 of file mapperTime.c.
00067 { 00068 int i, fPhaseLeaf; 00069 for ( i = 0; i < pCut->nLeaves; i++ ) 00070 { 00071 fPhaseLeaf = Map_CutGetLeafPhase( pCut, fPhase, i ); 00072 if ( pCut->ppLeaves[i]->nRefAct[fPhaseLeaf] > 0 ) 00073 continue; 00074 Map_TimeCutComputeArrival_rec( pCut->ppLeaves[i]->pCutBest[fPhaseLeaf], fPhaseLeaf ); 00075 } 00076 Map_TimeCutComputeArrival( NULL, pCut, fPhase, MAP_FLOAT_LARGE ); 00077 }
float Map_TimeCutFanoutDelay | ( | Map_Node_t * | pNode, | |
Map_Cut_t * | pCut, | |||
int | fPhase | |||
) |
float Map_TimeMatchWithInverter | ( | Map_Man_t * | p, | |
Map_Match_t * | pMatch | |||
) |
FUNCTION DEFINITIONS ///function*************************************************************
synopsis [Computes the exact area associated with the cut.]
description []
sideeffects []
seealso []
Definition at line 44 of file mapperTime.c.
float Map_TimeNodeFanoutDelay | ( | Map_Node_t * | pNode, | |
int | fPhase | |||
) |
int Map_TruthCountOnes | ( | unsigned * | uTruth, | |
int | nLeaves | |||
) |
int Map_TruthDetectTwoFirst | ( | unsigned * | uTruth, | |
int | nLeaves | |||
) |