/* * Copyright (c) 2015, University of Kaiserslautern * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: * Janik Schlemminger * Matthias Jung */ #ifndef SIMULATION_H_ #define SIMULATION_H_ #include "Dram.h" #include "Arbiter.h" #include "TracePlayer.h" #include "TraceGenerator.h" #include "ReorderBuffer.h" #include "../controller/Controller.h" #include #include #include "TracePlayerListener.h" #include "../common/third_party/tinyxml2/tinyxml2.h" #include "../error/flip_memory.h" struct DramSetup { DramSetup():memspec(NULL),memconfig(NULL),simconfig(NULL),addressmapping(NULL){} DramSetup(tinyxml2::XMLElement* memspec, tinyxml2::XMLElement* memconfig, tinyxml2::XMLElement* simconfig, tinyxml2::XMLElement* addressmapping) : memspec(memspec), memconfig(memconfig), simconfig(simconfig), addressmapping(addressmapping) {} tinyxml2::XMLElement* memspec; tinyxml2::XMLElement* memconfig; tinyxml2::XMLElement* simconfig; tinyxml2::XMLElement* addressmapping; }; struct Device { Device():trace("empty.stl"), burstLength(0){} Device(std::string trace, unsigned int clkMhz, unsigned int burstLength = 8) : trace(trace), clkMhz (clkMhz), burstLength(burstLength) { } std::string trace; unsigned int clkMhz; unsigned int burstLength; }; 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(); void start(); void stop(); virtual void tracePlayerTerminates() override; // TODO: this information should be get from configuration constexpr static unsigned int NumberOfTracePlayers = 4; // TODO: this information should be get from configuration constexpr static unsigned int NumberOfMemChannels = 1; private: std::string traceName; DramSetup dramSetup; 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; // TODO: here should be a vector or some other abstract data type and elements should be dynamically allocated based on configuration TracePlayer<> *player1; TracePlayer<> *player2; TracePlayer<> *player3; TracePlayer<> *player4; clock_t simulationStartTime; void report(std::string message); void setupDebugManager(const string& traceName); void setupTlmRecorder(const string &traceName, const string &pathToResources, const std::vector &devices); void instantiateModules(const string &pathToResources, const std::vector &devices); void bindSockets(); }; #endif /* SIMULATIONMANAGER_H_ */