[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" |
---|
[663] | 93 | #include "alloc_elems.h" |
---|
[378] | 94 | #include "tsar_xbar_cluster.h" |
---|
[344] | 95 | |
---|
[663] | 96 | #define USE_ALMOS 1 |
---|
| 97 | //#define USE_GIET |
---|
[344] | 98 | |
---|
[464] | 99 | #ifdef USE_ALMOS |
---|
| 100 | #ifdef USE_GIET |
---|
| 101 | #error "Can't use Two different OS" |
---|
| 102 | #endif |
---|
| 103 | #endif |
---|
| 104 | |
---|
| 105 | #ifndef USE_ALMOS |
---|
| 106 | #ifndef USE_GIET |
---|
| 107 | #error "You need to specify one OS" |
---|
| 108 | #endif |
---|
| 109 | #endif |
---|
| 110 | |
---|
[663] | 111 | #ifdef USE_ALMOS |
---|
| 112 | #define PREFIX_OS "almos/" |
---|
| 113 | #include "almos/hard_config.h" |
---|
| 114 | #endif |
---|
| 115 | #ifdef USE_GIET |
---|
| 116 | #define PREFIX_OS "giet_vm/" |
---|
| 117 | #endif |
---|
| 118 | |
---|
[344] | 119 | /////////////////////////////////////////////////// |
---|
| 120 | // Parallelisation |
---|
| 121 | /////////////////////////////////////////////////// |
---|
[663] | 122 | |
---|
[344] | 123 | |
---|
| 124 | #if USE_OPENMP |
---|
| 125 | #include <omp.h> |
---|
| 126 | #endif |
---|
| 127 | |
---|
[1012] | 128 | // nluster index (computed from x,y coordinates) |
---|
[619] | 129 | #ifdef USE_ALMOS |
---|
[663] | 130 | #define cluster(x,y) (y + x * Y_SIZE) |
---|
[619] | 131 | #else |
---|
[663] | 132 | #define cluster(x,y) (y + (x << Y_WIDTH)) |
---|
[619] | 133 | #endif |
---|
[344] | 134 | |
---|
[619] | 135 | |
---|
[547] | 136 | #define min(x, y) (x < y ? x : y) |
---|
| 137 | |
---|
[344] | 138 | /////////////////////////////////////////////////////////// |
---|
| 139 | // DSPIN parameters |
---|
| 140 | /////////////////////////////////////////////////////////// |
---|
| 141 | |
---|
[404] | 142 | #define dspin_cmd_width 39 |
---|
| 143 | #define dspin_rsp_width 32 |
---|
[344] | 144 | |
---|
[396] | 145 | /////////////////////////////////////////////////////////// |
---|
| 146 | // VCI parameters |
---|
| 147 | /////////////////////////////////////////////////////////// |
---|
| 148 | |
---|
[438] | 149 | #define vci_cell_width_int 4 |
---|
| 150 | #define vci_cell_width_ext 8 |
---|
[396] | 151 | |
---|
[504] | 152 | #ifdef USE_ALMOS |
---|
| 153 | #define vci_address_width 32 |
---|
| 154 | #endif |
---|
| 155 | #ifdef USE_GIET |
---|
| 156 | #define vci_address_width 40 |
---|
| 157 | #endif |
---|
[438] | 158 | #define vci_plen_width 8 |
---|
| 159 | #define vci_rerror_width 1 |
---|
| 160 | #define vci_clen_width 1 |
---|
| 161 | #define vci_rflag_width 1 |
---|
| 162 | #define vci_srcid_width 14 |
---|
| 163 | #define vci_pktid_width 4 |
---|
| 164 | #define vci_trdid_width 4 |
---|
| 165 | #define vci_wrplen_width 1 |
---|
[493] | 166 | |
---|
[344] | 167 | //////////////////////////////////////////////////////////// |
---|
[396] | 168 | // Secondary Hardware Parameters |
---|
[344] | 169 | //////////////////////i///////////////////////////////////// |
---|
| 170 | |
---|
[438] | 171 | |
---|
[344] | 172 | #define XRAM_LATENCY 0 |
---|
| 173 | |
---|
| 174 | #define MEMC_WAYS 16 |
---|
| 175 | #define MEMC_SETS 256 |
---|
| 176 | |
---|
| 177 | #define L1_IWAYS 4 |
---|
| 178 | #define L1_ISETS 64 |
---|
| 179 | |
---|
| 180 | #define L1_DWAYS 4 |
---|
| 181 | #define L1_DSETS 64 |
---|
| 182 | |
---|
[464] | 183 | #ifdef USE_ALMOS |
---|
[663] | 184 | #define FBUF_X_SIZE 1024 |
---|
| 185 | #define FBUF_Y_SIZE 1024 |
---|
[464] | 186 | #endif |
---|
| 187 | #ifdef USE_GIET |
---|
[344] | 188 | #define FBUF_X_SIZE 128 |
---|
| 189 | #define FBUF_Y_SIZE 128 |
---|
[464] | 190 | #endif |
---|
[344] | 191 | |
---|
[464] | 192 | #ifdef USE_GIET |
---|
[344] | 193 | #define BDEV_SECTOR_SIZE 512 |
---|
[468] | 194 | #define BDEV_IMAGE_NAME PREFIX_OS"display/images.raw" |
---|
[464] | 195 | #endif |
---|
| 196 | #ifdef USE_ALMOS |
---|
| 197 | #define BDEV_SECTOR_SIZE 4096 |
---|
| 198 | #define BDEV_IMAGE_NAME PREFIX_OS"hdd-img.bin" |
---|
| 199 | #endif |
---|
[344] | 200 | |
---|
[464] | 201 | #define NIC_RX_NAME PREFIX_OS"nic/rx_packets.txt" |
---|
| 202 | #define NIC_TX_NAME PREFIX_OS"nic/tx_packets.txt" |
---|
[344] | 203 | #define NIC_TIMEOUT 10000 |
---|
| 204 | |
---|
[438] | 205 | #define NORTH 0 |
---|
| 206 | #define SOUTH 1 |
---|
| 207 | #define EAST 2 |
---|
| 208 | #define WEST 3 |
---|
| 209 | |
---|
[344] | 210 | //////////////////////////////////////////////////////////// |
---|
| 211 | // Software to be loaded in ROM & RAM |
---|
| 212 | //////////////////////i///////////////////////////////////// |
---|
| 213 | |
---|
[464] | 214 | #ifdef USE_ALMOS |
---|
[1012] | 215 | #define soft_name PREFIX_OS"preloader.elf" |
---|
[464] | 216 | #endif |
---|
| 217 | #ifdef USE_GIET |
---|
[468] | 218 | #define soft_pathname PREFIX_OS"soft.elf" |
---|
[464] | 219 | #endif |
---|
[344] | 220 | |
---|
| 221 | //////////////////////////////////////////////////////////// |
---|
| 222 | // DEBUG Parameters default values |
---|
| 223 | //////////////////////i///////////////////////////////////// |
---|
| 224 | |
---|
[663] | 225 | #define MAX_FROZEN_CYCLES 100000000 |
---|
[344] | 226 | |
---|
[572] | 227 | |
---|
| 228 | //////////////////////////////////////////////////////////////////// |
---|
| 229 | // TGTID definition in direct space |
---|
| 230 | // For all components: global TGTID = global SRCID = cluster_index |
---|
| 231 | //////////////////////////////////////////////////////////////////// |
---|
| 232 | |
---|
| 233 | |
---|
[344] | 234 | ///////////////////////////////////////////////////////// |
---|
| 235 | // Physical segments definition |
---|
| 236 | ///////////////////////////////////////////////////////// |
---|
| 237 | // There is 3 segments replicated in all clusters |
---|
| 238 | // and 5 specific segments in the "IO" cluster |
---|
| 239 | // (containing address 0xBF000000) |
---|
| 240 | ///////////////////////////////////////////////////////// |
---|
| 241 | |
---|
[547] | 242 | #ifdef USE_GIET |
---|
[1012] | 243 | #error "This platform is no more supported for the GIET" |
---|
[504] | 244 | #endif |
---|
[344] | 245 | |
---|
[504] | 246 | #ifdef USE_ALMOS |
---|
[572] | 247 | // 2^19 is the offset for the local id (8 bits for global ID : |
---|
| 248 | // 1 bit for Memcache or Peripheral, 4 for local peripheral id) |
---|
| 249 | // (Almos supports 32 bits physical addresses) |
---|
[504] | 250 | #endif |
---|
[344] | 251 | |
---|
[504] | 252 | bool stop_called = false; |
---|
| 253 | |
---|
[344] | 254 | ///////////////////////////////// |
---|
| 255 | int _main(int argc, char *argv[]) |
---|
| 256 | { |
---|
| 257 | using namespace sc_core; |
---|
| 258 | using namespace soclib::caba; |
---|
| 259 | using namespace soclib::common; |
---|
| 260 | |
---|
[663] | 261 | const int64_t max_cycles = 5000000; // Maximum number of cycles simulated in one sc_start call |
---|
| 262 | int64_t ncycles = 0x7FFFFFFFFFFFFFFF; // simulated cycles |
---|
| 263 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
| 264 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
| 265 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
| 266 | ssize_t threads_nr = 1; // simulator's threads number |
---|
| 267 | bool debug_ok = false; // trace activated |
---|
| 268 | size_t debug_period = 1; // trace period |
---|
| 269 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
| 270 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
| 271 | int64_t debug_from = 0; // trace start cycle |
---|
| 272 | int64_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
| 273 | int64_t reset_counters = -1; |
---|
| 274 | int64_t dump_counters = -1; |
---|
| 275 | bool do_reset_counters = false; |
---|
| 276 | bool do_dump_counters = false; |
---|
| 277 | struct timeval t1, t2; |
---|
| 278 | uint64_t ms1, ms2; |
---|
[344] | 279 | |
---|
| 280 | ////////////// command line arguments ////////////////////// |
---|
[1023] | 281 | if (argc > 1) { |
---|
| 282 | for (int n = 1; n < argc; n = n + 2) { |
---|
| 283 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) { |
---|
[663] | 284 | ncycles = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 285 | } |
---|
[1023] | 286 | else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) { |
---|
[464] | 287 | #ifdef USE_ALMOS |
---|
| 288 | assert( 0 && "Can't define almos soft name" ); |
---|
| 289 | #endif |
---|
| 290 | #ifdef USE_GIET |
---|
[504] | 291 | strcpy(soft_name, argv[n + 1]); |
---|
[464] | 292 | #endif |
---|
[344] | 293 | } |
---|
[1023] | 294 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) { |
---|
[504] | 295 | strcpy(disk_name, argv[n + 1]); |
---|
[344] | 296 | } |
---|
[1023] | 297 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) { |
---|
[344] | 298 | debug_ok = true; |
---|
[663] | 299 | debug_from = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 300 | } |
---|
[1023] | 301 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) { |
---|
[619] | 302 | debug_memc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
| 303 | #ifdef USE_ALMOS |
---|
[663] | 304 | assert((debug_memc_id < (X_SIZE * Y_SIZE)) && |
---|
| 305 | "debug_memc_id larger than X_SIZE * Y_SIZE" ); |
---|
[619] | 306 | #else |
---|
| 307 | size_t x = debug_memc_id >> Y_WIDTH; |
---|
[836] | 308 | size_t y = debug_memc_id & ((1 << Y_WIDTH) - 1); |
---|
[619] | 309 | |
---|
[663] | 310 | assert( (x <= X_SIZE) and (y <= Y_SIZE) && |
---|
[619] | 311 | "MEMCID parameter refers a not valid memory cache"); |
---|
| 312 | #endif |
---|
[344] | 313 | } |
---|
[1023] | 314 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) { |
---|
[619] | 315 | debug_proc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
| 316 | #ifdef USE_ALMOS |
---|
[663] | 317 | assert((debug_proc_id < (X_SIZE * Y_SIZE * NB_PROCS_MAX)) && |
---|
| 318 | "debug_proc_id larger than X_SIZE * Y_SIZE * NB_PROCS"); |
---|
[619] | 319 | #else |
---|
| 320 | size_t cluster_xy = debug_proc_id / NB_PROCS_MAX ; |
---|
[836] | 321 | size_t x = cluster_xy >> Y_WIDTH; |
---|
| 322 | size_t y = cluster_xy & ((1 << Y_WIDTH) - 1); |
---|
[619] | 323 | |
---|
[663] | 324 | assert( (x <= X_SIZE) and (y <= Y_SIZE) && |
---|
[619] | 325 | "PROCID parameter refers a not valid processor"); |
---|
| 326 | #endif |
---|
[344] | 327 | } |
---|
[1023] | 328 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) { |
---|
[619] | 329 | threads_nr = (ssize_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 330 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
| 331 | } |
---|
[1023] | 332 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) { |
---|
[663] | 333 | frozen_cycles = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 334 | } |
---|
[1023] | 335 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) { |
---|
[619] | 336 | debug_period = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 337 | } |
---|
[1023] | 338 | else if ((strcmp(argv[n], "--reset-counters") == 0) && (n + 1 < argc)) { |
---|
[663] | 339 | reset_counters = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
| 340 | do_reset_counters = true; |
---|
| 341 | } |
---|
[1023] | 342 | else if ((strcmp(argv[n], "--dump-counters") == 0) && (n + 1 < argc)) { |
---|
[663] | 343 | dump_counters = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
| 344 | do_dump_counters = true; |
---|
| 345 | } |
---|
[1023] | 346 | else { |
---|
[344] | 347 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
| 348 | std::cout << " The order is not important." << std::endl; |
---|
| 349 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
| 350 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
| 351 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
| 352 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
| 353 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
| 354 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
| 355 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
| 356 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
| 357 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
| 358 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
| 359 | exit(0); |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | |
---|
[396] | 364 | // checking hardware parameters |
---|
[663] | 365 | assert( ( (X_SIZE == 1) or (X_SIZE == 2) or (X_SIZE == 4) or |
---|
| 366 | (X_SIZE == 8) or (X_SIZE == 16) ) and |
---|
| 367 | "The X_SIZE parameter must be 1, 2, 4, 8 or 16" ); |
---|
[344] | 368 | |
---|
[663] | 369 | assert( ( (Y_SIZE == 1) or (Y_SIZE == 2) or (Y_SIZE == 4) or |
---|
| 370 | (Y_SIZE == 8) or (Y_SIZE == 16) ) and |
---|
| 371 | "The Y_SIZE parameter must be 1, 2, 4, 8 or 16" ); |
---|
[344] | 372 | |
---|
[396] | 373 | assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or |
---|
| 374 | (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and |
---|
| 375 | "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" ); |
---|
[344] | 376 | |
---|
[396] | 377 | assert( (NB_DMA_CHANNELS < 9) and |
---|
| 378 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
[344] | 379 | |
---|
[396] | 380 | assert( (NB_TTY_CHANNELS < 15) and |
---|
| 381 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
[344] | 382 | |
---|
[396] | 383 | assert( (NB_NIC_CHANNELS < 9) and |
---|
| 384 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
[344] | 385 | |
---|
[464] | 386 | #ifdef USE_GIET |
---|
[438] | 387 | assert( (vci_address_width == 40) and |
---|
[504] | 388 | "VCI address width with the GIET must be 40 bits" ); |
---|
[464] | 389 | #endif |
---|
[344] | 390 | |
---|
[504] | 391 | #ifdef USE_ALMOS |
---|
| 392 | assert( (vci_address_width == 32) and |
---|
| 393 | "VCI address width with ALMOS must be 32 bits" ); |
---|
| 394 | #endif |
---|
| 395 | |
---|
| 396 | |
---|
[396] | 397 | std::cout << std::endl; |
---|
[663] | 398 | std::cout << " - X_SIZE = " << X_SIZE << std::endl; |
---|
| 399 | std::cout << " - Y_SIZE = " << Y_SIZE << std::endl; |
---|
[438] | 400 | std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl; |
---|
[396] | 401 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
[438] | 402 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
| 403 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
| 404 | std::cout << " - MEMC_WAYS = " << MEMC_WAYS << std::endl; |
---|
| 405 | std::cout << " - MEMC_SETS = " << MEMC_SETS << std::endl; |
---|
| 406 | std::cout << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl; |
---|
| 407 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
[396] | 408 | |
---|
| 409 | std::cout << std::endl; |
---|
| 410 | // Internal and External VCI parameters definition |
---|
[438] | 411 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
| 412 | vci_plen_width, |
---|
| 413 | vci_address_width, |
---|
| 414 | vci_rerror_width, |
---|
| 415 | vci_clen_width, |
---|
| 416 | vci_rflag_width, |
---|
| 417 | vci_srcid_width, |
---|
| 418 | vci_pktid_width, |
---|
| 419 | vci_trdid_width, |
---|
| 420 | vci_wrplen_width> vci_param_int; |
---|
[396] | 421 | |
---|
[438] | 422 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
| 423 | vci_plen_width, |
---|
| 424 | vci_address_width, |
---|
| 425 | vci_rerror_width, |
---|
| 426 | vci_clen_width, |
---|
| 427 | vci_rflag_width, |
---|
| 428 | vci_srcid_width, |
---|
| 429 | vci_pktid_width, |
---|
| 430 | vci_trdid_width, |
---|
| 431 | vci_wrplen_width> vci_param_ext; |
---|
[396] | 432 | |
---|
[344] | 433 | #if USE_OPENMP |
---|
| 434 | omp_set_dynamic(false); |
---|
| 435 | omp_set_num_threads(threads_nr); |
---|
| 436 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
| 437 | #endif |
---|
| 438 | |
---|
[663] | 439 | // Define parameters depending on mesh size |
---|
| 440 | size_t x_width; |
---|
| 441 | size_t y_width; |
---|
| 442 | |
---|
[619] | 443 | #ifdef USE_ALMOS |
---|
[663] | 444 | if (X_SIZE == 1) x_width = 0; |
---|
| 445 | else if (X_SIZE == 2) x_width = 1; |
---|
| 446 | else if (X_SIZE <= 4) x_width = 2; |
---|
| 447 | else if (X_SIZE <= 8) x_width = 3; |
---|
[1023] | 448 | else x_width = 4; |
---|
[344] | 449 | |
---|
[663] | 450 | if (Y_SIZE == 1) y_width = 0; |
---|
| 451 | else if (Y_SIZE == 2) y_width = 1; |
---|
| 452 | else if (Y_SIZE <= 4) y_width = 2; |
---|
| 453 | else if (Y_SIZE <= 8) y_width = 3; |
---|
[1023] | 454 | else y_width = 4; |
---|
[344] | 455 | |
---|
[619] | 456 | #else |
---|
| 457 | size_t x_width = X_WIDTH; |
---|
| 458 | size_t y_width = Y_WIDTH; |
---|
| 459 | |
---|
[1012] | 460 | assert((X_WIDTH <= 4) and (Y_WIDTH <= 4) and |
---|
[619] | 461 | "Up to 256 clusters"); |
---|
| 462 | |
---|
[1012] | 463 | assert((X_SIZE <= (1 << X_WIDTH)) and (Y_SIZE <= (1 << Y_WIDTH)) and |
---|
[619] | 464 | "The X_WIDTH and Y_WIDTH parameter are insufficient"); |
---|
| 465 | |
---|
[504] | 466 | #endif |
---|
| 467 | |
---|
[344] | 468 | ///////////////////// |
---|
| 469 | // Mapping Tables |
---|
| 470 | ///////////////////// |
---|
| 471 | |
---|
[396] | 472 | // internal network |
---|
[438] | 473 | MappingTable maptabd(vci_address_width, |
---|
[572] | 474 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
[438] | 475 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
[547] | 476 | 0x00FF800000); |
---|
[344] | 477 | |
---|
[1023] | 478 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 479 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
[438] | 480 | sc_uint<vci_address_width> offset; |
---|
[1012] | 481 | offset = (sc_uint<vci_address_width>) cluster(x,y) |
---|
| 482 | << (vci_address_width - x_width - y_width); |
---|
[344] | 483 | |
---|
| 484 | std::ostringstream si; |
---|
[396] | 485 | si << "seg_xicu_" << x << "_" << y; |
---|
[1012] | 486 | maptabd.add(Segment(si.str(), SEG_XCU_BASE + offset, SEG_XCU_SIZE, |
---|
| 487 | IntTab(cluster(x,y), XCU_TGTID), false)); |
---|
[344] | 488 | |
---|
| 489 | std::ostringstream sd; |
---|
[396] | 490 | sd << "seg_mdma_" << x << "_" << y; |
---|
[1012] | 491 | maptabd.add(Segment(sd.str(), SEG_DMA_BASE + offset, SEG_DMA_SIZE, |
---|
| 492 | IntTab(cluster(x,y), DMA_TGTID), false)); |
---|
[344] | 493 | |
---|
[547] | 494 | std::ostringstream sh; |
---|
| 495 | sh << "seg_memc_" << x << "_" << y; |
---|
[1012] | 496 | maptabd.add(Segment(sh.str(), SEG_RAM_BASE + offset, SEG_RAM_SIZE, |
---|
| 497 | IntTab(cluster(x,y), RAM_TGTID), true)); |
---|
[547] | 498 | |
---|
[1023] | 499 | if (x == X_IO && y == Y_IO) { |
---|
[1012] | 500 | maptabd.add(Segment("seg_mtty", SEG_TTY_BASE, SEG_TTY_SIZE, |
---|
| 501 | IntTab(cluster(x,y),TTY_TGTID), false)); |
---|
| 502 | maptabd.add(Segment("seg_fbuf", SEG_FBF_BASE, SEG_FBF_SIZE, |
---|
| 503 | IntTab(cluster(x,y),FBF_TGTID), false)); |
---|
| 504 | maptabd.add(Segment("seg_bdev", SEG_IOC_BASE, SEG_IOC_SIZE, |
---|
| 505 | IntTab(cluster(x,y),IOC_TGTID), false)); |
---|
| 506 | maptabd.add(Segment("seg_brom", SEG_ROM_BASE, SEG_ROM_SIZE, |
---|
| 507 | IntTab(cluster(x,y),ROM_TGTID), true)); |
---|
| 508 | maptabd.add(Segment("seg_mnic", SEG_NIC_BASE, SEG_NIC_SIZE, |
---|
| 509 | IntTab(cluster(x,y),NIC_TGTID), false)); |
---|
| 510 | maptabd.add(Segment("seg_cdma", SEG_CMA_BASE, SEG_CMA_SIZE, |
---|
| 511 | IntTab(cluster(x,y),CMA_TGTID), false)); |
---|
| 512 | maptabd.add(Segment("seg_simh", SEG_SIM_BASE, SEG_SIM_SIZE, |
---|
| 513 | IntTab(cluster(x,y),SIM_TGTID), false)); |
---|
[344] | 514 | } |
---|
| 515 | } |
---|
| 516 | } |
---|
| 517 | std::cout << maptabd << std::endl; |
---|
| 518 | |
---|
| 519 | // external network |
---|
[438] | 520 | MappingTable maptabx(vci_address_width, |
---|
[1012] | 521 | IntTab(x_width + y_width), |
---|
| 522 | IntTab(x_width + y_width), |
---|
[396] | 523 | 0xFFFF000000ULL); |
---|
[344] | 524 | |
---|
[1023] | 525 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 526 | for (size_t y = 0; y < Y_SIZE ; y++) { |
---|
[396] | 527 | |
---|
[438] | 528 | sc_uint<vci_address_width> offset; |
---|
[1012] | 529 | offset = (sc_uint<vci_address_width>) cluster(x,y) |
---|
[836] | 530 | << (vci_address_width - x_width - y_width); |
---|
[396] | 531 | |
---|
[344] | 532 | std::ostringstream sh; |
---|
| 533 | sh << "x_seg_memc_" << x << "_" << y; |
---|
[396] | 534 | |
---|
[1012] | 535 | maptabx.add(Segment(sh.str(), SEG_RAM_BASE + offset, |
---|
| 536 | SEG_RAM_SIZE, IntTab(cluster(x,y)), false)); |
---|
[344] | 537 | } |
---|
| 538 | } |
---|
| 539 | std::cout << maptabx << std::endl; |
---|
| 540 | |
---|
| 541 | //////////////////// |
---|
| 542 | // Signals |
---|
| 543 | /////////////////// |
---|
| 544 | |
---|
[389] | 545 | sc_clock signal_clk("clk"); |
---|
[344] | 546 | sc_signal<bool> signal_resetn("resetn"); |
---|
| 547 | |
---|
| 548 | // Horizontal inter-clusters DSPIN signals |
---|
[885] | 549 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cmd_inc = |
---|
[1012] | 550 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", X_SIZE - 1, Y_SIZE); |
---|
[885] | 551 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cmd_dec = |
---|
[1012] | 552 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", X_SIZE - 1, Y_SIZE); |
---|
[344] | 553 | |
---|
[885] | 554 | DspinSignals<dspin_rsp_width>** signal_dspin_h_rsp_inc = |
---|
[1012] | 555 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", X_SIZE - 1, Y_SIZE); |
---|
[885] | 556 | DspinSignals<dspin_rsp_width>** signal_dspin_h_rsp_dec = |
---|
[1012] | 557 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", X_SIZE - 1, Y_SIZE); |
---|
[885] | 558 | |
---|
| 559 | DspinSignals<dspin_cmd_width>** signal_dspin_h_m2p_inc = |
---|
[1012] | 560 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_inc", X_SIZE- 1 , Y_SIZE); |
---|
[885] | 561 | DspinSignals<dspin_cmd_width>** signal_dspin_h_m2p_dec = |
---|
[1012] | 562 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_dec", X_SIZE - 1, Y_SIZE); |
---|
[885] | 563 | |
---|
| 564 | DspinSignals<dspin_rsp_width>** signal_dspin_h_p2m_inc = |
---|
[1012] | 565 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_inc", X_SIZE - 1, Y_SIZE); |
---|
[885] | 566 | DspinSignals<dspin_rsp_width>** signal_dspin_h_p2m_dec = |
---|
[1012] | 567 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_dec", X_SIZE - 1, Y_SIZE); |
---|
[885] | 568 | |
---|
| 569 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cla_inc = |
---|
[1012] | 570 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_inc", X_SIZE - 1, Y_SIZE); |
---|
[885] | 571 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cla_dec = |
---|
[1012] | 572 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_dec", X_SIZE - 1, Y_SIZE); |
---|
[885] | 573 | |
---|
[344] | 574 | // Vertical inter-clusters DSPIN signals |
---|
[885] | 575 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cmd_inc = |
---|
[1012] | 576 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", X_SIZE, Y_SIZE - 1); |
---|
[885] | 577 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cmd_dec = |
---|
[1012] | 578 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", X_SIZE, Y_SIZE - 1); |
---|
[344] | 579 | |
---|
[885] | 580 | DspinSignals<dspin_rsp_width>** signal_dspin_v_rsp_inc = |
---|
[1012] | 581 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", X_SIZE, Y_SIZE - 1); |
---|
[885] | 582 | DspinSignals<dspin_rsp_width>** signal_dspin_v_rsp_dec = |
---|
[1012] | 583 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", X_SIZE, Y_SIZE - 1); |
---|
[344] | 584 | |
---|
[885] | 585 | DspinSignals<dspin_cmd_width>** signal_dspin_v_m2p_inc = |
---|
[1012] | 586 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_m2p_inc", X_SIZE, Y_SIZE - 1); |
---|
[885] | 587 | DspinSignals<dspin_cmd_width>** signal_dspin_v_m2p_dec = |
---|
[1012] | 588 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_m2p_dec", X_SIZE, Y_SIZE - 1); |
---|
[885] | 589 | |
---|
| 590 | DspinSignals<dspin_rsp_width>** signal_dspin_v_p2m_inc = |
---|
[1012] | 591 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_p2m_inc", X_SIZE, Y_SIZE - 1); |
---|
[885] | 592 | DspinSignals<dspin_rsp_width>** signal_dspin_v_p2m_dec = |
---|
[1012] | 593 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_p2m_dec", X_SIZE, Y_SIZE - 1); |
---|
[885] | 594 | |
---|
| 595 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cla_inc = |
---|
[1012] | 596 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cla_inc", X_SIZE, Y_SIZE - 1); |
---|
[885] | 597 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cla_dec = |
---|
[1012] | 598 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cla_dec", X_SIZE, Y_SIZE - 1); |
---|
[885] | 599 | |
---|
| 600 | // Mesh boundaries DSPIN signals (Most of those signals are not used...) |
---|
| 601 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cmd_in = |
---|
| 602 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cmd_in" , X_SIZE, Y_SIZE, 4); |
---|
| 603 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cmd_out = |
---|
| 604 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cmd_out", X_SIZE, Y_SIZE, 4); |
---|
| 605 | |
---|
| 606 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_rsp_in = |
---|
| 607 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_rsp_in" , X_SIZE, Y_SIZE, 4); |
---|
| 608 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_rsp_out = |
---|
| 609 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_rsp_out", X_SIZE, Y_SIZE, 4); |
---|
| 610 | |
---|
| 611 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_m2p_in = |
---|
| 612 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_m2p_in" , X_SIZE, Y_SIZE, 4); |
---|
| 613 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_m2p_out = |
---|
| 614 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_m2p_out", X_SIZE, Y_SIZE, 4); |
---|
| 615 | |
---|
| 616 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_p2m_in = |
---|
| 617 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_p2m_in" , X_SIZE, Y_SIZE, 4); |
---|
| 618 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_p2m_out = |
---|
| 619 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_p2m_out", X_SIZE, Y_SIZE, 4); |
---|
| 620 | |
---|
| 621 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cla_in = |
---|
| 622 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cla_in" , X_SIZE, Y_SIZE, 4); |
---|
| 623 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cla_out = |
---|
| 624 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cla_out", X_SIZE, Y_SIZE, 4); |
---|
| 625 | |
---|
| 626 | |
---|
[344] | 627 | //////////////////////////// |
---|
| 628 | // Loader |
---|
| 629 | //////////////////////////// |
---|
| 630 | |
---|
| 631 | soclib::common::Loader loader(soft_name); |
---|
| 632 | |
---|
| 633 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
| 634 | proc_iss::set_loader(loader); |
---|
| 635 | |
---|
| 636 | //////////////////////////// |
---|
| 637 | // Clusters construction |
---|
| 638 | //////////////////////////// |
---|
| 639 | |
---|
[396] | 640 | TsarXbarCluster<dspin_cmd_width, |
---|
| 641 | dspin_rsp_width, |
---|
| 642 | vci_param_int, |
---|
[836] | 643 | vci_param_ext> * clusters[X_SIZE][Y_SIZE]; |
---|
[344] | 644 | |
---|
| 645 | #if USE_OPENMP |
---|
| 646 | #pragma omp parallel |
---|
| 647 | { |
---|
| 648 | #pragma omp for |
---|
| 649 | #endif |
---|
[1023] | 650 | for (size_t i = 0; i < (X_SIZE * Y_SIZE); i++) { |
---|
[663] | 651 | size_t x = i / Y_SIZE; |
---|
| 652 | size_t y = i % Y_SIZE; |
---|
[344] | 653 | |
---|
| 654 | #if USE_OPENMP |
---|
| 655 | #pragma omp critical |
---|
| 656 | { |
---|
| 657 | #endif |
---|
[438] | 658 | std::cout << std::endl; |
---|
| 659 | std::cout << "Cluster_" << x << "_" << y << std::endl; |
---|
| 660 | std::cout << std::endl; |
---|
[389] | 661 | |
---|
[344] | 662 | std::ostringstream sc; |
---|
| 663 | sc << "cluster_" << x << "_" << y; |
---|
[396] | 664 | clusters[x][y] = new TsarXbarCluster<dspin_cmd_width, |
---|
| 665 | dspin_rsp_width, |
---|
| 666 | vci_param_int, |
---|
| 667 | vci_param_ext> |
---|
[344] | 668 | ( |
---|
| 669 | sc.str().c_str(), |
---|
[396] | 670 | NB_PROCS_MAX, |
---|
[752] | 671 | NB_TTY_CHANNELS, |
---|
| 672 | NB_DMA_CHANNELS, |
---|
[396] | 673 | x, |
---|
| 674 | y, |
---|
| 675 | cluster(x,y), |
---|
| 676 | maptabd, |
---|
| 677 | maptabx, |
---|
| 678 | x_width, |
---|
| 679 | y_width, |
---|
[438] | 680 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
[1023] | 681 | P_WIDTH, |
---|
[1012] | 682 | RAM_TGTID, |
---|
| 683 | XCU_TGTID, |
---|
| 684 | DMA_TGTID, |
---|
| 685 | FBF_TGTID, |
---|
| 686 | TTY_TGTID, |
---|
| 687 | ROM_TGTID, |
---|
| 688 | NIC_TGTID, |
---|
| 689 | CMA_TGTID, |
---|
| 690 | IOC_TGTID, |
---|
| 691 | SIM_TGTID, |
---|
[396] | 692 | MEMC_WAYS, |
---|
| 693 | MEMC_SETS, |
---|
| 694 | L1_IWAYS, |
---|
| 695 | L1_ISETS, |
---|
| 696 | L1_DWAYS, |
---|
| 697 | L1_DSETS, |
---|
[706] | 698 | IRQ_PER_PROCESSOR, |
---|
[396] | 699 | XRAM_LATENCY, |
---|
[1023] | 700 | x == X_IO && y == Y_IO, |
---|
[1012] | 701 | FBF_X_SIZE, |
---|
| 702 | FBF_Y_SIZE, |
---|
[396] | 703 | disk_name, |
---|
| 704 | BDEV_SECTOR_SIZE, |
---|
| 705 | NB_NIC_CHANNELS, |
---|
| 706 | nic_rx_name, |
---|
| 707 | nic_tx_name, |
---|
| 708 | NIC_TIMEOUT, |
---|
[485] | 709 | NB_CMA_CHANNELS, |
---|
[396] | 710 | loader, |
---|
[344] | 711 | frozen_cycles, |
---|
[663] | 712 | debug_from, |
---|
[836] | 713 | debug_ok, |
---|
| 714 | debug_ok |
---|
[344] | 715 | ); |
---|
| 716 | |
---|
| 717 | #if USE_OPENMP |
---|
| 718 | } // end critical |
---|
| 719 | #endif |
---|
| 720 | } // end for |
---|
| 721 | #if USE_OPENMP |
---|
| 722 | } |
---|
| 723 | #endif |
---|
| 724 | |
---|
| 725 | /////////////////////////////////////////////////////////////// |
---|
| 726 | // Net-list |
---|
| 727 | /////////////////////////////////////////////////////////////// |
---|
| 728 | |
---|
| 729 | // Clock & RESET |
---|
[1023] | 730 | for (int x = 0; x < X_SIZE; x++) { |
---|
| 731 | for (int y = 0; y < Y_SIZE; y++) { |
---|
| 732 | clusters[x][y]->p_clk (signal_clk); |
---|
| 733 | clusters[x][y]->p_resetn (signal_resetn); |
---|
[344] | 734 | } |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | // Inter Clusters horizontal connections |
---|
[1023] | 738 | for (int x = 0; x < X_SIZE - 1; x++) { |
---|
| 739 | for (int y = 0; y < Y_SIZE; y++) { |
---|
| 740 | clusters[x][y]->p_cmd_out[EAST] (signal_dspin_h_cmd_inc[x][y]); |
---|
| 741 | clusters[x + 1][y]->p_cmd_in[WEST] (signal_dspin_h_cmd_inc[x][y]); |
---|
| 742 | clusters[x][y]->p_cmd_in[EAST] (signal_dspin_h_cmd_dec[x][y]); |
---|
| 743 | clusters[x + 1][y]->p_cmd_out[WEST] (signal_dspin_h_cmd_dec[x][y]); |
---|
[468] | 744 | |
---|
[1023] | 745 | clusters[x][y]->p_rsp_out[EAST] (signal_dspin_h_rsp_inc[x][y]); |
---|
| 746 | clusters[x + 1][y]->p_rsp_in[WEST] (signal_dspin_h_rsp_inc[x][y]); |
---|
| 747 | clusters[x][y]->p_rsp_in[EAST] (signal_dspin_h_rsp_dec[x][y]); |
---|
| 748 | clusters[x + 1][y]->p_rsp_out[WEST] (signal_dspin_h_rsp_dec[x][y]); |
---|
[885] | 749 | |
---|
[1023] | 750 | clusters[x][y]->p_m2p_out[EAST] (signal_dspin_h_m2p_inc[x][y]); |
---|
| 751 | clusters[x + 1][y]->p_m2p_in[WEST] (signal_dspin_h_m2p_inc[x][y]); |
---|
| 752 | clusters[x][y]->p_m2p_in[EAST] (signal_dspin_h_m2p_dec[x][y]); |
---|
| 753 | clusters[x + 1][y]->p_m2p_out[WEST] (signal_dspin_h_m2p_dec[x][y]); |
---|
[885] | 754 | |
---|
[1023] | 755 | clusters[x][y]->p_p2m_out[EAST] (signal_dspin_h_p2m_inc[x][y]); |
---|
| 756 | clusters[x + 1][y]->p_p2m_in[WEST] (signal_dspin_h_p2m_inc[x][y]); |
---|
| 757 | clusters[x][y]->p_p2m_in[EAST] (signal_dspin_h_p2m_dec[x][y]); |
---|
| 758 | clusters[x + 1][y]->p_p2m_out[WEST] (signal_dspin_h_p2m_dec[x][y]); |
---|
[885] | 759 | |
---|
[1023] | 760 | clusters[x][y]->p_cla_out[EAST] (signal_dspin_h_cla_inc[x][y]); |
---|
| 761 | clusters[x + 1][y]->p_cla_in[WEST] (signal_dspin_h_cla_inc[x][y]); |
---|
| 762 | clusters[x][y]->p_cla_in[EAST] (signal_dspin_h_cla_dec[x][y]); |
---|
| 763 | clusters[x + 1][y]->p_cla_out[WEST] (signal_dspin_h_cla_dec[x][y]); |
---|
| 764 | } |
---|
[344] | 765 | } |
---|
[885] | 766 | std::cout << std::endl << "Horizontal connections done" << std::endl; |
---|
[344] | 767 | |
---|
| 768 | // Inter Clusters vertical connections |
---|
[1023] | 769 | for (int y = 0; y < Y_SIZE - 1; y++) { |
---|
| 770 | for (int x = 0; x < X_SIZE; x++) { |
---|
| 771 | clusters[x][y]->p_cmd_out[NORTH] (signal_dspin_v_cmd_inc[x][y]); |
---|
| 772 | clusters[x][y + 1]->p_cmd_in[SOUTH] (signal_dspin_v_cmd_inc[x][y]); |
---|
| 773 | clusters[x][y]->p_cmd_in[NORTH] (signal_dspin_v_cmd_dec[x][y]); |
---|
| 774 | clusters[x][y + 1]->p_cmd_out[SOUTH] (signal_dspin_v_cmd_dec[x][y]); |
---|
[468] | 775 | |
---|
[1023] | 776 | clusters[x][y]->p_rsp_out[NORTH] (signal_dspin_v_rsp_inc[x][y]); |
---|
| 777 | clusters[x][y + 1]->p_rsp_in[SOUTH] (signal_dspin_v_rsp_inc[x][y]); |
---|
| 778 | clusters[x][y]->p_rsp_in[NORTH] (signal_dspin_v_rsp_dec[x][y]); |
---|
| 779 | clusters[x][y + 1]->p_rsp_out[SOUTH] (signal_dspin_v_rsp_dec[x][y]); |
---|
[885] | 780 | |
---|
[1023] | 781 | clusters[x][y]->p_m2p_out[NORTH] (signal_dspin_v_m2p_inc[x][y]); |
---|
| 782 | clusters[x][y + 1]->p_m2p_in[SOUTH] (signal_dspin_v_m2p_inc[x][y]); |
---|
| 783 | clusters[x][y]->p_m2p_in[NORTH] (signal_dspin_v_m2p_dec[x][y]); |
---|
| 784 | clusters[x][y + 1]->p_m2p_out[SOUTH] (signal_dspin_v_m2p_dec[x][y]); |
---|
[885] | 785 | |
---|
[1023] | 786 | clusters[x][y]->p_p2m_out[NORTH] (signal_dspin_v_p2m_inc[x][y]); |
---|
| 787 | clusters[x][y + 1]->p_p2m_in[SOUTH] (signal_dspin_v_p2m_inc[x][y]); |
---|
| 788 | clusters[x][y]->p_p2m_in[NORTH] (signal_dspin_v_p2m_dec[x][y]); |
---|
| 789 | clusters[x][y + 1]->p_p2m_out[SOUTH] (signal_dspin_v_p2m_dec[x][y]); |
---|
[885] | 790 | |
---|
[1023] | 791 | clusters[x][y]->p_cla_out[NORTH] (signal_dspin_v_cla_inc[x][y]); |
---|
| 792 | clusters[x][y + 1]->p_cla_in[SOUTH] (signal_dspin_v_cla_inc[x][y]); |
---|
| 793 | clusters[x][y]->p_cla_in[NORTH] (signal_dspin_v_cla_dec[x][y]); |
---|
| 794 | clusters[x][y + 1]->p_cla_out[SOUTH] (signal_dspin_v_cla_dec[x][y]); |
---|
| 795 | } |
---|
[344] | 796 | } |
---|
[885] | 797 | std::cout << std::endl << "Vertical connections done" << std::endl; |
---|
[344] | 798 | |
---|
| 799 | // East & West boundary cluster connections |
---|
[1023] | 800 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
[885] | 801 | clusters[0][y]->p_cmd_in[WEST] (signal_dspin_bound_cmd_in[0][y][WEST]); |
---|
| 802 | clusters[0][y]->p_cmd_out[WEST] (signal_dspin_bound_cmd_out[0][y][WEST]); |
---|
[1023] | 803 | clusters[X_SIZE - 1][y]->p_cmd_in[EAST] (signal_dspin_bound_cmd_in[X_SIZE - 1][y][EAST]); |
---|
| 804 | clusters[X_SIZE - 1][y]->p_cmd_out[EAST] (signal_dspin_bound_cmd_out[X_SIZE - 1][y][EAST]); |
---|
[468] | 805 | |
---|
[885] | 806 | clusters[0][y]->p_rsp_in[WEST] (signal_dspin_bound_rsp_in[0][y][WEST]); |
---|
| 807 | clusters[0][y]->p_rsp_out[WEST] (signal_dspin_bound_rsp_out[0][y][WEST]); |
---|
[1023] | 808 | clusters[X_SIZE - 1][y]->p_rsp_in[EAST] (signal_dspin_bound_rsp_in[X_SIZE - 1][y][EAST]); |
---|
| 809 | clusters[X_SIZE - 1][y]->p_rsp_out[EAST] (signal_dspin_bound_rsp_out[X_SIZE - 1][y][EAST]); |
---|
[885] | 810 | |
---|
| 811 | clusters[0][y]->p_m2p_in[WEST] (signal_dspin_bound_m2p_in[0][y][WEST]); |
---|
| 812 | clusters[0][y]->p_m2p_out[WEST] (signal_dspin_bound_m2p_out[0][y][WEST]); |
---|
[1023] | 813 | clusters[X_SIZE - 1][y]->p_m2p_in[EAST] (signal_dspin_bound_m2p_in[X_SIZE - 1][y][EAST]); |
---|
| 814 | clusters[X_SIZE - 1][y]->p_m2p_out[EAST] (signal_dspin_bound_m2p_out[X_SIZE - 1][y][EAST]); |
---|
[885] | 815 | |
---|
| 816 | clusters[0][y]->p_p2m_in[WEST] (signal_dspin_bound_p2m_in[0][y][WEST]); |
---|
| 817 | clusters[0][y]->p_p2m_out[WEST] (signal_dspin_bound_p2m_out[0][y][WEST]); |
---|
[1023] | 818 | clusters[X_SIZE - 1][y]->p_p2m_in[EAST] (signal_dspin_bound_p2m_in[X_SIZE - 1][y][EAST]); |
---|
| 819 | clusters[X_SIZE - 1][y]->p_p2m_out[EAST] (signal_dspin_bound_p2m_out[X_SIZE - 1][y][EAST]); |
---|
[885] | 820 | |
---|
| 821 | clusters[0][y]->p_cla_in[WEST] (signal_dspin_bound_cla_in[0][y][WEST]); |
---|
| 822 | clusters[0][y]->p_cla_out[WEST] (signal_dspin_bound_cla_out[0][y][WEST]); |
---|
[1023] | 823 | clusters[X_SIZE - 1][y]->p_cla_in[EAST] (signal_dspin_bound_cla_in[X_SIZE - 1][y][EAST]); |
---|
| 824 | clusters[X_SIZE - 1][y]->p_cla_out[EAST] (signal_dspin_bound_cla_out[X_SIZE - 1][y][EAST]); |
---|
[344] | 825 | } |
---|
| 826 | |
---|
[885] | 827 | std::cout << std::endl << "West & East boundaries connections done" << std::endl; |
---|
| 828 | |
---|
[344] | 829 | // North & South boundary clusters connections |
---|
[885] | 830 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 831 | clusters[x][0]->p_cmd_in[SOUTH] (signal_dspin_bound_cmd_in[x][0][SOUTH]); |
---|
| 832 | clusters[x][0]->p_cmd_out[SOUTH] (signal_dspin_bound_cmd_out[x][0][SOUTH]); |
---|
[1023] | 833 | clusters[x][Y_SIZE - 1]->p_cmd_in[NORTH] (signal_dspin_bound_cmd_in[x][Y_SIZE - 1][NORTH]); |
---|
| 834 | clusters[x][Y_SIZE - 1]->p_cmd_out[NORTH](signal_dspin_bound_cmd_out[x][Y_SIZE - 1][NORTH]); |
---|
[468] | 835 | |
---|
[885] | 836 | clusters[x][0]->p_rsp_in[SOUTH] (signal_dspin_bound_rsp_in[x][0][SOUTH]); |
---|
| 837 | clusters[x][0]->p_rsp_out[SOUTH] (signal_dspin_bound_rsp_out[x][0][SOUTH]); |
---|
[1023] | 838 | clusters[x][Y_SIZE - 1]->p_rsp_in[NORTH] (signal_dspin_bound_rsp_in[x][Y_SIZE - 1][NORTH]); |
---|
| 839 | clusters[x][Y_SIZE - 1]->p_rsp_out[NORTH](signal_dspin_bound_rsp_out[x][Y_SIZE - 1][NORTH]); |
---|
[885] | 840 | |
---|
| 841 | clusters[x][0]->p_m2p_in[SOUTH] (signal_dspin_bound_m2p_in[x][0][SOUTH]); |
---|
| 842 | clusters[x][0]->p_m2p_out[SOUTH] (signal_dspin_bound_m2p_out[x][0][SOUTH]); |
---|
[1023] | 843 | clusters[x][Y_SIZE - 1]->p_m2p_in[NORTH] (signal_dspin_bound_m2p_in[x][Y_SIZE - 1][NORTH]); |
---|
| 844 | clusters[x][Y_SIZE - 1]->p_m2p_out[NORTH](signal_dspin_bound_m2p_out[x][Y_SIZE - 1][NORTH]); |
---|
[885] | 845 | |
---|
| 846 | clusters[x][0]->p_p2m_in[SOUTH] (signal_dspin_bound_p2m_in[x][0][SOUTH]); |
---|
| 847 | clusters[x][0]->p_p2m_out[SOUTH] (signal_dspin_bound_p2m_out[x][0][SOUTH]); |
---|
[1023] | 848 | clusters[x][Y_SIZE - 1]->p_p2m_in[NORTH] (signal_dspin_bound_p2m_in[x][Y_SIZE - 1][NORTH]); |
---|
| 849 | clusters[x][Y_SIZE - 1]->p_p2m_out[NORTH](signal_dspin_bound_p2m_out[x][Y_SIZE - 1][NORTH]); |
---|
[885] | 850 | |
---|
| 851 | clusters[x][0]->p_cla_in[SOUTH] (signal_dspin_bound_cla_in[x][0][SOUTH]); |
---|
| 852 | clusters[x][0]->p_cla_out[SOUTH] (signal_dspin_bound_cla_out[x][0][SOUTH]); |
---|
[1023] | 853 | clusters[x][Y_SIZE - 1]->p_cla_in[NORTH] (signal_dspin_bound_cla_in[x][Y_SIZE - 1][NORTH]); |
---|
| 854 | clusters[x][Y_SIZE - 1]->p_cla_out[NORTH](signal_dspin_bound_cla_out[x][Y_SIZE - 1][NORTH]); |
---|
[344] | 855 | } |
---|
[885] | 856 | |
---|
| 857 | std::cout << std::endl << "North & South boundaries connections done" << std::endl; |
---|
[396] | 858 | std::cout << std::endl; |
---|
[344] | 859 | |
---|
| 860 | |
---|
[836] | 861 | #ifdef WT_IDL |
---|
| 862 | std::list<VciCcVCacheWrapper<vci_param_int, |
---|
| 863 | dspin_cmd_width, |
---|
| 864 | dspin_rsp_width, |
---|
| 865 | GdbServer<Mips32ElIss> > * > l1_caches; |
---|
| 866 | |
---|
[1023] | 867 | for (int x = 0; x < X_SIZE; x++) { |
---|
| 868 | for (int y = 0; y < Y_SIZE; y++) { |
---|
[836] | 869 | for (int proc = 0; proc < NB_PROCS_MAX; proc++) { |
---|
| 870 | l1_caches.push_back(clusters[x][y]->proc[proc]); |
---|
| 871 | } |
---|
| 872 | } |
---|
| 873 | } |
---|
| 874 | |
---|
[1023] | 875 | for (int x = 0; x < X_SIZE; x++) { |
---|
| 876 | for (int y = 0; y < Y_SIZE; y++) { |
---|
[836] | 877 | clusters[x][y]->memc->set_vcache_list(l1_caches); |
---|
| 878 | } |
---|
| 879 | } |
---|
| 880 | #endif |
---|
| 881 | |
---|
| 882 | |
---|
[779] | 883 | //#define SC_TRACE |
---|
[752] | 884 | #ifdef SC_TRACE |
---|
| 885 | sc_trace_file * tf = sc_create_vcd_trace_file("my_trace_file"); |
---|
| 886 | |
---|
[1023] | 887 | for (int x = 0; x < X_SIZE - 1; x++) { |
---|
| 888 | for (int y = 0; y < Y_SIZE; y++) { |
---|
| 889 | for (int k = 0; k < 3; k++) { |
---|
| 890 | signal_dspin_h_cmd_inc[x][y][k].trace(tf, "dspin_h_cmd_inc"); |
---|
| 891 | signal_dspin_h_cmd_dec[x][y][k].trace(tf, "dspin_h_cmd_dec"); |
---|
| 892 | } |
---|
[752] | 893 | |
---|
[1023] | 894 | for (int k = 0; k < 2; k++) { |
---|
| 895 | signal_dspin_h_rsp_inc[x][y][k].trace(tf, "dspin_h_rsp_inc"); |
---|
| 896 | signal_dspin_h_rsp_dec[x][y][k].trace(tf, "dspin_h_rsp_dec"); |
---|
[752] | 897 | } |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | |
---|
[1023] | 901 | for (int y = 0; y < Y_SIZE - 1; y++) { |
---|
| 902 | for (int x = 0; x < X_SIZE; x++) { |
---|
| 903 | for (int k = 0; k < 3; k++) { |
---|
| 904 | signal_dspin_v_cmd_inc[x][y][k].trace(tf, "dspin_v_cmd_inc"); |
---|
| 905 | signal_dspin_v_cmd_dec[x][y][k].trace(tf, "dspin_v_cmd_dec"); |
---|
| 906 | } |
---|
[752] | 907 | |
---|
[1023] | 908 | for (int k = 0; k < 2; k++) { |
---|
| 909 | signal_dspin_v_rsp_inc[x][y][k].trace(tf, "dspin_v_rsp_inc"); |
---|
| 910 | signal_dspin_v_rsp_dec[x][y][k].trace(tf, "dspin_v_rsp_dec"); |
---|
[752] | 911 | } |
---|
| 912 | } |
---|
| 913 | } |
---|
| 914 | |
---|
[1023] | 915 | for (int x = 0; x < (X_SIZE); x++) { |
---|
| 916 | for (int y = 0; y < Y_SIZE; y++) { |
---|
[752] | 917 | std::ostringstream signame; |
---|
| 918 | signame << "cluster" << x << "_" << y; |
---|
| 919 | clusters[x][y]->trace(tf, signame.str()); |
---|
| 920 | } |
---|
| 921 | } |
---|
| 922 | #endif |
---|
| 923 | |
---|
[779] | 924 | |
---|
| 925 | //////////////////////////////////////////////////////// |
---|
| 926 | // Simulation |
---|
| 927 | /////////////////////////////////////////////////////// |
---|
| 928 | |
---|
| 929 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
| 930 | signal_resetn = false; |
---|
| 931 | |
---|
[885] | 932 | // set network boundaries signals default values |
---|
| 933 | // for all boundary clusters |
---|
| 934 | for (size_t x = 0; x < X_SIZE ; x++) { |
---|
| 935 | for (size_t y = 0; y < Y_SIZE ; y++) { |
---|
| 936 | for (size_t face = 0; face < 4; face++) { |
---|
| 937 | signal_dspin_bound_cmd_in [x][y][face].write = false; |
---|
| 938 | signal_dspin_bound_cmd_in [x][y][face].read = true; |
---|
| 939 | signal_dspin_bound_cmd_out[x][y][face].write = false; |
---|
| 940 | signal_dspin_bound_cmd_out[x][y][face].read = true; |
---|
| 941 | |
---|
| 942 | signal_dspin_bound_rsp_in [x][y][face].write = false; |
---|
| 943 | signal_dspin_bound_rsp_in [x][y][face].read = true; |
---|
| 944 | signal_dspin_bound_rsp_out[x][y][face].write = false; |
---|
| 945 | signal_dspin_bound_rsp_out[x][y][face].read = true; |
---|
| 946 | |
---|
| 947 | signal_dspin_bound_m2p_in [x][y][face].write = false; |
---|
| 948 | signal_dspin_bound_m2p_in [x][y][face].read = true; |
---|
| 949 | signal_dspin_bound_m2p_out[x][y][face].write = false; |
---|
| 950 | signal_dspin_bound_m2p_out[x][y][face].read = true; |
---|
| 951 | |
---|
| 952 | signal_dspin_bound_p2m_in [x][y][face].write = false; |
---|
| 953 | signal_dspin_bound_p2m_in [x][y][face].read = true; |
---|
| 954 | signal_dspin_bound_p2m_out[x][y][face].write = false; |
---|
| 955 | signal_dspin_bound_p2m_out[x][y][face].read = true; |
---|
| 956 | |
---|
| 957 | signal_dspin_bound_cla_in [x][y][face].write = false; |
---|
| 958 | signal_dspin_bound_cla_in [x][y][face].read = true; |
---|
| 959 | signal_dspin_bound_cla_out[x][y][face].write = false; |
---|
| 960 | signal_dspin_bound_cla_out[x][y][face].read = true; |
---|
| 961 | } |
---|
| 962 | } |
---|
[779] | 963 | } |
---|
[1023] | 964 | // @M debug fu** |
---|
| 965 | clusters[0][0]->signal_dspin_m2p_proc[2].read = true; |
---|
[779] | 966 | |
---|
| 967 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 968 | signal_resetn = true; |
---|
| 969 | |
---|
[663] | 970 | if (debug_ok) { |
---|
| 971 | #if USE_OPENMP |
---|
| 972 | assert(false && "OPEN MP should not be used with debug because of its traces"); |
---|
| 973 | #endif |
---|
[464] | 974 | |
---|
[663] | 975 | if (gettimeofday(&t1, NULL) != 0) { |
---|
| 976 | perror("gettimeofday"); |
---|
| 977 | return EXIT_FAILURE; |
---|
| 978 | } |
---|
[396] | 979 | |
---|
[1023] | 980 | for (int64_t n = 1; n < ncycles && !stop_called; n++) { |
---|
| 981 | if ((n % max_cycles) == 0) { |
---|
[663] | 982 | |
---|
[1023] | 983 | if (gettimeofday(&t2, NULL) != 0) { |
---|
[663] | 984 | perror("gettimeofday"); |
---|
| 985 | return EXIT_FAILURE; |
---|
| 986 | } |
---|
| 987 | |
---|
| 988 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
| 989 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
| 990 | std::cerr << "platform clock frequency " << (double) 5000000 / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
| 991 | |
---|
[752] | 992 | if (gettimeofday(&t1, NULL) != 0) |
---|
[663] | 993 | { |
---|
| 994 | perror("gettimeofday"); |
---|
| 995 | return EXIT_FAILURE; |
---|
| 996 | } |
---|
[464] | 997 | } |
---|
| 998 | |
---|
| 999 | |
---|
[663] | 1000 | if (n == reset_counters) { |
---|
| 1001 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1002 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1003 | clusters[x][y]->memc->reset_counters(); |
---|
| 1004 | } |
---|
| 1005 | } |
---|
[464] | 1006 | } |
---|
| 1007 | |
---|
[663] | 1008 | if (n == dump_counters) { |
---|
| 1009 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1010 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1011 | clusters[x][y]->memc->print_stats(true, false); |
---|
| 1012 | } |
---|
| 1013 | } |
---|
| 1014 | } |
---|
[344] | 1015 | |
---|
[1023] | 1016 | if ((n > debug_from) and (n % debug_period == 0)) { |
---|
[663] | 1017 | std::cout << "****************** cycle " << std::dec << n ; |
---|
[836] | 1018 | std::cout << "************************************************" << std::endl; |
---|
[379] | 1019 | |
---|
[1023] | 1020 | for (size_t x = 0; x < X_SIZE ; x++) { |
---|
| 1021 | for (size_t y = 0; y < Y_SIZE ; y++) { |
---|
[836] | 1022 | for (int proc = 0; proc < NB_PROCS_MAX; proc++) { |
---|
[1023] | 1023 | if (x == 0 && y == 0 && proc == 2) { |
---|
| 1024 | continue; |
---|
| 1025 | } |
---|
[836] | 1026 | clusters[x][y]->proc[proc]->print_trace(); |
---|
| 1027 | std::ostringstream proc_signame; |
---|
| 1028 | proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << proc ; |
---|
| 1029 | std::ostringstream p2m_signame; |
---|
| 1030 | p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << proc << " P2M"; |
---|
| 1031 | std::ostringstream m2p_signame; |
---|
| 1032 | m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << proc << " M2P"; |
---|
[404] | 1033 | |
---|
[836] | 1034 | clusters[x][y]->signal_vci_ini_proc[proc].print_trace(proc_signame.str()); |
---|
| 1035 | clusters[x][y]->signal_dspin_p2m_proc[proc].print_trace(p2m_signame.str()); |
---|
| 1036 | clusters[x][y]->signal_dspin_m2p_proc[proc].print_trace(m2p_signame.str()); |
---|
| 1037 | } |
---|
[404] | 1038 | |
---|
[836] | 1039 | clusters[x][y]->memc->print_trace(); |
---|
[344] | 1040 | |
---|
[836] | 1041 | std::ostringstream smemc; |
---|
| 1042 | smemc << "[SIG]MEMC_" << x << "_" << y; |
---|
| 1043 | std::ostringstream sxram; |
---|
| 1044 | sxram << "[SIG]XRAM_" << x << "_" << y; |
---|
| 1045 | std::ostringstream sm2p; |
---|
| 1046 | sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P"; |
---|
| 1047 | std::ostringstream sp2m; |
---|
| 1048 | sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M"; |
---|
[344] | 1049 | |
---|
[836] | 1050 | clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str()); |
---|
| 1051 | clusters[x][y]->signal_vci_xram.print_trace(sxram.str()); |
---|
| 1052 | clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str()); |
---|
| 1053 | clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str()); |
---|
| 1054 | } |
---|
| 1055 | } |
---|
[663] | 1056 | } |
---|
| 1057 | |
---|
| 1058 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
[344] | 1059 | } |
---|
[663] | 1060 | } |
---|
| 1061 | else { |
---|
| 1062 | int64_t n = 0; |
---|
[749] | 1063 | while (!stop_called && n != ncycles) { |
---|
[663] | 1064 | if (gettimeofday(&t1, NULL) != 0) { |
---|
| 1065 | perror("gettimeofday"); |
---|
| 1066 | return EXIT_FAILURE; |
---|
| 1067 | } |
---|
[749] | 1068 | int64_t nb_cycles = min(max_cycles, ncycles - n); |
---|
[663] | 1069 | if (do_reset_counters) { |
---|
| 1070 | nb_cycles = min(nb_cycles, reset_counters - n); |
---|
| 1071 | } |
---|
| 1072 | if (do_dump_counters) { |
---|
| 1073 | nb_cycles = min(nb_cycles, dump_counters - n); |
---|
| 1074 | } |
---|
[344] | 1075 | |
---|
[663] | 1076 | sc_start(sc_core::sc_time(nb_cycles, SC_NS)); |
---|
| 1077 | n += nb_cycles; |
---|
| 1078 | |
---|
| 1079 | if (do_reset_counters && n == reset_counters) { |
---|
| 1080 | // Reseting counters |
---|
| 1081 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1082 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1083 | clusters[x][y]->memc->reset_counters(); |
---|
| 1084 | } |
---|
| 1085 | } |
---|
| 1086 | do_reset_counters = false; |
---|
| 1087 | } |
---|
| 1088 | |
---|
| 1089 | if (do_dump_counters && n == dump_counters) { |
---|
| 1090 | // Dumping counters |
---|
| 1091 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1092 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1093 | clusters[x][y]->memc->print_stats(true, false); |
---|
| 1094 | } |
---|
| 1095 | } |
---|
| 1096 | do_dump_counters = false; |
---|
| 1097 | } |
---|
| 1098 | |
---|
| 1099 | |
---|
| 1100 | if (gettimeofday(&t2, NULL) != 0) { |
---|
| 1101 | perror("gettimeofday"); |
---|
| 1102 | return EXIT_FAILURE; |
---|
| 1103 | } |
---|
| 1104 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
| 1105 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
[706] | 1106 | std::cerr << std::dec << "cycle " << n << " platform clock frequency " << (double) nb_cycles / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
[663] | 1107 | } |
---|
[344] | 1108 | } |
---|
[504] | 1109 | |
---|
[885] | 1110 | |
---|
[512] | 1111 | // Free memory |
---|
[1023] | 1112 | for (size_t i = 0; i < (X_SIZE * Y_SIZE); i++) { |
---|
[663] | 1113 | size_t x = i / Y_SIZE; |
---|
| 1114 | size_t y = i % Y_SIZE; |
---|
[504] | 1115 | delete clusters[x][y]; |
---|
| 1116 | } |
---|
| 1117 | |
---|
[1023] | 1118 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, X_SIZE - 1, Y_SIZE); |
---|
| 1119 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, X_SIZE - 1, Y_SIZE); |
---|
[512] | 1120 | |
---|
[1023] | 1121 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, X_SIZE - 1, Y_SIZE); |
---|
| 1122 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, X_SIZE - 1, Y_SIZE); |
---|
[885] | 1123 | |
---|
[1023] | 1124 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_inc, X_SIZE - 1, Y_SIZE); |
---|
| 1125 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_dec, X_SIZE - 1, Y_SIZE); |
---|
[885] | 1126 | |
---|
[1023] | 1127 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_inc, X_SIZE - 1, Y_SIZE); |
---|
| 1128 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_dec, X_SIZE - 1, Y_SIZE); |
---|
[885] | 1129 | |
---|
[1023] | 1130 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_inc, X_SIZE - 1, Y_SIZE); |
---|
| 1131 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_dec, X_SIZE - 1, Y_SIZE); |
---|
[885] | 1132 | |
---|
[1023] | 1133 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, X_SIZE, Y_SIZE - 1); |
---|
| 1134 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, X_SIZE, Y_SIZE - 1); |
---|
[885] | 1135 | |
---|
[1023] | 1136 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, X_SIZE, Y_SIZE - 1); |
---|
| 1137 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, X_SIZE, Y_SIZE - 1); |
---|
[885] | 1138 | |
---|
[1023] | 1139 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_inc, X_SIZE, Y_SIZE - 1); |
---|
| 1140 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_dec, X_SIZE, Y_SIZE - 1); |
---|
[885] | 1141 | |
---|
[1023] | 1142 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_inc, X_SIZE, Y_SIZE - 1); |
---|
| 1143 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_dec, X_SIZE, Y_SIZE - 1); |
---|
[885] | 1144 | |
---|
[1023] | 1145 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_inc, X_SIZE, Y_SIZE - 1); |
---|
| 1146 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_dec, X_SIZE, Y_SIZE - 1); |
---|
[885] | 1147 | |
---|
| 1148 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cmd_in, X_SIZE, Y_SIZE, 4); |
---|
| 1149 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cmd_out, X_SIZE, Y_SIZE, 4); |
---|
| 1150 | |
---|
| 1151 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_rsp_in, X_SIZE, Y_SIZE, 4); |
---|
| 1152 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_rsp_out, X_SIZE, Y_SIZE, 4); |
---|
| 1153 | |
---|
| 1154 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_m2p_in, X_SIZE, Y_SIZE, 4); |
---|
| 1155 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_m2p_out, X_SIZE, Y_SIZE, 4); |
---|
| 1156 | |
---|
| 1157 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_p2m_in, X_SIZE, Y_SIZE, 4); |
---|
| 1158 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_p2m_out, X_SIZE, Y_SIZE, 4); |
---|
| 1159 | |
---|
| 1160 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cla_in, X_SIZE, Y_SIZE, 4); |
---|
| 1161 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cla_out, X_SIZE, Y_SIZE, 4); |
---|
| 1162 | |
---|
[344] | 1163 | return EXIT_SUCCESS; |
---|
| 1164 | } |
---|
| 1165 | |
---|
[504] | 1166 | |
---|
| 1167 | void handler(int dummy = 0) { |
---|
| 1168 | stop_called = true; |
---|
| 1169 | sc_stop(); |
---|
| 1170 | } |
---|
| 1171 | |
---|
[547] | 1172 | void voidhandler(int dummy = 0) {} |
---|
[504] | 1173 | |
---|
[1023] | 1174 | int sc_main (int argc, char *argv[]) { |
---|
[504] | 1175 | signal(SIGINT, handler); |
---|
[547] | 1176 | signal(SIGPIPE, voidhandler); |
---|
[504] | 1177 | |
---|
[344] | 1178 | try { |
---|
| 1179 | return _main(argc, argv); |
---|
| 1180 | } catch (std::exception &e) { |
---|
| 1181 | std::cout << e.what() << std::endl; |
---|
[1023] | 1182 | } |
---|
| 1183 | catch (...) { |
---|
[344] | 1184 | std::cout << "Unknown exception occured" << std::endl; |
---|
| 1185 | throw; |
---|
| 1186 | } |
---|
| 1187 | return 1; |
---|
| 1188 | } |
---|
| 1189 | |
---|
| 1190 | |
---|
| 1191 | // Local Variables: |
---|
| 1192 | // tab-width: 3 |
---|
| 1193 | // c-basic-offset: 3 |
---|
| 1194 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 1195 | // indent-tabs-mode: nil |
---|
| 1196 | // End: |
---|
| 1197 | |
---|
| 1198 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|