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