dram simulator fix
This commit is contained in:
@@ -13,6 +13,7 @@ DISABLE_WARNING_POP
|
||||
|
||||
#include "constants.h"
|
||||
#include "types.h"
|
||||
#include "debug.h"
|
||||
|
||||
using namespace vortex;
|
||||
|
||||
@@ -51,37 +52,50 @@ public:
|
||||
return perf_stats_;
|
||||
}
|
||||
|
||||
void dram_callback(ramulator::Request& req, uint32_t tag) {
|
||||
MemRsp mem_rsp{tag, (uint32_t)req.coreid};
|
||||
void dram_callback(ramulator::Request& req, uint32_t tag, uint64_t uuid) {
|
||||
if (req.type == ramulator::Request::Type::WRITE)
|
||||
return;
|
||||
MemRsp mem_rsp{tag, (uint32_t)req.coreid, uuid};
|
||||
simobject_->MemRspPort.send(mem_rsp, 1);
|
||||
DT(3, simobject_->name() << "-" << mem_rsp);
|
||||
}
|
||||
|
||||
void step(uint64_t /*cycle*/) {
|
||||
dram_->tick();
|
||||
void reset() {
|
||||
perf_stats_ = PerfStats();
|
||||
}
|
||||
|
||||
void tick() {
|
||||
if (MEM_CYCLE_RATIO > 0) {
|
||||
auto cycle = SimPlatform::instance().cycles();
|
||||
if ((cycle % MEM_CYCLE_RATIO) == 0)
|
||||
dram_->tick();
|
||||
} else {
|
||||
for (int i = MEM_CYCLE_RATIO; i <= 0; ++i)
|
||||
dram_->tick();
|
||||
}
|
||||
|
||||
if (simobject_->MemReqPort.empty())
|
||||
return;
|
||||
|
||||
auto& mem_req = simobject_->MemReqPort.front();
|
||||
|
||||
if (mem_req.write) {
|
||||
ramulator::Request dram_req(
|
||||
mem_req.addr,
|
||||
ramulator::Request::Type::WRITE,
|
||||
mem_req.core_id
|
||||
);
|
||||
dram_->send(dram_req);
|
||||
ramulator::Request dram_req(
|
||||
mem_req.addr,
|
||||
mem_req.write ? ramulator::Request::Type::WRITE : ramulator::Request::Type::READ,
|
||||
std::bind(&Impl::dram_callback, this, placeholders::_1, mem_req.tag, mem_req.uuid),
|
||||
mem_req.core_id
|
||||
);
|
||||
|
||||
if (!dram_->send(dram_req))
|
||||
return;
|
||||
|
||||
if (mem_req.write) {
|
||||
++perf_stats_.writes;
|
||||
} else {
|
||||
ramulator::Request dram_req(
|
||||
mem_req.addr,
|
||||
ramulator::Request::Type::READ,
|
||||
std::bind(&Impl::dram_callback, this, placeholders::_1, mem_req.tag),
|
||||
mem_req.core_id
|
||||
);
|
||||
dram_->send(dram_req);
|
||||
++perf_stats_.reads;
|
||||
}
|
||||
|
||||
DT(3, simobject_->name() << "-" << mem_req);
|
||||
|
||||
simobject_->MemReqPort.pop();
|
||||
}
|
||||
@@ -89,8 +103,8 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MemSim::MemSim(const SimContext& ctx, const Config& config)
|
||||
: SimObject<MemSim>(ctx, "MemSim")
|
||||
MemSim::MemSim(const SimContext& ctx, const char* name, const Config& config)
|
||||
: SimObject<MemSim>(ctx, name)
|
||||
, MemReqPort(this)
|
||||
, MemRspPort(this)
|
||||
, impl_(new Impl(this, config))
|
||||
@@ -100,6 +114,10 @@ MemSim::~MemSim() {
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
void MemSim::step(uint64_t cycle) {
|
||||
impl_->step(cycle);
|
||||
void MemSim::reset() {
|
||||
impl_->reset();
|
||||
}
|
||||
|
||||
void MemSim::tick() {
|
||||
impl_->tick();
|
||||
}
|
||||
Reference in New Issue
Block a user