99d891f958b2c4cc24527178fc6215419ae038cf
[gem5.git] / src / mem / ruby / network / garnet2.0 / GarnetLink.cc
1 /*
2 * Copyright (c) 2008 Princeton University
3 * Copyright (c) 2016 Georgia Institute of Technology
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 #include "mem/ruby/network/garnet2.0/GarnetLink.hh"
32
33 #include "debug/RubyNetwork.hh"
34 #include "mem/ruby/network/garnet2.0/CreditLink.hh"
35 #include "mem/ruby/network/garnet2.0/NetworkBridge.hh"
36 #include "mem/ruby/network/garnet2.0/NetworkLink.hh"
37
38 GarnetIntLink::GarnetIntLink(const Params *p)
39 : BasicIntLink(p)
40 {
41 // Uni-directional
42
43 m_network_link = p->network_link;
44 m_credit_link = p->credit_link;
45
46 srcCdcEn = p->src_cdc;
47 dstCdcEn = p->dst_cdc;
48
49 srcSerdesEn = p->src_serdes;
50 dstSerdesEn = p->dst_serdes;
51
52 srcBridgeEn = false;
53 dstBridgeEn = false;
54
55 if (srcCdcEn || srcSerdesEn) {
56 srcBridgeEn = true;
57 srcNetBridge = p->src_net_bridge;
58 srcCredBridge = p->src_cred_bridge;
59 }
60 if (dstCdcEn || dstSerdesEn) {
61 dstBridgeEn = true;
62 dstNetBridge = p->dst_net_bridge;
63 dstCredBridge = p->dst_cred_bridge;
64 }
65
66 }
67
68 void
69 GarnetIntLink::init()
70 {
71 if (srcBridgeEn) {
72 assert(srcNetBridge && srcCredBridge);
73 srcNetBridge->initBridge(srcCredBridge, srcCdcEn, srcSerdesEn);
74 srcCredBridge->initBridge(srcNetBridge, srcCdcEn, srcSerdesEn);
75 }
76
77 if (dstBridgeEn) {
78 assert(dstNetBridge && dstCredBridge);
79 dstNetBridge->initBridge(dstCredBridge, dstCdcEn, dstSerdesEn);
80 dstCredBridge->initBridge(dstNetBridge, dstCdcEn, dstSerdesEn);
81 }
82 }
83
84 void
85 GarnetIntLink::print(std::ostream& out) const
86 {
87 out << name();
88 }
89
90 GarnetIntLink *
91 GarnetIntLinkParams::create()
92 {
93 return new GarnetIntLink(this);
94 }
95
96 GarnetExtLink::GarnetExtLink(const Params *p)
97 : BasicExtLink(p)
98 {
99 // Bi-directional
100
101 // In
102 m_network_links[0] = p->network_links[0];
103 m_credit_links[0] = p->credit_links[0];
104
105 // Out
106 m_network_links[1] = p->network_links[1];
107 m_credit_links[1] = p->credit_links[1];
108
109
110 extCdcEn = p->ext_cdc;
111 intCdcEn = p->int_cdc;
112
113 extSerdesEn = p->ext_serdes;
114 intSerdesEn = p->int_serdes;
115
116 extBridgeEn = false;
117 intBridgeEn = false;
118
119 if (extCdcEn || extSerdesEn) {
120 extBridgeEn = true;
121 extNetBridge[0] = p->ext_net_bridge[0];
122 extCredBridge[0] = p->ext_cred_bridge[0];
123 extNetBridge[1] = p->ext_net_bridge[1];
124 extCredBridge[1] = p->ext_cred_bridge[1];
125 }
126
127 if (intCdcEn || intSerdesEn) {
128 intBridgeEn = true;
129 intNetBridge[0] = p->int_net_bridge[0];
130 intNetBridge[1] = p->int_net_bridge[1];
131 intCredBridge[0] = p->int_cred_bridge[0];
132 intCredBridge[1] = p->int_cred_bridge[1];
133 }
134
135 }
136
137 void
138 GarnetExtLink::init()
139 {
140 if (extBridgeEn) {
141 assert(extNetBridge[0] && extCredBridge[0] &&
142 extNetBridge[1] && extCredBridge[1]);
143 extNetBridge[0]->initBridge(extCredBridge[0], extCdcEn, extSerdesEn);
144 extCredBridge[0]->initBridge(extNetBridge[0], extCdcEn, extSerdesEn);
145 extNetBridge[1]->initBridge(extCredBridge[1], extCdcEn, extSerdesEn);
146 extCredBridge[1]->initBridge(extNetBridge[1], extCdcEn, extSerdesEn);
147 }
148
149 if (intBridgeEn) {
150 assert(intNetBridge[0] && intCredBridge[0] &&
151 intNetBridge[1] && intCredBridge[1]);
152 intNetBridge[0]->initBridge(intCredBridge[0], intCdcEn, intSerdesEn);
153 intCredBridge[0]->initBridge(intNetBridge[0], intCdcEn, intSerdesEn);
154 intNetBridge[1]->initBridge(intCredBridge[1], intCdcEn, intSerdesEn);
155 intCredBridge[1]->initBridge(intNetBridge[1], intCdcEn, intSerdesEn);
156 }
157 }
158
159 void
160 GarnetExtLink::print(std::ostream& out) const
161 {
162 out << name();
163 }
164
165 GarnetExtLink *
166 GarnetExtLinkParams::create()
167 {
168 return new GarnetExtLink(this);
169 }