gem5  v20.1.0.0
Switch.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Inria
3  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*
31  * The actual modelled switch. It use the perfect switch and a
32  * Throttle object to control and bandwidth and timing *only for the
33  * output port*. So here we have un-realistic modelling, since the
34  * order of PerfectSwitch and Throttle objects get woke up affect the
35  * message timing. A more accurate model would be having two set of
36  * system states, one for this cycle, one for next cycle. And on the
37  * cycle boundary swap the two set of states.
38  */
39 
40 #ifndef __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
41 #define __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
42 
43 #include <iostream>
44 #include <list>
45 #include <vector>
46 
47 #include "mem/packet.hh"
52 #include "mem/ruby/protocol/MessageSizeType.hh"
53 #include "params/Switch.hh"
54 
55 class MessageBuffer;
56 class NetDest;
57 class SimpleNetwork;
58 
59 class Switch : public BasicRouter
60 {
61  public:
62  typedef SwitchParams Params;
63  Switch(const Params *p);
64  ~Switch() = default;
65  void init();
66 
67  void addInPort(const std::vector<MessageBuffer*>& in);
69  const NetDest& routing_table_entry,
70  Cycles link_latency, int bw_multiplier);
71 
72  void resetStats();
73  void collateStats();
74  void regStats();
75  const Stats::Formula & getMsgCount(unsigned int type) const
76  { return m_msg_counts[type]; }
77 
78  void print(std::ostream& out) const;
79  void init_net_ptr(SimpleNetwork* net_ptr) { m_network_ptr = net_ptr; }
80 
81  bool functionalRead(Packet *);
82  uint32_t functionalWrite(Packet *);
83 
84  private:
85  // Private copy constructor and assignment operator
86  Switch(const Switch& obj);
87  Switch& operator=(const Switch& obj);
88 
92 
95 
96  // Statistical variables
98  Stats::Formula m_msg_counts[MessageSizeType_NUM];
99  Stats::Formula m_msg_bytes[MessageSizeType_NUM];
100 };
101 
102 inline std::ostream&
103 operator<<(std::ostream& out, const Switch& obj)
104 {
105  obj.print(out);
106  out << std::flush;
107  return out;
108 }
109 
110 #endif // __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
Switch::init_net_ptr
void init_net_ptr(SimpleNetwork *net_ptr)
Definition: Switch.hh:79
PerfectSwitch
Definition: PerfectSwitch.hh:59
PerfectSwitch.hh
Switch::~Switch
~Switch()=default
operator<<
std::ostream & operator<<(std::ostream &out, const Switch &obj)
Definition: Switch.hh:103
type
uint8_t type
Definition: inet.hh:421
Switch::addInPort
void addInPort(const std::vector< MessageBuffer * > &in)
Definition: Switch.cc:72
Switch::m_network_ptr
SimpleNetwork * m_network_ptr
Definition: Switch.hh:90
std::vector< MessageBuffer * >
Switch
Definition: Switch.hh:59
Switch::operator=
Switch & operator=(const Switch &obj)
Switch::throttles
std::list< Throttle > throttles
Definition: Switch.hh:91
Throttle.hh
Switch::resetStats
void resetStats()
Callback to reset stats.
Definition: Switch.cc:142
packet.hh
Switch::m_port_buffers
std::vector< MessageBuffer * > m_port_buffers
Definition: Switch.hh:94
BasicRouter::Params
BasicRouterParams Params
Definition: BasicRouter.hh:42
TypeDefines.hh
Switch::perfectSwitch
PerfectSwitch perfectSwitch
Definition: Switch.hh:89
SimpleNetwork
Definition: SimpleNetwork.hh:43
Switch::print
void print(std::ostream &out) const
Definition: Switch.cc:160
BasicRouter
Definition: BasicRouter.hh:39
Switch::m_msg_counts
Stats::Formula m_msg_counts[MessageSizeType_NUM]
Definition: Switch.hh:98
Switch::functionalWrite
uint32_t functionalWrite(Packet *)
Definition: Switch.cc:177
Switch::regStats
void regStats()
Callback to set stat parameters.
Definition: Switch.cc:106
Switch::m_msg_bytes
Stats::Formula m_msg_bytes[MessageSizeType_NUM]
Definition: Switch.hh:99
Switch::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Switch.cc:65
Switch::collateStats
void collateStats()
Definition: Switch.cc:151
Switch::addOutPort
void addOutPort(const std::vector< MessageBuffer * > &out, const NetDest &routing_table_entry, Cycles link_latency, int bw_multiplier)
Definition: Switch.cc:78
Switch::Params
SwitchParams Params
Definition: Switch.hh:62
Switch::getMsgCount
const Stats::Formula & getMsgCount(unsigned int type) const
Definition: Switch.hh:75
BasicRouter.hh
Stats::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3037
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Switch::m_num_connected_buffers
unsigned m_num_connected_buffers
Definition: Switch.hh:93
Switch::Switch
Switch(const Params *p)
Definition: Switch.cc:54
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Switch::m_avg_utilization
Stats::Formula m_avg_utilization
Definition: Switch.hh:97
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< Throttle >
MessageBuffer
Definition: MessageBuffer.hh:68
NetDest
Definition: NetDest.hh:39
Switch::functionalRead
bool functionalRead(Packet *)
Definition: Switch.cc:167

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17