Code cleanup for open sourcing.

This commit is contained in:
Lukas Steiner
2020-03-27 15:29:58 +01:00
parent aa246c31bf
commit b1efbb8721
15 changed files with 43 additions and 167 deletions

View File

@@ -65,17 +65,16 @@ include_directories(
)
add_library(DRAMSysLibrary
src/common/third_party/tinyxml2/tinyxml2.cpp
src/common/TlmRecorder.cpp
src/common/DebugManager.cpp
src/common/CongenAddressDecoder.cpp
src/common/XmlAddressDecoder.cpp
src/common/timingCalculations.cpp
src/common/dramExtensions.cpp
src/common/utils.cpp
src/common/AddressDecoder.cpp
src/common/CongenAddressDecoder.cpp
src/common/DebugManager.cpp
src/common/dramExtensions.cpp
src/common/protocol.h
src/common/tlm2_base_protocol_checker.h
src/common/TlmRecorder.cpp
src/common/utils.cpp
src/common/XmlAddressDecoder.cpp
src/common/third_party/tinyxml2/tinyxml2.cpp
src/configuration/Configuration.cpp
src/configuration/ConfigurationLoader.cpp
@@ -94,7 +93,7 @@ add_library(DRAMSysLibrary
src/controller/BankMachine.cpp
src/controller/Command.cpp
src/controller/GenericController.h
src/controller/ControllerIF.h
src/controller/Controller.cpp
src/controller/ControllerRecordable.cpp
@@ -141,12 +140,18 @@ add_library(DRAMSysLibrary
src/simulation/Arbiter.cpp
src/simulation/DRAMSys.cpp
src/simulation/ExampleInitiator.h
src/simulation/IArbiter.h
src/simulation/MemoryManager.cpp
src/simulation/ReorderBuffer.h
src/simulation/Setup.cpp
src/simulation/TemperatureController.cpp
src/simulation/TracePlayer.cpp
src/simulation/TraceSetup.cpp
src/simulation/SimpleArbiter.h
src/simulation/StlPlayer.h
src/simulation/TemperatureController.cpp
src/simulation/TraceGenerator.h
src/simulation/TracePlayer.cpp
src/simulation/TracePlayerListener.h
src/simulation/TraceSetup.cpp
src/simulation/dram/Dram.cpp
src/simulation/dram/DramRecordable.cpp

View File

@@ -124,10 +124,10 @@ void XmlAddressDecoder::setConfiguration(std::string addressConfigURI)
Configuration &config = Configuration::getInstance();
MemSpec *memSpec = config.memSpec;
if (config.NumberOfMemChannels != amount.channel || memSpec->NumberOfRanks != amount.rank
if (config.numberOfMemChannels != amount.channel || memSpec->NumberOfRanks != amount.rank
|| memSpec->NumberOfBankGroups != amount.bankgroup || memSpec->NumberOfBanks != amount.bank
|| memSpec->NumberOfRows != amount.row || memSpec->NumberOfColumns != amount.column
|| config.NumberOfDevicesOnDIMM * memSpec->bitWidth != amount.bytes * 8)
|| config.numberOfDevicesOnDIMM * memSpec->bitWidth != amount.bytes * 8)
SC_REPORT_FATAL("XmlAddressDecoder", "Memspec and addressmapping do not match");
}

View File

@@ -1,71 +0,0 @@
/*
* 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
*/
#include "timingCalculations.h"
#include "../configuration/memspec/MemSpec.h"
#include "DebugManager.h"
#include "../configuration/Configuration.h"
#include "utils.h"
sc_time getDelayToMeetConstraint(sc_time previous, sc_time start,
sc_time constraint)
{
if (previous + constraint > start)
return previous + constraint - start;
else
return SC_ZERO_TIME;
}
const sc_time FrequencyToClk(double frequencyMhz)
{
return sc_time(1 / frequencyMhz, SC_US);
}
const sc_time clkAlign(sc_time time, Alignment alignment)
{
sc_time clk = Configuration::getInstance().memSpec->clk;
if (alignment == UP)
return ceil(time / clk) * clk;
else
return floor(time / clk) * clk;
}
bool isClkAligned(sc_time time, sc_time clk)
{
return !((time / clk) - ceil(time / clk));
}

View File

@@ -1,52 +0,0 @@
/*
* 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 TIMINGCALCULATIONS_H
#define TIMINGCALCULATIONS_H
#include <systemc.h>
#include <tlm.h>
#include "dramExtensions.h"
sc_time getDelayToMeetConstraint(sc_time previous, sc_time start,
sc_time constraint);
enum Alignment {UP, DOWN};
const sc_time clkAlign(sc_time time, Alignment alignment = UP);
bool isClkAligned(sc_time time, sc_time clk);
const sc_time FrequencyToClk(double frequencyMhz);
#endif // TIMINGCALCULATIONS_H

View File

@@ -46,7 +46,6 @@
#include "memspec/MemSpecGDDR5.h"
#include "memspec/MemSpecGDDR5X.h"
#include "memspec/MemSpecGDDR6.h"
#include "../common/timingCalculations.h"
using namespace tinyxml2;
using namespace std;
@@ -225,7 +224,7 @@ void ConfigurationLoader::loadCommons(Configuration &config, XMLElement *xmlSpec
// Clock
XMLElement *timings = xmlSpec->FirstChildElement("memtimingspec");
memSpec->clkMHz = queryDoubleParameter(timings, "clkMhz");
memSpec->clk = FrequencyToClk(memSpec->clkMHz);
memSpec->clk = sc_time(1.0 / memSpec->clkMHz, SC_US);
}
void ConfigurationLoader::loadDDR3(Configuration &config, XMLElement *xmlSpec)

View File

@@ -60,7 +60,7 @@
#include "powerdown/PowerDownManagerDummy.h"
Controller::Controller(sc_module_name name) :
GenericController(name)
ControllerIF(name)
{
SC_METHOD(controllerMethod);
sensitive << beginReqEvent << endRespEvent << controllerEvent << dataResponseEvent;

View File

@@ -42,7 +42,7 @@
#include <tlm.h>
#include <tlm_utils/simple_initiator_socket.h>
#include <tlm_utils/simple_target_socket.h>
#include "GenericController.h"
#include "ControllerIF.h"
#include "../common/dramExtensions.h"
#include "BankMachine.h"
#include "cmdmux/CmdMuxIF.h"
@@ -59,7 +59,7 @@ class BankMachine;
class SchedulerIF;
class PowerDownManagerStaggered;
class Controller : public GenericController
class Controller : public ControllerIF
{
public:
Controller(sc_module_name);

View File

@@ -1,5 +1,5 @@
#ifndef GENERICCONTROLLER_H
#define GENERICCONTROLLER_H
#ifndef CONTROLLERIF_H
#define CONTROLLERIF_H
#include <systemc.h>
#include <tlm.h>
@@ -11,15 +11,15 @@ using namespace tlm;
// Utiliy class to pass around the DRAMSys, without having to propagate the template defintions
// throughout all classes
class GenericController : public sc_module
class ControllerIF : public sc_module
{
public:
// Already create and bind sockets to the virtual functions
tlm_utils::simple_target_socket<GenericController> tSocket; // Arbiter side
tlm_utils::simple_initiator_socket<GenericController> iSocket; // DRAM side
tlm_utils::simple_target_socket<ControllerIF> tSocket; // Arbiter side
tlm_utils::simple_initiator_socket<ControllerIF> iSocket; // DRAM side
// Destructor
virtual ~GenericController()
virtual ~ControllerIF()
{
sc_time activeTime = numberOfTransactionsServed
* Configuration::getInstance().memSpec->BurstLength
@@ -60,14 +60,14 @@ public:
protected:
// Bind sockets with virtual functions
GenericController(sc_module_name name) :
ControllerIF(sc_module_name name) :
sc_module(name), tSocket("tSocket"), iSocket("iSocket")
{
tSocket.register_nb_transport_fw(this, &GenericController::nb_transport_fw);
tSocket.register_transport_dbg(this, &GenericController::transport_dbg);
iSocket.register_nb_transport_bw(this, &GenericController::nb_transport_bw);
tSocket.register_nb_transport_fw(this, &ControllerIF::nb_transport_fw);
tSocket.register_transport_dbg(this, &ControllerIF::transport_dbg);
iSocket.register_nb_transport_bw(this, &ControllerIF::nb_transport_bw);
}
SC_HAS_PROCESS(GenericController);
SC_HAS_PROCESS(ControllerIF);
// Virtual transport functions
virtual tlm_sync_enum nb_transport_fw(tlm_generic_payload &, tlm_phase &, sc_time &) = 0;
@@ -80,4 +80,4 @@ protected:
};
#endif // GENERICCONTROLLER_H
#endif // CONTROLLERIF_H

View File

@@ -48,7 +48,6 @@
#include <tlm_utils/peq_with_cb_and_phase.h>
#include "../common/XmlAddressDecoder.h"
#include "../common/dramExtensions.h"
#include "../common/timingCalculations.h"
#include "../configuration/ConfigurationLoader.h"
using namespace std;

View File

@@ -253,7 +253,7 @@ void DRAMSys::instantiateModules(const string &traceName,
{
std::string str = "controller" + std::to_string(i);
GenericController *controller;
ControllerIF *controller;
if (recordingEnabled)
controller = new ControllerRecordable(str.c_str(), tlmRecorders[i]);
else

View File

@@ -51,7 +51,7 @@
#include "../common/third_party/tinyxml2/tinyxml2.h"
#include "../common/tlm2_base_protocol_checker.h"
#include "../error/eccbaseclass.h"
#include "../controller/GenericController.h"
#include "../controller/ControllerIF.h"
#include "../common/TlmRecorder.h"
class DRAMSys : public sc_module
@@ -87,8 +87,7 @@ private:
// All transactions pass through the same arbiter
Arbiter *arbiter;
// Each DRAM unit has a controller
std::vector<GenericController *> controllers;
//std::vector<GenericController *> controllers;
std::vector<ControllerIF *> controllers;
// TODO: Each DRAM has a reorder buffer (check this!)
ReorderBuffer *reorder;

View File

@@ -52,7 +52,7 @@ public:
if (clkMhz == 0)
clk = Configuration::getInstance().memSpec->clk;
else
clk = FrequencyToClk(clkMhz);
clk = sc_time(1.0 / clkMhz, SC_US);
this->burstlenght = Configuration::getInstance().memSpec->BurstLength;
}

View File

@@ -50,7 +50,6 @@
#include "../configuration/Configuration.h"
#include "../common/DebugManager.h"
#include "../common/XmlAddressDecoder.h"
#include "../common/timingCalculations.h"
#include "TracePlayerListener.h"
using namespace std;

View File

@@ -61,13 +61,12 @@ traceSetup::traceSetup(std::string uri,
device = device->NextSiblingElement("device"))
{
sc_time playerClk;
unsigned int frequency = device->IntAttribute("clkMhz");
unsigned int frequencyMHz = device->IntAttribute("clkMhz");
if (frequency == 0) {
if (frequencyMHz == 0)
reportFatal("traceSetup", "No Frequency Defined");
} else {
playerClk = FrequencyToClk(frequency);
}
else
playerClk = sc_time(1.0 / frequencyMHz, SC_US);
std::string name = device->GetText();

View File

@@ -54,7 +54,6 @@
#include <stdlib.h>
#include "../../common/DebugManager.h"
#include "../../common/dramExtensions.h"
#include "../../common/timingCalculations.h"
#include "../../configuration/Configuration.h"
#include "../../common/protocol.h"
#include "../../common/utils.h"