update DRAM simulation - reduce the latency of duplicate requests (simulate DRAM cache)
This commit is contained in:
@@ -245,15 +245,17 @@ void opae_sim::sTxPort_bus() {
|
||||
}
|
||||
|
||||
void opae_sim::avs_bus() {
|
||||
// schedule DRAM read responses
|
||||
// update DRAM responses schedule
|
||||
for (auto& rsp : dram_reads_) {
|
||||
if (rsp.cycles_left > 0)
|
||||
rsp.cycles_left -= 1;
|
||||
}
|
||||
|
||||
// schedule DRAM responses in FIFO order
|
||||
std::list<dram_rd_req_t>::iterator dram_rd_it(dram_reads_.end());
|
||||
for (auto it = dram_reads_.begin(), ie = dram_reads_.end(); it != ie; ++it) {
|
||||
if (it->cycles_left > 0) {
|
||||
it->cycles_left -= 1;
|
||||
}
|
||||
if ((it != ie) && (it->cycles_left == 0)) {
|
||||
dram_rd_it = it;
|
||||
}
|
||||
if (!dram_reads_.empty()
|
||||
&& (0 == dram_reads_.begin()->cycles_left)) {
|
||||
dram_rd_it = dram_reads_.begin();
|
||||
}
|
||||
|
||||
// send DRAM response
|
||||
@@ -304,6 +306,12 @@ void opae_sim::avs_bus() {
|
||||
dram_req.addr = vortex_afu_->avs_address;
|
||||
ram_.read(vortex_afu_->avs_address * CACHE_BLOCK_SIZE, CACHE_BLOCK_SIZE, dram_req.block.data());
|
||||
dram_req.cycles_left = DRAM_LATENCY;
|
||||
for (auto& rsp : dram_reads_) {
|
||||
if (dram_req.addr == rsp.addr) {
|
||||
dram_req.cycles_left = rsp.cycles_left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dram_reads_.emplace_back(dram_req);
|
||||
/*printf("%0ld: [sim] DRAM Rd Req: addr=%x, pending={", timestamp, dram_req.addr * CACHE_BLOCK_SIZE);
|
||||
for (auto& req : dram_reads_) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
`endif
|
||||
|
||||
`ifndef NUM_THREADS
|
||||
`define NUM_THREADS 4
|
||||
`define NUM_THREADS 8
|
||||
`endif
|
||||
|
||||
`ifndef NUM_BARRIERS
|
||||
|
||||
@@ -127,15 +127,17 @@ void Simulator::eval_dram_bus() {
|
||||
return;
|
||||
}
|
||||
|
||||
// schedule DRAM responses
|
||||
// update DRAM responses schedule
|
||||
for (auto& rsp : dram_rsp_vec_) {
|
||||
if (rsp.cycles_left > 0)
|
||||
rsp.cycles_left -= 1;
|
||||
}
|
||||
|
||||
// schedule DRAM responses in FIFO order
|
||||
std::list<dram_req_t>::iterator dram_rsp_it(dram_rsp_vec_.end());
|
||||
for (auto it = dram_rsp_vec_.begin(), ie = dram_rsp_vec_.end(); it != ie; ++it) {
|
||||
if (it->cycles_left > 0) {
|
||||
it->cycles_left -= 1;
|
||||
}
|
||||
if ((dram_rsp_it == ie) && (it->cycles_left == 0)) {
|
||||
dram_rsp_it = it;
|
||||
}
|
||||
if (!dram_rsp_vec_.empty()
|
||||
&& (0 == dram_rsp_vec_.begin()->cycles_left)) {
|
||||
dram_rsp_it = dram_rsp_vec_.begin();
|
||||
}
|
||||
|
||||
// send DRAM response
|
||||
@@ -180,9 +182,16 @@ void Simulator::eval_dram_bus() {
|
||||
}
|
||||
} else {
|
||||
dram_req_t dram_req;
|
||||
dram_req.tag = vortex_->dram_req_tag;
|
||||
dram_req.tag = vortex_->dram_req_tag;
|
||||
dram_req.addr = vortex_->dram_req_addr;
|
||||
ram_->read(vortex_->dram_req_addr * GLOBAL_BLOCK_SIZE, GLOBAL_BLOCK_SIZE, dram_req.block.data());
|
||||
dram_req.cycles_left = DRAM_LATENCY;
|
||||
dram_req.cycles_left = DRAM_LATENCY;
|
||||
for (auto& rsp : dram_rsp_vec_) {
|
||||
if (dram_req.addr == rsp.addr) {
|
||||
dram_req.cycles_left = rsp.cycles_left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dram_rsp_vec_.emplace_back(dram_req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ private:
|
||||
typedef struct {
|
||||
int cycles_left;
|
||||
std::array<uint8_t, GLOBAL_BLOCK_SIZE> block;
|
||||
uint32_t addr;
|
||||
uint32_t tag;
|
||||
} dram_req_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user