summaryrefslogtreecommitdiff
path: root/src/cpu/testers/traffic_gen/traffic_gen.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/testers/traffic_gen/traffic_gen.hh')
-rw-r--r--src/cpu/testers/traffic_gen/traffic_gen.hh180
1 files changed, 62 insertions, 118 deletions
diff --git a/src/cpu/testers/traffic_gen/traffic_gen.hh b/src/cpu/testers/traffic_gen/traffic_gen.hh
index 6793e24b6..a2fcd3bc0 100644
--- a/src/cpu/testers/traffic_gen/traffic_gen.hh
+++ b/src/cpu/testers/traffic_gen/traffic_gen.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012-2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -49,12 +49,12 @@
/**
* The traffic generator is a master module that generates stimuli for
- * the memory system, based on a collection of simple behaviours that
- * are either probabilistic or based on traces. It can be used stand
- * alone for creating test cases for interconnect and memory
- * controllers, or function as a black box replacement for system
- * components that are not yet modelled in detail, e.g. a video engine
- * or baseband subsystem.
+ * the memory system, based on a collection of simple generator
+ * behaviours that are either probabilistic or based on traces. It can
+ * be used stand alone for creating test cases for interconnect and
+ * memory controllers, or function as a black box replacement for
+ * system components that are not yet modelled in detail, e.g. a video
+ * engine or baseband subsystem.
*/
class TrafficGen : public MemObject
{
@@ -62,123 +62,76 @@ class TrafficGen : public MemObject
private:
/**
- * The system used to determine which mode we are currently operating
- * in.
+ * Determine next state and perform the transition.
*/
- System* system;
+ void transition();
/**
- * MasterID used in generated requests.
+ * Enter a new state.
+ *
+ * @param newState identifier of state to enter
*/
- MasterID masterID;
-
- protected:
+ void enterState(uint32_t newState);
/**
- * The state graph is responsible for instantiating and keeping
- * track of the various generator states and also perform the
- * transitions and call the appropriate functions when entering,
- * executing and exiting a state.
+ * Get the tick of the next event, either an execution or a
+ * transition.
+ *
+ * @return tick of the next update event
*/
- class StateGraph
+ Tick nextEventTick()
{
+ return std::min(states[currState]->nextExecuteTick(),
+ nextTransitionTick);
+ }
- public:
-
- /**
- * Create a state graph from an input file.
- *
- * @param _owner used solely for the name
- * @param _port port used to send requests
- * @param file_name configuration description to read in
- * @param master_id the unique id used for all requests
- */
- StateGraph(TrafficGen& _owner, QueuedMasterPort& _port,
- const std::string& file_name, MasterID master_id)
- : nextTransitionTick(0), owner(_owner), port(_port)
- {
- parseConfig(file_name, master_id);
- }
-
- /**
- * Get the name, used for DPRINTFs.
- *
- * @return the owner's name
- */
- std::string name() const { return owner.name(); }
-
- /**
- * Either perform a state transition or execute the current
- * state, depending on the current time.
- */
- void update();
-
- /**
- * Determine next state and perform the transition.
- */
- void transition();
-
- /**
- * Enter a new state.
- *
- * @param newState identifier of state to enter
- */
- void enterState(uint32_t newState);
-
- /**
- * Get the tick of the next event, either an execution or a
- * transition.
- *
- * @return tick of the next state graph event
- */
- Tick nextEventTick()
- {
- return std::min(states[currState]->nextExecuteTick(),
- nextTransitionTick);
-
- }
-
- /** Time of next transition */
- Tick nextTransitionTick;
-
- private:
-
- /**
- * Parse the config file and build the state map and
- * transition matrix.
- *
- * @param file_name Config file name to parse
- * @param master_id MasterID to use for generated requests
- */
- void parseConfig(const std::string& file_name, MasterID master_id);
+ /**
+ * Parse the config file and build the state map and
+ * transition matrix.
+ *
+ * @param file_name Config file name to parse
+ * @param master_id MasterID to use for generated requests
+ */
+ void parseConfig(const std::string& file_name, MasterID master_id);
- /** Struct to represent a probabilistic transition during parsing. */
- struct Transition {
- uint32_t from;
- uint32_t to;
- double p;
- };
+ /**
+ * Schedules event for next update and executes an update on the
+ * state graph, either performing a state transition or executing
+ * the current state, depending on the current time.
+ */
+ void update();
- /** Pointer to owner of request handler */
- TrafficGen& owner;
+ /** Struct to represent a probabilistic transition during parsing. */
+ struct Transition {
+ uint32_t from;
+ uint32_t to;
+ double p;
+ };
- /** Pointer to request handler */
- QueuedMasterPort& port;
+ /**
+ * The system used to determine which mode we are currently operating
+ * in.
+ */
+ System* system;
- /** State transition matrix */
- std::vector<std::vector<double> > transitionMatrix;
+ /**
+ * MasterID used in generated requests.
+ */
+ MasterID masterID;
- public:
+ /** Time of next transition */
+ Tick nextTransitionTick;
- /** Index of the current state */
- uint32_t currState;
+ /** State transition matrix */
+ std::vector<std::vector<double> > transitionMatrix;
- /** Map of states */
- m5::hash_map<uint32_t, BaseGen*> states;
- };
+ /** Index of the current state */
+ uint32_t currState;
+ /** Map of generator states */
+ m5::hash_map<uint32_t, BaseGen*> states;
- /** Queued handler */
+ /** Queued master port */
class TrafficGenPort : public QueuedMasterPort
{
public:
@@ -197,20 +150,11 @@ class TrafficGen : public MemObject
};
+ /** The instance of master port used by the traffic generator. */
TrafficGenPort port;
- /** Request generator state graph */
- StateGraph stateGraph;
-
- /**
- * Schedules event for next update and executes an update on the
- * state graph.
- */
- void updateStateGraph();
-
- /** Event for updating the state graph */
- EventWrapper<TrafficGen,
- &TrafficGen::updateStateGraph> updateStateGraphEvent;
+ /** Event for scheduling updates */
+ EventWrapper<TrafficGen, &TrafficGen::update> updateEvent;
public: