Changeset 337
- Timestamp:
- Mar 28, 2013, 1:50:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/generic_cache_tsar/include/generic_cache.h
r303 r337 399 399 } 400 400 401 //////////////////////////////////////////////////////////////////// 402 // Read one or two 32 bits word. 403 // Both data and directory are accessed. 404 // returns the access status in the state argument: 405 // - VALID : (matching tag) and (state == VALID) 406 // - ZOMBI : (matching tag) and (state == ZOMBI) 407 // - MISS : no matching tag or EMPTY state 408 // If VALID or ZOMBI, the data, the way, set and word index are 409 // returned in the other arguments. 410 //////////////////////////////////////////////////////////////////// 411 inline void read( addr_t ad, 412 data_t* dt, 413 data_t* dt_next, 414 size_t* selway, 415 size_t* selset, 416 size_t* selword, 417 int* state ) 418 { 419 const tag_t tag = m_z[ad]; 420 const size_t set = m_y[ad]; 421 const size_t word = m_x[ad]; 422 423 // default return values 424 *state = CACHE_SLOT_STATE_EMPTY; 425 *selway = 0; 426 *selset = 0; 427 *selword = 0; 428 *dt = 0; 429 430 for ( size_t way = 0; way < m_ways; way++ ) 431 { 432 if ( tag == cache_tag(way, set) ) // matching tag 433 { 434 435 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID ) 436 { 437 *state = CACHE_SLOT_STATE_VALID; 438 *selway = way; 439 *selset = set; 440 *selword = word; 441 *dt = cache_data(way, set, word); 442 if ( word+1 < m_words) 443 { 444 *dt_next = cache_data(way, set, word+1); 445 } 446 cache_set_lru(way, set); 447 } 448 else if ( cache_state(way, set) == CACHE_SLOT_STATE_ZOMBI ) 449 { 450 *state = CACHE_SLOT_STATE_ZOMBI; 451 *selway = way; 452 *selset = set; 453 *selword = word; 454 } 455 } 456 } 457 } 458 401 459 /////////////////////////////////////////////////////////////////////////////// 402 460 // Checks the cache state for a given address.
Note: See TracChangeset
for help on using the changeset viewer.