#include "mem/ruby/network/garnet2.0/Router.hh"
CrossbarSwitch::CrossbarSwitch(Router *router)
- : Consumer(router)
+ : Consumer(router), m_router(router), m_num_vcs(m_router->get_num_vcs()),
+ m_crossbar_activity(0), switchBuffers(0)
{
- m_router = router;
- m_num_vcs = m_router->get_num_vcs();
- m_crossbar_activity = 0;
}
void
CrossbarSwitch::init()
{
- m_num_inports = m_router->get_num_inports();
- m_switch_buffer.resize(m_num_inports);
- for (int i = 0; i < m_num_inports; i++) {
- m_switch_buffer[i].reset(new flitBuffer());
- }
+ switchBuffers.resize(m_router->get_num_inports());
}
/*
"at time: %lld\n",
m_router->get_id(), m_router->curCycle());
- for (int inport = 0; inport < m_num_inports; inport++) {
- if (!m_switch_buffer[inport]->isReady(m_router->curCycle()))
+ for (auto& switch_buffer : switchBuffers) {
+ if (!switch_buffer.isReady(m_router->curCycle())) {
continue;
+ }
- flit *t_flit = m_switch_buffer[inport]->peekTopFlit();
+ flit *t_flit = switch_buffer.peekTopFlit();
if (t_flit->is_stage(ST_, m_router->curCycle())) {
int outport = t_flit->get_outport();
// This will take care of waking up the Network Link
// in the next cycle
m_router->getOutputUnit(outport)->insert_flit(t_flit);
- m_switch_buffer[inport]->getTopFlit();
+ switch_buffer.getTopFlit();
m_crossbar_activity++;
}
}
{
uint32_t num_functional_writes = 0;
- for (uint32_t i = 0; i < m_switch_buffer.size(); ++i) {
- num_functional_writes += m_switch_buffer[i]->functionalWrite(pkt);
+ for (auto& switch_buffer : switchBuffers) {
+ num_functional_writes += switch_buffer.functionalWrite(pkt);
}
return num_functional_writes;
#define __MEM_RUBY_NETWORK_GARNET2_0_CROSSBARSWITCH_HH__
#include <iostream>
-#include <memory>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet2.0/flitBuffer.hh"
class Router;
-class OutputUnit;
class CrossbarSwitch : public Consumer
{
void init();
void print(std::ostream& out) const {};
- inline void update_sw_winner(int inport, flit *t_flit)
- { m_switch_buffer[inport]->insert(t_flit); }
+ inline void
+ update_sw_winner(int inport, flit *t_flit)
+ {
+ switchBuffers[inport].insert(t_flit);
+ }
inline double get_crossbar_activity() { return m_crossbar_activity; }
void resetStats();
private:
+ Router *m_router;
int m_num_vcs;
- int m_num_inports;
double m_crossbar_activity;
- Router *m_router;
- std::vector<std::unique_ptr<flitBuffer>> m_switch_buffer;
+ std::vector<flitBuffer> switchBuffers;
};
#endif // __MEM_RUBY_NETWORK_GARNET2_0_CROSSBARSWITCH_HH__