[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 | |
---|
| 128 | // cluster 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 |
---|
[663] | 215 | #define soft_name PREFIX_OS"bootloader-tsar-mipsel.bin",\ |
---|
[468] | 216 | PREFIX_OS"kernel-soclib.bin@0xbfc10000:D",\ |
---|
| 217 | PREFIX_OS"arch-info.bib@0xBFC08000:D" |
---|
[464] | 218 | #endif |
---|
| 219 | #ifdef USE_GIET |
---|
[468] | 220 | #define soft_pathname PREFIX_OS"soft.elf" |
---|
[464] | 221 | #endif |
---|
[344] | 222 | |
---|
| 223 | //////////////////////////////////////////////////////////// |
---|
| 224 | // DEBUG Parameters default values |
---|
| 225 | //////////////////////i///////////////////////////////////// |
---|
| 226 | |
---|
[663] | 227 | #define MAX_FROZEN_CYCLES 100000000 |
---|
[344] | 228 | |
---|
[572] | 229 | |
---|
| 230 | //////////////////////////////////////////////////////////////////// |
---|
| 231 | // TGTID definition in direct space |
---|
| 232 | // For all components: global TGTID = global SRCID = cluster_index |
---|
| 233 | //////////////////////////////////////////////////////////////////// |
---|
| 234 | |
---|
| 235 | #define MEMC_TGTID 0 |
---|
| 236 | #define XICU_TGTID 1 |
---|
| 237 | #define MDMA_TGTID 2 |
---|
| 238 | #define MTTY_TGTID 3 |
---|
[663] | 239 | #define BDEV_TGTID 4 |
---|
| 240 | #define MNIC_TGTID 5 |
---|
| 241 | #define BROM_TGTID 6 |
---|
| 242 | #define CDMA_TGTID 7 |
---|
| 243 | #define SIMH_TGTID 8 |
---|
| 244 | #define FBUF_TGTID 9 |
---|
[572] | 245 | |
---|
| 246 | |
---|
[344] | 247 | ///////////////////////////////////////////////////////// |
---|
| 248 | // Physical segments definition |
---|
| 249 | ///////////////////////////////////////////////////////// |
---|
| 250 | // There is 3 segments replicated in all clusters |
---|
| 251 | // and 5 specific segments in the "IO" cluster |
---|
| 252 | // (containing address 0xBF000000) |
---|
| 253 | ///////////////////////////////////////////////////////// |
---|
| 254 | |
---|
[547] | 255 | #ifdef USE_GIET |
---|
| 256 | // specific segments in "IO" cluster : absolute physical address |
---|
| 257 | #define BROM_BASE 0x00BFC00000 |
---|
| 258 | #define BROM_SIZE 0x0000100000 // 1 Mbytes |
---|
[344] | 259 | |
---|
[547] | 260 | #define FBUF_BASE 0x00B2000000 |
---|
| 261 | #define FBUF_SIZE (FBUF_X_SIZE * FBUF_Y_SIZE * 2) |
---|
[344] | 262 | |
---|
[547] | 263 | #define BDEV_BASE 0x00B3000000 |
---|
| 264 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
[344] | 265 | |
---|
[547] | 266 | #define MTTY_BASE 0x00B4000000 |
---|
| 267 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
[344] | 268 | |
---|
[547] | 269 | #define MNIC_BASE 0x00B5000000 |
---|
| 270 | #define MNIC_SIZE 0x0000080000 // 512 Kbytes (for 8 channels) |
---|
[344] | 271 | |
---|
[547] | 272 | #define CDMA_BASE 0x00B6000000 |
---|
| 273 | #define CDMA_SIZE 0x0000004000 * NB_CMA_CHANNELS |
---|
[344] | 274 | |
---|
[547] | 275 | // replicated segments : address is incremented by a cluster offset |
---|
| 276 | // offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
[475] | 277 | |
---|
[547] | 278 | #define MEMC_BASE 0x0000000000 |
---|
| 279 | #define MEMC_SIZE 0x0010000000 // 256 Mbytes per cluster |
---|
[344] | 280 | |
---|
[547] | 281 | #define XICU_BASE 0x00B0000000 |
---|
| 282 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
[344] | 283 | |
---|
[547] | 284 | #define MDMA_BASE 0x00B1000000 |
---|
| 285 | #define MDMA_SIZE 0x0000001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
| 286 | |
---|
| 287 | #define SIMH_BASE 0x00B7000000 |
---|
| 288 | #define SIMH_SIZE 0x0000001000 |
---|
[504] | 289 | #endif |
---|
[344] | 290 | |
---|
[504] | 291 | #ifdef USE_ALMOS |
---|
[572] | 292 | // 2^19 is the offset for the local id (8 bits for global ID : |
---|
| 293 | // 1 bit for Memcache or Peripheral, 4 for local peripheral id) |
---|
| 294 | // (Almos supports 32 bits physical addresses) |
---|
[547] | 295 | |
---|
[706] | 296 | #define CLUSTER_INC (0x80000000ULL / (X_SIZE * Y_SIZE) * 2) |
---|
[547] | 297 | |
---|
[706] | 298 | #define CLUSTER_IO_INC (cluster_io_id * CLUSTER_INC) |
---|
| 299 | #define MEMC_MAX_SIZE (0x40000000 / (X_SIZE * Y_SIZE)) // 0x40000000 : valeur totale souhaitée (ici : 1Go) |
---|
| 300 | |
---|
[547] | 301 | #define BROM_BASE 0x00BFC00000 |
---|
[706] | 302 | #define BROM_SIZE 0x0000100000 // 1 Mbytes |
---|
[547] | 303 | |
---|
[572] | 304 | #define MEMC_BASE 0x0000000000 |
---|
[663] | 305 | #define MEMC_SIZE min(0x04000000, MEMC_MAX_SIZE) |
---|
[572] | 306 | |
---|
[706] | 307 | #define XICU_BASE (CLUSTER_INC >> 1) + (XICU_TGTID << 19) |
---|
| 308 | #define XICU_SIZE 0x0000001000 // 4 Kbytes |
---|
[572] | 309 | |
---|
[706] | 310 | #define MDMA_BASE (CLUSTER_INC >> 1) + (MDMA_TGTID << 19) |
---|
| 311 | #define MDMA_SIZE (0x0000001000 * NB_DMA_CHANNELS) // 4 Kbytes per channel |
---|
[547] | 312 | |
---|
[706] | 313 | #define BDEV_BASE (CLUSTER_INC >> 1) + (BDEV_TGTID << 19) + (CLUSTER_IO_INC) |
---|
| 314 | #define BDEV_SIZE 0x0000001000 // 4 Kbytes |
---|
[663] | 315 | |
---|
[706] | 316 | #define MTTY_BASE (CLUSTER_INC >> 1) + (MTTY_TGTID << 19) + (CLUSTER_IO_INC) |
---|
| 317 | #define MTTY_SIZE 0x0000001000 // 4 Kbytes |
---|
[663] | 318 | |
---|
[706] | 319 | #define FBUF_BASE (CLUSTER_INC >> 1) + (FBUF_TGTID << 19) + (CLUSTER_IO_INC) |
---|
[547] | 320 | #define FBUF_SIZE (FBUF_X_SIZE * FBUF_Y_SIZE * 2) // Should be 0x80000 |
---|
[663] | 321 | |
---|
[706] | 322 | #define MNIC_BASE (CLUSTER_INC >> 1) + (MNIC_TGTID << 19) + (CLUSTER_IO_INC) |
---|
[572] | 323 | #define MNIC_SIZE 0x0000080000 |
---|
[663] | 324 | |
---|
[706] | 325 | #define CDMA_BASE (CLUSTER_INC >> 1) + (CDMA_TGTID << 19) + (CLUSTER_IO_INC) |
---|
[572] | 326 | #define CDMA_SIZE (0x0000004000 * NB_CMA_CHANNELS) |
---|
[663] | 327 | |
---|
[706] | 328 | #define SIMH_BASE (CLUSTER_INC >> 1) + (SIMH_TGTID << 19) + (CLUSTER_IO_INC) |
---|
[572] | 329 | #define SIMH_SIZE 0x0000001000 |
---|
[504] | 330 | #endif |
---|
[344] | 331 | |
---|
[504] | 332 | bool stop_called = false; |
---|
| 333 | |
---|
[344] | 334 | ///////////////////////////////// |
---|
| 335 | int _main(int argc, char *argv[]) |
---|
| 336 | { |
---|
| 337 | using namespace sc_core; |
---|
| 338 | using namespace soclib::caba; |
---|
| 339 | using namespace soclib::common; |
---|
| 340 | |
---|
[464] | 341 | #ifdef USE_GIET |
---|
[663] | 342 | char soft_name[256] = soft_pathname; // pathname to binary code |
---|
[464] | 343 | #endif |
---|
[663] | 344 | const int64_t max_cycles = 5000000; // Maximum number of cycles simulated in one sc_start call |
---|
| 345 | int64_t ncycles = 0x7FFFFFFFFFFFFFFF; // simulated cycles |
---|
| 346 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
| 347 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
| 348 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
| 349 | ssize_t threads_nr = 1; // simulator's threads number |
---|
| 350 | bool debug_ok = false; // trace activated |
---|
| 351 | size_t debug_period = 1; // trace period |
---|
| 352 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
| 353 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
| 354 | int64_t debug_from = 0; // trace start cycle |
---|
| 355 | int64_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
[504] | 356 | size_t cluster_io_id; // index of cluster containing IOs |
---|
[663] | 357 | int64_t reset_counters = -1; |
---|
| 358 | int64_t dump_counters = -1; |
---|
| 359 | bool do_reset_counters = false; |
---|
| 360 | bool do_dump_counters = false; |
---|
| 361 | struct timeval t1, t2; |
---|
| 362 | uint64_t ms1, ms2; |
---|
[344] | 363 | |
---|
| 364 | ////////////// command line arguments ////////////////////// |
---|
| 365 | if (argc > 1) |
---|
| 366 | { |
---|
| 367 | for (int n = 1; n < argc; n = n + 2) |
---|
| 368 | { |
---|
[504] | 369 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) |
---|
[344] | 370 | { |
---|
[663] | 371 | ncycles = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 372 | } |
---|
[504] | 373 | else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) |
---|
[344] | 374 | { |
---|
[464] | 375 | #ifdef USE_ALMOS |
---|
| 376 | assert( 0 && "Can't define almos soft name" ); |
---|
| 377 | #endif |
---|
| 378 | #ifdef USE_GIET |
---|
[504] | 379 | strcpy(soft_name, argv[n + 1]); |
---|
[464] | 380 | #endif |
---|
[344] | 381 | } |
---|
[504] | 382 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) |
---|
[344] | 383 | { |
---|
[504] | 384 | strcpy(disk_name, argv[n + 1]); |
---|
[344] | 385 | } |
---|
[504] | 386 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) |
---|
[344] | 387 | { |
---|
| 388 | debug_ok = true; |
---|
[663] | 389 | debug_from = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 390 | } |
---|
[504] | 391 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) |
---|
[344] | 392 | { |
---|
[619] | 393 | debug_memc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
| 394 | #ifdef USE_ALMOS |
---|
[663] | 395 | assert((debug_memc_id < (X_SIZE * Y_SIZE)) && |
---|
| 396 | "debug_memc_id larger than X_SIZE * Y_SIZE" ); |
---|
[619] | 397 | #else |
---|
| 398 | size_t x = debug_memc_id >> Y_WIDTH; |
---|
[836] | 399 | size_t y = debug_memc_id & ((1 << Y_WIDTH) - 1); |
---|
[619] | 400 | |
---|
[663] | 401 | assert( (x <= X_SIZE) and (y <= Y_SIZE) && |
---|
[619] | 402 | "MEMCID parameter refers a not valid memory cache"); |
---|
| 403 | #endif |
---|
[344] | 404 | } |
---|
[504] | 405 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) |
---|
[344] | 406 | { |
---|
[619] | 407 | debug_proc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
| 408 | #ifdef USE_ALMOS |
---|
[663] | 409 | assert((debug_proc_id < (X_SIZE * Y_SIZE * NB_PROCS_MAX)) && |
---|
| 410 | "debug_proc_id larger than X_SIZE * Y_SIZE * NB_PROCS"); |
---|
[619] | 411 | #else |
---|
| 412 | size_t cluster_xy = debug_proc_id / NB_PROCS_MAX ; |
---|
[836] | 413 | size_t x = cluster_xy >> Y_WIDTH; |
---|
| 414 | size_t y = cluster_xy & ((1 << Y_WIDTH) - 1); |
---|
[619] | 415 | |
---|
[663] | 416 | assert( (x <= X_SIZE) and (y <= Y_SIZE) && |
---|
[619] | 417 | "PROCID parameter refers a not valid processor"); |
---|
| 418 | #endif |
---|
[344] | 419 | } |
---|
[504] | 420 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) |
---|
[344] | 421 | { |
---|
[619] | 422 | threads_nr = (ssize_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 423 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
| 424 | } |
---|
[504] | 425 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) |
---|
[344] | 426 | { |
---|
[663] | 427 | frozen_cycles = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 428 | } |
---|
[504] | 429 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) |
---|
[344] | 430 | { |
---|
[619] | 431 | debug_period = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
[344] | 432 | } |
---|
[663] | 433 | else if ((strcmp(argv[n], "--reset-counters") == 0) && (n + 1 < argc)) |
---|
| 434 | { |
---|
| 435 | reset_counters = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
| 436 | do_reset_counters = true; |
---|
| 437 | } |
---|
| 438 | else if ((strcmp(argv[n], "--dump-counters") == 0) && (n + 1 < argc)) |
---|
| 439 | { |
---|
| 440 | dump_counters = (int64_t) strtol(argv[n + 1], NULL, 0); |
---|
| 441 | do_dump_counters = true; |
---|
| 442 | } |
---|
[344] | 443 | else |
---|
| 444 | { |
---|
| 445 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
| 446 | std::cout << " The order is not important." << std::endl; |
---|
| 447 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
| 448 | std::cout << " -SOFT pathname_for_embedded_soft" << std::endl; |
---|
| 449 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
| 450 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
| 451 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
| 452 | std::cout << " -THREADS simulator's threads number" << std::endl; |
---|
| 453 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
| 454 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
| 455 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
| 456 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
| 457 | exit(0); |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | |
---|
[396] | 462 | // checking hardware parameters |
---|
[663] | 463 | assert( ( (X_SIZE == 1) or (X_SIZE == 2) or (X_SIZE == 4) or |
---|
| 464 | (X_SIZE == 8) or (X_SIZE == 16) ) and |
---|
| 465 | "The X_SIZE parameter must be 1, 2, 4, 8 or 16" ); |
---|
[344] | 466 | |
---|
[663] | 467 | assert( ( (Y_SIZE == 1) or (Y_SIZE == 2) or (Y_SIZE == 4) or |
---|
| 468 | (Y_SIZE == 8) or (Y_SIZE == 16) ) and |
---|
| 469 | "The Y_SIZE parameter must be 1, 2, 4, 8 or 16" ); |
---|
[344] | 470 | |
---|
[396] | 471 | assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or |
---|
| 472 | (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and |
---|
| 473 | "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" ); |
---|
[344] | 474 | |
---|
[396] | 475 | assert( (NB_DMA_CHANNELS < 9) and |
---|
| 476 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
[344] | 477 | |
---|
[396] | 478 | assert( (NB_TTY_CHANNELS < 15) and |
---|
| 479 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
[344] | 480 | |
---|
[396] | 481 | assert( (NB_NIC_CHANNELS < 9) and |
---|
| 482 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
[344] | 483 | |
---|
[464] | 484 | #ifdef USE_GIET |
---|
[438] | 485 | assert( (vci_address_width == 40) and |
---|
[504] | 486 | "VCI address width with the GIET must be 40 bits" ); |
---|
[464] | 487 | #endif |
---|
[344] | 488 | |
---|
[504] | 489 | #ifdef USE_ALMOS |
---|
| 490 | assert( (vci_address_width == 32) and |
---|
| 491 | "VCI address width with ALMOS must be 32 bits" ); |
---|
| 492 | #endif |
---|
| 493 | |
---|
| 494 | |
---|
[396] | 495 | std::cout << std::endl; |
---|
[663] | 496 | std::cout << " - X_SIZE = " << X_SIZE << std::endl; |
---|
| 497 | std::cout << " - Y_SIZE = " << Y_SIZE << std::endl; |
---|
[438] | 498 | std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl; |
---|
[396] | 499 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
[438] | 500 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
| 501 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
| 502 | std::cout << " - MEMC_WAYS = " << MEMC_WAYS << std::endl; |
---|
| 503 | std::cout << " - MEMC_SETS = " << MEMC_SETS << std::endl; |
---|
| 504 | std::cout << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl; |
---|
| 505 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
[396] | 506 | |
---|
| 507 | std::cout << std::endl; |
---|
| 508 | // Internal and External VCI parameters definition |
---|
[438] | 509 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
| 510 | vci_plen_width, |
---|
| 511 | vci_address_width, |
---|
| 512 | vci_rerror_width, |
---|
| 513 | vci_clen_width, |
---|
| 514 | vci_rflag_width, |
---|
| 515 | vci_srcid_width, |
---|
| 516 | vci_pktid_width, |
---|
| 517 | vci_trdid_width, |
---|
| 518 | vci_wrplen_width> vci_param_int; |
---|
[396] | 519 | |
---|
[438] | 520 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
| 521 | vci_plen_width, |
---|
| 522 | vci_address_width, |
---|
| 523 | vci_rerror_width, |
---|
| 524 | vci_clen_width, |
---|
| 525 | vci_rflag_width, |
---|
| 526 | vci_srcid_width, |
---|
| 527 | vci_pktid_width, |
---|
| 528 | vci_trdid_width, |
---|
| 529 | vci_wrplen_width> vci_param_ext; |
---|
[396] | 530 | |
---|
[344] | 531 | #if USE_OPENMP |
---|
| 532 | omp_set_dynamic(false); |
---|
| 533 | omp_set_num_threads(threads_nr); |
---|
| 534 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
| 535 | #endif |
---|
| 536 | |
---|
[663] | 537 | // Define parameters depending on mesh size |
---|
| 538 | size_t x_width; |
---|
| 539 | size_t y_width; |
---|
| 540 | |
---|
[619] | 541 | #ifdef USE_ALMOS |
---|
[663] | 542 | if (X_SIZE == 1) x_width = 0; |
---|
| 543 | else if (X_SIZE == 2) x_width = 1; |
---|
| 544 | else if (X_SIZE <= 4) x_width = 2; |
---|
| 545 | else if (X_SIZE <= 8) x_width = 3; |
---|
[504] | 546 | else x_width = 4; |
---|
[344] | 547 | |
---|
[663] | 548 | if (Y_SIZE == 1) y_width = 0; |
---|
| 549 | else if (Y_SIZE == 2) y_width = 1; |
---|
| 550 | else if (Y_SIZE <= 4) y_width = 2; |
---|
| 551 | else if (Y_SIZE <= 8) y_width = 3; |
---|
[504] | 552 | else y_width = 4; |
---|
[344] | 553 | |
---|
[619] | 554 | #else |
---|
| 555 | size_t x_width = X_WIDTH; |
---|
| 556 | size_t y_width = Y_WIDTH; |
---|
| 557 | |
---|
| 558 | assert( (X_WIDTH <= 4) and (Y_WIDTH <= 4) and |
---|
| 559 | "Up to 256 clusters"); |
---|
| 560 | |
---|
[663] | 561 | assert( (X_SIZE <= (1 << X_WIDTH)) and (Y_SIZE <= (1 << Y_WIDTH)) and |
---|
[619] | 562 | "The X_WIDTH and Y_WIDTH parameter are insufficient"); |
---|
| 563 | |
---|
[504] | 564 | #endif |
---|
| 565 | |
---|
[619] | 566 | // index of cluster containing IOs |
---|
| 567 | cluster_io_id = 0x00bfc00000ULL >> (vci_address_width - x_width - y_width); |
---|
| 568 | |
---|
[663] | 569 | |
---|
[344] | 570 | ///////////////////// |
---|
| 571 | // Mapping Tables |
---|
| 572 | ///////////////////// |
---|
| 573 | |
---|
[396] | 574 | // internal network |
---|
[438] | 575 | MappingTable maptabd(vci_address_width, |
---|
[572] | 576 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
[438] | 577 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
[547] | 578 | 0x00FF800000); |
---|
[344] | 579 | |
---|
[663] | 580 | for (size_t x = 0; x < X_SIZE; x++) |
---|
[344] | 581 | { |
---|
[663] | 582 | for (size_t y = 0; y < Y_SIZE; y++) |
---|
[344] | 583 | { |
---|
[438] | 584 | sc_uint<vci_address_width> offset; |
---|
| 585 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
| 586 | << (vci_address_width-x_width-y_width); |
---|
[344] | 587 | |
---|
| 588 | std::ostringstream si; |
---|
[396] | 589 | si << "seg_xicu_" << x << "_" << y; |
---|
[547] | 590 | maptabd.add(Segment(si.str(), XICU_BASE + offset, XICU_SIZE, |
---|
| 591 | IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
[344] | 592 | |
---|
| 593 | std::ostringstream sd; |
---|
[396] | 594 | sd << "seg_mdma_" << x << "_" << y; |
---|
[547] | 595 | maptabd.add(Segment(sd.str(), MDMA_BASE + offset, MDMA_SIZE, |
---|
| 596 | IntTab(cluster(x,y),MDMA_TGTID), false)); |
---|
[344] | 597 | |
---|
[547] | 598 | std::ostringstream sh; |
---|
| 599 | sh << "seg_memc_" << x << "_" << y; |
---|
| 600 | maptabd.add(Segment(sh.str(), MEMC_BASE + offset, MEMC_SIZE, |
---|
| 601 | IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
| 602 | |
---|
[344] | 603 | if ( cluster(x,y) == cluster_io_id ) |
---|
| 604 | { |
---|
[396] | 605 | maptabd.add(Segment("seg_mtty", MTTY_BASE, MTTY_SIZE, |
---|
| 606 | IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
| 607 | maptabd.add(Segment("seg_fbuf", FBUF_BASE, FBUF_SIZE, |
---|
| 608 | IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
| 609 | maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, |
---|
| 610 | IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
[547] | 611 | maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, |
---|
| 612 | IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
[396] | 613 | maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, |
---|
| 614 | IntTab(cluster(x,y),MNIC_TGTID), false)); |
---|
[493] | 615 | maptabd.add(Segment("seg_cdma", CDMA_BASE, CDMA_SIZE, |
---|
| 616 | IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
[547] | 617 | maptabd.add(Segment("seg_simh", SIMH_BASE, SIMH_SIZE, |
---|
| 618 | IntTab(cluster(x,y),SIMH_TGTID), false)); |
---|
[344] | 619 | } |
---|
| 620 | } |
---|
| 621 | } |
---|
| 622 | std::cout << maptabd << std::endl; |
---|
| 623 | |
---|
| 624 | // external network |
---|
[438] | 625 | MappingTable maptabx(vci_address_width, |
---|
[396] | 626 | IntTab(x_width+y_width), |
---|
| 627 | IntTab(x_width+y_width), |
---|
| 628 | 0xFFFF000000ULL); |
---|
[344] | 629 | |
---|
[663] | 630 | for (size_t x = 0; x < X_SIZE; x++) |
---|
[344] | 631 | { |
---|
[663] | 632 | for (size_t y = 0; y < Y_SIZE ; y++) |
---|
[752] | 633 | { |
---|
[396] | 634 | |
---|
[438] | 635 | sc_uint<vci_address_width> offset; |
---|
| 636 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
[836] | 637 | << (vci_address_width - x_width - y_width); |
---|
[396] | 638 | |
---|
[344] | 639 | std::ostringstream sh; |
---|
| 640 | sh << "x_seg_memc_" << x << "_" << y; |
---|
[396] | 641 | |
---|
[547] | 642 | maptabx.add(Segment(sh.str(), MEMC_BASE + offset, |
---|
[344] | 643 | MEMC_SIZE, IntTab(cluster(x,y)), false)); |
---|
| 644 | } |
---|
| 645 | } |
---|
| 646 | std::cout << maptabx << std::endl; |
---|
| 647 | |
---|
| 648 | //////////////////// |
---|
| 649 | // Signals |
---|
| 650 | /////////////////// |
---|
| 651 | |
---|
[389] | 652 | sc_clock signal_clk("clk"); |
---|
[344] | 653 | sc_signal<bool> signal_resetn("resetn"); |
---|
| 654 | |
---|
| 655 | // Horizontal inter-clusters DSPIN signals |
---|
[885] | 656 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cmd_inc = |
---|
| 657 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", X_SIZE-1, Y_SIZE); |
---|
| 658 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cmd_dec = |
---|
| 659 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", X_SIZE-1, Y_SIZE); |
---|
[344] | 660 | |
---|
[885] | 661 | DspinSignals<dspin_rsp_width>** signal_dspin_h_rsp_inc = |
---|
| 662 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", X_SIZE-1, Y_SIZE); |
---|
| 663 | DspinSignals<dspin_rsp_width>** signal_dspin_h_rsp_dec = |
---|
| 664 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", X_SIZE-1, Y_SIZE); |
---|
| 665 | |
---|
| 666 | DspinSignals<dspin_cmd_width>** signal_dspin_h_m2p_inc = |
---|
| 667 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_inc", X_SIZE-1, Y_SIZE); |
---|
| 668 | DspinSignals<dspin_cmd_width>** signal_dspin_h_m2p_dec = |
---|
| 669 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_dec", X_SIZE-1, Y_SIZE); |
---|
| 670 | |
---|
| 671 | DspinSignals<dspin_rsp_width>** signal_dspin_h_p2m_inc = |
---|
| 672 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_inc", X_SIZE-1, Y_SIZE); |
---|
| 673 | DspinSignals<dspin_rsp_width>** signal_dspin_h_p2m_dec = |
---|
| 674 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_dec", X_SIZE-1, Y_SIZE); |
---|
| 675 | |
---|
| 676 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cla_inc = |
---|
| 677 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_inc", X_SIZE-1, Y_SIZE); |
---|
| 678 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cla_dec = |
---|
| 679 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_dec", X_SIZE-1, Y_SIZE); |
---|
| 680 | |
---|
[344] | 681 | // Vertical inter-clusters DSPIN signals |
---|
[885] | 682 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cmd_inc = |
---|
| 683 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", X_SIZE, Y_SIZE-1); |
---|
| 684 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cmd_dec = |
---|
| 685 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", X_SIZE, Y_SIZE-1); |
---|
[344] | 686 | |
---|
[885] | 687 | DspinSignals<dspin_rsp_width>** signal_dspin_v_rsp_inc = |
---|
| 688 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", X_SIZE, Y_SIZE-1); |
---|
| 689 | DspinSignals<dspin_rsp_width>** signal_dspin_v_rsp_dec = |
---|
| 690 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", X_SIZE, Y_SIZE-1); |
---|
[344] | 691 | |
---|
[885] | 692 | DspinSignals<dspin_cmd_width>** signal_dspin_v_m2p_inc = |
---|
| 693 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_m2p_inc", X_SIZE, Y_SIZE-1); |
---|
| 694 | DspinSignals<dspin_cmd_width>** signal_dspin_v_m2p_dec = |
---|
| 695 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_m2p_dec", X_SIZE, Y_SIZE-1); |
---|
| 696 | |
---|
| 697 | DspinSignals<dspin_rsp_width>** signal_dspin_v_p2m_inc = |
---|
| 698 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_p2m_inc", X_SIZE, Y_SIZE-1); |
---|
| 699 | DspinSignals<dspin_rsp_width>** signal_dspin_v_p2m_dec = |
---|
| 700 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_p2m_dec", X_SIZE, Y_SIZE-1); |
---|
| 701 | |
---|
| 702 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cla_inc = |
---|
| 703 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cla_inc", X_SIZE, Y_SIZE-1); |
---|
| 704 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cla_dec = |
---|
| 705 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cla_dec", X_SIZE, Y_SIZE-1); |
---|
| 706 | |
---|
| 707 | // Mesh boundaries DSPIN signals (Most of those signals are not used...) |
---|
| 708 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cmd_in = |
---|
| 709 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cmd_in" , X_SIZE, Y_SIZE, 4); |
---|
| 710 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cmd_out = |
---|
| 711 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cmd_out", X_SIZE, Y_SIZE, 4); |
---|
| 712 | |
---|
| 713 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_rsp_in = |
---|
| 714 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_rsp_in" , X_SIZE, Y_SIZE, 4); |
---|
| 715 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_rsp_out = |
---|
| 716 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_rsp_out", X_SIZE, Y_SIZE, 4); |
---|
| 717 | |
---|
| 718 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_m2p_in = |
---|
| 719 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_m2p_in" , X_SIZE, Y_SIZE, 4); |
---|
| 720 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_m2p_out = |
---|
| 721 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_m2p_out", X_SIZE, Y_SIZE, 4); |
---|
| 722 | |
---|
| 723 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_p2m_in = |
---|
| 724 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_p2m_in" , X_SIZE, Y_SIZE, 4); |
---|
| 725 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_p2m_out = |
---|
| 726 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_p2m_out", X_SIZE, Y_SIZE, 4); |
---|
| 727 | |
---|
| 728 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cla_in = |
---|
| 729 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cla_in" , X_SIZE, Y_SIZE, 4); |
---|
| 730 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cla_out = |
---|
| 731 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cla_out", X_SIZE, Y_SIZE, 4); |
---|
| 732 | |
---|
| 733 | |
---|
[344] | 734 | //////////////////////////// |
---|
| 735 | // Loader |
---|
| 736 | //////////////////////////// |
---|
| 737 | |
---|
| 738 | soclib::common::Loader loader(soft_name); |
---|
| 739 | |
---|
| 740 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
| 741 | proc_iss::set_loader(loader); |
---|
| 742 | |
---|
| 743 | //////////////////////////// |
---|
| 744 | // Clusters construction |
---|
| 745 | //////////////////////////// |
---|
| 746 | |
---|
[396] | 747 | TsarXbarCluster<dspin_cmd_width, |
---|
| 748 | dspin_rsp_width, |
---|
| 749 | vci_param_int, |
---|
[836] | 750 | vci_param_ext> * clusters[X_SIZE][Y_SIZE]; |
---|
[344] | 751 | |
---|
| 752 | #if USE_OPENMP |
---|
| 753 | #pragma omp parallel |
---|
| 754 | { |
---|
| 755 | #pragma omp for |
---|
| 756 | #endif |
---|
[663] | 757 | for (size_t i = 0; i < (X_SIZE * Y_SIZE); i++) |
---|
[344] | 758 | { |
---|
[663] | 759 | size_t x = i / Y_SIZE; |
---|
| 760 | size_t y = i % Y_SIZE; |
---|
[344] | 761 | |
---|
| 762 | #if USE_OPENMP |
---|
| 763 | #pragma omp critical |
---|
| 764 | { |
---|
| 765 | #endif |
---|
[438] | 766 | std::cout << std::endl; |
---|
| 767 | std::cout << "Cluster_" << x << "_" << y << std::endl; |
---|
| 768 | std::cout << std::endl; |
---|
[389] | 769 | |
---|
[344] | 770 | std::ostringstream sc; |
---|
| 771 | sc << "cluster_" << x << "_" << y; |
---|
[396] | 772 | clusters[x][y] = new TsarXbarCluster<dspin_cmd_width, |
---|
| 773 | dspin_rsp_width, |
---|
| 774 | vci_param_int, |
---|
| 775 | vci_param_ext> |
---|
[344] | 776 | ( |
---|
| 777 | sc.str().c_str(), |
---|
[396] | 778 | NB_PROCS_MAX, |
---|
[752] | 779 | NB_TTY_CHANNELS, |
---|
| 780 | NB_DMA_CHANNELS, |
---|
[396] | 781 | x, |
---|
| 782 | y, |
---|
| 783 | cluster(x,y), |
---|
| 784 | maptabd, |
---|
| 785 | maptabx, |
---|
| 786 | x_width, |
---|
| 787 | y_width, |
---|
[438] | 788 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
[396] | 789 | MEMC_TGTID, |
---|
| 790 | XICU_TGTID, |
---|
| 791 | MDMA_TGTID, |
---|
| 792 | FBUF_TGTID, |
---|
| 793 | MTTY_TGTID, |
---|
| 794 | BROM_TGTID, |
---|
| 795 | MNIC_TGTID, |
---|
[493] | 796 | CDMA_TGTID, |
---|
[396] | 797 | BDEV_TGTID, |
---|
[547] | 798 | SIMH_TGTID, |
---|
[396] | 799 | MEMC_WAYS, |
---|
| 800 | MEMC_SETS, |
---|
| 801 | L1_IWAYS, |
---|
| 802 | L1_ISETS, |
---|
| 803 | L1_DWAYS, |
---|
| 804 | L1_DSETS, |
---|
[706] | 805 | IRQ_PER_PROCESSOR, |
---|
[396] | 806 | XRAM_LATENCY, |
---|
| 807 | (cluster(x,y) == cluster_io_id), |
---|
| 808 | FBUF_X_SIZE, |
---|
| 809 | FBUF_Y_SIZE, |
---|
| 810 | disk_name, |
---|
| 811 | BDEV_SECTOR_SIZE, |
---|
| 812 | NB_NIC_CHANNELS, |
---|
| 813 | nic_rx_name, |
---|
| 814 | nic_tx_name, |
---|
| 815 | NIC_TIMEOUT, |
---|
[485] | 816 | NB_CMA_CHANNELS, |
---|
[396] | 817 | loader, |
---|
[344] | 818 | frozen_cycles, |
---|
[663] | 819 | debug_from, |
---|
[836] | 820 | debug_ok, |
---|
| 821 | debug_ok |
---|
[344] | 822 | ); |
---|
| 823 | |
---|
| 824 | #if USE_OPENMP |
---|
| 825 | } // end critical |
---|
| 826 | #endif |
---|
| 827 | } // end for |
---|
| 828 | #if USE_OPENMP |
---|
| 829 | } |
---|
| 830 | #endif |
---|
| 831 | |
---|
| 832 | /////////////////////////////////////////////////////////////// |
---|
| 833 | // Net-list |
---|
| 834 | /////////////////////////////////////////////////////////////// |
---|
| 835 | |
---|
| 836 | // Clock & RESET |
---|
[663] | 837 | for (size_t x = 0; x < (X_SIZE); x++){ |
---|
| 838 | for (size_t y = 0; y < Y_SIZE; y++){ |
---|
[389] | 839 | clusters[x][y]->p_clk (signal_clk); |
---|
| 840 | clusters[x][y]->p_resetn (signal_resetn); |
---|
[344] | 841 | } |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | // Inter Clusters horizontal connections |
---|
[885] | 845 | if (X_SIZE > 1) { |
---|
| 846 | for (size_t x = 0; x < (X_SIZE-1); x++) { |
---|
| 847 | for (size_t y = 0; y < (Y_SIZE); y++) { |
---|
| 848 | clusters[x][y]->p_cmd_out[EAST] (signal_dspin_h_cmd_inc[x][y]); |
---|
| 849 | clusters[x+1][y]->p_cmd_in[WEST] (signal_dspin_h_cmd_inc[x][y]); |
---|
| 850 | clusters[x][y]->p_cmd_in[EAST] (signal_dspin_h_cmd_dec[x][y]); |
---|
| 851 | clusters[x+1][y]->p_cmd_out[WEST] (signal_dspin_h_cmd_dec[x][y]); |
---|
[468] | 852 | |
---|
[885] | 853 | clusters[x][y]->p_rsp_out[EAST] (signal_dspin_h_rsp_inc[x][y]); |
---|
| 854 | clusters[x+1][y]->p_rsp_in[WEST] (signal_dspin_h_rsp_inc[x][y]); |
---|
| 855 | clusters[x][y]->p_rsp_in[EAST] (signal_dspin_h_rsp_dec[x][y]); |
---|
| 856 | clusters[x+1][y]->p_rsp_out[WEST] (signal_dspin_h_rsp_dec[x][y]); |
---|
| 857 | |
---|
| 858 | clusters[x][y]->p_m2p_out[EAST] (signal_dspin_h_m2p_inc[x][y]); |
---|
| 859 | clusters[x+1][y]->p_m2p_in[WEST] (signal_dspin_h_m2p_inc[x][y]); |
---|
| 860 | clusters[x][y]->p_m2p_in[EAST] (signal_dspin_h_m2p_dec[x][y]); |
---|
| 861 | clusters[x+1][y]->p_m2p_out[WEST] (signal_dspin_h_m2p_dec[x][y]); |
---|
| 862 | |
---|
| 863 | clusters[x][y]->p_p2m_out[EAST] (signal_dspin_h_p2m_inc[x][y]); |
---|
| 864 | clusters[x+1][y]->p_p2m_in[WEST] (signal_dspin_h_p2m_inc[x][y]); |
---|
| 865 | clusters[x][y]->p_p2m_in[EAST] (signal_dspin_h_p2m_dec[x][y]); |
---|
| 866 | clusters[x+1][y]->p_p2m_out[WEST] (signal_dspin_h_p2m_dec[x][y]); |
---|
| 867 | |
---|
| 868 | clusters[x][y]->p_cla_out[EAST] (signal_dspin_h_cla_inc[x][y]); |
---|
| 869 | clusters[x+1][y]->p_cla_in[WEST] (signal_dspin_h_cla_inc[x][y]); |
---|
| 870 | clusters[x][y]->p_cla_in[EAST] (signal_dspin_h_cla_dec[x][y]); |
---|
| 871 | clusters[x+1][y]->p_cla_out[WEST] (signal_dspin_h_cla_dec[x][y]); |
---|
| 872 | } |
---|
| 873 | } |
---|
[344] | 874 | } |
---|
[885] | 875 | std::cout << std::endl << "Horizontal connections done" << std::endl; |
---|
[344] | 876 | |
---|
| 877 | // Inter Clusters vertical connections |
---|
[663] | 878 | if (Y_SIZE > 1) { |
---|
[885] | 879 | for (size_t y = 0; y < (Y_SIZE-1); y++) { |
---|
| 880 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 881 | clusters[x][y]->p_cmd_out[NORTH] (signal_dspin_v_cmd_inc[x][y]); |
---|
| 882 | clusters[x][y+1]->p_cmd_in[SOUTH] (signal_dspin_v_cmd_inc[x][y]); |
---|
| 883 | clusters[x][y]->p_cmd_in[NORTH] (signal_dspin_v_cmd_dec[x][y]); |
---|
| 884 | clusters[x][y+1]->p_cmd_out[SOUTH] (signal_dspin_v_cmd_dec[x][y]); |
---|
[468] | 885 | |
---|
[885] | 886 | clusters[x][y]->p_rsp_out[NORTH] (signal_dspin_v_rsp_inc[x][y]); |
---|
| 887 | clusters[x][y+1]->p_rsp_in[SOUTH] (signal_dspin_v_rsp_inc[x][y]); |
---|
| 888 | clusters[x][y]->p_rsp_in[NORTH] (signal_dspin_v_rsp_dec[x][y]); |
---|
| 889 | clusters[x][y+1]->p_rsp_out[SOUTH] (signal_dspin_v_rsp_dec[x][y]); |
---|
| 890 | |
---|
| 891 | clusters[x][y]->p_m2p_out[NORTH] (signal_dspin_v_m2p_inc[x][y]); |
---|
| 892 | clusters[x][y+1]->p_m2p_in[SOUTH] (signal_dspin_v_m2p_inc[x][y]); |
---|
| 893 | clusters[x][y]->p_m2p_in[NORTH] (signal_dspin_v_m2p_dec[x][y]); |
---|
| 894 | clusters[x][y+1]->p_m2p_out[SOUTH] (signal_dspin_v_m2p_dec[x][y]); |
---|
| 895 | |
---|
| 896 | clusters[x][y]->p_p2m_out[NORTH] (signal_dspin_v_p2m_inc[x][y]); |
---|
| 897 | clusters[x][y+1]->p_p2m_in[SOUTH] (signal_dspin_v_p2m_inc[x][y]); |
---|
| 898 | clusters[x][y]->p_p2m_in[NORTH] (signal_dspin_v_p2m_dec[x][y]); |
---|
| 899 | clusters[x][y+1]->p_p2m_out[SOUTH] (signal_dspin_v_p2m_dec[x][y]); |
---|
| 900 | |
---|
| 901 | clusters[x][y]->p_cla_out[NORTH] (signal_dspin_v_cla_inc[x][y]); |
---|
| 902 | clusters[x][y+1]->p_cla_in[SOUTH] (signal_dspin_v_cla_inc[x][y]); |
---|
| 903 | clusters[x][y]->p_cla_in[NORTH] (signal_dspin_v_cla_dec[x][y]); |
---|
| 904 | clusters[x][y+1]->p_cla_out[SOUTH] (signal_dspin_v_cla_dec[x][y]); |
---|
| 905 | } |
---|
| 906 | } |
---|
[344] | 907 | } |
---|
[885] | 908 | std::cout << std::endl << "Vertical connections done" << std::endl; |
---|
[344] | 909 | |
---|
| 910 | // East & West boundary cluster connections |
---|
[885] | 911 | for (size_t y = 0; y < (Y_SIZE); y++) { |
---|
| 912 | clusters[0][y]->p_cmd_in[WEST] (signal_dspin_bound_cmd_in[0][y][WEST]); |
---|
| 913 | clusters[0][y]->p_cmd_out[WEST] (signal_dspin_bound_cmd_out[0][y][WEST]); |
---|
| 914 | clusters[X_SIZE-1][y]->p_cmd_in[EAST] (signal_dspin_bound_cmd_in[X_SIZE-1][y][EAST]); |
---|
| 915 | clusters[X_SIZE-1][y]->p_cmd_out[EAST] (signal_dspin_bound_cmd_out[X_SIZE-1][y][EAST]); |
---|
[468] | 916 | |
---|
[885] | 917 | clusters[0][y]->p_rsp_in[WEST] (signal_dspin_bound_rsp_in[0][y][WEST]); |
---|
| 918 | clusters[0][y]->p_rsp_out[WEST] (signal_dspin_bound_rsp_out[0][y][WEST]); |
---|
| 919 | clusters[X_SIZE-1][y]->p_rsp_in[EAST] (signal_dspin_bound_rsp_in[X_SIZE-1][y][EAST]); |
---|
| 920 | clusters[X_SIZE-1][y]->p_rsp_out[EAST] (signal_dspin_bound_rsp_out[X_SIZE-1][y][EAST]); |
---|
| 921 | |
---|
| 922 | clusters[0][y]->p_m2p_in[WEST] (signal_dspin_bound_m2p_in[0][y][WEST]); |
---|
| 923 | clusters[0][y]->p_m2p_out[WEST] (signal_dspin_bound_m2p_out[0][y][WEST]); |
---|
| 924 | clusters[X_SIZE-1][y]->p_m2p_in[EAST] (signal_dspin_bound_m2p_in[X_SIZE-1][y][EAST]); |
---|
| 925 | clusters[X_SIZE-1][y]->p_m2p_out[EAST] (signal_dspin_bound_m2p_out[X_SIZE-1][y][EAST]); |
---|
| 926 | |
---|
| 927 | clusters[0][y]->p_p2m_in[WEST] (signal_dspin_bound_p2m_in[0][y][WEST]); |
---|
| 928 | clusters[0][y]->p_p2m_out[WEST] (signal_dspin_bound_p2m_out[0][y][WEST]); |
---|
| 929 | clusters[X_SIZE-1][y]->p_p2m_in[EAST] (signal_dspin_bound_p2m_in[X_SIZE-1][y][EAST]); |
---|
| 930 | clusters[X_SIZE-1][y]->p_p2m_out[EAST] (signal_dspin_bound_p2m_out[X_SIZE-1][y][EAST]); |
---|
| 931 | |
---|
| 932 | clusters[0][y]->p_cla_in[WEST] (signal_dspin_bound_cla_in[0][y][WEST]); |
---|
| 933 | clusters[0][y]->p_cla_out[WEST] (signal_dspin_bound_cla_out[0][y][WEST]); |
---|
| 934 | clusters[X_SIZE-1][y]->p_cla_in[EAST] (signal_dspin_bound_cla_in[X_SIZE-1][y][EAST]); |
---|
| 935 | clusters[X_SIZE-1][y]->p_cla_out[EAST] (signal_dspin_bound_cla_out[X_SIZE-1][y][EAST]); |
---|
[344] | 936 | } |
---|
| 937 | |
---|
[885] | 938 | std::cout << std::endl << "West & East boundaries connections done" << std::endl; |
---|
| 939 | |
---|
[344] | 940 | // North & South boundary clusters connections |
---|
[885] | 941 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 942 | clusters[x][0]->p_cmd_in[SOUTH] (signal_dspin_bound_cmd_in[x][0][SOUTH]); |
---|
| 943 | clusters[x][0]->p_cmd_out[SOUTH] (signal_dspin_bound_cmd_out[x][0][SOUTH]); |
---|
| 944 | clusters[x][Y_SIZE-1]->p_cmd_in[NORTH] (signal_dspin_bound_cmd_in[x][Y_SIZE-1][NORTH]); |
---|
| 945 | clusters[x][Y_SIZE-1]->p_cmd_out[NORTH] (signal_dspin_bound_cmd_out[x][Y_SIZE-1][NORTH]); |
---|
[468] | 946 | |
---|
[885] | 947 | clusters[x][0]->p_rsp_in[SOUTH] (signal_dspin_bound_rsp_in[x][0][SOUTH]); |
---|
| 948 | clusters[x][0]->p_rsp_out[SOUTH] (signal_dspin_bound_rsp_out[x][0][SOUTH]); |
---|
| 949 | clusters[x][Y_SIZE-1]->p_rsp_in[NORTH] (signal_dspin_bound_rsp_in[x][Y_SIZE-1][NORTH]); |
---|
| 950 | clusters[x][Y_SIZE-1]->p_rsp_out[NORTH] (signal_dspin_bound_rsp_out[x][Y_SIZE-1][NORTH]); |
---|
| 951 | |
---|
| 952 | clusters[x][0]->p_m2p_in[SOUTH] (signal_dspin_bound_m2p_in[x][0][SOUTH]); |
---|
| 953 | clusters[x][0]->p_m2p_out[SOUTH] (signal_dspin_bound_m2p_out[x][0][SOUTH]); |
---|
| 954 | clusters[x][Y_SIZE-1]->p_m2p_in[NORTH] (signal_dspin_bound_m2p_in[x][Y_SIZE-1][NORTH]); |
---|
| 955 | clusters[x][Y_SIZE-1]->p_m2p_out[NORTH] (signal_dspin_bound_m2p_out[x][Y_SIZE-1][NORTH]); |
---|
| 956 | |
---|
| 957 | clusters[x][0]->p_p2m_in[SOUTH] (signal_dspin_bound_p2m_in[x][0][SOUTH]); |
---|
| 958 | clusters[x][0]->p_p2m_out[SOUTH] (signal_dspin_bound_p2m_out[x][0][SOUTH]); |
---|
| 959 | clusters[x][Y_SIZE-1]->p_p2m_in[NORTH] (signal_dspin_bound_p2m_in[x][Y_SIZE-1][NORTH]); |
---|
| 960 | clusters[x][Y_SIZE-1]->p_p2m_out[NORTH] (signal_dspin_bound_p2m_out[x][Y_SIZE-1][NORTH]); |
---|
| 961 | |
---|
| 962 | clusters[x][0]->p_cla_in[SOUTH] (signal_dspin_bound_cla_in[x][0][SOUTH]); |
---|
| 963 | clusters[x][0]->p_cla_out[SOUTH] (signal_dspin_bound_cla_out[x][0][SOUTH]); |
---|
| 964 | clusters[x][Y_SIZE-1]->p_cla_in[NORTH] (signal_dspin_bound_cla_in[x][Y_SIZE-1][NORTH]); |
---|
| 965 | clusters[x][Y_SIZE-1]->p_cla_out[NORTH] (signal_dspin_bound_cla_out[x][Y_SIZE-1][NORTH]); |
---|
[344] | 966 | } |
---|
[885] | 967 | |
---|
| 968 | std::cout << std::endl << "North & South boundaries connections done" << std::endl; |
---|
[396] | 969 | std::cout << std::endl; |
---|
[344] | 970 | |
---|
| 971 | |
---|
[836] | 972 | #ifdef WT_IDL |
---|
| 973 | std::list<VciCcVCacheWrapper<vci_param_int, |
---|
| 974 | dspin_cmd_width, |
---|
| 975 | dspin_rsp_width, |
---|
| 976 | GdbServer<Mips32ElIss> > * > l1_caches; |
---|
| 977 | |
---|
| 978 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 979 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 980 | for (int proc = 0; proc < NB_PROCS_MAX; proc++) { |
---|
| 981 | l1_caches.push_back(clusters[x][y]->proc[proc]); |
---|
| 982 | } |
---|
| 983 | } |
---|
| 984 | } |
---|
| 985 | |
---|
| 986 | for (size_t x = 0; x < X_SIZE; x++) { |
---|
| 987 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 988 | clusters[x][y]->memc->set_vcache_list(l1_caches); |
---|
| 989 | } |
---|
| 990 | } |
---|
| 991 | #endif |
---|
| 992 | |
---|
| 993 | |
---|
[779] | 994 | //#define SC_TRACE |
---|
[752] | 995 | #ifdef SC_TRACE |
---|
| 996 | sc_trace_file * tf = sc_create_vcd_trace_file("my_trace_file"); |
---|
| 997 | |
---|
| 998 | if (X_SIZE > 1){ |
---|
| 999 | for (size_t x = 0; x < (X_SIZE-1); x++){ |
---|
| 1000 | for (size_t y = 0; y < Y_SIZE; y++){ |
---|
| 1001 | for (size_t k = 0; k < 3; k++){ |
---|
| 1002 | signal_dspin_h_cmd_inc[x][y][k].trace(tf, "dspin_h_cmd_inc"); |
---|
| 1003 | signal_dspin_h_cmd_dec[x][y][k].trace(tf, "dspin_h_cmd_dec"); |
---|
| 1004 | } |
---|
| 1005 | |
---|
| 1006 | for (size_t k = 0; k < 2; k++){ |
---|
| 1007 | signal_dspin_h_rsp_inc[x][y][k].trace(tf, "dspin_h_rsp_inc"); |
---|
| 1008 | signal_dspin_h_rsp_dec[x][y][k].trace(tf, "dspin_h_rsp_dec"); |
---|
| 1009 | } |
---|
| 1010 | } |
---|
| 1011 | } |
---|
| 1012 | } |
---|
| 1013 | |
---|
| 1014 | if (Y_SIZE > 1) { |
---|
| 1015 | for (size_t y = 0; y < (Y_SIZE-1); y++){ |
---|
| 1016 | for (size_t x = 0; x < X_SIZE; x++){ |
---|
| 1017 | for (size_t k = 0; k < 3; k++){ |
---|
| 1018 | signal_dspin_v_cmd_inc[x][y][k].trace(tf, "dspin_v_cmd_inc"); |
---|
| 1019 | signal_dspin_v_cmd_dec[x][y][k].trace(tf, "dspin_v_cmd_dec"); |
---|
| 1020 | } |
---|
| 1021 | |
---|
| 1022 | for (size_t k = 0; k < 2; k++){ |
---|
| 1023 | signal_dspin_v_rsp_inc[x][y][k].trace(tf, "dspin_v_rsp_inc"); |
---|
| 1024 | signal_dspin_v_rsp_dec[x][y][k].trace(tf, "dspin_v_rsp_dec"); |
---|
| 1025 | } |
---|
| 1026 | } |
---|
| 1027 | } |
---|
| 1028 | } |
---|
| 1029 | |
---|
| 1030 | for (size_t x = 0; x < (X_SIZE); x++){ |
---|
| 1031 | for (size_t y = 0; y < Y_SIZE; y++){ |
---|
| 1032 | std::ostringstream signame; |
---|
| 1033 | signame << "cluster" << x << "_" << y; |
---|
| 1034 | clusters[x][y]->trace(tf, signame.str()); |
---|
| 1035 | } |
---|
| 1036 | } |
---|
| 1037 | #endif |
---|
| 1038 | |
---|
[779] | 1039 | |
---|
| 1040 | //////////////////////////////////////////////////////// |
---|
| 1041 | // Simulation |
---|
| 1042 | /////////////////////////////////////////////////////// |
---|
| 1043 | |
---|
| 1044 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
| 1045 | signal_resetn = false; |
---|
| 1046 | |
---|
[885] | 1047 | // set network boundaries signals default values |
---|
| 1048 | // for all boundary clusters |
---|
| 1049 | for (size_t x = 0; x < X_SIZE ; x++) { |
---|
| 1050 | for (size_t y = 0; y < Y_SIZE ; y++) { |
---|
| 1051 | for (size_t face = 0; face < 4; face++) { |
---|
| 1052 | signal_dspin_bound_cmd_in [x][y][face].write = false; |
---|
| 1053 | signal_dspin_bound_cmd_in [x][y][face].read = true; |
---|
| 1054 | signal_dspin_bound_cmd_out[x][y][face].write = false; |
---|
| 1055 | signal_dspin_bound_cmd_out[x][y][face].read = true; |
---|
| 1056 | |
---|
| 1057 | signal_dspin_bound_rsp_in [x][y][face].write = false; |
---|
| 1058 | signal_dspin_bound_rsp_in [x][y][face].read = true; |
---|
| 1059 | signal_dspin_bound_rsp_out[x][y][face].write = false; |
---|
| 1060 | signal_dspin_bound_rsp_out[x][y][face].read = true; |
---|
| 1061 | |
---|
| 1062 | signal_dspin_bound_m2p_in [x][y][face].write = false; |
---|
| 1063 | signal_dspin_bound_m2p_in [x][y][face].read = true; |
---|
| 1064 | signal_dspin_bound_m2p_out[x][y][face].write = false; |
---|
| 1065 | signal_dspin_bound_m2p_out[x][y][face].read = true; |
---|
| 1066 | |
---|
| 1067 | signal_dspin_bound_p2m_in [x][y][face].write = false; |
---|
| 1068 | signal_dspin_bound_p2m_in [x][y][face].read = true; |
---|
| 1069 | signal_dspin_bound_p2m_out[x][y][face].write = false; |
---|
| 1070 | signal_dspin_bound_p2m_out[x][y][face].read = true; |
---|
| 1071 | |
---|
| 1072 | signal_dspin_bound_cla_in [x][y][face].write = false; |
---|
| 1073 | signal_dspin_bound_cla_in [x][y][face].read = true; |
---|
| 1074 | signal_dspin_bound_cla_out[x][y][face].write = false; |
---|
| 1075 | signal_dspin_bound_cla_out[x][y][face].read = true; |
---|
| 1076 | } |
---|
| 1077 | } |
---|
[779] | 1078 | } |
---|
| 1079 | |
---|
| 1080 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 1081 | signal_resetn = true; |
---|
| 1082 | |
---|
[663] | 1083 | if (debug_ok) { |
---|
| 1084 | #if USE_OPENMP |
---|
| 1085 | assert(false && "OPEN MP should not be used with debug because of its traces"); |
---|
| 1086 | #endif |
---|
[464] | 1087 | |
---|
[663] | 1088 | if (gettimeofday(&t1, NULL) != 0) { |
---|
| 1089 | perror("gettimeofday"); |
---|
| 1090 | return EXIT_FAILURE; |
---|
| 1091 | } |
---|
[396] | 1092 | |
---|
[663] | 1093 | for (int64_t n = 1; n < ncycles && !stop_called; n++) |
---|
[464] | 1094 | { |
---|
[663] | 1095 | if ((n % max_cycles) == 0) |
---|
[464] | 1096 | { |
---|
[663] | 1097 | |
---|
[752] | 1098 | if (gettimeofday(&t2, NULL) != 0) |
---|
[663] | 1099 | { |
---|
| 1100 | perror("gettimeofday"); |
---|
| 1101 | return EXIT_FAILURE; |
---|
| 1102 | } |
---|
| 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; |
---|
| 1106 | std::cerr << "platform clock frequency " << (double) 5000000 / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
| 1107 | |
---|
[752] | 1108 | if (gettimeofday(&t1, NULL) != 0) |
---|
[663] | 1109 | { |
---|
| 1110 | perror("gettimeofday"); |
---|
| 1111 | return EXIT_FAILURE; |
---|
| 1112 | } |
---|
[464] | 1113 | } |
---|
| 1114 | |
---|
| 1115 | |
---|
[663] | 1116 | if (n == reset_counters) { |
---|
| 1117 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1118 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1119 | clusters[x][y]->memc->reset_counters(); |
---|
| 1120 | } |
---|
| 1121 | } |
---|
[464] | 1122 | } |
---|
| 1123 | |
---|
[663] | 1124 | if (n == dump_counters) { |
---|
| 1125 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1126 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1127 | clusters[x][y]->memc->print_stats(true, false); |
---|
| 1128 | } |
---|
| 1129 | } |
---|
| 1130 | } |
---|
[344] | 1131 | |
---|
[752] | 1132 | if ((n > debug_from) and (n % debug_period == 0)) |
---|
[663] | 1133 | { |
---|
| 1134 | std::cout << "****************** cycle " << std::dec << n ; |
---|
[836] | 1135 | std::cout << "************************************************" << std::endl; |
---|
[379] | 1136 | |
---|
[836] | 1137 | for (size_t x = 0; x < X_SIZE ; x++){ |
---|
| 1138 | for (size_t y = 0; y < Y_SIZE ; y++){ |
---|
| 1139 | for (int proc = 0; proc < NB_PROCS_MAX; proc++) { |
---|
[379] | 1140 | |
---|
[836] | 1141 | clusters[x][y]->proc[proc]->print_trace(); |
---|
| 1142 | std::ostringstream proc_signame; |
---|
| 1143 | proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << proc ; |
---|
| 1144 | std::ostringstream p2m_signame; |
---|
| 1145 | p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << proc << " P2M"; |
---|
| 1146 | std::ostringstream m2p_signame; |
---|
| 1147 | m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << proc << " M2P"; |
---|
[404] | 1148 | |
---|
[836] | 1149 | clusters[x][y]->signal_vci_ini_proc[proc].print_trace(proc_signame.str()); |
---|
| 1150 | clusters[x][y]->signal_dspin_p2m_proc[proc].print_trace(p2m_signame.str()); |
---|
| 1151 | clusters[x][y]->signal_dspin_m2p_proc[proc].print_trace(m2p_signame.str()); |
---|
| 1152 | } |
---|
[404] | 1153 | |
---|
[836] | 1154 | clusters[x][y]->memc->print_trace(); |
---|
[344] | 1155 | |
---|
[836] | 1156 | std::ostringstream smemc; |
---|
| 1157 | smemc << "[SIG]MEMC_" << x << "_" << y; |
---|
| 1158 | std::ostringstream sxram; |
---|
| 1159 | sxram << "[SIG]XRAM_" << x << "_" << y; |
---|
| 1160 | std::ostringstream sm2p; |
---|
| 1161 | sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P"; |
---|
| 1162 | std::ostringstream sp2m; |
---|
| 1163 | sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M"; |
---|
[344] | 1164 | |
---|
[836] | 1165 | clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str()); |
---|
| 1166 | clusters[x][y]->signal_vci_xram.print_trace(sxram.str()); |
---|
| 1167 | clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str()); |
---|
| 1168 | clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str()); |
---|
| 1169 | } |
---|
| 1170 | } |
---|
[663] | 1171 | } |
---|
| 1172 | |
---|
| 1173 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
[344] | 1174 | } |
---|
[663] | 1175 | } |
---|
| 1176 | else { |
---|
| 1177 | int64_t n = 0; |
---|
[749] | 1178 | while (!stop_called && n != ncycles) { |
---|
[663] | 1179 | if (gettimeofday(&t1, NULL) != 0) { |
---|
| 1180 | perror("gettimeofday"); |
---|
| 1181 | return EXIT_FAILURE; |
---|
| 1182 | } |
---|
[749] | 1183 | int64_t nb_cycles = min(max_cycles, ncycles - n); |
---|
[663] | 1184 | if (do_reset_counters) { |
---|
| 1185 | nb_cycles = min(nb_cycles, reset_counters - n); |
---|
| 1186 | } |
---|
| 1187 | if (do_dump_counters) { |
---|
| 1188 | nb_cycles = min(nb_cycles, dump_counters - n); |
---|
| 1189 | } |
---|
[344] | 1190 | |
---|
[663] | 1191 | sc_start(sc_core::sc_time(nb_cycles, SC_NS)); |
---|
| 1192 | n += nb_cycles; |
---|
| 1193 | |
---|
| 1194 | if (do_reset_counters && n == reset_counters) { |
---|
| 1195 | // Reseting counters |
---|
| 1196 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1197 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1198 | clusters[x][y]->memc->reset_counters(); |
---|
| 1199 | } |
---|
| 1200 | } |
---|
| 1201 | do_reset_counters = false; |
---|
| 1202 | } |
---|
| 1203 | |
---|
| 1204 | if (do_dump_counters && n == dump_counters) { |
---|
| 1205 | // Dumping counters |
---|
| 1206 | for (size_t x = 0; x < (X_SIZE); x++) { |
---|
| 1207 | for (size_t y = 0; y < Y_SIZE; y++) { |
---|
| 1208 | clusters[x][y]->memc->print_stats(true, false); |
---|
| 1209 | } |
---|
| 1210 | } |
---|
| 1211 | do_dump_counters = false; |
---|
| 1212 | } |
---|
| 1213 | |
---|
| 1214 | |
---|
| 1215 | if (gettimeofday(&t2, NULL) != 0) { |
---|
| 1216 | perror("gettimeofday"); |
---|
| 1217 | return EXIT_FAILURE; |
---|
| 1218 | } |
---|
| 1219 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
| 1220 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
[706] | 1221 | std::cerr << std::dec << "cycle " << n << " platform clock frequency " << (double) nb_cycles / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
[663] | 1222 | } |
---|
[344] | 1223 | } |
---|
[504] | 1224 | |
---|
[885] | 1225 | |
---|
[512] | 1226 | // Free memory |
---|
[663] | 1227 | for (size_t i = 0; i < (X_SIZE * Y_SIZE); i++) |
---|
[504] | 1228 | { |
---|
[663] | 1229 | size_t x = i / Y_SIZE; |
---|
| 1230 | size_t y = i % Y_SIZE; |
---|
[504] | 1231 | delete clusters[x][y]; |
---|
| 1232 | } |
---|
| 1233 | |
---|
[885] | 1234 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, X_SIZE-1, Y_SIZE); |
---|
| 1235 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, X_SIZE-1, Y_SIZE); |
---|
[512] | 1236 | |
---|
[885] | 1237 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, X_SIZE-1, Y_SIZE); |
---|
| 1238 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, X_SIZE-1, Y_SIZE); |
---|
| 1239 | |
---|
| 1240 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_inc, X_SIZE-1, Y_SIZE); |
---|
| 1241 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_dec, X_SIZE-1, Y_SIZE); |
---|
| 1242 | |
---|
| 1243 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_inc, X_SIZE-1, Y_SIZE); |
---|
| 1244 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_dec, X_SIZE-1, Y_SIZE); |
---|
| 1245 | |
---|
| 1246 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_inc, X_SIZE-1, Y_SIZE); |
---|
| 1247 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_dec, X_SIZE-1, Y_SIZE); |
---|
| 1248 | |
---|
| 1249 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, X_SIZE, Y_SIZE-1); |
---|
| 1250 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, X_SIZE, Y_SIZE-1); |
---|
| 1251 | |
---|
| 1252 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, X_SIZE, Y_SIZE-1); |
---|
| 1253 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, X_SIZE, Y_SIZE-1); |
---|
| 1254 | |
---|
| 1255 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_inc, X_SIZE, Y_SIZE-1); |
---|
| 1256 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_dec, X_SIZE, Y_SIZE-1); |
---|
| 1257 | |
---|
| 1258 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_inc, X_SIZE, Y_SIZE-1); |
---|
| 1259 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_dec, X_SIZE, Y_SIZE-1); |
---|
| 1260 | |
---|
| 1261 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_inc, X_SIZE, Y_SIZE-1); |
---|
| 1262 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_dec, X_SIZE, Y_SIZE-1); |
---|
| 1263 | |
---|
| 1264 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cmd_in, X_SIZE, Y_SIZE, 4); |
---|
| 1265 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cmd_out, X_SIZE, Y_SIZE, 4); |
---|
| 1266 | |
---|
| 1267 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_rsp_in, X_SIZE, Y_SIZE, 4); |
---|
| 1268 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_rsp_out, X_SIZE, Y_SIZE, 4); |
---|
| 1269 | |
---|
| 1270 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_m2p_in, X_SIZE, Y_SIZE, 4); |
---|
| 1271 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_m2p_out, X_SIZE, Y_SIZE, 4); |
---|
| 1272 | |
---|
| 1273 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_p2m_in, X_SIZE, Y_SIZE, 4); |
---|
| 1274 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_bound_p2m_out, X_SIZE, Y_SIZE, 4); |
---|
| 1275 | |
---|
| 1276 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cla_in, X_SIZE, Y_SIZE, 4); |
---|
| 1277 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cla_out, X_SIZE, Y_SIZE, 4); |
---|
| 1278 | |
---|
[344] | 1279 | return EXIT_SUCCESS; |
---|
| 1280 | } |
---|
| 1281 | |
---|
[504] | 1282 | |
---|
| 1283 | void handler(int dummy = 0) { |
---|
| 1284 | stop_called = true; |
---|
| 1285 | sc_stop(); |
---|
| 1286 | } |
---|
| 1287 | |
---|
[547] | 1288 | void voidhandler(int dummy = 0) {} |
---|
[504] | 1289 | |
---|
[344] | 1290 | int sc_main (int argc, char *argv[]) |
---|
| 1291 | { |
---|
[504] | 1292 | signal(SIGINT, handler); |
---|
[547] | 1293 | signal(SIGPIPE, voidhandler); |
---|
[504] | 1294 | |
---|
[344] | 1295 | try { |
---|
| 1296 | return _main(argc, argv); |
---|
| 1297 | } catch (std::exception &e) { |
---|
| 1298 | std::cout << e.what() << std::endl; |
---|
| 1299 | } catch (...) { |
---|
| 1300 | std::cout << "Unknown exception occured" << std::endl; |
---|
| 1301 | throw; |
---|
| 1302 | } |
---|
| 1303 | return 1; |
---|
| 1304 | } |
---|
| 1305 | |
---|
| 1306 | |
---|
| 1307 | // Local Variables: |
---|
| 1308 | // tab-width: 3 |
---|
| 1309 | // c-basic-offset: 3 |
---|
| 1310 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 1311 | // indent-tabs-mode: nil |
---|
| 1312 | // End: |
---|
| 1313 | |
---|
| 1314 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|