Changes in the Arbiter block: - now multiple initiator sockets are possible. These intiator sockets connect to multiple memory controllers; - added lots of comments to the code in order to make it easier to understand. Changes in Simulaton[cpp,h]: - added TODO messages in some points that need to be changed to provide full support to multiple memory channles/controllers based on configuration.
120 lines
4.6 KiB
C++
120 lines
4.6 KiB
C++
/*
|
|
* 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 <string>
|
|
#include <systemc.h>
|
|
#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<Device> devices);
|
|
Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
|
|
std::vector<Device> 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<NumberOfTracePlayers, 128, NumberOfMemChannels> *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<Device> &devices);
|
|
void instantiateModules(const string &pathToResources, const std::vector<Device> &devices);
|
|
void bindSockets();
|
|
};
|
|
|
|
#endif /* SIMULATIONMANAGER_H_ */
|