1 | ////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File: simple_cluster.cpp |
---|
3 | // Author: Alain Greiner |
---|
4 | // Copyright: UPMC/LIP6 |
---|
5 | // Date : march 2013 |
---|
6 | // This program is released under the GNU public license |
---|
7 | ////////////////////////////////////////////////////////////////////////////// |
---|
8 | |
---|
9 | #include "../include/simple_cluster.h" |
---|
10 | |
---|
11 | namespace soclib { |
---|
12 | namespace caba { |
---|
13 | |
---|
14 | ////////////////////////////////////////////////////////////////////////// |
---|
15 | // Constructor |
---|
16 | ////////////////////////////////////////////////////////////////////////// |
---|
17 | template<typename vci_param, int cmd_width, int rsp_width> |
---|
18 | SimpleCluster<vci_param, cmd_width, rsp_width>::SimpleCluster( |
---|
19 | sc_module_name name, |
---|
20 | size_t x_local, |
---|
21 | size_t y_local, |
---|
22 | size_t x_width, |
---|
23 | size_t y_width, |
---|
24 | size_t load_d, |
---|
25 | size_t plen_d, |
---|
26 | size_t load_ini_c, |
---|
27 | size_t plen_ini_c, |
---|
28 | size_t load_tgt_c, |
---|
29 | size_t plen_tgt_c, |
---|
30 | size_t bcp_ini, |
---|
31 | size_t bcp_tgt ) |
---|
32 | : soclib::caba::BaseModule(name), |
---|
33 | p_clk("clk"), |
---|
34 | p_resetn("resetn") |
---|
35 | { |
---|
36 | // Vectors of ports definition |
---|
37 | p_cmd_in = alloc_elems<DspinInput<cmd_width> >("p_cmd_in", 2, 4); |
---|
38 | p_cmd_out = alloc_elems<DspinOutput<cmd_width> >("p_cmd_out", 2, 4); |
---|
39 | p_rsp_in = alloc_elems<DspinInput<rsp_width> >("p_rsp_in", 2, 4); |
---|
40 | p_rsp_out = alloc_elems<DspinOutput<rsp_width> >("p_rsp_out", 2, 4); |
---|
41 | |
---|
42 | // Empty mapping table (required by dspin_local_crossbar) |
---|
43 | MappingTable mt( 32, IntTab(1), IntTab (1), 0xFF000000); |
---|
44 | |
---|
45 | ///////////////////////////////////////// |
---|
46 | // Hardware Components definition |
---|
47 | ///////////////////////////////////////// |
---|
48 | |
---|
49 | // local crossbar CMD on coherence network |
---|
50 | std::ostringstream s2; |
---|
51 | s2 << "xbar_cmd_c_" << x_local << "_" << y_local; |
---|
52 | xbar_cmd_c = new DspinLocalCrossbar<cmd_width>( |
---|
53 | s2.str().c_str(), |
---|
54 | mt, // unused mapping table |
---|
55 | x_local, y_local, // cluster coordinates |
---|
56 | x_width, y_width, 0, // l_width == 0 |
---|
57 | 1, 1, // one local source & one local dest |
---|
58 | 2, 2, // fifo depths |
---|
59 | false, // don't use local routing table |
---|
60 | true ); // broacast supported |
---|
61 | |
---|
62 | std::cout << "- build xbar_cmd_c_" << x_local << "_" << y_local |
---|
63 | << " / flit_width = " << cmd_width << std::endl; |
---|
64 | |
---|
65 | // local crossbar RSP on coherence network |
---|
66 | std::ostringstream s3; |
---|
67 | s3 << "xbar_rsp_c_" << x_local << "_" << y_local; |
---|
68 | xbar_rsp_c = new DspinLocalCrossbar<rsp_width>( |
---|
69 | s3.str().c_str(), |
---|
70 | mt, // unused mapping table |
---|
71 | x_local, y_local, // cluster coordinates |
---|
72 | x_width, y_width, 0, // l_width == 0 |
---|
73 | 1, 1, // one local source & one local dest |
---|
74 | 2, 2, // fifo depths |
---|
75 | false, // don't use local routing table |
---|
76 | true ); // broadcast supported |
---|
77 | |
---|
78 | std::cout << "- build xbar_rsp_c_" << x_local << "_" << y_local |
---|
79 | << " / flit_width = " << rsp_width << std::endl; |
---|
80 | |
---|
81 | // local crossbar CMD on direct network |
---|
82 | std::ostringstream s0; |
---|
83 | s0 << "xbar_cmd_d_" << x_local << "_" << y_local; |
---|
84 | xbar_cmd_d = new DspinLocalCrossbar<cmd_width>( |
---|
85 | s0.str().c_str(), |
---|
86 | mt, // unused mapping table |
---|
87 | x_local, y_local, // cluster coordinates |
---|
88 | x_width, y_width, 0, // l_width = 0 |
---|
89 | 1, 1, // one local source & one local dest |
---|
90 | 2, 2, // fifo depths |
---|
91 | false, // don't use local routing table |
---|
92 | false ); // no broacast |
---|
93 | |
---|
94 | std::cout << "- build xbar_cmd_d_" << x_local << "_" << y_local |
---|
95 | << " / flit_width = " << cmd_width << std::endl; |
---|
96 | |
---|
97 | |
---|
98 | // local crossbar RSP on direct network |
---|
99 | std::ostringstream s1; |
---|
100 | s1 << "xbar_rsp_d_" << x_local << "_" << y_local; |
---|
101 | xbar_rsp_d = new DspinLocalCrossbar<rsp_width>( |
---|
102 | s1.str().c_str(), |
---|
103 | mt, // unused mapping table |
---|
104 | x_local, y_local, // cluster coordinates |
---|
105 | x_width, y_width, 0, // l_width == 0 |
---|
106 | 1, 1, // one local source & one local dest |
---|
107 | 2, 2, // fifo depths |
---|
108 | false, // don't use local routing table |
---|
109 | false ); // no broacast |
---|
110 | |
---|
111 | std::cout << "- build xbar_rsp_d_" << x_local << "_" << y_local |
---|
112 | << " / flit_width = " << rsp_width << std::endl; |
---|
113 | |
---|
114 | // VCI Initiator on direct network |
---|
115 | size_t srcid = (x_local << y_width) | y_local; |
---|
116 | std::ostringstream sid; |
---|
117 | sid << "ini_d_" << x_local << "_" << y_local; |
---|
118 | ini_d = new VciSyntheticInitiator<vci_param>( |
---|
119 | sid.str().c_str(), |
---|
120 | srcid, // VCI SRCID |
---|
121 | plen_d, // packet length |
---|
122 | load_d, // requested load |
---|
123 | 1024 ); // fifo depth |
---|
124 | |
---|
125 | std::ostringstream swid; |
---|
126 | swid << "w_ini_d_" << x_local << "_" << y_local; |
---|
127 | w_ini_d = new VciDspinInitiatorWrapper<vci_param,cmd_width,rsp_width>( |
---|
128 | swid.str().c_str(), |
---|
129 | x_width + y_width ); |
---|
130 | |
---|
131 | std::cout << "- build ini_d_" << x_local << "_" << y_local << std::endl; |
---|
132 | |
---|
133 | // VCI Target on direct network |
---|
134 | size_t tgtid = (x_local << y_width) | y_local; |
---|
135 | std::ostringstream std; |
---|
136 | std << "tgt_d_" << x_local << "_" << y_local; |
---|
137 | tgt_d = new VciSyntheticTarget<vci_param>( |
---|
138 | std.str().c_str(), |
---|
139 | tgtid, // MSB bits of VCI address |
---|
140 | x_width, // X field width |
---|
141 | y_width, // Y field width |
---|
142 | 0 ); // L field width |
---|
143 | |
---|
144 | std::ostringstream swtd; |
---|
145 | swtd << "w_tgt_d_" << x_local << "_" << y_local; |
---|
146 | w_tgt_d = new VciDspinTargetWrapper<vci_param,cmd_width,rsp_width>( |
---|
147 | swtd.str().c_str(), |
---|
148 | x_width + y_width ); |
---|
149 | |
---|
150 | std::cout << "- build tgt_d_" << x_local << "_" << y_local << std::endl; |
---|
151 | |
---|
152 | // DSPIN Sender on cc40 network / Receiver on cc33 |
---|
153 | size_t s40_srcid = (x_local << y_width) | y_local; |
---|
154 | std::ostringstream s40; |
---|
155 | s40 << "ini_c_" << x_local << "_" << y_local; |
---|
156 | ini_c = new DspinPacketGenerator<cmd_width, rsp_width>( |
---|
157 | s40.str().c_str(), |
---|
158 | s40_srcid, // ini component identifier |
---|
159 | plen_ini_c, // packet length (number of flits) |
---|
160 | load_ini_c, // requested load * 1000 |
---|
161 | 1024, // fifo depth |
---|
162 | bcp_ini ); // broadcast period |
---|
163 | |
---|
164 | std::cout << "- build ini_c_" << x_local << "_" << y_local << std::endl; |
---|
165 | |
---|
166 | // DSPIN Sender on cc33 network / Receiver on cc40 |
---|
167 | size_t s33_srcid = (x_local << y_width) | y_local; |
---|
168 | std::ostringstream s33; |
---|
169 | s33 << "tgt_c_" << x_local << "_" << y_local; |
---|
170 | tgt_c = new DspinPacketGenerator<rsp_width, cmd_width>( |
---|
171 | s33.str().c_str(), |
---|
172 | s33_srcid, // ini component identifier |
---|
173 | plen_tgt_c, // packet length (number of flits) |
---|
174 | load_tgt_c, // requested load * 1000 |
---|
175 | 1024, // fifo depth |
---|
176 | bcp_tgt ); // broadcast period |
---|
177 | |
---|
178 | std::cout << "- build tgt_c_" << x_local << "_" << y_local << std::endl; |
---|
179 | |
---|
180 | // router CMD |
---|
181 | std::ostringstream rcmd; |
---|
182 | rcmd << "router_cmd_" << x_local << "_" << y_local; |
---|
183 | router_cmd = new VirtualDspinRouter<cmd_width>( |
---|
184 | rcmd.str().c_str(), |
---|
185 | x_local,y_local, // coordinate in the mesh |
---|
186 | x_width, y_width, // x & y fields width |
---|
187 | 4,4); // input & output fifo depths |
---|
188 | |
---|
189 | std::cout << "- build router_cmd_" << x_local << "_" << y_local << std::endl; |
---|
190 | |
---|
191 | // router RSP |
---|
192 | std::ostringstream rrsp; |
---|
193 | rrsp << "router_rsp_" << x_local << "_" << y_local; |
---|
194 | router_rsp = new VirtualDspinRouter<rsp_width>( |
---|
195 | rrsp.str().c_str(), |
---|
196 | x_local,y_local, // coordinate in the mesh |
---|
197 | x_width, y_width, // x & y fields width |
---|
198 | 4,4); // input & output fifo depths |
---|
199 | |
---|
200 | std::cout << "- build router_cmd_" << x_local << "_" << y_local << std::endl; |
---|
201 | |
---|
202 | //////////////////////////////////// |
---|
203 | // Connections are defined here |
---|
204 | //////////////////////////////////// |
---|
205 | |
---|
206 | // CMD ROUTER and RSP ROUTER |
---|
207 | router_cmd->p_clk (this->p_clk); |
---|
208 | router_cmd->p_resetn (this->p_resetn); |
---|
209 | router_rsp->p_clk (this->p_clk); |
---|
210 | router_rsp->p_resetn (this->p_resetn); |
---|
211 | |
---|
212 | for (int x = 0; x < 2; x++) |
---|
213 | { |
---|
214 | for(int y = 0; y < 4; y++) |
---|
215 | { |
---|
216 | router_cmd->p_out[x][y] (this->p_cmd_out[x][y]); |
---|
217 | router_cmd->p_in[x][y] (this->p_cmd_in[x][y]); |
---|
218 | router_rsp->p_out[x][y] (this->p_rsp_out[x][y]); |
---|
219 | router_rsp->p_in[x][y] (this->p_rsp_in[x][y]); |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | router_cmd->p_out[0][4] (signal_dspin_cmd_g2l_d); |
---|
224 | router_cmd->p_out[1][4] (signal_dspin_cmd_g2l_c); |
---|
225 | router_cmd->p_in[0][4] (signal_dspin_cmd_l2g_d); |
---|
226 | router_cmd->p_in[1][4] (signal_dspin_cmd_l2g_c); |
---|
227 | |
---|
228 | router_rsp->p_out[0][4] (signal_dspin_rsp_g2l_d); |
---|
229 | router_rsp->p_out[1][4] (signal_dspin_rsp_g2l_c); |
---|
230 | router_rsp->p_in[0][4] (signal_dspin_rsp_l2g_d); |
---|
231 | router_rsp->p_in[1][4] (signal_dspin_rsp_l2g_c); |
---|
232 | |
---|
233 | std::cout << "- CMD & RSP routers connected" << std::endl; |
---|
234 | |
---|
235 | // CMD local crossbar direct |
---|
236 | xbar_cmd_d->p_clk (this->p_clk); |
---|
237 | xbar_cmd_d->p_resetn (this->p_resetn); |
---|
238 | xbar_cmd_d->p_global_out (signal_dspin_cmd_l2g_d); |
---|
239 | xbar_cmd_d->p_global_in (signal_dspin_cmd_g2l_d); |
---|
240 | xbar_cmd_d->p_local_out[0] (signal_dspin_tgt_cmd_d); |
---|
241 | xbar_cmd_d->p_local_in[0] (signal_dspin_ini_cmd_d); |
---|
242 | |
---|
243 | std::cout << "- CMD Direct crossbar connected" << std::endl; |
---|
244 | |
---|
245 | // RSP local crossbar direct |
---|
246 | xbar_rsp_d->p_clk (this->p_clk); |
---|
247 | xbar_rsp_d->p_resetn (this->p_resetn); |
---|
248 | xbar_rsp_d->p_global_out (signal_dspin_rsp_l2g_d); |
---|
249 | xbar_rsp_d->p_global_in (signal_dspin_rsp_g2l_d); |
---|
250 | xbar_rsp_d->p_local_in[0] (signal_dspin_tgt_rsp_d); |
---|
251 | xbar_rsp_d->p_local_out[0] (signal_dspin_ini_rsp_d); |
---|
252 | |
---|
253 | std::cout << "- RSP Direct crossbar connected" << std::endl; |
---|
254 | |
---|
255 | // CMD local crossbar coherence |
---|
256 | xbar_cmd_c->p_clk (this->p_clk); |
---|
257 | xbar_cmd_c->p_resetn (this->p_resetn); |
---|
258 | xbar_cmd_c->p_global_out (signal_dspin_cmd_l2g_c); |
---|
259 | xbar_cmd_c->p_global_in (signal_dspin_cmd_g2l_c); |
---|
260 | xbar_cmd_c->p_local_out[0] (signal_dspin_tgt_cmd_c); |
---|
261 | xbar_cmd_c->p_local_in[0] (signal_dspin_ini_cmd_c); |
---|
262 | |
---|
263 | std::cout << "- CMD coherence crossbar connected" << std::endl; |
---|
264 | |
---|
265 | // RSP local crossbar coherence |
---|
266 | xbar_rsp_c->p_clk (this->p_clk); |
---|
267 | xbar_rsp_c->p_resetn (this->p_resetn); |
---|
268 | xbar_rsp_c->p_global_out (signal_dspin_rsp_l2g_c); |
---|
269 | xbar_rsp_c->p_global_in (signal_dspin_rsp_g2l_c); |
---|
270 | xbar_rsp_c->p_local_in[0] (signal_dspin_tgt_rsp_c); |
---|
271 | xbar_rsp_c->p_local_out[0] (signal_dspin_ini_rsp_c); |
---|
272 | |
---|
273 | std::cout << "- RSP coherence crossbar connected" << std::endl; |
---|
274 | |
---|
275 | // VCI Initiator (and wrapper) on direct network |
---|
276 | ini_d->p_clk (this->p_clk); |
---|
277 | ini_d->p_resetn (this->p_resetn); |
---|
278 | ini_d->p_vci (signal_vci_ini); |
---|
279 | |
---|
280 | w_ini_d->p_clk (this->p_clk); |
---|
281 | w_ini_d->p_resetn (this->p_resetn); |
---|
282 | w_ini_d->p_dspin_cmd (signal_dspin_ini_cmd_d); |
---|
283 | w_ini_d->p_dspin_rsp (signal_dspin_ini_rsp_d); |
---|
284 | w_ini_d->p_vci (signal_vci_ini); |
---|
285 | |
---|
286 | std::cout << "- VCI initiators on direct network connected" << std::endl; |
---|
287 | |
---|
288 | // VCI Target (and wrapper) on direct network |
---|
289 | tgt_d->p_clk (this->p_clk); |
---|
290 | tgt_d->p_resetn (this->p_resetn); |
---|
291 | tgt_d->p_vci (signal_vci_tgt); |
---|
292 | |
---|
293 | w_tgt_d->p_clk (this->p_clk); |
---|
294 | w_tgt_d->p_resetn (this->p_resetn); |
---|
295 | w_tgt_d->p_dspin_cmd (signal_dspin_tgt_cmd_d); |
---|
296 | w_tgt_d->p_dspin_rsp (signal_dspin_tgt_rsp_d); |
---|
297 | w_tgt_d->p_vci (signal_vci_tgt); |
---|
298 | |
---|
299 | std::cout << "- VCI targets on direct network connected" << std::endl; |
---|
300 | |
---|
301 | // DSPIN initiators on coherence network |
---|
302 | ini_c->p_clk (this->p_clk); |
---|
303 | ini_c->p_resetn (this->p_resetn); |
---|
304 | ini_c->p_in (signal_dspin_ini_rsp_c); |
---|
305 | ini_c->p_out (signal_dspin_ini_cmd_c); |
---|
306 | |
---|
307 | std::cout << "- DSPIN initiators on coherence network connected" << std::endl; |
---|
308 | |
---|
309 | // DSPIN targets on coherence network |
---|
310 | tgt_c->p_clk (this->p_clk); |
---|
311 | tgt_c->p_resetn (this->p_resetn); |
---|
312 | tgt_c->p_in (signal_dspin_tgt_cmd_c); |
---|
313 | tgt_c->p_out (signal_dspin_tgt_rsp_c); |
---|
314 | |
---|
315 | std::cout << "- DSPIN targets on coherence network connected" << std::endl; |
---|
316 | |
---|
317 | } // end constructor |
---|
318 | |
---|
319 | }} // end namespaces |
---|
320 | |
---|
321 | |
---|
322 | // Local Variables: |
---|
323 | // tab-width: 3 |
---|
324 | // c-basic-offset: 3 |
---|
325 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
326 | // indent-tabs-mode: nil |
---|
327 | // End: |
---|
328 | |
---|
329 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|
330 | |
---|
331 | |
---|
332 | |
---|