1 | ///////////////////////////////////////////////////////////////////////// |
---|
2 | // File: top.cpp |
---|
3 | // Author: Alain Greiner |
---|
4 | // Copyright: UPMC/LIP6 |
---|
5 | // Date : june 2011 |
---|
6 | // This program is released under the GNU public license |
---|
7 | ///////////////////////////////////////////////////////////////////////// |
---|
8 | // This file define a generic TSAR architecture with virtual memory. |
---|
9 | // - It uses vci_local_crossbar as local interconnect |
---|
10 | // - It uses virtual_dspin as global interconnect |
---|
11 | // - It uses the vci_cc_vcache_wrapper_v4 |
---|
12 | // - It uses the vci_mem_cache_v4 |
---|
13 | // - It uses one vci_xicu, one vci_multi_tty, |
---|
14 | // and one vci_multi_dma controler per cluster. |
---|
15 | // |
---|
16 | // It is build with one single component implementing a cluster: |
---|
17 | // The Tsarv4ClusterMmu component is defined in files |
---|
18 | // tsarv4_cluster_mmu.* (with * = cpp, h, sd) |
---|
19 | // |
---|
20 | // The physical address space is 32 bits. |
---|
21 | // The number of clusters cannot be larger than 256. |
---|
22 | // The number of processors per cluster cannot be larger than 4. |
---|
23 | // The parameters must be power of 2. |
---|
24 | // - xmax : number of clusters in a row |
---|
25 | // - ymax : number of clusters in a column |
---|
26 | // - nprocs : number of processors per cluster |
---|
27 | // |
---|
28 | // The peripherals BDEV, FBUF, and the boot BROM |
---|
29 | // are in the cluster containing address 0xBFC00000. |
---|
30 | // - The nprocs TTY IRQs are connected to IRQ_IN[0] to IRQ_IN[3] |
---|
31 | // - The nprocs DMA IRQs are connected to IRQ_IN[4] to IRQ_IN[7] |
---|
32 | // - The IOC IRQ is connected to IRQ_IN[8] |
---|
33 | // |
---|
34 | // General policy for 32 bits physical address decoding: |
---|
35 | // All segments base addresses are multiple of 64 Kbytes |
---|
36 | // Therefore the 16 address MSB bits completely define the target: |
---|
37 | // The (x_width + y_width) MSB bits (left aligned) define |
---|
38 | // the cluster index, and the 8 LSB bits define the local index: |
---|
39 | // | X_ID | Y_ID |---| LADR | OFFSET | |
---|
40 | // |x_width|y_width|---| 8 | 16 | |
---|
41 | ///////////////////////////////////////////////////////////////////////// |
---|
42 | |
---|
43 | #include <systemc> |
---|
44 | #include <sys/time.h> |
---|
45 | #include <iostream> |
---|
46 | #include <sstream> |
---|
47 | #include <cstdlib> |
---|
48 | #include <cstdarg> |
---|
49 | #include <stdint.h> |
---|
50 | |
---|
51 | #include "gdbserver.h" |
---|
52 | #include "mapping_table.h" |
---|
53 | #include "tsarv4_cluster_mmu.h" |
---|
54 | #include "alloc_elems.h" |
---|
55 | |
---|
56 | /////////////////////////////////////////////////// |
---|
57 | // OS |
---|
58 | /////////////////////////////////////////////////// |
---|
59 | |
---|
60 | #define USE_ALMOS 0 |
---|
61 | #define almos_bootloader_pathname "/Users/alain/soc/tsar-svn-june-2010/softs/almos/bootloader/bin/bootloader-soclib-mipsel.bin" |
---|
62 | #define almos_kernel_pathname "/Users/alain/soc/tsar-svn-june-2010/softs/almos/kernel/bin/kernel-soclib-mipsel.bin@0xbfc10000:D" |
---|
63 | #define almos_archinfo_pathname "/Users/alain/soc/tsar-svn-june-2010/softs/almos/arch_bins/arch-info_4_4.bin@0xBFC08000:D" |
---|
64 | |
---|
65 | /////////////////////////////////////////////////// |
---|
66 | // Parallelisation |
---|
67 | /////////////////////////////////////////////////// |
---|
68 | |
---|
69 | #define USE_OPENMP 0 |
---|
70 | #define OPENMP_THREADS_NR 8 |
---|
71 | |
---|
72 | #if USE_OPENMP |
---|
73 | #include <omp.h> |
---|
74 | #endif |
---|
75 | |
---|
76 | // cluster index (computed from x,y coordinates) |
---|
77 | #define cluster(x,y) (y + ymax*x) |
---|
78 | |
---|
79 | // flit widths for the DSPIN network |
---|
80 | #define cmd_width 40 |
---|
81 | #define rsp_width 33 |
---|
82 | |
---|
83 | // VCI format |
---|
84 | #define cell_width 4 |
---|
85 | #define address_width 32 |
---|
86 | #define plen_width 8 |
---|
87 | #define error_width 2 |
---|
88 | #define clen_width 1 |
---|
89 | #define rflag_width 1 |
---|
90 | #define srcid_width 14 |
---|
91 | #define pktid_width 4 |
---|
92 | #define trdid_width 4 |
---|
93 | #define wrplen_width 1 |
---|
94 | |
---|
95 | /////////////////////////////////////////////////// |
---|
96 | // Parameters default values |
---|
97 | /////////////////////////////////////////////////// |
---|
98 | |
---|
99 | #define MESH_XMAX 2 |
---|
100 | #define MESH_YMAX 2 |
---|
101 | |
---|
102 | #define NPROCS 4 |
---|
103 | #define XRAM_LATENCY 0 |
---|
104 | |
---|
105 | #define MEMC_WAYS 16 |
---|
106 | #define MEMC_SETS 256 |
---|
107 | |
---|
108 | #define L1_IWAYS 4 |
---|
109 | #define L1_ISETS 64 |
---|
110 | |
---|
111 | #define L1_DWAYS 4 |
---|
112 | #define L1_DSETS 64 |
---|
113 | |
---|
114 | #define FBUF_X_SIZE 512 |
---|
115 | #define FBUF_Y_SIZE 512 |
---|
116 | |
---|
117 | #define BDEV_SECTOR_SIZE 128 |
---|
118 | #define BDEV_IMAGE_NAME "../../softs/soft_transpose_giet/couple_512.raw" |
---|
119 | |
---|
120 | #define BOOT_SOFT_NAME "../../softs/soft_transpose_giet/bin.soft" |
---|
121 | |
---|
122 | #define MAX_FROZEN_CYCLES 100000 |
---|
123 | |
---|
124 | ///////////////////////////////////////////////////////// |
---|
125 | // Physical segments definition |
---|
126 | ///////////////////////////////////////////////////////// |
---|
127 | // There is 3 segments replicated in all clusters: |
---|
128 | // - seg_memc -> MEMC / BASE = 0x**000000 (12 M bytes) |
---|
129 | // - seg_icu -> ICU / BASE = 0x**F00000 |
---|
130 | // - seg_dma -> CDMA / BASE = 0x**F30000 |
---|
131 | // |
---|
132 | // There is 4 specific segments in the "IO" cluster |
---|
133 | // (containing address 0xBF000000) |
---|
134 | // - seg_reset -> BROM / BASE = 0xBFC00000 (1 Mbytes) |
---|
135 | // - seg_fbuf -> FBUF / BASE = 0xBFD00000 (2 M bytes) |
---|
136 | // - seg_bdev -> BDEV / BASE = 0xBFF10000 |
---|
137 | // - seg_tty -> MTTY / BASE = 0x**F20000 |
---|
138 | // |
---|
139 | // There is one special segment corresponding to |
---|
140 | // the processors in the coherence address space |
---|
141 | // - seg_proc -> PROC / BASE = 0x**B0 to 0xBF |
---|
142 | /////////////////////////////////////////////////// |
---|
143 | |
---|
144 | // specific segments in "IO" cluster |
---|
145 | |
---|
146 | #define BROM_BASE 0xBFC00000 |
---|
147 | #define BROM_SIZE 0x00100000 |
---|
148 | |
---|
149 | #define FBUF_BASE 0xBFD00000 |
---|
150 | #define FBUF_SIZE 0x00200000 |
---|
151 | |
---|
152 | #define BDEV_BASE 0xBFF10000 |
---|
153 | #define BDEV_SIZE 0x00000020 |
---|
154 | |
---|
155 | #define MTTY_BASE 0xBFF20000 |
---|
156 | #define MTTY_SIZE 0x00000040 |
---|
157 | |
---|
158 | // replicated segments |
---|
159 | |
---|
160 | #define MEMC_BASE 0x00000000 |
---|
161 | #define MEMC_SIZE 0x00C00000 |
---|
162 | |
---|
163 | #define XICU_BASE 0x00F00000 |
---|
164 | #define XICU_SIZE 0x00001000 |
---|
165 | |
---|
166 | #define CDMA_BASE 0x00F30000 |
---|
167 | #define CDMA_SIZE 0x00004000 |
---|
168 | |
---|
169 | #define PROC_BASE 0x00D00000 |
---|
170 | #define PROC_SIZE 0x00000010 |
---|
171 | |
---|
172 | //////////////////////////////////////////////////////////////////// |
---|
173 | // TGTID definition in direct space |
---|
174 | // For all components: global TGTID = global SRCID = cluster_index |
---|
175 | //////////////////////////////////////////////////////////////////// |
---|
176 | |
---|
177 | #define MEMC_TGTID 0 |
---|
178 | #define XICU_TGTID 1 |
---|
179 | #define CDMA_TGTID 2 |
---|
180 | #define MTTY_TGTID 3 |
---|
181 | #define FBUF_TGTID 4 |
---|
182 | #define BROM_TGTID 5 |
---|
183 | #define BDEV_TGTID 6 |
---|
184 | |
---|
185 | ///////////////////////////////// |
---|
186 | int _main(int argc, char *argv[]) |
---|
187 | { |
---|
188 | using namespace sc_core; |
---|
189 | using namespace soclib::caba; |
---|
190 | using namespace soclib::common; |
---|
191 | |
---|
192 | |
---|
193 | char soft_name[256] = BOOT_SOFT_NAME; // pathname to binary code |
---|
194 | size_t ncycles = 1000000000; // simulated cycles |
---|
195 | size_t xmax = MESH_XMAX; // number of clusters in a row |
---|
196 | size_t ymax = MESH_YMAX; // number of clusters in a column |
---|
197 | size_t nprocs = NPROCS; // number of processors per cluster |
---|
198 | size_t xfb = FBUF_X_SIZE; // frameBuffer column number |
---|
199 | size_t yfb = FBUF_Y_SIZE; // frameBuffer lines number |
---|
200 | size_t memc_ways = MEMC_WAYS; |
---|
201 | size_t memc_sets = MEMC_SETS; |
---|
202 | size_t l1_d_ways = L1_DWAYS; |
---|
203 | size_t l1_d_sets = L1_DSETS; |
---|
204 | size_t l1_i_ways = L1_IWAYS; |
---|
205 | size_t l1_i_sets = L1_ISETS; |
---|
206 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
207 | size_t blk_size = BDEV_SECTOR_SIZE; // block size (in bytes) |
---|
208 | size_t xram_latency = XRAM_LATENCY; // external RAM latency |
---|
209 | bool trace_ok = false; // trace activated |
---|
210 | size_t trace_period = 1; // trace period |
---|
211 | uint32_t from_cycle = 0; // debug start cycle |
---|
212 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
213 | |
---|
214 | ////////////// command line arguments ////////////////////// |
---|
215 | if (argc > 1){ |
---|
216 | for (int n = 1; n < argc; n = n + 2){ |
---|
217 | if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc)){ |
---|
218 | ncycles = atoi(argv[n+1]); |
---|
219 | } |
---|
220 | else if ((strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc)){ |
---|
221 | nprocs = atoi(argv[n+1]); |
---|
222 | assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)) && |
---|
223 | "NPROCS must be equal to 1, 2, or 4"); |
---|
224 | } |
---|
225 | else if ((strcmp(argv[n],"-XMAX") == 0) && (n+1<argc)){ |
---|
226 | xmax = atoi(argv[n+1]); |
---|
227 | assert( ((xmax == 1) || (xmax == 2) || (xmax == 4) || (xmax == 8) || (xmax == 16)) |
---|
228 | && "The XMAX parameter must be 2, 4, 8, or 16" ); |
---|
229 | } |
---|
230 | |
---|
231 | else if ((strcmp(argv[n],"-YMAX") == 0) && (n+1<argc)){ |
---|
232 | ymax = atoi(argv[n+1]); |
---|
233 | assert( ((ymax == 1) || (ymax == 2) || (ymax == 4) || (ymax == 8) || (ymax == 16)) |
---|
234 | && "The YMAX parameter must be 2, 4, 8, or 16" ); |
---|
235 | } |
---|
236 | else if ((strcmp(argv[n],"-XFB") == 0) && (n+1<argc)){ |
---|
237 | xfb = atoi(argv[n+1]); |
---|
238 | } |
---|
239 | else if ((strcmp(argv[n],"-YFB") == 0) && (n+1<argc) ){ |
---|
240 | yfb = atoi(argv[n+1]); |
---|
241 | } |
---|
242 | else if ((strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) ){ |
---|
243 | strcpy(soft_name, argv[n+1]); |
---|
244 | } |
---|
245 | else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) ){ |
---|
246 | strcpy(disk_name, argv[n+1]); |
---|
247 | } |
---|
248 | else if ((strcmp(argv[n],"-TRACE") == 0) && (n+1<argc) ){ |
---|
249 | trace_ok = true; |
---|
250 | from_cycle = atoi(argv[n+1]); |
---|
251 | } |
---|
252 | else if ((strcmp(argv[n], "-MCWAYS") == 0) && (n+1 < argc)){ |
---|
253 | memc_ways = atoi(argv[n+1]); |
---|
254 | } |
---|
255 | else if ((strcmp(argv[n], "-MCSETS") == 0) && (n+1 < argc)){ |
---|
256 | memc_sets = atoi(argv[n+1]); |
---|
257 | } |
---|
258 | else if ((strcmp(argv[n], "-XLATENCY") == 0) && (n+1 < argc)){ |
---|
259 | xram_latency = atoi(argv[n+1]); |
---|
260 | } |
---|
261 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc)){ |
---|
262 | frozen_cycles = atoi(argv[n+1]); |
---|
263 | } |
---|
264 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n+1 < argc)){ |
---|
265 | trace_period = atoi(argv[n+1]); |
---|
266 | } |
---|
267 | else |
---|
268 | { |
---|
269 | std::cout << " Arguments on the command line are (key,value) couples." << std::endl; |
---|
270 | std::cout << " The order is not important." << std::endl; |
---|
271 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
272 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
273 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
274 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
275 | std::cout << " -NPROCS number_of_processors_per_cluster" << std::endl; |
---|
276 | std::cout << " -XMAX number_of_clusters_in_a_row" << std::endl; |
---|
277 | std::cout << " -YMAX number_of_clusters_in_a_column" << std::endl; |
---|
278 | std::cout << " -TRACE debug_start_cycle" << std::endl; |
---|
279 | std::cout << " -MCWAYS memory_cache_number_of_ways" << std::endl; |
---|
280 | std::cout << " -MCSETS memory_cache_number_of_sets" << std::endl; |
---|
281 | std::cout << " -XLATENCY external_ram_latency_value" << std::endl; |
---|
282 | std::cout << " -XFB fram_buffer_number_of_pixels" << std::endl; |
---|
283 | std::cout << " -YFB fram_buffer_number_of_lines" << std::endl; |
---|
284 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
285 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
286 | exit(0); |
---|
287 | } |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | std::cout << std::endl; |
---|
292 | std::cout << " - NPROCS = " << nprocs << std::endl; |
---|
293 | std::cout << " - NCLUSTERS = " << xmax*ymax << std::endl; |
---|
294 | std::cout << " - MAX FROZEN = " << frozen_cycles << std::endl; |
---|
295 | std::cout << " - MEMC_WAYS = " << memc_ways << std::endl; |
---|
296 | std::cout << " - MEMC_SETS = " << memc_sets << std::endl; |
---|
297 | std::cout << " - RAM_LATENCY = " << xram_latency << std::endl; |
---|
298 | |
---|
299 | std::cout << std::endl; |
---|
300 | |
---|
301 | #if USE_OPENMP |
---|
302 | omp_set_dynamic(false); |
---|
303 | omp_set_num_threads(threads_nr); |
---|
304 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
305 | #endif |
---|
306 | |
---|
307 | // Define VCI parameters |
---|
308 | typedef soclib::caba::VciParams<cell_width, |
---|
309 | plen_width, |
---|
310 | address_width, |
---|
311 | error_width, |
---|
312 | clen_width, |
---|
313 | rflag_width, |
---|
314 | srcid_width, |
---|
315 | pktid_width, |
---|
316 | trdid_width, |
---|
317 | wrplen_width> vci_param; |
---|
318 | |
---|
319 | size_t cluster_io_index; |
---|
320 | size_t x_width; |
---|
321 | size_t y_width; |
---|
322 | |
---|
323 | if (xmax == 1) x_width = 0; |
---|
324 | else if (xmax == 2) x_width = 1; |
---|
325 | else if (xmax <= 4) x_width = 2; |
---|
326 | else if (xmax <= 8) x_width = 3; |
---|
327 | else x_width = 4; |
---|
328 | |
---|
329 | if (ymax == 1) y_width = 0; |
---|
330 | else if (ymax == 2) y_width = 1; |
---|
331 | else if (ymax <= 4) y_width = 2; |
---|
332 | else if (ymax <= 8) y_width = 3; |
---|
333 | else y_width = 4; |
---|
334 | |
---|
335 | cluster_io_index = 0xBF >> (8 - x_width - y_width); |
---|
336 | |
---|
337 | ///////////////////// |
---|
338 | // Mapping Tables |
---|
339 | ///////////////////// |
---|
340 | |
---|
341 | // direct network |
---|
342 | MappingTable maptabd(address_width, |
---|
343 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
344 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
345 | 0x00FF0000); |
---|
346 | |
---|
347 | for (size_t x = 0; x < xmax; x++){ |
---|
348 | for (size_t y = 0; y < ymax; y++){ |
---|
349 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
350 | |
---|
351 | std::ostringstream sh; |
---|
352 | sh << "d_seg_memc_" << x << "_" << y; |
---|
353 | maptabd.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
354 | |
---|
355 | std::ostringstream si; |
---|
356 | si << "d_seg_xicu_" << x << "_" << y; |
---|
357 | maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
358 | |
---|
359 | std::ostringstream sd; |
---|
360 | sd << "d_seg_mdma_" << x << "_" << y; |
---|
361 | maptabd.add(Segment(sd.str(), CDMA_BASE+offset, CDMA_SIZE, IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
362 | |
---|
363 | if ( cluster(x,y) == cluster_io_index ) |
---|
364 | { |
---|
365 | maptabd.add(Segment("d_seg_mtty ", MTTY_BASE, MTTY_SIZE, IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
366 | maptabd.add(Segment("d_seg_fbuf ", FBUF_BASE, FBUF_SIZE, IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
367 | maptabd.add(Segment("d_seg_bdev ", BDEV_BASE, BDEV_SIZE, IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
368 | maptabd.add(Segment("d_seg_brom ", BROM_BASE, BROM_SIZE, IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | std::cout << maptabd << std::endl; |
---|
373 | |
---|
374 | // coherence network |
---|
375 | // - tgtid_c_proc = srcid_c_proc = local procid |
---|
376 | // - tgtid_c_memc = srcid_c_memc = nprocs |
---|
377 | MappingTable maptabc(address_width, |
---|
378 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
379 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
380 | 0x00FF0000); |
---|
381 | |
---|
382 | for (size_t x = 0; x < xmax; x++){ |
---|
383 | for (size_t y = 0; y < ymax; y++){ |
---|
384 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
385 | |
---|
386 | // cleanup requests regarding the memc segment must be routed to the memory cache |
---|
387 | std::ostringstream sh; |
---|
388 | sh << "c_seg_memc_" << x << "_" << y; |
---|
389 | maptabc.add(Segment(sh.str(), (nprocs << (address_width - srcid_width)) + offset, 0x10, IntTab(cluster(x,y), nprocs), false)); |
---|
390 | |
---|
391 | // update & invalidate requests must be routed to the proper processor |
---|
392 | for ( size_t p = 0 ; p < nprocs ; p++) { |
---|
393 | std::ostringstream sp; |
---|
394 | sp << "c_seg_proc_" << x << "_" << y << "_" << p; |
---|
395 | maptabc.add( Segment( sp.str() , (p << (address_width - srcid_width)) + offset , 0x10 , IntTab(cluster(x,y), p) , false)); |
---|
396 | } |
---|
397 | } |
---|
398 | } |
---|
399 | std::cout << maptabc << std::endl; |
---|
400 | |
---|
401 | // external network |
---|
402 | MappingTable maptabx(address_width, IntTab(1), IntTab(x_width+y_width), 0xF0000000); |
---|
403 | |
---|
404 | for (size_t x = 0; x < xmax; x++){ |
---|
405 | for (size_t y = 0; y < ymax ; y++){ |
---|
406 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
407 | std::ostringstream sh; |
---|
408 | sh << "x_seg_memc_" << x << "_" << y; |
---|
409 | maptabx.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y)), false)); |
---|
410 | } |
---|
411 | } |
---|
412 | std::cout << maptabx << std::endl; |
---|
413 | |
---|
414 | //////////////////// |
---|
415 | // Signals |
---|
416 | /////////////////// |
---|
417 | |
---|
418 | sc_clock signal_clk("clk"); |
---|
419 | sc_signal<bool> signal_resetn("resetn"); |
---|
420 | |
---|
421 | // Horizontal inter-clusters DSPIN signals |
---|
422 | DspinSignals<cmd_width>*** signal_dspin_h_cmd_inc = |
---|
423 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_inc", xmax-1, ymax, 2); |
---|
424 | DspinSignals<cmd_width>*** signal_dspin_h_cmd_dec = |
---|
425 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_dec", xmax-1, ymax, 2); |
---|
426 | DspinSignals<rsp_width>*** signal_dspin_h_rsp_inc = |
---|
427 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_inc", xmax-1, ymax, 2); |
---|
428 | DspinSignals<rsp_width>*** signal_dspin_h_rsp_dec = |
---|
429 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_dec", xmax-1, ymax, 2); |
---|
430 | |
---|
431 | // Vertical inter-clusters DSPIN signals |
---|
432 | DspinSignals<cmd_width>*** signal_dspin_v_cmd_inc = |
---|
433 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_inc", xmax, ymax-1, 2); |
---|
434 | DspinSignals<cmd_width>*** signal_dspin_v_cmd_dec = |
---|
435 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_dec", xmax, ymax-1, 2); |
---|
436 | DspinSignals<rsp_width>*** signal_dspin_v_rsp_inc = |
---|
437 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_inc", xmax, ymax-1, 2); |
---|
438 | DspinSignals<rsp_width>*** signal_dspin_v_rsp_dec = |
---|
439 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_dec", xmax, ymax-1, 2); |
---|
440 | |
---|
441 | // Mesh boundaries DSPIN signals |
---|
442 | DspinSignals<cmd_width>**** signal_dspin_false_cmd_in = |
---|
443 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_in", xmax, ymax, 2, 4); |
---|
444 | DspinSignals<cmd_width>**** signal_dspin_false_cmd_out = |
---|
445 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_out", xmax, ymax, 2, 4); |
---|
446 | DspinSignals<rsp_width>**** signal_dspin_false_rsp_in = |
---|
447 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_in", xmax, ymax, 2, 4); |
---|
448 | DspinSignals<rsp_width>**** signal_dspin_false_rsp_out = |
---|
449 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_out", xmax, ymax, 2, 4); |
---|
450 | |
---|
451 | |
---|
452 | //////////////////////////// |
---|
453 | // Components |
---|
454 | //////////////////////////// |
---|
455 | |
---|
456 | #if USE_ALMOS |
---|
457 | soclib::common::Loader loader(almos_bootloader_pathname, |
---|
458 | almos_archinfo_pathname, |
---|
459 | almos_kernel_pathname); |
---|
460 | #else |
---|
461 | soclib::common::Loader loader(soft_name); |
---|
462 | #endif |
---|
463 | |
---|
464 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
465 | proc_iss::set_loader(loader); |
---|
466 | |
---|
467 | TsarV4ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width>* clusters[xmax][ymax]; |
---|
468 | |
---|
469 | #if USE_OPENMP |
---|
470 | |
---|
471 | #pragma omp parallel |
---|
472 | { |
---|
473 | #pragma omp for |
---|
474 | for(size_t i = 0; i < (xmax * ymax); i++){ |
---|
475 | size_t x = i / ymax; |
---|
476 | size_t y = i % ymax; |
---|
477 | |
---|
478 | #pragma omp critical |
---|
479 | std::ostringstream sc; |
---|
480 | sc << "cluster_" << x << "_" << y; |
---|
481 | clusters[x][y] = new TsarV4ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width> |
---|
482 | (sc.str().c_str(), |
---|
483 | nprocs, |
---|
484 | x, |
---|
485 | y, |
---|
486 | cluster(x,y), |
---|
487 | maptabd, |
---|
488 | maptabc, |
---|
489 | maptabx, |
---|
490 | x_width, |
---|
491 | y_width, |
---|
492 | MEMC_TGTID, |
---|
493 | XICU_TGTID, |
---|
494 | FBUF_TGTID, |
---|
495 | MTTY_TGTID, |
---|
496 | BROM_TGTID, |
---|
497 | BDEV_TGTID, |
---|
498 | CDMA_TGTID, |
---|
499 | memc_ways, |
---|
500 | memc_sets, |
---|
501 | l1_i_ways, |
---|
502 | l1_i_sets, |
---|
503 | l1_d_ways, |
---|
504 | l1_d_sets, |
---|
505 | xram_latency, |
---|
506 | (cluster(x,y) == cluster_io_index), |
---|
507 | xfb, |
---|
508 | yfb, |
---|
509 | disk_name, |
---|
510 | blk_size, |
---|
511 | loader, |
---|
512 | frozen_cycles, |
---|
513 | from_cycle, |
---|
514 | trace_ok and (cluster_io_index == cluster(x,y)) ); |
---|
515 | } |
---|
516 | } |
---|
517 | |
---|
518 | #else // NO OPENMP |
---|
519 | |
---|
520 | for (size_t x = 0; x < xmax; x++){ |
---|
521 | for (size_t y = 0; y < ymax; y++){ |
---|
522 | |
---|
523 | std::cout << "building cluster_" << x << "_" << y << std::endl; |
---|
524 | |
---|
525 | std::ostringstream sc; |
---|
526 | sc << "cluster_" << x << "_" << y; |
---|
527 | clusters[x][y] = new TsarV4ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width> |
---|
528 | (sc.str().c_str(), |
---|
529 | nprocs, |
---|
530 | x, |
---|
531 | y, |
---|
532 | cluster(x,y), |
---|
533 | maptabd, |
---|
534 | maptabc, |
---|
535 | maptabx, |
---|
536 | x_width, |
---|
537 | y_width, |
---|
538 | MEMC_TGTID, |
---|
539 | XICU_TGTID, |
---|
540 | FBUF_TGTID, |
---|
541 | MTTY_TGTID, |
---|
542 | BROM_TGTID, |
---|
543 | BDEV_TGTID, |
---|
544 | CDMA_TGTID, |
---|
545 | memc_ways, |
---|
546 | memc_sets, |
---|
547 | l1_i_ways, |
---|
548 | l1_i_sets, |
---|
549 | l1_d_ways, |
---|
550 | l1_d_sets, |
---|
551 | xram_latency, |
---|
552 | (cluster(x,y) == cluster_io_index), |
---|
553 | xfb, |
---|
554 | yfb, |
---|
555 | disk_name, |
---|
556 | blk_size, |
---|
557 | loader, |
---|
558 | frozen_cycles, |
---|
559 | from_cycle, |
---|
560 | trace_ok and (cluster_io_index == cluster(x,y)) ); |
---|
561 | |
---|
562 | std::cout << "cluster_" << x << "_" << y << " constructed" << std::endl; |
---|
563 | |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | #endif // USE_OPENMP |
---|
568 | |
---|
569 | /////////////////////////////////////////////////////////////// |
---|
570 | // Net-list |
---|
571 | /////////////////////////////////////////////////////////////// |
---|
572 | |
---|
573 | // Clock & RESET |
---|
574 | for (size_t x = 0; x < (xmax); x++){ |
---|
575 | for (size_t y = 0; y < ymax; y++){ |
---|
576 | clusters[x][y]->p_clk (signal_clk); |
---|
577 | clusters[x][y]->p_resetn (signal_resetn); |
---|
578 | } |
---|
579 | } |
---|
580 | |
---|
581 | // Inter Clusters horizontal connections |
---|
582 | if (xmax > 1){ |
---|
583 | for (size_t x = 0; x < (xmax-1); x++){ |
---|
584 | for (size_t y = 0; y < ymax; y++){ |
---|
585 | for (size_t k = 0; k < 2; k++){ |
---|
586 | clusters[x][y]->p_cmd_out[k][EAST] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
587 | clusters[x+1][y]->p_cmd_in[k][WEST] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
588 | clusters[x][y]->p_cmd_in[k][EAST] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
589 | clusters[x+1][y]->p_cmd_out[k][WEST] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
590 | clusters[x][y]->p_rsp_out[k][EAST] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
591 | clusters[x+1][y]->p_rsp_in[k][WEST] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
592 | clusters[x][y]->p_rsp_in[k][EAST] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
593 | clusters[x+1][y]->p_rsp_out[k][WEST] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
594 | } |
---|
595 | } |
---|
596 | } |
---|
597 | } |
---|
598 | std::cout << "Horizontal connections established" << std::endl; |
---|
599 | |
---|
600 | // Inter Clusters vertical connections |
---|
601 | if (ymax > 1) { |
---|
602 | for (size_t y = 0; y < (ymax-1); y++){ |
---|
603 | for (size_t x = 0; x < xmax; x++){ |
---|
604 | for (size_t k = 0; k < 2; k++){ |
---|
605 | clusters[x][y]->p_cmd_out[k][NORTH] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
606 | clusters[x][y+1]->p_cmd_in[k][SOUTH] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
607 | clusters[x][y]->p_cmd_in[k][NORTH] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
608 | clusters[x][y+1]->p_cmd_out[k][SOUTH] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
609 | clusters[x][y]->p_rsp_out[k][NORTH] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
610 | clusters[x][y+1]->p_rsp_in[k][SOUTH] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
611 | clusters[x][y]->p_rsp_in[k][NORTH] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
612 | clusters[x][y+1]->p_rsp_out[k][SOUTH] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
613 | } |
---|
614 | } |
---|
615 | } |
---|
616 | } |
---|
617 | std::cout << "Vertical connections established" << std::endl; |
---|
618 | |
---|
619 | // East & West boundary cluster connections |
---|
620 | for (size_t y = 0; y < ymax; y++){ |
---|
621 | for (size_t k = 0; k < 2; k++){ |
---|
622 | clusters[0][y]->p_cmd_in[k][WEST] (signal_dspin_false_cmd_in[0][y][k][WEST]); |
---|
623 | clusters[0][y]->p_cmd_out[k][WEST] (signal_dspin_false_cmd_out[0][y][k][WEST]); |
---|
624 | clusters[0][y]->p_rsp_in[k][WEST] (signal_dspin_false_rsp_in[0][y][k][WEST]); |
---|
625 | clusters[0][y]->p_rsp_out[k][WEST] (signal_dspin_false_rsp_out[0][y][k][WEST]); |
---|
626 | |
---|
627 | clusters[xmax-1][y]->p_cmd_in[k][EAST] (signal_dspin_false_cmd_in[xmax-1][y][k][EAST]); |
---|
628 | clusters[xmax-1][y]->p_cmd_out[k][EAST] (signal_dspin_false_cmd_out[xmax-1][y][k][EAST]); |
---|
629 | clusters[xmax-1][y]->p_rsp_in[k][EAST] (signal_dspin_false_rsp_in[xmax-1][y][k][EAST]); |
---|
630 | clusters[xmax-1][y]->p_rsp_out[k][EAST] (signal_dspin_false_rsp_out[xmax-1][y][k][EAST]); |
---|
631 | } |
---|
632 | } |
---|
633 | |
---|
634 | // North & South boundary clusters connections |
---|
635 | for (size_t x = 0; x < xmax; x++){ |
---|
636 | for (size_t k = 0; k < 2; k++){ |
---|
637 | clusters[x][0]->p_cmd_in[k][SOUTH] (signal_dspin_false_cmd_in[x][0][k][SOUTH]); |
---|
638 | clusters[x][0]->p_cmd_out[k][SOUTH] (signal_dspin_false_cmd_out[x][0][k][SOUTH]); |
---|
639 | clusters[x][0]->p_rsp_in[k][SOUTH] (signal_dspin_false_rsp_in[x][0][k][SOUTH]); |
---|
640 | clusters[x][0]->p_rsp_out[k][SOUTH] (signal_dspin_false_rsp_out[x][0][k][SOUTH]); |
---|
641 | |
---|
642 | clusters[x][ymax-1]->p_cmd_in[k][NORTH] (signal_dspin_false_cmd_in[x][ymax-1][k][NORTH]); |
---|
643 | clusters[x][ymax-1]->p_cmd_out[k][NORTH] (signal_dspin_false_cmd_out[x][ymax-1][k][NORTH]); |
---|
644 | clusters[x][ymax-1]->p_rsp_in[k][NORTH] (signal_dspin_false_rsp_in[x][ymax-1][k][NORTH]); |
---|
645 | clusters[x][ymax-1]->p_rsp_out[k][NORTH] (signal_dspin_false_rsp_out[x][ymax-1][k][NORTH]); |
---|
646 | } |
---|
647 | } |
---|
648 | |
---|
649 | |
---|
650 | //////////////////////////////////////////////////////// |
---|
651 | // Simulation |
---|
652 | /////////////////////////////////////////////////////// |
---|
653 | |
---|
654 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
655 | signal_resetn = false; |
---|
656 | |
---|
657 | // network boundaries signals |
---|
658 | for (size_t x = 0; x < xmax ; x++){ |
---|
659 | for (size_t y = 0; y < ymax ; y++){ |
---|
660 | for (size_t k = 0; k < 2; k++){ |
---|
661 | for (size_t a = 0; a < 4; a++){ |
---|
662 | signal_dspin_false_cmd_in[x][y][k][a].write = false; |
---|
663 | signal_dspin_false_cmd_in[x][y][k][a].read = true; |
---|
664 | signal_dspin_false_cmd_out[x][y][k][a].write = false; |
---|
665 | signal_dspin_false_cmd_out[x][y][k][a].read = true; |
---|
666 | |
---|
667 | signal_dspin_false_rsp_in[x][y][k][a].write = false; |
---|
668 | signal_dspin_false_rsp_in[x][y][k][a].read = true; |
---|
669 | signal_dspin_false_rsp_out[x][y][k][a].write = false; |
---|
670 | signal_dspin_false_rsp_out[x][y][k][a].read = true; |
---|
671 | } |
---|
672 | } |
---|
673 | } |
---|
674 | } |
---|
675 | |
---|
676 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
677 | signal_resetn = true; |
---|
678 | |
---|
679 | for (size_t n = 1; n < ncycles; n++){ |
---|
680 | if (trace_ok and (n > from_cycle) and (n % trace_period == 0)){ |
---|
681 | std::cout << "****************** cycle " << std::dec << n ; |
---|
682 | std::cout << " ************************************************" << std::endl; |
---|
683 | |
---|
684 | // components cluster 00 ///////////////////// |
---|
685 | // clusters[0][0]->proc[0]->print_trace(); |
---|
686 | // clusters[0][0]->memc->print_trace(); |
---|
687 | |
---|
688 | // signals cluster 00 //////////////////////// |
---|
689 | // clusters[0][0]->signal_vci_ini_d_proc[0].print_trace("proc_0_0_0_ini_d"); |
---|
690 | // clusters[0][0]->signal_vci_ini_c_proc[0].print_trace("proc_0_0_0_ini_c"); |
---|
691 | // clusters[0][0]->signal_vci_tgt_c_proc[0].print_trace("proc_0_0_0_tgt_c"); |
---|
692 | // clusters[0][0]->signal_vci_xram.print_trace("memc_0_0_xram"); |
---|
693 | |
---|
694 | // components cluster 01 ///////////////////// |
---|
695 | // clusters[0][1]->proc[0]->print_trace(); |
---|
696 | // clusters[0][1]->memc->print_trace(); |
---|
697 | |
---|
698 | // signals cluster 01 /////////////////////// |
---|
699 | // clusters[0][1]->signal_vci_ini_d_proc[0].print_trace("proc_0_1_0_ini_d"); |
---|
700 | // clusters[0][1]->signal_vci_ini_c_proc[0].print_trace("proc_0_1_0_ini_c"); |
---|
701 | // clusters[0][1]->signal_vci_tgt_c_proc[0].print_trace("proc_0_1_0_tgt_c"); |
---|
702 | // clusters[0][1]->signal_vci_xram.print_trace("memc_0_1_xram"); |
---|
703 | |
---|
704 | // components cluster 10 //////////////////// |
---|
705 | clusters[1][0]->proc[0]->print_trace(1); |
---|
706 | clusters[1][0]->memc->print_trace(); |
---|
707 | // clusters[1][0]->bdev->print_trace(); |
---|
708 | // clusters[1][0]->mdma->print_trace(); |
---|
709 | |
---|
710 | // signals cluster 10 /////////////////////// |
---|
711 | clusters[1][0]->signal_vci_ini_d_proc[0].print_trace("proc_1_0_0_ini_d"); |
---|
712 | // clusters[1][0]->signal_vci_ini_c_proc[0].print_trace("proc_1_0_0_ini_c"); |
---|
713 | // clusters[1][0]->signal_vci_tgt_c_proc[0].print_trace("proc_1_0_0_tgt_c"); |
---|
714 | clusters[1][0]->signal_vci_tgt_d_memc.print_trace("memc_1_0_tgt_d "); |
---|
715 | // clusters[1][0]->signal_vci_ini_c_memc.print_trace("memc_1_0_ini_c "); |
---|
716 | // clusters[1][0]->signal_vci_tgt_c_memc.print_trace("memc_1_0_tgt_c "); |
---|
717 | // clusters[1][0]->signal_vci_tgt_d_bdev.print_trace("bdev_1_0_tgt_d "); |
---|
718 | // clusters[1][0]->signal_vci_ini_d_bdev.print_trace("bdev_1_0_ini_d "); |
---|
719 | // clusters[1][0]->signal_vci_tgt_d_mdma.print_trace("mdma_1_0_tgt_d "); |
---|
720 | // clusters[1][0]->signal_vci_ini_d_mdma.print_trace("mdma_1_0_ini_d "); |
---|
721 | clusters[1][0]->signal_vci_tgt_d_mtty.print_trace("mtty_1_0_tgt_d "); |
---|
722 | clusters[1][0]->signal_vci_xram.print_trace("memc_1_0_xram"); |
---|
723 | |
---|
724 | // components cluster 11 ///////////////////// |
---|
725 | // clusters[1][1]->proc[0]->print_trace(); |
---|
726 | // clusters[1][1]->memc->print_trace(); |
---|
727 | |
---|
728 | // signals cluster 11 //////////////////////// |
---|
729 | // clusters[1][1]->signal_vci_ini_d_proc[0].print_trace("proc_1_1_0_ini_d"); |
---|
730 | // clusters[1][1]->signal_vci_ini_c_proc[0].print_trace("proc_1_1_0_ini_c"); |
---|
731 | // clusters[1][1]->signal_vci_tgt_c_proc[0].print_trace("proc_1_1_0_tgt_c"); |
---|
732 | // clusters[1][1]->signal_vci_xram.print_trace("memc_1_1_xram"); |
---|
733 | } |
---|
734 | |
---|
735 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
736 | } |
---|
737 | return EXIT_SUCCESS; |
---|
738 | } |
---|
739 | |
---|
740 | int sc_main (int argc, char *argv[]) |
---|
741 | { |
---|
742 | try { |
---|
743 | return _main(argc, argv); |
---|
744 | } catch (std::exception &e) { |
---|
745 | std::cout << e.what() << std::endl; |
---|
746 | } catch (...) { |
---|
747 | std::cout << "Unknown exception occured" << std::endl; |
---|
748 | throw; |
---|
749 | } |
---|
750 | return 1; |
---|
751 | } |
---|
752 | |
---|
753 | |
---|
754 | // Local Variables: |
---|
755 | // tab-width: 3 |
---|
756 | // c-basic-offset: 3 |
---|
757 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
758 | // indent-tabs-mode: nil |
---|
759 | // End: |
---|
760 | |
---|
761 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|
762 | |
---|
763 | |
---|
764 | |
---|
765 | |
---|