Network.hh (6154:6bb54dcb940e) Network.hh (6284:a63d1dc4c820)
1
2/*
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/*
1
2/*
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 * Network.h
31 * Network.hh
32 *
33 * Description: The Network class is the base class for classes that
34 * implement the interconnection network between components
35 * (processor/cache components and memory/directory components). The
36 * interconnection network as described here is not a physical
37 * network, but a programming concept used to implement all
38 * communication between components. Thus parts of this 'network'
39 * will model the on-chip connections between cache controllers and
40 * directory controllers as well as the links between chip and network
41 * switches.
42 *
43 * $Id$
44 * */
45
46#ifndef NETWORK_H
47#define NETWORK_H
48
49#include "mem/ruby/common/Global.hh"
50#include "mem/ruby/system/NodeID.hh"
51#include "mem/protocol/MessageSizeType.hh"
52
53class NetDest;
54class MessageBuffer;
55class Throttle;
56
57class Network {
58public:
59 // Constructors
60 Network() {}
61
62 // Destructor
63 virtual ~Network() {}
64
65 // Public Methods
66
67 static Network* createNetwork(int nodes);
68
69 // returns the queue requested for the given component
70 virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
71 virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
72 virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
73
74 virtual int getNumNodes() {return 1;}
75
76 virtual void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
77 virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
78 virtual void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
79
80 virtual void reset() = 0;
81
82 virtual void printStats(ostream& out) const = 0;
83 virtual void clearStats() = 0;
84 virtual void printConfig(ostream& out) const = 0;
85 virtual void print(ostream& out) const = 0;
86
87private:
88
89 // Private Methods
90 // Private copy constructor and assignment operator
91 Network(const Network& obj);
92 Network& operator=(const Network& obj);
93
94 // Data Members (m_ prefix)
95};
96
97// Output operator declaration
98ostream& operator<<(ostream& out, const Network& obj);
99
100// ******************* Definitions *******************
101
102// Output operator definition
103extern inline
104ostream& operator<<(ostream& out, const Network& obj)
105{
106 obj.print(out);
107 out << flush;
108 return out;
109}
110
111// Code to map network message size types to an integer number of bytes
112const int CONTROL_MESSAGE_SIZE = 8;
113const int DATA_MESSAGE_SIZE = (64+8);
114
115extern inline
116int MessageSizeType_to_int(MessageSizeType size_type)
117{
118 switch(size_type) {
119 case MessageSizeType_Undefined:
120 ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
121 break;
122 case MessageSizeType_Control:
123 case MessageSizeType_Request_Control:
124 case MessageSizeType_Reissue_Control:
125 case MessageSizeType_Response_Control:
126 case MessageSizeType_Writeback_Control:
127 case MessageSizeType_Forwarded_Control:
128 case MessageSizeType_Invalidate_Control:
129 case MessageSizeType_Unblock_Control:
130 case MessageSizeType_Persistent_Control:
131 case MessageSizeType_Completion_Control:
132 return CONTROL_MESSAGE_SIZE;
133 break;
134 case MessageSizeType_Data:
135 case MessageSizeType_Response_Data:
136 case MessageSizeType_ResponseLocal_Data:
137 case MessageSizeType_ResponseL2hit_Data:
138 case MessageSizeType_Writeback_Data:
139 return DATA_MESSAGE_SIZE;
140 break;
141 default:
142 ERROR_MSG("Invalid range for type MessageSizeType");
143 break;
144 }
145 return 0;
146}
147
148#endif //NETWORK_H
32 *
33 * Description: The Network class is the base class for classes that
34 * implement the interconnection network between components
35 * (processor/cache components and memory/directory components). The
36 * interconnection network as described here is not a physical
37 * network, but a programming concept used to implement all
38 * communication between components. Thus parts of this 'network'
39 * will model the on-chip connections between cache controllers and
40 * directory controllers as well as the links between chip and network
41 * switches.
42 *
43 * $Id$
44 * */
45
46#ifndef NETWORK_H
47#define NETWORK_H
48
49#include "mem/ruby/common/Global.hh"
50#include "mem/ruby/system/NodeID.hh"
51#include "mem/protocol/MessageSizeType.hh"
52
53class NetDest;
54class MessageBuffer;
55class Throttle;
56
57class Network {
58public:
59 // Constructors
60 Network() {}
61
62 // Destructor
63 virtual ~Network() {}
64
65 // Public Methods
66
67 static Network* createNetwork(int nodes);
68
69 // returns the queue requested for the given component
70 virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
71 virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
72 virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
73
74 virtual int getNumNodes() {return 1;}
75
76 virtual void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
77 virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
78 virtual void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
79
80 virtual void reset() = 0;
81
82 virtual void printStats(ostream& out) const = 0;
83 virtual void clearStats() = 0;
84 virtual void printConfig(ostream& out) const = 0;
85 virtual void print(ostream& out) const = 0;
86
87private:
88
89 // Private Methods
90 // Private copy constructor and assignment operator
91 Network(const Network& obj);
92 Network& operator=(const Network& obj);
93
94 // Data Members (m_ prefix)
95};
96
97// Output operator declaration
98ostream& operator<<(ostream& out, const Network& obj);
99
100// ******************* Definitions *******************
101
102// Output operator definition
103extern inline
104ostream& operator<<(ostream& out, const Network& obj)
105{
106 obj.print(out);
107 out << flush;
108 return out;
109}
110
111// Code to map network message size types to an integer number of bytes
112const int CONTROL_MESSAGE_SIZE = 8;
113const int DATA_MESSAGE_SIZE = (64+8);
114
115extern inline
116int MessageSizeType_to_int(MessageSizeType size_type)
117{
118 switch(size_type) {
119 case MessageSizeType_Undefined:
120 ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
121 break;
122 case MessageSizeType_Control:
123 case MessageSizeType_Request_Control:
124 case MessageSizeType_Reissue_Control:
125 case MessageSizeType_Response_Control:
126 case MessageSizeType_Writeback_Control:
127 case MessageSizeType_Forwarded_Control:
128 case MessageSizeType_Invalidate_Control:
129 case MessageSizeType_Unblock_Control:
130 case MessageSizeType_Persistent_Control:
131 case MessageSizeType_Completion_Control:
132 return CONTROL_MESSAGE_SIZE;
133 break;
134 case MessageSizeType_Data:
135 case MessageSizeType_Response_Data:
136 case MessageSizeType_ResponseLocal_Data:
137 case MessageSizeType_ResponseL2hit_Data:
138 case MessageSizeType_Writeback_Data:
139 return DATA_MESSAGE_SIZE;
140 break;
141 default:
142 ERROR_MSG("Invalid range for type MessageSizeType");
143 break;
144 }
145 return 0;
146}
147
148#endif //NETWORK_H