- Timestamp:
- Jul 17, 2013, 9:24:48 AM (11 years ago)
- Location:
- branches/v5/modules/vci_mem_cache
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/v5/modules/vci_mem_cache
-
Property
svn:mergeinfo
set to
/trunk/modules/vci_mem_cache merged eligible
-
Property
svn:mergeinfo
set to
-
branches/v5/modules/vci_mem_cache/caba/source/include/update_tab.h
r307 r440 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 uint32_t size_t; 129 typedef sc_dt::sc_uint<40> addr_t; 140 typedef uint64_t addr_t; 130 141 131 142 private: 132 size_t size_tab;143 size_t size_tab; 133 144 std::vector<UpdateTabEntry> tab; 134 145 … … 150 161 // The size() function returns the size of the tab 151 162 //////////////////////////////////////////////////////////////////// 152 const size_t size(){ 163 const size_t size() 164 { 153 165 return size_tab; 154 166 } 155 167 156 157 168 //////////////////////////////////////////////////////////////////// 158 169 // The print() function diplays the tab content 159 170 //////////////////////////////////////////////////////////////////// 160 void print(){ 161 for(size_t i=0; i<size_tab; i++) { 162 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 << "] "; 163 177 tab[i].print(); 164 178 } … … 166 180 } 167 181 168 169 182 ///////////////////////////////////////////////////////////////////// 170 183 // The init() function initializes the tab 171 184 ///////////////////////////////////////////////////////////////////// 172 void init(){ 173 for ( size_t i=0; i<size_tab; i++) { 174 tab[i].init(); 175 } 176 } 177 185 void init() 186 { 187 for ( size_t i=0; i<size_tab; i++) tab[i].init(); 188 } 178 189 179 190 ///////////////////////////////////////////////////////////////////// … … 201 212 /////////////////////////////////////////////////////////////////////////// 202 213 bool set(const bool update, 203 const bool brdcast, 204 const bool rsp, 205 const size_t srcid, 206 const size_t trdid, 207 const size_t pktid, 208 const addr_t nline, 209 const size_t count, 210 size_t &index) 211 { 212 for ( size_t i=0 ; i<size_tab ; i++ ) { 213 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 { 214 228 tab[i].valid = true; 215 229 tab[i].update = update; 216 230 tab[i].brdcast = brdcast; 217 231 tab[i].rsp = rsp; 232 tab[i].ack = ack; 218 233 tab[i].srcid = (size_t) srcid; 219 234 tab[i].trdid = (size_t) trdid; … … 236 251 ///////////////////////////////////////////////////////////////////// 237 252 bool decrement( const size_t index, 238 size_t &counter )253 size_t &counter ) 239 254 { 240 255 assert((index<size_tab) && "Bad Update Tab Entry"); 241 if ( tab[index].valid ) { 256 if ( tab[index].valid ) 257 { 242 258 tab[index].count--; 243 259 counter = tab[index].count; 244 260 return true; 245 } else { 261 } 262 else 263 { 246 264 return false; 247 265 } … … 253 271 bool is_full() 254 272 { 255 for(size_t i = 0 ; i < size_tab ; i++){ 256 if(!tab[i].valid){ 257 return false; 258 } 273 for(size_t i = 0 ; i < size_tab ; i++) 274 { 275 if(!tab[i].valid) return false; 259 276 } 260 277 return true; … … 266 283 bool is_not_empty() 267 284 { 268 for(size_t i = 0 ; i < size_tab ; i++){ 269 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 ; 270 394 return true; 271 395 } … … 275 399 276 400 ///////////////////////////////////////////////////////////////////// 277 // The need_rsp() function returns the need of a response 278 // Arguments : 279 // - index : the index of the entry 280 ///////////////////////////////////////////////////////////////////// 281 bool need_rsp(const size_t index) 282 { 283 assert(index<size_tab && "Bad Update Tab Entry"); 284 return tab[index].rsp; 285 } 286 287 ///////////////////////////////////////////////////////////////////// 288 // The is_update() function returns the transaction type 289 // Arguments : 290 // - index : the index of the entry 291 ///////////////////////////////////////////////////////////////////// 292 bool is_brdcast(const size_t index) 293 { 294 assert(index<size_tab && "Bad Update Tab Entry"); 295 return tab[index].brdcast; 296 } 297 298 ///////////////////////////////////////////////////////////////////// 299 // The is_update() function returns the transaction type 300 // Arguments : 301 // - index : the index of the entry 302 ///////////////////////////////////////////////////////////////////// 303 bool is_update(const size_t index) 304 { 305 assert(index<size_tab && "Bad Update Tab Entry"); 306 return tab[index].update; 307 } 308 309 ///////////////////////////////////////////////////////////////////// 310 // The srcid() function returns the srcid value 311 // Arguments : 312 // - index : the index of the entry 313 ///////////////////////////////////////////////////////////////////// 314 size_t srcid(const size_t index) 315 { 316 assert(index<size_tab && "Bad Update Tab Entry"); 317 return tab[index].srcid; 318 } 319 320 ///////////////////////////////////////////////////////////////////// 321 // The trdid() function returns the trdid value 322 // Arguments : 323 // - index : the index of the entry 324 ///////////////////////////////////////////////////////////////////// 325 size_t trdid(const size_t index) 326 { 327 assert(index<size_tab && "Bad Update Tab Entry"); 328 return tab[index].trdid; 329 } 330 331 ///////////////////////////////////////////////////////////////////// 332 // The pktid() function returns the pktid value 333 // Arguments : 334 // - index : the index of the entry 335 ///////////////////////////////////////////////////////////////////// 336 size_t pktid(const size_t index) 337 { 338 assert(index<size_tab && "Bad Update Tab Entry"); 339 return tab[index].pktid; 340 } 341 342 ///////////////////////////////////////////////////////////////////// 343 // The nline() function returns the nline value 344 // Arguments : 345 // - index : the index of the entry 346 ///////////////////////////////////////////////////////////////////// 347 addr_t nline(const size_t index) 348 { 349 assert(index<size_tab && "Bad Update Tab Entry"); 350 return tab[index].nline; 351 } 352 353 ///////////////////////////////////////////////////////////////////// 354 // 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 355 402 // Arguments : 356 403 // - nline : the line number of the entry in the directory 357 404 ///////////////////////////////////////////////////////////////////// 358 bool search_inval(const addr_t nline,size_t &index)405 bool read_nline(const addr_t nline,size_t &index) 359 406 { 360 407 size_t i ; 361 408 362 for (i = 0 ; i < size_tab ; i++){ 363 if((tab[i].nline == nline) && tab[i].valid){ 364 if(!tab[i].update){ 365 index = i ; 366 return true; 367 } 368 } 369 } 370 return false; 371 } 372 373 ///////////////////////////////////////////////////////////////////// 374 // The read_nline() function returns the index of the entry in UPT 375 // Arguments : 376 // - nline : the line number of the entry in the directory 377 ///////////////////////////////////////////////////////////////////// 378 bool read_nline(const addr_t nline,size_t &index) 379 { 380 size_t i ; 381 382 for (i = 0 ; i < size_tab ; i++){ 383 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 { 384 413 index = i ; 385 414 return true;
Note: See TracChangeset
for help on using the changeset viewer.