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 "alloc_elems.h" |
---|
94 | #include "tsar_super_cluster.h" |
---|
95 | |
---|
96 | //#define USE_ALMOS 1 |
---|
97 | #define USE_GIET |
---|
98 | |
---|
99 | #ifdef USE_ALMOS |
---|
100 | #ifdef USE_GIET |
---|
101 | #error "Can't use Two different OS" |
---|
102 | #endif |
---|
103 | #endif |
---|
104 | |
---|
105 | #ifndef USE_ALMOS |
---|
106 | #ifndef USE_GIET |
---|
107 | #error "You need to specify one OS" |
---|
108 | #endif |
---|
109 | #endif |
---|
110 | |
---|
111 | #ifdef USE_ALMOS |
---|
112 | #define PREFIX_OS "almos/" |
---|
113 | #include "almos/hard_config.h" |
---|
114 | #endif |
---|
115 | #ifdef USE_GIET |
---|
116 | #include "hard_config.h" |
---|
117 | #define RAM_TGTID 0 |
---|
118 | #define XCU_TGTID 1 |
---|
119 | #define DMA_TGTID 2 |
---|
120 | #define TTY_TGTID 3 |
---|
121 | #define IOC_TGTID 4 |
---|
122 | #define FBF_TGTID 5 |
---|
123 | #define NIC_TGTID 6 |
---|
124 | #define CMA_TGTID 7 |
---|
125 | #define ROM_TGTID 8 |
---|
126 | #define SIM_TGTID 9 |
---|
127 | |
---|
128 | #define FBF_X_SIZE FBUF_X_SIZE |
---|
129 | #define FBF_Y_SIZE FBUF_Y_SIZE |
---|
130 | |
---|
131 | #define Z_WIDTH3D 1 |
---|
132 | #define Z_SIZE3D (1 << Z_WIDTH3D) |
---|
133 | #define Z_IO3D (Y_IO & ((1 << Z_WIDTH3D) - 1)) |
---|
134 | #define Y_SIZE3D (Y_SIZE / Z_SIZE3D) |
---|
135 | #define Y_WIDTH3D (Y_WIDTH - Z_WIDTH3D) |
---|
136 | #define Y_IO3D (Y_IO >> Z_WIDTH3D) |
---|
137 | #define X_SIZE3D X_SIZE |
---|
138 | #define X_WIDTH3D X_WIDTH |
---|
139 | #define X_IO3D X_IO |
---|
140 | |
---|
141 | #define ELEVATOR_X 0 |
---|
142 | #define ELEVATOR_Y 0 |
---|
143 | #endif |
---|
144 | |
---|
145 | /////////////////////////////////////////////////// |
---|
146 | // Parallelisation |
---|
147 | /////////////////////////////////////////////////// |
---|
148 | |
---|
149 | |
---|
150 | #ifdef _OPENMP |
---|
151 | #include <omp.h> |
---|
152 | #endif |
---|
153 | |
---|
154 | // nluster index (computed from x,y coordinates) |
---|
155 | #ifdef USE_ALMOS |
---|
156 | #define cluster(x,y,z) (z + y * Z_SIZE3D + x * Y_SIZE3D) |
---|
157 | #else |
---|
158 | #define cluster(x,y,z) ((x << (Y_WIDTH3D + Z_WIDTH3D)) + (y << Z_WIDTH3D) + z) |
---|
159 | #endif |
---|
160 | |
---|
161 | |
---|
162 | #define min(x, y) (x < y ? x : y) |
---|
163 | |
---|
164 | /////////////////////////////////////////////////////////// |
---|
165 | // DSPIN parameters |
---|
166 | /////////////////////////////////////////////////////////// |
---|
167 | |
---|
168 | #define dspin_cmd_width 39 |
---|
169 | #define dspin_rsp_width 32 |
---|
170 | |
---|
171 | /////////////////////////////////////////////////////////// |
---|
172 | // VCI parameters |
---|
173 | /////////////////////////////////////////////////////////// |
---|
174 | |
---|
175 | #define vci_cell_width_int 4 |
---|
176 | #define vci_cell_width_ext 8 |
---|
177 | |
---|
178 | #ifdef USE_ALMOS |
---|
179 | #define vci_address_width 32 |
---|
180 | #endif |
---|
181 | #ifdef USE_GIET |
---|
182 | #define vci_address_width 40 |
---|
183 | #endif |
---|
184 | #define vci_plen_width 8 |
---|
185 | #define vci_rerror_width 1 |
---|
186 | #define vci_clen_width 1 |
---|
187 | #define vci_rflag_width 1 |
---|
188 | #define vci_srcid_width 14 |
---|
189 | #define vci_pktid_width 4 |
---|
190 | #define vci_trdid_width 4 |
---|
191 | #define vci_wrplen_width 1 |
---|
192 | |
---|
193 | //////////////////////////////////////////////////////////// |
---|
194 | // Secondary Hardware Parameters |
---|
195 | //////////////////////i///////////////////////////////////// |
---|
196 | |
---|
197 | |
---|
198 | #define XRAM_LATENCY 0 |
---|
199 | |
---|
200 | #define MEMC_WAYS 16 |
---|
201 | #define MEMC_SETS 256 |
---|
202 | |
---|
203 | #define L1_IWAYS 4 |
---|
204 | #define L1_ISETS 64 |
---|
205 | |
---|
206 | #define L1_DWAYS 4 |
---|
207 | #define L1_DSETS 64 |
---|
208 | |
---|
209 | #ifdef USE_ALMOS |
---|
210 | #define FBUF_X_SIZE 1024 |
---|
211 | #define FBUF_Y_SIZE 1024 |
---|
212 | #endif |
---|
213 | |
---|
214 | #ifdef USE_GIET |
---|
215 | #define BDEV_SECTOR_SIZE 512 |
---|
216 | #define BDEV_IMAGE_NAME "virt_hdd.dmg" |
---|
217 | #endif |
---|
218 | #ifdef USE_ALMOS |
---|
219 | #define BDEV_SECTOR_SIZE 4096 |
---|
220 | #define BDEV_IMAGE_NAME PREFIX_OS"hdd-img.bin" |
---|
221 | #endif |
---|
222 | |
---|
223 | #define NIC_RX_NAME PREFIX_OS"nic/rx_packets.txt" |
---|
224 | #define NIC_TX_NAME PREFIX_OS"nic/tx_packets.txt" |
---|
225 | #define NIC_TIMEOUT 10000 |
---|
226 | |
---|
227 | //////////////////////////////////////////////////////////// |
---|
228 | // Software to be loaded in ROM & RAM |
---|
229 | //////////////////////i///////////////////////////////////// |
---|
230 | |
---|
231 | #ifdef USE_ALMOS |
---|
232 | #define soft_name PREFIX_OS"preloader.elf" |
---|
233 | #endif |
---|
234 | #ifdef USE_GIET |
---|
235 | #define soft_name "../../softs/tsar_boot/preloader.elf" |
---|
236 | #endif |
---|
237 | |
---|
238 | //////////////////////////////////////////////////////////// |
---|
239 | // DEBUG Parameters default values |
---|
240 | //////////////////////i///////////////////////////////////// |
---|
241 | |
---|
242 | #define MAX_FROZEN_CYCLES 100000000 |
---|
243 | |
---|
244 | |
---|
245 | //////////////////////////////////////////////////////////////////// |
---|
246 | // TGTID definition in direct space |
---|
247 | // For all components: global TGTID = global SRCID = cluster_index |
---|
248 | //////////////////////////////////////////////////////////////////// |
---|
249 | |
---|
250 | |
---|
251 | ///////////////////////////////////////////////////////// |
---|
252 | // Physical segments definition |
---|
253 | ///////////////////////////////////////////////////////// |
---|
254 | // There is 3 segments replicated in all clusters |
---|
255 | // and 5 specific segments in the "IO" cluster |
---|
256 | // (containing address 0xBF000000) |
---|
257 | ///////////////////////////////////////////////////////// |
---|
258 | |
---|
259 | #ifdef USE_ALMOS |
---|
260 | // 2^19 is the offset for the local id (8 bits for global ID : |
---|
261 | // 1 bit for Memcache or Peripheral, 4 for local peripheral id) |
---|
262 | // (Almos supports 32 bits physical addresses) |
---|
263 | #endif |
---|
264 | |
---|
265 | bool stop_called = false; |
---|
266 | |
---|
267 | ///////////////////////////////// |
---|
268 | int _main(int argc, char *argv[]) |
---|
269 | { |
---|
270 | using namespace sc_core; |
---|
271 | using namespace soclib::caba; |
---|
272 | using namespace soclib::common; |
---|
273 | |
---|
274 | const int64_t max_cycles = 5000000; // Maximum number of cycles simulated in one sc_start call |
---|
275 | int64_t ncycles = 0x7FFFFFFFFFFFFFFF; // simulated cycles |
---|
276 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
277 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
278 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
279 | ssize_t threads_nr = 1; // simulator's threads number |
---|
280 | bool debug_ok = false; // trace activated |
---|
281 | size_t debug_period = 1; // trace period |
---|
282 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
283 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
284 | int64_t debug_from = 0; // trace start cycle |
---|
285 | int64_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
286 | int64_t reset_counters = -1; |
---|
287 | int64_t dump_counters = -1; |
---|
288 | bool do_reset_counters = false; |
---|
289 | bool do_dump_counters = false; |
---|
290 | struct timeval t1, t2; |
---|
291 | uint64_t ms1, ms2; |
---|
292 | |
---|
293 | ////////////// command line arguments ////////////////////// |
---|
294 | if (argc > 1) { |
---|
295 | for (int n = 1; n < argc; n = n + 2) { |
---|
296 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) { |
---|
297 | ncycles = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
298 | } |
---|
299 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) { |
---|
300 | strcpy(disk_name, argv[n + 1]); |
---|
301 | } |
---|
302 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) { |
---|
303 | debug_ok = true; |
---|
304 | debug_from = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
305 | } |
---|
306 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) { |
---|
307 | debug_memc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
308 | #ifdef USE_ALMOS |
---|
309 | assert((debug_memc_id < (X_SIZE3D * Y_SIZE3D)) && |
---|
310 | "debug_memc_id larger than X_SIZE3D * Y_SIZE3D" ); |
---|
311 | #else |
---|
312 | size_t x = debug_memc_id >> (Y_WIDTH3D + Z_WIDTH3D); |
---|
313 | size_t y = (debug_memc_id >> Z_WIDTH3D) & ((1 << Y_WIDTH3D) - 1); |
---|
314 | size_t z = debug_memc_id & ((1 << Z_WIDTH3D) - 1); |
---|
315 | |
---|
316 | assert( (x <= X_SIZE3D) and (y <= Y_SIZE3D) and (z <= Z_SIZE3D) && |
---|
317 | "MEMCID parameter refers a not valid memory cache"); |
---|
318 | #endif |
---|
319 | } |
---|
320 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) { |
---|
321 | debug_proc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
322 | #ifdef USE_ALMOS |
---|
323 | assert((debug_proc_id < (X_SIZE3D * Y_SIZE3D * Z_SIZE3D * NB_PROCS_MAX)) && |
---|
324 | "debug_proc_id larger than X_SIZE3D * Y_SIZE3D * Z_SIZE3D * NB_PROCS"); |
---|
325 | #else |
---|
326 | size_t cluster_xyz = debug_proc_id / NB_PROCS_MAX ; |
---|
327 | size_t x = cluster_xyz >> (Y_WIDTH3D + Z_WIDTH3D); |
---|
328 | size_t y = (cluster_xyz >> Z_WIDTH3D) & ((1 << Y_WIDTH3D) - 1); |
---|
329 | size_t z = cluster_xyz & ((1 << Z_WIDTH3D) - 1); |
---|
330 | |
---|
331 | assert( (x <= X_SIZE3D) and (y <= Y_SIZE3D) and (z <= Z_SIZE3D) && |
---|
332 | "PROCID parameter refers a not valid processor"); |
---|
333 | #endif |
---|
334 | } |
---|
335 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) { |
---|
336 | threads_nr = (ssize_t) strtol(argv[n + 1], NULL, 0); |
---|
337 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
338 | } |
---|
339 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) { |
---|
340 | frozen_cycles = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
341 | } |
---|
342 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) { |
---|
343 | debug_period = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
344 | } |
---|
345 | else if ((strcmp(argv[n], "--reset-counters") == 0) && (n + 1 < argc)) { |
---|
346 | reset_counters = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
347 | do_reset_counters = true; |
---|
348 | } |
---|
349 | else if ((strcmp(argv[n], "--dump-counters") == 0) && (n + 1 < argc)) { |
---|
350 | dump_counters = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
351 | do_dump_counters = true; |
---|
352 | } |
---|
353 | else { |
---|
354 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
355 | std::cout << " The order is not important." << std::endl; |
---|
356 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
357 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
358 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
359 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
360 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
361 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
362 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
363 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
364 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
365 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
366 | exit(0); |
---|
367 | } |
---|
368 | } |
---|
369 | } |
---|
370 | |
---|
371 | // checking hardware parameters |
---|
372 | assert( ( (X_SIZE3D == 1) or (X_SIZE3D == 2) or (X_SIZE3D == 4) or |
---|
373 | (X_SIZE3D == 8) or (X_SIZE3D == 16) ) and |
---|
374 | "The X_SIZE3D parameter must be 1, 2, 4, 8 or 16" ); |
---|
375 | |
---|
376 | assert( ( (Y_SIZE3D == 1) or (Y_SIZE3D == 2) or (Y_SIZE3D == 4) or |
---|
377 | (Y_SIZE3D == 8) or (Y_SIZE3D == 16) ) and |
---|
378 | "The Y_SIZE3D parameter must be 1, 2, 4, 8 or 16" ); |
---|
379 | |
---|
380 | assert( ( (Z_SIZE3D == 1) or (Z_SIZE3D == 2) or (Z_SIZE3D == 4) or |
---|
381 | (Z_SIZE3D == 8) or (Z_SIZE3D == 16) ) and |
---|
382 | "The Z_SIZE3D parameter must be 1, 2, 4, 8 or 16" ); |
---|
383 | |
---|
384 | assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or |
---|
385 | (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and |
---|
386 | "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" ); |
---|
387 | |
---|
388 | assert( (NB_DMA_CHANNELS < 9) and |
---|
389 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
390 | |
---|
391 | assert( (NB_TTY_CHANNELS < 15) and |
---|
392 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
393 | |
---|
394 | assert( (NB_NIC_CHANNELS < 9) and |
---|
395 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
396 | |
---|
397 | #ifdef USE_GIET |
---|
398 | assert( (vci_address_width == 40) and |
---|
399 | "VCI address width with the GIET must be 40 bits" ); |
---|
400 | #endif |
---|
401 | |
---|
402 | #ifdef USE_ALMOS |
---|
403 | assert( (vci_address_width == 32) and |
---|
404 | "VCI address width with ALMOS must be 32 bits" ); |
---|
405 | #endif |
---|
406 | |
---|
407 | |
---|
408 | std::cout << std::endl; |
---|
409 | std::cout << " - X_SIZE3D = " << X_SIZE3D << std::endl; |
---|
410 | std::cout << " - Y_SIZE3D = " << Y_SIZE3D << std::endl; |
---|
411 | std::cout << " - Z_SIZE3D = " << Z_SIZE3D << std::endl; |
---|
412 | std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl; |
---|
413 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
414 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
415 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
416 | std::cout << " - MEMC_WAYS = " << MEMC_WAYS << std::endl; |
---|
417 | std::cout << " - MEMC_SETS = " << MEMC_SETS << std::endl; |
---|
418 | std::cout << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl; |
---|
419 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
420 | |
---|
421 | std::cout << std::endl; |
---|
422 | // Internal and External VCI parameters definition |
---|
423 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
424 | vci_plen_width, |
---|
425 | vci_address_width, |
---|
426 | vci_rerror_width, |
---|
427 | vci_clen_width, |
---|
428 | vci_rflag_width, |
---|
429 | vci_srcid_width, |
---|
430 | vci_pktid_width, |
---|
431 | vci_trdid_width, |
---|
432 | vci_wrplen_width> vci_param_int; |
---|
433 | |
---|
434 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
435 | vci_plen_width, |
---|
436 | vci_address_width, |
---|
437 | vci_rerror_width, |
---|
438 | vci_clen_width, |
---|
439 | vci_rflag_width, |
---|
440 | vci_srcid_width, |
---|
441 | vci_pktid_width, |
---|
442 | vci_trdid_width, |
---|
443 | vci_wrplen_width> vci_param_ext; |
---|
444 | |
---|
445 | #ifdef _OPENMP |
---|
446 | omp_set_dynamic(false); |
---|
447 | omp_set_num_threads(threads_nr); |
---|
448 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
449 | #endif |
---|
450 | |
---|
451 | // Define parameters depending on mesh size |
---|
452 | size_t x_width; |
---|
453 | size_t y_width; |
---|
454 | size_t z_width; |
---|
455 | |
---|
456 | #ifdef USE_ALMOS |
---|
457 | if (X_SIZE3D == 1) x_width = 0; |
---|
458 | else if (X_SIZE3D == 2) x_width = 1; |
---|
459 | else if (X_SIZE3D <= 4) x_width = 2; |
---|
460 | else if (X_SIZE3D <= 8) x_width = 3; |
---|
461 | else x_width = 4; |
---|
462 | |
---|
463 | if (Y_SIZE3D == 1) y_width = 0; |
---|
464 | else if (Y_SIZE3D == 2) y_width = 1; |
---|
465 | else if (Y_SIZE3D <= 4) y_width = 2; |
---|
466 | else if (Y_SIZE3D <= 8) y_width = 3; |
---|
467 | else y_width = 4; |
---|
468 | |
---|
469 | if (Z_SIZE3D == 1) z_width = 0; |
---|
470 | else if (Z_SIZE3D == 2) z_width = 1; |
---|
471 | else if (Z_SIZE3D <= 4) z_width = 2; |
---|
472 | else if (Z_SIZE3D <= 8) z_width = 3; |
---|
473 | else z_width = 4; |
---|
474 | |
---|
475 | #else |
---|
476 | x_width = X_WIDTH3D; |
---|
477 | y_width = Y_WIDTH3D; |
---|
478 | z_width = Z_WIDTH3D; |
---|
479 | |
---|
480 | assert(((X_WIDTH3D + Y_WIDTH3D + Z_WIDTH3D) <= 8) and |
---|
481 | "Up to 256 clusters"); |
---|
482 | |
---|
483 | assert((X_SIZE3D <= (1 << X_WIDTH3D)) and (Y_SIZE3D <= (1 << Y_WIDTH3D)) and |
---|
484 | (Z_SIZE3D <= (1 << Z_WIDTH3D)) and |
---|
485 | "The X_WIDTH3D and Y_WIDTH3D and Z_WIDTH3D parameter are insufficient"); |
---|
486 | |
---|
487 | #endif |
---|
488 | |
---|
489 | ///////////////////// |
---|
490 | // Mapping Tables |
---|
491 | ///////////////////// |
---|
492 | |
---|
493 | // internal network |
---|
494 | MappingTable maptabd(vci_address_width, |
---|
495 | IntTab(x_width + y_width + z_width, 16 - x_width - y_width - z_width), |
---|
496 | IntTab(x_width + y_width + z_width, vci_srcid_width - x_width - y_width - z_width), |
---|
497 | 0x00FF000000); |
---|
498 | |
---|
499 | for (size_t x = 0; x < X_SIZE3D; x++) { |
---|
500 | for (size_t y = 0; y < Y_SIZE3D; y++) { |
---|
501 | for (size_t z = 0; z < Z_SIZE3D; z++) { |
---|
502 | sc_uint<vci_address_width> offset; |
---|
503 | offset = (sc_uint<vci_address_width>) cluster(x,y,z) |
---|
504 | << (vci_address_width - x_width - y_width - z_width); |
---|
505 | |
---|
506 | std::ostringstream si; |
---|
507 | si << "seg_xicu_" << x << "_" << y << "_" << z; |
---|
508 | maptabd.add(Segment(si.str(), SEG_XCU_BASE + offset, SEG_XCU_SIZE, |
---|
509 | IntTab(cluster(x,y,z), XCU_TGTID), false)); |
---|
510 | |
---|
511 | std::ostringstream sd; |
---|
512 | sd << "seg_mdma_" << x << "_" << y << "_" << z; |
---|
513 | maptabd.add(Segment(sd.str(), SEG_DMA_BASE + offset, SEG_DMA_SIZE, |
---|
514 | IntTab(cluster(x,y,z), DMA_TGTID), false)); |
---|
515 | |
---|
516 | std::ostringstream sh; |
---|
517 | sh << "seg_memc_" << x << "_" << y << "_" << z; |
---|
518 | maptabd.add(Segment(sh.str(), SEG_RAM_BASE + offset, SEG_RAM_SIZE, |
---|
519 | IntTab(cluster(x,y,z), RAM_TGTID), true)); |
---|
520 | |
---|
521 | if (x == X_IO3D && y == Y_IO3D && z == Z_IO3D) { |
---|
522 | maptabd.add(Segment("seg_mtty", SEG_TTY_BASE, SEG_TTY_SIZE, |
---|
523 | IntTab(cluster(x,y,z),TTY_TGTID), false)); |
---|
524 | maptabd.add(Segment("seg_fbuf", SEG_FBF_BASE, SEG_FBF_SIZE, |
---|
525 | IntTab(cluster(x,y,z),FBF_TGTID), false)); |
---|
526 | maptabd.add(Segment("seg_bdev", SEG_IOC_BASE, SEG_IOC_SIZE, |
---|
527 | IntTab(cluster(x,y,z),IOC_TGTID), false)); |
---|
528 | maptabd.add(Segment("seg_brom", SEG_ROM_BASE, SEG_ROM_SIZE, |
---|
529 | IntTab(cluster(x,y,z),ROM_TGTID), true)); |
---|
530 | maptabd.add(Segment("seg_mnic", SEG_NIC_BASE, SEG_NIC_SIZE, |
---|
531 | IntTab(cluster(x,y,z),NIC_TGTID), false)); |
---|
532 | maptabd.add(Segment("seg_cdma", SEG_CMA_BASE, SEG_CMA_SIZE, |
---|
533 | IntTab(cluster(x,y,z),CMA_TGTID), false)); |
---|
534 | maptabd.add(Segment("seg_simh", SEG_SIM_BASE, SEG_SIM_SIZE, |
---|
535 | IntTab(cluster(x,y,z),SIM_TGTID), false)); |
---|
536 | } |
---|
537 | } |
---|
538 | } |
---|
539 | } |
---|
540 | std::cout << maptabd << std::endl; |
---|
541 | |
---|
542 | // external network |
---|
543 | MappingTable maptabx(vci_address_width, |
---|
544 | IntTab(x_width + y_width + z_width), |
---|
545 | IntTab(x_width + y_width + z_width), |
---|
546 | 0xFFFF000000ULL); |
---|
547 | |
---|
548 | for (size_t x = 0; x < X_SIZE3D; x++) { |
---|
549 | for (size_t y = 0; y < Y_SIZE3D ; y++) { |
---|
550 | for (size_t z = 0; z < Z_SIZE3D ; z++) { |
---|
551 | |
---|
552 | sc_uint<vci_address_width> offset; |
---|
553 | offset = (sc_uint<vci_address_width>) cluster(x,y,z) |
---|
554 | << (vci_address_width - x_width - y_width - z_width); |
---|
555 | |
---|
556 | std::ostringstream sh; |
---|
557 | sh << "x_seg_memc_" << x << "_" << y << "_" << z; |
---|
558 | |
---|
559 | maptabx.add(Segment(sh.str(), SEG_RAM_BASE + offset, |
---|
560 | SEG_RAM_SIZE, IntTab(cluster(x,y,z)), false)); |
---|
561 | } |
---|
562 | } |
---|
563 | } |
---|
564 | std::cout << maptabx << std::endl; |
---|
565 | |
---|
566 | //////////////////// |
---|
567 | // Signals |
---|
568 | /////////////////// |
---|
569 | |
---|
570 | sc_clock signal_clk("clk"); |
---|
571 | sc_signal<bool> signal_resetn("resetn"); |
---|
572 | |
---|
573 | // Z-axis inter-clusters DSPIN signals |
---|
574 | DspinSignals<dspin_cmd_width>* signal_dspin_z_cmd_inc = |
---|
575 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", Z_SIZE3D + 1); |
---|
576 | DspinSignals<dspin_cmd_width>* signal_dspin_z_cmd_dec = |
---|
577 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", Z_SIZE3D + 1); |
---|
578 | |
---|
579 | DspinSignals<dspin_rsp_width>* signal_dspin_z_rsp_inc = |
---|
580 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", Z_SIZE3D + 1); |
---|
581 | DspinSignals<dspin_rsp_width>* signal_dspin_z_rsp_dec = |
---|
582 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", Z_SIZE3D + 1); |
---|
583 | |
---|
584 | DspinSignals<dspin_cmd_width>* signal_dspin_z_m2p_inc = |
---|
585 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_inc", Z_SIZE3D + 1); |
---|
586 | DspinSignals<dspin_cmd_width>* signal_dspin_z_m2p_dec = |
---|
587 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_dec", Z_SIZE3D + 1); |
---|
588 | |
---|
589 | DspinSignals<dspin_rsp_width>* signal_dspin_z_p2m_inc = |
---|
590 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_inc", Z_SIZE3D + 1); |
---|
591 | DspinSignals<dspin_rsp_width>* signal_dspin_z_p2m_dec = |
---|
592 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_dec", Z_SIZE3D + 1); |
---|
593 | |
---|
594 | DspinSignals<dspin_cmd_width>* signal_dspin_z_cla_inc = |
---|
595 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_inc", Z_SIZE3D + 1); |
---|
596 | DspinSignals<dspin_cmd_width>* signal_dspin_z_cla_dec = |
---|
597 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_dec", Z_SIZE3D + 1); |
---|
598 | |
---|
599 | //////////////////////////// |
---|
600 | // Loader |
---|
601 | //////////////////////////// |
---|
602 | |
---|
603 | soclib::common::Loader loader(soft_name); |
---|
604 | |
---|
605 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
606 | proc_iss::set_loader(loader); |
---|
607 | |
---|
608 | //////////////////////////// |
---|
609 | // Clusters construction |
---|
610 | //////////////////////////// |
---|
611 | |
---|
612 | TsarSuperCluster<dspin_cmd_width, |
---|
613 | dspin_rsp_width, |
---|
614 | vci_param_int, |
---|
615 | vci_param_ext> * clusters[Z_SIZE3D]; |
---|
616 | |
---|
617 | for (size_t z = 0; z < Z_SIZE3D; z++) { |
---|
618 | std::cout << std::endl; |
---|
619 | std::cout << "SuperCluster_" << z << std::endl; |
---|
620 | |
---|
621 | std::ostringstream sc; |
---|
622 | sc << "scluster_" << z; |
---|
623 | clusters[z] = new TsarSuperCluster<dspin_cmd_width, |
---|
624 | dspin_rsp_width, |
---|
625 | vci_param_int, |
---|
626 | vci_param_ext> |
---|
627 | ( |
---|
628 | sc.str().c_str(), |
---|
629 | NB_PROCS_MAX, |
---|
630 | NB_TTY_CHANNELS, |
---|
631 | NB_DMA_CHANNELS, |
---|
632 | X_SIZE3D, |
---|
633 | Y_SIZE3D, |
---|
634 | z, |
---|
635 | ELEVATOR_X, |
---|
636 | ELEVATOR_Y, |
---|
637 | maptabd, |
---|
638 | maptabx, |
---|
639 | x_width, |
---|
640 | y_width, |
---|
641 | z_width, |
---|
642 | P_WIDTH, |
---|
643 | vci_srcid_width, |
---|
644 | RAM_TGTID, |
---|
645 | XCU_TGTID, |
---|
646 | DMA_TGTID, |
---|
647 | FBF_TGTID, |
---|
648 | TTY_TGTID, |
---|
649 | ROM_TGTID, |
---|
650 | NIC_TGTID, |
---|
651 | CMA_TGTID, |
---|
652 | IOC_TGTID, |
---|
653 | SIM_TGTID, |
---|
654 | MEMC_WAYS, |
---|
655 | MEMC_SETS, |
---|
656 | L1_IWAYS, |
---|
657 | L1_ISETS, |
---|
658 | L1_DWAYS, |
---|
659 | L1_DSETS, |
---|
660 | IRQ_PER_PROCESSOR, |
---|
661 | XRAM_LATENCY, |
---|
662 | X_IO3D, |
---|
663 | Y_IO3D, |
---|
664 | Z_IO3D, |
---|
665 | FBF_X_SIZE, |
---|
666 | FBF_Y_SIZE, |
---|
667 | disk_name, |
---|
668 | BDEV_SECTOR_SIZE, |
---|
669 | NB_NIC_CHANNELS, |
---|
670 | nic_rx_name, |
---|
671 | nic_tx_name, |
---|
672 | NIC_TIMEOUT, |
---|
673 | NB_CMA_CHANNELS, |
---|
674 | loader, |
---|
675 | frozen_cycles, |
---|
676 | debug_from, |
---|
677 | debug_ok, |
---|
678 | debug_ok |
---|
679 | ); |
---|
680 | |
---|
681 | } |
---|
682 | |
---|
683 | /////////////////////////////////////////////////////////////// |
---|
684 | // Net-list |
---|
685 | /////////////////////////////////////////////////////////////// |
---|
686 | |
---|
687 | for (int z = 0; z < Z_SIZE3D; z++) { |
---|
688 | // Clock & RESET |
---|
689 | clusters[z]->p_clk (signal_clk); |
---|
690 | clusters[z]->p_resetn (signal_resetn); |
---|
691 | |
---|
692 | // Inter Clusters Z connections |
---|
693 | #define UP 0 |
---|
694 | #define DOWN 1 |
---|
695 | clusters[z]->p_cmd_out[UP] (signal_dspin_z_cmd_inc[z + 1]); |
---|
696 | clusters[z]->p_cmd_in[DOWN] (signal_dspin_z_cmd_inc[z]); |
---|
697 | clusters[z]->p_cmd_in[UP] (signal_dspin_z_cmd_dec[z + 1]); |
---|
698 | clusters[z]->p_cmd_out[DOWN] (signal_dspin_z_cmd_dec[z]); |
---|
699 | |
---|
700 | clusters[z]->p_rsp_out[UP] (signal_dspin_z_rsp_inc[z + 1]); |
---|
701 | clusters[z]->p_rsp_in[DOWN] (signal_dspin_z_rsp_inc[z]); |
---|
702 | clusters[z]->p_rsp_in[UP] (signal_dspin_z_rsp_dec[z + 1]); |
---|
703 | clusters[z]->p_rsp_out[DOWN] (signal_dspin_z_rsp_dec[z]); |
---|
704 | |
---|
705 | clusters[z]->p_m2p_out[UP] (signal_dspin_z_m2p_inc[z + 1]); |
---|
706 | clusters[z]->p_m2p_in[DOWN] (signal_dspin_z_m2p_inc[z]); |
---|
707 | clusters[z]->p_m2p_in[UP] (signal_dspin_z_m2p_dec[z + 1]); |
---|
708 | clusters[z]->p_m2p_out[DOWN] (signal_dspin_z_m2p_dec[z]); |
---|
709 | |
---|
710 | clusters[z]->p_p2m_out[UP] (signal_dspin_z_p2m_inc[z + 1]); |
---|
711 | clusters[z]->p_p2m_in[DOWN] (signal_dspin_z_p2m_inc[z]); |
---|
712 | clusters[z]->p_p2m_in[UP] (signal_dspin_z_p2m_dec[z + 1]); |
---|
713 | clusters[z]->p_p2m_out[DOWN] (signal_dspin_z_p2m_dec[z]); |
---|
714 | |
---|
715 | clusters[z]->p_cla_out[UP] (signal_dspin_z_cla_inc[z + 1]); |
---|
716 | clusters[z]->p_cla_in[DOWN] (signal_dspin_z_cla_inc[z]); |
---|
717 | clusters[z]->p_cla_in[UP] (signal_dspin_z_cla_dec[z + 1]); |
---|
718 | clusters[z]->p_cla_out[DOWN] (signal_dspin_z_cla_dec[z]); |
---|
719 | } |
---|
720 | std::cout << std::endl << "Z connections done" << std::endl; |
---|
721 | |
---|
722 | #ifdef WT_IDL |
---|
723 | std::list<VciCcVCacheWrapper<vci_param_int, |
---|
724 | dspin_cmd_width, |
---|
725 | dspin_rsp_width, |
---|
726 | GdbServer<Mips32ElIss> > * > l1_caches; |
---|
727 | |
---|
728 | for (int x = 0; x < X_SIZE3D; x++) { |
---|
729 | for (int y = 0; y < Y_SIZE3D; y++) { |
---|
730 | for (int proc = 0; proc < NB_PROCS_MAX; proc++) { |
---|
731 | l1_caches.push_back(clusters[x][y]->proc[proc]); |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | for (int x = 0; x < X_SIZE3D; x++) { |
---|
737 | for (int y = 0; y < Y_SIZE3D; y++) { |
---|
738 | clusters[x][y]->memc->set_vcache_list(l1_caches); |
---|
739 | } |
---|
740 | } |
---|
741 | #endif |
---|
742 | |
---|
743 | |
---|
744 | // #define SC_TRACE |
---|
745 | #ifdef SC_TRACE |
---|
746 | sc_trace_file * tf = sc_create_vcd_trace_file("my_trace_file"); |
---|
747 | |
---|
748 | #if 0 |
---|
749 | for (int x = 0; x < X_SIZE3D - 1; x++) { |
---|
750 | for (int y = 0; y < Y_SIZE3D; y++) { |
---|
751 | for (int k = 0; k < 3; k++) { |
---|
752 | signal_dspin_h_cmd_inc[x][y][k].trace(tf, "dspin_h_cmd_inc"); |
---|
753 | signal_dspin_h_cmd_dec[x][y][k].trace(tf, "dspin_h_cmd_dec"); |
---|
754 | } |
---|
755 | |
---|
756 | for (int k = 0; k < 2; k++) { |
---|
757 | signal_dspin_h_rsp_inc[x][y][k].trace(tf, "dspin_h_rsp_inc"); |
---|
758 | signal_dspin_h_rsp_dec[x][y][k].trace(tf, "dspin_h_rsp_dec"); |
---|
759 | } |
---|
760 | } |
---|
761 | } |
---|
762 | |
---|
763 | for (int y = 0; y < Y_SIZE3D - 1; y++) { |
---|
764 | for (int x = 0; x < X_SIZE3D; x++) { |
---|
765 | for (int k = 0; k < 3; k++) { |
---|
766 | signal_dspin_v_cmd_inc[x][y][k].trace(tf, "dspin_v_cmd_inc"); |
---|
767 | signal_dspin_v_cmd_dec[x][y][k].trace(tf, "dspin_v_cmd_dec"); |
---|
768 | } |
---|
769 | |
---|
770 | for (int k = 0; k < 2; k++) { |
---|
771 | signal_dspin_v_rsp_inc[x][y][k].trace(tf, "dspin_v_rsp_inc"); |
---|
772 | signal_dspin_v_rsp_dec[x][y][k].trace(tf, "dspin_v_rsp_dec"); |
---|
773 | } |
---|
774 | } |
---|
775 | } |
---|
776 | |
---|
777 | for (int x = 0; x < (X_SIZE3D); x++) { |
---|
778 | for (int y = 0; y < Y_SIZE3D; y++) { |
---|
779 | std::ostringstream signame; |
---|
780 | signame << "cluster" << x << "_" << y; |
---|
781 | clusters[x][y]->trace(tf, signame.str()); |
---|
782 | } |
---|
783 | } |
---|
784 | #endif |
---|
785 | for (size_t z = 0; z < (Z_SIZE3D); z++) { |
---|
786 | clusters[z]->trace(tf); |
---|
787 | } |
---|
788 | #endif |
---|
789 | |
---|
790 | |
---|
791 | //////////////////////////////////////////////////////// |
---|
792 | // Simulation |
---|
793 | /////////////////////////////////////////////////////// |
---|
794 | |
---|
795 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
796 | signal_resetn = false; |
---|
797 | |
---|
798 | // set network boundaries signals default values |
---|
799 | // for all boundary clusters |
---|
800 | |
---|
801 | signal_dspin_z_cmd_inc[0].write = false; |
---|
802 | signal_dspin_z_cmd_inc[0].read = true; |
---|
803 | signal_dspin_z_cmd_dec[0].write = false; |
---|
804 | signal_dspin_z_cmd_dec[0].read = true; |
---|
805 | signal_dspin_z_cmd_inc[Z_SIZE3D].write = false; |
---|
806 | signal_dspin_z_cmd_inc[Z_SIZE3D].read = true; |
---|
807 | signal_dspin_z_cmd_dec[Z_SIZE3D].write = false; |
---|
808 | signal_dspin_z_cmd_dec[Z_SIZE3D].read = true; |
---|
809 | |
---|
810 | signal_dspin_z_rsp_inc[0].write = false; |
---|
811 | signal_dspin_z_rsp_inc[0].read = true; |
---|
812 | signal_dspin_z_rsp_dec[0].write = false; |
---|
813 | signal_dspin_z_rsp_dec[0].read = true; |
---|
814 | signal_dspin_z_rsp_inc[Z_SIZE3D].write = false; |
---|
815 | signal_dspin_z_rsp_inc[Z_SIZE3D].read = true; |
---|
816 | signal_dspin_z_rsp_dec[Z_SIZE3D].write = false; |
---|
817 | signal_dspin_z_rsp_dec[Z_SIZE3D].read = true; |
---|
818 | |
---|
819 | signal_dspin_z_p2m_inc[0].write = false; |
---|
820 | signal_dspin_z_p2m_inc[0].read = true; |
---|
821 | signal_dspin_z_p2m_dec[0].write = false; |
---|
822 | signal_dspin_z_p2m_dec[0].read = true; |
---|
823 | signal_dspin_z_p2m_inc[Z_SIZE3D].write = false; |
---|
824 | signal_dspin_z_p2m_inc[Z_SIZE3D].read = true; |
---|
825 | signal_dspin_z_p2m_dec[Z_SIZE3D].write = false; |
---|
826 | signal_dspin_z_p2m_dec[Z_SIZE3D].read = true; |
---|
827 | |
---|
828 | signal_dspin_z_m2p_inc[0].write = false; |
---|
829 | signal_dspin_z_m2p_inc[0].read = true; |
---|
830 | signal_dspin_z_m2p_dec[0].write = false; |
---|
831 | signal_dspin_z_m2p_dec[0].read = true; |
---|
832 | signal_dspin_z_m2p_inc[Z_SIZE3D].write = false; |
---|
833 | signal_dspin_z_m2p_inc[Z_SIZE3D].read = true; |
---|
834 | signal_dspin_z_m2p_dec[Z_SIZE3D].write = false; |
---|
835 | signal_dspin_z_m2p_dec[Z_SIZE3D].read = true; |
---|
836 | |
---|
837 | signal_dspin_z_cla_inc[0].write = false; |
---|
838 | signal_dspin_z_cla_inc[0].read = true; |
---|
839 | signal_dspin_z_cla_dec[0].write = false; |
---|
840 | signal_dspin_z_cla_dec[0].read = true; |
---|
841 | signal_dspin_z_cla_inc[Z_SIZE3D].write = false; |
---|
842 | signal_dspin_z_cla_inc[Z_SIZE3D].read = true; |
---|
843 | signal_dspin_z_cla_dec[Z_SIZE3D].write = false; |
---|
844 | signal_dspin_z_cla_dec[Z_SIZE3D].read = true; |
---|
845 | |
---|
846 | for (int z = 0; z < Z_SIZE3D; z++) { |
---|
847 | clusters[z]->reset(); |
---|
848 | } |
---|
849 | |
---|
850 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
851 | signal_resetn = true; |
---|
852 | |
---|
853 | if (debug_ok) { |
---|
854 | if (gettimeofday(&t1, NULL) != 0) { |
---|
855 | perror("gettimeofday"); |
---|
856 | return EXIT_FAILURE; |
---|
857 | } |
---|
858 | |
---|
859 | for (int64_t n = 1; n < ncycles && !stop_called; n++) { |
---|
860 | if ((n % max_cycles) == 0) { |
---|
861 | |
---|
862 | if (gettimeofday(&t2, NULL) != 0) { |
---|
863 | perror("gettimeofday"); |
---|
864 | return EXIT_FAILURE; |
---|
865 | } |
---|
866 | |
---|
867 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
868 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
869 | std::cerr << "platform clock frequency " << (double) 5000000 / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
870 | |
---|
871 | if (gettimeofday(&t1, NULL) != 0) |
---|
872 | { |
---|
873 | perror("gettimeofday"); |
---|
874 | return EXIT_FAILURE; |
---|
875 | } |
---|
876 | } |
---|
877 | |
---|
878 | |
---|
879 | if ((n > debug_from) and (n % debug_period == 0)) { |
---|
880 | std::cout << "****************** cycle " << std::dec << n ; |
---|
881 | std::cout << "************************************************" << std::endl; |
---|
882 | } |
---|
883 | |
---|
884 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
885 | } |
---|
886 | } |
---|
887 | else { |
---|
888 | int64_t n = 0; |
---|
889 | while (!stop_called && n != ncycles) { |
---|
890 | if (gettimeofday(&t1, NULL) != 0) { |
---|
891 | perror("gettimeofday"); |
---|
892 | return EXIT_FAILURE; |
---|
893 | } |
---|
894 | int64_t nb_cycles = min(max_cycles, ncycles - n); |
---|
895 | if (do_reset_counters) { |
---|
896 | nb_cycles = min(nb_cycles, reset_counters - n); |
---|
897 | } |
---|
898 | if (do_dump_counters) { |
---|
899 | nb_cycles = min(nb_cycles, dump_counters - n); |
---|
900 | } |
---|
901 | |
---|
902 | sc_start(sc_core::sc_time(nb_cycles, SC_NS)); |
---|
903 | n += nb_cycles; |
---|
904 | |
---|
905 | if (gettimeofday(&t2, NULL) != 0) { |
---|
906 | perror("gettimeofday"); |
---|
907 | return EXIT_FAILURE; |
---|
908 | } |
---|
909 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
910 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
911 | std::cerr << std::dec << "cycle " << n << " platform clock frequency " << (double) nb_cycles / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
912 | } |
---|
913 | } |
---|
914 | |
---|
915 | |
---|
916 | return EXIT_SUCCESS; |
---|
917 | } |
---|
918 | |
---|
919 | |
---|
920 | void handler(int dummy = 0) { |
---|
921 | stop_called = true; |
---|
922 | sc_stop(); |
---|
923 | } |
---|
924 | |
---|
925 | void voidhandler(int dummy = 0) {} |
---|
926 | |
---|
927 | int sc_main (int argc, char *argv[]) { |
---|
928 | signal(SIGINT, handler); |
---|
929 | //signal(SIGPIPE, voidhandler); |
---|
930 | |
---|
931 | try { |
---|
932 | return _main(argc, argv); |
---|
933 | } catch (std::exception &e) { |
---|
934 | std::cout << e.what() << std::endl; |
---|
935 | } |
---|
936 | catch (...) { |
---|
937 | std::cout << "Unknown exception occured" << std::endl; |
---|
938 | throw; |
---|
939 | } |
---|
940 | return 1; |
---|
941 | } |
---|
942 | |
---|
943 | |
---|
944 | // Local Variables: |
---|
945 | // tab-width: 3 |
---|
946 | // c-basic-offset: 3 |
---|
947 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
948 | // indent-tabs-mode: nil |
---|
949 | // End: |
---|
950 | |
---|
951 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|