- Timestamp:
- Oct 15, 2014, 11:41:49 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_mem_cache/caba/source/include/xram_transaction.h
r601 r836 15 15 class TransactionTabEntry 16 16 { 17 typedef sc_dt::sc_uint<64> 18 typedef sc_dt::sc_uint<40> 19 typedef uint32_t 20 typedef uint32_t 17 typedef sc_dt::sc_uint<64> wide_data_t; 18 typedef sc_dt::sc_uint<40> addr_t; 19 typedef uint32_t data_t; 20 typedef uint32_t be_t; 21 21 22 22 public: 23 bool valid;// entry valid24 bool xram_read;// read request to XRAM25 addr_t nline;// index (zy) of the requested line26 size_t srcid;// processor requesting the transaction27 size_t trdid;// processor requesting the transaction28 size_t pktid;// processor requesting the transaction29 bool proc_read;// read request from processor30 size_t read_length;// length of the read (for the response)31 size_t word_index;// index of the first read word (for response)32 std::vector<data_t> wdata; 33 std::vector<be_t> wdata_be; 34 bool rerror;// error returned by xram35 data_t ll_key;// LL key returned by the llsc_global_table36 bool config;// transaction required by CONFIG FSM23 bool valid; // entry valid 24 bool xram_read; // read request to XRAM 25 addr_t nline; // index (zy) of the requested line 26 size_t srcid; // processor requesting the transaction 27 size_t trdid; // processor requesting the transaction 28 size_t pktid; // processor requesting the transaction 29 bool proc_read; // read request from processor 30 size_t read_length; // length of the read (for the response) 31 size_t word_index; // index of the first read word (for response) 32 std::vector<data_t> wdata; // write buffer (one cache line) 33 std::vector<be_t> wdata_be; // be for each data in the write buffer 34 bool rerror; // error returned by xram 35 data_t ll_key; // LL key returned by the llsc_global_table 36 bool config; // transaction required by CONFIG FSM 37 37 38 38 ///////////////////////////////////////////////////////////////////// … … 41 41 void init() 42 42 { 43 valid 44 rerror 45 config 43 valid = false; 44 rerror = false; 45 config = false; 46 46 } 47 47 … … 52 52 void alloc(size_t n_words) 53 53 { 54 wdata_be.reserve( (int)n_words);55 wdata.reserve( (int)n_words);56 for (size_t i=0; i<n_words; i++)54 wdata_be.reserve((int) n_words); 55 wdata.reserve((int) n_words); 56 for (size_t i = 0; i < n_words; i++) 57 57 { 58 58 wdata_be.push_back(0); … … 66 66 void copy(const TransactionTabEntry &source) 67 67 { 68 valid 69 xram_read 70 nline 71 srcid 72 trdid 73 pktid 74 proc_read 68 valid = source.valid; 69 xram_read = source.xram_read; 70 nline = source.nline; 71 srcid = source.srcid; 72 trdid = source.trdid; 73 pktid = source.pktid; 74 proc_read = source.proc_read; 75 75 read_length = source.read_length; 76 word_index 76 word_index = source.word_index; 77 77 wdata_be.assign(source.wdata_be.begin(),source.wdata_be.end()); 78 78 wdata.assign(source.wdata.begin(),source.wdata.end()); … … 85 85 // The print() function prints the entry identified by "index". 86 86 //////////////////////////////////////////////////////////////////// 87 void print( size_t index, size_t mode)87 void print(size_t index, size_t mode) 88 88 { 89 89 std::cout << " TRT[" << std::dec << index << "] " 90 91 92 93 94 95 96 if ( mode)90 << " valid = " << valid 91 << " / error = " << rerror 92 << " / get = " << xram_read 93 << " / config = " << config << std::hex 94 << " / address = " << nline*4*wdata.size() 95 << " / srcid = " << srcid << std::endl; 96 if (mode) 97 97 { 98 98 std::cout << " trdid = " << trdid 99 100 101 102 103 99 << " / pktid = " << pktid << std::dec 100 << " / proc_read = " << proc_read 101 << " / read_length = " << read_length 102 << " / word_index = " << word_index << std::hex 103 << " / ll_key = " << ll_key << std::endl; 104 104 std::cout << " wdata = "; 105 for (size_t i=0; i<wdata.size(); i++)105 for (size_t i = 0; i < wdata.size(); i++) 106 106 { 107 107 std::cout << std::hex << wdata[i] << " / "; … … 112 112 113 113 ///////////////////////////////////////////////////////////////////// 114 // 114 // Constructors 115 115 ///////////////////////////////////////////////////////////////////// 116 116 … … 126 126 TransactionTabEntry(const TransactionTabEntry &source) 127 127 { 128 valid 129 xram_read 130 nline 131 srcid 132 trdid 133 pktid 134 proc_read 128 valid = source.valid; 129 xram_read = source.xram_read; 130 nline = source.nline; 131 srcid = source.srcid; 132 trdid = source.trdid; 133 pktid = source.pktid; 134 proc_read = source.proc_read; 135 135 read_length = source.read_length; 136 word_index 137 wdata_be.assign(source.wdata_be.begin(), source.wdata_be.end());138 wdata.assign(source.wdata.begin(), source.wdata.end());136 word_index = source.word_index; 137 wdata_be.assign(source.wdata_be.begin(), source.wdata_be.end()); 138 wdata.assign(source.wdata.begin(), source.wdata.end()); 139 139 rerror = source.rerror; 140 140 ll_key = source.ll_key; … … 149 149 class TransactionTab 150 150 { 151 typedef sc_dt::sc_uint<64> 152 typedef sc_dt::sc_uint<40> 153 typedef uint32_t 154 typedef uint32_t 151 typedef sc_dt::sc_uint<64> wide_data_t; 152 typedef sc_dt::sc_uint<40> addr_t; 153 typedef uint32_t data_t; 154 typedef uint32_t be_t; 155 155 156 156 private: 157 const std::string tab_name; 158 size_t size_tab;// the size of the tab157 const std::string tab_name; // the name for logs 158 size_t size_tab; // the size of the tab 159 159 160 160 data_t be_to_mask(be_t be) 161 161 { 162 162 data_t ret = 0; 163 if ( be&0x1) {163 if (be & 0x1) { 164 164 ret = ret | 0x000000FF; 165 165 } 166 if ( be&0x2) {166 if (be & 0x2) { 167 167 ret = ret | 0x0000FF00; 168 168 } 169 if ( be&0x4) {169 if (be & 0x4) { 170 170 ret = ret | 0x00FF0000; 171 171 } 172 if ( be&0x8) {172 if (be & 0x8) { 173 173 ret = ret | 0xFF000000; 174 174 } … … 177 177 178 178 public: 179 TransactionTabEntry * tab;// The transaction tab180 181 //////////////////////////////////////////////////////////////////// 182 // 179 TransactionTabEntry * tab; // The transaction tab 180 181 //////////////////////////////////////////////////////////////////// 182 // Constructors 183 183 //////////////////////////////////////////////////////////////////// 184 184 TransactionTab() 185 185 { 186 size_tab =0;187 tab =NULL;186 size_tab = 0; 187 tab = NULL; 188 188 } 189 189 190 190 TransactionTab(const std::string &name, 191 size_tn_entries,192 size_t n_words)193 : tab_name( name),194 size_tab( n_entries)191 size_t n_entries, 192 size_t n_words) 193 : tab_name(name), 194 size_tab(n_entries) 195 195 { 196 196 tab = new TransactionTabEntry[size_tab]; 197 for ( size_t i=0; i<size_tab; i++)197 for (size_t i = 0; i < size_tab; i++) 198 198 { 199 199 tab[i].alloc(n_words); … … 217 217 void init() 218 218 { 219 for ( size_t i=0; i<size_tab; i++)219 for (size_t i = 0; i < size_tab; i++) 220 220 { 221 221 tab[i].init(); … … 226 226 // Detailed content if detailed argument is non zero. 227 227 ///////////////////////////////////////////////////////////////////// 228 void print( size_t detailed = 0)228 void print(size_t detailed = 0) 229 229 { 230 230 std::cout << " < TRT content in " << tab_name << " >" << std::endl; 231 for ( size_t id = 0 ; id < size_tab ; id++)231 for (size_t id = 0; id < size_tab; id++) 232 232 { 233 233 tab[id].print( id , detailed ); … … 241 241 TransactionTabEntry read(const size_t index) 242 242 { 243 assert( (index < size_tab) and 244 "MEMC ERROR: Invalid Transaction Tab Entry"); 243 assert((index < size_tab) and "MEMC ERROR: Invalid Transaction Tab Entry"); 245 244 246 245 return tab[index]; … … 252 251 // The function returns true if the transaction tab is full 253 252 ///////////////////////////////////////////////////////////////////// 254 bool full(size_t & index)255 { 256 for (size_t i=0; i<size_tab; i++)257 { 258 if (!tab[i].valid)253 bool full(size_t & index) 254 { 255 for (size_t i = 0; i < size_tab; i++) 256 { 257 if (!tab[i].valid) 259 258 { 260 index =i;261 return false; 259 index = i; 260 return false; 262 261 } 263 262 } … … 274 273 bool hit_read(const addr_t nline,size_t &index) 275 274 { 276 for (size_t i=0; i<size_tab; i++)277 { 278 if ((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read))275 for (size_t i = 0; i < size_tab; i++) 276 { 277 if ((tab[i].valid && (nline == tab[i].nline)) && (tab[i].xram_read)) 279 278 { 280 index =i;281 return true; 279 index = i; 280 return true; 282 281 } 283 282 } … … 293 292 bool hit_write(const addr_t nline) 294 293 { 295 for (size_t i=0; i<size_tab; i++)296 { 297 if (tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read))294 for (size_t i = 0; i < size_tab; i++) 295 { 296 if (tab[i].valid && (nline == tab[i].nline) && !(tab[i].xram_read)) 298 297 { 299 return true; 298 return true; 300 299 } 301 300 } … … 312 311 ///////////////////////////////////////////////////////////////////// 313 312 void write_data_mask(const size_t index, 314 const std::vector<be_t> & be,315 const std::vector<data_t> & data)313 const std::vector<be_t> & be, 314 const std::vector<data_t> & data) 316 315 { 317 316 assert( (index < size_tab) and 318 "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");319 320 assert( (be.size() ==tab[index].wdata_be.size()) and321 "MEMC ERROR: Bad be size in TRT write_data_mask()");322 323 assert( (data.size() ==tab[index].wdata.size()) and324 "MEMC ERROR: Bad data size in TRT write_data_mask()");325 326 for (size_t i=0; i<tab[index].wdata_be.size(); i++)317 "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()"); 318 319 assert( (be.size() == tab[index].wdata_be.size()) and 320 "MEMC ERROR: Bad be size in TRT write_data_mask()"); 321 322 assert( (data.size() == tab[index].wdata.size()) and 323 "MEMC ERROR: Bad data size in TRT write_data_mask()"); 324 325 for (size_t i = 0; i < tab[index].wdata_be.size(); i++) 327 326 { 328 327 tab[index].wdata_be[i] = tab[index].wdata_be[i] | be[i]; … … 358 357 const size_t read_length, 359 358 const size_t word_index, 360 const std::vector<be_t> & data_be,361 const std::vector<data_t> & data,359 const std::vector<be_t> & data_be, 360 const std::vector<data_t> & data, 362 361 const data_t ll_key = 0, 363 362 const bool config = false) 364 363 { 365 assert( 366 "MEMC ERROR: The selected entry is out of range in TRT set()");367 368 assert( 369 "MEMC ERROR: Bad data_be argument in TRT set()");370 371 assert( 372 "MEMC ERROR: Bad data argument in TRT set()");373 374 tab[index].valid 375 tab[index].xram_read 376 tab[index].nline 377 tab[index].srcid 378 tab[index].trdid 379 tab[index].pktid 380 tab[index].proc_read 381 tab[index].read_length 382 tab[index].word_index 383 tab[index].ll_key 384 tab[index].config 385 for (size_t i=0; i<tab[index].wdata.size(); i++)386 { 387 tab[index].wdata_be[i] 388 tab[index].wdata[i] 364 assert((index < size_tab) and 365 "MEMC ERROR: The selected entry is out of range in TRT set()"); 366 367 assert((data_be.size()==tab[index].wdata_be.size()) and 368 "MEMC ERROR: Bad data_be argument in TRT set()"); 369 370 assert((data.size()==tab[index].wdata.size()) and 371 "MEMC ERROR: Bad data argument in TRT set()"); 372 373 tab[index].valid = true; 374 tab[index].xram_read = xram_read; 375 tab[index].nline = nline; 376 tab[index].srcid = srcid; 377 tab[index].trdid = trdid; 378 tab[index].pktid = pktid; 379 tab[index].proc_read = proc_read; 380 tab[index].read_length = read_length; 381 tab[index].word_index = word_index; 382 tab[index].ll_key = ll_key; 383 tab[index].config = config; 384 for (size_t i = 0; i < tab[index].wdata.size(); i++) 385 { 386 tab[index].wdata_be[i] = data_be[i]; 387 tab[index].wdata[i] = data[i]; 389 388 } 390 389 } … … 399 398 // - data : 64 bits value (first data right) 400 399 ///////////////////////////////////////////////////////////////////// 401 void write_rsp(const size_t 402 const size_tword,403 const wide_data_tdata,404 const boolrerror)405 { 406 data_t 407 data_t 408 409 assert( 410 "MEMC ERROR: The selected entry is out of range in TRT write_rsp()");411 412 assert( 413 "MEMC ERROR: Bad word index in TRT write_rsp()");414 415 assert( 416 "MEMC ERROR: TRT entry not valid in TRT write_rsp()");417 418 assert( 419 "MEMC ERROR: TRT entry is not a GET in TRT write_rsp()");420 421 if ( rerror)400 void write_rsp(const size_t index, 401 const size_t word, 402 const wide_data_t data, 403 const bool rerror) 404 { 405 data_t value; 406 data_t mask; 407 408 assert((index < size_tab) and 409 "MEMC ERROR: The selected entry is out of range in TRT write_rsp()"); 410 411 assert((word < tab[index].wdata_be.size()) and 412 "MEMC ERROR: Bad word index in TRT write_rsp()"); 413 414 assert((tab[index].valid) and 415 "MEMC ERROR: TRT entry not valid in TRT write_rsp()"); 416 417 assert((tab[index].xram_read ) and 418 "MEMC ERROR: TRT entry is not a GET in TRT write_rsp()"); 419 420 if (rerror) 422 421 { 423 422 tab[index].rerror = true; … … 426 425 427 426 // first 32 bits word 428 value = (data_t) data;427 value = (data_t) data; 429 428 mask = be_to_mask(tab[index].wdata_be[word]); 430 429 tab[index].wdata[word] = (tab[index].wdata[word] & mask) | (value & ~mask); 431 430 432 431 // second 32 bits word 433 value = (data_t) (data>>32);434 mask = be_to_mask(tab[index].wdata_be[word +1]);435 tab[index].wdata[word +1] = (tab[index].wdata[word+1] & mask) | (value & ~mask);432 value = (data_t) (data >> 32); 433 mask = be_to_mask(tab[index].wdata_be[word + 1]); 434 tab[index].wdata[word + 1] = (tab[index].wdata[word + 1] & mask) | (value & ~mask); 436 435 } 437 436 ///////////////////////////////////////////////////////////////////// … … 443 442 { 444 443 assert( (index < size_tab) and 445 "MEMC ERROR: The selected entry is out of range in TRT erase()");446 447 tab[index].valid 448 tab[index].rerror 444 "MEMC ERROR: The selected entry is out of range in TRT erase()"); 445 446 tab[index].valid = false; 447 tab[index].rerror = false; 449 448 } 450 449 ///////////////////////////////////////////////////////////////////// … … 456 455 { 457 456 assert( (index < size_tab) and 458 "MEMC ERROR: The selected entry is out of range in TRT is_config()");457 "MEMC ERROR: The selected entry is out of range in TRT is_config()"); 459 458 460 459 return tab[index].config;
Note: See TracChangeset
for help on using the changeset viewer.