From d71e649447d357b000a7f91b56074aa5bd7da7f3 Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Tue, 14 Jan 2025 14:55:11 +0100 Subject: [PATCH] Fix the verification of generator parameters Also, clamp the read write ratio instead of generating an error --- src/simulator/simulator/generator/RandomProducer.cpp | 5 ++--- src/simulator/simulator/generator/SequentialProducer.cpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/simulator/simulator/generator/RandomProducer.cpp b/src/simulator/simulator/generator/RandomProducer.cpp index 3cc18299..b954bd46 100644 --- a/src/simulator/simulator/generator/RandomProducer.cpp +++ b/src/simulator/simulator/generator/RandomProducer.cpp @@ -57,13 +57,12 @@ RandomProducer::RandomProducer(uint64_t numRequests, SC_REPORT_FATAL("TrafficGenerator", "minAddress is out of range."); if (maxAddress > memorySize - 1) - SC_REPORT_FATAL("TrafficGenerator", "minAddress is out of range."); + SC_REPORT_FATAL("TrafficGenerator", "maxAddress is out of range."); if (maxAddress < minAddress) SC_REPORT_FATAL("TrafficGenerator", "maxAddress is smaller than minAddress."); - if (rwRatio < 0 || rwRatio > 1) - SC_REPORT_FATAL("TraceSetup", "Read/Write ratio is not a number between 0 and 1."); + rwRatio = std::clamp(rwRatio, 0.0, 1.0); } Request RandomProducer::nextRequest() diff --git a/src/simulator/simulator/generator/SequentialProducer.cpp b/src/simulator/simulator/generator/SequentialProducer.cpp index 9c0d552e..43cfa525 100644 --- a/src/simulator/simulator/generator/SequentialProducer.cpp +++ b/src/simulator/simulator/generator/SequentialProducer.cpp @@ -57,13 +57,12 @@ SequentialProducer::SequentialProducer(uint64_t numRequests, SC_REPORT_FATAL("TrafficGenerator", "minAddress is out of range."); if (maxAddress > memorySize - 1) - SC_REPORT_FATAL("TrafficGenerator", "minAddress is out of range."); + SC_REPORT_FATAL("TrafficGenerator", "maxAddress is out of range."); if (maxAddress < minAddress) SC_REPORT_FATAL("TrafficGenerator", "maxAddress is smaller than minAddress."); - if (rwRatio < 0 || rwRatio > 1) - SC_REPORT_FATAL("TraceSetup", "Read/Write ratio is not a number between 0 and 1."); + rwRatio = std::clamp(rwRatio, 0.0, 1.0); } Request SequentialProducer::nextRequest()