From fbde607efdab25356a8d360a248c9ebeb5a1dfe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20Ferreira=20Zulian?= Date: Fri, 12 Jun 2015 18:08:32 +0200 Subject: [PATCH] Controllers and drams objects creation based base on the number of channels. --- dram/src/simulation/Simulation.cpp | 51 ++++++++++++++++++------------ dram/src/simulation/Simulation.h | 19 +++++------ 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/dram/src/simulation/Simulation.cpp b/dram/src/simulation/Simulation.cpp index 8dcc6ced..63123c04 100644 --- a/dram/src/simulation/Simulation.cpp +++ b/dram/src/simulation/Simulation.cpp @@ -100,46 +100,53 @@ void Simulation::setupTlmRecorder(const string &traceName, const string &pathToR void Simulation::instantiateModules(const string &pathToResources, const std::vector& devices) { - // TODO: the number of Drams objects or the number of target sockets in a Dram object should be proportional to the number of controllers/channles (info from config) - dram = new Dram<>("dram"); - arbiter = new Arbiter("arbiter"); - - // TODO: the number of controllers should be the number of channesl, right?! - // each of the arbiter's initiators sockets should bind to a controller... - // The number of channels is equal the number of controllers and comes from config. - controller = new Controller<>("controller"); - for (size_t i = 0; i < NumberOfTracePlayers; i++) { std::string playerStr = "player" + std::to_string(i); TracePlayer<> *player = new StlPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this); players.push_back(player); } + + arbiter = new Arbiter("arbiter"); + + for (size_t i = 0; i < NumberOfMemChannels; i++) { + std::string str = "controller" + std::to_string(i); + Controller<> *controller = new Controller<>(str.c_str()); + controllers.push_back(controller); + + str = "dram" + std::to_string(i); + Dram<> *dram = new Dram<>(str.c_str()); + drams.push_back(dram); + } } void Simulation::bindSockets() { - int i = 0; + size_t i = 0; for (auto player : players) { player->iSocket.bind(arbiter->tSockets[i++]); } - // TODO: the number of controllers should be the number of channesl, right?! - // each of the arbiter's initiators sockets should bind to a controller... - arbiter->iSocket[0].bind(controller->tSocket); - - controller->iSocket.bind(dram->tSocket); + for (i = 0; i < NumberOfMemChannels; i++) { + arbiter->iSocket[i].bind(controllers[i]->tSocket); + controllers[i]->iSocket.bind(drams[i]->tSocket); + } } Simulation::~Simulation() { - delete dram; - delete arbiter; - // TODO: the number of components should come from config - delete controller; - for (auto player : players) { delete player; } + + delete arbiter; + + for (auto controller : controllers) { + delete controller; + } + + for (auto dram : drams) { + delete dram; + } } void Simulation::start() @@ -173,7 +180,9 @@ void Simulation::stop() { wait(terminateSimulation); report("\nTerminating simulation"); - controller->terminateSimulation(); + for (auto controller : controllers) { + controller->terminateSimulation(); + } wait(sc_time(200, SC_NS)); TlmRecorder::getInstance().closeConnection(); sc_stop(); diff --git a/dram/src/simulation/Simulation.h b/dram/src/simulation/Simulation.h index 8cd8a1f5..bcc276ed 100644 --- a/dram/src/simulation/Simulation.h +++ b/dram/src/simulation/Simulation.h @@ -78,7 +78,6 @@ class Simulation: public sc_module, public TracePlayerListener { public: SC_HAS_PROCESS(Simulation); - //Simulation(sc_module_name name, string pathToResources, string traceName, std::vector devices); Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup, std::vector devices); ~Simulation(); @@ -98,15 +97,17 @@ private: sc_event terminateSimulation; - // TODO: here should be a vector or some other abstract data type and elements should be dynamically allocated based on configuration - Dram<> *dram; - Arbiter *arbiter; - // TODO: here should be a vector or some other abstract data type and elements should be dynamically allocated based on configuration - Controller<> *controller; - ReorderBuffer<> *reorder; - - // A vector of pointers to all trace player (that represent devices which acquire the bus and generate transactions targeting the memory) + // A vector of pointers to all trace player (devices which acquire the bus + // and initiate transactions targeting the memory) std::vector*> players; + // All transactions pass through the same arbiter + Arbiter *arbiter; + // Each DRAM unit has a controller + std::vector*> controllers; + // TODO: Each DRAM has a reorder buffer (check this!) + ReorderBuffer<> *reorder; + // DRAM units + std::vector*> drams; clock_t simulationStartTime; void report(std::string message);