Georgia Institute of Technology
CS4290/CS6290/ECE4100/ECE6100
How to iterate the mshr and check a memory type?
list::const_iterator cii;
m_mshr_entry_s* entry;
for (cii= m_mshr.begin() ; cii != m_mshr.end(); cii++) {
entry = (*cii);
if (!entry->valid) continue;
mem_req_s *req = entry->m_mem_req;
if (req->m_state == MEM_NEW) {
// do some useful work
// if you want to stop after doing useful work call retur here
return;
}
}
How to pop a memory request from a queue (e.g. queue1) and send it to another queue (eq. queue2)?
Basically,
(1) mem_req_s *t_mem_req = queue1.front() to get a memory request (you are just peeking the first entry in the queue)
(2) Ready to move to the other queue?
(3) queue.pop(): actually popping
(4) queue2.push_back(t_mem_req) : pushing the memory request into the back of the other queue
// check whether a queue is empty or not
if (dram_in_queue.empty()) return;
// calling front gives the first entry (read-only)
mem_req_s *t_mem_req = dram_in_queue.front();
// prevent from checking null objects
if (!t_mem_req) return;
// pop removes one entry from the queue.
dram_in_queue.pop_front();
assert(t_mem_req->m_state == MEM_DRAM_IN);
int dram_bank_id = get_dram_bank_id(t_mem_req->m_addr);
// push_back:
dram_bank_sch_queue[dram_bank_id].push_back(t_mem_req);
How to check store-load forwarding?
canpiggyback = check_piggyback()
if (canpiggyback) {
if (current_op == LOAD && matched_req->m_type == MRT_DSTORE) {
if ((matched_req->m_addr <= current_m_addr) &&
(matched_req->m_addr + matched_req->m_size >= current_m_addr + current_m_size)) {
// store-load fowarding
}
else
{
if (current_op == LOAD)
// add op into req_ops
}