Generic hardware access library
|
00001 #ifndef __AMSortFunctor 00002 #define __AMSortFunctor 00003 00004 namespace HAL { 00005 00006 class AMSortFunctor { 00007 public: 00008 AMSortFunctor() { 00009 for ( int i = 0; i < NUM_AMs; i++ ) { 00010 lookupTable[ i ] = 0; 00011 } 00012 00013 // The lookup table with the priorities: 00014 // The am is the index into the table; the contents of the 00015 // table is the priority. Higher values mean higher priority. 00016 // A40 is not supported. 00017 00018 // A32 accesses (at the moment D64 (MBLT) not supported) 00019 lookupTable[ 0x08 ] = 0; 00020 lookupTable[ 0x0c ] = 0; 00021 lookupTable[ 0x0b ] = 64; 00022 lookupTable[ 0x0f ] = 63; 00023 lookupTable[ 0x09 ] = 62; 00024 lookupTable[ 0x0d ] = 61; 00025 lookupTable[ 0x0a ] = 60; 00026 lookupTable[ 0x0e ] = 59; 00027 00028 // A24 accesses (at the moment D64 (MBLT) not supported) 00029 lookupTable[ 0x38 ] = 0; 00030 lookupTable[ 0x3c ] = 0; 00031 lookupTable[ 0x3b ] = 58; 00032 lookupTable[ 0x3f ] = 57; 00033 lookupTable[ 0x39 ] = 56; 00034 lookupTable[ 0x3d ] = 55; 00035 lookupTable[ 0x3a ] = 54; 00036 lookupTable[ 0x3e ] = 53; 00037 00038 // A16 accesses 00039 lookupTable[ 0x29 ] = 52; 00040 lookupTable[ 0x2d ] = 51; 00041 00042 }; 00043 00044 bool operator() ( uint32_t AM1, uint32_t AM2 ) { 00045 if ( AM1 < 64 && AM2 < 64 ) { 00046 return lookupTable[ AM1 ] > lookupTable[ AM2 ]; // sort in descending order 00047 } else if ( AM1 >= 64 ) { 00048 return true; 00049 } 00050 return false; 00051 } 00052 private: 00053 static const int NUM_AMs = 64; 00054 uint32_t lookupTable[NUM_AMs]; 00055 }; 00056 00057 } /* namespace HAL */ 00058 00059 #endif /* __AMSortFunctor */