2 * Copyright (c) 2016 Georgia Institute of Technology
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __CPU_GARNET_SYNTHETIC_TRAFFIC_HH__
30 #define __CPU_GARNET_SYNTHETIC_TRAFFIC_HH__
34 #include "base/statistics.hh"
35 #include "mem/port.hh"
36 #include "params/GarnetSyntheticTraffic.hh"
37 #include "sim/clocked_object.hh"
38 #include "sim/eventq.hh"
39 #include "sim/sim_exit.hh"
40 #include "sim/sim_object.hh"
41 #include "sim/stats.hh"
43 enum TrafficType {BIT_COMPLEMENT_ = 0,
51 NUM_TRAFFIC_PATTERNS_};
54 class GarnetSyntheticTraffic : public ClockedObject
57 typedef GarnetSyntheticTrafficParams Params;
58 GarnetSyntheticTraffic(const Params *p);
62 // main simulation loop (one cycle)
65 Port &getPort(const std::string &if_name,
66 PortID idx=InvalidPortID) override;
69 * Print state of address in memory system via PrintReq (for
72 void printAddr(Addr a);
75 EventFunctionWrapper tickEvent;
77 class CpuPort : public RequestPort
79 GarnetSyntheticTraffic *tester;
83 CpuPort(const std::string &_name, GarnetSyntheticTraffic *_tester)
84 : RequestPort(_name, _tester), tester(_tester)
89 virtual bool recvTimingResp(PacketPtr pkt);
91 virtual void recvReqRetry();
96 class GarnetSyntheticTrafficSenderState : public Packet::SenderState
100 GarnetSyntheticTrafficSenderState(uint8_t *_data)
104 // Hold onto data pointer
112 std::map<std::string, TrafficType> trafficStringToEnum;
114 unsigned blockSizeBits;
116 Tick noResponseCycles;
125 std::string trafficType; // string
126 TrafficType traffic; // enum from string
131 const Cycles responseLimit;
133 RequestorID requestorId;
135 void completeRequest(PacketPtr pkt);
138 void sendPkt(PacketPtr pkt);
139 void initTrafficType();
143 friend class MemCompleteEvent;
146 #endif // __CPU_GARNET_SYNTHETIC_TRAFFIC_HH__