Apply minor changes to TrafficInitiator and TrafficGenerator

This commit is contained in:
2021-05-19 11:37:05 +02:00
parent fdacb97c9b
commit 1d5bd72c60
9 changed files with 19 additions and 104 deletions

View File

@@ -47,7 +47,6 @@ add_executable(DRAMSys
ExampleInitiator.h
MemoryManager.cpp
StlPlayer.cpp
TracePlayer.cpp
TrafficGenerator.cpp
TrafficInitiator.cpp
TraceSetup.cpp

View File

@@ -49,7 +49,7 @@ StlPlayer::StlPlayer(const sc_module_name &name,
unsigned int maxPendingWriteRequests,
TraceSetup *setup,
bool relative)
: TracePlayer(name, setup), file(pathToTrace),
: TrafficInitiator(name, setup), file(pathToTrace),
currentBuffer(&lineContents[0]),
parseBuffer(&lineContents[1]),
relative(relative)

View File

@@ -46,7 +46,7 @@
#include <array>
#include <thread>
#include "TraceSetup.h"
#include "TracePlayer.h"
#include "TrafficInitiator.h"
struct LineContent
{
@@ -56,7 +56,7 @@ struct LineContent
std::vector<unsigned char> data;
};
class StlPlayer : public TracePlayer
class StlPlayer : public TrafficInitiator
{
public:
StlPlayer(const sc_module_name &name,

View File

@@ -1,41 +0,0 @@
/*
* Copyright (c) 2021, Technische Universität 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.
*
* Author:
* Derek Christ
*/
#include "TracePlayer.h"
TracePlayer::TracePlayer(const sc_core::sc_module_name &name, TraceSetup *setup) :
TrafficInitiator(name, setup)
{
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2021, Technische Universität 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.
*
* Author:
* Derek Christ
*/
#ifndef TRACEPLAYER_H
#define TRACEPLAYER_H
#include <systemc.h>
#include "TrafficInitiator.h"
class TracePlayer : public TrafficInitiator
{
protected:
TracePlayer(const sc_module_name &name, TraceSetup *setup);
};
#endif // TRACEPLAYER_H

View File

@@ -151,7 +151,7 @@ TraceSetup::TraceSetup(const std::string &uri,
if (addressDistribution == "sequential")
{
unsigned int addressIncrement = 0x0;
uint64_t addressIncrement = 0x0;
if (!value["addressIncrement"].is_number_unsigned())
SC_REPORT_FATAL("TraceSetup", "Address increment is not a number.");

View File

@@ -59,7 +59,8 @@ TrafficGenerator::TrafficGenerator(const sc_module_name &name,
void TrafficGenerator::nextPayload()
{
if (transactionsSent >= numRequests) {
if (transactionsSent >= numRequests)
{
finished = true;
return;
}
@@ -72,9 +73,12 @@ void TrafficGenerator::nextPayload()
uint64_t address = getNextAddress();
tlm::tlm_command command;
if (randomRwDistribution(randomGenerator) < rwRatio) {
if (randomRwDistribution(randomGenerator) < rwRatio)
{
command = tlm::TLM_READ_COMMAND;
} else {
}
else
{
command = tlm::TLM_WRITE_COMMAND;
}
@@ -131,7 +135,8 @@ TrafficGeneratorSequential::TrafficGeneratorSequential(const sc_core::sc_module_
uint64_t numRequests,
unsigned int maxPendingReadRequests,
unsigned int maxPendingWriteRequests,
float rwRatio, unsigned int addressIncrement,
float rwRatio,
uint64_t addressIncrement,
unsigned int seed,
TraceSetup *setup) :
TrafficGenerator(name, tCK, numRequests, maxPendingReadRequests,

View File

@@ -64,9 +64,8 @@ protected:
private:
unsigned int burstlenght;
sc_time tCK;
unsigned int numRequests;
uint64_t numRequests;
float rwRatio;
unsigned int addressIncrement;
std::uniform_real_distribution<float> randomRwDistribution = std::uniform_real_distribution<float>(0.0f, 1.0f);
};
@@ -98,15 +97,15 @@ public:
unsigned int maxPendingReadRequests,
unsigned int maxPendingWriteRequests,
float rwRatio,
unsigned int addressIncrement,
uint64_t addressIncrement,
unsigned int seed,
TraceSetup *setup);
private:
virtual uint64_t getNextAddress() override;
unsigned int currentAddress = 0x0;
unsigned int addressIncrement;
uint64_t currentAddress = 0x0;
uint64_t addressIncrement;
};
#endif // TRAFFICGENERATOR_H

View File

@@ -96,7 +96,8 @@ void TrafficInitiator::peqCallback(tlm_generic_payload &payload,
pendingWriteRequests--;
// If the initiator wasn't able to send the next payload in the END_REQ phase, do it now.
if (payloadPostponed) {
if (payloadPostponed)
{
nextPayload();
payloadPostponed = false;
}