00001
00019 #include "fpgaInt.h"
00020
00024
00028
00040 float Fpga_CutGetSwitchDerefed( Fpga_Man_t * pMan, Fpga_Node_t * pNode, Fpga_Cut_t * pCut )
00041 {
00042 float aResult, aResult2;
00043 aResult2 = Fpga_CutRefSwitch( pMan, pNode, pCut, 0 );
00044 aResult = Fpga_CutDerefSwitch( pMan, pNode, pCut, 0 );
00045
00046 return aResult;
00047 }
00048
00060 float Fpga_CutRefSwitch( Fpga_Man_t * pMan, Fpga_Node_t * pNode, Fpga_Cut_t * pCut, int fFanouts )
00061 {
00062 Fpga_Node_t * pNodeChild;
00063 float aArea;
00064 int i;
00065
00066 aArea = pNode->Switching;
00067 if ( pCut->nLeaves == 1 )
00068 return aArea;
00069
00070 for ( i = 0; i < pCut->nLeaves; i++ )
00071 {
00072 pNodeChild = pCut->ppLeaves[i];
00073 assert( pNodeChild->nRefs >= 0 );
00074 if ( pNodeChild->nRefs++ > 0 )
00075 continue;
00076 aArea += Fpga_CutRefSwitch( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
00077 }
00078 return aArea;
00079 }
00080
00092 float Fpga_CutDerefSwitch( Fpga_Man_t * pMan, Fpga_Node_t * pNode, Fpga_Cut_t * pCut, int fFanouts )
00093 {
00094 Fpga_Node_t * pNodeChild;
00095 float aArea;
00096 int i;
00097
00098 aArea = pNode->Switching;
00099 if ( pCut->nLeaves == 1 )
00100 return aArea;
00101
00102 for ( i = 0; i < pCut->nLeaves; i++ )
00103 {
00104 pNodeChild = pCut->ppLeaves[i];
00105 assert( pNodeChild->nRefs > 0 );
00106 if ( --pNodeChild->nRefs > 0 )
00107 continue;
00108 aArea += Fpga_CutDerefSwitch( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
00109 }
00110 return aArea;
00111 }
00112
00124 float Fpga_MappingGetSwitching( Fpga_Man_t * pMan, Fpga_NodeVec_t * vMapping )
00125 {
00126 Fpga_Node_t * pNode;
00127 float Switch;
00128 int i;
00129 Switch = 0.0;
00130 for ( i = 0; i < vMapping->nSize; i++ )
00131 {
00132 pNode = vMapping->pArray[i];
00133
00134 assert( !Fpga_NodeIsAnd(pNode) || pNode->pCutBest != NULL );
00135
00136 assert( pNode->nRefs > 0 );
00137
00138 Switch += pNode->Switching;
00139 }
00140
00141 for ( i = 0; i < pMan->nOutputs; i++ )
00142 if ( Fpga_NodeIsVar(pMan->pOutputs[i]) && !Fpga_IsComplement(pMan->pOutputs[i]) )
00143 Switch += pMan->pOutputs[i]->Switching;
00144 return Switch;
00145 }
00146
00150
00151