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 | // Parallelisation |
---|
98 | /////////////////////////////////////////////////// |
---|
99 | #if USE_OPENMP |
---|
100 | #include <omp.h> |
---|
101 | #endif |
---|
102 | |
---|
103 | // cluster index (computed from x,y coordinates) |
---|
104 | #define cluster(x,y) (y + ymax * x) |
---|
105 | |
---|
106 | #define min(x, y) (x < y ? x : y) |
---|
107 | |
---|
108 | /////////////////////////////////////////////////////////// |
---|
109 | // DSPIN parameters |
---|
110 | /////////////////////////////////////////////////////////// |
---|
111 | #define dspin_cmd_width 39 |
---|
112 | #define dspin_rsp_width 32 |
---|
113 | |
---|
114 | /////////////////////////////////////////////////////////// |
---|
115 | // VCI parameters |
---|
116 | /////////////////////////////////////////////////////////// |
---|
117 | #define vci_cell_width_int 4 |
---|
118 | #define vci_cell_width_ext 8 |
---|
119 | #define vci_address_width 32 |
---|
120 | #define vci_plen_width 8 |
---|
121 | #define vci_rerror_width 1 |
---|
122 | #define vci_clen_width 1 |
---|
123 | #define vci_rflag_width 1 |
---|
124 | #define vci_srcid_width 14 |
---|
125 | #define vci_pktid_width 4 |
---|
126 | #define vci_trdid_width 4 |
---|
127 | #define vci_wrplen_width 1 |
---|
128 | |
---|
129 | //////////////////////////////////////////////////////////// |
---|
130 | // Main Hardware Parameters values |
---|
131 | //////////////////////////////////////////////////////////// |
---|
132 | #define CLUSTER_X 1 |
---|
133 | #define CLUSTER_Y 1 |
---|
134 | #define NB_CLUSTERS 1 |
---|
135 | #define NB_PROCS_MAX 4 |
---|
136 | #define NB_DMA_CHANNELS 1 |
---|
137 | #define NB_TTY_CHANNELS 4 |
---|
138 | #define NB_IOC_CHANNELS 1 |
---|
139 | #define NB_NIC_CHANNELS 1 |
---|
140 | #define NB_CMA_CHANNELS 0 |
---|
141 | #define USE_XICU 1 |
---|
142 | #define IOMMU_ACTIVE 0 |
---|
143 | |
---|
144 | //////////////////////////////////////////////////////////// |
---|
145 | // Secondary Hardware Parameters |
---|
146 | //////////////////////////////////////////////////////////// |
---|
147 | #define XRAM_LATENCY 0 |
---|
148 | |
---|
149 | #define MEMC_WAYS 16 |
---|
150 | #define MEMC_SETS 256 |
---|
151 | |
---|
152 | #define L1_IWAYS 4 |
---|
153 | #define L1_ISETS 64 |
---|
154 | #define L1_DWAYS 4 |
---|
155 | #define L1_DSETS 64 |
---|
156 | |
---|
157 | #define FBUF_X_SIZE 512 |
---|
158 | #define FBUF_Y_SIZE 512 |
---|
159 | |
---|
160 | #define BDEV_SECTOR_SIZE 4096 |
---|
161 | #define BDEV_IMAGE_NAME "hdd-img.bin" |
---|
162 | |
---|
163 | #define NIC_RX_NAME "rx_packets.txt" |
---|
164 | #define NIC_TX_NAME "tx_packets.txt" |
---|
165 | #define NIC_TIMEOUT 10000 |
---|
166 | |
---|
167 | #define NORTH 0 |
---|
168 | #define SOUTH 1 |
---|
169 | #define EAST 2 |
---|
170 | #define WEST 3 |
---|
171 | |
---|
172 | //////////////////////////////////////////////////////////// |
---|
173 | // Software to be loaded in ROM/RAM |
---|
174 | //////////////////////////////////////////////////////////// |
---|
175 | #define soft_name "bootloader.bin",\ |
---|
176 | "kernel-soclib.bin@0xbfc10000:D",\ |
---|
177 | "arch-info.bin@0xBFC08000:D" |
---|
178 | |
---|
179 | //////////////////////////////////////////////////////////// |
---|
180 | // DEBUG Parameters default values |
---|
181 | //////////////////////////////////////////////////////////// |
---|
182 | #define MAX_FROZEN_CYCLES 100000000 |
---|
183 | |
---|
184 | //////////////////////////////////////////////////////////////////// |
---|
185 | // TGTID definition in direct space |
---|
186 | // For all components: global TGTID = global SRCID = cluster_index |
---|
187 | //////////////////////////////////////////////////////////////////// |
---|
188 | #define MEMC_TGTID 0 |
---|
189 | #define XICU_TGTID 1 |
---|
190 | #define MDMA_TGTID 2 |
---|
191 | #define MTTY_TGTID 3 |
---|
192 | #define FBUF_TGTID 4 |
---|
193 | #define BDEV_TGTID 5 |
---|
194 | #define MNIC_TGTID 6 |
---|
195 | #define BROM_TGTID 7 |
---|
196 | #define CDMA_TGTID 8 |
---|
197 | #define SIMH_TGTID 9 |
---|
198 | |
---|
199 | ///////////////////////////////////////////////////////// |
---|
200 | // Physical segments definition |
---|
201 | ///////////////////////////////////////////////////////// |
---|
202 | // There is 3 segments replicated in all clusters |
---|
203 | // and 5 specific segments in the "IO" cluster |
---|
204 | // (containing address 0xBF000000) |
---|
205 | ///////////////////////////////////////////////////////// |
---|
206 | // Physical Address Decoding: 8 GID + 8 LID + 16 offset. |
---|
207 | ///////////////////////////////////////////////////////// |
---|
208 | #define RAM_BASE 0x00000000 |
---|
209 | #define RAM_SIZE 0x00C00000 |
---|
210 | |
---|
211 | #define BROM_BASE 0xBFC00000 |
---|
212 | #define BROM_SIZE 0x00100000 |
---|
213 | |
---|
214 | #define FBUF_BASE 0xBFD00000 |
---|
215 | #define FBUF_SIZE 0x00200000 |
---|
216 | |
---|
217 | #define XICU_BASE 0x00F00000 |
---|
218 | #define XICU_SIZE 0x00002000 |
---|
219 | |
---|
220 | #define BDEV_BASE 0xBFF10000 |
---|
221 | #define BDEV_SIZE 0x00000100 |
---|
222 | |
---|
223 | #define MTTY_BASE 0xBFF20000 |
---|
224 | #define MTTY_SIZE 0x00000100 |
---|
225 | |
---|
226 | #define MDMA_BASE 0x00F30000 |
---|
227 | #define MDMA_SIZE 0x00001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
228 | |
---|
229 | #define MEMC_BASE 0x00F40000 |
---|
230 | #define MEMC_SIZE 0x00001000 |
---|
231 | |
---|
232 | #define SIMH_BASE 0xBFF50000 |
---|
233 | #define SIMH_SIZE 0x00001000 |
---|
234 | |
---|
235 | #define CDMA_BASE 0xBFF60000 |
---|
236 | #define CDMA_SIZE 0x00000100 |
---|
237 | |
---|
238 | #define MNIC_BASE 0xB0F80000 |
---|
239 | #define MNIC_SIZE 0x00080000 // 512 Kbytes (for 8 channels) |
---|
240 | |
---|
241 | bool stop_called = false; |
---|
242 | |
---|
243 | ///////////////////////////////// |
---|
244 | int _main(int argc, char *argv[]) |
---|
245 | { |
---|
246 | using namespace sc_core; |
---|
247 | using namespace soclib::caba; |
---|
248 | using namespace soclib::common; |
---|
249 | |
---|
250 | uint64_t ncycles = 0xFFFFFFFFFFFFFFFF; // simulated cycles |
---|
251 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
252 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
253 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
254 | ssize_t threads_nr = 1; // simulator's threads number |
---|
255 | bool debug_ok = false; // trace activated |
---|
256 | size_t debug_period = 1; // trace period |
---|
257 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
258 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
259 | uint32_t debug_from = 0; // trace start cycle |
---|
260 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
261 | size_t xmax = CLUSTER_X; // number of clusters in a row |
---|
262 | size_t ymax = CLUSTER_Y; // number of clusters in a column |
---|
263 | size_t nprocs = NB_PROCS_MAX; // number of processors per cluster |
---|
264 | size_t xfb = FBUF_X_SIZE; // frameBuffer column number |
---|
265 | size_t yfb = FBUF_Y_SIZE; // frameBuffer lines number |
---|
266 | size_t fb_mode = 420; |
---|
267 | size_t ram_size = RAM_SIZE; |
---|
268 | size_t blk_size = BDEV_SECTOR_SIZE; |
---|
269 | size_t l1_i_ways = L1_IWAYS; |
---|
270 | size_t l1_d_ways = L1_DWAYS; |
---|
271 | size_t l1_i_sets = L1_ISETS; |
---|
272 | size_t l1_d_sets = L1_DSETS; |
---|
273 | size_t memc_sets = MEMC_SETS; |
---|
274 | size_t memc_ways = MEMC_WAYS; |
---|
275 | size_t xram_latency = XRAM_LATENCY; |
---|
276 | size_t ram_base = RAM_BASE; |
---|
277 | size_t xicu_base = XICU_BASE; |
---|
278 | size_t mdma_base = MDMA_BASE; |
---|
279 | size_t memc_base = MEMC_BASE; |
---|
280 | bool isRamSizeSet = false; |
---|
281 | size_t cluster_io_id; // index of cluster containing IOs |
---|
282 | struct timeval t1,t2; |
---|
283 | uint64_t ms1,ms2; |
---|
284 | |
---|
285 | ////////////// command line arguments ////////////////////// |
---|
286 | if (argc > 1) |
---|
287 | { |
---|
288 | for (int n = 1; n < argc; n = n + 2) |
---|
289 | { |
---|
290 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) |
---|
291 | { |
---|
292 | ncycles = atoi(argv[n + 1]); |
---|
293 | } |
---|
294 | else if( (strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc) ) |
---|
295 | { |
---|
296 | nprocs = atoi(argv[n+1]); |
---|
297 | assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)) && |
---|
298 | "NPROCS must be equal to 1, 2, or 4"); |
---|
299 | } |
---|
300 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) |
---|
301 | { |
---|
302 | threads_nr = atoi(argv[n + 1]); |
---|
303 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
304 | } |
---|
305 | else if( (strcmp(argv[n],"-XMAX") == 0) && (n+1<argc) ) |
---|
306 | { |
---|
307 | xmax = atoi(argv[n+1]); |
---|
308 | assert( ((xmax == 1) || (xmax == 2) || (xmax == 4) || (xmax == 8) || (xmax == 16)) |
---|
309 | && "The XMAX parameter must be 2, 4, 8, or 16" ); |
---|
310 | } |
---|
311 | else if( (strcmp(argv[n],"-YMAX") == 0) && (n+1<argc) ) |
---|
312 | { |
---|
313 | ymax = atoi(argv[n+1]); |
---|
314 | assert( ((ymax == 1) || (ymax == 2) || (ymax == 4) || (ymax == 8) || (ymax == 16)) |
---|
315 | && "The YMAX parameter must be 2, 4, 8, or 16" ); |
---|
316 | } |
---|
317 | else if((strcmp(argv[n], "-MEMSZ") == 0) && (n+1 < argc)) |
---|
318 | { |
---|
319 | ram_size = atoi(argv[n+1]); |
---|
320 | isRamSizeSet = true; |
---|
321 | } |
---|
322 | else if((strcmp(argv[n], "-MCWAYS") == 0) && (n+1 < argc)) |
---|
323 | { |
---|
324 | memc_ways = atoi(argv[n+1]); |
---|
325 | } |
---|
326 | else if((strcmp(argv[n], "-MCSETS") == 0) && (n+1 < argc)) |
---|
327 | { |
---|
328 | memc_sets = atoi(argv[n+1]); |
---|
329 | } |
---|
330 | else if((strcmp(argv[n], "-L1_IWAYS") == 0) && (n+1 < argc)) |
---|
331 | { |
---|
332 | l1_i_ways = atoi(argv[n+1]); |
---|
333 | } |
---|
334 | else if((strcmp(argv[n], "-L1_ISETS") == 0) && (n+1 < argc)) |
---|
335 | { |
---|
336 | l1_i_sets = atoi(argv[n+1]); |
---|
337 | } |
---|
338 | else if((strcmp(argv[n], "-L1_DWAYS") == 0) && (n+1 < argc)) |
---|
339 | { |
---|
340 | l1_d_ways = atoi(argv[n+1]); |
---|
341 | } |
---|
342 | else if((strcmp(argv[n], "-L1_DSETS") == 0) && (n+1 < argc)) |
---|
343 | { |
---|
344 | l1_d_sets = atoi(argv[n+1]); |
---|
345 | } |
---|
346 | else if((strcmp(argv[n], "-XLATENCY") == 0) && (n+1 < argc)) |
---|
347 | { |
---|
348 | xram_latency = atoi(argv[n+1]); |
---|
349 | } |
---|
350 | else if( (strcmp(argv[n],"-XFB") == 0) && (n+1<argc) ) |
---|
351 | { |
---|
352 | xfb = atoi(argv[n+1]); |
---|
353 | } |
---|
354 | else if( (strcmp(argv[n],"-YFB") == 0) && (n+1<argc) ) |
---|
355 | { |
---|
356 | yfb = atoi(argv[n+1]); |
---|
357 | } |
---|
358 | else if( (strcmp(argv[n], "-FBMODE") == 0) && (n+1 < argc)) |
---|
359 | { |
---|
360 | fb_mode = atoi(argv[n+1]); |
---|
361 | } |
---|
362 | else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) |
---|
363 | { |
---|
364 | std::cerr << "Warning: -SOFT is useless when using Almos, ignored" << std::endl; |
---|
365 | } |
---|
366 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) |
---|
367 | { |
---|
368 | strcpy(disk_name, argv[n + 1]); |
---|
369 | } |
---|
370 | else if( (strcmp(argv[n],"-BLKSZ") == 0) && (n+1<argc) ) |
---|
371 | { |
---|
372 | blk_size = atoi(argv[n+1]); |
---|
373 | assert(((blk_size % 512) == 0) && "BDEV: Block size must be multiple of 512 bytes"); |
---|
374 | } |
---|
375 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) |
---|
376 | { |
---|
377 | debug_ok = true; |
---|
378 | debug_from = atoi(argv[n + 1]); |
---|
379 | } |
---|
380 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) |
---|
381 | { |
---|
382 | debug_memc_id = atoi(argv[n + 1]); |
---|
383 | assert((debug_memc_id < (xmax * ymax)) && |
---|
384 | "debug_memc_id larger than xmax * ymax" ); |
---|
385 | } |
---|
386 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) |
---|
387 | { |
---|
388 | debug_proc_id = atoi(argv[n + 1]); |
---|
389 | assert((debug_proc_id < (xmax * ymax * nprocs)) && |
---|
390 | "debug_proc_id larger than XMAX * ymax * NB_PROCS"); |
---|
391 | } |
---|
392 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) |
---|
393 | { |
---|
394 | frozen_cycles = atoi(argv[n + 1]); |
---|
395 | } |
---|
396 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) |
---|
397 | { |
---|
398 | debug_period = atoi(argv[n + 1]); |
---|
399 | } |
---|
400 | else |
---|
401 | { |
---|
402 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
403 | std::cout << " The order is not important." << std::endl; |
---|
404 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
405 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
406 | std::cout << " -NPROCS number_of_processors_per_cluster" << std::endl; |
---|
407 | std::cout << " -THREADS simulator's openmp threads number" << std::endl; |
---|
408 | std::cout << " -XMAX number_of_clusters_in_a_row" << std::endl; |
---|
409 | std::cout << " -YMAX number_of_clusters_in_a_column" << std::endl; |
---|
410 | std::cout << " -MCWAYS memory_cache_number_of_ways" << std::endl; |
---|
411 | std::cout << " -MCSETS memory_cache_number_of_sets" << std::endl; |
---|
412 | std::cout << " -L1_IWAYS L1_instruction_cache_number_of_ways" << std::endl; |
---|
413 | std::cout << " -L1_ISETS L1_instruction_cache_number_of_sets" << std::endl; |
---|
414 | std::cout << " -L1_DWAYS L1_data_cache_number_of_ways" << std::endl; |
---|
415 | std::cout << " -XLATENCY external_ram_latency_value" << std::endl; |
---|
416 | std::cout << " -XFB fram_buffer_number_of_pixels" << std::endl; |
---|
417 | std::cout << " -YFB fram_buffer_number_of_lines" << std::endl; |
---|
418 | std::cout << " -FBMODE fram buffer subsampling integer value " |
---|
419 | "(YUV:420,YUV:422,RGB:0,RGB:16,RGB:32,RGBPAL:256)" << std::endl; |
---|
420 | std::cout << " -MEMSZ per-cluster memory size ( <= 12 MB when using Almos)" << std::endl; |
---|
421 | std::cout << " -L1_DSETS L1_data_cache_number_of_sets" << std::endl; |
---|
422 | std::cout << " -SOFT pathname_for_embedded_soft (GIET only)" << std::endl; |
---|
423 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
424 | std::cout << " -BLKSZ sector size in bytes ( must be multiple of 512 bytes )" << std::endl; |
---|
425 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
426 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
427 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
428 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
429 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
430 | exit(0); |
---|
431 | } |
---|
432 | } |
---|
433 | } |
---|
434 | |
---|
435 | // checking hardware parameters |
---|
436 | assert( ( (xmax == 1) or (xmax == 2) or (xmax == 4) or |
---|
437 | (xmax == 8) or (xmax == 16) ) and |
---|
438 | "The XMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
439 | |
---|
440 | assert( ( (ymax == 1) or (ymax == 2) or (ymax == 4) or |
---|
441 | (ymax == 8) or (ymax == 16) ) and |
---|
442 | "The YMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
443 | |
---|
444 | assert( ( (nprocs == 1) or (nprocs == 2) or |
---|
445 | (nprocs == 4) or (nprocs == 8) ) and |
---|
446 | "The nprocs parameter must be 1, 2, 4 or 8" ); |
---|
447 | |
---|
448 | assert( (NB_DMA_CHANNELS < 9) and |
---|
449 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
450 | |
---|
451 | assert( (NB_TTY_CHANNELS < 15) and |
---|
452 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
453 | |
---|
454 | assert( (NB_NIC_CHANNELS < 9) and |
---|
455 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
456 | |
---|
457 | assert( (vci_address_width == 32) and |
---|
458 | "VCI address width with ALMOS must be 32 bits" ); |
---|
459 | |
---|
460 | std::cout << std::endl; |
---|
461 | std::cout << " - XMAX = " << xmax << std::endl; |
---|
462 | std::cout << " - YMAX = " << ymax << std::endl; |
---|
463 | std::cout << " - NPROCS = " << nprocs << std::endl; |
---|
464 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
465 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
466 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
467 | std::cout << " - MEMC_WAYS = " << memc_ways << std::endl; |
---|
468 | std::cout << " - MEMC_SETS = " << memc_sets << std::endl; |
---|
469 | std::cout << " - RAM_SIZE = " << ram_size << std::endl; |
---|
470 | std::cout << " - RAM_LATENCY = " << xram_latency << std::endl; |
---|
471 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
472 | std::cout << "[PROCS] " << nprocs * xmax * ymax << std::endl; |
---|
473 | |
---|
474 | std::cout << std::endl; |
---|
475 | // Internal and External VCI parameters definition |
---|
476 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
477 | vci_plen_width, |
---|
478 | vci_address_width, |
---|
479 | vci_rerror_width, |
---|
480 | vci_clen_width, |
---|
481 | vci_rflag_width, |
---|
482 | vci_srcid_width, |
---|
483 | vci_pktid_width, |
---|
484 | vci_trdid_width, |
---|
485 | vci_wrplen_width> vci_param_int; |
---|
486 | |
---|
487 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
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_ext; |
---|
497 | |
---|
498 | #if USE_OPENMP |
---|
499 | omp_set_dynamic(false); |
---|
500 | omp_set_num_threads(threads_nr); |
---|
501 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
502 | #endif |
---|
503 | |
---|
504 | // Define parameters depending on mesh size |
---|
505 | size_t x_width; |
---|
506 | size_t y_width; |
---|
507 | |
---|
508 | if (xmax == 1) x_width = 0; |
---|
509 | else if (xmax == 2) x_width = 1; |
---|
510 | else if (xmax <= 4) x_width = 2; |
---|
511 | else if (xmax <= 8) x_width = 3; |
---|
512 | else x_width = 4; |
---|
513 | |
---|
514 | if (ymax == 1) y_width = 0; |
---|
515 | else if (ymax == 2) y_width = 1; |
---|
516 | else if (ymax <= 4) y_width = 2; |
---|
517 | else if (ymax <= 8) y_width = 3; |
---|
518 | else y_width = 4; |
---|
519 | |
---|
520 | if((xmax == 1) && (ymax == 1)) |
---|
521 | { |
---|
522 | cluster_io_id = 0; |
---|
523 | ram_size = (isRamSizeSet == true) ? ram_size : 0x8000000; |
---|
524 | xicu_base = 0x80f00000; |
---|
525 | memc_base = 0x80f40000; |
---|
526 | mdma_base = 0x80f30000; |
---|
527 | } |
---|
528 | else |
---|
529 | cluster_io_id = 0xbfc00000 >> (vci_address_width - x_width - y_width); // index of cluster containing IOs |
---|
530 | |
---|
531 | ///////////////////// |
---|
532 | // Mapping Tables |
---|
533 | ///////////////////// |
---|
534 | |
---|
535 | // internal network |
---|
536 | MappingTable maptabd(vci_address_width, |
---|
537 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
538 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
539 | 0x00FFFF0000); |
---|
540 | |
---|
541 | for (size_t x = 0; x < xmax; x++) |
---|
542 | { |
---|
543 | for (size_t y = 0; y < ymax; y++) |
---|
544 | { |
---|
545 | sc_uint<vci_address_width> offset; |
---|
546 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
547 | << (vci_address_width-x_width-y_width); |
---|
548 | |
---|
549 | std::ostringstream si; |
---|
550 | si << "seg_xicu_" << x << "_" << y; |
---|
551 | maptabd.add(Segment(si.str(), xicu_base + offset, XICU_SIZE, |
---|
552 | IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
553 | |
---|
554 | std::ostringstream sd; |
---|
555 | sd << "seg_mdma_" << x << "_" << y; |
---|
556 | maptabd.add(Segment(sd.str(), mdma_base + offset, MDMA_SIZE, |
---|
557 | IntTab(cluster(x,y),MDMA_TGTID), false)); |
---|
558 | |
---|
559 | std::ostringstream sh; |
---|
560 | sh << "seg_ram_" << x << "_" << y; |
---|
561 | maptabd.add(Segment(sh.str(), RAM_BASE + offset, ram_size, |
---|
562 | IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
563 | |
---|
564 | std::ostringstream sconf; |
---|
565 | sconf << "seg_memc_config_" << x << "_" << y; |
---|
566 | maptabd.add(Segment(sconf.str(), memc_base + offset, RAM_SIZE, |
---|
567 | IntTab(cluster(x,y),MEMC_TGTID), true, true)); |
---|
568 | |
---|
569 | if ( cluster(x,y) == cluster_io_id ) |
---|
570 | { |
---|
571 | maptabd.add(Segment("seg_mtty", MTTY_BASE, MTTY_SIZE, |
---|
572 | IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
573 | maptabd.add(Segment("seg_fbuf", FBUF_BASE, FBUF_SIZE, |
---|
574 | IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
575 | maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, |
---|
576 | IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
577 | maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, |
---|
578 | IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
579 | maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, |
---|
580 | IntTab(cluster(x,y),MNIC_TGTID), false)); |
---|
581 | maptabd.add(Segment("seg_cdma", CDMA_BASE, CDMA_SIZE, |
---|
582 | IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
583 | maptabd.add(Segment("seg_simh", SIMH_BASE, SIMH_SIZE, |
---|
584 | IntTab(cluster(x,y),SIMH_TGTID), false)); |
---|
585 | } |
---|
586 | } |
---|
587 | } |
---|
588 | std::cout << maptabd << std::endl; |
---|
589 | |
---|
590 | // external network |
---|
591 | MappingTable maptabx(vci_address_width, |
---|
592 | IntTab(x_width+y_width), |
---|
593 | IntTab(x_width+y_width), |
---|
594 | 0x00FFFF0000ULL); |
---|
595 | |
---|
596 | for (size_t x = 0; x < xmax; x++) |
---|
597 | { |
---|
598 | for (size_t y = 0; y < ymax ; y++) |
---|
599 | { |
---|
600 | |
---|
601 | sc_uint<vci_address_width> offset; |
---|
602 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
603 | << (vci_address_width-x_width-y_width); |
---|
604 | |
---|
605 | std::ostringstream sh; |
---|
606 | sh << "x_seg_memc_" << x << "_" << y; |
---|
607 | |
---|
608 | maptabx.add(Segment(sh.str(), RAM_BASE + offset, |
---|
609 | ram_size, IntTab(cluster(x,y)), false)); |
---|
610 | } |
---|
611 | } |
---|
612 | std::cout << maptabx << std::endl; |
---|
613 | |
---|
614 | //////////////////// |
---|
615 | // Signals |
---|
616 | /////////////////// |
---|
617 | |
---|
618 | std::cout << "Clock .. "; |
---|
619 | sc_clock signal_clk("clk"); |
---|
620 | std::cout << ". [OK]" << std::endl; |
---|
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 | |
---|
627 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_dec = |
---|
628 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", xmax-1, ymax, 3); |
---|
629 | |
---|
630 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_inc = |
---|
631 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", xmax-1, ymax, 2); |
---|
632 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_dec = |
---|
633 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", xmax-1, ymax, 2); |
---|
634 | |
---|
635 | // Vertical inter-clusters DSPIN signals |
---|
636 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_inc = |
---|
637 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", xmax, ymax-1, 3); |
---|
638 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_dec = |
---|
639 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", xmax, ymax-1, 3); |
---|
640 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_inc = |
---|
641 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", xmax, ymax-1, 2); |
---|
642 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_dec = |
---|
643 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", xmax, ymax-1, 2); |
---|
644 | |
---|
645 | // Mesh boundaries DSPIN signals |
---|
646 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_in = |
---|
647 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in" , xmax, ymax, 4, 3); |
---|
648 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_out = |
---|
649 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", xmax, ymax, 4, 3); |
---|
650 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_in = |
---|
651 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in" , xmax, ymax, 4, 2); |
---|
652 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_out = |
---|
653 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", xmax, ymax, 4, 2); |
---|
654 | |
---|
655 | //////////////////////////// |
---|
656 | // Loader |
---|
657 | //////////////////////////// |
---|
658 | |
---|
659 | soclib::common::Loader loader(soft_name); |
---|
660 | |
---|
661 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
662 | proc_iss::set_loader(loader); |
---|
663 | |
---|
664 | //////////////////////////// |
---|
665 | // Clusters construction |
---|
666 | //////////////////////////// |
---|
667 | |
---|
668 | TsarXbarCluster<dspin_cmd_width, |
---|
669 | dspin_rsp_width, |
---|
670 | vci_param_int, |
---|
671 | vci_param_ext>* clusters[xmax][ymax]; |
---|
672 | |
---|
673 | #if USE_OPENMP |
---|
674 | #pragma omp parallel |
---|
675 | { |
---|
676 | #pragma omp for |
---|
677 | #endif |
---|
678 | for (size_t i = 0; i < (xmax * ymax); i++) |
---|
679 | { |
---|
680 | size_t x = i / ymax; |
---|
681 | size_t y = i % ymax; |
---|
682 | |
---|
683 | #if USE_OPENMP |
---|
684 | #pragma omp critical |
---|
685 | { |
---|
686 | #endif |
---|
687 | std::cout << std::endl; |
---|
688 | std::cout << "Cluster_" << x << "_" << y << std::endl; |
---|
689 | std::cout << std::endl; |
---|
690 | |
---|
691 | std::ostringstream sc; |
---|
692 | sc << "cluster_" << x << "_" << y; |
---|
693 | clusters[x][y] = new TsarXbarCluster<dspin_cmd_width, |
---|
694 | dspin_rsp_width, |
---|
695 | vci_param_int, |
---|
696 | vci_param_ext> |
---|
697 | ( |
---|
698 | sc.str().c_str(), |
---|
699 | nprocs, |
---|
700 | NB_TTY_CHANNELS, |
---|
701 | NB_DMA_CHANNELS, |
---|
702 | x, |
---|
703 | y, |
---|
704 | cluster(x,y), |
---|
705 | maptabd, |
---|
706 | maptabx, |
---|
707 | x_width, |
---|
708 | y_width, |
---|
709 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
710 | MEMC_TGTID, |
---|
711 | XICU_TGTID, |
---|
712 | MDMA_TGTID, |
---|
713 | FBUF_TGTID, |
---|
714 | MTTY_TGTID, |
---|
715 | BROM_TGTID, |
---|
716 | MNIC_TGTID, |
---|
717 | CDMA_TGTID, |
---|
718 | BDEV_TGTID, |
---|
719 | SIMH_TGTID, |
---|
720 | memc_ways, |
---|
721 | memc_sets, |
---|
722 | l1_i_ways, |
---|
723 | l1_i_sets, |
---|
724 | l1_d_ways, |
---|
725 | l1_d_sets, |
---|
726 | xram_latency, |
---|
727 | (cluster(x,y) == cluster_io_id), |
---|
728 | xfb, |
---|
729 | yfb, |
---|
730 | disk_name, |
---|
731 | blk_size, |
---|
732 | NB_NIC_CHANNELS, |
---|
733 | nic_rx_name, |
---|
734 | nic_tx_name, |
---|
735 | NIC_TIMEOUT, |
---|
736 | NB_CMA_CHANNELS, |
---|
737 | loader, |
---|
738 | frozen_cycles, |
---|
739 | debug_from , |
---|
740 | debug_ok and (cluster(x,y) == debug_memc_id), |
---|
741 | debug_ok and (cluster(x,y) == debug_proc_id) |
---|
742 | ); |
---|
743 | |
---|
744 | #if USE_OPENMP |
---|
745 | } // end critical |
---|
746 | #endif |
---|
747 | } // end for |
---|
748 | #if USE_OPENMP |
---|
749 | } |
---|
750 | #endif |
---|
751 | |
---|
752 | /////////////////////////////////////////////////////////////// |
---|
753 | // Net-list |
---|
754 | /////////////////////////////////////////////////////////////// |
---|
755 | |
---|
756 | // Clock & RESET |
---|
757 | for (size_t x = 0; x < (xmax); x++){ |
---|
758 | for (size_t y = 0; y < ymax; y++){ |
---|
759 | clusters[x][y]->p_clk (signal_clk); |
---|
760 | clusters[x][y]->p_resetn (signal_resetn); |
---|
761 | } |
---|
762 | } |
---|
763 | |
---|
764 | // Inter Clusters horizontal connections |
---|
765 | if (xmax > 1){ |
---|
766 | for (size_t x = 0; x < (xmax-1); x++){ |
---|
767 | for (size_t y = 0; y < ymax; y++){ |
---|
768 | for (size_t k = 0; k < 3; k++){ |
---|
769 | clusters[x][y]->p_cmd_out[EAST][k] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
770 | clusters[x+1][y]->p_cmd_in[WEST][k] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
771 | clusters[x][y]->p_cmd_in[EAST][k] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
772 | clusters[x+1][y]->p_cmd_out[WEST][k] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
773 | } |
---|
774 | |
---|
775 | for (size_t k = 0; k < 2; k++){ |
---|
776 | clusters[x][y]->p_rsp_out[EAST][k] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
777 | clusters[x+1][y]->p_rsp_in[WEST][k] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
778 | clusters[x][y]->p_rsp_in[EAST][k] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
779 | clusters[x+1][y]->p_rsp_out[WEST][k] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
780 | } |
---|
781 | } |
---|
782 | } |
---|
783 | } |
---|
784 | std::cout << std::endl << "Horizontal connections established" << std::endl; |
---|
785 | |
---|
786 | // Inter Clusters vertical connections |
---|
787 | if (ymax > 1) { |
---|
788 | for (size_t y = 0; y < (ymax-1); y++){ |
---|
789 | for (size_t x = 0; x < xmax; x++){ |
---|
790 | for (size_t k = 0; k < 3; k++){ |
---|
791 | clusters[x][y]->p_cmd_out[NORTH][k] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
792 | clusters[x][y+1]->p_cmd_in[SOUTH][k] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
793 | clusters[x][y]->p_cmd_in[NORTH][k] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
794 | clusters[x][y+1]->p_cmd_out[SOUTH][k] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
795 | } |
---|
796 | |
---|
797 | for (size_t k = 0; k < 2; k++){ |
---|
798 | clusters[x][y]->p_rsp_out[NORTH][k] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
799 | clusters[x][y+1]->p_rsp_in[SOUTH][k] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
800 | clusters[x][y]->p_rsp_in[NORTH][k] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
801 | clusters[x][y+1]->p_rsp_out[SOUTH][k] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
802 | } |
---|
803 | } |
---|
804 | } |
---|
805 | } |
---|
806 | std::cout << "Vertical connections established" << std::endl; |
---|
807 | |
---|
808 | // East & West boundary cluster connections |
---|
809 | for (size_t y = 0; y < ymax; y++) |
---|
810 | { |
---|
811 | for (size_t k = 0; k < 3; k++) |
---|
812 | { |
---|
813 | clusters[0][y]->p_cmd_in[WEST][k] (signal_dspin_false_cmd_in[0][y][WEST][k]); |
---|
814 | clusters[0][y]->p_cmd_out[WEST][k] (signal_dspin_false_cmd_out[0][y][WEST][k]); |
---|
815 | clusters[xmax-1][y]->p_cmd_in[EAST][k] (signal_dspin_false_cmd_in[xmax-1][y][EAST][k]); |
---|
816 | clusters[xmax-1][y]->p_cmd_out[EAST][k] (signal_dspin_false_cmd_out[xmax-1][y][EAST][k]); |
---|
817 | } |
---|
818 | |
---|
819 | for (size_t k = 0; k < 2; k++) |
---|
820 | { |
---|
821 | clusters[0][y]->p_rsp_in[WEST][k] (signal_dspin_false_rsp_in[0][y][WEST][k]); |
---|
822 | clusters[0][y]->p_rsp_out[WEST][k] (signal_dspin_false_rsp_out[0][y][WEST][k]); |
---|
823 | clusters[xmax-1][y]->p_rsp_in[EAST][k] (signal_dspin_false_rsp_in[xmax-1][y][EAST][k]); |
---|
824 | clusters[xmax-1][y]->p_rsp_out[EAST][k] (signal_dspin_false_rsp_out[xmax-1][y][EAST][k]); |
---|
825 | } |
---|
826 | } |
---|
827 | |
---|
828 | // North & South boundary clusters connections |
---|
829 | for (size_t x = 0; x < xmax; x++) |
---|
830 | { |
---|
831 | for (size_t k = 0; k < 3; k++) |
---|
832 | { |
---|
833 | clusters[x][0]->p_cmd_in[SOUTH][k] (signal_dspin_false_cmd_in[x][0][SOUTH][k]); |
---|
834 | clusters[x][0]->p_cmd_out[SOUTH][k] (signal_dspin_false_cmd_out[x][0][SOUTH][k]); |
---|
835 | clusters[x][ymax-1]->p_cmd_in[NORTH][k] (signal_dspin_false_cmd_in[x][ymax-1][NORTH][k]); |
---|
836 | clusters[x][ymax-1]->p_cmd_out[NORTH][k] (signal_dspin_false_cmd_out[x][ymax-1][NORTH][k]); |
---|
837 | } |
---|
838 | |
---|
839 | for (size_t k = 0; k < 2; k++) |
---|
840 | { |
---|
841 | clusters[x][0]->p_rsp_in[SOUTH][k] (signal_dspin_false_rsp_in[x][0][SOUTH][k]); |
---|
842 | clusters[x][0]->p_rsp_out[SOUTH][k] (signal_dspin_false_rsp_out[x][0][SOUTH][k]); |
---|
843 | clusters[x][ymax-1]->p_rsp_in[NORTH][k] (signal_dspin_false_rsp_in[x][ymax-1][NORTH][k]); |
---|
844 | clusters[x][ymax-1]->p_rsp_out[NORTH][k] (signal_dspin_false_rsp_out[x][ymax-1][NORTH][k]); |
---|
845 | } |
---|
846 | } |
---|
847 | std::cout << "North, South, West, East connections established" << std::endl; |
---|
848 | std::cout << std::endl; |
---|
849 | |
---|
850 | |
---|
851 | //////////////////////////////////////////////////////// |
---|
852 | // Simulation |
---|
853 | /////////////////////////////////////////////////////// |
---|
854 | |
---|
855 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
856 | signal_resetn = false; |
---|
857 | |
---|
858 | // network boundaries signals |
---|
859 | for (size_t x = 0; x < xmax ; x++){ |
---|
860 | for (size_t y = 0; y < ymax ; y++){ |
---|
861 | for (size_t a = 0; a < 4; a++){ |
---|
862 | for (size_t k = 0; k < 3; k++){ |
---|
863 | signal_dspin_false_cmd_in [x][y][a][k].write = false; |
---|
864 | signal_dspin_false_cmd_in [x][y][a][k].read = true; |
---|
865 | signal_dspin_false_cmd_out[x][y][a][k].write = false; |
---|
866 | signal_dspin_false_cmd_out[x][y][a][k].read = true; |
---|
867 | } |
---|
868 | |
---|
869 | for (size_t k = 0; k < 2; k++){ |
---|
870 | signal_dspin_false_rsp_in [x][y][a][k].write = false; |
---|
871 | signal_dspin_false_rsp_in [x][y][a][k].read = true; |
---|
872 | signal_dspin_false_rsp_out[x][y][a][k].write = false; |
---|
873 | signal_dspin_false_rsp_out[x][y][a][k].read = true; |
---|
874 | } |
---|
875 | } |
---|
876 | } |
---|
877 | } |
---|
878 | |
---|
879 | #define STATS_CYCLES 10000000 |
---|
880 | |
---|
881 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
882 | signal_resetn = true; |
---|
883 | |
---|
884 | uint64_t n = 0; |
---|
885 | |
---|
886 | while (!stop_called) { |
---|
887 | if (gettimeofday(&t1, NULL) != 0) { |
---|
888 | perror("gettimeofday"); |
---|
889 | return EXIT_FAILURE; |
---|
890 | } |
---|
891 | sc_start(STATS_CYCLES); |
---|
892 | n += STATS_CYCLES; |
---|
893 | if (gettimeofday(&t2, NULL) != 0) { |
---|
894 | perror("gettimeofday"); |
---|
895 | return EXIT_FAILURE; |
---|
896 | } |
---|
897 | ms1 = (uint64_t)t1.tv_sec * 1000ULL + (uint64_t)t1.tv_usec / 1000; |
---|
898 | ms2 = (uint64_t)t2.tv_sec * 1000ULL + (uint64_t)t2.tv_usec / 1000; |
---|
899 | std::cerr << "cycle " << n |
---|
900 | << " platform clock frequency " |
---|
901 | << (double)STATS_CYCLES / (double)(ms2 - ms1) |
---|
902 | << "Khz" << std::endl; |
---|
903 | } |
---|
904 | |
---|
905 | // Free memory |
---|
906 | for (size_t i = 0; i < (xmax * ymax); i++) |
---|
907 | { |
---|
908 | size_t x = i / ymax; |
---|
909 | size_t y = i % ymax; |
---|
910 | delete clusters[x][y]; |
---|
911 | } |
---|
912 | |
---|
913 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, xmax - 1, ymax, 3); |
---|
914 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, xmax - 1, ymax, 3); |
---|
915 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, xmax - 1, ymax, 2); |
---|
916 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, xmax - 1, ymax, 2); |
---|
917 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, xmax, ymax - 1, 3); |
---|
918 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, xmax, ymax - 1, 3); |
---|
919 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, xmax, ymax - 1, 2); |
---|
920 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, xmax, ymax - 1, 2); |
---|
921 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_in, xmax, ymax, 4, 3); |
---|
922 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_out, xmax, ymax, 4, 3); |
---|
923 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_in, xmax, ymax, 4, 2); |
---|
924 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_out, xmax, ymax, 4, 2); |
---|
925 | |
---|
926 | return EXIT_SUCCESS; |
---|
927 | } |
---|
928 | |
---|
929 | |
---|
930 | void handler(int dummy = 0) { |
---|
931 | stop_called = true; |
---|
932 | sc_stop(); |
---|
933 | } |
---|
934 | |
---|
935 | void voidhandler(int dummy = 0) {} |
---|
936 | |
---|
937 | int sc_main (int argc, char *argv[]) |
---|
938 | { |
---|
939 | signal(SIGINT, handler); |
---|
940 | signal(SIGPIPE, voidhandler); |
---|
941 | |
---|
942 | try { |
---|
943 | return _main(argc, argv); |
---|
944 | } catch (std::exception &e) { |
---|
945 | std::cout << e.what() << std::endl; |
---|
946 | } catch (...) { |
---|
947 | std::cout << "Unknown exception occured" << std::endl; |
---|
948 | throw; |
---|
949 | } |
---|
950 | return 1; |
---|
951 | } |
---|
952 | |
---|
953 | |
---|
954 | // Local Variables: |
---|
955 | // tab-width: 3 |
---|
956 | // c-basic-offset: 3 |
---|
957 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
958 | // indent-tabs-mode: nil |
---|
959 | // End: |
---|
960 | |
---|
961 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|