- Timestamp:
- Jul 12, 2013, 12:16:30 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_mem_cache/caba/source/include/update_tab.h
r385 r434 11 11 //////////////////////////////////////////////////////////////////////// 12 12 class UpdateTabEntry { 13 13 14 typedef uint32_t size_t; 14 15 typedef sc_dt::sc_uint<40> addr_t; 15 16 16 17 public: 18 17 19 bool valid; // It is a valid pending transaction 18 20 bool update; // It is an update transaction 19 21 bool brdcast; // It is a broadcast invalidate 20 bool rsp; // It needs a response to the initiator 22 bool rsp; // Response to the initiator required 23 bool ack; // Acknowledge to the CONFIG FSM required 21 24 size_t srcid; // The srcid of the initiator which wrote the data 22 25 size_t trdid; // The trdid of the initiator which wrote the data … … 25 28 size_t count; // The number of acknowledge responses to receive 26 29 27 UpdateTabEntry(){ 30 UpdateTabEntry() 31 { 28 32 valid = false; 29 33 update = false; 30 34 brdcast = false; 31 35 rsp = false; 36 ack = false; 32 37 srcid = 0; 33 38 trdid = 0; … … 38 43 39 44 UpdateTabEntry(bool i_valid, 40 bool i_update, 41 bool i_brdcast, 42 bool i_rsp, 43 size_t i_srcid, 44 size_t i_trdid, 45 size_t i_pktid, 46 addr_t i_nline, 47 size_t i_count) 45 bool i_update, 46 bool i_brdcast, 47 bool i_rsp, 48 bool i_ack, 49 size_t i_srcid, 50 size_t i_trdid, 51 size_t i_pktid, 52 addr_t i_nline, 53 size_t i_count) 48 54 { 49 55 valid = i_valid; … … 51 57 brdcast = i_brdcast; 52 58 rsp = i_rsp; 59 ack = i_ack; 53 60 srcid = i_srcid; 54 61 trdid = i_trdid; … … 64 71 brdcast = source.brdcast; 65 72 rsp = source.rsp; 73 ack = source.ack; 66 74 srcid = source.srcid; 67 75 trdid = source.trdid; … … 80 88 brdcast= false; 81 89 rsp = false; 90 ack = false; 82 91 srcid = 0; 83 92 trdid = 0; … … 98 107 brdcast= source.brdcast; 99 108 rsp = source.rsp; 109 ack = source.ack ; 100 110 srcid = source.srcid; 101 111 trdid = source.trdid; … … 108 118 // The print() function prints the entry 109 119 //////////////////////////////////////////////////////////////////// 110 void print(){ 111 std::cout << std::dec << "valid = " << valid << std::endl; 112 std::cout << "update = " << update << std::endl; 113 std::cout << "brdcast= " << brdcast<< std::endl; 114 std::cout << "rsp = " << rsp << std::endl; 115 std::cout << "srcid = " << srcid << std::endl; 116 std::cout << "trdid = " << trdid << std::endl; 117 std::cout << "pktid = " << pktid << std::endl; 118 std::cout << std::hex << "nline = " << nline << std::endl; 119 std::cout << std::dec << "count = " << count << std::endl; 120 void print() 121 { 122 std::cout << " val = " << std::dec << valid 123 << " / updt = " << update 124 << " / bc = " << brdcast 125 << " / rsp = " << rsp 126 << " / ack = " << ack 127 << " / count = " << count 128 << " / srcid = " << std::hex << srcid 129 << " / trdid = " << trdid 130 << " / pktid = " << pktid 131 << " / nline = " << nline << std::endl; 120 132 } 121 133 }; … … 126 138 class UpdateTab{ 127 139 128 typedef sc_dt::sc_uint<40>addr_t;140 typedef uint64_t addr_t; 129 141 130 142 private: 131 size_t size_tab;143 size_t size_tab; 132 144 std::vector<UpdateTabEntry> tab; 133 145 … … 149 161 // The size() function returns the size of the tab 150 162 //////////////////////////////////////////////////////////////////// 151 const size_t size(){ 163 const size_t size() 164 { 152 165 return size_tab; 153 166 } 154 167 155 156 168 //////////////////////////////////////////////////////////////////// 157 169 // The print() function diplays the tab content 158 170 //////////////////////////////////////////////////////////////////// 159 void print(){ 160 for(size_t i=0; i<size_tab; i++) { 161 std::cout << "UPDATE TAB ENTRY " << std::dec << i << "--------" << std::endl; 171 void print() 172 { 173 std::cout << "UPDATE TABLE Content" << std::endl; 174 for(size_t i=0; i<size_tab; i++) 175 { 176 std::cout << "[" << std::dec << i << "] "; 162 177 tab[i].print(); 163 178 } … … 165 180 } 166 181 167 168 182 ///////////////////////////////////////////////////////////////////// 169 183 // The init() function initializes the tab 170 184 ///////////////////////////////////////////////////////////////////// 171 void init(){ 172 for ( size_t i=0; i<size_tab; i++) { 173 tab[i].init(); 174 } 175 } 176 185 void init() 186 { 187 for ( size_t i=0; i<size_tab; i++) tab[i].init(); 188 } 177 189 178 190 ///////////////////////////////////////////////////////////////////// … … 200 212 /////////////////////////////////////////////////////////////////////////// 201 213 bool set(const bool update, 202 const bool brdcast, 203 const bool rsp, 204 const size_t srcid, 205 const size_t trdid, 206 const size_t pktid, 207 const addr_t nline, 208 const size_t count, 209 size_t &index) 210 { 211 for ( size_t i=0 ; i<size_tab ; i++ ) { 212 if( !tab[i].valid ) { 214 const bool brdcast, 215 const bool rsp, 216 const bool ack, 217 const size_t srcid, 218 const size_t trdid, 219 const size_t pktid, 220 const addr_t nline, 221 const size_t count, 222 size_t &index) 223 { 224 for ( size_t i=0 ; i<size_tab ; i++ ) 225 { 226 if( !tab[i].valid ) 227 { 213 228 tab[i].valid = true; 214 229 tab[i].update = update; 215 230 tab[i].brdcast = brdcast; 216 231 tab[i].rsp = rsp; 232 tab[i].ack = ack; 217 233 tab[i].srcid = (size_t) srcid; 218 234 tab[i].trdid = (size_t) trdid; … … 235 251 ///////////////////////////////////////////////////////////////////// 236 252 bool decrement( const size_t index, 237 size_t &counter )253 size_t &counter ) 238 254 { 239 255 assert((index<size_tab) && "Bad Update Tab Entry"); 240 if ( tab[index].valid ) { 256 if ( tab[index].valid ) 257 { 241 258 tab[index].count--; 242 259 counter = tab[index].count; 243 260 return true; 244 } else { 261 } 262 else 263 { 245 264 return false; 246 265 } … … 252 271 bool is_full() 253 272 { 254 for(size_t i = 0 ; i < size_tab ; i++){ 255 if(!tab[i].valid){ 256 return false; 257 } 273 for(size_t i = 0 ; i < size_tab ; i++) 274 { 275 if(!tab[i].valid) return false; 258 276 } 259 277 return true; … … 265 283 bool is_not_empty() 266 284 { 267 for(size_t i = 0 ; i < size_tab ; i++){ 268 if(tab[i].valid){ 285 for(size_t i = 0 ; i < size_tab ; i++) 286 { 287 if(tab[i].valid) return true; 288 } 289 return false; 290 } 291 292 ///////////////////////////////////////////////////////////////////// 293 // The need_rsp() function returns the need of a response 294 // Arguments : 295 // - index : the index of the entry 296 ///////////////////////////////////////////////////////////////////// 297 bool need_rsp(const size_t index) 298 { 299 assert(index<size_tab && "Bad Update Tab Entry"); 300 return tab[index].rsp; 301 } 302 303 ///////////////////////////////////////////////////////////////////// 304 // The need_ack() function returns the need of an acknowledge 305 // Arguments : 306 // - index : the index of the entry 307 ///////////////////////////////////////////////////////////////////// 308 bool need_ack(const size_t index) 309 { 310 assert(index<size_tab && "Bad Update Tab Entry"); 311 return tab[index].ack; 312 } 313 314 ///////////////////////////////////////////////////////////////////// 315 // The is_brdcast() function returns the transaction type 316 // Arguments : 317 // - index : the index of the entry 318 ///////////////////////////////////////////////////////////////////// 319 bool is_brdcast(const size_t index) 320 { 321 assert(index<size_tab && "Bad Update Tab Entry"); 322 return tab[index].brdcast; 323 } 324 325 ///////////////////////////////////////////////////////////////////// 326 // The is_update() function returns the transaction type 327 // Arguments : 328 // - index : the index of the entry 329 ///////////////////////////////////////////////////////////////////// 330 bool is_update(const size_t index) 331 { 332 assert(index<size_tab && "Bad Update Tab Entry"); 333 return tab[index].update; 334 } 335 336 ///////////////////////////////////////////////////////////////////// 337 // The srcid() function returns the srcid value 338 // Arguments : 339 // - index : the index of the entry 340 ///////////////////////////////////////////////////////////////////// 341 size_t srcid(const size_t index) 342 { 343 assert(index<size_tab && "Bad Update Tab Entry"); 344 return tab[index].srcid; 345 } 346 347 ///////////////////////////////////////////////////////////////////// 348 // The trdid() function returns the trdid value 349 // Arguments : 350 // - index : the index of the entry 351 ///////////////////////////////////////////////////////////////////// 352 size_t trdid(const size_t index) 353 { 354 assert(index<size_tab && "Bad Update Tab Entry"); 355 return tab[index].trdid; 356 } 357 358 ///////////////////////////////////////////////////////////////////// 359 // The pktid() function returns the pktid value 360 // Arguments : 361 // - index : the index of the entry 362 ///////////////////////////////////////////////////////////////////// 363 size_t pktid(const size_t index) 364 { 365 assert(index<size_tab && "Bad Update Tab Entry"); 366 return tab[index].pktid; 367 } 368 369 ///////////////////////////////////////////////////////////////////// 370 // The nline() function returns the nline value 371 // Arguments : 372 // - index : the index of the entry 373 ///////////////////////////////////////////////////////////////////// 374 addr_t nline(const size_t index) 375 { 376 assert(index<size_tab && "Bad Update Tab Entry"); 377 return tab[index].nline; 378 } 379 380 ///////////////////////////////////////////////////////////////////// 381 // The search_inval() function returns the index of the entry in UPT 382 // Arguments : 383 // - nline : the line number of the entry in the directory 384 ///////////////////////////////////////////////////////////////////// 385 bool search_inval(const addr_t nline,size_t &index) 386 { 387 size_t i ; 388 389 for (i = 0 ; i < size_tab ; i++) 390 { 391 if ( (tab[i].nline == nline) and tab[i].valid and not tab[i].update ) 392 { 393 index = i ; 269 394 return true; 270 395 } … … 274 399 275 400 ///////////////////////////////////////////////////////////////////// 276 // The need_rsp() function returns the need of a response 277 // Arguments : 278 // - index : the index of the entry 279 ///////////////////////////////////////////////////////////////////// 280 bool need_rsp(const size_t index) 281 { 282 assert(index<size_tab && "Bad Update Tab Entry"); 283 return tab[index].rsp; 284 } 285 286 ///////////////////////////////////////////////////////////////////// 287 // The is_update() function returns the transaction type 288 // Arguments : 289 // - index : the index of the entry 290 ///////////////////////////////////////////////////////////////////// 291 bool is_brdcast(const size_t index) 292 { 293 assert(index<size_tab && "Bad Update Tab Entry"); 294 return tab[index].brdcast; 295 } 296 297 ///////////////////////////////////////////////////////////////////// 298 // The is_update() function returns the transaction type 299 // Arguments : 300 // - index : the index of the entry 301 ///////////////////////////////////////////////////////////////////// 302 bool is_update(const size_t index) 303 { 304 assert(index<size_tab && "Bad Update Tab Entry"); 305 return tab[index].update; 306 } 307 308 ///////////////////////////////////////////////////////////////////// 309 // The srcid() function returns the srcid value 310 // Arguments : 311 // - index : the index of the entry 312 ///////////////////////////////////////////////////////////////////// 313 size_t srcid(const size_t index) 314 { 315 assert(index<size_tab && "Bad Update Tab Entry"); 316 return tab[index].srcid; 317 } 318 319 ///////////////////////////////////////////////////////////////////// 320 // The trdid() function returns the trdid value 321 // Arguments : 322 // - index : the index of the entry 323 ///////////////////////////////////////////////////////////////////// 324 size_t trdid(const size_t index) 325 { 326 assert(index<size_tab && "Bad Update Tab Entry"); 327 return tab[index].trdid; 328 } 329 330 ///////////////////////////////////////////////////////////////////// 331 // The pktid() function returns the pktid value 332 // Arguments : 333 // - index : the index of the entry 334 ///////////////////////////////////////////////////////////////////// 335 size_t pktid(const size_t index) 336 { 337 assert(index<size_tab && "Bad Update Tab Entry"); 338 return tab[index].pktid; 339 } 340 341 ///////////////////////////////////////////////////////////////////// 342 // The nline() function returns the nline value 343 // Arguments : 344 // - index : the index of the entry 345 ///////////////////////////////////////////////////////////////////// 346 addr_t nline(const size_t index) 347 { 348 assert(index<size_tab && "Bad Update Tab Entry"); 349 return tab[index].nline; 350 } 351 352 ///////////////////////////////////////////////////////////////////// 353 // The search_inval() function returns the index of the entry in UPT 401 // The read_nline() function returns the index of the entry in UPT 354 402 // Arguments : 355 403 // - nline : the line number of the entry in the directory 356 404 ///////////////////////////////////////////////////////////////////// 357 bool search_inval(const addr_t nline,size_t &index)405 bool read_nline(const addr_t nline,size_t &index) 358 406 { 359 407 size_t i ; 360 408 361 for (i = 0 ; i < size_tab ; i++){ 362 if((tab[i].nline == nline) && tab[i].valid){ 363 if(!tab[i].update){ 364 index = i ; 365 return true; 366 } 367 } 368 } 369 return false; 370 } 371 372 ///////////////////////////////////////////////////////////////////// 373 // The read_nline() function returns the index of the entry in UPT 374 // Arguments : 375 // - nline : the line number of the entry in the directory 376 ///////////////////////////////////////////////////////////////////// 377 bool read_nline(const addr_t nline,size_t &index) 378 { 379 size_t i ; 380 381 for (i = 0 ; i < size_tab ; i++){ 382 if((tab[i].nline == nline) && tab[i].valid){ 409 for (i = 0 ; i < size_tab ; i++) 410 { 411 if ( (tab[i].nline == nline) and tab[i].valid ) 412 { 383 413 index = i ; 384 414 return true;
Note: See TracChangeset
for help on using the changeset viewer.