Ignore:
Timestamp:
Mar 12, 2013, 3:20:33 PM (11 years ago)
Author:
cfuguet
Message:

Erasing useless template parameters for the communication/dspin_dhccp_param class.

Modifying consequently the vci_mem_cache_dspin_coherence class to use the
dspin_dhccp_param class without templates.

Introducing in the vci_mem_cache and the vci_mem_cache_dspin_coherence modules
the state CAS_DIR_HIT_COMPARE.

Before this modification, the comparison between the expected data and the actual
data was done directly in the CAS_DIR_HIT_READ state using the data obtained in the
same cycle from the cache.

Now, the data obtained from the cache is stored in a buffer and the next cycle,
in the CAS_DIR_HIT_COMPARE state, the comparison is made using the data from the
buffer.

This modifications allows to eliminate a critical path obtained in the ASIC
synthesis of the memory cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/v5/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r305 r313  
    175175    "CAS_DIR_LOCK",
    176176    "CAS_DIR_HIT_READ",
     177    "CAS_DIR_HIT_COMPARE",
    177178    "CAS_DIR_HIT_WRITE",
    178179    "CAS_UPT_LOCK",
     
    434435
    435436      // Allocation for CAS FSM
    436       r_cas_to_ixr_cmd_data        = new sc_signal<data_t>[nwords];
    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];
    439440
    440441      // Simulation
     
    43284329            if( r_alloc_dir_fsm.read() == ALLOC_DIR_CAS )
    43294330            {
    4330               r_cas_fsm = CAS_DIR_LOCK;
     4331                r_cas_fsm = CAS_DIR_LOCK;
    43314332            }
    43324333
     
    43344335            if( m_debug_cas_fsm )
    43354336            {
    4336               std::cout
    4337                 << "  <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;
    43394340            }
    43404341#endif
     
    43634364
    43644365                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;
    43664367
    43674368#if DEBUG_MEMC_CAS
     
    43784379            else
    43794380            {
    4380               std::cout
    4381                 << "VCI_MEM_CACHE ERROR " << name()
    4382                 << " CAS_DIR_LOCK state" << std::endl
    4383                 << "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);
    43864387            }
    43874388
    43884389            break;
    43894390        }
     4391
    43904392        /////////////////////
    43914393        case CAS_DIR_HIT_READ:  // update directory for lock and dirty bit
    4392                                // and check data change in cache
     4394                                // and check data change in cache
    43934395        {
    43944396            size_t way  = r_cas_way.read();
    43954397            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())];
    43974398
    43984399            // update directory (lock & dirty bits)
     
    44024403            entry.dirty          = true;
    44034404            entry.lock           = true;
    4404             entry.tag          = r_cas_tag.read();
     4405            entry.tag            = r_cas_tag.read();
    44054406            entry.owner.srcid    = r_cas_copy.read();
    44064407#if L1_MULTI_CACHE
     
    44134414            m_cache_directory.write(set, way, entry);
    44144415
    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]);
    44194441
    44204442            // 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)
    44254448            {
    44264449                r_cas_fsm = CAS_DIR_HIT_WRITE;
    44274450            }
    4428             else                            // return failure
     4451            // cas failure
     4452            else
    44294453            {
    44304454                r_cas_fsm = CAS_RSP_FAIL;
     
    44324456
    44334457#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            }
    44414466#endif
    44424467            break;
    44434468        }
     4469
    44444470        //////////////////////
    44454471        case CAS_DIR_HIT_WRITE:    // test if a CC transaction is required
     
    44774503                    m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
    44784504
     4505                r_cas_fsm = CAS_RSP_SUCCESS;
     4506
    44794507                // monitor
    44804508                if ( m_monitor_ok )
    44814509                {
    44824510                    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
    44854516                    check_monitor( buf, address, r_cas_wdata.read() );
    44864517                    if ( r_cas_cpt.read()==4 )
    44874518                    check_monitor( buf, address+4, m_cmd_cas_wdata_fifo.read() );
    44884519                }
    4489                 r_cas_fsm = CAS_RSP_SUCCESS;
    44904520
    44914521#if DEBUG_MEMC_CAS
     
    47044734                {
    47054735                    // 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())];
    47094737                    for(size_t i = 0; i<m_words; i++)
    47104738                    {
     
    47194747                        else
    47204748                        {
    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();
    47224750                        }
    47234751                    }
     
    58225850        ////////////////////
    58235851        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   ))
    58335862            ||
    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      ))
    58365865            ||
    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       )))
    58395868        {
    58405869          if ( r_cleanup_fsm.read() == CLEANUP_DIR_REQ )
Note: See TracChangeset for help on using the changeset viewer.