Changeset 192 for trunk


Ignore:
Timestamp:
Feb 10, 2012, 9:52:27 AM (12 years ago)
Author:
cfuguet
Message:

Cleanup transaction modification

Location:
trunk/modules/vci_mem_cache_v1/caba/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/vci_mem_cache_v1/caba/source/include/vci_mem_cache_v1.h

    r32 r192  
    5050#define TRANSACTION_TAB_LINES 4     // Number of lines in the transaction tab
    5151#define UPDATE_TAB_LINES 4          // Number of lines in the update tab
    52 #define BROADCAST_ADDR 0x0000000003 // Address to send the broadcast invalidate
     52//#define BROADCAST_ADDR 0x0000000003 // Address to send the broadcast invalidate
    5353
    5454namespace soclib {  namespace caba {
     
    150150        WRITE_INVAL,
    151151        WRITE_XRAM_SEND,
     152        WRITE_RESET
    152153      };
    153154
     
    303304      UpdateTab                 m_update_tab;               // pending update & invalidate
    304305      CacheDirectory                    m_cache_directory;          // data cache directory
     306      vci_addr_t                        m_broadcast_address;    // broadcast address
    305307
    306308      data_t                           ***m_cache_data;         // data array[set][way][word]
  • trunk/modules/vci_mem_cache_v1/caba/source/src/vci_mem_cache_v1.cpp

    r32 r192  
    2929#include "../include/vci_mem_cache_v1.h"
    3030
    31 #define VHDL_ACCURATE
    32 
    3331//#define IDEBUG
    3432//#define DEBUG_VCI_MEM_CACHE 2
    3533#define RANDOMIZE_SC
     34#define VHDL_ACCURATE
     35//#define DEBUG_CLEANUP
    3636
    3737namespace soclib { namespace caba {
     
    109109    "WRITE_DIR_INVAL",
    110110    "WRITE_INVAL",
    111     "WRITE_XRAM_SEND",
     111    "WRITE_XRAM_SEND"
     112#ifdef VHDL_ACCURATE
     113    , "WRITE_RESET"
     114#endif
    112115  };
    113116  const char *ixr_rsp_fsm_str[] = {
     
    282285      assert(nways <= 32);
    283286
     287      m_broadcast_address = 0x3 | (0x7C1F << (vci_param::N-20));
    284288
    285289      // Get the segments associated to the MemCache
     
    422426      r_init_rsp_fsm    = INIT_RSP_IDLE;
    423427      r_read_fsm        = READ_IDLE;
     428
     429#ifdef VHDL_ACCURATE
     430      r_write_fsm       = WRITE_RESET;
     431      r_alloc_dir_fsm   = ALLOC_DIR_WRITE;
     432#else
    424433      r_write_fsm       = WRITE_IDLE;
     434      r_alloc_dir_fsm   = ALLOC_DIR_READ;
     435#endif
     436
    425437      r_llsc_fsm        = LLSC_IDLE;
    426       r_cleanup_fsm     = CLEANUP_IDLE;
    427       r_alloc_dir_fsm   = ALLOC_DIR_READ;
     438      r_cleanup_fsm       = CLEANUP_IDLE;
     439
    428440      r_alloc_trt_fsm   = ALLOC_TRT_READ;
    429441      r_alloc_upt_fsm   = ALLOC_UPT_WRITE;
     
    433445
    434446      //  Initializing Tables
     447      //  The Directory is initialized in the WRITE RESET state
     448      //  in the VHDL ACCURATE model
     449#ifndef VHDL_ACCURATE
    435450      m_cache_directory.init();
     451#endif
    436452      m_atomic_tab.init();     
    437453      m_transaction_tab.init();
     
    486502
    487503      r_copies_limit        = 3;
     504
     505      // Initialize WRITE FSM registers
     506      r_write_way     = 0;
     507      r_write_address   = 0;
    488508
    489509      // Activity counters
     
    912932          if ( r_alloc_trt_fsm.read() == ALLOC_TRT_READ ) {
    913933#ifdef IDEBUG
    914         std::cout << sc_time_stamp() << " " << name() << " READ_TRT_LOCK " << std::endl;
     934            std::cout << sc_time_stamp() << " " << name() << " READ_TRT_LOCK " << std::endl;
    915935#endif
    916936            size_t index = 0;
     
    943963                std::vector<data_t>(m_words,0));
    944964#ifdef IDEBUG
    945         std::cout << sc_time_stamp() << " " << name() << " READ_TRT_SET transaction table : " << std::endl;
    946         for(size_t i = 0 ; i < m_transaction_tab.size() ; i++)
    947           m_transaction_tab.print(i);
     965                std::cout << sc_time_stamp() << " " << name() << " READ_TRT_SET transaction table : " << std::endl;
     966                for(size_t i = 0 ; i < m_transaction_tab.size() ; i++)
     967                  m_transaction_tab.print(i);
    948968#endif
    949969
     
    9951015
    9961016    switch ( r_write_fsm.read() ) {
    997 
     1017#ifdef VHDL_ACCURATE
     1018      case WRITE_RESET:
     1019        {
     1020          r_write_word_index    = 0;
     1021          r_write_word_count    = 0;
     1022
     1023          for (int i=0; i < m_words ; i++) {
     1024            r_write_data[i]     = 0;
     1025          }
     1026
     1027          r_write_srcid       = 0;
     1028          r_write_trdid       = 0;
     1029          r_write_pktid       = 0;
     1030          r_write_is_cnt      = false;
     1031          r_write_lock        = false;
     1032          r_write_d_copies    = 0;
     1033          r_write_i_copies    = 0;
     1034          r_write_count       = 0;
     1035          r_write_tag         = 0;
     1036
     1037          if ( r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE ) {
     1038         
     1039            r_write_way = (r_write_way.read()+1);
     1040            if(r_write_way.read() == (m_ways-1)) {
     1041              r_write_way     = 0;
     1042             
     1043#define L2 soclib::common::uint32_log2
     1044              r_write_address   = r_write_address.read() + (1<<(L2(m_words)+2));
     1045#undef L2
     1046            }
     1047
     1048
     1049            DirectoryEntry entry;
     1050            entry.valid    = false;
     1051            entry.dirty    = false;
     1052            entry.tag        = 0;
     1053            entry.is_cnt   = false;
     1054            entry.lock     = false;
     1055            entry.d_copies = 0;
     1056            entry.i_copies = 0;
     1057            entry.count    = 0;
     1058
     1059            size_t set     = m_y[(vci_addr_t)(r_write_address.read())];
     1060            size_t way     = r_write_way.read();
     1061
     1062            m_cache_directory.write(set, way, entry);
     1063
     1064#ifdef IDEBUG
     1065            std::cout  << "Initialize directory entry: "  << std::endl
     1066                  << "WRITE FSM: Way     = "              << way << std::endl
     1067                  << "WRITE FSM: Set     = "              << set << std::endl
     1068                  << "WRITE FSM: Address = "          << r_write_address.read()
     1069                  << std::endl;
     1070#endif
     1071           
     1072
     1073            if((set == (m_sets-1)) && (way == (m_ways-1))) {
     1074              r_write_fsm = WRITE_IDLE;
     1075            }
     1076          }
     1077          break;
     1078        }
     1079#endif
    9981080      ////////////////
    9991081      case WRITE_IDLE:  // copy first word of a write burst in local buffer     
     
    17721854              TransactionTabEntry    trt_entry(m_transaction_tab.read(index)); 
    17731855
     1856#ifdef IDEBUG
     1857              std::cout << "TRANSACTION ENTRY DEBUG" << std::endl;
     1858              trt_entry.print();
     1859#endif
     1860
    17741861              r_xram_rsp_trt_buf.copy(trt_entry);  // TRT entry local buffer
    17751862
     
    20442131      ///////////////////
    20452132      case CLEANUP_IDLE:
    2046         {
    2047 
     2133        {       
    20482134          if ( p_vci_tgt_cleanup.cmdval.read() ) {
     2135           
    20492136            assert( (p_vci_tgt_cleanup.srcid.read() < m_initiators) &&
    20502137                "VCI_MEM_CACHE error in VCI_MEM_CACHE in the CLEANUP network : The received SRCID is larger than 31");
     2138
     2139            addr_t nline_addr = ( ((addr_t) p_vci_tgt_cleanup.be.read()) << 32)
     2140                                | ((addr_t) p_vci_tgt_cleanup.wdata.read());
     2141
    20512142            bool reached = false;
    20522143            for ( size_t index = 0 ; index < ncseg && !reached ; index++ ){
     
    20562147            }
    20572148            if ( (p_vci_tgt_cleanup.cmd.read() == vci_param::CMD_WRITE) &&
    2058                 (((addr_t)(p_vci_tgt_cleanup.address.read())) != BROADCAST_ADDR) &&
     2149                (((addr_t)(p_vci_tgt_cleanup.address.read())) != m_broadcast_address) &&
    20592150                reached) {
    20602151
    20612152              m_cpt_cleanup++;
    20622153
    2063               r_cleanup_nline      = (addr_t)(m_nline[(vci_addr_t)(p_vci_tgt_cleanup.address.read())]) ;
     2154              r_cleanup_nline      = nline_addr;
    20642155              r_cleanup_srcid      = p_vci_tgt_cleanup.srcid.read();
    20652156              r_cleanup_trdid      = p_vci_tgt_cleanup.trdid.read();
     
    20702161#endif
    20712162              r_cleanup_fsm        = CLEANUP_DIR_LOCK;
     2163
     2164#ifdef DEBUG_CLEANUP
     2165              std::cout << "Cleanup Received" << std::endl;
     2166              std::cout << "MemCache address: ";
     2167              std::cout << std::hex << p_vci_tgt_cleanup.address.read();
     2168              std::cout << std::endl;
     2169              std::cout << "SrcId: ";
     2170              std::cout << std::hex << p_vci_tgt_cleanup.srcid.read();
     2171              std::cout << std::endl;
     2172              std::cout << "Cache Line Address: ";
     2173              std::cout << std::hex << nline_addr;
     2174              std::cout << std::endl;
     2175#endif
    20722176            }
    20732177          }
     
    20832187              // Read the directory
    20842188              size_t way = 0;
    2085                   addr_t cleanup_address = r_cleanup_nline.read() * m_words * 4;
     2189              addr_t cleanup_address = r_cleanup_nline.read() * m_words * 4;
    20862190              DirectoryEntry entry = m_cache_directory.read(cleanup_address , way);
    20872191#ifdef IDEBUG
     
    24262530            cmd_llsc_fifo_get           = true;
    24272531            r_llsc_to_tgt_rsp_req       = true;
    2428             r_llsc_to_tgt_rsp_data      = 1;
     2532            //r_llsc_to_tgt_rsp_data    = 1;
     2533            r_llsc_to_tgt_rsp_data      = 1; // FIXME: SC done inverted
    24292534            r_llsc_to_tgt_rsp_srcid     = m_cmd_llsc_srcid_fifo.read();
    24302535            r_llsc_to_tgt_rsp_trdid     = m_cmd_llsc_trdid_fifo.read();
     
    24402545            cmd_llsc_fifo_get       = true;
    24412546            r_llsc_to_tgt_rsp_req       = true;
    2442             r_llsc_to_tgt_rsp_data      = 0;
     2547            //r_llsc_to_tgt_rsp_data    = 0;
     2548            r_llsc_to_tgt_rsp_data      = 0; // FIXME: SC done inverted
    24432549            r_llsc_to_tgt_rsp_srcid     = m_cmd_llsc_srcid_fifo.read();
    24442550            r_llsc_to_tgt_rsp_trdid     = m_cmd_llsc_trdid_fifo.read();
     
    29983104        /////////////////////
    29993105      case ALLOC_DIR_WRITE:
    3000         if ( ( (r_write_fsm.read() != WRITE_DIR_LOCK)     &&
     3106        if ((
     3107#ifdef VHDL_ACCURATE
     3108              (r_write_fsm.read() != WRITE_RESET)     &&
     3109#endif
     3110              (r_write_fsm.read() != WRITE_DIR_LOCK)     &&
    30013111              (r_write_fsm.read() != WRITE_TRT_LOCK)     &&
    30023112              (r_write_fsm.read() != WRITE_DIR_HIT_READ) &&
     
    34643574        p_vci_ini.cmdval  = true;
    34653575        if(r_xram_rsp_to_init_cmd_brdcast.read())
    3466           p_vci_ini.address = BROADCAST_ADDR;
     3576          p_vci_ini.address = m_broadcast_address;
    34673577        else {
    34683578          if(r_init_cmd_inst.read()) {
    3469             p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]+8);
     3579            #define L2 soclib::common::uint32_log2
     3580            p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 8);
     3581            //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]+8);
    34703582          } else {
    3471             p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]);
    3472           }
    3473         }
     3583            #define L2 soclib::common::uint32_log2
     3584            p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))));
     3585            //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()]);
     3586          }
     3587        }
     3588
    34743589        p_vci_ini.wdata   = (uint32_t)r_xram_rsp_to_init_cmd_nline.read();
    34753590        p_vci_ini.be      = ((r_xram_rsp_to_init_cmd_nline.read() >> 32) & 0x3);
     
    34793594        break;
    34803595      case INIT_CMD_BRDCAST:
     3596
    34813597        p_vci_ini.cmdval  = true;
    3482         p_vci_ini.address = BROADCAST_ADDR;
     3598        p_vci_ini.address = m_broadcast_address;
    34833599        p_vci_ini.wdata   = (addr_t)r_write_to_init_cmd_nline.read();
    34843600        p_vci_ini.be      = ((r_write_to_init_cmd_nline.read() >> 32) & 0x3);
     
    34903606        p_vci_ini.cmdval  = true;
    34913607        if(r_init_cmd_inst.read()){
    3492           p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12);
     3608          #define L2 soclib::common::uint32_log2
     3609          p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 12);
     3610          #undef L2
     3611          //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12);
    34933612        } else {
    3494           p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4);
    3495         }
     3613          #define L2 soclib::common::uint32_log2
     3614          p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 4);
     3615          #undef L2
     3616          //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4);
     3617        }
     3618
    34963619        p_vci_ini.wdata   = (uint32_t)r_write_to_init_cmd_nline.read();
    34973620        p_vci_ini.be      = ((r_write_to_init_cmd_nline.read() >> 32 ) & 0x3);
     
    35033626        p_vci_ini.cmdval  = true;
    35043627        if(r_init_cmd_inst.read()){
    3505           p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12);
     3628          #define L2 soclib::common::uint32_log2
     3629          p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 12);
     3630          #undef L2
     3631          //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12);
    35063632        } else {
    3507           p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4);
    3508         }
     3633          #define L2 soclib::common::uint32_log2
     3634          p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 4);
     3635          #undef L2
     3636          //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4);
     3637        }
     3638
    35093639        p_vci_ini.wdata   = r_write_to_init_cmd_index.read();
    35103640        p_vci_ini.be      = 0xF;
     
    35163646        p_vci_ini.cmdval  = true;
    35173647        if(r_init_cmd_inst.read()){
    3518           p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12);
     3648          #define L2 soclib::common::uint32_log2
     3649          p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 12);
     3650          #undef L2
     3651          //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 12);
    35193652        } else {
    3520           p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4);
    3521         }
     3653          #define L2 soclib::common::uint32_log2
     3654          p_vci_ini.address = (addr_t)((r_init_cmd_target.read()<<(vci_param::N - L2(m_initiators))) + 4);
     3655          #undef L2
     3656          //p_vci_ini.address = (addr_t)(m_coherence_table[r_init_cmd_target.read()] + 4);
     3657        }
     3658
    35223659        p_vci_ini.wdata   = r_write_to_init_cmd_data[r_init_cmd_cpt.read() +
    35233660          r_write_to_init_cmd_index.read()].read();
     
    35863723// End:
    35873724
    3588 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
    3589 
     3725// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=2
     3726
Note: See TracChangeset for help on using the changeset viewer.