summaryrefslogtreecommitdiff
path: root/src/cpu/testers
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2013-01-07 13:05:35 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2013-01-07 13:05:35 -0500
commitf22d3bb9c3a010bfe9681cf7b02e0fc39a694e49 (patch)
tree83169008ad696a220983a6e64407be8f2ae5c267 /src/cpu/testers
parent852a7bcf923af424de8df1ddbeb462d52de8383b (diff)
downloadgem5-f22d3bb9c3a010bfe9681cf7b02e0fc39a694e49.tar.xz
cpu: Fix the traffic gen read percentage
This patch fixes the computation that determines whether to perform a read or a write such that the two corner cases (0 and 100) are both more efficient and handled correctly.
Diffstat (limited to 'src/cpu/testers')
-rw-r--r--src/cpu/testers/traffic_gen/traffic_gen.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/cpu/testers/traffic_gen/traffic_gen.cc b/src/cpu/testers/traffic_gen/traffic_gen.cc
index e0657822c..59a2ae6d5 100644
--- a/src/cpu/testers/traffic_gen/traffic_gen.cc
+++ b/src/cpu/testers/traffic_gen/traffic_gen.cc
@@ -370,10 +370,11 @@ void
TrafficGen::StateGraph::LinearGen::execute()
{
// choose if we generate a read or a write here
- bool isRead = random_mt.random<uint8_t>(0, 100) < readPercent;
+ bool isRead = readPercent != 0 &&
+ (readPercent == 100 || random_mt.random<uint8_t>(0, 100) < readPercent);
- if (readPercent == 0)
- assert(!isRead);
+ assert((readPercent == 0 && !isRead) || (readPercent == 100 && isRead) ||
+ readPercent != 100);
DPRINTF(TrafficGen, "LinearGen::execute: %c to addr %x, size %d\n",
isRead ? 'r' : 'w', nextAddr, blocksize);
@@ -442,10 +443,11 @@ void
TrafficGen::StateGraph::RandomGen::execute()
{
// choose if we generate a read or a write here
- bool isRead = random_mt.random<uint8_t>(0, 100) < readPercent;
+ bool isRead = readPercent != 0 &&
+ (readPercent == 100 || random_mt.random<uint8_t>(0, 100) < readPercent);
- if (readPercent == 0)
- assert(!isRead);
+ assert((readPercent == 0 && !isRead) || (readPercent == 100 && isRead) ||
+ readPercent != 100);
// address of the request
Addr addr = random_mt.random<Addr>(startAddr, endAddr - 1);