2014-09-12 19:15:04 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2012-12-04 16:04:26 +01:00
|
|
|
#ifndef _MM_EMULATOR_DRAMSIM2_H
|
|
|
|
#define _MM_EMULATOR_DRAMSIM2_H
|
|
|
|
|
|
|
|
#include "mm.h"
|
|
|
|
#include <DRAMSim.h>
|
|
|
|
#include <map>
|
|
|
|
#include <queue>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
class mm_dramsim2_t : public mm_t
|
|
|
|
{
|
|
|
|
public:
|
2015-10-14 20:33:18 +02:00
|
|
|
mm_dramsim2_t() : store_inflight(false) {}
|
2012-12-04 16:04:26 +01:00
|
|
|
|
2013-05-02 13:58:43 +02:00
|
|
|
virtual void init(size_t sz, int word_size, int line_size);
|
2012-12-04 16:04:26 +01:00
|
|
|
|
2015-10-14 20:33:18 +02:00
|
|
|
virtual bool ar_ready() { return mem->willAcceptTransaction(); }
|
|
|
|
virtual bool aw_ready() { return mem->willAcceptTransaction() && !store_inflight; }
|
|
|
|
virtual bool w_ready() { return store_inflight; }
|
|
|
|
virtual bool b_valid() { return !bresp.empty(); }
|
|
|
|
virtual uint64_t b_resp() { return 0; }
|
|
|
|
virtual uint64_t b_id() { return b_valid() ? bresp.front() : 0; }
|
|
|
|
virtual bool r_valid() { return !rresp.empty(); }
|
|
|
|
virtual uint64_t r_resp() { return 0; }
|
|
|
|
virtual uint64_t r_id() { return r_valid() ? rresp.front().id: 0; }
|
|
|
|
virtual void *r_data() { return r_valid() ? &rresp.front().data[0] : &dummy_data[0]; }
|
|
|
|
virtual bool r_last() { return r_valid() ? rresp.front().last : false; }
|
2012-12-04 16:04:26 +01:00
|
|
|
|
|
|
|
virtual void tick
|
|
|
|
(
|
2015-10-14 20:33:18 +02:00
|
|
|
bool ar_valid,
|
|
|
|
uint64_t ar_addr,
|
|
|
|
uint64_t ar_id,
|
|
|
|
uint64_t ar_size,
|
|
|
|
uint64_t ar_len,
|
|
|
|
|
|
|
|
bool aw_valid,
|
|
|
|
uint64_t aw_addr,
|
|
|
|
uint64_t aw_id,
|
|
|
|
uint64_t aw_size,
|
|
|
|
uint64_t aw_len,
|
|
|
|
|
|
|
|
bool w_valid,
|
|
|
|
uint64_t w_strb,
|
|
|
|
void *w_data,
|
|
|
|
bool w_last,
|
|
|
|
|
|
|
|
bool r_ready,
|
|
|
|
bool b_ready
|
2012-12-04 16:04:26 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DRAMSim::MultiChannelMemorySystem *mem;
|
|
|
|
uint64_t cycle;
|
|
|
|
|
|
|
|
bool store_inflight;
|
|
|
|
uint64_t store_addr;
|
2015-10-14 20:33:18 +02:00
|
|
|
uint64_t store_id;
|
|
|
|
uint64_t store_size;
|
|
|
|
uint64_t store_count;
|
2012-12-04 16:04:26 +01:00
|
|
|
std::vector<char> dummy_data;
|
2015-10-14 20:33:18 +02:00
|
|
|
std::queue<uint64_t> bresp;
|
2016-03-29 22:51:59 +02:00
|
|
|
std::map<uint64_t, std::queue<uint64_t> > wreq;
|
2012-12-04 16:04:26 +01:00
|
|
|
|
2016-07-11 21:16:24 +02:00
|
|
|
std::map<uint64_t, std::queue<mm_rresp_t> > rreq;
|
2015-10-14 20:33:18 +02:00
|
|
|
std::queue<mm_rresp_t> rresp;
|
2012-12-04 16:04:26 +01:00
|
|
|
|
|
|
|
void read_complete(unsigned id, uint64_t address, uint64_t clock_cycle);
|
|
|
|
void write_complete(unsigned id, uint64_t address, uint64_t clock_cycle);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|