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