1 | ///////////////////////////////////////////////////////////////////////// |
---|
2 | // File: top.cpp |
---|
3 | // Author: Alain Greiner |
---|
4 | // Copyright: UPMC/LIP6 |
---|
5 | // Date : may 2013 |
---|
6 | // This program is released under the GNU public license |
---|
7 | ///////////////////////////////////////////////////////////////////////// |
---|
8 | // This file define a generic TSAR architecture. |
---|
9 | // The physical address space is 40 bits. |
---|
10 | // |
---|
11 | // The number of clusters cannot be larger than 256. |
---|
12 | // The number of processors per cluster cannot be larger than 8. |
---|
13 | // |
---|
14 | // - It uses four dspin_local_crossbar per cluster as local interconnect |
---|
15 | // - It uses two virtual_dspin routers per cluster as global interconnect |
---|
16 | // - It uses the vci_cc_vcache_wrapper |
---|
17 | // - It uses the vci_mem_cache |
---|
18 | // - It contains one vci_xicu per cluster. |
---|
19 | // - It contains one vci_multi_dma per cluster. |
---|
20 | // - It contains one vci_simple_ram per cluster to model the L3 cache. |
---|
21 | // |
---|
22 | // The communication between the MemCache and the Xram is 64 bits. |
---|
23 | // |
---|
24 | // All clusters are identical, but the cluster 0 (called io_cluster), |
---|
25 | // contains 6 extra components: |
---|
26 | // - the boot rom (BROM) |
---|
27 | // - the disk controller (BDEV) |
---|
28 | // - the multi-channel network controller (MNIC) |
---|
29 | // - the multi-channel chained buffer dma controller (CDMA) |
---|
30 | // - the multi-channel tty controller (MTTY) |
---|
31 | // - the frame buffer controller (FBUF) |
---|
32 | // |
---|
33 | // It is build with one single component implementing a cluster, |
---|
34 | // defined in files tsar_xbar_cluster.* (with * = cpp, h, sd) |
---|
35 | // |
---|
36 | // The IRQs are connected to XICUs as follow: |
---|
37 | // - The IRQ_IN[0] to IRQ_IN[7] ports are not used in all clusters. |
---|
38 | // - The DMA IRQs are connected to IRQ_IN[8] to IRQ_IN[15] in all clusters. |
---|
39 | // - The TTY IRQs are connected to IRQ_IN[16] to IRQ_IN[30] in I/O cluster. |
---|
40 | // - The BDEV IRQ is connected to IRQ_IN[31] in I/O cluster. |
---|
41 | // |
---|
42 | // Some hardware parameters are used when compiling the OS, and are used |
---|
43 | // by this top.cpp file. They must be defined in the hard_config.h file : |
---|
44 | // - CLUSTER_X : number of clusters in a row (power of 2) |
---|
45 | // - CLUSTER_Y : number of clusters in a column (power of 2) |
---|
46 | // - CLUSTER_SIZE : size of the segment allocated to a cluster |
---|
47 | // - NB_PROCS_MAX : number of processors per cluster (power of 2) |
---|
48 | // - NB_DMA_CHANNELS : number of DMA channels per cluster (< 9) |
---|
49 | // - NB_TTY_CHANNELS : number of TTY channels in I/O cluster (< 16) |
---|
50 | // - NB_NIC_CHANNELS : number of NIC channels in I/O cluster (< 9) |
---|
51 | // |
---|
52 | // Some other hardware parameters are not used when compiling the OS, |
---|
53 | // and can be directly defined in this top.cpp file: |
---|
54 | // - XRAM_LATENCY : external ram latency |
---|
55 | // - MEMC_WAYS : L2 cache number of ways |
---|
56 | // - MEMC_SETS : L2 cache number of sets |
---|
57 | // - L1_IWAYS |
---|
58 | // - L1_ISETS |
---|
59 | // - L1_DWAYS |
---|
60 | // - L1_DSETS |
---|
61 | // - FBUF_X_SIZE : width of frame buffer (pixels) |
---|
62 | // - FBUF_Y_SIZE : heigth of frame buffer (lines) |
---|
63 | // - BDEV_SECTOR_SIZE : block size for block drvice |
---|
64 | // - BDEV_IMAGE_NAME : file pathname for block device |
---|
65 | // - NIC_RX_NAME : file pathname for NIC received packets |
---|
66 | // - NIC_TX_NAME : file pathname for NIC transmited packets |
---|
67 | // - NIC_TIMEOUT : max number of cycles before closing a container |
---|
68 | ///////////////////////////////////////////////////////////////////////// |
---|
69 | // General policy for 40 bits physical address decoding: |
---|
70 | // All physical segments base addresses are multiple of 1 Mbytes |
---|
71 | // (=> the 24 LSB bits = 0, and the 16 MSB bits define the target) |
---|
72 | // The (x_width + y_width) MSB bits (left aligned) define |
---|
73 | // the cluster index, and the LADR bits define the local index: |
---|
74 | // | X_ID | Y_ID |---| LADR | OFFSET | |
---|
75 | // |x_width|y_width|---| 8 | 24 | |
---|
76 | ///////////////////////////////////////////////////////////////////////// |
---|
77 | // General policy for 14 bits SRCID decoding: |
---|
78 | // Each component is identified by (x_id, y_id, l_id) tuple. |
---|
79 | // | X_ID | Y_ID |---| L_ID | |
---|
80 | // |x_width|y_width|---| 6 | |
---|
81 | ///////////////////////////////////////////////////////////////////////// |
---|
82 | |
---|
83 | #include <systemc> |
---|
84 | #include <sys/time.h> |
---|
85 | #include <iostream> |
---|
86 | #include <sstream> |
---|
87 | #include <cstdlib> |
---|
88 | #include <cstdarg> |
---|
89 | #include <stdint.h> |
---|
90 | |
---|
91 | #include "gdbserver.h" |
---|
92 | #include "mapping_table.h" |
---|
93 | #include "tsar_xbar_cluster.h" |
---|
94 | #include "alloc_elems.h" |
---|
95 | |
---|
96 | /////////////////////////////////////////////////// |
---|
97 | // OS |
---|
98 | /////////////////////////////////////////////////// |
---|
99 | |
---|
100 | //#define USE_ALMOS 1 |
---|
101 | #define USE_GIET 1 |
---|
102 | |
---|
103 | #ifdef USE_ALMOS |
---|
104 | #ifdef USE_GIET |
---|
105 | #error "Can't use Two different OS" |
---|
106 | #endif |
---|
107 | #endif |
---|
108 | |
---|
109 | #ifndef USE_ALMOS |
---|
110 | #ifndef USE_GIET |
---|
111 | #error "You need to specify one OS" |
---|
112 | #endif |
---|
113 | #endif |
---|
114 | |
---|
115 | /////////////////////////////////////////////////// |
---|
116 | // Parallelisation |
---|
117 | /////////////////////////////////////////////////// |
---|
118 | #define USE_OPENMP 0 |
---|
119 | |
---|
120 | #if USE_OPENMP |
---|
121 | #include <omp.h> |
---|
122 | #endif |
---|
123 | |
---|
124 | // cluster index (computed from x,y coordinates) |
---|
125 | #define cluster(x,y) (y + YMAX * x) |
---|
126 | |
---|
127 | #define min(x, y) (x < y ? x : y) |
---|
128 | |
---|
129 | /////////////////////////////////////////////////////////// |
---|
130 | // DSPIN parameters |
---|
131 | /////////////////////////////////////////////////////////// |
---|
132 | |
---|
133 | #define dspin_cmd_width 39 |
---|
134 | #define dspin_rsp_width 32 |
---|
135 | |
---|
136 | /////////////////////////////////////////////////////////// |
---|
137 | // VCI parameters |
---|
138 | /////////////////////////////////////////////////////////// |
---|
139 | |
---|
140 | #define vci_cell_width_int 4 |
---|
141 | #define vci_cell_width_ext 8 |
---|
142 | |
---|
143 | #ifdef USE_ALMOS |
---|
144 | #define vci_address_width 32 |
---|
145 | #endif |
---|
146 | #ifdef USE_GIET |
---|
147 | #define vci_address_width 40 |
---|
148 | #endif |
---|
149 | #define vci_plen_width 8 |
---|
150 | #define vci_rerror_width 1 |
---|
151 | #define vci_clen_width 1 |
---|
152 | #define vci_rflag_width 1 |
---|
153 | #define vci_srcid_width 14 |
---|
154 | #define vci_pktid_width 4 |
---|
155 | #define vci_trdid_width 4 |
---|
156 | #define vci_wrplen_width 1 |
---|
157 | |
---|
158 | //////////////////////////////////////////////////////////// |
---|
159 | // Main Hardware Parameters values |
---|
160 | //////////////////////i///////////////////////////////////// |
---|
161 | |
---|
162 | #ifdef USE_ALMOS |
---|
163 | #include "almos/hard_config.h" |
---|
164 | #define PREFIX_OS "almos/" |
---|
165 | #endif |
---|
166 | #ifdef USE_GIET |
---|
167 | #include "giet_vm/hard_config.h" |
---|
168 | #define PREFIX_OS "giet_vm/" |
---|
169 | #endif |
---|
170 | |
---|
171 | //////////////////////////////////////////////////////////// |
---|
172 | // Secondary Hardware Parameters |
---|
173 | //////////////////////i///////////////////////////////////// |
---|
174 | |
---|
175 | #define XMAX CLUSTER_X |
---|
176 | #define YMAX CLUSTER_Y |
---|
177 | |
---|
178 | #define XRAM_LATENCY 0 |
---|
179 | |
---|
180 | #define MEMC_WAYS 16 |
---|
181 | #define MEMC_SETS 256 |
---|
182 | |
---|
183 | #define L1_IWAYS 4 |
---|
184 | #define L1_ISETS 64 |
---|
185 | |
---|
186 | #define L1_DWAYS 4 |
---|
187 | #define L1_DSETS 64 |
---|
188 | |
---|
189 | #ifdef USE_ALMOS |
---|
190 | #define FBUF_X_SIZE 512 |
---|
191 | #define FBUF_Y_SIZE 512 |
---|
192 | #endif |
---|
193 | #ifdef USE_GIET |
---|
194 | #define FBUF_X_SIZE 128 |
---|
195 | #define FBUF_Y_SIZE 128 |
---|
196 | #endif |
---|
197 | |
---|
198 | #ifdef USE_GIET |
---|
199 | #define BDEV_SECTOR_SIZE 512 |
---|
200 | #define BDEV_IMAGE_NAME PREFIX_OS"display/images.raw" |
---|
201 | #endif |
---|
202 | #ifdef USE_ALMOS |
---|
203 | #define BDEV_SECTOR_SIZE 4096 |
---|
204 | #define BDEV_IMAGE_NAME PREFIX_OS"hdd-img.bin" |
---|
205 | #endif |
---|
206 | |
---|
207 | #define NIC_RX_NAME PREFIX_OS"nic/rx_packets.txt" |
---|
208 | #define NIC_TX_NAME PREFIX_OS"nic/tx_packets.txt" |
---|
209 | #define NIC_TIMEOUT 10000 |
---|
210 | |
---|
211 | #define NORTH 0 |
---|
212 | #define SOUTH 1 |
---|
213 | #define EAST 2 |
---|
214 | #define WEST 3 |
---|
215 | |
---|
216 | //////////////////////////////////////////////////////////// |
---|
217 | // Software to be loaded in ROM & RAM |
---|
218 | //////////////////////i///////////////////////////////////// |
---|
219 | |
---|
220 | #ifdef USE_ALMOS |
---|
221 | #define soft_name PREFIX_OS"bootloader.bin",\ |
---|
222 | PREFIX_OS"kernel-soclib.bin@0xbfc10000:D",\ |
---|
223 | PREFIX_OS"arch-info.bib@0xBFC08000:D" |
---|
224 | #endif |
---|
225 | #ifdef USE_GIET |
---|
226 | #define soft_pathname PREFIX_OS"soft.elf" |
---|
227 | #endif |
---|
228 | |
---|
229 | //////////////////////////////////////////////////////////// |
---|
230 | // DEBUG Parameters default values |
---|
231 | //////////////////////i///////////////////////////////////// |
---|
232 | |
---|
233 | #define MAX_FROZEN_CYCLES 1000000 |
---|
234 | |
---|
235 | |
---|
236 | |
---|
237 | //////////////////////////////////////////////////////////////////// |
---|
238 | // TGTID definition in direct space |
---|
239 | // For all components: global TGTID = global SRCID = cluster_index |
---|
240 | //////////////////////////////////////////////////////////////////// |
---|
241 | |
---|
242 | #define MEMC_TGTID 0 |
---|
243 | #define XICU_TGTID 1 |
---|
244 | #define MDMA_TGTID 2 |
---|
245 | #define MTTY_TGTID 3 |
---|
246 | #define FBUF_TGTID 4 |
---|
247 | #define BDEV_TGTID 5 |
---|
248 | #define MNIC_TGTID 6 |
---|
249 | #define BROM_TGTID 7 |
---|
250 | #define CDMA_TGTID 8 |
---|
251 | #define SIMH_TGTID 9 |
---|
252 | |
---|
253 | |
---|
254 | |
---|
255 | ///////////////////////////////////////////////////////// |
---|
256 | // Physical segments definition |
---|
257 | ///////////////////////////////////////////////////////// |
---|
258 | // There is 3 segments replicated in all clusters |
---|
259 | // and 5 specific segments in the "IO" cluster |
---|
260 | // (containing address 0xBF000000) |
---|
261 | ///////////////////////////////////////////////////////// |
---|
262 | |
---|
263 | #ifdef USE_GIET |
---|
264 | // specific segments in "IO" cluster : absolute physical address |
---|
265 | #define BROM_BASE 0x00BFC00000 |
---|
266 | #define BROM_SIZE 0x0000100000 // 1 Mbytes |
---|
267 | |
---|
268 | #define FBUF_BASE 0x00B2000000 |
---|
269 | #define FBUF_SIZE (FBUF_X_SIZE * FBUF_Y_SIZE * 2) |
---|
270 | |
---|
271 | #define BDEV_BASE 0x00B3000000 |
---|
272 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
273 | |
---|
274 | #define MTTY_BASE 0x00B4000000 |
---|
275 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
276 | |
---|
277 | #define MNIC_BASE 0x00B5000000 |
---|
278 | #define MNIC_SIZE 0x0000080000 // 512 Kbytes (for 8 channels) |
---|
279 | |
---|
280 | #define CDMA_BASE 0x00B6000000 |
---|
281 | #define CDMA_SIZE 0x0000004000 * NB_CMA_CHANNELS |
---|
282 | |
---|
283 | // replicated segments : address is incremented by a cluster offset |
---|
284 | // offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
285 | |
---|
286 | #define MEMC_BASE 0x0000000000 |
---|
287 | #define MEMC_SIZE 0x0010000000 // 256 Mbytes per cluster |
---|
288 | |
---|
289 | #define XICU_BASE 0x00B0000000 |
---|
290 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
291 | |
---|
292 | #define MDMA_BASE 0x00B1000000 |
---|
293 | #define MDMA_SIZE 0x0000001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
294 | |
---|
295 | #define SIMH_BASE 0x00B7000000 |
---|
296 | #define SIMH_SIZE 0x0000001000 |
---|
297 | #endif |
---|
298 | |
---|
299 | #ifdef USE_ALMOS |
---|
300 | // 2^19 is the offset for the local id (8 bits for global ID : |
---|
301 | // 1 bit for Memcache or Peripheral, 4 for local peripheral id) |
---|
302 | // (Almos supports 32 bits physical addresses) |
---|
303 | |
---|
304 | #define CLUSTER_IO_INC (cluster_io_id * (0x80000000ULL / (XMAX * YMAX) * 2)) |
---|
305 | |
---|
306 | #define MEMC_MAX_SIZE (0x80000000 / (XMAX * YMAX)) |
---|
307 | |
---|
308 | #define BROM_BASE 0x00BFC00000 |
---|
309 | #define BROM_SIZE 0x0000100000 // 1 Mbytes |
---|
310 | |
---|
311 | #define MEMC_BASE 0x0000000000 |
---|
312 | #define MEMC_SIZE min(0x02000000, MEMC_MAX_SIZE) |
---|
313 | |
---|
314 | #define XICU_BASE MEMC_MAX_SIZE + (XICU_TGTID << 19) |
---|
315 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
316 | |
---|
317 | #define MDMA_BASE MEMC_MAX_SIZE + (MDMA_TGTID << 19) |
---|
318 | #define MDMA_SIZE (0x0000001000 * NB_DMA_CHANNELS) // 4 Kbytes per channel |
---|
319 | |
---|
320 | #define BDEV_BASE MEMC_MAX_SIZE + (BDEV_TGTID << 19) + (CLUSTER_IO_INC) |
---|
321 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
322 | |
---|
323 | #define MTTY_BASE MEMC_MAX_SIZE + (MTTY_TGTID << 19) + (CLUSTER_IO_INC) |
---|
324 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
325 | |
---|
326 | #define FBUF_BASE MEMC_MAX_SIZE + (FBUF_TGTID << 19) + (CLUSTER_IO_INC) |
---|
327 | #define FBUF_SIZE (FBUF_X_SIZE * FBUF_Y_SIZE * 2) // Should be 0x80000 |
---|
328 | |
---|
329 | #define MNIC_BASE MEMC_MAX_SIZE + (MNIC_TGTID << 19) + (CLUSTER_IO_INC) |
---|
330 | #define MNIC_SIZE 0x0000080000 |
---|
331 | |
---|
332 | #define CDMA_BASE MEMC_MAX_SIZE + (CDMA_TGTID << 19) + (CLUSTER_IO_INC) |
---|
333 | #define CDMA_SIZE (0x0000004000 * NB_CMA_CHANNELS) |
---|
334 | |
---|
335 | #define SIMH_BASE MEMC_MAX_SIZE + (SIMH_TGTID << 19) + (CLUSTER_IO_INC) |
---|
336 | #define SIMH_SIZE 0x0000001000 |
---|
337 | |
---|
338 | #endif |
---|
339 | |
---|
340 | |
---|
341 | bool stop_called = false; |
---|
342 | |
---|
343 | ///////////////////////////////// |
---|
344 | int _main(int argc, char *argv[]) |
---|
345 | { |
---|
346 | using namespace sc_core; |
---|
347 | using namespace soclib::caba; |
---|
348 | using namespace soclib::common; |
---|
349 | |
---|
350 | #ifdef USE_GIET |
---|
351 | char soft_name[256] = soft_pathname; // pathname to binary code |
---|
352 | #endif |
---|
353 | uint64_t ncycles = 0xFFFFFFFFFFFFFFFF; // simulated cycles |
---|
354 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
355 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
356 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
357 | ssize_t threads_nr = 1; // simulator's threads number |
---|
358 | bool debug_ok = false; // trace activated |
---|
359 | size_t debug_period = 1; // trace period |
---|
360 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
361 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
362 | uint32_t debug_from = 0; // trace start cycle |
---|
363 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
364 | size_t cluster_io_id; // index of cluster containing IOs |
---|
365 | struct timeval t1,t2; |
---|
366 | uint64_t ms1,ms2; |
---|
367 | |
---|
368 | ////////////// command line arguments ////////////////////// |
---|
369 | if (argc > 1) |
---|
370 | { |
---|
371 | for (int n = 1; n < argc; n = n + 2) |
---|
372 | { |
---|
373 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) |
---|
374 | { |
---|
375 | ncycles = atoi(argv[n + 1]); |
---|
376 | } |
---|
377 | else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) |
---|
378 | { |
---|
379 | #ifdef USE_ALMOS |
---|
380 | assert( 0 && "Can't define almos soft name" ); |
---|
381 | #endif |
---|
382 | #ifdef USE_GIET |
---|
383 | strcpy(soft_name, argv[n + 1]); |
---|
384 | #endif |
---|
385 | } |
---|
386 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) |
---|
387 | { |
---|
388 | strcpy(disk_name, argv[n + 1]); |
---|
389 | } |
---|
390 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) |
---|
391 | { |
---|
392 | debug_ok = true; |
---|
393 | debug_from = atoi(argv[n + 1]); |
---|
394 | } |
---|
395 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) |
---|
396 | { |
---|
397 | debug_memc_id = atoi(argv[n + 1]); |
---|
398 | assert((debug_memc_id < (XMAX * YMAX)) && |
---|
399 | "debug_memc_id larger than XMAX * YMAX" ); |
---|
400 | } |
---|
401 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) |
---|
402 | { |
---|
403 | debug_proc_id = atoi(argv[n + 1]); |
---|
404 | assert((debug_proc_id < (XMAX * YMAX * NB_PROCS_MAX)) && |
---|
405 | "debug_proc_id larger than XMAX * YMAX * NB_PROCS"); |
---|
406 | } |
---|
407 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) |
---|
408 | { |
---|
409 | threads_nr = atoi(argv[n + 1]); |
---|
410 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
411 | } |
---|
412 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) |
---|
413 | { |
---|
414 | frozen_cycles = atoi(argv[n + 1]); |
---|
415 | } |
---|
416 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) |
---|
417 | { |
---|
418 | debug_period = atoi(argv[n + 1]); |
---|
419 | } |
---|
420 | else |
---|
421 | { |
---|
422 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
423 | std::cout << " The order is not important." << std::endl; |
---|
424 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
425 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
426 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
427 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
428 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
429 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
430 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
431 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
432 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
433 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
434 | exit(0); |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
439 | // checking hardware parameters |
---|
440 | assert( ( (XMAX == 1) or (XMAX == 2) or (XMAX == 4) or |
---|
441 | (XMAX == 8) or (XMAX == 16) ) and |
---|
442 | "The XMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
443 | |
---|
444 | assert( ( (YMAX == 1) or (YMAX == 2) or (YMAX == 4) or |
---|
445 | (YMAX == 8) or (YMAX == 16) ) and |
---|
446 | "The YMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
447 | |
---|
448 | assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or |
---|
449 | (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and |
---|
450 | "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" ); |
---|
451 | |
---|
452 | assert( (NB_DMA_CHANNELS < 9) and |
---|
453 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
454 | |
---|
455 | assert( (NB_TTY_CHANNELS < 15) and |
---|
456 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
457 | |
---|
458 | assert( (NB_NIC_CHANNELS < 9) and |
---|
459 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
460 | |
---|
461 | #ifdef USE_GIET |
---|
462 | assert( (vci_address_width == 40) and |
---|
463 | "VCI address width with the GIET must be 40 bits" ); |
---|
464 | #endif |
---|
465 | |
---|
466 | #ifdef USE_ALMOS |
---|
467 | assert( (vci_address_width == 32) and |
---|
468 | "VCI address width with ALMOS must be 32 bits" ); |
---|
469 | #endif |
---|
470 | |
---|
471 | |
---|
472 | std::cout << std::endl; |
---|
473 | std::cout << " - XMAX = " << XMAX << std::endl; |
---|
474 | std::cout << " - YMAX = " << YMAX << std::endl; |
---|
475 | std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl; |
---|
476 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
477 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
478 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
479 | std::cout << " - MEMC_WAYS = " << MEMC_WAYS << std::endl; |
---|
480 | std::cout << " - MEMC_SETS = " << MEMC_SETS << std::endl; |
---|
481 | std::cout << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl; |
---|
482 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
483 | std::cout << "[PROCS] " << NB_PROCS_MAX * XMAX * YMAX << std::endl; |
---|
484 | |
---|
485 | std::cout << std::endl; |
---|
486 | // Internal and External VCI parameters definition |
---|
487 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
488 | vci_plen_width, |
---|
489 | vci_address_width, |
---|
490 | vci_rerror_width, |
---|
491 | vci_clen_width, |
---|
492 | vci_rflag_width, |
---|
493 | vci_srcid_width, |
---|
494 | vci_pktid_width, |
---|
495 | vci_trdid_width, |
---|
496 | vci_wrplen_width> vci_param_int; |
---|
497 | |
---|
498 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
499 | vci_plen_width, |
---|
500 | vci_address_width, |
---|
501 | vci_rerror_width, |
---|
502 | vci_clen_width, |
---|
503 | vci_rflag_width, |
---|
504 | vci_srcid_width, |
---|
505 | vci_pktid_width, |
---|
506 | vci_trdid_width, |
---|
507 | vci_wrplen_width> vci_param_ext; |
---|
508 | |
---|
509 | #if USE_OPENMP |
---|
510 | omp_set_dynamic(false); |
---|
511 | omp_set_num_threads(threads_nr); |
---|
512 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
513 | #endif |
---|
514 | |
---|
515 | // Define parameters depending on mesh size |
---|
516 | size_t x_width; |
---|
517 | size_t y_width; |
---|
518 | |
---|
519 | if (XMAX == 1) x_width = 0; |
---|
520 | else if (XMAX == 2) x_width = 1; |
---|
521 | else if (XMAX <= 4) x_width = 2; |
---|
522 | else if (XMAX <= 8) x_width = 3; |
---|
523 | else x_width = 4; |
---|
524 | |
---|
525 | if (YMAX == 1) y_width = 0; |
---|
526 | else if (YMAX == 2) y_width = 1; |
---|
527 | else if (YMAX <= 4) y_width = 2; |
---|
528 | else if (YMAX <= 8) y_width = 3; |
---|
529 | else y_width = 4; |
---|
530 | |
---|
531 | |
---|
532 | #ifdef USE_ALMOS |
---|
533 | cluster_io_id = 0xbfc00000 >> (vci_address_width - x_width - y_width); // index of cluster containing IOs |
---|
534 | #else |
---|
535 | cluster_io_id = 0; |
---|
536 | #endif |
---|
537 | |
---|
538 | ///////////////////// |
---|
539 | // Mapping Tables |
---|
540 | ///////////////////// |
---|
541 | |
---|
542 | // internal network |
---|
543 | MappingTable maptabd(vci_address_width, |
---|
544 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
545 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
546 | 0x00FF800000); |
---|
547 | |
---|
548 | for (size_t x = 0; x < XMAX; x++) |
---|
549 | { |
---|
550 | for (size_t y = 0; y < YMAX; y++) |
---|
551 | { |
---|
552 | sc_uint<vci_address_width> offset; |
---|
553 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
554 | << (vci_address_width-x_width-y_width); |
---|
555 | |
---|
556 | std::ostringstream si; |
---|
557 | si << "seg_xicu_" << x << "_" << y; |
---|
558 | maptabd.add(Segment(si.str(), XICU_BASE + offset, XICU_SIZE, |
---|
559 | IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
560 | |
---|
561 | std::ostringstream sd; |
---|
562 | sd << "seg_mdma_" << x << "_" << y; |
---|
563 | maptabd.add(Segment(sd.str(), MDMA_BASE + offset, MDMA_SIZE, |
---|
564 | IntTab(cluster(x,y),MDMA_TGTID), false)); |
---|
565 | |
---|
566 | std::ostringstream sh; |
---|
567 | sh << "seg_memc_" << x << "_" << y; |
---|
568 | maptabd.add(Segment(sh.str(), MEMC_BASE + offset, MEMC_SIZE, |
---|
569 | IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
570 | |
---|
571 | if ( cluster(x,y) == cluster_io_id ) |
---|
572 | { |
---|
573 | maptabd.add(Segment("seg_mtty", MTTY_BASE, MTTY_SIZE, |
---|
574 | IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
575 | maptabd.add(Segment("seg_fbuf", FBUF_BASE, FBUF_SIZE, |
---|
576 | IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
577 | maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, |
---|
578 | IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
579 | maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, |
---|
580 | IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
581 | maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, |
---|
582 | IntTab(cluster(x,y),MNIC_TGTID), false)); |
---|
583 | maptabd.add(Segment("seg_cdma", CDMA_BASE, CDMA_SIZE, |
---|
584 | IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
585 | maptabd.add(Segment("seg_simh", SIMH_BASE, SIMH_SIZE, |
---|
586 | IntTab(cluster(x,y),SIMH_TGTID), false)); |
---|
587 | } |
---|
588 | } |
---|
589 | } |
---|
590 | std::cout << maptabd << std::endl; |
---|
591 | |
---|
592 | // external network |
---|
593 | MappingTable maptabx(vci_address_width, |
---|
594 | IntTab(x_width+y_width), |
---|
595 | IntTab(x_width+y_width), |
---|
596 | 0xFFFF000000ULL); |
---|
597 | |
---|
598 | for (size_t x = 0; x < XMAX; x++) |
---|
599 | { |
---|
600 | for (size_t y = 0; y < YMAX ; y++) |
---|
601 | { |
---|
602 | |
---|
603 | sc_uint<vci_address_width> offset; |
---|
604 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
605 | << (vci_address_width-x_width-y_width); |
---|
606 | |
---|
607 | std::ostringstream sh; |
---|
608 | sh << "x_seg_memc_" << x << "_" << y; |
---|
609 | |
---|
610 | maptabx.add(Segment(sh.str(), MEMC_BASE + offset, |
---|
611 | MEMC_SIZE, IntTab(cluster(x,y)), false)); |
---|
612 | } |
---|
613 | } |
---|
614 | std::cout << maptabx << std::endl; |
---|
615 | |
---|
616 | //////////////////// |
---|
617 | // Signals |
---|
618 | /////////////////// |
---|
619 | |
---|
620 | sc_clock signal_clk("clk"); |
---|
621 | sc_signal<bool> signal_resetn("resetn"); |
---|
622 | |
---|
623 | // Horizontal inter-clusters DSPIN signals |
---|
624 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_inc = |
---|
625 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", XMAX-1, YMAX, 3); |
---|
626 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_dec = |
---|
627 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", XMAX-1, YMAX, 3); |
---|
628 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_inc = |
---|
629 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", XMAX-1, YMAX, 2); |
---|
630 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_dec = |
---|
631 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", XMAX-1, YMAX, 2); |
---|
632 | |
---|
633 | // Vertical inter-clusters DSPIN signals |
---|
634 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_inc = |
---|
635 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", XMAX, YMAX-1, 3); |
---|
636 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_dec = |
---|
637 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", XMAX, YMAX-1, 3); |
---|
638 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_inc = |
---|
639 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", XMAX, YMAX-1, 2); |
---|
640 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_dec = |
---|
641 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", XMAX, YMAX-1, 2); |
---|
642 | |
---|
643 | // Mesh boundaries DSPIN signals |
---|
644 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_in = |
---|
645 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in" , XMAX, YMAX, 4, 3); |
---|
646 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_out = |
---|
647 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", XMAX, YMAX, 4, 3); |
---|
648 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_in = |
---|
649 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in" , XMAX, YMAX, 4, 2); |
---|
650 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_out = |
---|
651 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", XMAX, YMAX, 4, 2); |
---|
652 | |
---|
653 | |
---|
654 | //////////////////////////// |
---|
655 | // Loader |
---|
656 | //////////////////////////// |
---|
657 | |
---|
658 | soclib::common::Loader loader(soft_name); |
---|
659 | |
---|
660 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
661 | proc_iss::set_loader(loader); |
---|
662 | |
---|
663 | //////////////////////////// |
---|
664 | // Clusters construction |
---|
665 | //////////////////////////// |
---|
666 | |
---|
667 | TsarXbarCluster<dspin_cmd_width, |
---|
668 | dspin_rsp_width, |
---|
669 | vci_param_int, |
---|
670 | vci_param_ext>* clusters[XMAX][YMAX]; |
---|
671 | |
---|
672 | #if USE_OPENMP |
---|
673 | #pragma omp parallel |
---|
674 | { |
---|
675 | #pragma omp for |
---|
676 | #endif |
---|
677 | for (size_t i = 0; i < (XMAX * YMAX); i++) |
---|
678 | { |
---|
679 | size_t x = i / YMAX; |
---|
680 | size_t y = i % YMAX; |
---|
681 | |
---|
682 | #if USE_OPENMP |
---|
683 | #pragma omp critical |
---|
684 | { |
---|
685 | #endif |
---|
686 | std::cout << std::endl; |
---|
687 | std::cout << "Cluster_" << x << "_" << y << std::endl; |
---|
688 | std::cout << std::endl; |
---|
689 | |
---|
690 | std::ostringstream sc; |
---|
691 | sc << "cluster_" << x << "_" << y; |
---|
692 | clusters[x][y] = new TsarXbarCluster<dspin_cmd_width, |
---|
693 | dspin_rsp_width, |
---|
694 | vci_param_int, |
---|
695 | vci_param_ext> |
---|
696 | ( |
---|
697 | sc.str().c_str(), |
---|
698 | NB_PROCS_MAX, |
---|
699 | NB_TTY_CHANNELS, |
---|
700 | NB_DMA_CHANNELS, |
---|
701 | x, |
---|
702 | y, |
---|
703 | cluster(x,y), |
---|
704 | maptabd, |
---|
705 | maptabx, |
---|
706 | x_width, |
---|
707 | y_width, |
---|
708 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
709 | MEMC_TGTID, |
---|
710 | XICU_TGTID, |
---|
711 | MDMA_TGTID, |
---|
712 | FBUF_TGTID, |
---|
713 | MTTY_TGTID, |
---|
714 | BROM_TGTID, |
---|
715 | MNIC_TGTID, |
---|
716 | CDMA_TGTID, |
---|
717 | BDEV_TGTID, |
---|
718 | SIMH_TGTID, |
---|
719 | MEMC_WAYS, |
---|
720 | MEMC_SETS, |
---|
721 | L1_IWAYS, |
---|
722 | L1_ISETS, |
---|
723 | L1_DWAYS, |
---|
724 | L1_DSETS, |
---|
725 | XRAM_LATENCY, |
---|
726 | (cluster(x,y) == cluster_io_id), |
---|
727 | FBUF_X_SIZE, |
---|
728 | FBUF_Y_SIZE, |
---|
729 | disk_name, |
---|
730 | BDEV_SECTOR_SIZE, |
---|
731 | NB_NIC_CHANNELS, |
---|
732 | nic_rx_name, |
---|
733 | nic_tx_name, |
---|
734 | NIC_TIMEOUT, |
---|
735 | NB_CMA_CHANNELS, |
---|
736 | loader, |
---|
737 | frozen_cycles, |
---|
738 | debug_from , |
---|
739 | debug_ok and (cluster(x,y) == debug_memc_id), |
---|
740 | debug_ok and (cluster(x,y) == debug_proc_id) |
---|
741 | ); |
---|
742 | |
---|
743 | #if USE_OPENMP |
---|
744 | } // end critical |
---|
745 | #endif |
---|
746 | } // end for |
---|
747 | #if USE_OPENMP |
---|
748 | } |
---|
749 | #endif |
---|
750 | |
---|
751 | /////////////////////////////////////////////////////////////// |
---|
752 | // Net-list |
---|
753 | /////////////////////////////////////////////////////////////// |
---|
754 | |
---|
755 | // Clock & RESET |
---|
756 | for (size_t x = 0; x < (XMAX); x++){ |
---|
757 | for (size_t y = 0; y < YMAX; y++){ |
---|
758 | clusters[x][y]->p_clk (signal_clk); |
---|
759 | clusters[x][y]->p_resetn (signal_resetn); |
---|
760 | } |
---|
761 | } |
---|
762 | |
---|
763 | // Inter Clusters horizontal connections |
---|
764 | if (XMAX > 1){ |
---|
765 | for (size_t x = 0; x < (XMAX-1); x++){ |
---|
766 | for (size_t y = 0; y < YMAX; y++){ |
---|
767 | for (size_t k = 0; k < 3; k++){ |
---|
768 | clusters[x][y]->p_cmd_out[EAST][k] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
769 | clusters[x+1][y]->p_cmd_in[WEST][k] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
770 | clusters[x][y]->p_cmd_in[EAST][k] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
771 | clusters[x+1][y]->p_cmd_out[WEST][k] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
772 | } |
---|
773 | |
---|
774 | for (size_t k = 0; k < 2; k++){ |
---|
775 | clusters[x][y]->p_rsp_out[EAST][k] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
776 | clusters[x+1][y]->p_rsp_in[WEST][k] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
777 | clusters[x][y]->p_rsp_in[EAST][k] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
778 | clusters[x+1][y]->p_rsp_out[WEST][k] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
779 | } |
---|
780 | } |
---|
781 | } |
---|
782 | } |
---|
783 | std::cout << std::endl << "Horizontal connections established" << std::endl; |
---|
784 | |
---|
785 | // Inter Clusters vertical connections |
---|
786 | if (YMAX > 1) { |
---|
787 | for (size_t y = 0; y < (YMAX-1); y++){ |
---|
788 | for (size_t x = 0; x < XMAX; x++){ |
---|
789 | for (size_t k = 0; k < 3; k++){ |
---|
790 | clusters[x][y]->p_cmd_out[NORTH][k] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
791 | clusters[x][y+1]->p_cmd_in[SOUTH][k] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
792 | clusters[x][y]->p_cmd_in[NORTH][k] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
793 | clusters[x][y+1]->p_cmd_out[SOUTH][k] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
794 | } |
---|
795 | |
---|
796 | for (size_t k = 0; k < 2; k++){ |
---|
797 | clusters[x][y]->p_rsp_out[NORTH][k] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
798 | clusters[x][y+1]->p_rsp_in[SOUTH][k] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
799 | clusters[x][y]->p_rsp_in[NORTH][k] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
800 | clusters[x][y+1]->p_rsp_out[SOUTH][k] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
801 | } |
---|
802 | } |
---|
803 | } |
---|
804 | } |
---|
805 | std::cout << "Vertical connections established" << std::endl; |
---|
806 | |
---|
807 | // East & West boundary cluster connections |
---|
808 | for (size_t y = 0; y < YMAX; y++) |
---|
809 | { |
---|
810 | for (size_t k = 0; k < 3; k++) |
---|
811 | { |
---|
812 | clusters[0][y]->p_cmd_in[WEST][k] (signal_dspin_false_cmd_in[0][y][WEST][k]); |
---|
813 | clusters[0][y]->p_cmd_out[WEST][k] (signal_dspin_false_cmd_out[0][y][WEST][k]); |
---|
814 | clusters[XMAX-1][y]->p_cmd_in[EAST][k] (signal_dspin_false_cmd_in[XMAX-1][y][EAST][k]); |
---|
815 | clusters[XMAX-1][y]->p_cmd_out[EAST][k] (signal_dspin_false_cmd_out[XMAX-1][y][EAST][k]); |
---|
816 | } |
---|
817 | |
---|
818 | for (size_t k = 0; k < 2; k++) |
---|
819 | { |
---|
820 | clusters[0][y]->p_rsp_in[WEST][k] (signal_dspin_false_rsp_in[0][y][WEST][k]); |
---|
821 | clusters[0][y]->p_rsp_out[WEST][k] (signal_dspin_false_rsp_out[0][y][WEST][k]); |
---|
822 | clusters[XMAX-1][y]->p_rsp_in[EAST][k] (signal_dspin_false_rsp_in[XMAX-1][y][EAST][k]); |
---|
823 | clusters[XMAX-1][y]->p_rsp_out[EAST][k] (signal_dspin_false_rsp_out[XMAX-1][y][EAST][k]); |
---|
824 | } |
---|
825 | } |
---|
826 | |
---|
827 | // North & South boundary clusters connections |
---|
828 | for (size_t x = 0; x < XMAX; x++) |
---|
829 | { |
---|
830 | for (size_t k = 0; k < 3; k++) |
---|
831 | { |
---|
832 | clusters[x][0]->p_cmd_in[SOUTH][k] (signal_dspin_false_cmd_in[x][0][SOUTH][k]); |
---|
833 | clusters[x][0]->p_cmd_out[SOUTH][k] (signal_dspin_false_cmd_out[x][0][SOUTH][k]); |
---|
834 | clusters[x][YMAX-1]->p_cmd_in[NORTH][k] (signal_dspin_false_cmd_in[x][YMAX-1][NORTH][k]); |
---|
835 | clusters[x][YMAX-1]->p_cmd_out[NORTH][k] (signal_dspin_false_cmd_out[x][YMAX-1][NORTH][k]); |
---|
836 | } |
---|
837 | |
---|
838 | for (size_t k = 0; k < 2; k++) |
---|
839 | { |
---|
840 | clusters[x][0]->p_rsp_in[SOUTH][k] (signal_dspin_false_rsp_in[x][0][SOUTH][k]); |
---|
841 | clusters[x][0]->p_rsp_out[SOUTH][k] (signal_dspin_false_rsp_out[x][0][SOUTH][k]); |
---|
842 | clusters[x][YMAX-1]->p_rsp_in[NORTH][k] (signal_dspin_false_rsp_in[x][YMAX-1][NORTH][k]); |
---|
843 | clusters[x][YMAX-1]->p_rsp_out[NORTH][k] (signal_dspin_false_rsp_out[x][YMAX-1][NORTH][k]); |
---|
844 | } |
---|
845 | } |
---|
846 | std::cout << "North, South, West, East connections established" << std::endl; |
---|
847 | std::cout << std::endl; |
---|
848 | |
---|
849 | |
---|
850 | //////////////////////////////////////////////////////// |
---|
851 | // Simulation |
---|
852 | /////////////////////////////////////////////////////// |
---|
853 | |
---|
854 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
855 | signal_resetn = false; |
---|
856 | |
---|
857 | // network boundaries signals |
---|
858 | for (size_t x = 0; x < XMAX ; x++){ |
---|
859 | for (size_t y = 0; y < YMAX ; y++){ |
---|
860 | for (size_t a = 0; a < 4; a++){ |
---|
861 | for (size_t k = 0; k < 3; k++){ |
---|
862 | signal_dspin_false_cmd_in [x][y][a][k].write = false; |
---|
863 | signal_dspin_false_cmd_in [x][y][a][k].read = true; |
---|
864 | signal_dspin_false_cmd_out[x][y][a][k].write = false; |
---|
865 | signal_dspin_false_cmd_out[x][y][a][k].read = true; |
---|
866 | } |
---|
867 | |
---|
868 | for (size_t k = 0; k < 2; k++){ |
---|
869 | signal_dspin_false_rsp_in [x][y][a][k].write = false; |
---|
870 | signal_dspin_false_rsp_in [x][y][a][k].read = true; |
---|
871 | signal_dspin_false_rsp_out[x][y][a][k].write = false; |
---|
872 | signal_dspin_false_rsp_out[x][y][a][k].read = true; |
---|
873 | } |
---|
874 | } |
---|
875 | } |
---|
876 | } |
---|
877 | |
---|
878 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
879 | signal_resetn = true; |
---|
880 | |
---|
881 | if (gettimeofday(&t1, NULL) != 0) |
---|
882 | { |
---|
883 | perror("gettimeofday"); |
---|
884 | return EXIT_FAILURE; |
---|
885 | } |
---|
886 | |
---|
887 | for (uint64_t n = 1; n < ncycles && !stop_called; n++) |
---|
888 | { |
---|
889 | // Monitor a specific address for L1 & L2 caches |
---|
890 | //clusters[0][0]->proc[0]->cache_monitor(0x800002c000ULL); |
---|
891 | //clusters[1][0]->memc->copies_monitor(0x800002C000ULL); |
---|
892 | |
---|
893 | if( (n % 5000000) == 0) |
---|
894 | { |
---|
895 | |
---|
896 | if (gettimeofday(&t2, NULL) != 0) |
---|
897 | { |
---|
898 | perror("gettimeofday"); |
---|
899 | return EXIT_FAILURE; |
---|
900 | } |
---|
901 | |
---|
902 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
903 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
904 | std::cerr << "platform clock frequency " << (double) 5000000 / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
905 | |
---|
906 | if (gettimeofday(&t1, NULL) != 0) |
---|
907 | { |
---|
908 | perror("gettimeofday"); |
---|
909 | return EXIT_FAILURE; |
---|
910 | } |
---|
911 | } |
---|
912 | |
---|
913 | if (debug_ok and (n > debug_from) and (n % debug_period == 0)) |
---|
914 | { |
---|
915 | std::cout << "****************** cycle " << std::dec << n ; |
---|
916 | std::cout << " ************************************************" << std::endl; |
---|
917 | |
---|
918 | // trace proc[debug_proc_id] |
---|
919 | size_t l = debug_proc_id % NB_PROCS_MAX ; |
---|
920 | size_t y = (debug_proc_id / NB_PROCS_MAX) % YMAX ; |
---|
921 | size_t x = debug_proc_id / (YMAX * NB_PROCS_MAX) ; |
---|
922 | |
---|
923 | std::ostringstream proc_signame; |
---|
924 | proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ; |
---|
925 | std::ostringstream p2m_signame; |
---|
926 | p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " P2M" ; |
---|
927 | std::ostringstream m2p_signame; |
---|
928 | m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " M2P" ; |
---|
929 | std::ostringstream p_cmd_signame; |
---|
930 | p_cmd_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " CMD" ; |
---|
931 | std::ostringstream p_rsp_signame; |
---|
932 | p_rsp_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " RSP" ; |
---|
933 | |
---|
934 | clusters[x][y]->proc[l]->print_trace(); |
---|
935 | clusters[x][y]->wi_proc[l]->print_trace(); |
---|
936 | clusters[x][y]->signal_vci_ini_proc[l].print_trace(proc_signame.str()); |
---|
937 | clusters[x][y]->signal_dspin_p2m_proc[l].print_trace(p2m_signame.str()); |
---|
938 | clusters[x][y]->signal_dspin_m2p_proc[l].print_trace(m2p_signame.str()); |
---|
939 | clusters[x][y]->signal_dspin_cmd_proc_i[l].print_trace(p_cmd_signame.str()); |
---|
940 | clusters[x][y]->signal_dspin_rsp_proc_i[l].print_trace(p_rsp_signame.str()); |
---|
941 | |
---|
942 | clusters[x][y]->xbar_rsp_d->print_trace(); |
---|
943 | clusters[x][y]->xbar_cmd_d->print_trace(); |
---|
944 | clusters[x][y]->signal_dspin_cmd_l2g_d.print_trace("[SIG]L2G CMD"); |
---|
945 | clusters[x][y]->signal_dspin_cmd_g2l_d.print_trace("[SIG]G2L CMD"); |
---|
946 | clusters[x][y]->signal_dspin_rsp_l2g_d.print_trace("[SIG]L2G RSP"); |
---|
947 | clusters[x][y]->signal_dspin_rsp_g2l_d.print_trace("[SIG]G2L RSP"); |
---|
948 | |
---|
949 | // trace memc[debug_memc_id] |
---|
950 | x = debug_memc_id / YMAX; |
---|
951 | y = debug_memc_id % YMAX; |
---|
952 | |
---|
953 | std::ostringstream smemc; |
---|
954 | smemc << "[SIG]MEMC_" << x << "_" << y; |
---|
955 | std::ostringstream sxram; |
---|
956 | sxram << "[SIG]XRAM_" << x << "_" << y; |
---|
957 | std::ostringstream sm2p; |
---|
958 | sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P" ; |
---|
959 | std::ostringstream sp2m; |
---|
960 | sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M" ; |
---|
961 | std::ostringstream m_cmd_signame; |
---|
962 | m_cmd_signame << "[SIG]MEMC_" << x << "_" << y << " CMD" ; |
---|
963 | std::ostringstream m_rsp_signame; |
---|
964 | m_rsp_signame << "[SIG]MEMC_" << x << "_" << y << " RSP" ; |
---|
965 | |
---|
966 | clusters[x][y]->memc->print_trace(); |
---|
967 | clusters[x][y]->wt_memc->print_trace(); |
---|
968 | clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str()); |
---|
969 | clusters[x][y]->signal_vci_xram.print_trace(sxram.str()); |
---|
970 | clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str()); |
---|
971 | clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str()); |
---|
972 | clusters[x][y]->signal_dspin_cmd_memc_t.print_trace(m_cmd_signame.str()); |
---|
973 | clusters[x][y]->signal_dspin_rsp_memc_t.print_trace(m_rsp_signame.str()); |
---|
974 | |
---|
975 | // trace replicated peripherals |
---|
976 | // clusters[1][1]->mdma->print_trace(); |
---|
977 | // clusters[1][1]->signal_vci_tgt_mdma.print_trace("[SIG]MDMA_TGT_1_1"); |
---|
978 | // clusters[1][1]->signal_vci_ini_mdma.print_trace("[SIG]MDMA_INI_1_1"); |
---|
979 | |
---|
980 | |
---|
981 | // trace external peripherals |
---|
982 | size_t io_x = cluster_io_id / YMAX; |
---|
983 | size_t io_y = cluster_io_id % YMAX; |
---|
984 | |
---|
985 | clusters[io_x][io_y]->brom->print_trace(); |
---|
986 | clusters[io_x][io_y]->wt_brom->print_trace(); |
---|
987 | clusters[io_x][io_y]->signal_vci_tgt_brom.print_trace("[SIG]BROM"); |
---|
988 | clusters[io_x][io_y]->signal_dspin_cmd_brom_t.print_trace("[SIG]BROM CMD"); |
---|
989 | clusters[io_x][io_y]->signal_dspin_rsp_brom_t.print_trace("[SIG]BROM RSP"); |
---|
990 | |
---|
991 | // clusters[io_x][io_y]->bdev->print_trace(); |
---|
992 | // clusters[io_x][io_y]->signal_vci_tgt_bdev.print_trace("[SIG]BDEV_TGT"); |
---|
993 | // clusters[io_x][io_y]->signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI"); |
---|
994 | } |
---|
995 | |
---|
996 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
997 | } |
---|
998 | |
---|
999 | |
---|
1000 | // Free memory |
---|
1001 | for (size_t i = 0; i < (XMAX * YMAX); i++) |
---|
1002 | { |
---|
1003 | size_t x = i / YMAX; |
---|
1004 | size_t y = i % YMAX; |
---|
1005 | delete clusters[x][y]; |
---|
1006 | } |
---|
1007 | |
---|
1008 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, XMAX - 1, YMAX, 3); |
---|
1009 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, XMAX - 1, YMAX, 3); |
---|
1010 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, XMAX - 1, YMAX, 2); |
---|
1011 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, XMAX - 1, YMAX, 2); |
---|
1012 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, XMAX, YMAX - 1, 3); |
---|
1013 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, XMAX, YMAX - 1, 3); |
---|
1014 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, XMAX, YMAX - 1, 2); |
---|
1015 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, XMAX, YMAX - 1, 2); |
---|
1016 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_in, XMAX, YMAX, 4, 3); |
---|
1017 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_out, XMAX, YMAX, 4, 3); |
---|
1018 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_in, XMAX, YMAX, 4, 2); |
---|
1019 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_out, XMAX, YMAX, 4, 2); |
---|
1020 | |
---|
1021 | return EXIT_SUCCESS; |
---|
1022 | } |
---|
1023 | |
---|
1024 | |
---|
1025 | void handler(int dummy = 0) { |
---|
1026 | stop_called = true; |
---|
1027 | sc_stop(); |
---|
1028 | } |
---|
1029 | |
---|
1030 | void voidhandler(int dummy = 0) {} |
---|
1031 | |
---|
1032 | int sc_main (int argc, char *argv[]) |
---|
1033 | { |
---|
1034 | signal(SIGINT, handler); |
---|
1035 | signal(SIGPIPE, voidhandler); |
---|
1036 | |
---|
1037 | try { |
---|
1038 | return _main(argc, argv); |
---|
1039 | } catch (std::exception &e) { |
---|
1040 | std::cout << e.what() << std::endl; |
---|
1041 | } catch (...) { |
---|
1042 | std::cout << "Unknown exception occured" << std::endl; |
---|
1043 | throw; |
---|
1044 | } |
---|
1045 | return 1; |
---|
1046 | } |
---|
1047 | |
---|
1048 | |
---|
1049 | // Local Variables: |
---|
1050 | // tab-width: 3 |
---|
1051 | // c-basic-offset: 3 |
---|
1052 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
1053 | // indent-tabs-mode: nil |
---|
1054 | // End: |
---|
1055 | |
---|
1056 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|