1 | ///////////////////////////////////////////////////////////////////////// |
---|
2 | // File: top.cpp |
---|
3 | // Author: Alain Greiner |
---|
4 | // Copyright: UPMC/LIP6 |
---|
5 | // Date : august 2012 |
---|
6 | // This program is released under the GNU public license |
---|
7 | ///////////////////////////////////////////////////////////////////////// |
---|
8 | // This file define a generic TSAR architecture with virtual memory. |
---|
9 | // The physical address space is 32 bits. |
---|
10 | // The number of clusters cannot be larger than 256. |
---|
11 | // The number of processors per cluster cannot be larger than 8. |
---|
12 | // |
---|
13 | // - It uses four dspin_local_crossbar per cluster as local interconnect |
---|
14 | // - It uses two virtual_dspin routers per cluster as global interconnect |
---|
15 | // - It uses the vci_cc_vcache_wrapper |
---|
16 | // - It uses the vci_mem_cache |
---|
17 | // - It contains one vci_xicu and one vci_multi_dma per cluster. |
---|
18 | // |
---|
19 | // All clusters are identical, but the cluster containing address |
---|
20 | // 0xBFC00000 (called io_cluster), contains 5 extra components: |
---|
21 | // - the boot rom (BROM) |
---|
22 | // - the disk controller (BDEV) |
---|
23 | // - the multi-channel network controller (MNIC) |
---|
24 | // - the multi-channel tty controller (MTTY) |
---|
25 | // - the frame buffer controller (FBUF) |
---|
26 | // |
---|
27 | // It is build with one single component implementing a cluster: |
---|
28 | // The Tsarv4ClusterMmu component is defined in files |
---|
29 | // tsarv4_cluster_mmu.* (with * = cpp, h, sd) |
---|
30 | // |
---|
31 | // The IRQs are connected to XICUs as follow: |
---|
32 | // - The IRQ_IN[0] to IRQ_IN[7] ports are not used in all clusters. |
---|
33 | // - The DMA IRQs are connected to IRQ_IN[8] to IRQ_IN[15] in all clusters. |
---|
34 | // - The TTY IRQs are connected to IRQ_IN[16] to IRQ_IN[30] in I/O cluster. |
---|
35 | // - The BDEV IRQ is connected to IRQ_IN[31] in I/O cluster. |
---|
36 | // |
---|
37 | // The main hardware parameters must be defined in the hard_config.h file : |
---|
38 | // - CLUSTER_X : number of clusters in a row (power of 2) |
---|
39 | // - CLUSTER_Y : number of clusters in a column (power of 2) |
---|
40 | // - CLUSTER_SIZE : size of the segment allocated to a cluster |
---|
41 | // - NB_PROCS_MAX : number of processors per cluster (power of 2) |
---|
42 | // - NB_DMAS_MAX : number of DMA channels per cluster (< 9) |
---|
43 | // - NB_TTYS : number of TTY channels in I/O cluster (< 16) |
---|
44 | // - NB_NICS : number of NIC channels in I/O cluster (< 9) |
---|
45 | // |
---|
46 | // Some secondary hardware parameters must be defined in this top.cpp file: |
---|
47 | // - XRAM_LATENCY : external ram latency |
---|
48 | // - MEMC_WAYS : L2 cache number of ways |
---|
49 | // - MEMC_SETS : L2 cache number of sets |
---|
50 | // - L1_IWAYS |
---|
51 | // - L1_ISETS |
---|
52 | // - L1_DWAYS |
---|
53 | // - L1_DSETS |
---|
54 | // - FBUF_X_SIZE : width of frame buffer (pixels) |
---|
55 | // - FBUF_Y_SIZE : heigth of frame buffer (lines) |
---|
56 | // - BDEV_SECTOR_SIZE : block size for block drvice |
---|
57 | // - BDEV_IMAGE_NAME : file pathname for block device |
---|
58 | // - NIC_RX_NAME : file pathname for NIC received packets |
---|
59 | // - NIC_TX_NAME : file pathname for NIC transmited packets |
---|
60 | // - NIC_TIMEOUT : max number of cycles before closing a container |
---|
61 | // |
---|
62 | // General policy for 32 bits physical address decoding: |
---|
63 | // All segments base addresses are multiple of 64 Kbytes |
---|
64 | // Therefore the 16 address MSB bits completely define the target: |
---|
65 | // The (x_width + y_width) MSB bits (left aligned) define |
---|
66 | // the cluster index, and the 8 LSB bits define the local index: |
---|
67 | // | X_ID | Y_ID |---| LADR | OFFSET | |
---|
68 | // |x_width|y_width|---| 8 | 16 | |
---|
69 | // |
---|
70 | // General policy for hardware component indexing: |
---|
71 | // Each component is identified by (x_id,y_id,l_id) tuple. |
---|
72 | // | X_ID | Y_ID | L_ID | |
---|
73 | // |x_width|y_width| 4 | |
---|
74 | ///////////////////////////////////////////////////////////////////////// |
---|
75 | |
---|
76 | #include <systemc> |
---|
77 | #include <sys/time.h> |
---|
78 | #include <iostream> |
---|
79 | #include <sstream> |
---|
80 | #include <cstdlib> |
---|
81 | #include <cstdarg> |
---|
82 | #include <stdint.h> |
---|
83 | |
---|
84 | #include "gdbserver.h" |
---|
85 | #include "mapping_table.h" |
---|
86 | #include "tsarv5_cluster_mmu.h" |
---|
87 | #include "alloc_elems.h" |
---|
88 | |
---|
89 | /////////////////////////////////////////////////// |
---|
90 | // OS |
---|
91 | /////////////////////////////////////////////////// |
---|
92 | #define USE_ALMOS 0 |
---|
93 | |
---|
94 | #define almos_bootloader_pathname "bootloader.bin" |
---|
95 | #define almos_kernel_pathname "kernel-soclib.bin@0xbfc10000:D" |
---|
96 | #define almos_archinfo_pathname "arch-info.bin@0xBFC08000:D" |
---|
97 | |
---|
98 | /////////////////////////////////////////////////// |
---|
99 | // Parallelisation |
---|
100 | /////////////////////////////////////////////////// |
---|
101 | #define USE_OPENMP 0 |
---|
102 | |
---|
103 | #if USE_OPENMP |
---|
104 | #include <omp.h> |
---|
105 | #endif |
---|
106 | |
---|
107 | // cluster index (computed from x,y coordinates) |
---|
108 | #define cluster(x,y) (y + CLUSTER_Y*x) |
---|
109 | |
---|
110 | /////////////////////////////////////////////////////////// |
---|
111 | // DSPIN parameters |
---|
112 | /////////////////////////////////////////////////////////// |
---|
113 | |
---|
114 | #define cmd_width 40 |
---|
115 | #define rsp_width 33 |
---|
116 | |
---|
117 | /////////////////////////////////////////////////////////// |
---|
118 | // VCI parameters |
---|
119 | /////////////////////////////////////////////////////////// |
---|
120 | |
---|
121 | #define cell_width 4 |
---|
122 | #define address_width 32 |
---|
123 | #define plen_width 8 |
---|
124 | #define error_width 2 |
---|
125 | #define clen_width 1 |
---|
126 | #define rflag_width 1 |
---|
127 | #define srcid_width 14 |
---|
128 | #define pktid_width 4 |
---|
129 | #define trdid_width 4 |
---|
130 | #define wrplen_width 1 |
---|
131 | |
---|
132 | //////////////////////////////////////////////////////////// |
---|
133 | // Main Hardware Parameters values |
---|
134 | //////////////////////i///////////////////////////////////// |
---|
135 | |
---|
136 | #include "hard_config.h" |
---|
137 | |
---|
138 | //////////////////////////////////////////////////////////// |
---|
139 | // Secondary Hardware Parameters values |
---|
140 | //////////////////////i///////////////////////////////////// |
---|
141 | |
---|
142 | #define XRAM_LATENCY 0 |
---|
143 | |
---|
144 | #define MEMC_WAYS 16 |
---|
145 | #define MEMC_SETS 256 |
---|
146 | |
---|
147 | #define L1_IWAYS 4 |
---|
148 | #define L1_ISETS 64 |
---|
149 | |
---|
150 | #define L1_DWAYS 4 |
---|
151 | #define L1_DSETS 64 |
---|
152 | |
---|
153 | #define FBUF_X_SIZE 128 |
---|
154 | #define FBUF_Y_SIZE 128 |
---|
155 | |
---|
156 | #define BDEV_SECTOR_SIZE 512 |
---|
157 | #define BDEV_IMAGE_NAME "giet_vm/display/images.raw" |
---|
158 | |
---|
159 | #define NIC_RX_NAME "giet_vm/nic/rx_data.txt" |
---|
160 | #define NIC_TX_NAME "giet_vm/nic/tx_data.txt" |
---|
161 | #define NIC_TIMEOUT 10000 |
---|
162 | |
---|
163 | //////////////////////////////////////////////////////////// |
---|
164 | // Software to be loaded in ROM & RAM |
---|
165 | //////////////////////i///////////////////////////////////// |
---|
166 | |
---|
167 | #define BOOT_SOFT_NAME "giet_vm/soft.elf" |
---|
168 | |
---|
169 | //////////////////////////////////////////////////////////// |
---|
170 | // DEBUG Parameters default values |
---|
171 | //////////////////////i///////////////////////////////////// |
---|
172 | |
---|
173 | #define MAX_FROZEN_CYCLES 10000 |
---|
174 | |
---|
175 | #define TRACE_MEMC_ID 1000000 |
---|
176 | #define TRACE_PROC_ID 1000000 |
---|
177 | |
---|
178 | ///////////////////////////////////////////////////////// |
---|
179 | // Physical segments definition |
---|
180 | ///////////////////////////////////////////////////////// |
---|
181 | // There is 3 segments replicated in all clusters |
---|
182 | // and 5 specific segments in the "IO" cluster |
---|
183 | // (containing address 0xBF000000) |
---|
184 | ///////////////////////////////////////////////////////// |
---|
185 | |
---|
186 | // specific segments in "IO" cluster : absolute physical address |
---|
187 | |
---|
188 | #define BROM_BASE 0xBFC00000 |
---|
189 | #define BROM_SIZE 0x00100000 // 1 Mbytes |
---|
190 | |
---|
191 | #define FBUF_BASE 0xBFD00000 |
---|
192 | #define FBUF_SIZE 0x00200000 // 2 Mbytes |
---|
193 | |
---|
194 | #define BDEV_BASE 0xBFF10000 |
---|
195 | #define BDEV_SIZE 0x00001000 // 4 Kbytes |
---|
196 | |
---|
197 | #define MTTY_BASE 0xBFF20000 |
---|
198 | #define MTTY_SIZE 0x00001000 // 4 Kbytes |
---|
199 | |
---|
200 | #define MNIC_BASE 0xBFF80000 |
---|
201 | #define MNIC_SIZE 0x00002000 * (NB_NICS + 1) // 8 Kbytes per channel + 8 Kbytes |
---|
202 | |
---|
203 | // replicated segments : address is incremented by a cluster offset |
---|
204 | // offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
205 | |
---|
206 | #define MEMC_BASE 0x00000000 |
---|
207 | #define MEMC_SIZE 0x00C00000 // 12 Mbytes |
---|
208 | |
---|
209 | #define XICU_BASE 0x00F00000 |
---|
210 | #define XICU_SIZE 0x00001000 // 4 Kbytes |
---|
211 | |
---|
212 | #define CDMA_BASE 0x00F30000 |
---|
213 | #define CDMA_SIZE 0x00001000 * NB_DMAS_MAX // 4 Kbytes per channel |
---|
214 | |
---|
215 | //////////////////////////////////////////////////////////////////// |
---|
216 | // TGTID definition in direct space |
---|
217 | // For all components: global TGTID = global SRCID = cluster_index |
---|
218 | //////////////////////////////////////////////////////////////////// |
---|
219 | |
---|
220 | #define MEMC_TGTID 0 |
---|
221 | #define XICU_TGTID 1 |
---|
222 | #define CDMA_TGTID 2 |
---|
223 | #define MTTY_TGTID 3 |
---|
224 | #define FBUF_TGTID 4 |
---|
225 | #define BROM_TGTID 5 |
---|
226 | #define BDEV_TGTID 6 |
---|
227 | #define MNIC_TGTID 7 |
---|
228 | |
---|
229 | ///////////////////////////////// |
---|
230 | int _main(int argc, char *argv[]) |
---|
231 | { |
---|
232 | using namespace sc_core; |
---|
233 | using namespace soclib::caba; |
---|
234 | using namespace soclib::common; |
---|
235 | |
---|
236 | |
---|
237 | char soft_name[256] = BOOT_SOFT_NAME; // pathname to binary code |
---|
238 | size_t ncycles = 1000000000; // simulated cycles |
---|
239 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
240 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
241 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
242 | ssize_t threads_nr = 1; // simulator's threads number |
---|
243 | bool debug_ok = false; // trace activated |
---|
244 | size_t debug_period = 1; // trace period |
---|
245 | size_t debug_memc_id = TRACE_MEMC_ID; // index of memc to be traced (cluster_id) |
---|
246 | size_t debug_proc_id = TRACE_PROC_ID; // index of proc to be traced |
---|
247 | uint32_t debug_from = 0; // trace start cycle |
---|
248 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
249 | |
---|
250 | ////////////// command line arguments ////////////////////// |
---|
251 | if (argc > 1) |
---|
252 | { |
---|
253 | for (int n = 1; n < argc; n = n + 2) |
---|
254 | { |
---|
255 | if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc)) |
---|
256 | { |
---|
257 | ncycles = atoi(argv[n+1]); |
---|
258 | } |
---|
259 | else if ((strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) ) |
---|
260 | { |
---|
261 | strcpy(soft_name, argv[n+1]); |
---|
262 | } |
---|
263 | else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) ) |
---|
264 | { |
---|
265 | strcpy(disk_name, argv[n+1]); |
---|
266 | } |
---|
267 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) ) |
---|
268 | { |
---|
269 | debug_ok = true; |
---|
270 | debug_from = atoi(argv[n+1]); |
---|
271 | } |
---|
272 | else if ((strcmp(argv[n],"-MEMCID") == 0) && (n+1<argc) ) |
---|
273 | { |
---|
274 | debug_memc_id = atoi(argv[n+1]); |
---|
275 | assert( (debug_memc_id < (CLUSTER_X*CLUSTER_Y) ) && |
---|
276 | "debug_memc_id larger than XMAX * YMAX" ); |
---|
277 | } |
---|
278 | else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) ) |
---|
279 | { |
---|
280 | debug_proc_id = atoi(argv[n+1]); |
---|
281 | assert( (debug_proc_id < (CLUSTER_X * CLUSTER_Y * NB_PROCS_MAX) ) && |
---|
282 | "debug_proc_id larger than XMAX * YMAX * NB_PROCS" ); |
---|
283 | } |
---|
284 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n+1) < argc)) |
---|
285 | { |
---|
286 | threads_nr = atoi(argv[n+1]); |
---|
287 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
288 | } |
---|
289 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc)) |
---|
290 | { |
---|
291 | frozen_cycles = atoi(argv[n+1]); |
---|
292 | } |
---|
293 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n+1 < argc)) |
---|
294 | { |
---|
295 | debug_period = atoi(argv[n+1]); |
---|
296 | } |
---|
297 | else |
---|
298 | { |
---|
299 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
300 | std::cout << " The order is not important." << std::endl; |
---|
301 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
302 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
303 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
304 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
305 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
306 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
307 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
308 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
309 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
310 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
311 | exit(0); |
---|
312 | } |
---|
313 | } |
---|
314 | } |
---|
315 | |
---|
316 | // checking hardware parameters |
---|
317 | assert( ( (CLUSTER_X == 1) or (CLUSTER_X == 2) or (CLUSTER_X == 4) or |
---|
318 | (CLUSTER_X == 8) or (CLUSTER_X == 16) ) and |
---|
319 | "The CLUSTER_X parameter must be 1, 2, 4, 8 or 16" ); |
---|
320 | |
---|
321 | assert( ( (CLUSTER_Y == 1) or (CLUSTER_Y == 2) or (CLUSTER_Y == 4) or |
---|
322 | (CLUSTER_Y == 8) or (CLUSTER_Y == 16) ) and |
---|
323 | "The CLUSTER_Y parameter must be 1, 2, 4, 8 or 16" ); |
---|
324 | |
---|
325 | assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or |
---|
326 | (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and |
---|
327 | "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" ); |
---|
328 | |
---|
329 | assert( (NB_DMAS_MAX < 9) and |
---|
330 | "The NB_DMAS_MAX parameter must be smaller than 9" ); |
---|
331 | |
---|
332 | assert( (NB_TTYS < 15) and |
---|
333 | "The NB_TTYS parameter must be smaller than 15" ); |
---|
334 | |
---|
335 | assert( (NB_NICS < 9) and |
---|
336 | "The NB_NICS parameter must be smaller than 9" ); |
---|
337 | |
---|
338 | std::cout << std::endl; |
---|
339 | std::cout << " - CLUSTER_X = " << CLUSTER_X << std::endl; |
---|
340 | std::cout << " - CLUSTER_Y = " << CLUSTER_Y << std::endl; |
---|
341 | std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl; |
---|
342 | std::cout << " - NB_DMAS_MAX = " << NB_DMAS_MAX << std::endl; |
---|
343 | std::cout << " - NB_TTYS = " << NB_TTYS << std::endl; |
---|
344 | std::cout << " - NB_NICS = " << NB_NICS << std::endl; |
---|
345 | std::cout << " - MEMC_WAYS = " << MEMC_WAYS << std::endl; |
---|
346 | std::cout << " - MEMC_SETS = " << MEMC_SETS << std::endl; |
---|
347 | std::cout << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl; |
---|
348 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
349 | |
---|
350 | std::cout << std::endl; |
---|
351 | |
---|
352 | #if USE_OPENMP |
---|
353 | omp_set_dynamic(false); |
---|
354 | omp_set_num_threads(threads_nr); |
---|
355 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
356 | #endif |
---|
357 | |
---|
358 | // Define VCI parameters |
---|
359 | typedef soclib::caba::VciParams<cell_width, |
---|
360 | plen_width, |
---|
361 | address_width, |
---|
362 | error_width, |
---|
363 | clen_width, |
---|
364 | rflag_width, |
---|
365 | srcid_width, |
---|
366 | pktid_width, |
---|
367 | trdid_width, |
---|
368 | wrplen_width> vci_param; |
---|
369 | |
---|
370 | // Define parameters depending on mesh size |
---|
371 | size_t cluster_io_id; |
---|
372 | size_t x_width; |
---|
373 | size_t y_width; |
---|
374 | |
---|
375 | if (CLUSTER_X == 1) x_width = 0; |
---|
376 | else if (CLUSTER_X == 2) x_width = 1; |
---|
377 | else if (CLUSTER_X <= 4) x_width = 2; |
---|
378 | else if (CLUSTER_X <= 8) x_width = 3; |
---|
379 | else x_width = 4; |
---|
380 | |
---|
381 | if (CLUSTER_Y == 1) y_width = 0; |
---|
382 | else if (CLUSTER_Y == 2) y_width = 1; |
---|
383 | else if (CLUSTER_Y <= 4) y_width = 2; |
---|
384 | else if (CLUSTER_Y <= 8) y_width = 3; |
---|
385 | else y_width = 4; |
---|
386 | |
---|
387 | cluster_io_id = 0xBF >> (8 - x_width - y_width); |
---|
388 | |
---|
389 | ///////////////////// |
---|
390 | // Mapping Tables |
---|
391 | ///////////////////// |
---|
392 | |
---|
393 | // direct network |
---|
394 | MappingTable maptabd(address_width, |
---|
395 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
396 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
397 | 0x00FF0000); |
---|
398 | |
---|
399 | for (size_t x = 0; x < CLUSTER_X; x++) |
---|
400 | { |
---|
401 | for (size_t y = 0; y < CLUSTER_Y; y++) |
---|
402 | { |
---|
403 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
404 | |
---|
405 | std::ostringstream sh; |
---|
406 | sh << "d_seg_memc_" << x << "_" << y; |
---|
407 | maptabd.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
408 | |
---|
409 | std::ostringstream si; |
---|
410 | si << "d_seg_xicu_" << x << "_" << y; |
---|
411 | maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
412 | |
---|
413 | std::ostringstream sd; |
---|
414 | sd << "d_seg_mdma_" << x << "_" << y; |
---|
415 | maptabd.add(Segment(sd.str(), CDMA_BASE+offset, CDMA_SIZE, IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
416 | |
---|
417 | if ( cluster(x,y) == cluster_io_id ) |
---|
418 | { |
---|
419 | maptabd.add(Segment("d_seg_mtty", MTTY_BASE, MTTY_SIZE, IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
420 | maptabd.add(Segment("d_seg_fbuf", FBUF_BASE, FBUF_SIZE, IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
421 | maptabd.add(Segment("d_seg_bdev", BDEV_BASE, BDEV_SIZE, IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
422 | maptabd.add(Segment("d_seg_mnic", MNIC_BASE, MNIC_SIZE, IntTab(cluster(x,y),MNIC_TGTID), false)); |
---|
423 | maptabd.add(Segment("d_seg_brom", BROM_BASE, BROM_SIZE, IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
424 | } |
---|
425 | } |
---|
426 | } |
---|
427 | std::cout << maptabd << std::endl; |
---|
428 | |
---|
429 | /* |
---|
430 | WE DONT NEED any COHERENCE MAPPING TABLE, AS THE DIRECT NETWORK |
---|
431 | USES DIRECT ADRESSING (XID,YID,LID) |
---|
432 | |
---|
433 | // coherence network |
---|
434 | // - tgtid_c_proc = srcid_c_proc = local procid |
---|
435 | // - tgtid_c_memc = srcid_c_memc = NB_PROCS_MAX |
---|
436 | MappingTable maptabc(address_width, |
---|
437 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
438 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
439 | 0x00FF0000); |
---|
440 | |
---|
441 | for (size_t x = 0; x < CLUSTER_X; x++) |
---|
442 | { |
---|
443 | for (size_t y = 0; y < CLUSTER_Y; y++) |
---|
444 | { |
---|
445 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
446 | |
---|
447 | // cleanup requests must be routed to the memory cache |
---|
448 | std::ostringstream sh; |
---|
449 | sh << "c_seg_memc_" << x << "_" << y; |
---|
450 | maptabc.add(Segment(sh.str(), (NB_PROCS_MAX << (address_width - srcid_width)) + offset, |
---|
451 | 0x10, IntTab(cluster(x,y), NB_PROCS_MAX), false)); |
---|
452 | |
---|
453 | // update & invalidate requests must be routed to the proper processor |
---|
454 | for ( size_t p = 0 ; p < NB_PROCS_MAX ; p++) |
---|
455 | { |
---|
456 | std::ostringstream sp; |
---|
457 | sp << "c_seg_proc_" << x << "_" << y << "_" << p; |
---|
458 | maptabc.add( Segment( sp.str() , (p << (address_width - srcid_width)) + offset , |
---|
459 | 0x10 , IntTab(cluster(x,y), p) , false)); |
---|
460 | } |
---|
461 | } |
---|
462 | } |
---|
463 | std::cout << maptabc << std::endl; |
---|
464 | |
---|
465 | */ |
---|
466 | |
---|
467 | // external network |
---|
468 | MappingTable maptabx(address_width, IntTab(1), IntTab(x_width+y_width), 0xF0000000); |
---|
469 | |
---|
470 | for (size_t x = 0; x < CLUSTER_X; x++) |
---|
471 | { |
---|
472 | for (size_t y = 0; y < CLUSTER_Y ; y++) |
---|
473 | { |
---|
474 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
475 | std::ostringstream sh; |
---|
476 | sh << "x_seg_memc_" << x << "_" << y; |
---|
477 | maptabx.add(Segment(sh.str(), MEMC_BASE+offset, |
---|
478 | MEMC_SIZE, IntTab(cluster(x,y)), false)); |
---|
479 | } |
---|
480 | } |
---|
481 | std::cout << maptabx << std::endl; |
---|
482 | |
---|
483 | //////////////////// |
---|
484 | // Signals |
---|
485 | /////////////////// |
---|
486 | |
---|
487 | sc_clock signal_clk("clk"); |
---|
488 | sc_signal<bool> signal_resetn("resetn"); |
---|
489 | |
---|
490 | // Horizontal inter-clusters DSPIN signals |
---|
491 | DspinSignals<cmd_width>*** signal_dspin_h_cmd_inc = |
---|
492 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_inc", CLUSTER_X-1, CLUSTER_Y, 2); |
---|
493 | DspinSignals<cmd_width>*** signal_dspin_h_cmd_dec = |
---|
494 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_dec", CLUSTER_X-1, CLUSTER_Y, 2); |
---|
495 | DspinSignals<rsp_width>*** signal_dspin_h_rsp_inc = |
---|
496 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_inc", CLUSTER_X-1, CLUSTER_Y, 2); |
---|
497 | DspinSignals<rsp_width>*** signal_dspin_h_rsp_dec = |
---|
498 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_dec", CLUSTER_X-1, CLUSTER_Y, 2); |
---|
499 | |
---|
500 | // Vertical inter-clusters DSPIN signals |
---|
501 | DspinSignals<cmd_width>*** signal_dspin_v_cmd_inc = |
---|
502 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_inc", CLUSTER_X, CLUSTER_Y-1, 2); |
---|
503 | DspinSignals<cmd_width>*** signal_dspin_v_cmd_dec = |
---|
504 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_dec", CLUSTER_X, CLUSTER_Y-1, 2); |
---|
505 | DspinSignals<rsp_width>*** signal_dspin_v_rsp_inc = |
---|
506 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_inc", CLUSTER_X, CLUSTER_Y-1, 2); |
---|
507 | DspinSignals<rsp_width>*** signal_dspin_v_rsp_dec = |
---|
508 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_dec", CLUSTER_X, CLUSTER_Y-1, 2); |
---|
509 | |
---|
510 | // Mesh boundaries DSPIN signals |
---|
511 | DspinSignals<cmd_width>**** signal_dspin_false_cmd_in = |
---|
512 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_in", CLUSTER_X, CLUSTER_Y, 2, 4); |
---|
513 | DspinSignals<cmd_width>**** signal_dspin_false_cmd_out = |
---|
514 | alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_out", CLUSTER_X, CLUSTER_Y, 2, 4); |
---|
515 | DspinSignals<rsp_width>**** signal_dspin_false_rsp_in = |
---|
516 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_in", CLUSTER_X, CLUSTER_Y, 2, 4); |
---|
517 | DspinSignals<rsp_width>**** signal_dspin_false_rsp_out = |
---|
518 | alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_out", CLUSTER_X, CLUSTER_Y, 2, 4); |
---|
519 | |
---|
520 | |
---|
521 | //////////////////////////// |
---|
522 | // Loader |
---|
523 | //////////////////////////// |
---|
524 | |
---|
525 | #if USE_ALMOS |
---|
526 | soclib::common::Loader loader(almos_bootloader_pathname, |
---|
527 | almos_archinfo_pathname, |
---|
528 | almos_kernel_pathname); |
---|
529 | #else |
---|
530 | soclib::common::Loader loader(soft_name); |
---|
531 | #endif |
---|
532 | |
---|
533 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
534 | proc_iss::set_loader(loader); |
---|
535 | |
---|
536 | //////////////////////////// |
---|
537 | // Clusters construction |
---|
538 | //////////////////////////// |
---|
539 | |
---|
540 | TsarV5ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width>* clusters[CLUSTER_X][CLUSTER_Y]; |
---|
541 | |
---|
542 | #if USE_OPENMP |
---|
543 | #pragma omp parallel |
---|
544 | { |
---|
545 | #pragma omp for |
---|
546 | #endif |
---|
547 | for(size_t i = 0; i < (CLUSTER_X * CLUSTER_Y); i++) |
---|
548 | { |
---|
549 | size_t x = i / CLUSTER_Y; |
---|
550 | size_t y = i % CLUSTER_Y; |
---|
551 | |
---|
552 | #if USE_OPENMP |
---|
553 | #pragma omp critical |
---|
554 | { |
---|
555 | #endif |
---|
556 | std::ostringstream sc; |
---|
557 | sc << "cluster_" << x << "_" << y; |
---|
558 | clusters[x][y] = new TsarV5ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width> |
---|
559 | ( |
---|
560 | sc.str().c_str(), |
---|
561 | NB_PROCS_MAX, |
---|
562 | NB_TTYS, |
---|
563 | NB_DMAS_MAX, |
---|
564 | x, |
---|
565 | y, |
---|
566 | cluster(x,y), |
---|
567 | maptabd, |
---|
568 | maptabx, |
---|
569 | x_width, |
---|
570 | y_width, |
---|
571 | 4, // l_id width, |
---|
572 | MEMC_TGTID, |
---|
573 | XICU_TGTID, |
---|
574 | CDMA_TGTID, |
---|
575 | FBUF_TGTID, |
---|
576 | MTTY_TGTID, |
---|
577 | BROM_TGTID, |
---|
578 | MNIC_TGTID, |
---|
579 | BDEV_TGTID, |
---|
580 | MEMC_WAYS, |
---|
581 | MEMC_SETS, |
---|
582 | L1_IWAYS, |
---|
583 | L1_ISETS, |
---|
584 | L1_DWAYS, |
---|
585 | L1_DSETS, |
---|
586 | XRAM_LATENCY, |
---|
587 | (cluster(x,y) == cluster_io_id), |
---|
588 | FBUF_X_SIZE, |
---|
589 | FBUF_Y_SIZE, |
---|
590 | disk_name, |
---|
591 | BDEV_SECTOR_SIZE, |
---|
592 | NB_NICS, |
---|
593 | nic_rx_name, |
---|
594 | nic_tx_name, |
---|
595 | NIC_TIMEOUT, |
---|
596 | loader, |
---|
597 | frozen_cycles, |
---|
598 | debug_from, |
---|
599 | debug_ok and (cluster(x,y) == debug_memc_id), |
---|
600 | debug_ok and (cluster(x,y) == debug_proc_id) |
---|
601 | ); |
---|
602 | |
---|
603 | std::cout << "cluster_" << x << "_" << y << " constructed" << std::endl; |
---|
604 | #if USE_OPENMP |
---|
605 | } // end critical |
---|
606 | #endif |
---|
607 | } // end for |
---|
608 | #if USE_OPENMP |
---|
609 | } |
---|
610 | #endif |
---|
611 | |
---|
612 | /////////////////////////////////////////////////////////////// |
---|
613 | // Net-list |
---|
614 | /////////////////////////////////////////////////////////////// |
---|
615 | |
---|
616 | // Clock & RESET |
---|
617 | for (size_t x = 0; x < (CLUSTER_X); x++){ |
---|
618 | for (size_t y = 0; y < CLUSTER_Y; y++){ |
---|
619 | clusters[x][y]->p_clk (signal_clk); |
---|
620 | clusters[x][y]->p_resetn (signal_resetn); |
---|
621 | } |
---|
622 | } |
---|
623 | |
---|
624 | // Inter Clusters horizontal connections |
---|
625 | if (CLUSTER_X > 1){ |
---|
626 | for (size_t x = 0; x < (CLUSTER_X-1); x++){ |
---|
627 | for (size_t y = 0; y < CLUSTER_Y; y++){ |
---|
628 | for (size_t k = 0; k < 2; k++){ |
---|
629 | clusters[x][y]->p_cmd_out[k][EAST] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
630 | clusters[x+1][y]->p_cmd_in[k][WEST] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
631 | clusters[x][y]->p_cmd_in[k][EAST] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
632 | clusters[x+1][y]->p_cmd_out[k][WEST] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
633 | clusters[x][y]->p_rsp_out[k][EAST] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
634 | clusters[x+1][y]->p_rsp_in[k][WEST] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
635 | clusters[x][y]->p_rsp_in[k][EAST] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
636 | clusters[x+1][y]->p_rsp_out[k][WEST] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
637 | } |
---|
638 | } |
---|
639 | } |
---|
640 | } |
---|
641 | std::cout << std::endl << "Horizontal connections established" << std::endl; |
---|
642 | |
---|
643 | // Inter Clusters vertical connections |
---|
644 | if (CLUSTER_Y > 1) { |
---|
645 | for (size_t y = 0; y < (CLUSTER_Y-1); y++){ |
---|
646 | for (size_t x = 0; x < CLUSTER_X; x++){ |
---|
647 | for (size_t k = 0; k < 2; k++){ |
---|
648 | clusters[x][y]->p_cmd_out[k][NORTH] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
649 | clusters[x][y+1]->p_cmd_in[k][SOUTH] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
650 | clusters[x][y]->p_cmd_in[k][NORTH] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
651 | clusters[x][y+1]->p_cmd_out[k][SOUTH] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
652 | clusters[x][y]->p_rsp_out[k][NORTH] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
653 | clusters[x][y+1]->p_rsp_in[k][SOUTH] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
654 | clusters[x][y]->p_rsp_in[k][NORTH] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
655 | clusters[x][y+1]->p_rsp_out[k][SOUTH] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
656 | } |
---|
657 | } |
---|
658 | } |
---|
659 | } |
---|
660 | std::cout << "Vertical connections established" << std::endl; |
---|
661 | |
---|
662 | // East & West boundary cluster connections |
---|
663 | for (size_t y = 0; y < CLUSTER_Y; y++) |
---|
664 | { |
---|
665 | for (size_t k = 0; k < 2; k++) |
---|
666 | { |
---|
667 | clusters[0][y]->p_cmd_in[k][WEST] (signal_dspin_false_cmd_in[0][y][k][WEST]); |
---|
668 | clusters[0][y]->p_cmd_out[k][WEST] (signal_dspin_false_cmd_out[0][y][k][WEST]); |
---|
669 | clusters[0][y]->p_rsp_in[k][WEST] (signal_dspin_false_rsp_in[0][y][k][WEST]); |
---|
670 | clusters[0][y]->p_rsp_out[k][WEST] (signal_dspin_false_rsp_out[0][y][k][WEST]); |
---|
671 | |
---|
672 | clusters[CLUSTER_X-1][y]->p_cmd_in[k][EAST] (signal_dspin_false_cmd_in[CLUSTER_X-1][y][k][EAST]); |
---|
673 | clusters[CLUSTER_X-1][y]->p_cmd_out[k][EAST] (signal_dspin_false_cmd_out[CLUSTER_X-1][y][k][EAST]); |
---|
674 | clusters[CLUSTER_X-1][y]->p_rsp_in[k][EAST] (signal_dspin_false_rsp_in[CLUSTER_X-1][y][k][EAST]); |
---|
675 | clusters[CLUSTER_X-1][y]->p_rsp_out[k][EAST] (signal_dspin_false_rsp_out[CLUSTER_X-1][y][k][EAST]); |
---|
676 | } |
---|
677 | } |
---|
678 | |
---|
679 | // North & South boundary clusters connections |
---|
680 | for (size_t x = 0; x < CLUSTER_X; x++) |
---|
681 | { |
---|
682 | for (size_t k = 0; k < 2; k++) |
---|
683 | { |
---|
684 | clusters[x][0]->p_cmd_in[k][SOUTH] (signal_dspin_false_cmd_in[x][0][k][SOUTH]); |
---|
685 | clusters[x][0]->p_cmd_out[k][SOUTH] (signal_dspin_false_cmd_out[x][0][k][SOUTH]); |
---|
686 | clusters[x][0]->p_rsp_in[k][SOUTH] (signal_dspin_false_rsp_in[x][0][k][SOUTH]); |
---|
687 | clusters[x][0]->p_rsp_out[k][SOUTH] (signal_dspin_false_rsp_out[x][0][k][SOUTH]); |
---|
688 | |
---|
689 | clusters[x][CLUSTER_Y-1]->p_cmd_in[k][NORTH] (signal_dspin_false_cmd_in[x][CLUSTER_Y-1][k][NORTH]); |
---|
690 | clusters[x][CLUSTER_Y-1]->p_cmd_out[k][NORTH] (signal_dspin_false_cmd_out[x][CLUSTER_Y-1][k][NORTH]); |
---|
691 | clusters[x][CLUSTER_Y-1]->p_rsp_in[k][NORTH] (signal_dspin_false_rsp_in[x][CLUSTER_Y-1][k][NORTH]); |
---|
692 | clusters[x][CLUSTER_Y-1]->p_rsp_out[k][NORTH] (signal_dspin_false_rsp_out[x][CLUSTER_Y-1][k][NORTH]); |
---|
693 | } |
---|
694 | } |
---|
695 | |
---|
696 | |
---|
697 | //////////////////////////////////////////////////////// |
---|
698 | // Simulation |
---|
699 | /////////////////////////////////////////////////////// |
---|
700 | |
---|
701 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
702 | signal_resetn = false; |
---|
703 | |
---|
704 | // network boundaries signals |
---|
705 | for (size_t x = 0; x < CLUSTER_X ; x++){ |
---|
706 | for (size_t y = 0; y < CLUSTER_Y ; y++){ |
---|
707 | for (size_t k = 0; k < 2; k++){ |
---|
708 | for (size_t a = 0; a < 4; a++){ |
---|
709 | signal_dspin_false_cmd_in[x][y][k][a].write = false; |
---|
710 | signal_dspin_false_cmd_in[x][y][k][a].read = true; |
---|
711 | signal_dspin_false_cmd_out[x][y][k][a].write = false; |
---|
712 | signal_dspin_false_cmd_out[x][y][k][a].read = true; |
---|
713 | |
---|
714 | signal_dspin_false_rsp_in[x][y][k][a].write = false; |
---|
715 | signal_dspin_false_rsp_in[x][y][k][a].read = true; |
---|
716 | signal_dspin_false_rsp_out[x][y][k][a].write = false; |
---|
717 | signal_dspin_false_rsp_out[x][y][k][a].read = true; |
---|
718 | } |
---|
719 | } |
---|
720 | } |
---|
721 | } |
---|
722 | |
---|
723 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
724 | signal_resetn = true; |
---|
725 | |
---|
726 | for (size_t n = 1; n < ncycles; n++) |
---|
727 | { |
---|
728 | |
---|
729 | if (debug_ok and (n > debug_from) and (n % debug_period == 0)) |
---|
730 | { |
---|
731 | std::cout << "****************** cycle " << std::dec << n ; |
---|
732 | std::cout << " ************************************************" << std::endl; |
---|
733 | |
---|
734 | // trace proc[debug_proc_id] |
---|
735 | if ( debug_proc_id < (CLUSTER_X * CLUSTER_Y * NB_PROCS_MAX) ) |
---|
736 | { |
---|
737 | size_t proc_x = debug_proc_id / CLUSTER_Y; |
---|
738 | size_t proc_y = debug_proc_id % CLUSTER_Y; |
---|
739 | |
---|
740 | clusters[proc_x][proc_y]->proc[0]->print_trace(); |
---|
741 | clusters[proc_x][proc_y]->signal_vci_ini_proc[0].print_trace("proc_0"); |
---|
742 | } |
---|
743 | |
---|
744 | // trace memc[debug_memc_id] |
---|
745 | if ( debug_memc_id < (CLUSTER_X * CLUSTER_Y) ) |
---|
746 | { |
---|
747 | size_t memc_x = debug_memc_id / CLUSTER_Y; |
---|
748 | size_t memc_y = debug_memc_id % CLUSTER_Y; |
---|
749 | |
---|
750 | clusters[memc_x][memc_y]->memc->print_trace(); |
---|
751 | clusters[memc_x][memc_y]->signal_vci_tgt_memc.print_trace("memc"); |
---|
752 | } |
---|
753 | |
---|
754 | // clusters[0][0]->signal_vci_tgt_xicu.print_trace("xicu_0_0"); |
---|
755 | // clusters[0][1]->signal_vci_tgt_xicu.print_trace("xicu_0_1"); |
---|
756 | // clusters[1][0]->signal_vci_tgt_xicu.print_trace("xicu_1_0"); |
---|
757 | // clusters[1][1]->signal_vci_tgt_xicu.print_trace("xicu_1_1"); |
---|
758 | |
---|
759 | // if ( clusters[1][1]->signal_irq_mdma[0].read() ) |
---|
760 | // std::cout << std::endl << " IRQ_DMA_1_1 activated" << std::endl; |
---|
761 | // if ( clusters[1][1]->signal_proc_it[0].read() ) |
---|
762 | // std::cout << " IRQ_PROC_1_1 activated" << std::endl << std::endl; |
---|
763 | |
---|
764 | // trace ioc component |
---|
765 | // size_t io_x = cluster_io_id / CLUSTER_Y; |
---|
766 | // size_t io_y = cluster_io_id % CLUSTER_Y; |
---|
767 | // clusters[io_x][io_y]->bdev->print_trace(); |
---|
768 | // clusters[io_x][io_y]->signal_vci_tgt_bdev.print_trace("bdev_tgt "); |
---|
769 | // clusters[io_x][io_y]->signal_vci_ini_bdev.print_trace("bdev_ini "); |
---|
770 | |
---|
771 | // clusters[1][1]->mdma->print_trace(); |
---|
772 | // clusters[1][1]->signal_vci_tgt_mdma.print_trace("mdma_1_1_tgt "); |
---|
773 | // clusters[1][1]->signal_vci_ini_mdma.print_trace("mdma_1_1_ini "); |
---|
774 | |
---|
775 | } |
---|
776 | |
---|
777 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
778 | } |
---|
779 | return EXIT_SUCCESS; |
---|
780 | } |
---|
781 | |
---|
782 | int sc_main (int argc, char *argv[]) |
---|
783 | { |
---|
784 | try { |
---|
785 | return _main(argc, argv); |
---|
786 | } catch (std::exception &e) { |
---|
787 | std::cout << e.what() << std::endl; |
---|
788 | } catch (...) { |
---|
789 | std::cout << "Unknown exception occured" << std::endl; |
---|
790 | throw; |
---|
791 | } |
---|
792 | return 1; |
---|
793 | } |
---|
794 | |
---|
795 | |
---|
796 | // Local Variables: |
---|
797 | // tab-width: 3 |
---|
798 | // c-basic-offset: 3 |
---|
799 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
800 | // indent-tabs-mode: nil |
---|
801 | // End: |
---|
802 | |
---|
803 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|
804 | |
---|
805 | |
---|
806 | |
---|
807 | |
---|