Ignore:
Timestamp:
Aug 9, 2013, 11:00:05 AM (11 years ago)
Author:
alain
Message:

Implement both the SYNC and INVAL configuration commands.
Uses the TRT to transmit the cache line to XRAM in cPUT transactions.
Improve the debug.

File:
1 edited

Legend:

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

    r422 r489  
    3434    bool                rerror;         // error returned by xram
    3535    data_t              ll_key;         // LL key returned by the llsc_global_table
     36    bool                config;         // transaction required by CONFIG FSM
    3637
    3738    /////////////////////////////////////////////////////////////////////
     
    4243        valid           = false;
    4344        rerror      = false;
     45        config      = false;
    4446    }
    4547
     
    8082        rerror      = source.rerror;
    8183        ll_key      = source.ll_key;
     84        config      = source.config;
    8285    }
    8386
     
    8790    void print()
    8891    {
     92        std::cout << "------- TRT entry -------" << std::endl;
    8993        std::cout << "valid       = " << valid        << std::endl;
    9094        std::cout << "xram_read   = " << xram_read    << std::endl;
     
    96100        std::cout << "read_length = " << read_length  << std::endl;
    97101        std::cout << "word_index  = " << word_index   << std::endl;
    98         for(size_t i=0; i<wdata_be.size() ; i++){
    99             std::cout << "wdata_be [" << i <<"] = " << wdata_be[i] << std::endl;
    100         }
    101         for(size_t i=0; i<wdata.size() ; i++){
    102             std::cout << "wdata [" << i <<"] = " << wdata[i] << std::endl;
    103         }
     102        for(size_t i=0; i<wdata_be.size() ; i++)
     103        {
     104            std::cout << "wdata_be[" << std::dec << i << "] = "
     105                      << std::hex << wdata_be[i] << std::endl;
     106        }
     107        for(size_t i=0; i<wdata.size() ; i++)
     108        {
     109            std::cout << "wdata[" << std::dec << i << "] = "
     110                      << std::hex << wdata[i] << std::endl;
     111        }
     112        std::cout << "rerror      = " << rerror       << std::endl;
     113        std::cout << "ll_key      = " << ll_key       << std::endl;
     114        std::cout << "config      = " << config       << std::endl;
    104115        std::cout << std::endl;
    105         std::cout << "rerror      = " << rerror       << std::endl;
    106116    }
    107117
     
    114124        wdata_be.clear();
    115125        wdata.clear();
    116         valid=false;
    117         rerror=false;
    118     }
    119 
    120     TransactionTabEntry(const TransactionTabEntry &source){
     126        valid  = false;
     127        rerror = false;
     128        config = false;
     129    }
     130
     131    TransactionTabEntry(const TransactionTabEntry &source)
     132    {
    121133        valid       = source.valid;
    122134        xram_read       = source.xram_read;
     
    132144        rerror      = source.rerror;
    133145        ll_key      = source.ll_key;
     146        config      = source.config;
    134147    }
    135148
     
    197210        delete [] tab;
    198211    }
    199 
    200212    /////////////////////////////////////////////////////////////////////
    201213    // The size() function returns the size of the tab
     
    205217        return size_tab;
    206218    }
    207 
    208219    /////////////////////////////////////////////////////////////////////
    209220    // The init() function initializes the transaction tab entries
     
    211222    void init()
    212223    {
    213         for ( size_t i=0; i<size_tab; i++) {
     224        for ( size_t i=0; i<size_tab; i++)
     225        {
    214226            tab[i].init();
    215227        }
    216228    }
    217 
    218229    /////////////////////////////////////////////////////////////////////
    219230    // The print() function prints a transaction tab entry
     
    223234    void print(const size_t index)
    224235    {
    225         assert( (index < size_tab)
    226                 && "Invalid Transaction Tab Entry");
     236        assert( (index < size_tab) and
     237        "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");
     238
    227239        tab[index].print();
    228240        return;
    229241    }
    230 
    231242    /////////////////////////////////////////////////////////////////////
    232243    // The read() function returns a transaction tab entry.
     
    236247    TransactionTabEntry read(const size_t index)
    237248    {
    238         assert( (index < size_tab)
    239                 && "Invalid Transaction Tab Entry");
     249        assert( (index < size_tab) and
     250        "MEMC ERROR: Invalid Transaction Tab Entry");
     251
    240252        return tab[index];
    241253    }
    242 
    243254    /////////////////////////////////////////////////////////////////////
    244255    // The full() function returns the state of the transaction tab
     
    249260    bool full(size_t &index)
    250261    {
    251         for(size_t i=0; i<size_tab; i++){
    252             if(!tab[i].valid){
     262        for(size_t i=0; i<size_tab; i++)
     263        {
     264            if(!tab[i].valid)
     265            {
    253266                index=i;
    254267                return false;   
     
    257270        return true;
    258271    }
    259 
    260272    /////////////////////////////////////////////////////////////////////
    261273    // The hit_read() function checks if an XRAM read transaction exists
     
    268280    bool hit_read(const addr_t nline,size_t &index)
    269281    {
    270         for(size_t i=0; i<size_tab; i++){
    271             if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read)) {
     282        for(size_t i=0; i<size_tab; i++)
     283        {
     284            if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read))
     285            {
    272286                index=i;
    273287                return true;   
     
    276290        return false;
    277291    }
    278 
    279292    ///////////////////////////////////////////////////////////////////////
    280293    // The hit_write() function looks if an XRAM write transaction exists
     
    286299    bool hit_write(const addr_t nline)
    287300    {
    288         for(size_t i=0; i<size_tab; i++){
    289             if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read)) {
     301        for(size_t i=0; i<size_tab; i++)
     302        {
     303            if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read))
     304            {
    290305                return true;   
    291306            }
     
    293308        return false;
    294309    }
    295 
    296310    /////////////////////////////////////////////////////////////////////
    297311    // The write_data_mask() function writes a vector of data (a line).
     
    307321            const std::vector<data_t> &data)
    308322    {
    309         assert( (index < size_tab)
    310                 && "Invalid Transaction Tab Entry");
    311         assert(be.size()==tab[index].wdata_be.size()
    312                 && "Bad data mask in write_data_mask in TransactionTab");
    313         assert(data.size()==tab[index].wdata.size()
    314                 && "Bad data in write_data_mask in TransactionTab");
    315 
    316         for(size_t i=0; i<tab[index].wdata_be.size() ; i++) {
     323        assert( (index < size_tab) and
     324        "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");
     325
     326        assert( (be.size()==tab[index].wdata_be.size()) and
     327        "MEMC ERROR: Bad be size in TRT write_data_mask()");
     328
     329        assert( (data.size()==tab[index].wdata.size()) and
     330        "MEMC ERROR: Bad data size in TRT write_data_mask()");
     331
     332        for(size_t i=0; i<tab[index].wdata_be.size() ; i++)
     333        {
    317334            tab[index].wdata_be[i] = tab[index].wdata_be[i] | be[i];
    318335            data_t mask = be_to_mask(be[i]);
     
    320337        }
    321338    }
    322 
    323339    /////////////////////////////////////////////////////////////////////
    324340    // The set() function registers a transaction (read or write)
     
    337353    // - data_be : the mask of the data to write (in case of write)
    338354    // - ll_key  : the ll key (if any) returned by the llsc_global_table
     355    // - config  : transaction required by config FSM
    339356    /////////////////////////////////////////////////////////////////////
    340357    void set(const size_t index,
     
    349366            const std::vector<be_t> &data_be,
    350367            const std::vector<data_t> &data,
    351             const data_t ll_key = 0)
    352     {
    353         assert( (index < size_tab)
    354                 && "The selected entry is out of range in set() Transaction Tab");
    355         assert(data_be.size()==tab[index].wdata_be.size()
    356                 && "Bad data_be argument in set() TransactionTab");
    357         assert(data.size()==tab[index].wdata.size()
    358                 && "Bad data argument in set() TransactionTab");
     368            const data_t ll_key = 0,
     369            const bool config = false)
     370    {
     371        assert( (index < size_tab) and
     372        "MEMC ERROR: The selected entry is out of range in TRT set()");
     373
     374        assert( (data_be.size()==tab[index].wdata_be.size()) and
     375        "MEMC ERROR: Bad data_be argument in TRT set()");
     376
     377        assert( (data.size()==tab[index].wdata.size()) and
     378        "MEMC ERROR: Bad data argument in TRT set()");
    359379
    360380        tab[index].valid                = true;
     
    368388        tab[index].word_index       = word_index;
    369389        tab[index].ll_key           = ll_key;
     390        tab[index].config           = config;
    370391        for(size_t i=0; i<tab[index].wdata.size(); i++)
    371392        {
     
    380401    // The BE field in TRT is taken into account.
    381402    // Arguments :
    382     // - index : the index of the transaction in the transaction tab
    383     // - word_index : the index of the data in the line
    384     // - data : a 64 bits value
    385     // - error : invalid data
     403    // - index : index of the entry in TRT
     404    // - word  : index of the 32 bits word in the line
     405    // - data  : 64 bits value (first data right)
    386406    /////////////////////////////////////////////////////////////////////
    387407    void write_rsp(const size_t      index,
    388408                   const size_t      word,
    389                    const wide_data_t data,
    390                    const bool        rerror)
     409                   const wide_data_t data)
    391410    {
    392411        data_t  value;
    393412        data_t  mask;
    394413
    395         if ( index >= size_tab )
    396         {
    397             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    398                       <<  " TRT entry  out of range in write_rsp()" << std::endl;
    399             exit(0);
    400         }
    401         if ( word > tab[index].wdata_be.size() )
    402         {
    403             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    404                       <<  " Bad word_index in write_rsp() in TRT" << std::endl;
    405             exit(0);
    406         }
    407         if ( not tab[index].valid )
    408         {
    409             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    410                       <<  " TRT Entry invalid in write_rsp()" << std::endl;
    411             exit(0);
    412         }
    413         if ( not tab[index].xram_read )
    414         {
    415             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    416                       <<  " TRT entry is not an XRAM GET in write_rsp()" << std::endl;
    417             exit(0);
    418         }
     414        assert( (index < size_tab) and
     415        "MEMC ERROR: The selected entry is out of range in TRT write_rsp()");
     416
     417        assert( (word < tab[index].wdata_be.size()) and
     418        "MEMC ERROR: Bad word index in TRT write_rsp()");
     419
     420        assert( (tab[index].valid) and
     421        "MEMC ERROR: TRT entry not valid in TRT write_rsp()");
     422
     423        assert( (tab[index].xram_read ) and
     424        "MEMC ERROR: TRT entry is not a GET in TRT write_rsp()");
    419425
    420426        // first 32 bits word
     
    427433        mask  = be_to_mask(tab[index].wdata_be[word+1]);
    428434        tab[index].wdata[word+1] = (tab[index].wdata[word+1] & mask) | (value & ~mask);
    429 
    430         // error update
    431         tab[index].rerror |= rerror;
    432     }
    433 
     435    }
    434436    /////////////////////////////////////////////////////////////////////
    435437    // The erase() function erases an entry in the transaction tab.
     
    439441    void erase(const size_t index)
    440442    {
    441         assert( (index < size_tab)
    442                 && "The selected entry is out of range in erase() Transaction Tab");
     443        assert( (index < size_tab) and
     444        "MEMC ERROR: The selected entry is out of range in TRT erase()");
     445
    443446        tab[index].valid        = false;
    444447        tab[index].rerror   = false;
     448    }
     449    /////////////////////////////////////////////////////////////////////
     450    // The is_config() function returns the config flag value.
     451    // Arguments :
     452    // - index : the index of the entry in the transaction tab
     453    /////////////////////////////////////////////////////////////////////
     454    bool is_config(const size_t index)
     455    {
     456        assert( (index < size_tab) and
     457        "MEMC ERROR: The selected entry is out of range in TRT is_config()");
     458
     459        return tab[index].config;
    445460    }
    446461}; // end class TransactionTab
Note: See TracChangeset for help on using the changeset viewer.