- Timestamp:
- Jun 23, 2014, 3:43:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_io_bridge/caba/source/include/transaction_tab_io.h
r240 r715 9 9 #define DEBUG_IOB_TRANSACTION 0 10 10 11 // The index of Transaction Tab Entry corresponds to the trdid of the VCI packet on XRAM network12 13 11 //////////////////////////////////////////////////////////////////////// 14 12 // A transaction tab entry … … 16 14 17 15 class TransactionTabIOEntry { 18 typedef uint32_t 16 typedef uint32_t size_t; 19 17 20 18 public: 21 bool valid; // entry valid22 size_t srcid; // processor requesting the transaction23 size_t trdid; // processor requesting thetransaction19 bool valid; // valid entry 20 size_t srcid; // initiator requesting the transaction 21 size_t trdid; // thread ID of transaction 24 22 25 23 ///////////////////////////////////////////////////////////////////// … … 28 26 void init() 29 27 { 30 valid 28 valid = false; 31 29 } 32 30 … … 38 36 void copy(const TransactionTabIOEntry &source) 39 37 { 40 valid 41 srcid 42 trdid 38 valid = source.valid; 39 srcid = source.srcid; 40 trdid = source.trdid; 43 41 } 44 42 … … 47 45 //////////////////////////////////////////////////////////////////// 48 46 void print(){ 49 std::cout << "valid = " << valid << std::endl; 50 std::cout << "srcid = " << srcid << std::endl; 51 std::cout << "trdid = " << trdid << std::endl; 52 } 53 54 ///////////////////////////////////////////////////////////////////// 55 // Constructors 47 std::cout << " valid = " << valid << std::hex 48 << " / srcid = " << srcid 49 << " / trdid = " << trdid << std::dec 50 << std::endl; 51 } 52 53 ///////////////////////////////////////////////////////////////////// 54 // Constructors 56 55 ///////////////////////////////////////////////////////////////////// 57 56 58 57 TransactionTabIOEntry() 58 { 59 valid = false; 60 } 61 62 TransactionTabIOEntry(const TransactionTabIOEntry &source){ 63 valid = source.valid; 64 srcid = source.srcid; 65 trdid = source.trdid; 66 } 67 68 }; // end class TransactionTabIOEntry 69 70 //////////////////////////////////////////////////////////////////////// 71 // The transaction tab 72 //////////////////////////////////////////////////////////////////////// 73 class TransactionTabIO{ 74 private: 75 const size_t size_tab; // The size of the tab 76 77 public: 78 TransactionTabIOEntry *tab; // The transaction tab 79 80 //////////////////////////////////////////////////////////////////// 81 // Constructors 82 //////////////////////////////////////////////////////////////////// 83 TransactionTabIO(size_t n_entries) : size_tab(n_entries) 84 { 85 tab = new TransactionTabIOEntry[size_tab]; 86 } 87 88 ~TransactionTabIO() 89 { 90 delete [] tab; 91 } 92 93 ///////////////////////////////////////////////////////////////////// 94 // The size() function returns the size of the tab 95 ///////////////////////////////////////////////////////////////////// 96 const size_t& size() 97 { 98 return size_tab; 99 } 100 101 ///////////////////////////////////////////////////////////////////// 102 // The init() function initializes the transaction tab entries 103 ///////////////////////////////////////////////////////////////////// 104 void init() 105 { 106 for ( size_t index = 0; index < size_tab; index++) 59 107 { 60 valid=false;108 tab[index].init(); 61 109 } 62 63 TransactionTabIOEntry(const TransactionTabIOEntry &source){64 valid = source.valid;65 srcid = source.srcid;66 trdid = source.trdid;67 }68 69 }; // end class TransactionTabIOEntry70 71 ////////////////////////////////////////////////////////////////////////72 // The transaction tab73 ////////////////////////////////////////////////////////////////////////74 class TransactionTabIO{75 // typedef uint32_t size_t;76 77 private:78 size_t size_tab; // The size of the tab79 80 public:81 TransactionTabIOEntry *tab; // The transaction tab82 83 ////////////////////////////////////////////////////////////////////84 // Constructors85 ////////////////////////////////////////////////////////////////////86 TransactionTabIO()87 {88 size_tab=0;89 tab=NULL;90 }91 92 TransactionTabIO(size_t n_entries)93 {94 size_tab = n_entries;95 tab = new TransactionTabIOEntry[size_tab];96 }97 98 ~TransactionTabIO()99 {100 delete [] tab;101 }102 103 /////////////////////////////////////////////////////////////////////104 // The size() function returns the size of the tab105 /////////////////////////////////////////////////////////////////////106 size_t size()107 {108 return size_tab;109 }110 111 /////////////////////////////////////////////////////////////////////112 // The init() function initializes the transaction tab entries113 /////////////////////////////////////////////////////////////////////114 void init()115 {116 for ( size_t i=0; i<size_tab; i++) {117 tab[i].init();118 }119 110 } 120 111 … … 126 117 void print(const size_t index) 127 118 { 128 assert( (index < size_tab) 129 && "Invalid Transaction Tab Entry"); 119 assert( (index < size_tab) && "Invalid Transaction Tab Entry"); 130 120 tab[index].print(); 131 121 return; … … 133 123 134 124 ///////////////////////////////////////////////////////////////////// 125 // The printTrace() function prints all transaction tab entries 126 ///////////////////////////////////////////////////////////////////// 127 void printTrace() 128 { 129 for (size_t index = 0; index < size_tab; index++) 130 { 131 tab[index].print(); 132 } 133 } 134 135 ///////////////////////////////////////////////////////////////////// 135 136 // The read() function returns a transaction tab entry. 136 137 // Arguments : 137 138 // - index : the index of the entry to read 138 139 ///////////////////////////////////////////////////////////////////// 139 TransactionTabIOEntry read(const size_t index) 140 { 141 assert( (index < size_tab) 142 && "Invalid Transaction Tab Entry"); 140 TransactionTabIOEntry& read(const size_t index) 141 { 142 assert( (index < size_tab) && "Invalid Transaction Tab Entry"); 143 143 return tab[index]; 144 144 } … … 151 151 size_t readSrcid(const size_t index) 152 152 { 153 assert( (index < size_tab) 154 && "Invalid Transaction Tab Entry"); 153 assert( (index < size_tab) && "Invalid Transaction Tab Entry"); 155 154 return tab[index].srcid; 156 155 } … … 163 162 size_t readTrdid(const size_t index) 164 163 { 165 assert( (index < size_tab) 166 && "Invalid Transaction Tab Entry"); 164 assert( (index < size_tab) && "Invalid Transaction Tab Entry"); 167 165 return tab[index].trdid; 168 166 } … … 176 174 bool full(size_t &index) 177 175 { 178 for(size_t i=0; i<size_tab; i++){ 179 if(!tab[i].valid){ 180 index=i; 181 return false; 176 for(size_t i=0; i<size_tab; i++) 177 { 178 if(!tab[i].valid) 179 { 180 index = i; 181 return false; 182 182 } 183 183 } … … 194 194 ///////////////////////////////////////////////////////////////////// 195 195 void set(const size_t index, 196 const size_t srcid, 197 const size_t trdid) 198 { 199 assert( (index < size_tab) 200 && "The selected entry is out of range in set() Transaction Tab"); 201 202 tab[index].valid = true; 203 tab[index].srcid = srcid; 204 tab[index].trdid = trdid; 196 const size_t srcid, 197 const size_t trdid) 198 { 199 assert( (index < size_tab) && "Invalid Transaction Tab Entry"); 200 tab[index].valid = true; 201 tab[index].srcid = srcid; 202 tab[index].trdid = trdid; 205 203 } 206 204 … … 212 210 void erase(const size_t index) 213 211 { 214 assert( (index < size_tab) 215 && "The selected entry is out of range in erase() Transaction Tab"); 216 tab[index].valid = false; 212 assert( (index < size_tab) && "Invalid Transaction Tab Entry"); 213 tab[index].valid = false; 217 214 } 218 215 }; // end class TransactionTabIO … … 221 218 222 219 // Local Variables: 223 // tab-width: 4224 // c-basic-offset: 4220 // tab-width: 2 221 // c-basic-offset: 2 225 222 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 226 223 // indent-tabs-mode: nil 227 224 // End: 228 225 229 // vim: filetype=cpp:expandtab:shiftwidth= 4:tabstop=4:softtabstop=4230 226 // vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=2:softtabstop=2 227
Note: See TracChangeset
for help on using the changeset viewer.