gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PerfectSwitch.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
29 /*
30  * Perfect switch, of course it is perfect and no latency or what so
31  * ever. Every cycle it is woke up and perform all the necessary
32  * routings that must be done. Note, this switch also has number of
33  * input ports/output ports and has a routing table as well.
34  */
35 
36 #ifndef __MEM_RUBY_NETWORK_SIMPLE_PERFECTSWITCH_HH__
37 #define __MEM_RUBY_NETWORK_SIMPLE_PERFECTSWITCH_HH__
38 
39 #include <iostream>
40 #include <string>
41 #include <vector>
42 
45 
46 class MessageBuffer;
47 class NetDest;
48 class SimpleNetwork;
49 class Switch;
50 
51 struct LinkOrder
52 {
53  int m_link;
54  int m_value;
55 };
56 
57 bool operator<(const LinkOrder& l1, const LinkOrder& l2);
58 
59 class PerfectSwitch : public Consumer
60 {
61  public:
62  PerfectSwitch(SwitchID sid, Switch *, uint32_t);
64 
65  std::string name()
66  { return csprintf("PerfectSwitch-%i", m_switch_id); }
67 
68  void init(SimpleNetwork *);
69  void addInPort(const std::vector<MessageBuffer*>& in);
71  const NetDest& routing_table_entry);
72 
73  int getInLinks() const { return m_in.size(); }
74  int getOutLinks() const { return m_out.size(); }
75 
76  void wakeup();
77  void storeEventInfo(int info);
78 
79  void clearStats();
80  void collateStats();
81  void print(std::ostream& out) const;
82 
83  private:
84  // Private copy constructor and assignment operator
85  PerfectSwitch(const PerfectSwitch& obj);
87 
88  void operateVnet(int vnet);
89  void operateMessageBuffer(MessageBuffer *b, int incoming, int vnet);
90 
92  Switch * const m_switch;
93 
94  // vector of queues from the components
97 
100 
104 
107 };
108 
109 inline std::ostream&
110 operator<<(std::ostream& out, const PerfectSwitch& obj)
111 {
112  obj.print(out);
113  out << std::flush;
114  return out;
115 }
116 
117 #endif // __MEM_RUBY_NETWORK_SIMPLE_PERFECTSWITCH_HH__
uint32_t m_virtual_networks
bool operator<(const LinkOrder &l1, const LinkOrder &l2)
SimpleNetwork * m_network_ptr
std::vector< NetDest > m_routing_table
std::ostream & operator<<(std::ostream &out, const PerfectSwitch &obj)
void storeEventInfo(int info)
Bitfield< 4 > l2
Definition: misc.hh:661
int getInLinks() const
const SwitchID m_switch_id
PerfectSwitch & operator=(const PerfectSwitch &obj)
Bitfield< 7 > b
Definition: miscregs.hh:1564
Definition: Switch.hh:57
unsigned int SwitchID
Definition: TypeDefines.hh:35
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
int getOutLinks() const
std::vector< int > m_pending_message_count
Switch *const m_switch
std::vector< LinkOrder > m_link_order
void addOutPort(const std::vector< MessageBuffer * > &out, const NetDest &routing_table_entry)
std::vector< std::vector< MessageBuffer * > > m_in
void init(SimpleNetwork *)
std::vector< std::vector< MessageBuffer * > > m_out
Bitfield< 2 > l1
Definition: misc.hh:659
void print(std::ostream &out) const
void operateVnet(int vnet)
std::string name()
PerfectSwitch(SwitchID sid, Switch *, uint32_t)
void addInPort(const std::vector< MessageBuffer * > &in)
void operateMessageBuffer(MessageBuffer *b, int incoming, int vnet)

Generated on Fri Jun 9 2017 13:03:50 for gem5 by doxygen 1.8.6