[536] | 1 | ///////////////////////////////////////////////////////////////////////// |
---|
| 2 | // File: top.cpp |
---|
| 3 | // Author: Alain Greiner |
---|
| 4 | // Copyright: UPMC/LIP6 |
---|
| 5 | // Date : may 2013 |
---|
| 6 | // This program is released under the GNU public license |
---|
| 7 | ///////////////////////////////////////////////////////////////////////// |
---|
| 8 | // This file define a generic TSAR architecture. |
---|
| 9 | // The physical address space is 40 bits. |
---|
| 10 | // |
---|
| 11 | // The number of clusters cannot be larger than 256. |
---|
| 12 | // The number of processors per cluster cannot be larger than 8. |
---|
| 13 | // |
---|
| 14 | // - It uses four dspin_local_crossbar per cluster as local interconnect |
---|
| 15 | // - It uses two virtual_dspin routers per cluster as global interconnect |
---|
| 16 | // - It uses the vci_cc_vcache_wrapper |
---|
| 17 | // - It uses the vci_mem_cache |
---|
| 18 | // - It contains one vci_xicu per cluster. |
---|
| 19 | // - It contains one vci_multi_dma per cluster. |
---|
| 20 | // - It contains one vci_simple_ram per cluster to model the L3 cache. |
---|
| 21 | // |
---|
| 22 | // The communication between the MemCache and the Xram is 64 bits. |
---|
| 23 | // |
---|
| 24 | // All clusters are identical, but the cluster 0 (called io_cluster), |
---|
| 25 | // contains 6 extra components: |
---|
| 26 | // - the boot rom (BROM) |
---|
| 27 | // - the disk controller (BDEV) |
---|
| 28 | // - the multi-channel network controller (MNIC) |
---|
| 29 | // - the multi-channel chained buffer dma controller (CDMA) |
---|
| 30 | // - the multi-channel tty controller (MTTY) |
---|
| 31 | // - the frame buffer controller (FBUF) |
---|
| 32 | // |
---|
| 33 | // It is build with one single component implementing a cluster, |
---|
| 34 | // defined in files tsar_xbar_cluster.* (with * = cpp, h, sd) |
---|
| 35 | // |
---|
| 36 | // The IRQs are connected to XICUs as follow: |
---|
| 37 | // - The IRQ_IN[0] to IRQ_IN[7] ports are not used in all clusters. |
---|
| 38 | // - The DMA IRQs are connected to IRQ_IN[8] to IRQ_IN[15] in all clusters. |
---|
| 39 | // - The TTY IRQs are connected to IRQ_IN[16] to IRQ_IN[30] in I/O cluster. |
---|
| 40 | // - The BDEV IRQ is connected to IRQ_IN[31] in I/O cluster. |
---|
| 41 | // |
---|
| 42 | // Some hardware parameters are used when compiling the OS, and are used |
---|
| 43 | // by this top.cpp file. They must be defined in the hard_config.h file : |
---|
| 44 | // - CLUSTER_X : number of clusters in a row (power of 2) |
---|
| 45 | // - CLUSTER_Y : number of clusters in a column (power of 2) |
---|
| 46 | // - CLUSTER_SIZE : size of the segment allocated to a cluster |
---|
| 47 | // - NB_PROCS_MAX : number of processors per cluster (power of 2) |
---|
| 48 | // - NB_DMA_CHANNELS : number of DMA channels per cluster (< 9) |
---|
| 49 | // - NB_TTY_CHANNELS : number of TTY channels in I/O cluster (< 16) |
---|
| 50 | // - NB_NIC_CHANNELS : number of NIC channels in I/O cluster (< 9) |
---|
| 51 | // |
---|
| 52 | // Some other hardware parameters are not used when compiling the OS, |
---|
| 53 | // and can be directly defined in this top.cpp file: |
---|
| 54 | // - XRAM_LATENCY : external ram latency |
---|
| 55 | // - MEMC_WAYS : L2 cache number of ways |
---|
| 56 | // - MEMC_SETS : L2 cache number of sets |
---|
| 57 | // - L1_IWAYS |
---|
| 58 | // - L1_ISETS |
---|
| 59 | // - L1_DWAYS |
---|
| 60 | // - L1_DSETS |
---|
| 61 | // - FBUF_X_SIZE : width of frame buffer (pixels) |
---|
| 62 | // - FBUF_Y_SIZE : heigth of frame buffer (lines) |
---|
| 63 | // - BDEV_SECTOR_SIZE : block size for block drvice |
---|
| 64 | // - BDEV_IMAGE_NAME : file pathname for block device |
---|
| 65 | // - NIC_RX_NAME : file pathname for NIC received packets |
---|
| 66 | // - NIC_TX_NAME : file pathname for NIC transmited packets |
---|
| 67 | // - NIC_TIMEOUT : max number of cycles before closing a container |
---|
| 68 | ///////////////////////////////////////////////////////////////////////// |
---|
| 69 | // General policy for 40 bits physical address decoding: |
---|
| 70 | // All physical segments base addresses are multiple of 1 Mbytes |
---|
| 71 | // (=> the 24 LSB bits = 0, and the 16 MSB bits define the target) |
---|
| 72 | // The (x_width + y_width) MSB bits (left aligned) define |
---|
| 73 | // the cluster index, and the LADR bits define the local index: |
---|
| 74 | // | X_ID | Y_ID |---| LADR | OFFSET | |
---|
| 75 | // |x_width|y_width|---| 8 | 24 | |
---|
| 76 | ///////////////////////////////////////////////////////////////////////// |
---|
| 77 | // General policy for 14 bits SRCID decoding: |
---|
| 78 | // Each component is identified by (x_id, y_id, l_id) tuple. |
---|
| 79 | // | X_ID | Y_ID |---| L_ID | |
---|
| 80 | // |x_width|y_width|---| 6 | |
---|
| 81 | ///////////////////////////////////////////////////////////////////////// |
---|
| 82 | |
---|
| 83 | #include <systemc> |
---|
| 84 | #include <sys/time.h> |
---|
| 85 | #include <iostream> |
---|
| 86 | #include <sstream> |
---|
| 87 | #include <cstdlib> |
---|
| 88 | #include <cstdarg> |
---|
| 89 | #include <stdint.h> |
---|
| 90 | |
---|
| 91 | #include "gdbserver.h" |
---|
| 92 | #include "mapping_table.h" |
---|
| 93 | #include "tsar_xbar_cluster.h" |
---|
| 94 | #include "alloc_elems.h" |
---|
| 95 | |
---|
| 96 | /////////////////////////////////////////////////// |
---|
| 97 | // OS |
---|
| 98 | /////////////////////////////////////////////////// |
---|
| 99 | |
---|
| 100 | //#define USE_ALMOS |
---|
| 101 | #define USE_GIET |
---|
| 102 | |
---|
| 103 | #ifdef USE_ALMOS |
---|
| 104 | #ifdef USE_GIET |
---|
| 105 | #error "Can't use Two different OS" |
---|
| 106 | #endif |
---|
| 107 | #endif |
---|
| 108 | |
---|
| 109 | #ifndef USE_ALMOS |
---|
| 110 | #ifndef USE_GIET |
---|
| 111 | #error "You need to specify one OS" |
---|
| 112 | #endif |
---|
| 113 | #endif |
---|
| 114 | |
---|
| 115 | /////////////////////////////////////////////////// |
---|
| 116 | // Parallelisation |
---|
| 117 | /////////////////////////////////////////////////// |
---|
| 118 | #define USE_OPENMP 0 |
---|
| 119 | |
---|
| 120 | #if USE_OPENMP |
---|
| 121 | #include <omp.h> |
---|
| 122 | #endif |
---|
| 123 | |
---|
| 124 | // cluster index (computed from x,y coordinates) |
---|
| 125 | #define cluster(x,y) (y + YMAX * x) |
---|
| 126 | |
---|
| 127 | #define min(x, y) (x < y ? x : y) |
---|
| 128 | |
---|
| 129 | /////////////////////////////////////////////////////////// |
---|
| 130 | // DSPIN parameters |
---|
| 131 | /////////////////////////////////////////////////////////// |
---|
| 132 | |
---|
| 133 | #define dspin_cmd_width 39 |
---|
| 134 | #define dspin_rsp_width 32 |
---|
| 135 | |
---|
| 136 | /////////////////////////////////////////////////////////// |
---|
| 137 | // VCI parameters |
---|
| 138 | /////////////////////////////////////////////////////////// |
---|
| 139 | |
---|
| 140 | #define vci_cell_width_int 4 |
---|
| 141 | #define vci_cell_width_ext 8 |
---|
| 142 | |
---|
| 143 | #ifdef USE_ALMOS |
---|
| 144 | #define vci_address_width 32 |
---|
| 145 | #endif |
---|
| 146 | #ifdef USE_GIET |
---|
| 147 | #define vci_address_width 40 |
---|
| 148 | #endif |
---|
| 149 | #define vci_plen_width 8 |
---|
| 150 | #define vci_rerror_width 1 |
---|
| 151 | #define vci_clen_width 1 |
---|
| 152 | #define vci_rflag_width 1 |
---|
| 153 | #define vci_srcid_width 14 |
---|
| 154 | #define vci_pktid_width 4 |
---|
| 155 | #define vci_trdid_width 4 |
---|
| 156 | #define vci_wrplen_width 1 |
---|
| 157 | |
---|
| 158 | //////////////////////////////////////////////////////////// |
---|
| 159 | // Main Hardware Parameters values |
---|
| 160 | //////////////////////i///////////////////////////////////// |
---|
| 161 | |
---|
| 162 | #ifdef USE_ALMOS |
---|
| 163 | #include "almos/hard_config.h" |
---|
| 164 | #define PREFIX_OS "almos/" |
---|
| 165 | #endif |
---|
| 166 | #ifdef USE_GIET |
---|
| 167 | #include "scripts/soft/hard_config.h" |
---|
| 168 | #define PREFIX_OS "/users/cao/meunier/src/giet_vm/" |
---|
| 169 | #endif |
---|
| 170 | |
---|
| 171 | //////////////////////////////////////////////////////////// |
---|
| 172 | // Secondary Hardware Parameters |
---|
| 173 | //////////////////////i///////////////////////////////////// |
---|
| 174 | |
---|
| 175 | #define XMAX CLUSTER_X |
---|
| 176 | #define YMAX CLUSTER_Y |
---|
| 177 | |
---|
| 178 | #define XRAM_LATENCY 0 |
---|
| 179 | |
---|
| 180 | #define MEMC_WAYS 16 |
---|
| 181 | #define MEMC_SETS 256 |
---|
| 182 | |
---|
| 183 | #define L1_IWAYS 4 |
---|
| 184 | #define L1_ISETS 64 |
---|
| 185 | |
---|
| 186 | #define L1_DWAYS 4 |
---|
| 187 | #define L1_DSETS 64 |
---|
| 188 | |
---|
| 189 | #ifdef USE_ALMOS |
---|
| 190 | #define FBUF_X_SIZE 512 |
---|
| 191 | #define FBUF_Y_SIZE 512 |
---|
| 192 | #endif |
---|
| 193 | #ifdef USE_GIET |
---|
| 194 | #define FBUF_X_SIZE 128 |
---|
| 195 | #define FBUF_Y_SIZE 128 |
---|
| 196 | #endif |
---|
| 197 | |
---|
| 198 | #ifdef USE_GIET |
---|
| 199 | #define BDEV_SECTOR_SIZE 512 |
---|
| 200 | #define BDEV_IMAGE_NAME PREFIX_OS"display/images.raw" |
---|
| 201 | #endif |
---|
| 202 | #ifdef USE_ALMOS |
---|
| 203 | #define BDEV_SECTOR_SIZE 4096 |
---|
| 204 | #define BDEV_IMAGE_NAME PREFIX_OS"hdd-img.bin" |
---|
| 205 | #endif |
---|
| 206 | |
---|
| 207 | #define NIC_RX_NAME PREFIX_OS"nic/rx_packets.txt" |
---|
| 208 | #define NIC_TX_NAME PREFIX_OS"nic/tx_packets.txt" |
---|
| 209 | #define NIC_TIMEOUT 10000 |
---|
| 210 | |
---|
| 211 | #define NORTH 0 |
---|
| 212 | #define SOUTH 1 |
---|
| 213 | #define EAST 2 |
---|
| 214 | #define WEST 3 |
---|
| 215 | |
---|
| 216 | //////////////////////////////////////////////////////////// |
---|
| 217 | // Software to be loaded in ROM & RAM |
---|
| 218 | //////////////////////i///////////////////////////////////// |
---|
| 219 | |
---|
| 220 | #ifdef USE_ALMOS |
---|
| 221 | #define soft_name PREFIX_OS"bootloader.bin",\ |
---|
| 222 | PREFIX_OS"kernel-soclib.bin@0xbfc10000:D",\ |
---|
| 223 | PREFIX_OS"arch-info.bib@0xBFC08000:D" |
---|
| 224 | #endif |
---|
| 225 | #ifdef USE_GIET |
---|
| 226 | #define soft_pathname "scripts/soft/soft.elf" |
---|
| 227 | #endif |
---|
| 228 | |
---|
| 229 | //////////////////////////////////////////////////////////// |
---|
| 230 | // DEBUG Parameters default values |
---|
| 231 | //////////////////////i///////////////////////////////////// |
---|
| 232 | |
---|
| 233 | #define MAX_FROZEN_CYCLES 1000000 |
---|
| 234 | |
---|
| 235 | ///////////////////////////////////////////////////////// |
---|
| 236 | // Physical segments definition |
---|
| 237 | ///////////////////////////////////////////////////////// |
---|
| 238 | // There is 3 segments replicated in all clusters |
---|
| 239 | // and 5 specific segments in the "IO" cluster |
---|
| 240 | // (containing address 0xBF000000) |
---|
| 241 | ///////////////////////////////////////////////////////// |
---|
| 242 | |
---|
| 243 | #ifdef USE_GIET |
---|
| 244 | // specific segments in "IO" cluster : absolute physical address |
---|
| 245 | #define BROM_BASE 0x00BFC00000 |
---|
| 246 | #define BROM_SIZE 0x0000100000 // 1 Mbytes |
---|
| 247 | |
---|
| 248 | #define FBUF_BASE 0x00B2000000 |
---|
| 249 | #define FBUF_SIZE (FBUF_X_SIZE * FBUF_Y_SIZE * 2) |
---|
| 250 | |
---|
| 251 | #define BDEV_BASE 0x00B3000000 |
---|
| 252 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
| 253 | |
---|
| 254 | #define MTTY_BASE 0x00B4000000 |
---|
| 255 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
| 256 | |
---|
| 257 | #define MNIC_BASE 0x00B5000000 |
---|
| 258 | #define MNIC_SIZE 0x0000080000 // 512 Kbytes (for 8 channels) |
---|
| 259 | |
---|
| 260 | #define CDMA_BASE 0x00B6000000 |
---|
| 261 | #define CDMA_SIZE 0x0000004000 * NB_CMA_CHANNELS |
---|
| 262 | |
---|
| 263 | // replicated segments : address is incremented by a cluster offset |
---|
| 264 | // offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
| 265 | |
---|
| 266 | #define MEMC_BASE 0x0000000000 |
---|
| 267 | #define MEMC_SIZE 0x0010000000 // 256 Mbytes per cluster |
---|
| 268 | |
---|
| 269 | #define XICU_BASE 0x00B0000000 |
---|
| 270 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
| 271 | |
---|
| 272 | #define MDMA_BASE 0x00B1000000 |
---|
| 273 | #define MDMA_SIZE 0x0000001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
| 274 | #endif |
---|
| 275 | |
---|
| 276 | #ifdef USE_ALMOS |
---|
| 277 | #define CLUSTER_INC (0x80000000ULL / (XMAX * YMAX) * 2) |
---|
| 278 | |
---|
| 279 | #define MEMC_BASE 0x0000000000 |
---|
| 280 | #define MEMC_SIZE min(0x02000000, (0x80000000 / (XMAX * YMAX))) |
---|
| 281 | |
---|
| 282 | #define BROM_BASE 0x00BFC00000 |
---|
| 283 | #define BROM_SIZE 0x0000100000 // 1 Mbytes |
---|
| 284 | |
---|
| 285 | #define XICU_BASE (MEMC_SIZE) |
---|
| 286 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
| 287 | |
---|
| 288 | #define MDMA_BASE (XICU_BASE + XICU_SIZE) |
---|
| 289 | #define MDMA_SIZE 0x0000001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
| 290 | |
---|
| 291 | #define BDEV_BASE ((cluster_io_id * (CLUSTER_INC)) + MDMA_BASE + MDMA_SIZE) |
---|
| 292 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
| 293 | |
---|
| 294 | #define MTTY_BASE (BDEV_BASE + BDEV_SIZE) |
---|
| 295 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
| 296 | |
---|
| 297 | #define FBUF_BASE (MTTY_BASE + MTTY_SIZE) |
---|
| 298 | #define FBUF_SIZE (FBUF_X_SIZE * FBUF_Y_SIZE * 2) // Should be 0x80000 |
---|
| 299 | |
---|
| 300 | // Unused in almos |
---|
| 301 | #define MNIC_BASE (FBUF_BASE + FBUF_SIZE) |
---|
| 302 | #define MNIC_SIZE 0x0000001000 |
---|
| 303 | |
---|
| 304 | #define CDMA_BASE (MNIC_BASE + MNIC_SIZE) |
---|
| 305 | #define CDMA_SIZE 0x0000004000 * NB_CMA_CHANNELS |
---|
| 306 | |
---|
| 307 | #endif |
---|
| 308 | |
---|
| 309 | |
---|
| 310 | //////////////////////////////////////////////////////////////////// |
---|
| 311 | // TGTID definition in direct space |
---|
| 312 | // For all components: global TGTID = global SRCID = cluster_index |
---|
| 313 | //////////////////////////////////////////////////////////////////// |
---|
| 314 | |
---|
| 315 | #define MEMC_TGTID 0 |
---|
| 316 | #define XICU_TGTID 1 |
---|
| 317 | #define MDMA_TGTID 2 |
---|
| 318 | #define MTTY_TGTID 3 |
---|
| 319 | #define FBUF_TGTID 4 |
---|
| 320 | #define BDEV_TGTID 5 |
---|
| 321 | #define MNIC_TGTID 6 |
---|
| 322 | #define BROM_TGTID 7 |
---|
| 323 | #define CDMA_TGTID 8 |
---|
| 324 | |
---|
| 325 | bool stop_called = false; |
---|
| 326 | |
---|
| 327 | ///////////////////////////////// |
---|
| 328 | int _main(int argc, char *argv[]) |
---|
| 329 | { |
---|
| 330 | using namespace sc_core; |
---|
| 331 | using namespace soclib::caba; |
---|
| 332 | using namespace soclib::common; |
---|
| 333 | |
---|
| 334 | #ifdef USE_GIET |
---|
| 335 | char soft_name[256] = soft_pathname; // pathname to binary code |
---|
| 336 | #endif |
---|
| 337 | uint64_t ncycles = 0xFFFFFFFFFFFFFFFF; // simulated cycles |
---|
| 338 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
| 339 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
| 340 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
| 341 | ssize_t threads_nr = 1; // simulator's threads number |
---|
| 342 | bool debug_ok = false; // trace activated |
---|
| 343 | size_t debug_period = 1; // trace period |
---|
| 344 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
| 345 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
| 346 | uint32_t debug_from = 0; // trace start cycle |
---|
| 347 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
| 348 | size_t cluster_io_id; // index of cluster containing IOs |
---|
| 349 | struct timeval t1,t2; |
---|
| 350 | uint64_t ms1,ms2; |
---|
| 351 | |
---|
| 352 | ////////////// command line arguments ////////////////////// |
---|
| 353 | if (argc > 1) |
---|
| 354 | { |
---|
| 355 | for (int n = 1; n < argc; n = n + 2) |
---|
| 356 | { |
---|
| 357 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) |
---|
| 358 | { |
---|
| 359 | ncycles = atoi(argv[n + 1]); |
---|
| 360 | } |
---|
| 361 | else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) |
---|
| 362 | { |
---|
| 363 | #ifdef USE_ALMOS |
---|
| 364 | assert( 0 && "Can't define almos soft name" ); |
---|
| 365 | #endif |
---|
| 366 | #ifdef USE_GIET |
---|
| 367 | strcpy(soft_name, argv[n + 1]); |
---|
| 368 | #endif |
---|
| 369 | } |
---|
| 370 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) |
---|
| 371 | { |
---|
| 372 | strcpy(disk_name, argv[n + 1]); |
---|
| 373 | } |
---|
| 374 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) |
---|
| 375 | { |
---|
| 376 | debug_ok = true; |
---|
| 377 | debug_from = atoi(argv[n + 1]); |
---|
| 378 | } |
---|
| 379 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) |
---|
| 380 | { |
---|
| 381 | debug_memc_id = atoi(argv[n + 1]); |
---|
| 382 | assert((debug_memc_id < (XMAX * YMAX)) && |
---|
| 383 | "debug_memc_id larger than XMAX * YMAX" ); |
---|
| 384 | } |
---|
| 385 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) |
---|
| 386 | { |
---|
| 387 | debug_proc_id = atoi(argv[n + 1]); |
---|
| 388 | assert((debug_proc_id < (XMAX * YMAX * NB_PROCS_MAX)) && |
---|
| 389 | "debug_proc_id larger than XMAX * YMAX * NB_PROCS"); |
---|
| 390 | } |
---|
| 391 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) |
---|
| 392 | { |
---|
| 393 | threads_nr = atoi(argv[n + 1]); |
---|
| 394 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
| 395 | } |
---|
| 396 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) |
---|
| 397 | { |
---|
| 398 | frozen_cycles = atoi(argv[n + 1]); |
---|
| 399 | } |
---|
| 400 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) |
---|
| 401 | { |
---|
| 402 | debug_period = atoi(argv[n + 1]); |
---|
| 403 | } |
---|
| 404 | else |
---|
| 405 | { |
---|
| 406 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
| 407 | std::cout << " The order is not important." << std::endl; |
---|
| 408 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
| 409 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
| 410 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
| 411 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
| 412 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
| 413 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
| 414 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
| 415 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
| 416 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
| 417 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
| 418 | exit(0); |
---|
| 419 | } |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | // checking hardware parameters |
---|
| 424 | assert( ( (XMAX == 1) or (XMAX == 2) or (XMAX == 4) or |
---|
| 425 | (XMAX == 8) or (XMAX == 16) ) and |
---|
| 426 | "The XMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
| 427 | |
---|
| 428 | assert( ( (YMAX == 1) or (YMAX == 2) or (YMAX == 4) or |
---|
| 429 | (YMAX == 8) or (YMAX == 16) ) and |
---|
| 430 | "The YMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
| 431 | |
---|
| 432 | assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or |
---|
| 433 | (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and |
---|
| 434 | "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" ); |
---|
| 435 | |
---|
| 436 | assert( (NB_DMA_CHANNELS < 9) and |
---|
| 437 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
| 438 | |
---|
| 439 | assert( (NB_TTY_CHANNELS < 15) and |
---|
| 440 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
| 441 | |
---|
| 442 | assert( (NB_NIC_CHANNELS < 9) and |
---|
| 443 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
| 444 | |
---|
| 445 | #ifdef USE_GIET |
---|
| 446 | assert( (vci_address_width == 40) and |
---|
| 447 | "VCI address width with the GIET must be 40 bits" ); |
---|
| 448 | #endif |
---|
| 449 | |
---|
| 450 | #ifdef USE_ALMOS |
---|
| 451 | assert( (vci_address_width == 32) and |
---|
| 452 | "VCI address width with ALMOS must be 32 bits" ); |
---|
| 453 | #endif |
---|
| 454 | |
---|
| 455 | |
---|
| 456 | std::cout << std::endl; |
---|
| 457 | std::cout << " - XMAX = " << XMAX << std::endl; |
---|
| 458 | std::cout << " - YMAX = " << YMAX << std::endl; |
---|
| 459 | std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl; |
---|
| 460 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
| 461 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
| 462 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
| 463 | std::cout << " - MEMC_WAYS = " << MEMC_WAYS << std::endl; |
---|
| 464 | std::cout << " - MEMC_SETS = " << MEMC_SETS << std::endl; |
---|
| 465 | std::cout << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl; |
---|
| 466 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
| 467 | std::cout << "[PROCS] " << NB_PROCS_MAX * XMAX * YMAX << std::endl; |
---|
| 468 | |
---|
| 469 | std::cout << std::endl; |
---|
| 470 | // Internal and External VCI parameters definition |
---|
| 471 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
| 472 | vci_plen_width, |
---|
| 473 | vci_address_width, |
---|
| 474 | vci_rerror_width, |
---|
| 475 | vci_clen_width, |
---|
| 476 | vci_rflag_width, |
---|
| 477 | vci_srcid_width, |
---|
| 478 | vci_pktid_width, |
---|
| 479 | vci_trdid_width, |
---|
| 480 | vci_wrplen_width> vci_param_int; |
---|
| 481 | |
---|
| 482 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
| 483 | vci_plen_width, |
---|
| 484 | vci_address_width, |
---|
| 485 | vci_rerror_width, |
---|
| 486 | vci_clen_width, |
---|
| 487 | vci_rflag_width, |
---|
| 488 | vci_srcid_width, |
---|
| 489 | vci_pktid_width, |
---|
| 490 | vci_trdid_width, |
---|
| 491 | vci_wrplen_width> vci_param_ext; |
---|
| 492 | |
---|
| 493 | #if USE_OPENMP |
---|
| 494 | omp_set_dynamic(false); |
---|
| 495 | omp_set_num_threads(threads_nr); |
---|
| 496 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
| 497 | #endif |
---|
| 498 | |
---|
| 499 | // Define parameters depending on mesh size |
---|
| 500 | size_t x_width; |
---|
| 501 | size_t y_width; |
---|
| 502 | |
---|
| 503 | if (XMAX == 1) x_width = 0; |
---|
| 504 | else if (XMAX == 2) x_width = 1; |
---|
| 505 | else if (XMAX <= 4) x_width = 2; |
---|
| 506 | else if (XMAX <= 8) x_width = 3; |
---|
| 507 | else x_width = 4; |
---|
| 508 | |
---|
| 509 | if (YMAX == 1) y_width = 0; |
---|
| 510 | else if (YMAX == 2) y_width = 1; |
---|
| 511 | else if (YMAX <= 4) y_width = 2; |
---|
| 512 | else if (YMAX <= 8) y_width = 3; |
---|
| 513 | else y_width = 4; |
---|
| 514 | |
---|
| 515 | |
---|
| 516 | #ifdef USE_ALMOS |
---|
| 517 | cluster_io_id = 0xbfc00000 >> (vci_address_width - x_width - y_width); // index of cluster containing IOs |
---|
| 518 | #else |
---|
| 519 | cluster_io_id = 0; |
---|
| 520 | #endif |
---|
| 521 | |
---|
| 522 | ///////////////////// |
---|
| 523 | // Mapping Tables |
---|
| 524 | ///////////////////// |
---|
| 525 | |
---|
| 526 | // internal network |
---|
| 527 | MappingTable maptabd(vci_address_width, |
---|
| 528 | IntTab(x_width + y_width, 20 - x_width - y_width), |
---|
| 529 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
| 530 | 0x00FF800000); |
---|
| 531 | |
---|
| 532 | for (size_t x = 0; x < XMAX; x++) |
---|
| 533 | { |
---|
| 534 | for (size_t y = 0; y < YMAX; y++) |
---|
| 535 | { |
---|
| 536 | sc_uint<vci_address_width> offset; |
---|
| 537 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
| 538 | << (vci_address_width-x_width-y_width); |
---|
| 539 | |
---|
| 540 | std::ostringstream si; |
---|
| 541 | si << "seg_xicu_" << x << "_" << y; |
---|
| 542 | maptabd.add(Segment(si.str(), XICU_BASE + offset, XICU_SIZE, |
---|
| 543 | IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
| 544 | |
---|
| 545 | std::ostringstream sd; |
---|
| 546 | sd << "seg_mdma_" << x << "_" << y; |
---|
| 547 | maptabd.add(Segment(sd.str(), MDMA_BASE + offset, MDMA_SIZE, |
---|
| 548 | IntTab(cluster(x,y),MDMA_TGTID), false)); |
---|
| 549 | |
---|
| 550 | std::ostringstream sh; |
---|
| 551 | sh << "seg_memc_" << x << "_" << y; |
---|
| 552 | maptabd.add(Segment(sh.str(), MEMC_BASE + offset, MEMC_SIZE, |
---|
| 553 | IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
| 554 | |
---|
| 555 | if ( cluster(x,y) == cluster_io_id ) |
---|
| 556 | { |
---|
| 557 | maptabd.add(Segment("seg_mtty", MTTY_BASE, MTTY_SIZE, |
---|
| 558 | IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
| 559 | maptabd.add(Segment("seg_fbuf", FBUF_BASE, FBUF_SIZE, |
---|
| 560 | IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
| 561 | maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, |
---|
| 562 | IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
| 563 | maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, |
---|
| 564 | IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
| 565 | maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, |
---|
| 566 | IntTab(cluster(x,y),MNIC_TGTID), false)); |
---|
| 567 | maptabd.add(Segment("seg_cdma", CDMA_BASE, CDMA_SIZE, |
---|
| 568 | IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
| 569 | } |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | std::cout << maptabd << std::endl; |
---|
| 573 | |
---|
| 574 | // external network |
---|
| 575 | MappingTable maptabx(vci_address_width, |
---|
| 576 | IntTab(x_width+y_width), |
---|
| 577 | IntTab(x_width+y_width), |
---|
| 578 | 0xFFFF000000ULL); |
---|
| 579 | |
---|
| 580 | for (size_t x = 0; x < XMAX; x++) |
---|
| 581 | { |
---|
| 582 | for (size_t y = 0; y < YMAX ; y++) |
---|
| 583 | { |
---|
| 584 | |
---|
| 585 | sc_uint<vci_address_width> offset; |
---|
| 586 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
| 587 | << (vci_address_width-x_width-y_width); |
---|
| 588 | |
---|
| 589 | std::ostringstream sh; |
---|
| 590 | sh << "x_seg_memc_" << x << "_" << y; |
---|
| 591 | |
---|
| 592 | maptabx.add(Segment(sh.str(), MEMC_BASE + offset, |
---|
| 593 | MEMC_SIZE, IntTab(cluster(x,y)), false)); |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | } |
---|
| 597 | std::cout << maptabx << std::endl; |
---|
| 598 | |
---|
| 599 | //////////////////// |
---|
| 600 | // Signals |
---|
| 601 | /////////////////// |
---|
| 602 | |
---|
| 603 | sc_clock signal_clk("clk"); |
---|
| 604 | sc_signal<bool> signal_resetn("resetn"); |
---|
| 605 | |
---|
| 606 | // Horizontal inter-clusters DSPIN signals |
---|
| 607 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_inc = |
---|
| 608 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", XMAX-1, YMAX, 3); |
---|
| 609 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_dec = |
---|
| 610 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", XMAX-1, YMAX, 3); |
---|
| 611 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_inc = |
---|
| 612 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", XMAX-1, YMAX, 2); |
---|
| 613 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_dec = |
---|
| 614 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", XMAX-1, YMAX, 2); |
---|
| 615 | |
---|
| 616 | // Vertical inter-clusters DSPIN signals |
---|
| 617 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_inc = |
---|
| 618 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", XMAX, YMAX-1, 3); |
---|
| 619 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_dec = |
---|
| 620 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", XMAX, YMAX-1, 3); |
---|
| 621 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_inc = |
---|
| 622 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", XMAX, YMAX-1, 2); |
---|
| 623 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_dec = |
---|
| 624 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", XMAX, YMAX-1, 2); |
---|
| 625 | |
---|
| 626 | // Mesh boundaries DSPIN signals |
---|
| 627 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_in = |
---|
| 628 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in" , XMAX, YMAX, 4, 3); |
---|
| 629 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_out = |
---|
| 630 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", XMAX, YMAX, 4, 3); |
---|
| 631 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_in = |
---|
| 632 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in" , XMAX, YMAX, 4, 2); |
---|
| 633 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_out = |
---|
| 634 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", XMAX, YMAX, 4, 2); |
---|
| 635 | |
---|
| 636 | |
---|
| 637 | //////////////////////////// |
---|
| 638 | // Loader |
---|
| 639 | //////////////////////////// |
---|
| 640 | |
---|
| 641 | soclib::common::Loader loader(soft_name); |
---|
| 642 | |
---|
| 643 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
| 644 | proc_iss::set_loader(loader); |
---|
| 645 | |
---|
| 646 | //////////////////////////// |
---|
| 647 | // Clusters construction |
---|
| 648 | //////////////////////////// |
---|
| 649 | |
---|
| 650 | TsarXbarCluster<dspin_cmd_width, |
---|
| 651 | dspin_rsp_width, |
---|
| 652 | vci_param_int, |
---|
| 653 | vci_param_ext>* clusters[XMAX][YMAX]; |
---|
| 654 | |
---|
| 655 | #if USE_OPENMP |
---|
| 656 | #pragma omp parallel |
---|
| 657 | { |
---|
| 658 | #pragma omp for |
---|
| 659 | #endif |
---|
| 660 | for (size_t i = 0; i < (XMAX * YMAX); i++) |
---|
| 661 | { |
---|
| 662 | size_t x = i / YMAX; |
---|
| 663 | size_t y = i % YMAX; |
---|
| 664 | |
---|
| 665 | #if USE_OPENMP |
---|
| 666 | #pragma omp critical |
---|
| 667 | { |
---|
| 668 | #endif |
---|
| 669 | std::cout << std::endl; |
---|
| 670 | std::cout << "Cluster_" << x << "_" << y << std::endl; |
---|
| 671 | std::cout << std::endl; |
---|
| 672 | |
---|
| 673 | std::ostringstream sc; |
---|
| 674 | sc << "cluster_" << x << "_" << y; |
---|
| 675 | clusters[x][y] = new TsarXbarCluster<dspin_cmd_width, |
---|
| 676 | dspin_rsp_width, |
---|
| 677 | vci_param_int, |
---|
| 678 | vci_param_ext> |
---|
| 679 | ( |
---|
| 680 | sc.str().c_str(), |
---|
| 681 | NB_PROCS_MAX, |
---|
| 682 | NB_TTY_CHANNELS, |
---|
| 683 | NB_DMA_CHANNELS, |
---|
| 684 | x, |
---|
| 685 | y, |
---|
| 686 | cluster(x,y), |
---|
| 687 | maptabd, |
---|
| 688 | maptabx, |
---|
| 689 | x_width, |
---|
| 690 | y_width, |
---|
| 691 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
| 692 | MEMC_TGTID, |
---|
| 693 | XICU_TGTID, |
---|
| 694 | MDMA_TGTID, |
---|
| 695 | FBUF_TGTID, |
---|
| 696 | MTTY_TGTID, |
---|
| 697 | BROM_TGTID, |
---|
| 698 | MNIC_TGTID, |
---|
| 699 | CDMA_TGTID, |
---|
| 700 | BDEV_TGTID, |
---|
| 701 | MEMC_WAYS, |
---|
| 702 | MEMC_SETS, |
---|
| 703 | L1_IWAYS, |
---|
| 704 | L1_ISETS, |
---|
| 705 | L1_DWAYS, |
---|
| 706 | L1_DSETS, |
---|
| 707 | XRAM_LATENCY, |
---|
| 708 | (cluster(x,y) == cluster_io_id), |
---|
| 709 | FBUF_X_SIZE, |
---|
| 710 | FBUF_Y_SIZE, |
---|
| 711 | disk_name, |
---|
| 712 | BDEV_SECTOR_SIZE, |
---|
| 713 | NB_NIC_CHANNELS, |
---|
| 714 | nic_rx_name, |
---|
| 715 | nic_tx_name, |
---|
| 716 | NIC_TIMEOUT, |
---|
| 717 | NB_CMA_CHANNELS, |
---|
| 718 | loader, |
---|
| 719 | frozen_cycles, |
---|
| 720 | debug_from , |
---|
| 721 | debug_ok and (cluster(x,y) == debug_memc_id), |
---|
| 722 | debug_ok and (cluster(x,y) == debug_proc_id) |
---|
| 723 | ); |
---|
| 724 | |
---|
| 725 | #if USE_OPENMP |
---|
| 726 | } // end critical |
---|
| 727 | #endif |
---|
| 728 | } // end for |
---|
| 729 | #if USE_OPENMP |
---|
| 730 | } |
---|
| 731 | #endif |
---|
| 732 | |
---|
| 733 | /////////////////////////////////////////////////////////////// |
---|
| 734 | // Net-list |
---|
| 735 | /////////////////////////////////////////////////////////////// |
---|
| 736 | |
---|
| 737 | // Clock & RESET |
---|
| 738 | for (size_t x = 0; x < (XMAX); x++){ |
---|
| 739 | for (size_t y = 0; y < YMAX; y++){ |
---|
| 740 | clusters[x][y]->p_clk (signal_clk); |
---|
| 741 | clusters[x][y]->p_resetn (signal_resetn); |
---|
| 742 | } |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | // Inter Clusters horizontal connections |
---|
| 746 | if (XMAX > 1){ |
---|
| 747 | for (size_t x = 0; x < (XMAX-1); x++){ |
---|
| 748 | for (size_t y = 0; y < YMAX; y++){ |
---|
| 749 | for (size_t k = 0; k < 3; k++){ |
---|
| 750 | clusters[x][y]->p_cmd_out[EAST][k] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
| 751 | clusters[x+1][y]->p_cmd_in[WEST][k] (signal_dspin_h_cmd_inc[x][y][k]); |
---|
| 752 | clusters[x][y]->p_cmd_in[EAST][k] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
| 753 | clusters[x+1][y]->p_cmd_out[WEST][k] (signal_dspin_h_cmd_dec[x][y][k]); |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | for (size_t k = 0; k < 2; k++){ |
---|
| 757 | clusters[x][y]->p_rsp_out[EAST][k] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
| 758 | clusters[x+1][y]->p_rsp_in[WEST][k] (signal_dspin_h_rsp_inc[x][y][k]); |
---|
| 759 | clusters[x][y]->p_rsp_in[EAST][k] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
| 760 | clusters[x+1][y]->p_rsp_out[WEST][k] (signal_dspin_h_rsp_dec[x][y][k]); |
---|
| 761 | } |
---|
| 762 | } |
---|
| 763 | } |
---|
| 764 | } |
---|
| 765 | std::cout << std::endl << "Horizontal connections established" << std::endl; |
---|
| 766 | |
---|
| 767 | // Inter Clusters vertical connections |
---|
| 768 | if (YMAX > 1) { |
---|
| 769 | for (size_t y = 0; y < (YMAX-1); y++){ |
---|
| 770 | for (size_t x = 0; x < XMAX; x++){ |
---|
| 771 | for (size_t k = 0; k < 3; k++){ |
---|
| 772 | clusters[x][y]->p_cmd_out[NORTH][k] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
| 773 | clusters[x][y+1]->p_cmd_in[SOUTH][k] (signal_dspin_v_cmd_inc[x][y][k]); |
---|
| 774 | clusters[x][y]->p_cmd_in[NORTH][k] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
| 775 | clusters[x][y+1]->p_cmd_out[SOUTH][k] (signal_dspin_v_cmd_dec[x][y][k]); |
---|
| 776 | } |
---|
| 777 | |
---|
| 778 | for (size_t k = 0; k < 2; k++){ |
---|
| 779 | clusters[x][y]->p_rsp_out[NORTH][k] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
| 780 | clusters[x][y+1]->p_rsp_in[SOUTH][k] (signal_dspin_v_rsp_inc[x][y][k]); |
---|
| 781 | clusters[x][y]->p_rsp_in[NORTH][k] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
| 782 | clusters[x][y+1]->p_rsp_out[SOUTH][k] (signal_dspin_v_rsp_dec[x][y][k]); |
---|
| 783 | } |
---|
| 784 | } |
---|
| 785 | } |
---|
| 786 | } |
---|
| 787 | std::cout << "Vertical connections established" << std::endl; |
---|
| 788 | |
---|
| 789 | // East & West boundary cluster connections |
---|
| 790 | for (size_t y = 0; y < YMAX; y++) |
---|
| 791 | { |
---|
| 792 | for (size_t k = 0; k < 3; k++) |
---|
| 793 | { |
---|
| 794 | clusters[0][y]->p_cmd_in[WEST][k] (signal_dspin_false_cmd_in[0][y][WEST][k]); |
---|
| 795 | clusters[0][y]->p_cmd_out[WEST][k] (signal_dspin_false_cmd_out[0][y][WEST][k]); |
---|
| 796 | clusters[XMAX-1][y]->p_cmd_in[EAST][k] (signal_dspin_false_cmd_in[XMAX-1][y][EAST][k]); |
---|
| 797 | clusters[XMAX-1][y]->p_cmd_out[EAST][k] (signal_dspin_false_cmd_out[XMAX-1][y][EAST][k]); |
---|
| 798 | } |
---|
| 799 | |
---|
| 800 | for (size_t k = 0; k < 2; k++) |
---|
| 801 | { |
---|
| 802 | clusters[0][y]->p_rsp_in[WEST][k] (signal_dspin_false_rsp_in[0][y][WEST][k]); |
---|
| 803 | clusters[0][y]->p_rsp_out[WEST][k] (signal_dspin_false_rsp_out[0][y][WEST][k]); |
---|
| 804 | clusters[XMAX-1][y]->p_rsp_in[EAST][k] (signal_dspin_false_rsp_in[XMAX-1][y][EAST][k]); |
---|
| 805 | clusters[XMAX-1][y]->p_rsp_out[EAST][k] (signal_dspin_false_rsp_out[XMAX-1][y][EAST][k]); |
---|
| 806 | } |
---|
| 807 | } |
---|
| 808 | |
---|
| 809 | // North & South boundary clusters connections |
---|
| 810 | for (size_t x = 0; x < XMAX; x++) |
---|
| 811 | { |
---|
| 812 | for (size_t k = 0; k < 3; k++) |
---|
| 813 | { |
---|
| 814 | clusters[x][0]->p_cmd_in[SOUTH][k] (signal_dspin_false_cmd_in[x][0][SOUTH][k]); |
---|
| 815 | clusters[x][0]->p_cmd_out[SOUTH][k] (signal_dspin_false_cmd_out[x][0][SOUTH][k]); |
---|
| 816 | clusters[x][YMAX-1]->p_cmd_in[NORTH][k] (signal_dspin_false_cmd_in[x][YMAX-1][NORTH][k]); |
---|
| 817 | clusters[x][YMAX-1]->p_cmd_out[NORTH][k] (signal_dspin_false_cmd_out[x][YMAX-1][NORTH][k]); |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | for (size_t k = 0; k < 2; k++) |
---|
| 821 | { |
---|
| 822 | clusters[x][0]->p_rsp_in[SOUTH][k] (signal_dspin_false_rsp_in[x][0][SOUTH][k]); |
---|
| 823 | clusters[x][0]->p_rsp_out[SOUTH][k] (signal_dspin_false_rsp_out[x][0][SOUTH][k]); |
---|
| 824 | clusters[x][YMAX-1]->p_rsp_in[NORTH][k] (signal_dspin_false_rsp_in[x][YMAX-1][NORTH][k]); |
---|
| 825 | clusters[x][YMAX-1]->p_rsp_out[NORTH][k] (signal_dspin_false_rsp_out[x][YMAX-1][NORTH][k]); |
---|
| 826 | } |
---|
| 827 | } |
---|
| 828 | std::cout << "North, South, West, East connections established" << std::endl; |
---|
| 829 | std::cout << std::endl; |
---|
| 830 | |
---|
| 831 | |
---|
| 832 | //////////////////////////////////////////////////////// |
---|
| 833 | // Simulation |
---|
| 834 | /////////////////////////////////////////////////////// |
---|
| 835 | |
---|
| 836 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
| 837 | signal_resetn = false; |
---|
| 838 | |
---|
| 839 | // network boundaries signals |
---|
| 840 | for (size_t x = 0; x < XMAX ; x++){ |
---|
| 841 | for (size_t y = 0; y < YMAX ; y++){ |
---|
| 842 | for (size_t a = 0; a < 4; a++){ |
---|
| 843 | for (size_t k = 0; k < 3; k++){ |
---|
| 844 | signal_dspin_false_cmd_in [x][y][a][k].write = false; |
---|
| 845 | signal_dspin_false_cmd_in [x][y][a][k].read = true; |
---|
| 846 | signal_dspin_false_cmd_out[x][y][a][k].write = false; |
---|
| 847 | signal_dspin_false_cmd_out[x][y][a][k].read = true; |
---|
| 848 | } |
---|
| 849 | |
---|
| 850 | for (size_t k = 0; k < 2; k++){ |
---|
| 851 | signal_dspin_false_rsp_in [x][y][a][k].write = false; |
---|
| 852 | signal_dspin_false_rsp_in [x][y][a][k].read = true; |
---|
| 853 | signal_dspin_false_rsp_out[x][y][a][k].write = false; |
---|
| 854 | signal_dspin_false_rsp_out[x][y][a][k].read = true; |
---|
| 855 | } |
---|
| 856 | } |
---|
| 857 | } |
---|
| 858 | } |
---|
| 859 | |
---|
| 860 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 861 | signal_resetn = true; |
---|
| 862 | |
---|
| 863 | if (gettimeofday(&t1, NULL) != 0) |
---|
| 864 | { |
---|
| 865 | perror("gettimeofday"); |
---|
| 866 | return EXIT_FAILURE; |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | for (uint64_t n = 1; n < ncycles && !stop_called; n++) |
---|
| 870 | { |
---|
| 871 | // Monitor a specific address for L1 & L2 caches |
---|
| 872 | //clusters[0][0]->proc[0]->cache_monitor(0x800002c000ULL); |
---|
| 873 | //clusters[1][0]->memc->copies_monitor(0x800002C000ULL); |
---|
| 874 | |
---|
| 875 | if( (n % 5000000) == 0) |
---|
| 876 | { |
---|
| 877 | |
---|
| 878 | if (gettimeofday(&t2, NULL) != 0) |
---|
| 879 | { |
---|
| 880 | perror("gettimeofday"); |
---|
| 881 | return EXIT_FAILURE; |
---|
| 882 | } |
---|
| 883 | |
---|
| 884 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
| 885 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
| 886 | std::cerr << "platform clock frequency " << (double) 5000000 / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
| 887 | |
---|
| 888 | if (gettimeofday(&t1, NULL) != 0) |
---|
| 889 | { |
---|
| 890 | perror("gettimeofday"); |
---|
| 891 | return EXIT_FAILURE; |
---|
| 892 | } |
---|
| 893 | } |
---|
| 894 | |
---|
| 895 | if (debug_ok and (n > debug_from) and (n % debug_period == 0)) |
---|
| 896 | { |
---|
| 897 | std::cout << "****************** cycle " << std::dec << n ; |
---|
| 898 | std::cout << " ************************************************" << std::endl; |
---|
| 899 | |
---|
| 900 | // trace proc[debug_proc_id] |
---|
| 901 | size_t l = debug_proc_id % NB_PROCS_MAX ; |
---|
| 902 | size_t y = (debug_proc_id / NB_PROCS_MAX) % YMAX ; |
---|
| 903 | size_t x = debug_proc_id / (YMAX * NB_PROCS_MAX) ; |
---|
| 904 | |
---|
| 905 | std::ostringstream proc_signame; |
---|
| 906 | proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ; |
---|
| 907 | std::ostringstream p2m_signame; |
---|
| 908 | p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " P2M" ; |
---|
| 909 | std::ostringstream m2p_signame; |
---|
| 910 | m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " M2P" ; |
---|
| 911 | std::ostringstream p_cmd_signame; |
---|
| 912 | p_cmd_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " CMD" ; |
---|
| 913 | std::ostringstream p_rsp_signame; |
---|
| 914 | p_rsp_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " RSP" ; |
---|
| 915 | |
---|
| 916 | clusters[x][y]->proc[l]->print_trace(); |
---|
| 917 | clusters[x][y]->wi_proc[l]->print_trace(); |
---|
| 918 | clusters[x][y]->signal_vci_ini_proc[l].print_trace(proc_signame.str()); |
---|
| 919 | clusters[x][y]->signal_dspin_p2m_proc[l].print_trace(p2m_signame.str()); |
---|
| 920 | clusters[x][y]->signal_dspin_m2p_proc[l].print_trace(m2p_signame.str()); |
---|
| 921 | clusters[x][y]->signal_dspin_cmd_proc_i[l].print_trace(p_cmd_signame.str()); |
---|
| 922 | clusters[x][y]->signal_dspin_rsp_proc_i[l].print_trace(p_rsp_signame.str()); |
---|
| 923 | |
---|
| 924 | clusters[x][y]->xbar_rsp_d->print_trace(); |
---|
| 925 | clusters[x][y]->xbar_cmd_d->print_trace(); |
---|
| 926 | clusters[x][y]->signal_dspin_cmd_l2g_d.print_trace("[SIG]L2G CMD"); |
---|
| 927 | clusters[x][y]->signal_dspin_cmd_g2l_d.print_trace("[SIG]G2L CMD"); |
---|
| 928 | clusters[x][y]->signal_dspin_rsp_l2g_d.print_trace("[SIG]L2G RSP"); |
---|
| 929 | clusters[x][y]->signal_dspin_rsp_g2l_d.print_trace("[SIG]G2L RSP"); |
---|
| 930 | |
---|
| 931 | // trace memc[debug_memc_id] |
---|
| 932 | x = debug_memc_id / YMAX; |
---|
| 933 | y = debug_memc_id % YMAX; |
---|
| 934 | |
---|
| 935 | std::ostringstream smemc; |
---|
| 936 | smemc << "[SIG]MEMC_" << x << "_" << y; |
---|
| 937 | std::ostringstream sxram; |
---|
| 938 | sxram << "[SIG]XRAM_" << x << "_" << y; |
---|
| 939 | std::ostringstream sm2p; |
---|
| 940 | sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P" ; |
---|
| 941 | std::ostringstream sp2m; |
---|
| 942 | sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M" ; |
---|
| 943 | std::ostringstream m_cmd_signame; |
---|
| 944 | m_cmd_signame << "[SIG]MEMC_" << x << "_" << y << " CMD" ; |
---|
| 945 | std::ostringstream m_rsp_signame; |
---|
| 946 | m_rsp_signame << "[SIG]MEMC_" << x << "_" << y << " RSP" ; |
---|
| 947 | |
---|
| 948 | clusters[x][y]->memc->print_trace(); |
---|
| 949 | clusters[x][y]->wt_memc->print_trace(); |
---|
| 950 | clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str()); |
---|
| 951 | clusters[x][y]->signal_vci_xram.print_trace(sxram.str()); |
---|
| 952 | clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str()); |
---|
| 953 | clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str()); |
---|
| 954 | clusters[x][y]->signal_dspin_cmd_memc_t.print_trace(m_cmd_signame.str()); |
---|
| 955 | clusters[x][y]->signal_dspin_rsp_memc_t.print_trace(m_rsp_signame.str()); |
---|
| 956 | |
---|
| 957 | // trace replicated peripherals |
---|
| 958 | // clusters[1][1]->mdma->print_trace(); |
---|
| 959 | // clusters[1][1]->signal_vci_tgt_mdma.print_trace("[SIG]MDMA_TGT_1_1"); |
---|
| 960 | // clusters[1][1]->signal_vci_ini_mdma.print_trace("[SIG]MDMA_INI_1_1"); |
---|
| 961 | |
---|
| 962 | |
---|
| 963 | // trace external peripherals |
---|
| 964 | size_t io_x = cluster_io_id / YMAX; |
---|
| 965 | size_t io_y = cluster_io_id % YMAX; |
---|
| 966 | |
---|
| 967 | clusters[io_x][io_y]->brom->print_trace(); |
---|
| 968 | clusters[io_x][io_y]->wt_brom->print_trace(); |
---|
| 969 | clusters[io_x][io_y]->signal_vci_tgt_brom.print_trace("[SIG]BROM"); |
---|
| 970 | clusters[io_x][io_y]->signal_dspin_cmd_brom_t.print_trace("[SIG]BROM CMD"); |
---|
| 971 | clusters[io_x][io_y]->signal_dspin_rsp_brom_t.print_trace("[SIG]BROM RSP"); |
---|
| 972 | |
---|
| 973 | // clusters[io_x][io_y]->bdev->print_trace(); |
---|
| 974 | // clusters[io_x][io_y]->signal_vci_tgt_bdev.print_trace("[SIG]BDEV_TGT"); |
---|
| 975 | // clusters[io_x][io_y]->signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI"); |
---|
| 976 | } |
---|
| 977 | |
---|
| 978 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 979 | } |
---|
| 980 | |
---|
| 981 | |
---|
| 982 | // Free memory |
---|
| 983 | for (size_t i = 0; i < (XMAX * YMAX); i++) |
---|
| 984 | { |
---|
| 985 | size_t x = i / YMAX; |
---|
| 986 | size_t y = i % YMAX; |
---|
| 987 | delete clusters[x][y]; |
---|
| 988 | } |
---|
| 989 | |
---|
| 990 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, XMAX - 1, YMAX, 3); |
---|
| 991 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, XMAX - 1, YMAX, 3); |
---|
| 992 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, XMAX - 1, YMAX, 2); |
---|
| 993 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, XMAX - 1, YMAX, 2); |
---|
| 994 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, XMAX, YMAX - 1, 3); |
---|
| 995 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, XMAX, YMAX - 1, 3); |
---|
| 996 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, XMAX, YMAX - 1, 2); |
---|
| 997 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, XMAX, YMAX - 1, 2); |
---|
| 998 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_in, XMAX, YMAX, 4, 3); |
---|
| 999 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_out, XMAX, YMAX, 4, 3); |
---|
| 1000 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_in, XMAX, YMAX, 4, 2); |
---|
| 1001 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_out, XMAX, YMAX, 4, 2); |
---|
| 1002 | |
---|
| 1003 | return EXIT_SUCCESS; |
---|
| 1004 | } |
---|
| 1005 | |
---|
| 1006 | |
---|
| 1007 | void handler(int dummy = 0) { |
---|
| 1008 | stop_called = true; |
---|
| 1009 | sc_stop(); |
---|
| 1010 | } |
---|
| 1011 | |
---|
| 1012 | void voidhandler(int dummy = 0) {} |
---|
| 1013 | |
---|
| 1014 | int sc_main (int argc, char *argv[]) |
---|
| 1015 | { |
---|
| 1016 | signal(SIGINT, handler); |
---|
| 1017 | signal(SIGPIPE, voidhandler); |
---|
| 1018 | |
---|
| 1019 | try { |
---|
| 1020 | return _main(argc, argv); |
---|
| 1021 | } catch (std::exception &e) { |
---|
| 1022 | std::cout << e.what() << std::endl; |
---|
| 1023 | } catch (...) { |
---|
| 1024 | std::cout << "Unknown exception occured" << std::endl; |
---|
| 1025 | throw; |
---|
| 1026 | } |
---|
| 1027 | return 1; |
---|
| 1028 | } |
---|
| 1029 | |
---|
| 1030 | |
---|
| 1031 | // Local Variables: |
---|
| 1032 | // tab-width: 3 |
---|
| 1033 | // c-basic-offset: 3 |
---|
| 1034 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 1035 | // indent-tabs-mode: nil |
---|
| 1036 | // End: |
---|
| 1037 | |
---|
| 1038 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|