1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File: top.cpp (for tsar_generic_iob platform) |
---|
3 | // Author: Alain Greiner |
---|
4 | // Copyright: UPMC/LIP6 |
---|
5 | // Date : august 2013 |
---|
6 | // This program is released under the GNU public license |
---|
7 | /////////////////////////////////////////////////////////////////////////////// |
---|
8 | // This file define a generic TSAR architecture with an IO network emulating |
---|
9 | // an external bus (i.e. Hypertransport) to access 7 external peripherals: |
---|
10 | // |
---|
11 | // - BROM : boot ROM |
---|
12 | // - FBUF : Frame Buffer |
---|
13 | // - MTTY : multi TTY (up to 15 channels) |
---|
14 | // - MNIC : Network controller (up to 2 channels) |
---|
15 | // - CDMA : Chained Buffer DMA controller (up to 4 channels) |
---|
16 | // - BDEV : Dlock Device controler (1 channel) |
---|
17 | // - IOPI : HWI to SWI translator. |
---|
18 | // |
---|
19 | // The internal physical address space is 40 bits, and the cluster index |
---|
20 | // is defined by the 8 MSB bits, using a fixed format: X is encoded on 4 bits, |
---|
21 | // Y is encodes on 4 bits, whatever the actual mesh size. |
---|
22 | // => at most 16 * 16 clusters. Each cluster contains up to 4 processors. |
---|
23 | // |
---|
24 | // It contains 3 networks: |
---|
25 | // |
---|
26 | // 1) the "INT" network supports Read/Write transactions |
---|
27 | // between processors and L2 caches or peripherals. |
---|
28 | // (VCI ADDDRESS = 40 bits / VCI DATA width = 32 bits) |
---|
29 | // It supports also coherence transactions between L1 & L2 caches. |
---|
30 | // 3) the "RAM" network is emulating the 3D network between L2 caches |
---|
31 | // and L3 caches, and is implemented as a 2D mesh between the L2 caches, |
---|
32 | // the two IO bridges and the physical RAMs disributed in all clusters. |
---|
33 | // (VCI ADDRESS = 40 bits / VCI DATA = 64 bits) |
---|
34 | // 4) the IOX network connects the two IO bridge components to the |
---|
35 | // 7 external peripheral controllers. |
---|
36 | // (VCI ADDDRESS = 40 bits / VCI DATA width = 64 bits) |
---|
37 | // |
---|
38 | // The external peripherals HWI IRQs are translated to WTI IRQs by the |
---|
39 | // external IOPIC component, that must be configured by the OS to route |
---|
40 | // these WTI ITQS to one or several internal XICU components. |
---|
41 | // The total number of channels for the external peripherals (MTTY, MNIC, CDMA |
---|
42 | // IOC or HBA) is limited by the IOPIC 32 HWI inputs:.. |
---|
43 | // - IOPIC HWI[1:0] connected to IRQ_NIC_RX[1:0] |
---|
44 | // - IOPIC HWI[3:2] connected to IRQ_NIC_TX[1:0] |
---|
45 | // - IOPIC HWI[7:4] connected to IRQ_CMA_TX[3:0]] |
---|
46 | // - IOPIC HWI[8] connected to IRQ_BDEV |
---|
47 | // - IOPIC HWI[15:9] unused (grounded) |
---|
48 | // - IOPIC HWI[23:16] connected to IRQ_TTY_RX[7:0]] |
---|
49 | // - IOPIC HWI[31:24] connected to IRQ_TTY_TX[7:0]] TBD |
---|
50 | // |
---|
51 | // Besides the external peripherals, each cluster contains on XICU component, |
---|
52 | // and one multi channels DMA component. |
---|
53 | // The XICU component is mainly used to handle WTI IRQs, as only 2 HWI IRQs |
---|
54 | // are connected to XICU in each cluster: |
---|
55 | // - IRQ_IN[0] : MMC |
---|
56 | // - IRQ_IN[1] : DMA channel 0 |
---|
57 | // - IRQ_IN[2] : DMA channel 1 |
---|
58 | // - IRQ_IN[3] : DMA channel 2 |
---|
59 | // - IRQ_IN[4] : DMA channel 3 |
---|
60 | // |
---|
61 | // All clusters are identical, but cluster(0,0) and cluster(XMAX-1,YMAX-1) |
---|
62 | // contain an extra IO bridge component. These IOB0 & IOB1 components are |
---|
63 | // connected to the three networks (INT, RAM, IOX). |
---|
64 | // |
---|
65 | // - It uses two dspin_local_crossbar per cluster to implement the |
---|
66 | // local interconnect correponding to the INT network. |
---|
67 | // - It uses two dspin_local_crossbar per cluster to implement the |
---|
68 | // local interconnect correponding to the coherence INT network. |
---|
69 | // - It uses two virtual_dspin_router per cluster to implement |
---|
70 | // the INT network (routing both the direct and coherence trafic). |
---|
71 | // - It uses two dspin_router per cluster to implement the RAM network. |
---|
72 | // - It uses the vci_cc_vcache_wrapper. |
---|
73 | // - It uses the vci_mem_cache. |
---|
74 | // - It contains one vci_xicu and one vci_multi_dma per cluster. |
---|
75 | // - It contains one vci_simple ram per cluster to model the L3 cache. |
---|
76 | // |
---|
77 | // The TsarIobCluster component is defined in files |
---|
78 | // tsar_iob_cluster.* (with * = cpp, h, sd) |
---|
79 | // |
---|
80 | // The main hardware parameters must be defined in the hard_config.h file : |
---|
81 | // - X_SIZE : number of clusters in a row |
---|
82 | // - Y_SIZE : number of clusters in a column |
---|
83 | // - NB_PROCS_MAX : number of processors per cluster (power of 2) |
---|
84 | // - NB_TTY_CHANNELS : number of TTY channels in I/O network (must be 1) |
---|
85 | // - NB_NIC_CHANNELS : number of NIC channels in I/O network (up to 2) |
---|
86 | // - NB_CMA_CHANNELS : number of CMA channels in I/O network (up to 4) |
---|
87 | // - FBUF_X_SIZE : width of frame buffer (pixels) |
---|
88 | // - FBUF_Y_SIZE : heigth of frame buffer (lines) |
---|
89 | // - XCU_NB_INPUTS : number of HWIs = number of WTIs = number of PTIs |
---|
90 | // |
---|
91 | // Some secondary hardware parameters must be defined in this top.cpp file: |
---|
92 | // - XRAM_LATENCY : external ram latency |
---|
93 | // - MEMC_WAYS : L2 cache number of ways |
---|
94 | // - MEMC_SETS : L2 cache number of sets |
---|
95 | // - L1_IWAYS |
---|
96 | // - L1_ISETS |
---|
97 | // - L1_DWAYS |
---|
98 | // - L1_DSETS |
---|
99 | // - BDEV_IMAGE_NAME : file pathname for block device |
---|
100 | // - NIC_RX_NAME : file pathname for NIC received packets |
---|
101 | // - NIC_TX_NAME : file pathname for NIC transmited packets |
---|
102 | // - NIC_TIMEOUT : max number of cycles before closing a container |
---|
103 | // |
---|
104 | // General policy for 40 bits physical address decoding: |
---|
105 | // All physical segments base addresses are multiple of 1 Mbytes |
---|
106 | // (=> the 24 LSB bits = 0, and the 16 MSB bits define the target) |
---|
107 | // The (x_width + y_width) MSB bits (left aligned) define |
---|
108 | // the cluster index, and the LADR bits define the local index: |
---|
109 | // |X_ID|Y_ID| LADR | OFFSET | |
---|
110 | // | 4 | 4 | 8 | 24 | |
---|
111 | // |
---|
112 | // General policy for 14 bits SRCID decoding: |
---|
113 | // Each component is identified by (x_id, y_id, l_id) tuple. |
---|
114 | // |X_ID|Y_ID| L_ID | |
---|
115 | // | 4 | 4 | 6 | |
---|
116 | ///////////////////////////////////////////////////////////////////////// |
---|
117 | |
---|
118 | #include <systemc> |
---|
119 | #include <sys/time.h> |
---|
120 | #include <iostream> |
---|
121 | #include <sstream> |
---|
122 | #include <cstdlib> |
---|
123 | #include <cstdarg> |
---|
124 | #include <stdint.h> |
---|
125 | |
---|
126 | #include "gdbserver.h" |
---|
127 | #include "mapping_table.h" |
---|
128 | |
---|
129 | #include "tsar_iob_cluster.h" |
---|
130 | #include "vci_chbuf_dma.h" |
---|
131 | #include "vci_multi_tty.h" |
---|
132 | #include "vci_multi_nic.h" |
---|
133 | #include "vci_simple_rom.h" |
---|
134 | #include "vci_block_device_tsar.h" |
---|
135 | #include "vci_framebuffer.h" |
---|
136 | #include "vci_iox_network.h" |
---|
137 | #include "vci_iox_network.h" |
---|
138 | #include "vci_iopic.h" |
---|
139 | |
---|
140 | #include "alloc_elems.h" |
---|
141 | |
---|
142 | /////////////////////////////////////////////////// |
---|
143 | // OS |
---|
144 | /////////////////////////////////////////////////// |
---|
145 | #define USE_ALMOS 0 |
---|
146 | |
---|
147 | #define almos_bootloader_pathname "bootloader.bin" |
---|
148 | #define almos_kernel_pathname "kernel-soclib.bin@0xbfc10000:D" |
---|
149 | #define almos_archinfo_pathname "arch-info.bin@0xBFC08000:D" |
---|
150 | |
---|
151 | /////////////////////////////////////////////////// |
---|
152 | // Parallelisation |
---|
153 | /////////////////////////////////////////////////// |
---|
154 | #define USE_OPENMP 0 |
---|
155 | |
---|
156 | #if USE_OPENMP |
---|
157 | #include <omp.h> |
---|
158 | #endif |
---|
159 | |
---|
160 | /////////////////////////////////////////////////////////// |
---|
161 | // DSPIN parameters |
---|
162 | /////////////////////////////////////////////////////////// |
---|
163 | |
---|
164 | #define dspin_int_cmd_width 39 |
---|
165 | #define dspin_int_rsp_width 32 |
---|
166 | |
---|
167 | #define dspin_ram_cmd_width 64 |
---|
168 | #define dspin_ram_rsp_width 64 |
---|
169 | |
---|
170 | /////////////////////////////////////////////////////////// |
---|
171 | // VCI fields width for the 3 VCI networks |
---|
172 | /////////////////////////////////////////////////////////// |
---|
173 | |
---|
174 | #define vci_cell_width_int 4 |
---|
175 | #define vci_cell_width_ext 8 |
---|
176 | |
---|
177 | #define vci_plen_width 8 |
---|
178 | #define vci_address_width 40 |
---|
179 | #define vci_rerror_width 1 |
---|
180 | #define vci_clen_width 1 |
---|
181 | #define vci_rflag_width 1 |
---|
182 | #define vci_srcid_width 14 |
---|
183 | #define vci_pktid_width 4 |
---|
184 | #define vci_trdid_width 4 |
---|
185 | #define vci_wrplen_width 1 |
---|
186 | |
---|
187 | //////////////////////////////////////////////////////////// |
---|
188 | // Main Hardware Parameters values |
---|
189 | //////////////////////i///////////////////////////////////// |
---|
190 | |
---|
191 | #include "hard_config.h" |
---|
192 | |
---|
193 | //////////////////////////////////////////////////////////// |
---|
194 | // Secondary Hardware Parameters values |
---|
195 | //////////////////////i///////////////////////////////////// |
---|
196 | |
---|
197 | #define XMAX X_SIZE |
---|
198 | #define YMAX Y_SIZE |
---|
199 | |
---|
200 | #define XRAM_LATENCY 0 |
---|
201 | |
---|
202 | #define MEMC_WAYS 16 |
---|
203 | #define MEMC_SETS 256 |
---|
204 | |
---|
205 | #define L1_IWAYS 4 |
---|
206 | #define L1_ISETS 64 |
---|
207 | |
---|
208 | #define L1_DWAYS 4 |
---|
209 | #define L1_DSETS 64 |
---|
210 | |
---|
211 | #define BDEV_IMAGE_NAME "../../../giet_vm/hdd/virt_hdd.dmg" |
---|
212 | |
---|
213 | #define NIC_RX_NAME "giet_vm/nic/rx_packets.txt" |
---|
214 | #define NIC_TX_NAME "giet_vm/nic/tx_packets.txt" |
---|
215 | #define NIC_TIMEOUT 10000 |
---|
216 | |
---|
217 | #define NORTH 0 |
---|
218 | #define SOUTH 1 |
---|
219 | #define EAST 2 |
---|
220 | #define WEST 3 |
---|
221 | |
---|
222 | #define cluster(x,y) ((y) + ((x) << 4)) |
---|
223 | |
---|
224 | //////////////////////////////////////////////////////////// |
---|
225 | // Software to be loaded in ROM & RAM |
---|
226 | //////////////////////i///////////////////////////////////// |
---|
227 | |
---|
228 | #define BOOT_SOFT_NAME "../../softs/tsar_boot/preloader.elf" |
---|
229 | |
---|
230 | //////////////////////////////////////////////////////////// |
---|
231 | // DEBUG Parameters default values |
---|
232 | //////////////////////i///////////////////////////////////// |
---|
233 | |
---|
234 | #define MAX_FROZEN_CYCLES 200000 |
---|
235 | |
---|
236 | ///////////////////////////////////////////////////////// |
---|
237 | // Physical segments definition |
---|
238 | ///////////////////////////////////////////////////////// |
---|
239 | |
---|
240 | // Non replicated peripherals (must be in cluster 0) |
---|
241 | |
---|
242 | #define BROM_BASE 0x00BFC00000 |
---|
243 | #define BROM_SIZE 0x0000100000 // 1 M Kbytes |
---|
244 | |
---|
245 | #define IOBX_BASE 0x00BE000000 |
---|
246 | #define IOBX_SIZE 0x0000001000 // 4 Kbytes |
---|
247 | |
---|
248 | #define BDEV_BASE 0x00B3000000 |
---|
249 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
250 | |
---|
251 | #define MTTY_BASE 0x00B4000000 |
---|
252 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
253 | |
---|
254 | #define MNIC_BASE 0x00B5000000 |
---|
255 | #define MNIC_SIZE 0x0000080000 // 512 Kbytes |
---|
256 | |
---|
257 | #define CDMA_BASE 0x00B6000000 |
---|
258 | #define CDMA_SIZE 0x0000001000 * (NB_CMA_CHANNELS) // 4 Kbytes per channel |
---|
259 | |
---|
260 | #define FBUF_BASE 0x00B7000000 |
---|
261 | #define FBUF_SIZE FBUF_X_SIZE * FBUF_Y_SIZE |
---|
262 | |
---|
263 | #define IOPI_BASE 0x00B8000000 |
---|
264 | #define IOPI_SIZE 0x0000001000 // 4 Kbytes |
---|
265 | |
---|
266 | // Replicated peripherals : address is incremented by a cluster offset |
---|
267 | // offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
268 | |
---|
269 | #define XRAM_BASE 0x0000000000 |
---|
270 | #define XRAM_SIZE 0x0004000000 // 64 Mbytes |
---|
271 | |
---|
272 | #define XICU_BASE 0x00B0000000 |
---|
273 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
274 | |
---|
275 | #define MDMA_BASE 0x00B1000000 |
---|
276 | #define MDMA_SIZE 0x0000001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
277 | |
---|
278 | // Replicated memory segments (XRAM) : address is incremented by a cluster offset |
---|
279 | // offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
280 | |
---|
281 | #define MEMC_BASE 0x00B2000000 |
---|
282 | #define MEMC_SIZE 0x0000001000 // 4 Kbytes |
---|
283 | |
---|
284 | //////////////////////////////////////////////////////////////////////// |
---|
285 | // SRCID definition |
---|
286 | //////////////////////////////////////////////////////////////////////// |
---|
287 | // All initiators are in the same indexing space (14 bits). |
---|
288 | // The SRCID is structured in two fields: |
---|
289 | // - The 10 MSB bits define the cluster index (left aligned) |
---|
290 | // - The 4 LSB bits define the local index. |
---|
291 | // Two different initiators cannot have the same SRCID, but a given |
---|
292 | // initiator can have two alias SRCIDs: |
---|
293 | // - Internal initiators (procs, mdma) are replicated in all clusters, |
---|
294 | // and each initiator has one single SRCID. |
---|
295 | // - External initiators (bdev, cdma) are not replicated, but can be |
---|
296 | // accessed in 2 clusters : cluster_iob0 and cluster_iob1. |
---|
297 | // They have the same local index, but two different cluster indexes. |
---|
298 | // |
---|
299 | // As cluster_iob0 and cluster_iob1 contain both internal initiators |
---|
300 | // and external initiators, they must have different local indexes. |
---|
301 | // Consequence: For a local interconnect, the INI_ID port index |
---|
302 | // is NOT equal to the SRCID local index, and the local interconnect |
---|
303 | // must make a translation: SRCID => INI_ID |
---|
304 | //////////////////////////////////////////////////////////////////////// |
---|
305 | |
---|
306 | #define PROC_LOCAL_SRCID 0x0 // from 0 to 7 |
---|
307 | #define MDMA_LOCAL_SRCID 0x8 |
---|
308 | #define IOBX_LOCAL_SRCID 0x9 |
---|
309 | #define MEMC_LOCAL_SRCID 0xA |
---|
310 | #define IOPI_LOCAL_SRCID 0xD |
---|
311 | #define CDMA_LOCAL_SRCID 0xE // hard-coded in dspin_tsar |
---|
312 | #define BDEV_LOCAL_SRCID 0xF // hard-coded in dspin_tsar |
---|
313 | |
---|
314 | /////////////////////////////////////////////////////////////////////// |
---|
315 | // TGT_ID and INI_ID port indexing for INT local interconnect |
---|
316 | /////////////////////////////////////////////////////////////////////// |
---|
317 | |
---|
318 | #define INT_MEMC_TGT_ID 0 |
---|
319 | #define INT_XICU_TGT_ID 1 |
---|
320 | #define INT_MDMA_TGT_ID 2 |
---|
321 | #define INT_IOBX_TGT_ID 3 |
---|
322 | |
---|
323 | #define INT_PROC_INI_ID 0 // from 0 to (NB_PROCS_MAX-1) |
---|
324 | #define INT_MDMA_INI_ID (NB_PROCS_MAX) |
---|
325 | #define INT_IOBX_INI_ID (NB_PROCS_MAX+1) |
---|
326 | |
---|
327 | /////////////////////////////////////////////////////////////////////// |
---|
328 | // TGT_ID and INI_ID port indexing for RAM local interconnect |
---|
329 | /////////////////////////////////////////////////////////////////////// |
---|
330 | |
---|
331 | #define RAM_XRAM_TGT_ID 0 |
---|
332 | |
---|
333 | #define RAM_MEMC_INI_ID 0 |
---|
334 | #define RAM_IOBX_INI_ID 1 |
---|
335 | |
---|
336 | /////////////////////////////////////////////////////////////////////// |
---|
337 | // TGT_ID and INI_ID port indexing for I0X local interconnect |
---|
338 | /////////////////////////////////////////////////////////////////////// |
---|
339 | |
---|
340 | #define IOX_IOB0_TGT_ID 0 // don't change this value |
---|
341 | #define IOX_IOB1_TGT_ID 1 // don't change this value |
---|
342 | #define IOX_FBUF_TGT_ID 2 |
---|
343 | #define IOX_BDEV_TGT_ID 3 |
---|
344 | #define IOX_MNIC_TGT_ID 4 |
---|
345 | #define IOX_CDMA_TGT_ID 5 |
---|
346 | #define IOX_BROM_TGT_ID 6 |
---|
347 | #define IOX_MTTY_TGT_ID 7 |
---|
348 | #define IOX_IOPI_TGT_ID 8 |
---|
349 | |
---|
350 | #define IOX_IOB0_INI_ID 0 // Don't change this value |
---|
351 | #define IOX_IOB1_INI_ID 1 // Don't change this value |
---|
352 | #define IOX_BDEV_INI_ID 2 |
---|
353 | #define IOX_CDMA_INI_ID 3 |
---|
354 | #define IOX_IOPI_INI_ID 4 |
---|
355 | |
---|
356 | //////////////////////////////////////////////////////////////////////// |
---|
357 | int _main(int argc, char *argv[]) |
---|
358 | //////////////////////////////////////////////////////////////////////// |
---|
359 | { |
---|
360 | using namespace sc_core; |
---|
361 | using namespace soclib::caba; |
---|
362 | using namespace soclib::common; |
---|
363 | |
---|
364 | |
---|
365 | char soft_name[256] = BOOT_SOFT_NAME; // pathname: binary code |
---|
366 | size_t ncycles = 1000000000; // simulated cycles |
---|
367 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname: disk image |
---|
368 | char nic_rx_name[256] = NIC_RX_NAME; // pathname: rx packets file |
---|
369 | char nic_tx_name[256] = NIC_TX_NAME; // pathname: tx packets file |
---|
370 | ssize_t threads_nr = 1; // simulator's threads number |
---|
371 | bool debug_ok = false; // trace activated |
---|
372 | size_t debug_period = 1; // trace period |
---|
373 | size_t debug_memc_id = 0xFFFFFFFF; // index of traced memc |
---|
374 | size_t debug_proc_id = 0xFFFFFFFF; // index of traced proc |
---|
375 | size_t debug_xram_id = 0xFFFFFFFF; // index of traced xram |
---|
376 | bool debug_iob = false; // trace iob0 & iob1 when true |
---|
377 | uint32_t debug_from = 0; // trace start cycle |
---|
378 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
379 | size_t cluster_iob0 = cluster(0,0); // cluster containing IOB0 |
---|
380 | size_t cluster_iob1 = cluster(XMAX-1,YMAX-1); // cluster containing IOB1 |
---|
381 | size_t x_width = 4; // at most 256 clusters |
---|
382 | size_t y_width = 4; // at most 256 clusters |
---|
383 | |
---|
384 | assert( (X_WIDTH == 4) and (Y_WIDTH == 4) and |
---|
385 | "ERROR: we must have X_WIDTH == Y_WIDTH == 4"); |
---|
386 | |
---|
387 | ////////////// command line arguments ////////////////////// |
---|
388 | if (argc > 1) |
---|
389 | { |
---|
390 | for (int n = 1; n < argc; n = n + 2) |
---|
391 | { |
---|
392 | if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc)) |
---|
393 | { |
---|
394 | ncycles = atoi(argv[n+1]); |
---|
395 | } |
---|
396 | else if ((strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) ) |
---|
397 | { |
---|
398 | strcpy(soft_name, argv[n+1]); |
---|
399 | } |
---|
400 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) ) |
---|
401 | { |
---|
402 | debug_ok = true; |
---|
403 | debug_from = atoi(argv[n+1]); |
---|
404 | } |
---|
405 | else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) ) |
---|
406 | { |
---|
407 | strcpy(disk_name, argv[n+1]); |
---|
408 | } |
---|
409 | else if ((strcmp(argv[n],"-MEMCID") == 0) && (n+1<argc) ) |
---|
410 | { |
---|
411 | debug_memc_id = atoi(argv[n+1]); |
---|
412 | size_t x = debug_memc_id >> 4; |
---|
413 | size_t y = debug_memc_id & 0xF; |
---|
414 | if( (x>=XMAX) || (y>=YMAX) ) |
---|
415 | { |
---|
416 | std::cout << "MEMCID parameter does'nt fit XMAX/YMAX" << std::endl; |
---|
417 | exit(0); |
---|
418 | } |
---|
419 | } |
---|
420 | else if ((strcmp(argv[n],"-XRAMID") == 0) && (n+1<argc) ) |
---|
421 | { |
---|
422 | debug_xram_id = atoi(argv[n+1]); |
---|
423 | size_t x = debug_xram_id >> 4; |
---|
424 | size_t y = debug_xram_id & 0xF; |
---|
425 | if( (x>=XMAX) || (y>=YMAX) ) |
---|
426 | { |
---|
427 | std::cout << "XRAMID parameter does'nt fit XMAX/YMAX" << std::endl; |
---|
428 | exit(0); |
---|
429 | } |
---|
430 | } |
---|
431 | else if ((strcmp(argv[n],"-IOB") == 0) && (n+1<argc) ) |
---|
432 | { |
---|
433 | debug_iob = atoi(argv[n+1]); |
---|
434 | } |
---|
435 | else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) ) |
---|
436 | { |
---|
437 | debug_proc_id = atoi(argv[n+1]); |
---|
438 | size_t cluster_xy = debug_proc_id / NB_PROCS_MAX ; |
---|
439 | size_t x = cluster_xy >> 4; |
---|
440 | size_t y = cluster_xy & 0xF; |
---|
441 | if( (x>=XMAX) || (y>=YMAX) ) |
---|
442 | { |
---|
443 | std::cout << "PROCID parameter does'nt fit XMAX/YMAX" << std::endl; |
---|
444 | exit(0); |
---|
445 | } |
---|
446 | } |
---|
447 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n+1) < argc)) |
---|
448 | { |
---|
449 | threads_nr = atoi(argv[n+1]); |
---|
450 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
451 | } |
---|
452 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc)) |
---|
453 | { |
---|
454 | frozen_cycles = atoi(argv[n+1]); |
---|
455 | } |
---|
456 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n+1 < argc)) |
---|
457 | { |
---|
458 | debug_period = atoi(argv[n+1]); |
---|
459 | } |
---|
460 | else |
---|
461 | { |
---|
462 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
463 | std::cout << " The order is not important." << std::endl; |
---|
464 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
465 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
466 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
467 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
468 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
469 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
470 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
471 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
472 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
473 | std::cout << " -XRAMID index_xram_to_be_traced" << std::endl; |
---|
474 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
475 | std::cout << " -IOB non_zero_value" << std::endl; |
---|
476 | exit(0); |
---|
477 | } |
---|
478 | } |
---|
479 | } |
---|
480 | |
---|
481 | // checking hardware parameters |
---|
482 | assert( (XMAX <= 16) and |
---|
483 | "The XMAX parameter cannot be larger than 16" ); |
---|
484 | |
---|
485 | assert( (YMAX <= 16) and |
---|
486 | "The YMAX parameter cannot be larger than 16" ); |
---|
487 | |
---|
488 | assert( (NB_PROCS_MAX <= 8) and |
---|
489 | "The NB_PROCS_MAX parameter cannot be larger than 8" ); |
---|
490 | |
---|
491 | assert( (NB_DMA_CHANNELS <= 4) and |
---|
492 | "The NB_DMA_CHANNELS parameter cannot be larger than 4" ); |
---|
493 | |
---|
494 | assert( (NB_TTY_CHANNELS == 1) and |
---|
495 | "The NB_TTY_CHANNELS parameter must be 1" ); |
---|
496 | |
---|
497 | assert( (NB_NIC_CHANNELS == 2) and |
---|
498 | "The NB_NIC_CHANNELS parameter must be 2" ); |
---|
499 | |
---|
500 | std::cout << std::endl << std::dec |
---|
501 | << " - XMAX = " << XMAX << std::endl |
---|
502 | << " - YMAX = " << YMAX << std::endl |
---|
503 | << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl |
---|
504 | << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl |
---|
505 | << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl |
---|
506 | << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl |
---|
507 | << " - MEMC_WAYS = " << MEMC_WAYS << std::endl |
---|
508 | << " - MEMC_SETS = " << MEMC_SETS << std::endl |
---|
509 | << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl |
---|
510 | << " - MAX_FROZEN = " << frozen_cycles << std::endl |
---|
511 | << " - DEBUG_PROCID = " << debug_proc_id << std::endl |
---|
512 | << " - DEBUG_MEMCID = " << debug_memc_id << std::endl |
---|
513 | << " - DEBUG_XRAMID = " << debug_xram_id << std::endl; |
---|
514 | |
---|
515 | std::cout << std::endl; |
---|
516 | |
---|
517 | #if USE_OPENMP |
---|
518 | omp_set_dynamic(false); |
---|
519 | omp_set_num_threads(threads_nr); |
---|
520 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
521 | #endif |
---|
522 | |
---|
523 | // Define VciParams objects |
---|
524 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
525 | vci_plen_width, |
---|
526 | vci_address_width, |
---|
527 | vci_rerror_width, |
---|
528 | vci_clen_width, |
---|
529 | vci_rflag_width, |
---|
530 | vci_srcid_width, |
---|
531 | vci_pktid_width, |
---|
532 | vci_trdid_width, |
---|
533 | vci_wrplen_width> vci_param_int; |
---|
534 | |
---|
535 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
536 | vci_plen_width, |
---|
537 | vci_address_width, |
---|
538 | vci_rerror_width, |
---|
539 | vci_clen_width, |
---|
540 | vci_rflag_width, |
---|
541 | vci_srcid_width, |
---|
542 | vci_pktid_width, |
---|
543 | vci_trdid_width, |
---|
544 | vci_wrplen_width> vci_param_ext; |
---|
545 | |
---|
546 | ///////////////////////////////////////////////////////////////////// |
---|
547 | // INT network mapping table |
---|
548 | // - two levels address decoding for commands |
---|
549 | // - two levels srcid decoding for responses |
---|
550 | // - NB_PROCS_MAX + 2 (MDMA, IOBX) local initiators per cluster |
---|
551 | // - 4 local targets (MEMC, XICU, MDMA, IOBX) per cluster |
---|
552 | ///////////////////////////////////////////////////////////////////// |
---|
553 | MappingTable maptab_int( vci_address_width, |
---|
554 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
555 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
556 | 0x00FF000000); |
---|
557 | |
---|
558 | for (size_t x = 0; x < XMAX; x++) |
---|
559 | { |
---|
560 | for (size_t y = 0; y < YMAX; y++) |
---|
561 | { |
---|
562 | uint64_t offset = ((uint64_t)cluster(x,y)) |
---|
563 | << (vci_address_width-x_width-y_width); |
---|
564 | bool config = true; |
---|
565 | bool cacheable = true; |
---|
566 | |
---|
567 | // the four following segments are defined in all clusters |
---|
568 | |
---|
569 | std::ostringstream smemc_conf; |
---|
570 | smemc_conf << "int_seg_memc_conf_" << x << "_" << y; |
---|
571 | maptab_int.add(Segment(smemc_conf.str(), MEMC_BASE+offset, MEMC_SIZE, |
---|
572 | IntTab(cluster(x,y),INT_MEMC_TGT_ID), not cacheable, config )); |
---|
573 | |
---|
574 | std::ostringstream smemc_xram; |
---|
575 | smemc_xram << "int_seg_memc_xram_" << x << "_" << y; |
---|
576 | maptab_int.add(Segment(smemc_xram.str(), XRAM_BASE+offset, XRAM_SIZE, |
---|
577 | IntTab(cluster(x,y),INT_MEMC_TGT_ID), cacheable)); |
---|
578 | |
---|
579 | std::ostringstream sxicu; |
---|
580 | sxicu << "int_seg_xicu_" << x << "_" << y; |
---|
581 | maptab_int.add(Segment(sxicu.str(), XICU_BASE+offset, XICU_SIZE, |
---|
582 | IntTab(cluster(x,y),INT_XICU_TGT_ID), not cacheable)); |
---|
583 | |
---|
584 | std::ostringstream smdma; |
---|
585 | smdma << "int_seg_mdma_" << x << "_" << y; |
---|
586 | maptab_int.add(Segment(smdma.str(), MDMA_BASE+offset, MDMA_SIZE, |
---|
587 | IntTab(cluster(x,y),INT_MDMA_TGT_ID), not cacheable)); |
---|
588 | |
---|
589 | // the following segments are only defined in cluster_iob0 or in cluster_iob1 |
---|
590 | |
---|
591 | if ( (cluster(x,y) == cluster_iob0) or (cluster(x,y) == cluster_iob1) ) |
---|
592 | { |
---|
593 | std::ostringstream siobx; |
---|
594 | siobx << "int_seg_iobx_" << x << "_" << y; |
---|
595 | maptab_int.add(Segment(siobx.str(), IOBX_BASE+offset, IOBX_SIZE, |
---|
596 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable, config )); |
---|
597 | |
---|
598 | std::ostringstream stty; |
---|
599 | stty << "int_seg_mtty_" << x << "_" << y; |
---|
600 | maptab_int.add(Segment(stty.str(), MTTY_BASE+offset, MTTY_SIZE, |
---|
601 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable)); |
---|
602 | |
---|
603 | std::ostringstream sfbf; |
---|
604 | sfbf << "int_seg_fbuf_" << x << "_" << y; |
---|
605 | maptab_int.add(Segment(sfbf.str(), FBUF_BASE+offset, FBUF_SIZE, |
---|
606 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable)); |
---|
607 | |
---|
608 | std::ostringstream sbdv; |
---|
609 | sbdv << "int_seg_bdev_" << x << "_" << y; |
---|
610 | maptab_int.add(Segment(sbdv.str(), BDEV_BASE+offset, BDEV_SIZE, |
---|
611 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable)); |
---|
612 | |
---|
613 | std::ostringstream snic; |
---|
614 | snic << "int_seg_mnic_" << x << "_" << y; |
---|
615 | maptab_int.add(Segment(snic.str(), MNIC_BASE+offset, MNIC_SIZE, |
---|
616 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable)); |
---|
617 | |
---|
618 | std::ostringstream srom; |
---|
619 | srom << "int_seg_brom_" << x << "_" << y; |
---|
620 | maptab_int.add(Segment(srom.str(), BROM_BASE+offset, BROM_SIZE, |
---|
621 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), cacheable )); |
---|
622 | |
---|
623 | std::ostringstream sdma; |
---|
624 | sdma << "int_seg_cdma_" << x << "_" << y; |
---|
625 | maptab_int.add(Segment(sdma.str(), CDMA_BASE+offset, CDMA_SIZE, |
---|
626 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable)); |
---|
627 | |
---|
628 | std::ostringstream spic; |
---|
629 | spic << "int_seg_iopi_" << x << "_" << y; |
---|
630 | maptab_int.add(Segment(spic.str(), IOPI_BASE+offset, IOPI_SIZE, |
---|
631 | IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable)); |
---|
632 | } |
---|
633 | |
---|
634 | // This define the mapping between the SRCIDs |
---|
635 | // and the port index on the local interconnect. |
---|
636 | |
---|
637 | maptab_int.srcid_map( IntTab( cluster(x,y), MDMA_LOCAL_SRCID ), |
---|
638 | IntTab( cluster(x,y), INT_MDMA_INI_ID ) ); |
---|
639 | |
---|
640 | maptab_int.srcid_map( IntTab( cluster(x,y), IOBX_LOCAL_SRCID ), |
---|
641 | IntTab( cluster(x,y), INT_IOBX_INI_ID ) ); |
---|
642 | |
---|
643 | maptab_int.srcid_map( IntTab( cluster(x,y), IOPI_LOCAL_SRCID ), |
---|
644 | IntTab( cluster(x,y), INT_IOBX_INI_ID ) ); |
---|
645 | |
---|
646 | for ( size_t p = 0 ; p < NB_PROCS_MAX ; p++ ) |
---|
647 | maptab_int.srcid_map( IntTab( cluster(x,y), PROC_LOCAL_SRCID+p ), |
---|
648 | IntTab( cluster(x,y), INT_PROC_INI_ID+p ) ); |
---|
649 | } |
---|
650 | } |
---|
651 | std::cout << "INT network " << maptab_int << std::endl; |
---|
652 | |
---|
653 | ///////////////////////////////////////////////////////////////////////// |
---|
654 | // RAM network mapping table |
---|
655 | // - two levels address decoding for commands |
---|
656 | // - two levels srcid decoding for responses |
---|
657 | // - 2 local initiators (MEMC, IOBX) per cluster |
---|
658 | // (IOBX component only in cluster_iob0 and cluster_iob1) |
---|
659 | // - 1 local target (XRAM) per cluster |
---|
660 | //////////////////////////////////////////////////////////////////////// |
---|
661 | MappingTable maptab_ram( vci_address_width, |
---|
662 | IntTab(x_width+y_width, 16 - x_width - y_width), |
---|
663 | IntTab(x_width+y_width, vci_srcid_width - x_width - y_width), |
---|
664 | 0x00FF000000); |
---|
665 | |
---|
666 | for (size_t x = 0; x < XMAX; x++) |
---|
667 | { |
---|
668 | for (size_t y = 0; y < YMAX ; y++) |
---|
669 | { |
---|
670 | uint64_t offset = ((uint64_t)cluster(x,y)) |
---|
671 | << (vci_address_width-x_width-y_width); |
---|
672 | |
---|
673 | std::ostringstream sxram; |
---|
674 | sxram << "ext_seg_xram_" << x << "_" << y; |
---|
675 | maptab_ram.add(Segment(sxram.str(), XRAM_BASE+offset, |
---|
676 | XRAM_SIZE, IntTab(cluster(x,y), 0), false)); |
---|
677 | } |
---|
678 | } |
---|
679 | |
---|
680 | // This define the mapping between the initiators SRCID |
---|
681 | // and the port index on the RAM local interconnect. |
---|
682 | // External initiator have two alias SRCID (iob0 / iob1) |
---|
683 | |
---|
684 | maptab_ram.srcid_map( IntTab( cluster_iob0, CDMA_LOCAL_SRCID ), |
---|
685 | IntTab( cluster_iob0, RAM_IOBX_INI_ID ) ); |
---|
686 | |
---|
687 | maptab_ram.srcid_map( IntTab( cluster_iob1, CDMA_LOCAL_SRCID ), |
---|
688 | IntTab( cluster_iob1, RAM_IOBX_INI_ID ) ); |
---|
689 | |
---|
690 | maptab_ram.srcid_map( IntTab( cluster_iob0, BDEV_LOCAL_SRCID ), |
---|
691 | IntTab( cluster_iob0, RAM_IOBX_INI_ID ) ); |
---|
692 | |
---|
693 | maptab_ram.srcid_map( IntTab( cluster_iob1, BDEV_LOCAL_SRCID ), |
---|
694 | IntTab( cluster_iob1, RAM_IOBX_INI_ID ) ); |
---|
695 | |
---|
696 | maptab_ram.srcid_map( IntTab( cluster_iob1, MEMC_LOCAL_SRCID ), |
---|
697 | IntTab( cluster_iob1, RAM_MEMC_INI_ID ) ); |
---|
698 | |
---|
699 | std::cout << "RAM network " << maptab_ram << std::endl; |
---|
700 | |
---|
701 | /////////////////////////////////////////////////////////////////////// |
---|
702 | // IOX network mapping table |
---|
703 | // - two levels address decoding for commands |
---|
704 | // - two levels srcid decoding for responses |
---|
705 | // - 5 initiators (IOB0, IOB1, BDEV, CDMA, IOPI) |
---|
706 | // - 9 targets (IOB0, IOB1, BDEV, CDMA, MTTY, FBUF, BROM, MNIC, IOPI) |
---|
707 | /////////////////////////////////////////////////////////////////////// |
---|
708 | MappingTable maptab_iox( vci_address_width, |
---|
709 | IntTab(x_width+y_width, 16 - x_width - y_width), |
---|
710 | IntTab(x_width+y_width, vci_srcid_width - x_width - y_width), |
---|
711 | 0x00FF000000); |
---|
712 | |
---|
713 | // compute base addresses for cluster_iob0 and cluster_iob1 |
---|
714 | uint64_t iob0_base = ((uint64_t)cluster_iob0) << (vci_address_width - x_width - y_width); |
---|
715 | uint64_t iob1_base = ((uint64_t)cluster_iob1) << (vci_address_width - x_width - y_width); |
---|
716 | |
---|
717 | // External peripherals segments |
---|
718 | // WHen there is more than one cluster, external peripherals can be accessed |
---|
719 | // through two segments, depending on the used IOB (IOB0 or IOB1). |
---|
720 | maptab_iox.add(Segment("iox_seg_mtty_0", MTTY_BASE + iob0_base, MTTY_SIZE, |
---|
721 | IntTab(cluster_iob0,IOX_MTTY_TGT_ID), false)); |
---|
722 | maptab_iox.add(Segment("iox_seg_fbuf_0", FBUF_BASE + iob0_base, FBUF_SIZE, |
---|
723 | IntTab(cluster_iob0,IOX_FBUF_TGT_ID), false)); |
---|
724 | maptab_iox.add(Segment("iox_seg_bdev_0", BDEV_BASE + iob0_base, BDEV_SIZE, |
---|
725 | IntTab(cluster_iob0,IOX_BDEV_TGT_ID), false)); |
---|
726 | maptab_iox.add(Segment("iox_seg_mnic_0", MNIC_BASE + iob0_base, MNIC_SIZE, |
---|
727 | IntTab(cluster_iob0,IOX_MNIC_TGT_ID), false)); |
---|
728 | maptab_iox.add(Segment("iox_seg_cdma_0", CDMA_BASE + iob0_base, CDMA_SIZE, |
---|
729 | IntTab(cluster_iob0,IOX_CDMA_TGT_ID), false)); |
---|
730 | maptab_iox.add(Segment("iox_seg_brom_0", BROM_BASE + iob0_base, BROM_SIZE, |
---|
731 | IntTab(cluster_iob0,IOX_BROM_TGT_ID), false)); |
---|
732 | maptab_iox.add(Segment("iox_seg_iopi_0", IOPI_BASE + iob0_base, IOPI_SIZE, |
---|
733 | IntTab(cluster_iob0,IOX_IOPI_TGT_ID), false)); |
---|
734 | |
---|
735 | if ( cluster_iob0 != cluster_iob1 ) |
---|
736 | { |
---|
737 | maptab_iox.add(Segment("iox_seg_mtty_1", MTTY_BASE + iob1_base, MTTY_SIZE, |
---|
738 | IntTab(cluster_iob1,IOX_MTTY_TGT_ID), false)); |
---|
739 | maptab_iox.add(Segment("iox_seg_fbuf_1", FBUF_BASE + iob1_base, FBUF_SIZE, |
---|
740 | IntTab(cluster_iob1,IOX_FBUF_TGT_ID), false)); |
---|
741 | maptab_iox.add(Segment("iox_seg_bdev_1", BDEV_BASE + iob1_base, BDEV_SIZE, |
---|
742 | IntTab(cluster_iob1,IOX_BDEV_TGT_ID), false)); |
---|
743 | maptab_iox.add(Segment("iox_seg_mnic_1", MNIC_BASE + iob1_base, MNIC_SIZE, |
---|
744 | IntTab(cluster_iob1,IOX_MNIC_TGT_ID), false)); |
---|
745 | maptab_iox.add(Segment("iox_seg_cdma_1", CDMA_BASE + iob1_base, CDMA_SIZE, |
---|
746 | IntTab(cluster_iob1,IOX_CDMA_TGT_ID), false)); |
---|
747 | maptab_iox.add(Segment("iox_seg_brom_1", BROM_BASE + iob1_base, BROM_SIZE, |
---|
748 | IntTab(cluster_iob1,IOX_BROM_TGT_ID), false)); |
---|
749 | maptab_iox.add(Segment("iox_seg_iopi_1", IOPI_BASE + iob1_base, IOPI_SIZE, |
---|
750 | IntTab(cluster_iob1,IOX_IOPI_TGT_ID), false)); |
---|
751 | } |
---|
752 | |
---|
753 | // If there is more than one cluster, external peripherals |
---|
754 | // can access RAM through two segments (IOB0 / IOB1). |
---|
755 | // As IOMMU is not activated, addresses are 40 bits (physical addresses), |
---|
756 | // and the choice depends on address bit A[39]. |
---|
757 | for (size_t x = 0; x < XMAX; x++) |
---|
758 | { |
---|
759 | for (size_t y = 0; y < YMAX ; y++) |
---|
760 | { |
---|
761 | uint64_t offset = ((uint64_t)cluster(x,y)) |
---|
762 | << (vci_address_width-x_width-y_width); |
---|
763 | |
---|
764 | if ( (cluster_iob0 != cluster_iob1) and (x >= (XMAX/2)) ) // use IOB1 |
---|
765 | { |
---|
766 | std::ostringstream siob1; |
---|
767 | siob1 << "iox_seg_xram_" << x << "_" << y; |
---|
768 | maptab_iox.add(Segment(siob1.str(), offset, XRAM_SIZE, |
---|
769 | IntTab(cluster_iob1,IOX_IOB1_TGT_ID), false)); |
---|
770 | } |
---|
771 | else // USE IOB0 |
---|
772 | { |
---|
773 | std::ostringstream siob0; |
---|
774 | siob0 << "iox_seg_xram_" << x << "_" << y; |
---|
775 | maptab_iox.add(Segment(siob0.str(), offset, XRAM_SIZE, |
---|
776 | IntTab(cluster_iob0,IOX_IOB0_TGT_ID), false)); |
---|
777 | } |
---|
778 | } |
---|
779 | } |
---|
780 | |
---|
781 | // This define the mapping between the external initiators (SRCID) |
---|
782 | // and the port index on the IOX local interconnect. |
---|
783 | // If there is more than one cluster, external initiators |
---|
784 | // have two alias SRCID (iob0 / iob1 access) |
---|
785 | maptab_iox.srcid_map( IntTab( cluster_iob0, CDMA_LOCAL_SRCID ), |
---|
786 | IntTab( cluster_iob0, IOX_CDMA_INI_ID ) ); |
---|
787 | maptab_iox.srcid_map( IntTab( cluster_iob0, BDEV_LOCAL_SRCID ), |
---|
788 | IntTab( cluster_iob0, IOX_BDEV_INI_ID ) ); |
---|
789 | maptab_iox.srcid_map( IntTab( cluster_iob0, IOPI_LOCAL_SRCID ), |
---|
790 | IntTab( cluster_iob0, IOX_IOPI_INI_ID ) ); |
---|
791 | |
---|
792 | if ( cluster_iob0 != cluster_iob1 ) |
---|
793 | { |
---|
794 | maptab_iox.srcid_map( IntTab( cluster_iob1, CDMA_LOCAL_SRCID ), |
---|
795 | IntTab( cluster_iob1, IOX_CDMA_INI_ID ) ); |
---|
796 | maptab_iox.srcid_map( IntTab( cluster_iob1, BDEV_LOCAL_SRCID ), |
---|
797 | IntTab( cluster_iob1, IOX_BDEV_INI_ID ) ); |
---|
798 | maptab_iox.srcid_map( IntTab( cluster_iob1, BDEV_LOCAL_SRCID ), |
---|
799 | IntTab( cluster_iob1, IOX_IOPI_INI_ID ) ); |
---|
800 | } |
---|
801 | |
---|
802 | // This define the mapping between the internal initiators (SRCID) |
---|
803 | // and the port index on the IOX local interconnect. |
---|
804 | // If there is more than one cluster, external initiators |
---|
805 | |
---|
806 | for (size_t x = 0; x < XMAX; x++) |
---|
807 | { |
---|
808 | for (size_t y = 0; y < YMAX ; y++) |
---|
809 | { |
---|
810 | if ( (cluster_iob0 != cluster_iob1) and (x >= (XMAX/2)) ) // use IOB1 |
---|
811 | { |
---|
812 | for (size_t p = 0 ; p < NB_PROCS_MAX ; p++) |
---|
813 | maptab_iox.srcid_map( IntTab( cluster(x,y), PROC_LOCAL_SRCID + p ), |
---|
814 | IntTab( cluster_iob1, IOX_IOB1_INI_ID ) ); |
---|
815 | |
---|
816 | maptab_iox.srcid_map( IntTab( cluster(x,y), MDMA_LOCAL_SRCID ), |
---|
817 | IntTab( cluster_iob1, IOX_IOB1_INI_ID ) ); |
---|
818 | } |
---|
819 | else // USE IOB0 |
---|
820 | { |
---|
821 | for (size_t p = 0 ; p < NB_PROCS_MAX ; p++) |
---|
822 | maptab_iox.srcid_map( IntTab( cluster(x,y), PROC_LOCAL_SRCID + p ), |
---|
823 | IntTab( cluster_iob0, IOX_IOB0_INI_ID ) ); |
---|
824 | |
---|
825 | maptab_iox.srcid_map( IntTab( cluster(x,y), MDMA_LOCAL_SRCID ), |
---|
826 | IntTab( cluster_iob0, IOX_IOB0_INI_ID ) ); |
---|
827 | } |
---|
828 | } |
---|
829 | } |
---|
830 | |
---|
831 | std::cout << "IOX network " << maptab_iox << std::endl; |
---|
832 | |
---|
833 | //////////////////// |
---|
834 | // Signals |
---|
835 | /////////////////// |
---|
836 | |
---|
837 | sc_clock signal_clk("clk"); |
---|
838 | sc_signal<bool> signal_resetn("resetn"); |
---|
839 | |
---|
840 | sc_signal<bool> signal_irq_false; |
---|
841 | sc_signal<bool> signal_irq_bdev; |
---|
842 | sc_signal<bool> signal_irq_mtty_rx; |
---|
843 | sc_signal<bool> signal_irq_mnic_rx[NB_NIC_CHANNELS]; |
---|
844 | sc_signal<bool> signal_irq_mnic_tx[NB_NIC_CHANNELS]; |
---|
845 | sc_signal<bool> signal_irq_cdma[NB_CMA_CHANNELS]; |
---|
846 | |
---|
847 | // DSPIN signals for loopback in cluster_iob0 & cluster_iob1 |
---|
848 | DspinSignals<dspin_ram_cmd_width> signal_dspin_cmd_iob0_loopback; |
---|
849 | DspinSignals<dspin_ram_rsp_width> signal_dspin_rsp_iob0_loopback; |
---|
850 | DspinSignals<dspin_ram_cmd_width> signal_dspin_cmd_iob1_loopback; |
---|
851 | DspinSignals<dspin_ram_rsp_width> signal_dspin_rsp_iob1_loopback; |
---|
852 | |
---|
853 | // VCI signals for IOX network |
---|
854 | VciSignals<vci_param_ext> signal_vci_ini_iob0("signal_vci_ini_iob0"); |
---|
855 | VciSignals<vci_param_ext> signal_vci_ini_iob1("signal_vci_ini_iob1"); |
---|
856 | VciSignals<vci_param_ext> signal_vci_ini_bdev("signal_vci_ini_bdev"); |
---|
857 | VciSignals<vci_param_ext> signal_vci_ini_cdma("signal_vci_ini_cdma"); |
---|
858 | VciSignals<vci_param_ext> signal_vci_ini_iopi("signal_vci_ini_iopi"); |
---|
859 | |
---|
860 | VciSignals<vci_param_ext> signal_vci_tgt_iob0("signal_vci_tgt_iob0"); |
---|
861 | VciSignals<vci_param_ext> signal_vci_tgt_iob1("signal_vci_tgt_iob1"); |
---|
862 | VciSignals<vci_param_ext> signal_vci_tgt_mtty("signal_vci_tgt_mtty"); |
---|
863 | VciSignals<vci_param_ext> signal_vci_tgt_fbuf("signal_vci_tgt_fbuf"); |
---|
864 | VciSignals<vci_param_ext> signal_vci_tgt_mnic("signal_vci_tgt_mnic"); |
---|
865 | VciSignals<vci_param_ext> signal_vci_tgt_brom("signal_vci_tgt_brom"); |
---|
866 | VciSignals<vci_param_ext> signal_vci_tgt_bdev("signal_vci_tgt_bdev"); |
---|
867 | VciSignals<vci_param_ext> signal_vci_tgt_cdma("signal_vci_tgt_cdma"); |
---|
868 | VciSignals<vci_param_ext> signal_vci_tgt_iopi("signal_vci_ini_iopi"); |
---|
869 | |
---|
870 | // Horizontal inter-clusters INT network DSPIN |
---|
871 | DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_inc = |
---|
872 | alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_inc", XMAX-1, YMAX, 3); |
---|
873 | DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_dec = |
---|
874 | alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_dec", XMAX-1, YMAX, 3); |
---|
875 | DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_h_inc = |
---|
876 | alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_h_inc", XMAX-1, YMAX, 2); |
---|
877 | DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_h_dec = |
---|
878 | alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_h_dec", XMAX-1, YMAX, 2); |
---|
879 | |
---|
880 | // Vertical inter-clusters INT network DSPIN |
---|
881 | DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_inc = |
---|
882 | alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_inc", XMAX, YMAX-1, 3); |
---|
883 | DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_dec = |
---|
884 | alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_dec", XMAX, YMAX-1, 3); |
---|
885 | DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_v_inc = |
---|
886 | alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_v_inc", XMAX, YMAX-1, 2); |
---|
887 | DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_v_dec = |
---|
888 | alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_v_dec", XMAX, YMAX-1, 2); |
---|
889 | |
---|
890 | // Mesh boundaries INT network DSPIN |
---|
891 | DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_in = |
---|
892 | alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_in", XMAX, YMAX, 4, 3); |
---|
893 | DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_out = |
---|
894 | alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_out", XMAX, YMAX, 4, 3); |
---|
895 | DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_in = |
---|
896 | alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_in", XMAX, YMAX, 4, 2); |
---|
897 | DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_out = |
---|
898 | alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_out", XMAX, YMAX, 4, 2); |
---|
899 | |
---|
900 | |
---|
901 | // Horizontal inter-clusters RAM network DSPIN |
---|
902 | DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_h_inc = |
---|
903 | alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_h_inc", XMAX-1, YMAX); |
---|
904 | DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_h_dec = |
---|
905 | alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_h_dec", XMAX-1, YMAX); |
---|
906 | DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_h_inc = |
---|
907 | alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_h_inc", XMAX-1, YMAX); |
---|
908 | DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_h_dec = |
---|
909 | alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_h_dec", XMAX-1, YMAX); |
---|
910 | |
---|
911 | // Vertical inter-clusters RAM network DSPIN |
---|
912 | DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_v_inc = |
---|
913 | alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_v_inc", XMAX, YMAX-1); |
---|
914 | DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_v_dec = |
---|
915 | alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_v_dec", XMAX, YMAX-1); |
---|
916 | DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_v_inc = |
---|
917 | alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_v_inc", XMAX, YMAX-1); |
---|
918 | DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_v_dec = |
---|
919 | alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_v_dec", XMAX, YMAX-1); |
---|
920 | |
---|
921 | // Mesh boundaries RAM network DSPIN |
---|
922 | DspinSignals<dspin_ram_cmd_width>*** signal_dspin_false_ram_cmd_in = |
---|
923 | alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_false_ram_cmd_in", XMAX, YMAX, 4); |
---|
924 | DspinSignals<dspin_ram_cmd_width>*** signal_dspin_false_ram_cmd_out = |
---|
925 | alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_false_ram_cmd_out", XMAX, YMAX, 4); |
---|
926 | DspinSignals<dspin_ram_rsp_width>*** signal_dspin_false_ram_rsp_in = |
---|
927 | alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_false_ram_rsp_in", XMAX, YMAX, 4); |
---|
928 | DspinSignals<dspin_ram_rsp_width>*** signal_dspin_false_ram_rsp_out = |
---|
929 | alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_false_ram_rsp_out", XMAX, YMAX, 4); |
---|
930 | |
---|
931 | //////////////////////////// |
---|
932 | // Loader |
---|
933 | //////////////////////////// |
---|
934 | |
---|
935 | #if USE_ALMOS |
---|
936 | soclib::common::Loader loader(almos_bootloader_pathname, |
---|
937 | almos_archinfo_pathname, |
---|
938 | almos_kernel_pathname); |
---|
939 | #else |
---|
940 | soclib::common::Loader loader(soft_name); |
---|
941 | #endif |
---|
942 | |
---|
943 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
944 | proc_iss::set_loader(loader); |
---|
945 | |
---|
946 | //////////////////////////////////////// |
---|
947 | // Instanciated Hardware Components |
---|
948 | //////////////////////////////////////// |
---|
949 | |
---|
950 | std::cout << std::endl << "External Bus and Peripherals" << std::endl << std::endl; |
---|
951 | |
---|
952 | // IOX network |
---|
953 | VciIoxNetwork<vci_param_ext>* iox_network; |
---|
954 | iox_network = new VciIoxNetwork<vci_param_ext>( "iox_network", |
---|
955 | maptab_iox, |
---|
956 | 9, // number of targets |
---|
957 | 5 ); // number of initiators |
---|
958 | // boot ROM |
---|
959 | VciSimpleRom<vci_param_ext>* brom; |
---|
960 | brom = new VciSimpleRom<vci_param_ext>( "brom", |
---|
961 | IntTab(0, IOX_BROM_TGT_ID), |
---|
962 | maptab_iox, |
---|
963 | loader ); |
---|
964 | // Network Controller |
---|
965 | VciMultiNic<vci_param_ext>* mnic; |
---|
966 | mnic = new VciMultiNic<vci_param_ext>( "mnic", |
---|
967 | IntTab(0, IOX_MNIC_TGT_ID), |
---|
968 | maptab_iox, |
---|
969 | NB_NIC_CHANNELS, |
---|
970 | 0, // mac_4 address |
---|
971 | 0, // mac_2 address |
---|
972 | nic_rx_name, |
---|
973 | nic_tx_name); |
---|
974 | |
---|
975 | // Frame Buffer |
---|
976 | VciFrameBuffer<vci_param_ext>* fbuf; |
---|
977 | fbuf = new VciFrameBuffer<vci_param_ext>( "fbuf", |
---|
978 | IntTab(0, IOX_FBUF_TGT_ID), |
---|
979 | maptab_iox, |
---|
980 | FBUF_X_SIZE, FBUF_Y_SIZE ); |
---|
981 | |
---|
982 | // Block Device |
---|
983 | // for AHCI |
---|
984 | // std::vector<std::string> filenames; |
---|
985 | // filenames.push_back(disk_name); // one single disk |
---|
986 | VciBlockDeviceTsar<vci_param_ext>* bdev; |
---|
987 | bdev = new VciBlockDeviceTsar<vci_param_ext>( "bdev", |
---|
988 | maptab_iox, |
---|
989 | IntTab(0, BDEV_LOCAL_SRCID), |
---|
990 | IntTab(0, IOX_BDEV_TGT_ID), |
---|
991 | disk_name, |
---|
992 | 512, // block size |
---|
993 | 64, // burst size (bytes) |
---|
994 | 0 ); // disk latency |
---|
995 | |
---|
996 | // Chained Buffer DMA controller |
---|
997 | VciChbufDma<vci_param_ext>* cdma; |
---|
998 | cdma = new VciChbufDma<vci_param_ext>( "cdma", |
---|
999 | maptab_iox, |
---|
1000 | IntTab(0, CDMA_LOCAL_SRCID), |
---|
1001 | IntTab(0, IOX_CDMA_TGT_ID), |
---|
1002 | 64, // burst size (bytes) |
---|
1003 | 2*NB_NIC_CHANNELS ); |
---|
1004 | // Multi-TTY controller |
---|
1005 | std::vector<std::string> vect_names; |
---|
1006 | for( size_t tid = 0 ; tid < NB_TTY_CHANNELS ; tid++ ) |
---|
1007 | { |
---|
1008 | std::ostringstream term_name; |
---|
1009 | term_name << "term" << tid; |
---|
1010 | vect_names.push_back(term_name.str().c_str()); |
---|
1011 | } |
---|
1012 | VciMultiTty<vci_param_ext>* mtty; |
---|
1013 | mtty = new VciMultiTty<vci_param_ext>( "mtty", |
---|
1014 | IntTab(0, IOX_MTTY_TGT_ID), |
---|
1015 | maptab_iox, |
---|
1016 | vect_names); |
---|
1017 | |
---|
1018 | // IOPIC |
---|
1019 | VciIopic<vci_param_ext>* iopi; |
---|
1020 | iopi = new VciIopic<vci_param_ext>( "iopi", |
---|
1021 | maptab_iox, |
---|
1022 | IntTab(0, IOPI_LOCAL_SRCID), |
---|
1023 | IntTab(0, IOX_IOPI_TGT_ID), |
---|
1024 | 32 ); // number of input HWI |
---|
1025 | // Clusters |
---|
1026 | TsarIobCluster<vci_param_int, |
---|
1027 | vci_param_ext, |
---|
1028 | dspin_int_cmd_width, |
---|
1029 | dspin_int_rsp_width, |
---|
1030 | dspin_ram_cmd_width, |
---|
1031 | dspin_ram_rsp_width>* clusters[XMAX][YMAX]; |
---|
1032 | |
---|
1033 | #if USE_OPENMP |
---|
1034 | #pragma omp parallel |
---|
1035 | { |
---|
1036 | #pragma omp for |
---|
1037 | #endif |
---|
1038 | for(size_t i = 0; i < (XMAX * YMAX); i++) |
---|
1039 | { |
---|
1040 | size_t x = i / YMAX; |
---|
1041 | size_t y = i % YMAX; |
---|
1042 | |
---|
1043 | #if USE_OPENMP |
---|
1044 | #pragma omp critical |
---|
1045 | { |
---|
1046 | #endif |
---|
1047 | std::cout << std::endl; |
---|
1048 | std::cout << "Cluster_" << std::dec << x << "_" << y << std::endl; |
---|
1049 | std::cout << std::endl; |
---|
1050 | |
---|
1051 | std::ostringstream sc; |
---|
1052 | sc << "cluster_" << x << "_" << y; |
---|
1053 | clusters[x][y] = new TsarIobCluster<vci_param_int, |
---|
1054 | vci_param_ext, |
---|
1055 | dspin_int_cmd_width, |
---|
1056 | dspin_int_rsp_width, |
---|
1057 | dspin_ram_cmd_width, |
---|
1058 | dspin_ram_rsp_width> |
---|
1059 | ( |
---|
1060 | sc.str().c_str(), |
---|
1061 | NB_PROCS_MAX, |
---|
1062 | NB_DMA_CHANNELS, |
---|
1063 | x, |
---|
1064 | y, |
---|
1065 | XMAX, |
---|
1066 | YMAX, |
---|
1067 | |
---|
1068 | maptab_int, |
---|
1069 | maptab_ram, |
---|
1070 | maptab_iox, |
---|
1071 | |
---|
1072 | x_width, |
---|
1073 | y_width, |
---|
1074 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
1075 | |
---|
1076 | INT_MEMC_TGT_ID, |
---|
1077 | INT_XICU_TGT_ID, |
---|
1078 | INT_MDMA_TGT_ID, |
---|
1079 | INT_IOBX_TGT_ID, |
---|
1080 | |
---|
1081 | INT_PROC_INI_ID, |
---|
1082 | INT_MDMA_INI_ID, |
---|
1083 | INT_IOBX_INI_ID, |
---|
1084 | |
---|
1085 | RAM_XRAM_TGT_ID, |
---|
1086 | |
---|
1087 | RAM_MEMC_INI_ID, |
---|
1088 | RAM_IOBX_INI_ID, |
---|
1089 | |
---|
1090 | MEMC_WAYS, |
---|
1091 | MEMC_SETS, |
---|
1092 | L1_IWAYS, |
---|
1093 | L1_ISETS, |
---|
1094 | L1_DWAYS, |
---|
1095 | L1_DSETS, |
---|
1096 | XRAM_LATENCY, |
---|
1097 | XCU_NB_INPUTS, |
---|
1098 | |
---|
1099 | loader, |
---|
1100 | |
---|
1101 | frozen_cycles, |
---|
1102 | debug_from, |
---|
1103 | debug_ok and (cluster(x,y) == debug_memc_id), |
---|
1104 | debug_ok and (cluster(x,y) == debug_proc_id), |
---|
1105 | debug_ok and debug_iob |
---|
1106 | ); |
---|
1107 | |
---|
1108 | #if USE_OPENMP |
---|
1109 | } // end critical |
---|
1110 | #endif |
---|
1111 | } // end for |
---|
1112 | #if USE_OPENMP |
---|
1113 | } |
---|
1114 | #endif |
---|
1115 | |
---|
1116 | std::cout << std::endl; |
---|
1117 | |
---|
1118 | /////////////////////////////////////////////////////////////////////////////// |
---|
1119 | // Net-list |
---|
1120 | /////////////////////////////////////////////////////////////////////////////// |
---|
1121 | |
---|
1122 | // IOX network connexion |
---|
1123 | iox_network->p_clk (signal_clk); |
---|
1124 | iox_network->p_resetn (signal_resetn); |
---|
1125 | iox_network->p_to_ini[IOX_IOB0_INI_ID] (signal_vci_ini_iob0); |
---|
1126 | iox_network->p_to_ini[IOX_IOB1_INI_ID] (signal_vci_ini_iob1); |
---|
1127 | iox_network->p_to_ini[IOX_BDEV_INI_ID] (signal_vci_ini_bdev); |
---|
1128 | iox_network->p_to_ini[IOX_CDMA_INI_ID] (signal_vci_ini_cdma); |
---|
1129 | iox_network->p_to_ini[IOX_IOPI_INI_ID] (signal_vci_ini_iopi); |
---|
1130 | |
---|
1131 | iox_network->p_to_tgt[IOX_IOB0_TGT_ID] (signal_vci_tgt_iob0); |
---|
1132 | iox_network->p_to_tgt[IOX_IOB1_TGT_ID] (signal_vci_tgt_iob1); |
---|
1133 | iox_network->p_to_tgt[IOX_MTTY_TGT_ID] (signal_vci_tgt_mtty); |
---|
1134 | iox_network->p_to_tgt[IOX_FBUF_TGT_ID] (signal_vci_tgt_fbuf); |
---|
1135 | iox_network->p_to_tgt[IOX_MNIC_TGT_ID] (signal_vci_tgt_mnic); |
---|
1136 | iox_network->p_to_tgt[IOX_BROM_TGT_ID] (signal_vci_tgt_brom); |
---|
1137 | iox_network->p_to_tgt[IOX_BDEV_TGT_ID] (signal_vci_tgt_bdev); |
---|
1138 | iox_network->p_to_tgt[IOX_CDMA_TGT_ID] (signal_vci_tgt_cdma); |
---|
1139 | iox_network->p_to_tgt[IOX_IOPI_TGT_ID] (signal_vci_tgt_iopi); |
---|
1140 | |
---|
1141 | // BDEV connexion |
---|
1142 | bdev->p_clk (signal_clk); |
---|
1143 | bdev->p_resetn (signal_resetn); |
---|
1144 | bdev->p_irq (signal_irq_bdev); |
---|
1145 | bdev->p_vci_target (signal_vci_tgt_bdev); |
---|
1146 | bdev->p_vci_initiator (signal_vci_ini_bdev); |
---|
1147 | |
---|
1148 | std::cout << " - BDEV connected" << std::endl; |
---|
1149 | |
---|
1150 | // FBUF connexion |
---|
1151 | fbuf->p_clk (signal_clk); |
---|
1152 | fbuf->p_resetn (signal_resetn); |
---|
1153 | fbuf->p_vci (signal_vci_tgt_fbuf); |
---|
1154 | |
---|
1155 | std::cout << " - FBUF connected" << std::endl; |
---|
1156 | |
---|
1157 | // MNIC connexion |
---|
1158 | mnic->p_clk (signal_clk); |
---|
1159 | mnic->p_resetn (signal_resetn); |
---|
1160 | mnic->p_vci (signal_vci_tgt_mnic); |
---|
1161 | for ( size_t i=0 ; i<NB_NIC_CHANNELS ; i++ ) |
---|
1162 | { |
---|
1163 | mnic->p_rx_irq[i] (signal_irq_mnic_rx[i]); |
---|
1164 | mnic->p_tx_irq[i] (signal_irq_mnic_tx[i]); |
---|
1165 | } |
---|
1166 | |
---|
1167 | std::cout << " - MNIC connected" << std::endl; |
---|
1168 | |
---|
1169 | // BROM connexion |
---|
1170 | brom->p_clk (signal_clk); |
---|
1171 | brom->p_resetn (signal_resetn); |
---|
1172 | brom->p_vci (signal_vci_tgt_brom); |
---|
1173 | |
---|
1174 | std::cout << " - BROM connected" << std::endl; |
---|
1175 | |
---|
1176 | // MTTY connexion |
---|
1177 | mtty->p_clk (signal_clk); |
---|
1178 | mtty->p_resetn (signal_resetn); |
---|
1179 | mtty->p_vci (signal_vci_tgt_mtty); |
---|
1180 | mtty->p_irq[0] (signal_irq_mtty_rx); |
---|
1181 | |
---|
1182 | std::cout << " - MTTY connected" << std::endl; |
---|
1183 | |
---|
1184 | // CDMA connexion |
---|
1185 | cdma->p_clk (signal_clk); |
---|
1186 | cdma->p_resetn (signal_resetn); |
---|
1187 | cdma->p_vci_target (signal_vci_tgt_cdma); |
---|
1188 | cdma->p_vci_initiator (signal_vci_ini_cdma); |
---|
1189 | for ( size_t i=0 ; i<(NB_NIC_CHANNELS*2) ; i++) |
---|
1190 | { |
---|
1191 | cdma->p_irq[i] (signal_irq_cdma[i]); |
---|
1192 | } |
---|
1193 | |
---|
1194 | std::cout << " - CDMA connected" << std::endl; |
---|
1195 | |
---|
1196 | // IOPI connexion |
---|
1197 | iopi->p_clk (signal_clk); |
---|
1198 | iopi->p_resetn (signal_resetn); |
---|
1199 | iopi->p_vci_target (signal_vci_tgt_iopi); |
---|
1200 | iopi->p_vci_initiator (signal_vci_ini_iopi); |
---|
1201 | for ( size_t i=0 ; i<32 ; i++) |
---|
1202 | { |
---|
1203 | if (i < NB_NIC_CHANNELS) iopi->p_hwi[i] (signal_irq_mnic_rx[i]); |
---|
1204 | else if(i < 2 ) iopi->p_hwi[i] (signal_irq_false); |
---|
1205 | else if(i < 2+NB_NIC_CHANNELS) iopi->p_hwi[i] (signal_irq_mnic_tx[i-2]); |
---|
1206 | else if(i < 4 ) iopi->p_hwi[i] (signal_irq_false); |
---|
1207 | else if(i < 4+NB_CMA_CHANNELS) iopi->p_hwi[i] (signal_irq_cdma[i-4]); |
---|
1208 | else if(i < 8) iopi->p_hwi[i] (signal_irq_false); |
---|
1209 | else if(i == 8) iopi->p_hwi[i] (signal_irq_bdev); |
---|
1210 | else if(i == 9) iopi->p_hwi[i] (signal_irq_mtty_rx); |
---|
1211 | else iopi->p_hwi[i] (signal_irq_false); |
---|
1212 | } |
---|
1213 | |
---|
1214 | std::cout << " - IOPIC connected" << std::endl; |
---|
1215 | |
---|
1216 | |
---|
1217 | // IOB0 cluster connexion to IOX network |
---|
1218 | (*clusters[0][0]->p_vci_iob_iox_ini) (signal_vci_ini_iob0); |
---|
1219 | (*clusters[0][0]->p_vci_iob_iox_tgt) (signal_vci_tgt_iob0); |
---|
1220 | |
---|
1221 | // IOB1 cluster connexion to IOX network |
---|
1222 | // (only when there is more than 1 cluster) |
---|
1223 | if ( cluster_iob0 != cluster_iob1 ) |
---|
1224 | { |
---|
1225 | (*clusters[XMAX-1][YMAX-1]->p_vci_iob_iox_ini) (signal_vci_ini_iob1); |
---|
1226 | (*clusters[XMAX-1][YMAX-1]->p_vci_iob_iox_tgt) (signal_vci_tgt_iob1); |
---|
1227 | } |
---|
1228 | |
---|
1229 | // All clusters Clock & RESET connexions |
---|
1230 | for ( size_t x = 0; x < (XMAX); x++ ) |
---|
1231 | { |
---|
1232 | for (size_t y = 0; y < YMAX; y++) |
---|
1233 | { |
---|
1234 | clusters[x][y]->p_clk (signal_clk); |
---|
1235 | clusters[x][y]->p_resetn (signal_resetn); |
---|
1236 | } |
---|
1237 | } |
---|
1238 | |
---|
1239 | // Inter Clusters horizontal connections |
---|
1240 | if (XMAX > 1) |
---|
1241 | { |
---|
1242 | for (size_t x = 0; x < (XMAX-1); x++) |
---|
1243 | { |
---|
1244 | for (size_t y = 0; y < YMAX; y++) |
---|
1245 | { |
---|
1246 | for (size_t k = 0; k < 3; k++) |
---|
1247 | { |
---|
1248 | clusters[x][y]->p_dspin_int_cmd_out[EAST][k] (signal_dspin_int_cmd_h_inc[x][y][k]); |
---|
1249 | clusters[x+1][y]->p_dspin_int_cmd_in[WEST][k] (signal_dspin_int_cmd_h_inc[x][y][k]); |
---|
1250 | clusters[x][y]->p_dspin_int_cmd_in[EAST][k] (signal_dspin_int_cmd_h_dec[x][y][k]); |
---|
1251 | clusters[x+1][y]->p_dspin_int_cmd_out[WEST][k] (signal_dspin_int_cmd_h_dec[x][y][k]); |
---|
1252 | } |
---|
1253 | |
---|
1254 | for (size_t k = 0; k < 2; k++) |
---|
1255 | { |
---|
1256 | clusters[x][y]->p_dspin_int_rsp_out[EAST][k] (signal_dspin_int_rsp_h_inc[x][y][k]); |
---|
1257 | clusters[x+1][y]->p_dspin_int_rsp_in[WEST][k] (signal_dspin_int_rsp_h_inc[x][y][k]); |
---|
1258 | clusters[x][y]->p_dspin_int_rsp_in[EAST][k] (signal_dspin_int_rsp_h_dec[x][y][k]); |
---|
1259 | clusters[x+1][y]->p_dspin_int_rsp_out[WEST][k] (signal_dspin_int_rsp_h_dec[x][y][k]); |
---|
1260 | } |
---|
1261 | |
---|
1262 | clusters[x][y]->p_dspin_ram_cmd_out[EAST] (signal_dspin_ram_cmd_h_inc[x][y]); |
---|
1263 | clusters[x+1][y]->p_dspin_ram_cmd_in[WEST] (signal_dspin_ram_cmd_h_inc[x][y]); |
---|
1264 | clusters[x][y]->p_dspin_ram_cmd_in[EAST] (signal_dspin_ram_cmd_h_dec[x][y]); |
---|
1265 | clusters[x+1][y]->p_dspin_ram_cmd_out[WEST] (signal_dspin_ram_cmd_h_dec[x][y]); |
---|
1266 | clusters[x][y]->p_dspin_ram_rsp_out[EAST] (signal_dspin_ram_rsp_h_inc[x][y]); |
---|
1267 | clusters[x+1][y]->p_dspin_ram_rsp_in[WEST] (signal_dspin_ram_rsp_h_inc[x][y]); |
---|
1268 | clusters[x][y]->p_dspin_ram_rsp_in[EAST] (signal_dspin_ram_rsp_h_dec[x][y]); |
---|
1269 | clusters[x+1][y]->p_dspin_ram_rsp_out[WEST] (signal_dspin_ram_rsp_h_dec[x][y]); |
---|
1270 | } |
---|
1271 | } |
---|
1272 | } |
---|
1273 | |
---|
1274 | std::cout << std::endl << "Horizontal connections established" << std::endl; |
---|
1275 | |
---|
1276 | // Inter Clusters vertical connections |
---|
1277 | if (YMAX > 1) |
---|
1278 | { |
---|
1279 | for (size_t y = 0; y < (YMAX-1); y++) |
---|
1280 | { |
---|
1281 | for (size_t x = 0; x < XMAX; x++) |
---|
1282 | { |
---|
1283 | for (size_t k = 0; k < 3; k++) |
---|
1284 | { |
---|
1285 | clusters[x][y]->p_dspin_int_cmd_out[NORTH][k] (signal_dspin_int_cmd_v_inc[x][y][k]); |
---|
1286 | clusters[x][y+1]->p_dspin_int_cmd_in[SOUTH][k] (signal_dspin_int_cmd_v_inc[x][y][k]); |
---|
1287 | clusters[x][y]->p_dspin_int_cmd_in[NORTH][k] (signal_dspin_int_cmd_v_dec[x][y][k]); |
---|
1288 | clusters[x][y+1]->p_dspin_int_cmd_out[SOUTH][k] (signal_dspin_int_cmd_v_dec[x][y][k]); |
---|
1289 | } |
---|
1290 | |
---|
1291 | for (size_t k = 0; k < 2; k++) |
---|
1292 | { |
---|
1293 | clusters[x][y]->p_dspin_int_rsp_out[NORTH][k] (signal_dspin_int_rsp_v_inc[x][y][k]); |
---|
1294 | clusters[x][y+1]->p_dspin_int_rsp_in[SOUTH][k] (signal_dspin_int_rsp_v_inc[x][y][k]); |
---|
1295 | clusters[x][y]->p_dspin_int_rsp_in[NORTH][k] (signal_dspin_int_rsp_v_dec[x][y][k]); |
---|
1296 | clusters[x][y+1]->p_dspin_int_rsp_out[SOUTH][k] (signal_dspin_int_rsp_v_dec[x][y][k]); |
---|
1297 | } |
---|
1298 | |
---|
1299 | clusters[x][y]->p_dspin_ram_cmd_out[NORTH] (signal_dspin_ram_cmd_v_inc[x][y]); |
---|
1300 | clusters[x][y+1]->p_dspin_ram_cmd_in[SOUTH] (signal_dspin_ram_cmd_v_inc[x][y]); |
---|
1301 | clusters[x][y]->p_dspin_ram_cmd_in[NORTH] (signal_dspin_ram_cmd_v_dec[x][y]); |
---|
1302 | clusters[x][y+1]->p_dspin_ram_cmd_out[SOUTH] (signal_dspin_ram_cmd_v_dec[x][y]); |
---|
1303 | clusters[x][y]->p_dspin_ram_rsp_out[NORTH] (signal_dspin_ram_rsp_v_inc[x][y]); |
---|
1304 | clusters[x][y+1]->p_dspin_ram_rsp_in[SOUTH] (signal_dspin_ram_rsp_v_inc[x][y]); |
---|
1305 | clusters[x][y]->p_dspin_ram_rsp_in[NORTH] (signal_dspin_ram_rsp_v_dec[x][y]); |
---|
1306 | clusters[x][y+1]->p_dspin_ram_rsp_out[SOUTH] (signal_dspin_ram_rsp_v_dec[x][y]); |
---|
1307 | } |
---|
1308 | } |
---|
1309 | } |
---|
1310 | |
---|
1311 | std::cout << "Vertical connections established" << std::endl; |
---|
1312 | |
---|
1313 | // East & West boundary cluster connections |
---|
1314 | for (size_t y = 0; y < YMAX; y++) |
---|
1315 | { |
---|
1316 | for (size_t k = 0; k < 3; k++) |
---|
1317 | { |
---|
1318 | clusters[0][y]->p_dspin_int_cmd_in[WEST][k] (signal_dspin_false_int_cmd_in[0][y][WEST][k]); |
---|
1319 | clusters[0][y]->p_dspin_int_cmd_out[WEST][k] (signal_dspin_false_int_cmd_out[0][y][WEST][k]); |
---|
1320 | clusters[XMAX-1][y]->p_dspin_int_cmd_in[EAST][k] (signal_dspin_false_int_cmd_in[XMAX-1][y][EAST][k]); |
---|
1321 | clusters[XMAX-1][y]->p_dspin_int_cmd_out[EAST][k] (signal_dspin_false_int_cmd_out[XMAX-1][y][EAST][k]); |
---|
1322 | } |
---|
1323 | |
---|
1324 | for (size_t k = 0; k < 2; k++) |
---|
1325 | { |
---|
1326 | clusters[0][y]->p_dspin_int_rsp_in[WEST][k] (signal_dspin_false_int_rsp_in[0][y][WEST][k]); |
---|
1327 | clusters[0][y]->p_dspin_int_rsp_out[WEST][k] (signal_dspin_false_int_rsp_out[0][y][WEST][k]); |
---|
1328 | clusters[XMAX-1][y]->p_dspin_int_rsp_in[EAST][k] (signal_dspin_false_int_rsp_in[XMAX-1][y][EAST][k]); |
---|
1329 | clusters[XMAX-1][y]->p_dspin_int_rsp_out[EAST][k] (signal_dspin_false_int_rsp_out[XMAX-1][y][EAST][k]); |
---|
1330 | } |
---|
1331 | |
---|
1332 | if( y == 0 ) // handling IOB to RAM network connection in cluster_iob0 |
---|
1333 | { |
---|
1334 | (*clusters[0][0]->p_dspin_iob_cmd_out) (signal_dspin_cmd_iob0_loopback); |
---|
1335 | clusters[0][0]->p_dspin_ram_cmd_in[WEST] (signal_dspin_cmd_iob0_loopback); |
---|
1336 | |
---|
1337 | clusters[0][0]->p_dspin_ram_cmd_out[WEST] (signal_dspin_false_ram_cmd_out[0][0][WEST]); |
---|
1338 | clusters[0][0]->p_dspin_ram_rsp_in[WEST] (signal_dspin_false_ram_rsp_in[0][0][WEST]); |
---|
1339 | |
---|
1340 | clusters[0][0]->p_dspin_ram_rsp_out[WEST] (signal_dspin_rsp_iob0_loopback); |
---|
1341 | (*clusters[0][0]->p_dspin_iob_rsp_in) (signal_dspin_rsp_iob0_loopback); |
---|
1342 | |
---|
1343 | } |
---|
1344 | else |
---|
1345 | { |
---|
1346 | clusters[0][y]->p_dspin_ram_cmd_in[WEST] (signal_dspin_false_ram_cmd_in[0][y][WEST]); |
---|
1347 | clusters[0][y]->p_dspin_ram_cmd_out[WEST] (signal_dspin_false_ram_cmd_out[0][y][WEST]); |
---|
1348 | clusters[0][y]->p_dspin_ram_rsp_in[WEST] (signal_dspin_false_ram_rsp_in[0][y][WEST]); |
---|
1349 | clusters[0][y]->p_dspin_ram_rsp_out[WEST] (signal_dspin_false_ram_rsp_out[0][y][WEST]); |
---|
1350 | } |
---|
1351 | |
---|
1352 | if( (y == YMAX-1) and (cluster_iob0 != cluster_iob1) ) // handling IOB to RAM network connection in cluster_iob1 |
---|
1353 | { |
---|
1354 | (*clusters[XMAX-1][YMAX-1]->p_dspin_iob_cmd_out) (signal_dspin_cmd_iob1_loopback); |
---|
1355 | clusters[XMAX-1][YMAX-1]->p_dspin_ram_cmd_in[EAST] (signal_dspin_cmd_iob1_loopback); |
---|
1356 | |
---|
1357 | clusters[XMAX-1][YMAX-1]->p_dspin_ram_cmd_out[EAST] (signal_dspin_false_ram_cmd_out[XMAX-1][YMAX-1][EAST]); |
---|
1358 | clusters[XMAX-1][YMAX-1]->p_dspin_ram_rsp_in[EAST] (signal_dspin_false_ram_rsp_in[XMAX-1][YMAX-1][EAST]); |
---|
1359 | |
---|
1360 | clusters[XMAX-1][YMAX-1]->p_dspin_ram_rsp_out[EAST] (signal_dspin_rsp_iob1_loopback); |
---|
1361 | (*clusters[XMAX-1][YMAX-1]->p_dspin_iob_rsp_in) (signal_dspin_rsp_iob1_loopback); |
---|
1362 | } |
---|
1363 | else |
---|
1364 | { |
---|
1365 | clusters[XMAX-1][y]->p_dspin_ram_cmd_in[EAST] (signal_dspin_false_ram_cmd_in[XMAX-1][y][EAST]); |
---|
1366 | clusters[XMAX-1][y]->p_dspin_ram_cmd_out[EAST] (signal_dspin_false_ram_cmd_out[XMAX-1][y][EAST]); |
---|
1367 | clusters[XMAX-1][y]->p_dspin_ram_rsp_in[EAST] (signal_dspin_false_ram_rsp_in[XMAX-1][y][EAST]); |
---|
1368 | clusters[XMAX-1][y]->p_dspin_ram_rsp_out[EAST] (signal_dspin_false_ram_rsp_out[XMAX-1][y][EAST]); |
---|
1369 | } |
---|
1370 | } |
---|
1371 | |
---|
1372 | std::cout << "East & West boundaries established" << std::endl; |
---|
1373 | |
---|
1374 | // North & South boundary clusters connections |
---|
1375 | for (size_t x = 0; x < XMAX; x++) |
---|
1376 | { |
---|
1377 | for (size_t k = 0; k < 3; k++) |
---|
1378 | { |
---|
1379 | clusters[x][0]->p_dspin_int_cmd_in[SOUTH][k] (signal_dspin_false_int_cmd_in[x][0][SOUTH][k]); |
---|
1380 | clusters[x][0]->p_dspin_int_cmd_out[SOUTH][k] (signal_dspin_false_int_cmd_out[x][0][SOUTH][k]); |
---|
1381 | clusters[x][YMAX-1]->p_dspin_int_cmd_in[NORTH][k] (signal_dspin_false_int_cmd_in[x][YMAX-1][NORTH][k]); |
---|
1382 | clusters[x][YMAX-1]->p_dspin_int_cmd_out[NORTH][k] (signal_dspin_false_int_cmd_out[x][YMAX-1][NORTH][k]); |
---|
1383 | } |
---|
1384 | |
---|
1385 | for (size_t k = 0; k < 2; k++) |
---|
1386 | { |
---|
1387 | clusters[x][0]->p_dspin_int_rsp_in[SOUTH][k] (signal_dspin_false_int_rsp_in[x][0][SOUTH][k]); |
---|
1388 | clusters[x][0]->p_dspin_int_rsp_out[SOUTH][k] (signal_dspin_false_int_rsp_out[x][0][SOUTH][k]); |
---|
1389 | clusters[x][YMAX-1]->p_dspin_int_rsp_in[NORTH][k] (signal_dspin_false_int_rsp_in[x][YMAX-1][NORTH][k]); |
---|
1390 | clusters[x][YMAX-1]->p_dspin_int_rsp_out[NORTH][k] (signal_dspin_false_int_rsp_out[x][YMAX-1][NORTH][k]); |
---|
1391 | } |
---|
1392 | |
---|
1393 | clusters[x][0]->p_dspin_ram_cmd_in[SOUTH] (signal_dspin_false_ram_cmd_in[x][0][SOUTH]); |
---|
1394 | clusters[x][0]->p_dspin_ram_cmd_out[SOUTH] (signal_dspin_false_ram_cmd_out[x][0][SOUTH]); |
---|
1395 | clusters[x][0]->p_dspin_ram_rsp_in[SOUTH] (signal_dspin_false_ram_rsp_in[x][0][SOUTH]); |
---|
1396 | clusters[x][0]->p_dspin_ram_rsp_out[SOUTH] (signal_dspin_false_ram_rsp_out[x][0][SOUTH]); |
---|
1397 | |
---|
1398 | clusters[x][YMAX-1]->p_dspin_ram_cmd_in[NORTH] (signal_dspin_false_ram_cmd_in[x][YMAX-1][NORTH]); |
---|
1399 | clusters[x][YMAX-1]->p_dspin_ram_cmd_out[NORTH] (signal_dspin_false_ram_cmd_out[x][YMAX-1][NORTH]); |
---|
1400 | clusters[x][YMAX-1]->p_dspin_ram_rsp_in[NORTH] (signal_dspin_false_ram_rsp_in[x][YMAX-1][NORTH]); |
---|
1401 | clusters[x][YMAX-1]->p_dspin_ram_rsp_out[NORTH] (signal_dspin_false_ram_rsp_out[x][YMAX-1][NORTH]); |
---|
1402 | } |
---|
1403 | |
---|
1404 | std::cout << "North & South boundaries established" << std::endl << std::endl; |
---|
1405 | |
---|
1406 | //////////////////////////////////////////////////////// |
---|
1407 | // Simulation |
---|
1408 | /////////////////////////////////////////////////////// |
---|
1409 | |
---|
1410 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
1411 | |
---|
1412 | signal_resetn = false; |
---|
1413 | |
---|
1414 | signal_irq_false = false; |
---|
1415 | |
---|
1416 | // only one cluster case: |
---|
1417 | if ( cluster_iob0 == cluster_iob1 ) |
---|
1418 | { |
---|
1419 | signal_vci_ini_iob1.cmdval = false; |
---|
1420 | signal_vci_ini_iob1.rspack = true; |
---|
1421 | signal_vci_tgt_iob1.cmdack = true; |
---|
1422 | signal_vci_tgt_iob1.rspval = false; |
---|
1423 | } |
---|
1424 | |
---|
1425 | // network boundaries signals |
---|
1426 | for (size_t x = 0; x < XMAX ; x++) |
---|
1427 | { |
---|
1428 | for (size_t y = 0; y < YMAX ; y++) |
---|
1429 | { |
---|
1430 | for (size_t a = 0; a < 4; a++) |
---|
1431 | { |
---|
1432 | for (size_t k = 0; k < 3; k++) |
---|
1433 | { |
---|
1434 | signal_dspin_false_int_cmd_in[x][y][a][k].write = false; |
---|
1435 | signal_dspin_false_int_cmd_in[x][y][a][k].read = true; |
---|
1436 | signal_dspin_false_int_cmd_out[x][y][a][k].write = false; |
---|
1437 | signal_dspin_false_int_cmd_out[x][y][a][k].read = true; |
---|
1438 | } |
---|
1439 | |
---|
1440 | for (size_t k = 0; k < 2; k++) |
---|
1441 | { |
---|
1442 | signal_dspin_false_int_rsp_in[x][y][a][k].write = false; |
---|
1443 | signal_dspin_false_int_rsp_in[x][y][a][k].read = true; |
---|
1444 | signal_dspin_false_int_rsp_out[x][y][a][k].write = false; |
---|
1445 | signal_dspin_false_int_rsp_out[x][y][a][k].read = true; |
---|
1446 | } |
---|
1447 | |
---|
1448 | signal_dspin_false_ram_cmd_in[x][y][a].write = false; |
---|
1449 | signal_dspin_false_ram_cmd_in[x][y][a].read = true; |
---|
1450 | signal_dspin_false_ram_cmd_out[x][y][a].write = false; |
---|
1451 | signal_dspin_false_ram_cmd_out[x][y][a].read = true; |
---|
1452 | |
---|
1453 | signal_dspin_false_ram_rsp_in[x][y][a].write = false; |
---|
1454 | signal_dspin_false_ram_rsp_in[x][y][a].read = true; |
---|
1455 | signal_dspin_false_ram_rsp_out[x][y][a].write = false; |
---|
1456 | signal_dspin_false_ram_rsp_out[x][y][a].read = true; |
---|
1457 | } |
---|
1458 | } |
---|
1459 | } |
---|
1460 | |
---|
1461 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
1462 | signal_resetn = true; |
---|
1463 | |
---|
1464 | |
---|
1465 | // simulation loop |
---|
1466 | struct timeval t1,t2; |
---|
1467 | gettimeofday(&t1, NULL); |
---|
1468 | |
---|
1469 | for (size_t n = 1; n < ncycles; n++) |
---|
1470 | { |
---|
1471 | // stats display |
---|
1472 | if( (n % 1000000) == 0) |
---|
1473 | { |
---|
1474 | gettimeofday(&t2, NULL); |
---|
1475 | |
---|
1476 | uint64_t ms1 = (uint64_t) t1.tv_sec * 1000ULL + |
---|
1477 | (uint64_t) t1.tv_usec / 1000; |
---|
1478 | uint64_t ms2 = (uint64_t) t2.tv_sec * 1000ULL + |
---|
1479 | (uint64_t) t2.tv_usec / 1000; |
---|
1480 | std::cerr << "### cycle = " << n |
---|
1481 | << " / frequency = " |
---|
1482 | << (double) 5000000 / (double) (ms2 - ms1) << "Khz" |
---|
1483 | << std::endl; |
---|
1484 | |
---|
1485 | gettimeofday(&t1, NULL); |
---|
1486 | } |
---|
1487 | |
---|
1488 | // Monitor a specific address for one L1 cache |
---|
1489 | // clusters[1][1]->proc[0]->cache_monitor(0x50090ULL); |
---|
1490 | |
---|
1491 | // Monitor a specific address for one L2 cache |
---|
1492 | // clusters[0][0]->memc->cache_monitor( 0x170000ULL); |
---|
1493 | |
---|
1494 | // Monitor a specific address for one XRAM |
---|
1495 | // if (n == 3000000) clusters[0][0]->xram->start_monitor( 0x170000ULL , 64); |
---|
1496 | |
---|
1497 | if (debug_ok and (n > debug_from) and (n % debug_period == 0)) |
---|
1498 | { |
---|
1499 | std::cout << "****************** cycle " << std::dec << n ; |
---|
1500 | std::cout << " ************************************************" << std::endl; |
---|
1501 | |
---|
1502 | // trace proc[debug_proc_id] |
---|
1503 | if ( debug_proc_id != 0xFFFFFFFF ) |
---|
1504 | { |
---|
1505 | size_t l = debug_proc_id % NB_PROCS_MAX ; |
---|
1506 | size_t cluster_xy = debug_proc_id / NB_PROCS_MAX ; |
---|
1507 | size_t x = cluster_xy >> 4; |
---|
1508 | size_t y = cluster_xy & 0xF; |
---|
1509 | |
---|
1510 | clusters[x][y]->proc[l]->print_trace(1); |
---|
1511 | std::ostringstream proc_signame; |
---|
1512 | proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ; |
---|
1513 | clusters[x][y]->signal_int_vci_ini_proc[l].print_trace(proc_signame.str()); |
---|
1514 | |
---|
1515 | clusters[x][y]->xicu->print_trace(l); |
---|
1516 | std::ostringstream xicu_signame; |
---|
1517 | xicu_signame << "[SIG]XICU_" << x << "_" << y; |
---|
1518 | clusters[x][y]->signal_int_vci_tgt_xicu.print_trace(xicu_signame.str()); |
---|
1519 | |
---|
1520 | // clusters[x][y]->mdma->print_trace(); |
---|
1521 | // std::ostringstream mdma_signame; |
---|
1522 | // mdma_signame << "[SIG]MDMA_" << x << "_" << y; |
---|
1523 | // clusters[x][y]->signal_int_vci_tgt_mdma.print_trace(mdma_signame.str()); |
---|
1524 | |
---|
1525 | if( clusters[x][y]->signal_proc_it[l].read() ) |
---|
1526 | std::cout << "### IRQ_PROC_" << std::dec |
---|
1527 | << x << "_" << y << "_" << l << " ACTIVE" << std::endl; |
---|
1528 | } |
---|
1529 | |
---|
1530 | // trace memc[debug_memc_id] |
---|
1531 | if ( debug_memc_id != 0xFFFFFFFF ) |
---|
1532 | { |
---|
1533 | size_t x = debug_memc_id >> 4; |
---|
1534 | size_t y = debug_memc_id & 0xF; |
---|
1535 | |
---|
1536 | clusters[x][y]->memc->print_trace(0); |
---|
1537 | std::ostringstream smemc_tgt; |
---|
1538 | smemc_tgt << "[SIG]MEMC_TGT_" << x << "_" << y; |
---|
1539 | clusters[x][y]->signal_int_vci_tgt_memc.print_trace(smemc_tgt.str()); |
---|
1540 | std::ostringstream smemc_ini; |
---|
1541 | smemc_ini << "[SIG]MEMC_INI_" << x << "_" << y; |
---|
1542 | clusters[x][y]->signal_ram_vci_ini_memc.print_trace(smemc_ini.str()); |
---|
1543 | |
---|
1544 | clusters[x][y]->xram->print_trace(); |
---|
1545 | std::ostringstream sxram_tgt; |
---|
1546 | sxram_tgt << "[SIG]XRAM_TGT_" << x << "_" << y; |
---|
1547 | clusters[x][y]->signal_ram_vci_tgt_xram.print_trace(sxram_tgt.str()); |
---|
1548 | } |
---|
1549 | |
---|
1550 | |
---|
1551 | // trace XRAM and XRAM network routers in cluster[debug_xram_id] |
---|
1552 | if ( debug_xram_id != 0xFFFFFFFF ) |
---|
1553 | { |
---|
1554 | size_t x = debug_xram_id >> 4; |
---|
1555 | size_t y = debug_xram_id & 0xF; |
---|
1556 | |
---|
1557 | clusters[x][y]->xram->print_trace(); |
---|
1558 | std::ostringstream sxram_tgt; |
---|
1559 | sxram_tgt << "[SIG]XRAM_TGT_" << x << "_" << y; |
---|
1560 | clusters[x][y]->signal_ram_vci_tgt_xram.print_trace(sxram_tgt.str()); |
---|
1561 | |
---|
1562 | clusters[x][y]->ram_router_cmd->print_trace(); |
---|
1563 | clusters[x][y]->ram_router_rsp->print_trace(); |
---|
1564 | } |
---|
1565 | |
---|
1566 | // trace iob, iox and external peripherals |
---|
1567 | if ( debug_iob ) |
---|
1568 | { |
---|
1569 | clusters[0][0]->iob->print_trace(); |
---|
1570 | clusters[0][0]->signal_int_vci_tgt_iobx.print_trace( "[SIG]IOB0_INT_TGT"); |
---|
1571 | clusters[0][0]->signal_int_vci_ini_iobx.print_trace( "[SIG]IOB0_INT_INI"); |
---|
1572 | clusters[0][0]->signal_ram_vci_ini_iobx.print_trace( "[SIG]IOB0_RAM_INI"); |
---|
1573 | |
---|
1574 | signal_vci_ini_iob0.print_trace("[SIG]IOB0_IOX_INI"); |
---|
1575 | signal_vci_tgt_iob0.print_trace("[SIG]IOB0_IOX_TGT"); |
---|
1576 | |
---|
1577 | // signal_dspin_cmd_iob0_loopback.print_trace("[SIG]IOB0_CMD_LOOPBACK"); |
---|
1578 | // signal_dspin_rsp_iob0_loopback.print_trace("[SIG]IOB0_RSP_LOOPBACK"); |
---|
1579 | |
---|
1580 | // cdma->print_trace(); |
---|
1581 | // signal_vci_tgt_cdma.print_trace("[SIG]IOX_CDMA_TGT"); |
---|
1582 | // signal_vci_ini_cdma.print_trace("[SIG]IOX_CDMA_INI"); |
---|
1583 | |
---|
1584 | // brom->print_trace(); |
---|
1585 | // signal_vci_tgt_brom.print_trace("[SIG]IOX_BROM_TGT"); |
---|
1586 | |
---|
1587 | // mtty->print_trace(); |
---|
1588 | // signal_vci_tgt_mtty.print_trace("[SIG]IOX_MTTY_TGT"); |
---|
1589 | |
---|
1590 | bdev->print_trace(); |
---|
1591 | signal_vci_tgt_bdev.print_trace("[SIG]BDEV_TGT"); |
---|
1592 | signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI"); |
---|
1593 | |
---|
1594 | mnic->print_trace(); |
---|
1595 | signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT"); |
---|
1596 | |
---|
1597 | // fbuf->print_trace(); |
---|
1598 | // signal_vci_tgt_fbuf.print_trace("[SIG]FBUF"); |
---|
1599 | |
---|
1600 | iopi->print_trace(); |
---|
1601 | signal_vci_ini_iopi.print_trace("[SIG]IOPI_INI"); |
---|
1602 | signal_vci_tgt_iopi.print_trace("[SIG]IOPI_TGT"); |
---|
1603 | iox_network->print_trace(); |
---|
1604 | |
---|
1605 | // interrupts |
---|
1606 | if (signal_irq_bdev) std::cout << "### IRQ_BDEV ACTIVE" << std::endl; |
---|
1607 | if (signal_irq_mtty_rx) std::cout << "### IRQ_MTTY ACTIVE" << std::endl; |
---|
1608 | if (signal_irq_mnic_rx[0]) std::cout << "### IRQ_MNIC_RX[0] ACTIVE" << std::endl; |
---|
1609 | if (signal_irq_mnic_rx[1]) std::cout << "### IRQ_MNIC_RX[1] ACTIVE" << std::endl; |
---|
1610 | if (signal_irq_mnic_tx[0]) std::cout << "### IRQ_MNIC_TX[0] ACTIVE" << std::endl; |
---|
1611 | if (signal_irq_mnic_tx[1]) std::cout << "### IRQ_MNIC_TX[1] ACTIVE" << std::endl; |
---|
1612 | } |
---|
1613 | } |
---|
1614 | |
---|
1615 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
1616 | } |
---|
1617 | return EXIT_SUCCESS; |
---|
1618 | } |
---|
1619 | |
---|
1620 | int sc_main (int argc, char *argv[]) |
---|
1621 | { |
---|
1622 | try { |
---|
1623 | return _main(argc, argv); |
---|
1624 | } catch (std::exception &e) { |
---|
1625 | std::cout << e.what() << std::endl; |
---|
1626 | } catch (...) { |
---|
1627 | std::cout << "Unknown exception occured" << std::endl; |
---|
1628 | throw; |
---|
1629 | } |
---|
1630 | return 1; |
---|
1631 | } |
---|
1632 | |
---|
1633 | |
---|
1634 | // Local Variables: |
---|
1635 | // tab-width: 3 |
---|
1636 | // c-basic-offset: 3 |
---|
1637 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
1638 | // indent-tabs-mode: nil |
---|
1639 | // End: |
---|
1640 | |
---|
1641 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|
1642 | |
---|
1643 | |
---|
1644 | |
---|