1 | #include <systemc> |
---|
2 | #include <sys/time.h> |
---|
3 | #include <iostream> |
---|
4 | #include <cstdlib> |
---|
5 | #include <cstdarg> |
---|
6 | |
---|
7 | #include "mapping_table.h" |
---|
8 | #include "dspin_local_ring_fast_c.h" |
---|
9 | #include "soclib_vci_initiator.h" |
---|
10 | #include "soclib_vci_target.h" |
---|
11 | #include "alloc_elems.h" |
---|
12 | #include "vci_param.h" |
---|
13 | #include "virtual_dspin_router.h" |
---|
14 | |
---|
15 | // Router ports index |
---|
16 | #define NORTH 0 |
---|
17 | #define SOUTH 1 |
---|
18 | #define EAST 2 |
---|
19 | #define WEST 3 |
---|
20 | #define LOCAL 4 |
---|
21 | |
---|
22 | #define X_MAX 2 |
---|
23 | #define Y_MAX 2 |
---|
24 | #define cmd_width 40 |
---|
25 | #define rsp_width 33 |
---|
26 | #define X_WIDTH 1 |
---|
27 | #define Y_WIDTH 1 |
---|
28 | #define SRCID_WIDTH 14 |
---|
29 | |
---|
30 | #define cluster(x,y) (y+x*Y_MAX) |
---|
31 | |
---|
32 | #define CYCLES 10000000 |
---|
33 | |
---|
34 | int _main(int argc, char *argv[]) |
---|
35 | { |
---|
36 | using namespace sc_core; |
---|
37 | // Avoid repeating these everywhere |
---|
38 | using soclib::common::IntTab; |
---|
39 | using soclib::common::Segment; |
---|
40 | using soclib::common::alloc_elems; |
---|
41 | using namespace soclib::caba; |
---|
42 | |
---|
43 | // Define VCI parameters |
---|
44 | typedef soclib::caba::VciParams<4,8,32,1,1,1,14,4,4,1> vci_param; |
---|
45 | |
---|
46 | // Mapping table primary network |
---|
47 | soclib::common::MappingTable maptabp(32, IntTab(X_WIDTH + Y_WIDTH, SRCID_WIDTH - X_WIDTH - Y_WIDTH), IntTab(X_WIDTH + Y_WIDTH, SRCID_WIDTH - X_WIDTH - Y_WIDTH), 0x00FF0000); |
---|
48 | for (size_t x = 0; x < X_MAX; x++) |
---|
49 | { |
---|
50 | for (size_t y = 0; y < Y_MAX; y++) |
---|
51 | { |
---|
52 | sc_uint<32> offset = cluster(x,y) << (32 - X_WIDTH - Y_WIDTH); |
---|
53 | |
---|
54 | for ( size_t p = 0 ; p < 4 ; p++) |
---|
55 | { |
---|
56 | std::ostringstream sp; |
---|
57 | sp << "c_seg_proc_" << x << "_" << y << "_" << p; |
---|
58 | maptabp.add( Segment( sp.str() , (p << (32 - SRCID_WIDTH)) + offset , 0x10 , IntTab(cluster(x,y), p) , false)); |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|
62 | /* |
---|
63 | soclib::common::MappingTable maptabp(32, IntTab(2,12), IntTab(2,12), 0xFF000000); |
---|
64 | |
---|
65 | maptabp.add(Segment("target_0_0" , 0x00000000 , 0x00001000 , IntTab(0,0), true )); |
---|
66 | maptabp.add(Segment("target_1_0" , 0x40000000 , 0x00001000 , IntTab(1,0), true )); |
---|
67 | maptabp.add(Segment("target_1_1" , 0x40000000 , 0x00001000 , IntTab(1,1), true )); |
---|
68 | maptabp.add(Segment("target_2_0" , 0x80000000 , 0x00001000 , IntTab(2,0), true )); |
---|
69 | maptabp.add(Segment("target_2_1" , 0xC0000000 , 0x00001000 , IntTab(3,0), true )); |
---|
70 | */ |
---|
71 | // Signals |
---|
72 | |
---|
73 | sc_clock signal_clk("clk"); |
---|
74 | sc_signal<bool> signal_resetn("resetn"); |
---|
75 | |
---|
76 | DspinSignals<40> dspin_cmd[4][5]; |
---|
77 | DspinSignals<33> dspin_rsp[4][5]; |
---|
78 | |
---|
79 | //--- Dspin router |
---|
80 | DspinSignals<cmd_width>*** signal_dspin_false_cmd_in = alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_in", (Y_MAX*X_MAX), 2, 2); |
---|
81 | DspinSignals<cmd_width>*** signal_dspin_false_cmd_out = alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_out", (Y_MAX*X_MAX), 2, 2); |
---|
82 | DspinSignals<rsp_width>*** signal_dspin_false_rsp_in = alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_in", (Y_MAX*X_MAX), 2, 2); |
---|
83 | DspinSignals<rsp_width>*** signal_dspin_false_rsp_out = alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_out", (Y_MAX*X_MAX), 2, 2); |
---|
84 | |
---|
85 | |
---|
86 | // DSPIN signals between local ring & global interconnects |
---|
87 | DspinSignals<cmd_width>** signal_dspin_cmd_l2g_d = |
---|
88 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_cmd_l2g_d", X_MAX, Y_MAX); |
---|
89 | DspinSignals<cmd_width>** signal_dspin_cmd_g2l_d = |
---|
90 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_cmd_g2l_d", X_MAX, Y_MAX); |
---|
91 | |
---|
92 | DspinSignals<cmd_width>** signal_dspin_cmd_l2g_c = |
---|
93 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_cmd_l2g_c", X_MAX, Y_MAX); |
---|
94 | DspinSignals<cmd_width>** signal_dspin_cmd_g2l_c = |
---|
95 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_cmd_g2l_c", X_MAX, Y_MAX); |
---|
96 | |
---|
97 | DspinSignals<rsp_width>** signal_dspin_rsp_l2g_d = |
---|
98 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_rsp_l2g_d", X_MAX, Y_MAX); |
---|
99 | DspinSignals<rsp_width>** signal_dspin_rsp_g2l_d = |
---|
100 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_rsp_g2l_d", X_MAX, Y_MAX); |
---|
101 | |
---|
102 | DspinSignals<rsp_width>** signal_dspin_rsp_l2g_c = |
---|
103 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_rsp_l2g_c", X_MAX, Y_MAX); |
---|
104 | DspinSignals<rsp_width>** signal_dspin_rsp_g2l_c = |
---|
105 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_rsp_g2l_c", X_MAX, Y_MAX); |
---|
106 | |
---|
107 | // Horizontal inter-clusters DSPIN signals |
---|
108 | DspinSignals<cmd_width>*** signal_dspin_h_cmd_inc = |
---|
109 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_inc", X_MAX-1, Y_MAX, 2); |
---|
110 | DspinSignals<cmd_width>*** signal_dspin_h_cmd_dec = |
---|
111 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_dec", X_MAX-1, Y_MAX, 2); |
---|
112 | DspinSignals<rsp_width>*** signal_dspin_h_rsp_inc = |
---|
113 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_inc", X_MAX-1, Y_MAX, 2); |
---|
114 | DspinSignals<rsp_width>*** signal_dspin_h_rsp_dec = |
---|
115 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_dec", X_MAX-1, Y_MAX, 2); |
---|
116 | |
---|
117 | // Vertical inter-clusters DSPIN signals |
---|
118 | DspinSignals<cmd_width>*** signal_dspin_v_cmd_inc = |
---|
119 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_inc", X_MAX, Y_MAX-1, 2); |
---|
120 | DspinSignals<cmd_width>*** signal_dspin_v_cmd_dec = |
---|
121 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_dec", X_MAX, Y_MAX-1, 2); |
---|
122 | DspinSignals<rsp_width>*** signal_dspin_v_rsp_inc = |
---|
123 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_inc", X_MAX, Y_MAX-1, 2); |
---|
124 | DspinSignals<rsp_width>*** signal_dspin_v_rsp_dec = |
---|
125 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_dec", X_MAX, Y_MAX-1, 2); |
---|
126 | |
---|
127 | soclib::caba::SoclibVciInitiator<40,33> initp0("initp0", 0, 16, X_WIDTH, Y_WIDTH, X_MAX, Y_MAX); |
---|
128 | soclib::caba::SoclibVciInitiator<40,33> initp1("initp1", 4096, 16, X_WIDTH, Y_WIDTH, X_MAX, Y_MAX); |
---|
129 | soclib::caba::SoclibVciInitiator<40,33> initp2("initp2", 8192, 16, X_WIDTH, Y_WIDTH, X_MAX, Y_MAX); |
---|
130 | soclib::caba::SoclibVciInitiator<40,33> initp3("initp3", 12288,16, X_WIDTH, Y_WIDTH, X_MAX, Y_MAX); |
---|
131 | |
---|
132 | soclib::caba::SoclibVciTarget<40,33> target0_0("target0_0", 0 ); |
---|
133 | soclib::caba::SoclibVciTarget<40,33> target0_1("target0_1", 1 ); |
---|
134 | soclib::caba::SoclibVciTarget<40,33> target0_2("target0_2", 2 ); |
---|
135 | soclib::caba::SoclibVciTarget<40,33> target0_3("target0_3", 3 ); |
---|
136 | |
---|
137 | soclib::caba::SoclibVciTarget<40,33> target1_0("target1_0", 4 ); |
---|
138 | soclib::caba::SoclibVciTarget<40,33> target1_1("target1_1", 5 ); |
---|
139 | soclib::caba::SoclibVciTarget<40,33> target1_2("target1_2", 6 ); |
---|
140 | soclib::caba::SoclibVciTarget<40,33> target1_3("target1_3", 7 ); |
---|
141 | |
---|
142 | soclib::caba::SoclibVciTarget<40,33> target2_0("target2_0", 8 ); |
---|
143 | soclib::caba::SoclibVciTarget<40,33> target2_1("target2_1", 9 ); |
---|
144 | soclib::caba::SoclibVciTarget<40,33> target2_2("target2_2", 10 ); |
---|
145 | soclib::caba::SoclibVciTarget<40,33> target2_3("target2_3", 11 ); |
---|
146 | |
---|
147 | soclib::caba::SoclibVciTarget<40,33> target3_0("target3_0", 12 ); |
---|
148 | soclib::caba::SoclibVciTarget<40,33> target3_1("target3_1", 13 ); |
---|
149 | soclib::caba::SoclibVciTarget<40,33> target3_2("target3_2", 14 ); |
---|
150 | soclib::caba::SoclibVciTarget<40,33> target3_3("target3_3", 15 ); |
---|
151 | |
---|
152 | // Local ring interconnects : 1 direct ring per cluster |
---|
153 | soclib::caba::DspinLocalRingFastC<vci_param, 40, 33> * clusterPN = (soclib::caba::DspinLocalRingFastC<vci_param, 40, 33> *) malloc(sizeof(soclib::caba::DspinLocalRingFastC<vci_param, 40, 33> )*4); |
---|
154 | |
---|
155 | new(&clusterPN[0]) soclib::caba::DspinLocalRingFastC<vci_param, 40, 33>("clusterPN0",maptabp, IntTab(0), 2, 2, 1, 4, 1, 1 ); |
---|
156 | new(&clusterPN[1]) soclib::caba::DspinLocalRingFastC<vci_param, 40, 33>("clusterPN1",maptabp, IntTab(1), 2, 2, 1, 4, 1, 1 ); |
---|
157 | new(&clusterPN[2]) soclib::caba::DspinLocalRingFastC<vci_param, 40, 33>("clusterPN2",maptabp, IntTab(2), 2, 2, 1, 4, 1, 1 ); |
---|
158 | new(&clusterPN[3]) soclib::caba::DspinLocalRingFastC<vci_param, 40, 33>("clusterPN3",maptabp, IntTab(3), 2, 2, 1, 4, 1, 1 ); |
---|
159 | |
---|
160 | // Distributed Global Interconnect : one cmd router & one rsp router per cluster |
---|
161 | VirtualDspinRouter<cmd_width>* cmdrouter = (VirtualDspinRouter<cmd_width>*) |
---|
162 | malloc(sizeof(VirtualDspinRouter<cmd_width>) * X_MAX * Y_MAX); |
---|
163 | VirtualDspinRouter<rsp_width>* rsprouter = (VirtualDspinRouter<rsp_width>*) |
---|
164 | malloc(sizeof(VirtualDspinRouter<rsp_width>) * X_MAX * Y_MAX); |
---|
165 | |
---|
166 | for ( size_t x = 0 ; x < X_MAX ; x++ ) |
---|
167 | { |
---|
168 | for ( size_t y = 0 ; y < Y_MAX ; y++ ) |
---|
169 | { |
---|
170 | |
---|
171 | std::ostringstream str_cmd; |
---|
172 | std::ostringstream str_rsp; |
---|
173 | |
---|
174 | str_cmd << "cmdrouter_" << x << "_" << y; |
---|
175 | str_rsp << "rsprouter_" << x << "_" << y; |
---|
176 | |
---|
177 | new(&cmdrouter[cluster(x,y)]) VirtualDspinRouter<cmd_width>(str_cmd.str().c_str(), |
---|
178 | x,y, // coordinate in the mesh |
---|
179 | X_WIDTH, Y_WIDTH, // x & y fields width |
---|
180 | 4,4); // input & output fifo depths |
---|
181 | new(&rsprouter[cluster(x,y)]) VirtualDspinRouter<rsp_width>(str_rsp.str().c_str(), |
---|
182 | x,y, // coordinates in mesh |
---|
183 | X_WIDTH, Y_WIDTH, // x & y fields width |
---|
184 | 4,4); // input & output fifo depths |
---|
185 | } |
---|
186 | } |
---|
187 | |
---|
188 | // Initiators |
---|
189 | initp0.p_clk(signal_clk); |
---|
190 | initp0.p_resetn(signal_resetn); |
---|
191 | initp0.p_cmd_out(dspin_cmd[0][0]); |
---|
192 | initp0.p_rsp_in(dspin_rsp[0][0]); |
---|
193 | |
---|
194 | initp1.p_clk(signal_clk); |
---|
195 | initp1.p_resetn(signal_resetn); |
---|
196 | initp1.p_cmd_out(dspin_cmd[1][0]); |
---|
197 | initp1.p_rsp_in(dspin_rsp[1][0]); |
---|
198 | |
---|
199 | initp2.p_clk(signal_clk); |
---|
200 | initp2.p_resetn(signal_resetn); |
---|
201 | initp2.p_cmd_out(dspin_cmd[2][0]); |
---|
202 | initp2.p_rsp_in(dspin_rsp[2][0]); |
---|
203 | |
---|
204 | initp3.p_clk(signal_clk); |
---|
205 | initp3.p_resetn(signal_resetn); |
---|
206 | initp3.p_cmd_out(dspin_cmd[3][0]); |
---|
207 | initp3.p_rsp_in(dspin_rsp[3][0]); |
---|
208 | |
---|
209 | // Target |
---|
210 | target0_0.p_clk(signal_clk); |
---|
211 | target0_0.p_resetn(signal_resetn); |
---|
212 | target0_0.p_cmd_in(dspin_cmd[0][1]); |
---|
213 | target0_0.p_rsp_out(dspin_rsp[0][1]); |
---|
214 | |
---|
215 | target0_1.p_clk(signal_clk); |
---|
216 | target0_1.p_resetn(signal_resetn); |
---|
217 | target0_1.p_cmd_in(dspin_cmd[0][2]); |
---|
218 | target0_1.p_rsp_out(dspin_rsp[0][2]); |
---|
219 | |
---|
220 | target0_2.p_clk(signal_clk); |
---|
221 | target0_2.p_resetn(signal_resetn); |
---|
222 | target0_2.p_cmd_in(dspin_cmd[0][3]); |
---|
223 | target0_2.p_rsp_out(dspin_rsp[0][3]); |
---|
224 | |
---|
225 | target0_3.p_clk(signal_clk); |
---|
226 | target0_3.p_resetn(signal_resetn); |
---|
227 | target0_3.p_cmd_in(dspin_cmd[0][4]); |
---|
228 | target0_3.p_rsp_out(dspin_rsp[0][4]); |
---|
229 | |
---|
230 | target1_0.p_clk(signal_clk); |
---|
231 | target1_0.p_resetn(signal_resetn); |
---|
232 | target1_0.p_cmd_in(dspin_cmd[1][1]); |
---|
233 | target1_0.p_rsp_out(dspin_rsp[1][1]); |
---|
234 | |
---|
235 | target1_1.p_clk(signal_clk); |
---|
236 | target1_1.p_resetn(signal_resetn); |
---|
237 | target1_1.p_cmd_in(dspin_cmd[1][2]); |
---|
238 | target1_1.p_rsp_out(dspin_rsp[1][2]); |
---|
239 | |
---|
240 | target1_2.p_clk(signal_clk); |
---|
241 | target1_2.p_resetn(signal_resetn); |
---|
242 | target1_2.p_cmd_in(dspin_cmd[1][3]); |
---|
243 | target1_2.p_rsp_out(dspin_rsp[1][3]); |
---|
244 | |
---|
245 | target1_3.p_clk(signal_clk); |
---|
246 | target1_3.p_resetn(signal_resetn); |
---|
247 | target1_3.p_cmd_in(dspin_cmd[1][4]); |
---|
248 | target1_3.p_rsp_out(dspin_rsp[1][4]); |
---|
249 | |
---|
250 | target2_0.p_clk(signal_clk); |
---|
251 | target2_0.p_resetn(signal_resetn); |
---|
252 | target2_0.p_cmd_in(dspin_cmd[2][1]); |
---|
253 | target2_0.p_rsp_out(dspin_rsp[2][1]); |
---|
254 | |
---|
255 | target2_1.p_clk(signal_clk); |
---|
256 | target2_1.p_resetn(signal_resetn); |
---|
257 | target2_1.p_cmd_in(dspin_cmd[2][2]); |
---|
258 | target2_1.p_rsp_out(dspin_rsp[2][2]); |
---|
259 | |
---|
260 | target2_2.p_clk(signal_clk); |
---|
261 | target2_2.p_resetn(signal_resetn); |
---|
262 | target2_2.p_cmd_in(dspin_cmd[2][3]); |
---|
263 | target2_2.p_rsp_out(dspin_rsp[2][3]); |
---|
264 | |
---|
265 | target2_3.p_clk(signal_clk); |
---|
266 | target2_3.p_resetn(signal_resetn); |
---|
267 | target2_3.p_cmd_in(dspin_cmd[2][4]); |
---|
268 | target2_3.p_rsp_out(dspin_rsp[2][4]); |
---|
269 | |
---|
270 | target3_0.p_clk(signal_clk); |
---|
271 | target3_0.p_resetn(signal_resetn); |
---|
272 | target3_0.p_cmd_in(dspin_cmd[3][1]); |
---|
273 | target3_0.p_rsp_out(dspin_rsp[3][1]); |
---|
274 | |
---|
275 | target3_1.p_clk(signal_clk); |
---|
276 | target3_1.p_resetn(signal_resetn); |
---|
277 | target3_1.p_cmd_in(dspin_cmd[3][2]); |
---|
278 | target3_1.p_rsp_out(dspin_rsp[3][2]); |
---|
279 | |
---|
280 | target3_2.p_clk(signal_clk); |
---|
281 | target3_2.p_resetn(signal_resetn); |
---|
282 | target3_2.p_cmd_in(dspin_cmd[3][3]); |
---|
283 | target3_2.p_rsp_out(dspin_rsp[3][3]); |
---|
284 | |
---|
285 | target3_3.p_clk(signal_clk); |
---|
286 | target3_3.p_resetn(signal_resetn); |
---|
287 | target3_3.p_cmd_in(dspin_cmd[3][4]); |
---|
288 | target3_3.p_rsp_out(dspin_rsp[3][4]); |
---|
289 | |
---|
290 | |
---|
291 | /////////////////////////////////////////////////////// |
---|
292 | // Routers connections |
---|
293 | /////////////////////////////////////////////////////// |
---|
294 | for ( size_t x = 0 ; x < X_MAX ; x++ ) |
---|
295 | { |
---|
296 | for ( size_t y = 0 ; y < Y_MAX ; y++ ) |
---|
297 | { |
---|
298 | // cmd DSPIN router |
---|
299 | cmdrouter[cluster(x,y)].p_clk (signal_clk); |
---|
300 | cmdrouter[cluster(x,y)].p_resetn (signal_resetn); |
---|
301 | cmdrouter[cluster(x,y)].p_out[0][LOCAL] (signal_dspin_cmd_g2l_d[x][y]); |
---|
302 | cmdrouter[cluster(x,y)].p_out[1][LOCAL] (signal_dspin_cmd_g2l_c[x][y]); |
---|
303 | cmdrouter[cluster(x,y)].p_in[0][LOCAL] (signal_dspin_cmd_l2g_d[x][y]); |
---|
304 | cmdrouter[cluster(x,y)].p_in[1][LOCAL] (signal_dspin_cmd_l2g_c[x][y]); |
---|
305 | |
---|
306 | // rsp DSPIN router |
---|
307 | rsprouter[cluster(x,y)].p_clk (signal_clk); |
---|
308 | rsprouter[cluster(x,y)].p_resetn (signal_resetn); |
---|
309 | rsprouter[cluster(x,y)].p_out[0][LOCAL] (signal_dspin_rsp_g2l_d[x][y]); |
---|
310 | rsprouter[cluster(x,y)].p_out[1][LOCAL] (signal_dspin_rsp_g2l_c[x][y]); |
---|
311 | rsprouter[cluster(x,y)].p_in[0][LOCAL] (signal_dspin_rsp_l2g_d[x][y]); |
---|
312 | rsprouter[cluster(x,y)].p_in[1][LOCAL] (signal_dspin_rsp_l2g_c[x][y]); |
---|
313 | } |
---|
314 | } |
---|
315 | |
---|
316 | // Inter Clusters horizontal connections |
---|
317 | for ( size_t x = 0 ; x < (X_MAX-1) ; x++ ) |
---|
318 | { |
---|
319 | for ( size_t y = 0 ; y < Y_MAX ; y++ ) |
---|
320 | { |
---|
321 | for ( size_t k = 0 ; k < 2 ; k++ ) |
---|
322 | { |
---|
323 | cmdrouter[cluster(x,y)].p_out[k][EAST] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
324 | cmdrouter[cluster((x+1),y)].p_in[k][WEST] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
325 | |
---|
326 | cmdrouter[cluster(x,y)].p_in[k][EAST] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
327 | cmdrouter[cluster((x+1),y)].p_out[k][WEST] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
328 | |
---|
329 | rsprouter[cluster(x,y)].p_out[k][EAST] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
330 | rsprouter[cluster((x+1),y)].p_in[k][WEST] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
331 | |
---|
332 | rsprouter[cluster(x,y)].p_in[k][EAST] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
333 | rsprouter[cluster((x+1),y)].p_out[k][WEST] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
334 | } |
---|
335 | } |
---|
336 | } |
---|
337 | |
---|
338 | |
---|
339 | // East & West boundary clusters connections |
---|
340 | for ( size_t y = 0 ; y < Y_MAX ; y++ ) |
---|
341 | { |
---|
342 | for ( size_t k = 0 ; k < 2 ; k++ ) |
---|
343 | { |
---|
344 | cmdrouter[cluster(0,y)].p_in[k][WEST] (signal_dspin_false_cmd_in[cluster(0,y)][k][0]); |
---|
345 | cmdrouter[cluster(0,y)].p_out[k][WEST] (signal_dspin_false_cmd_out[cluster(0,y)][k][0]); |
---|
346 | rsprouter[cluster(0,y)].p_in[k][WEST] (signal_dspin_false_rsp_in[cluster(0,y)][k][0]); |
---|
347 | rsprouter[cluster(0,y)].p_out[k][WEST] (signal_dspin_false_rsp_out[cluster(0,y)][k][0]); |
---|
348 | |
---|
349 | cmdrouter[cluster((X_MAX-1),y)].p_in[k][EAST] (signal_dspin_false_cmd_in[cluster((X_MAX-1),y)][k][0]); |
---|
350 | cmdrouter[cluster((X_MAX-1),y)].p_out[k][EAST] (signal_dspin_false_cmd_out[cluster((X_MAX-1),y)][k][0]); |
---|
351 | rsprouter[cluster((X_MAX-1),y)].p_in[k][EAST] (signal_dspin_false_rsp_in[cluster((X_MAX-1),y)][k][0]); |
---|
352 | rsprouter[cluster((X_MAX-1),y)].p_out[k][EAST] (signal_dspin_false_rsp_out[cluster((X_MAX-1),y)][k][0]); |
---|
353 | } |
---|
354 | } |
---|
355 | |
---|
356 | // Inter Clusters vertical connections |
---|
357 | for ( size_t y = 0 ; y < (Y_MAX-1) ; y++ ) |
---|
358 | { |
---|
359 | for ( size_t x = 0 ; x < X_MAX ; x++ ) |
---|
360 | { |
---|
361 | for ( size_t k = 0 ; k < 2 ; k++ ) |
---|
362 | { |
---|
363 | cmdrouter[cluster(x,y)].p_out[k][NORTH] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
364 | cmdrouter[cluster(x,(y+1))].p_in[k][SOUTH] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
365 | |
---|
366 | cmdrouter[cluster(x,y)].p_in[k][NORTH] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
367 | cmdrouter[cluster(x,(y+1))].p_out[k][SOUTH] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
368 | |
---|
369 | rsprouter[cluster(x,y)].p_out[k][NORTH] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
370 | rsprouter[cluster(x,(y+1))].p_in[k][SOUTH] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
371 | |
---|
372 | rsprouter[cluster(x,y)].p_in[k][NORTH] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
373 | rsprouter[cluster(x,(y+1))].p_out[k][SOUTH] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
374 | } |
---|
375 | } |
---|
376 | } |
---|
377 | |
---|
378 | // North & South boundary clusters connections |
---|
379 | for ( size_t x = 0 ; x < X_MAX ; x++ ) |
---|
380 | { |
---|
381 | for ( size_t k = 0 ; k < 2 ; k++ ) |
---|
382 | { |
---|
383 | cmdrouter[cluster(x,0)].p_in[k][SOUTH] (signal_dspin_false_cmd_in[cluster(x,0)][k][1]); |
---|
384 | cmdrouter[cluster(x,0)].p_out[k][SOUTH] (signal_dspin_false_cmd_out[cluster(x,0)][k][1]); |
---|
385 | rsprouter[cluster(x,0)].p_in[k][SOUTH] (signal_dspin_false_rsp_in[cluster(x,0)][k][1]); |
---|
386 | rsprouter[cluster(x,0)].p_out[k][SOUTH] (signal_dspin_false_rsp_out[cluster(x,0)][k][1]); |
---|
387 | |
---|
388 | cmdrouter[cluster(x,(Y_MAX-1))].p_out[k][NORTH] (signal_dspin_false_cmd_out[cluster(x,(Y_MAX-1))][k][1]); |
---|
389 | cmdrouter[cluster(x,(Y_MAX-1))].p_in[k][NORTH] (signal_dspin_false_cmd_in[cluster(x,(Y_MAX-1))][k][1]); |
---|
390 | rsprouter[cluster(x,(Y_MAX-1))].p_out[k][NORTH] (signal_dspin_false_rsp_out[cluster(x,(Y_MAX-1))][k][1]); |
---|
391 | rsprouter[cluster(x,(Y_MAX-1))].p_in[k][NORTH] (signal_dspin_false_rsp_in[cluster(x,(Y_MAX-1))][k][1]); |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | clusterPN[0].p_clk(signal_clk); |
---|
396 | clusterPN[0].p_resetn(signal_resetn); |
---|
397 | |
---|
398 | clusterPN[0].p_cmd_in[0](dspin_cmd[0][0]); |
---|
399 | clusterPN[0].p_rsp_out[0](dspin_rsp[0][0]); |
---|
400 | |
---|
401 | |
---|
402 | clusterPN[0].p_cmd_out[0](dspin_cmd[0][1]); |
---|
403 | clusterPN[0].p_rsp_in[0](dspin_rsp[0][1]); |
---|
404 | clusterPN[0].p_cmd_out[1](dspin_cmd[0][2]); |
---|
405 | clusterPN[0].p_rsp_in[1](dspin_rsp[0][2]); |
---|
406 | clusterPN[0].p_cmd_out[2](dspin_cmd[0][3]); |
---|
407 | clusterPN[0].p_rsp_in[2](dspin_rsp[0][3]); |
---|
408 | clusterPN[0].p_cmd_out[3](dspin_cmd[0][4]); |
---|
409 | clusterPN[0].p_rsp_in[3](dspin_rsp[0][4]); |
---|
410 | |
---|
411 | clusterPN[0].p_cmd_in[1](signal_dspin_cmd_g2l_d[0][0]); |
---|
412 | clusterPN[0].p_rsp_out[1](signal_dspin_rsp_l2g_d[0][0]); |
---|
413 | clusterPN[0].p_cmd_out[4](signal_dspin_cmd_l2g_d[0][0]); |
---|
414 | clusterPN[0].p_rsp_in[4](signal_dspin_rsp_g2l_d[0][0]); |
---|
415 | |
---|
416 | clusterPN[1].p_clk(signal_clk); |
---|
417 | clusterPN[1].p_resetn(signal_resetn); |
---|
418 | |
---|
419 | clusterPN[1].p_cmd_in[0](dspin_cmd[1][0]); |
---|
420 | clusterPN[1].p_rsp_out[0](dspin_rsp[1][0]); |
---|
421 | |
---|
422 | clusterPN[1].p_cmd_out[0](dspin_cmd[1][1]); |
---|
423 | clusterPN[1].p_rsp_in[0](dspin_rsp[1][1]); |
---|
424 | clusterPN[1].p_cmd_out[1](dspin_cmd[1][2]); |
---|
425 | clusterPN[1].p_rsp_in[1](dspin_rsp[1][2]); |
---|
426 | clusterPN[1].p_cmd_out[2](dspin_cmd[1][3]); |
---|
427 | clusterPN[1].p_rsp_in[2](dspin_rsp[1][3]); |
---|
428 | clusterPN[1].p_cmd_out[3](dspin_cmd[1][4]); |
---|
429 | clusterPN[1].p_rsp_in[3](dspin_rsp[1][4]); |
---|
430 | |
---|
431 | clusterPN[1].p_cmd_in[1](signal_dspin_cmd_g2l_d[0][1]); |
---|
432 | clusterPN[1].p_rsp_out[1](signal_dspin_rsp_l2g_d[0][1]); |
---|
433 | clusterPN[1].p_cmd_out[4](signal_dspin_cmd_l2g_d[0][1]); |
---|
434 | clusterPN[1].p_rsp_in[4](signal_dspin_rsp_g2l_d[0][1]); |
---|
435 | |
---|
436 | clusterPN[2].p_clk(signal_clk); |
---|
437 | clusterPN[2].p_resetn(signal_resetn); |
---|
438 | |
---|
439 | clusterPN[2].p_cmd_in[0](dspin_cmd[2][0]); |
---|
440 | clusterPN[2].p_rsp_out[0](dspin_rsp[2][0]); |
---|
441 | |
---|
442 | clusterPN[2].p_cmd_out[0](dspin_cmd[2][1]); |
---|
443 | clusterPN[2].p_rsp_in[0](dspin_rsp[2][1]); |
---|
444 | clusterPN[2].p_cmd_out[1](dspin_cmd[2][2]); |
---|
445 | clusterPN[2].p_rsp_in[1](dspin_rsp[2][2]); |
---|
446 | clusterPN[2].p_cmd_out[2](dspin_cmd[2][3]); |
---|
447 | clusterPN[2].p_rsp_in[2](dspin_rsp[2][3]); |
---|
448 | clusterPN[2].p_cmd_out[3](dspin_cmd[2][4]); |
---|
449 | clusterPN[2].p_rsp_in[3](dspin_rsp[2][4]); |
---|
450 | |
---|
451 | clusterPN[2].p_cmd_in[1](signal_dspin_cmd_g2l_d[1][0]); |
---|
452 | clusterPN[2].p_rsp_out[1](signal_dspin_rsp_l2g_d[1][0]); |
---|
453 | clusterPN[2].p_cmd_out[4](signal_dspin_cmd_l2g_d[1][0]); |
---|
454 | clusterPN[2].p_rsp_in[4](signal_dspin_rsp_g2l_d[1][0]); |
---|
455 | |
---|
456 | clusterPN[3].p_clk(signal_clk); |
---|
457 | clusterPN[3].p_resetn(signal_resetn); |
---|
458 | |
---|
459 | clusterPN[3].p_cmd_in[0](dspin_cmd[3][0]); |
---|
460 | clusterPN[3].p_rsp_out[0](dspin_rsp[3][0]); |
---|
461 | |
---|
462 | clusterPN[3].p_cmd_out[0](dspin_cmd[3][1]); |
---|
463 | clusterPN[3].p_rsp_in[0](dspin_rsp[3][1]); |
---|
464 | clusterPN[3].p_cmd_out[1](dspin_cmd[3][2]); |
---|
465 | clusterPN[3].p_rsp_in[1](dspin_rsp[3][2]); |
---|
466 | clusterPN[3].p_cmd_out[2](dspin_cmd[3][3]); |
---|
467 | clusterPN[3].p_rsp_in[2](dspin_rsp[3][3]); |
---|
468 | clusterPN[3].p_cmd_out[3](dspin_cmd[3][4]); |
---|
469 | clusterPN[3].p_rsp_in[3](dspin_rsp[3][4]); |
---|
470 | |
---|
471 | clusterPN[3].p_cmd_in[1](signal_dspin_cmd_g2l_d[1][1]); |
---|
472 | clusterPN[3].p_rsp_out[1](signal_dspin_rsp_l2g_d[1][1]); |
---|
473 | clusterPN[3].p_cmd_out[4](signal_dspin_cmd_l2g_d[1][1]); |
---|
474 | clusterPN[3].p_rsp_in[4](signal_dspin_rsp_g2l_d[1][1]); |
---|
475 | |
---|
476 | //////////////////////////////////////////////////////// |
---|
477 | |
---|
478 | int ncycles; |
---|
479 | |
---|
480 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
481 | signal_resetn = false; |
---|
482 | |
---|
483 | for(size_t x = 0; x < X_MAX; x++) |
---|
484 | { |
---|
485 | for(size_t y = 0; y < Y_MAX; y++) |
---|
486 | { |
---|
487 | signal_dspin_cmd_g2l_c[x][y].write = false; |
---|
488 | signal_dspin_cmd_g2l_c[x][y].read = true; |
---|
489 | signal_dspin_rsp_g2l_c[x][y].write = false; |
---|
490 | signal_dspin_rsp_g2l_c[x][y].read = true; |
---|
491 | signal_dspin_cmd_l2g_c[x][y].write = false; |
---|
492 | signal_dspin_cmd_l2g_c[x][y].read = true; |
---|
493 | signal_dspin_rsp_l2g_c[x][y].write = false; |
---|
494 | signal_dspin_rsp_l2g_c[x][y].read = true; |
---|
495 | } |
---|
496 | } |
---|
497 | |
---|
498 | for(size_t t = 0; t < X_MAX*Y_MAX; t++) |
---|
499 | { |
---|
500 | for (size_t k = 0; k < 2; k++) |
---|
501 | { |
---|
502 | for(size_t a = 0; a < 2; a ++) |
---|
503 | { |
---|
504 | signal_dspin_false_cmd_in[t][k][a].write = false; |
---|
505 | signal_dspin_false_cmd_in[t][k][a].read = true; |
---|
506 | signal_dspin_false_cmd_out[t][k][a].write = false; |
---|
507 | signal_dspin_false_cmd_out[t][k][a].read = true; |
---|
508 | |
---|
509 | signal_dspin_false_rsp_in[t][k][a].write = false; |
---|
510 | signal_dspin_false_rsp_in[t][k][a].read = true; |
---|
511 | signal_dspin_false_rsp_out[t][k][a].write = false; |
---|
512 | signal_dspin_false_rsp_out[t][k][a].read = true; |
---|
513 | } |
---|
514 | } |
---|
515 | } |
---|
516 | |
---|
517 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
518 | signal_resetn = true; |
---|
519 | |
---|
520 | |
---|
521 | while(1) |
---|
522 | { |
---|
523 | //rsprouter[3].debug_trace(0); |
---|
524 | //rsprouter[2].debug_trace(0); |
---|
525 | sc_start(sc_core::sc_time(CYCLES, SC_NS)); |
---|
526 | //sc_start(sc_core::sc_time(1, SC_NS)); |
---|
527 | |
---|
528 | } |
---|
529 | |
---|
530 | std::cout << "Hit ENTER to end simulation" << std::endl; |
---|
531 | char buf[1]; |
---|
532 | |
---|
533 | std::cin.getline(buf,1); |
---|
534 | |
---|
535 | return EXIT_SUCCESS; |
---|
536 | } |
---|
537 | |
---|
538 | int sc_main (int argc, char *argv[]) |
---|
539 | { |
---|
540 | try { |
---|
541 | return _main(argc, argv); |
---|
542 | } catch (std::exception &e) { |
---|
543 | std::cout << e.what() << std::endl; |
---|
544 | } catch (...) { |
---|
545 | std::cout << "Unknown exception occured" << std::endl; |
---|
546 | throw; |
---|
547 | } |
---|
548 | return 1; |
---|
549 | } |
---|