#ifndef XRAM_TRANSACTION_H_ #define XRAM_TRANSACTION_H_ #include #include #include #include "arithmetics.h" #define DEBUG_XRAM_TRANSACTION 0 //////////////////////////////////////////////////////////////////////// // A transaction tab entry //////////////////////////////////////////////////////////////////////// class TransactionTabEntry { typedef sc_dt::sc_uint<64> wide_data_t; typedef sc_dt::sc_uint<40> addr_t; typedef uint32_t data_t; typedef uint32_t be_t; public: bool valid; // entry valid bool xram_read; // read request to XRAM addr_t nline; // index (zy) of the requested line size_t srcid; // processor requesting the transaction size_t trdid; // processor requesting the transaction size_t pktid; // processor requesting the transaction bool proc_read; // read request from processor size_t read_length; // length of the read (for the response) size_t word_index; // index of the first read word (for the response) std::vector wdata; // write buffer (one cache line) std::vector wdata_be; // be for each data in the write buffer bool rerror; // error returned by xram data_t ll_key; // LL key returned by the llsc_global_table ///////////////////////////////////////////////////////////////////// // The init() function initializes the entry ///////////////////////////////////////////////////////////////////// void init() { valid = false; rerror = false; } ///////////////////////////////////////////////////////////////////// // The alloc() function initializes the vectors of an entry // Its arguments are : // - n_words : number of words per line in the cache ///////////////////////////////////////////////////////////////////// void alloc(size_t n_words) { wdata_be.reserve( (int)n_words ); wdata.reserve( (int)n_words ); for(size_t i=0; i &be, const std::vector &data) { assert( (index < size_tab) && "Invalid Transaction Tab Entry"); assert(be.size()==tab[index].wdata_be.size() && "Bad data mask in write_data_mask in TransactionTab"); assert(data.size()==tab[index].wdata.size() && "Bad data in write_data_mask in TransactionTab"); for(size_t i=0; i &data_be, const std::vector &data, const data_t ll_key = 0) { assert( (index < size_tab) && "The selected entry is out of range in set() Transaction Tab"); assert(data_be.size()==tab[index].wdata_be.size() && "Bad data_be argument in set() TransactionTab"); assert(data.size()==tab[index].wdata.size() && "Bad data argument in set() TransactionTab"); tab[index].valid = true; tab[index].xram_read = xram_read; tab[index].nline = nline; tab[index].srcid = srcid; tab[index].trdid = trdid; tab[index].pktid = pktid; tab[index].proc_read = proc_read; tab[index].read_length = read_length; tab[index].word_index = word_index; tab[index].ll_key = ll_key; for(size_t i=0; i= size_tab ) { std::cout << "VCI_MEM_CACHE ERRROR " << tab_name << " TRT entry out of range in write_rsp()" << std::endl; exit(0); } if ( word > tab[index].wdata_be.size() ) { std::cout << "VCI_MEM_CACHE ERRROR " << tab_name << " Bad word_index in write_rsp() in TRT" << std::endl; exit(0); } if ( not tab[index].valid ) { std::cout << "VCI_MEM_CACHE ERRROR " << tab_name << " TRT Entry invalid in write_rsp()" << std::endl; exit(0); } if ( not tab[index].xram_read ) { std::cout << "VCI_MEM_CACHE ERRROR " << tab_name << " TRT entry is not an XRAM GET in write_rsp()" << std::endl; exit(0); } // first 32 bits word value = (data_t)data; mask = be_to_mask(tab[index].wdata_be[word]); tab[index].wdata[word] = (tab[index].wdata[word] & mask) | (value & ~mask); // second 32 bits word value = (data_t)(data>>32); mask = be_to_mask(tab[index].wdata_be[word+1]); tab[index].wdata[word+1] = (tab[index].wdata[word+1] & mask) | (value & ~mask); // error update tab[index].rerror |= rerror; } ///////////////////////////////////////////////////////////////////// // The erase() function erases an entry in the transaction tab. // Arguments : // - index : the index of the request in the transaction tab ///////////////////////////////////////////////////////////////////// void erase(const size_t index) { assert( (index < size_tab) && "The selected entry is out of range in erase() Transaction Tab"); tab[index].valid = false; tab[index].rerror = false; } }; // end class TransactionTab #endif // Local Variables: // tab-width: 4 // c-basic-offset: 4 // c-file-offsets:((innamespace . 0)(inline-open . 0)) // indent-tabs-mode: nil // End: // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4