Skip to content

Commit 4785736

Browse files
committed
minor update
1 parent 38861d9 commit 4785736

File tree

1 file changed

+10
-53
lines changed

1 file changed

+10
-53
lines changed

sim/simx/cache_sim.cpp

+10-53
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ class CacheSim::Impl {
328328
{
329329
char sname[100];
330330

331-
//std::cout << "*** " << simobject->name() << ": banks=" << (int)(1 << config.B) << ", mem_ports=" << (int)config_.mem_ports << std::endl;
332-
333331
if (config_.bypass) {
334332
snprintf(sname, 100, "%s-bypass-arb", simobject->name().c_str());
335333
auto bypass_arb = MemArbiter::Create(sname, ArbiterType::RoundRobin, config_.num_inputs, config_.mem_ports);
@@ -357,58 +355,17 @@ class CacheSim::Impl {
357355
}
358356

359357
// Create bank's memory arbiter
360-
int mem_arb_type = 1;
361-
#ifdef L3_ARB_TYPE
362-
bool is_l3cache = simobject->name().find("l3cache") != std::string::npos;
363-
if (is_l3cache) {
364-
mem_arb_type = L3_ARB_TYPE;
365-
}
366-
#endif
367358
snprintf(sname, 100, "%s-bank-arb", simobject->name().c_str());
368-
switch (mem_arb_type) {
369-
case 0: {
370-
auto mem_xbar = MemCrossBar::Create(sname, ArbiterType::Priority, (1 << config.B), config_.mem_ports, 1,
371-
[lg2_block_size = log2ceil(MEM_BLOCK_SIZE), mem_ports=config_.mem_ports](const MemCrossBar::ReqType& req) {
372-
// Custom logic to calculate the output index using bank interleaving
373-
return (uint32_t)((req.addr >> lg2_block_size) & (mem_ports-1));
374-
});
375-
for (uint32_t i = 0, n = (1 << config.B); i < n; ++i) {
376-
mem_req_ports_.at(i).bind(&mem_xbar->ReqIn.at(i));
377-
mem_xbar->RspIn.at(i).bind(&mem_rsp_ports_.at(i));
378-
}
379-
// Connect bank's memory xbar to non-cacheable arbiter's input 0
380-
for (uint32_t i = 0; i < config_.mem_ports; ++i) {
381-
mem_xbar->ReqOut.at(i).bind(&nc_arbs_.at(i)->ReqIn.at(0));
382-
nc_arbs_.at(i)->RspIn.at(0).bind(&mem_xbar->RspOut.at(i));
383-
}
384-
} break;
385-
case 1: {
386-
auto bank_mem_arb = MemArbiter::Create(sname, ArbiterType::RoundRobin, (1 << config.B), config_.mem_ports);
387-
for (uint32_t i = 0, n = (1 << config.B); i < n; ++i) {
388-
mem_req_ports_.at(i).bind(&bank_mem_arb->ReqIn.at(i));
389-
bank_mem_arb->RspIn.at(i).bind(&mem_rsp_ports_.at(i));
390-
}
391-
// Connect bank's memory arbiter to non-cacheable arbiter's input 0
392-
for (uint32_t i = 0; i < config_.mem_ports; ++i) {
393-
bank_mem_arb->ReqOut.at(i).bind(&nc_arbs_.at(i)->ReqIn.at(0));
394-
nc_arbs_.at(i)->RspIn.at(0).bind(&bank_mem_arb->RspOut.at(i));
395-
}
396-
} break;
397-
case 2: {
398-
uint32_t k = (1 << config.B) / config_.mem_ports;
399-
assert(k > 1);
400-
auto bank_mem_arb = MemArbiter::Create(sname, ArbiterType::RoundRobin, (1 << config.B), config_.mem_ports);
401-
for (uint32_t i = 0, n = (1 << config.B); i < n; ++i) {
402-
uint32_t j = (i % config_.mem_ports) * k + (i / config_.mem_ports);
403-
mem_req_ports_.at(j).bind(&bank_mem_arb->ReqIn.at(i));
404-
bank_mem_arb->RspIn.at(i).bind(&mem_rsp_ports_.at(j));
405-
}
406-
// Connect bank's memory arbiter to non-cacheable arbiter's input 0
407-
for (uint32_t i = 0; i < config_.mem_ports; ++i) {
408-
bank_mem_arb->ReqOut.at(i).bind(&nc_arbs_.at(i)->ReqIn.at(0));
409-
nc_arbs_.at(i)->RspIn.at(0).bind(&bank_mem_arb->RspOut.at(i));
410-
}
411-
} break;
359+
auto bank_mem_arb = MemArbiter::Create(sname, ArbiterType::RoundRobin, (1 << config.B), config_.mem_ports);
360+
for (uint32_t i = 0, n = (1 << config.B); i < n; ++i) {
361+
mem_req_ports_.at(i).bind(&bank_mem_arb->ReqIn.at(i));
362+
bank_mem_arb->RspIn.at(i).bind(&mem_rsp_ports_.at(i));
363+
}
364+
365+
// Connect bank's memory arbiter to non-cacheable arbiter's input 0
366+
for (uint32_t i = 0; i < config_.mem_ports; ++i) {
367+
bank_mem_arb->ReqOut.at(i).bind(&nc_arbs_.at(i)->ReqIn.at(0));
368+
nc_arbs_.at(i)->RspIn.at(0).bind(&bank_mem_arb->RspOut.at(i));
412369
}
413370

414371
// calculate cache initialization cycles

0 commit comments

Comments
 (0)