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