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