gem5  v22.1.0.0
Switch.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 ARM Limited
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2020 Inria
15  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 /*
43  * The actual modelled switch. It use the perfect switch and a
44  * Throttle object to control and bandwidth and timing *only for the
45  * output port*. So here we have un-realistic modelling, since the
46  * order of PerfectSwitch and Throttle objects get woke up affect the
47  * message timing. A more accurate model would be having two set of
48  * system states, one for this cycle, one for next cycle. And on the
49  * cycle boundary swap the two set of states.
50  */
51 
52 #ifndef __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
53 #define __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
54 
55 #include <iostream>
56 #include <list>
57 #include <vector>
58 
59 #include "mem/packet.hh"
65 #include "mem/ruby/protocol/MessageSizeType.hh"
66 #include "params/Switch.hh"
67 
68 namespace gem5
69 {
70 
71 namespace ruby
72 {
73 
74 class MessageBuffer;
75 class NetDest;
76 class SimpleNetwork;
77 
78 class Switch : public BasicRouter
79 {
80  public:
81 
82  // Makes sure throttle sends messages to the links after the switch is
83  // done forwarding the messages in the same cycle
86 
87  typedef SwitchParams Params;
88  Switch(const Params &p);
89  ~Switch() = default;
90  void init();
91 
92  void addInPort(const std::vector<MessageBuffer*>& in);
94  const NetDest& routing_table_entry,
95  Cycles link_latency, int link_weight, int bw_multiplier,
96  bool is_external,
97  PortDirection dst_inport = "");
98 
99  void resetStats();
100  void collateStats();
101  void regStats();
102  const statistics::Formula & getMsgCount(unsigned int type) const
103  { return *(switchStats.m_msg_counts[type]); }
104 
105  void print(std::ostream& out) const;
106  void init_net_ptr(SimpleNetwork* net_ptr) { m_network_ptr = net_ptr; }
107 
108  bool functionalRead(Packet *);
109  bool functionalRead(Packet *, WriteMask&);
110  uint32_t functionalWrite(Packet *);
111 
113 
114  private:
115  // Private copy constructor and assignment operator
116  Switch(const Switch& obj);
117  Switch& operator=(const Switch& obj);
118 
122 
125 
127 
130 
131 
132  public:
134  {
136 
137  // Statistical variables
139  statistics::Formula* m_msg_counts[MessageSizeType_NUM];
140  statistics::Formula* m_msg_bytes[MessageSizeType_NUM];
142 };
143 
144 inline std::ostream&
145 operator<<(std::ostream& out, const Switch& obj)
146 {
147  obj.print(out);
148  out << std::flush;
149  return out;
150 }
151 
152 } // namespace ruby
153 } // namespace gem5
154 
155 #endif // __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
void addInPort(const std::vector< MessageBuffer * > &in)
Definition: Switch.cc:82
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Switch.cc:74
BaseRoutingUnit & m_routing_unit
Definition: Switch.hh:126
const Cycles m_int_routing_latency
Definition: Switch.hh:123
Switch & operator=(const Switch &obj)
PerfectSwitch perfectSwitch
Definition: Switch.hh:119
SwitchParams Params
Definition: Switch.hh:87
Switch(const Switch &obj)
static constexpr Event::Priority THROTTLE_EV_PRI
Definition: Switch.hh:85
bool functionalRead(Packet *)
Definition: Switch.cc:192
uint32_t functionalWrite(Packet *)
Definition: Switch.cc:213
SimpleNetwork * m_network_ptr
Definition: Switch.hh:120
void print(std::ostream &out) const
Definition: Switch.cc:185
Switch(const Params &p)
Definition: Switch.cc:59
const Cycles m_ext_routing_latency
Definition: Switch.hh:124
unsigned m_num_connected_buffers
Definition: Switch.hh:128
void addOutPort(const std::vector< MessageBuffer * > &out, const NetDest &routing_table_entry, Cycles link_latency, int link_weight, int bw_multiplier, bool is_external, PortDirection dst_inport="")
Definition: Switch.cc:88
BaseRoutingUnit & getRoutingUnit()
Definition: Switch.hh:112
std::vector< MessageBuffer * > m_port_buffers
Definition: Switch.hh:129
std::list< Throttle > throttles
Definition: Switch.hh:121
void resetStats()
Callback to reset stats.
Definition: Switch.cc:173
void collateStats()
Definition: Switch.cc:179
void regStats()
Callback to set stat parameters.
Definition: Switch.cc:138
const statistics::Formula & getMsgCount(unsigned int type) const
Definition: Switch.hh:102
static constexpr Event::Priority PERFECTSWITCH_EV_PRI
Definition: Switch.hh:84
void init_net_ptr(SimpleNetwork *net_ptr)
Definition: Switch.hh:106
gem5::ruby::Switch::SwitchStats switchStats
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
STL list class.
Definition: stl.hh:51
STL vector class.
Definition: stl.hh:37
int8_t Priority
Definition: eventq.hh:123
static const Priority Default_Pri
Default is zero for historical reasons.
Definition: eventq.hh:179
Bitfield< 54 > p
Definition: pagetable.hh:70
std::string PortDirection
Definition: TypeDefines.hh:44
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Declaration of the Packet class.
SwitchStats(statistics::Group *parent)
Definition: Switch.cc:224
statistics::Formula m_avg_utilization
Definition: Switch.hh:138
statistics::Formula * m_msg_bytes[MessageSizeType_NUM]
Definition: Switch.hh:140
statistics::Formula * m_msg_counts[MessageSizeType_NUM]
Definition: Switch.hh:139

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1