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