Changeset 313 for branches/v5/modules/vci_mem_cache
- Timestamp:
- Mar 12, 2013, 3:20:33 PM (12 years ago)
- Location:
- branches/v5/modules/vci_mem_cache/caba/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/v5/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h
r295 r313 215 215 CAS_DIR_LOCK, 216 216 CAS_DIR_HIT_READ, 217 CAS_DIR_HIT_COMPARE, 217 218 CAS_DIR_HIT_WRITE, 218 219 CAS_UPT_LOCK, … … 660 661 sc_signal<size_t> r_cas_trt_index; // Transaction Table index 661 662 sc_signal<size_t> r_cas_upt_index; // Update Table index 663 sc_signal<data_t> * r_cas_data; // cache line data 662 664 663 665 // Buffer between CAS fsm and INIT_CMD fsm (XRAM read) -
branches/v5/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp
r305 r313 175 175 "CAS_DIR_LOCK", 176 176 "CAS_DIR_HIT_READ", 177 "CAS_DIR_HIT_COMPARE", 177 178 "CAS_DIR_HIT_WRITE", 178 179 "CAS_UPT_LOCK", … … 434 435 435 436 // Allocation for CAS FSM 436 r_cas_to_ixr_cmd_data 437 r_cas_ rdata = new sc_signal<data_t>[2];438 437 r_cas_to_ixr_cmd_data = new sc_signal<data_t>[nwords]; 438 r_cas_data = new sc_signal<data_t>[nwords]; 439 r_cas_rdata = new sc_signal<data_t>[2]; 439 440 440 441 // Simulation … … 4328 4329 if( r_alloc_dir_fsm.read() == ALLOC_DIR_CAS ) 4329 4330 { 4330 r_cas_fsm = CAS_DIR_LOCK;4331 r_cas_fsm = CAS_DIR_LOCK; 4331 4332 } 4332 4333 … … 4334 4335 if( m_debug_cas_fsm ) 4335 4336 { 4336 std::cout4337 << " <MEMC " << name() << ".CAS_DIR_REQ> Requesting DIR lock "4338 << std::endl;4337 std::cout 4338 << " <MEMC " << name() << ".CAS_DIR_REQ> Requesting DIR lock " 4339 << std::endl; 4339 4340 } 4340 4341 #endif … … 4363 4364 4364 4365 if ( entry.valid ) r_cas_fsm = CAS_DIR_HIT_READ; 4365 else r_cas_fsm = CAS_MISS_TRT_LOCK;4366 else r_cas_fsm = CAS_MISS_TRT_LOCK; 4366 4367 4367 4368 #if DEBUG_MEMC_CAS … … 4378 4379 else 4379 4380 { 4380 std::cout4381 << "VCI_MEM_CACHE ERROR " << name()4382 << " CAS_DIR_LOCK state" << std::endl4383 << "Bad DIR allocation" << std::endl;4384 4385 exit(0);4381 std::cout 4382 << "VCI_MEM_CACHE ERROR " << name() 4383 << " CAS_DIR_LOCK state" << std::endl 4384 << "Bad DIR allocation" << std::endl; 4385 4386 exit(0); 4386 4387 } 4387 4388 4388 4389 break; 4389 4390 } 4391 4390 4392 ///////////////////// 4391 4393 case CAS_DIR_HIT_READ: // update directory for lock and dirty bit 4392 // and check data change in cache4394 // and check data change in cache 4393 4395 { 4394 4396 size_t way = r_cas_way.read(); 4395 4397 size_t set = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())]; 4396 size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];4397 4398 4398 4399 // update directory (lock & dirty bits) … … 4402 4403 entry.dirty = true; 4403 4404 entry.lock = true; 4404 entry.tag = r_cas_tag.read();4405 entry.tag = r_cas_tag.read(); 4405 4406 entry.owner.srcid = r_cas_copy.read(); 4406 4407 #if L1_MULTI_CACHE … … 4413 4414 m_cache_directory.write(set, way, entry); 4414 4415 4415 // read data in cache & check data change 4416 bool ok = ( r_cas_rdata[0].read() == m_cache_data.read(way, set, word) ); 4417 if ( r_cas_cpt.read()==4 ) // 64 bits CAS 4418 ok &= ( r_cas_rdata[1] == m_cache_data.read(way, set, word+1)); 4416 // Stored data from cache in buffer to do the comparison in next state 4417 m_cache_data.read_line(way, set, r_cas_data); 4418 4419 r_cas_fsm = CAS_DIR_HIT_COMPARE; 4420 4421 #if DEBUG_MEMC_CAS 4422 if(m_debug_cas_fsm) 4423 { 4424 std::cout << " <MEMC " << name() << ".CAS_DIR_HIT_READ> Read data from " 4425 << " cache and store it in buffer" 4426 << std::endl; 4427 } 4428 #endif 4429 break; 4430 } 4431 4432 case CAS_DIR_HIT_COMPARE: 4433 { 4434 size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())]; 4435 4436 // Read data in buffer & check data change 4437 bool ok = (r_cas_rdata[0].read() == r_cas_data[word].read()); 4438 4439 if(r_cas_cpt.read() == 4) // 64 bits CAS 4440 ok &= (r_cas_rdata[1] == r_cas_data[word+1]); 4419 4441 4420 4442 // to avoid livelock, force the atomic access to fail pseudo-randomly 4421 bool forced_fail = ( (r_cas_lfsr % (64) == 0) && RANDOMIZE_CAS ); 4422 r_cas_lfsr = (r_cas_lfsr >> 1) ^ ((-(r_cas_lfsr & 1)) & 0xd0000001); 4423 4424 if( ok and not forced_fail ) // no data change 4443 bool forced_fail = ((r_cas_lfsr % (64) == 0) && RANDOMIZE_CAS); 4444 r_cas_lfsr = (r_cas_lfsr >> 1) ^ ((- (r_cas_lfsr & 1)) & 0xd0000001); 4445 4446 // cas success 4447 if(ok and not forced_fail) 4425 4448 { 4426 4449 r_cas_fsm = CAS_DIR_HIT_WRITE; 4427 4450 } 4428 else // return failure 4451 // cas failure 4452 else 4429 4453 { 4430 4454 r_cas_fsm = CAS_RSP_FAIL; … … 4432 4456 4433 4457 #if DEBUG_MEMC_CAS 4434 if( m_debug_cas_fsm ) 4435 { 4436 std::cout << " <MEMC " << name() << ".CAS_DIR_HIT_READ> Test if CAS success:" 4437 << " / expected value = " << r_cas_rdata[0].read() 4438 << " / actual value = " << m_cache_data.read(way, set, word) 4439 << " / forced_fail = " << forced_fail << std::endl; 4440 } 4458 if(m_debug_cas_fsm) 4459 { 4460 std::cout << " <MEMC " << name() << ".CAS_DIR_HIT_COMPARE> Compare the old" 4461 << " and the new data" 4462 << " / expected value = " << r_cas_rdata[0].read() 4463 << " / actual value = " << r_cas_data[word].read() 4464 << " / forced_fail = " << forced_fail << std::endl; 4465 } 4441 4466 #endif 4442 4467 break; 4443 4468 } 4469 4444 4470 ////////////////////// 4445 4471 case CAS_DIR_HIT_WRITE: // test if a CC transaction is required … … 4477 4503 m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read()); 4478 4504 4505 r_cas_fsm = CAS_RSP_SUCCESS; 4506 4479 4507 // monitor 4480 4508 if ( m_monitor_ok ) 4481 4509 { 4482 4510 vci_addr_t address = m_cmd_cas_addr_fifo.read(); 4483 char buf[80]; 4484 snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d", m_cmd_cas_srcid_fifo.read()); 4511 4512 char buf[80]; 4513 snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d", 4514 m_cmd_cas_srcid_fifo.read()); 4515 4485 4516 check_monitor( buf, address, r_cas_wdata.read() ); 4486 4517 if ( r_cas_cpt.read()==4 ) 4487 4518 check_monitor( buf, address+4, m_cmd_cas_wdata_fifo.read() ); 4488 4519 } 4489 r_cas_fsm = CAS_RSP_SUCCESS;4490 4520 4491 4521 #if DEBUG_MEMC_CAS … … 4704 4734 { 4705 4735 // fill the data buffer 4706 size_t way = r_cas_way.read(); 4707 size_t set = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())]; 4708 size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())]; 4736 size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())]; 4709 4737 for(size_t i = 0; i<m_words; i++) 4710 4738 { … … 4719 4747 else 4720 4748 { 4721 r_cas_to_ixr_cmd_data[i] = m_cache_data.read(way, set, i);4749 r_cas_to_ixr_cmd_data[i] = r_cas_data[i].read(); 4722 4750 } 4723 4751 } … … 5822 5850 //////////////////// 5823 5851 case ALLOC_DIR_CAS: 5824 if ((( r_cas_fsm.read() != CAS_DIR_REQ ) && 5825 ( r_cas_fsm.read() != CAS_DIR_LOCK ) && 5826 ( r_cas_fsm.read() != CAS_DIR_HIT_READ ) && 5827 ( r_cas_fsm.read() != CAS_DIR_HIT_WRITE ) && 5828 ( r_cas_fsm.read() != CAS_BC_TRT_LOCK ) && 5829 ( r_cas_fsm.read() != CAS_BC_UPT_LOCK ) && 5830 ( r_cas_fsm.read() != CAS_MISS_TRT_LOCK ) && 5831 ( r_cas_fsm.read() != CAS_UPT_LOCK ) && 5832 ( r_cas_fsm.read() != CAS_UPT_HEAP_LOCK )) 5852 if ((( r_cas_fsm.read() != CAS_DIR_REQ ) && 5853 ( r_cas_fsm.read() != CAS_DIR_LOCK ) && 5854 ( r_cas_fsm.read() != CAS_DIR_HIT_READ ) && 5855 ( r_cas_fsm.read() != CAS_DIR_HIT_COMPARE ) && 5856 ( r_cas_fsm.read() != CAS_DIR_HIT_WRITE ) && 5857 ( r_cas_fsm.read() != CAS_BC_TRT_LOCK ) && 5858 ( r_cas_fsm.read() != CAS_BC_UPT_LOCK ) && 5859 ( r_cas_fsm.read() != CAS_MISS_TRT_LOCK ) && 5860 ( r_cas_fsm.read() != CAS_UPT_LOCK ) && 5861 ( r_cas_fsm.read() != CAS_UPT_HEAP_LOCK )) 5833 5862 || 5834 (( r_cas_fsm.read() == CAS_UPT_HEAP_LOCK ) &&5835 ( r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS ))5863 (( r_cas_fsm.read() == CAS_UPT_HEAP_LOCK ) && 5864 ( r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS )) 5836 5865 || 5837 (( r_cas_fsm.read() == CAS_MISS_TRT_LOCK ) &&5838 ( r_alloc_trt_fsm.read() == ALLOC_TRT_CAS )))5866 (( r_cas_fsm.read() == CAS_MISS_TRT_LOCK ) && 5867 ( r_alloc_trt_fsm.read() == ALLOC_TRT_CAS ))) 5839 5868 { 5840 5869 if ( r_cleanup_fsm.read() == CLEANUP_DIR_REQ )
Note: See TracChangeset
for help on using the changeset viewer.