gem5  v21.1.0.2
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"
64 #include "mem/ruby/protocol/MessageSizeType.hh"
65 #include "params/Switch.hh"
66 
67 namespace gem5
68 {
69 
70 namespace ruby
71 {
72 
73 class MessageBuffer;
74 class NetDest;
75 class SimpleNetwork;
76 
77 class Switch : public BasicRouter
78 {
79  public:
80  typedef SwitchParams Params;
81  Switch(const Params &p);
82  ~Switch() = default;
83  void init();
84 
85  void addInPort(const std::vector<MessageBuffer*>& in);
87  const NetDest& routing_table_entry,
88  Cycles link_latency, int bw_multiplier);
89 
90  void resetStats();
91  void collateStats();
92  void regStats();
93  const statistics::Formula & getMsgCount(unsigned int type) const
94  { return *(switchStats.m_msg_counts[type]); }
95 
96  void print(std::ostream& out) const;
97  void init_net_ptr(SimpleNetwork* net_ptr) { m_network_ptr = net_ptr; }
98 
99  bool functionalRead(Packet *);
100  bool functionalRead(Packet *, WriteMask&);
101  uint32_t functionalWrite(Packet *);
102 
103  private:
104  // Private copy constructor and assignment operator
105  Switch(const Switch& obj);
106  Switch& operator=(const Switch& obj);
107 
111 
114 
115 
116  public:
118  {
120 
121  // Statistical variables
123  statistics::Formula* m_msg_counts[MessageSizeType_NUM];
124  statistics::Formula* m_msg_bytes[MessageSizeType_NUM];
125  } switchStats;
126 };
127 
128 inline std::ostream&
129 operator<<(std::ostream& out, const Switch& obj)
130 {
131  obj.print(out);
132  out << std::flush;
133  return out;
134 }
135 
136 } // namespace ruby
137 } // namespace gem5
138 
139 #endif // __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
PerfectSwitch.hh
gem5::ruby::WriteMask
Definition: WriteMask.hh:59
gem5::ruby::Switch::addInPort
void addInPort(const std::vector< MessageBuffer * > &in)
Definition: Switch.cc:78
gem5::ruby::Switch::operator=
Switch & operator=(const Switch &obj)
gem5::ruby::BasicRouter
Definition: BasicRouter.hh:45
gem5::ruby::Switch::~Switch
~Switch()=default
gem5::ruby::Switch::getMsgCount
const statistics::Formula & getMsgCount(unsigned int type) const
Definition: Switch.hh:93
gem5::ruby::Switch::resetStats
void resetStats()
Callback to reset stats.
Definition: Switch.cc:151
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::Switch::Params
SwitchParams Params
Definition: Switch.hh:80
gem5::ruby::Switch::m_num_connected_buffers
unsigned m_num_connected_buffers
Definition: Switch.hh:112
gem5::ruby::SimpleNetwork
Definition: SimpleNetwork.hh:61
gem5::ruby::Switch::m_port_buffers
std::vector< MessageBuffer * > m_port_buffers
Definition: Switch.hh:113
gem5::ruby::Switch::collateStats
void collateStats()
Definition: Switch.cc:160
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2536
gem5::ruby::Switch::functionalWrite
uint32_t functionalWrite(Packet *)
Definition: Switch.cc:197
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ruby::PerfectSwitch
Definition: PerfectSwitch.hh:65
gem5::ruby::Switch
Definition: Switch.hh:77
gem5::ruby::Switch::switchStats
gem5::ruby::Switch::SwitchStats switchStats
Throttle.hh
gem5::ruby::Switch::SwitchStats::m_msg_bytes
statistics::Formula * m_msg_bytes[MessageSizeType_NUM]
Definition: Switch.hh:124
packet.hh
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::ruby::Switch::regStats
void regStats()
Callback to set stat parameters.
Definition: Switch.cc:112
gem5::ruby::Switch::init_net_ptr
void init_net_ptr(SimpleNetwork *net_ptr)
Definition: Switch.hh:97
gem5::ruby::Switch::functionalRead
bool functionalRead(Packet *)
Definition: Switch.cc:176
gem5::ruby::Switch::SwitchStats::SwitchStats
SwitchStats(statistics::Group *parent)
Definition: Switch.cc:208
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
TypeDefines.hh
gem5::ruby::Switch::SwitchStats::m_msg_counts
statistics::Formula * m_msg_counts[MessageSizeType_NUM]
Definition: Switch.hh:123
gem5::X86ISA::type
type
Definition: misc.hh:733
gem5::ruby::Switch::perfectSwitch
PerfectSwitch perfectSwitch
Definition: Switch.hh:108
gem5::ruby::Switch::m_network_ptr
SimpleNetwork * m_network_ptr
Definition: Switch.hh:109
gem5::ruby::Switch::addOutPort
void addOutPort(const std::vector< MessageBuffer * > &out, const NetDest &routing_table_entry, Cycles link_latency, int bw_multiplier)
Definition: Switch.cc:84
gem5::ruby::Switch::SwitchStats::m_avg_utilization
statistics::Formula m_avg_utilization
Definition: Switch.hh:122
gem5::ruby::Switch::print
void print(std::ostream &out) const
Definition: Switch.cc:169
gem5::ruby::NetDest
Definition: NetDest.hh:45
BasicRouter.hh
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::ruby::Switch::SwitchStats
Definition: Switch.hh:117
std::list
STL list class.
Definition: stl.hh:51
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::Switch::throttles
std::list< Throttle > throttles
Definition: Switch.hh:110
gem5::ruby::Switch::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Switch.cc:71
gem5::ruby::Switch::Switch
Switch(const Params &p)
Definition: Switch.cc:59

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17