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