[609] | 1 | ///////////////////////////////////////////////////////////////////////// |
---|
| 2 | // File: top.cpp |
---|
| 3 | // Author: Alain Greiner |
---|
| 4 | // Copyright: UPMC/LIP6 |
---|
| 5 | // Date : may 2013 |
---|
| 6 | // This program is released under the GNU public license |
---|
| 7 | ///////////////////////////////////////////////////////////////////////// |
---|
| 8 | // This file define a generic TSAR architecture. |
---|
| 9 | // The physical address space is 40 bits. |
---|
| 10 | // |
---|
| 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 |
---|
| 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. |
---|
| 21 | // |
---|
| 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 6 extra components: |
---|
| 26 | // - the boot rom (BROM) |
---|
| 27 | // - the disk controller (BDEV) |
---|
| 28 | // - the multi-channel network controller (MNIC) |
---|
| 29 | // - the multi-channel chained buffer dma controller (CDMA) |
---|
| 30 | // - the multi-channel tty controller (MTTY) |
---|
| 31 | // - the frame buffer controller (FBUF) |
---|
| 32 | // |
---|
| 33 | // It is build with one single component implementing a cluster, |
---|
| 34 | // defined in files tsar_xbar_cluster.* (with * = cpp, h, sd) |
---|
| 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 | // |
---|
| 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 : |
---|
| 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) |
---|
| 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) |
---|
| 51 | // |
---|
| 52 | // Some other hardware parameters are not used when compiling the OS, |
---|
| 53 | // and can be directly defined in this top.cpp file: |
---|
| 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 |
---|
| 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) |
---|
| 72 | // The (x_width + y_width) MSB bits (left aligned) define |
---|
| 73 | // the cluster index, and the LADR bits define the local index: |
---|
| 74 | // | X_ID | Y_ID |---| LADR | OFFSET | |
---|
| 75 | // |x_width|y_width|---| 8 | 24 | |
---|
| 76 | ///////////////////////////////////////////////////////////////////////// |
---|
| 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 | ///////////////////////////////////////////////////////////////////////// |
---|
| 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" |
---|
| 93 | #include "tsar_xbar_cluster.h" |
---|
| 94 | #include "alloc_elems.h" |
---|
| 95 | |
---|
| 96 | /////////////////////////////////////////////////// |
---|
| 97 | // Parallelisation |
---|
| 98 | /////////////////////////////////////////////////// |
---|
| 99 | #if USE_OPENMP |
---|
| 100 | #include <omp.h> |
---|
| 101 | #endif |
---|
| 102 | |
---|
| 103 | // cluster index (computed from x,y coordinates) |
---|
| 104 | #define cluster(x,y) (y + ymax * x) |
---|
| 105 | |
---|
| 106 | #define min(x, y) (x < y ? x : y) |
---|
| 107 | |
---|
| 108 | /////////////////////////////////////////////////////////// |
---|
| 109 | // DSPIN parameters |
---|
| 110 | /////////////////////////////////////////////////////////// |
---|
| 111 | #define dspin_cmd_width 39 |
---|
| 112 | #define dspin_rsp_width 32 |
---|
| 113 | |
---|
| 114 | /////////////////////////////////////////////////////////// |
---|
| 115 | // VCI parameters |
---|
| 116 | /////////////////////////////////////////////////////////// |
---|
| 117 | #define vci_cell_width_int 4 |
---|
| 118 | #define vci_cell_width_ext 8 |
---|
| 119 | #define vci_address_width 32 |
---|
| 120 | #define vci_plen_width 8 |
---|
| 121 | #define vci_rerror_width 1 |
---|
| 122 | #define vci_clen_width 1 |
---|
| 123 | #define vci_rflag_width 1 |
---|
| 124 | #define vci_srcid_width 14 |
---|
| 125 | #define vci_pktid_width 4 |
---|
| 126 | #define vci_trdid_width 4 |
---|
| 127 | #define vci_wrplen_width 1 |
---|
| 128 | |
---|
| 129 | //////////////////////////////////////////////////////////// |
---|
| 130 | // Main Hardware Parameters values |
---|
| 131 | //////////////////////////////////////////////////////////// |
---|
| 132 | #define CLUSTER_X 1 |
---|
| 133 | #define CLUSTER_Y 1 |
---|
| 134 | #define NB_CLUSTERS 1 |
---|
| 135 | #define NB_PROCS_MAX 4 |
---|
| 136 | #define NB_DMA_CHANNELS 1 |
---|
| 137 | #define NB_TTY_CHANNELS 4 |
---|
| 138 | #define NB_IOC_CHANNELS 1 |
---|
| 139 | #define NB_NIC_CHANNELS 1 |
---|
| 140 | #define NB_CMA_CHANNELS 0 |
---|
| 141 | #define USE_XICU 1 |
---|
| 142 | #define IOMMU_ACTIVE 0 |
---|
| 143 | |
---|
| 144 | //////////////////////////////////////////////////////////// |
---|
| 145 | // Secondary Hardware Parameters |
---|
| 146 | //////////////////////////////////////////////////////////// |
---|
| 147 | #define XRAM_LATENCY 0 |
---|
| 148 | |
---|
| 149 | #define MEMC_WAYS 16 |
---|
| 150 | #define MEMC_SETS 256 |
---|
| 151 | |
---|
| 152 | #define L1_IWAYS 4 |
---|
| 153 | #define L1_ISETS 64 |
---|
| 154 | #define L1_DWAYS 4 |
---|
| 155 | #define L1_DSETS 64 |
---|
| 156 | |
---|
| 157 | #define FBUF_X_SIZE 512 |
---|
| 158 | #define FBUF_Y_SIZE 512 |
---|
| 159 | |
---|
| 160 | #define BDEV_SECTOR_SIZE 4096 |
---|
| 161 | #define BDEV_IMAGE_NAME "hdd-img.bin" |
---|
| 162 | |
---|
| 163 | #define NIC_RX_NAME "rx_packets.txt" |
---|
| 164 | #define NIC_TX_NAME "tx_packets.txt" |
---|
| 165 | #define NIC_TIMEOUT 10000 |
---|
| 166 | |
---|
| 167 | #define NORTH 0 |
---|
| 168 | #define SOUTH 1 |
---|
| 169 | #define EAST 2 |
---|
| 170 | #define WEST 3 |
---|
| 171 | |
---|
| 172 | //////////////////////////////////////////////////////////// |
---|
| 173 | // Software to be loaded in ROM/RAM |
---|
| 174 | //////////////////////////////////////////////////////////// |
---|
| 175 | #define soft_name "bootloader.bin",\ |
---|
| 176 | "kernel-soclib.bin@0xbfc10000:D",\ |
---|
| 177 | "arch-info.bin@0xBFC08000:D" |
---|
| 178 | |
---|
| 179 | //////////////////////////////////////////////////////////// |
---|
| 180 | // DEBUG Parameters default values |
---|
| 181 | //////////////////////////////////////////////////////////// |
---|
| 182 | #define MAX_FROZEN_CYCLES 100000000 |
---|
| 183 | |
---|
| 184 | //////////////////////////////////////////////////////////////////// |
---|
| 185 | // TGTID definition in direct space |
---|
| 186 | // For all components: global TGTID = global SRCID = cluster_index |
---|
| 187 | //////////////////////////////////////////////////////////////////// |
---|
| 188 | #define MEMC_TGTID 0 |
---|
| 189 | #define XICU_TGTID 1 |
---|
| 190 | #define MDMA_TGTID 2 |
---|
| 191 | #define MTTY_TGTID 3 |
---|
| 192 | #define FBUF_TGTID 4 |
---|
| 193 | #define BDEV_TGTID 5 |
---|
| 194 | #define MNIC_TGTID 6 |
---|
| 195 | #define BROM_TGTID 7 |
---|
| 196 | #define CDMA_TGTID 8 |
---|
| 197 | #define SIMH_TGTID 9 |
---|
| 198 | |
---|
| 199 | ///////////////////////////////////////////////////////// |
---|
| 200 | // Physical segments definition |
---|
| 201 | ///////////////////////////////////////////////////////// |
---|
| 202 | // There is 3 segments replicated in all clusters |
---|
[752] | 203 | // and 5 specific segments in the "IO" cluster |
---|
[609] | 204 | // (containing address 0xBF000000) |
---|
| 205 | ///////////////////////////////////////////////////////// |
---|
| 206 | // Physical Address Decoding: 8 GID + 8 LID + 16 offset. |
---|
| 207 | ///////////////////////////////////////////////////////// |
---|
[752] | 208 | #define RAM_BASE 0x00000000 |
---|
[609] | 209 | #define RAM_SIZE 0x00C00000 |
---|
| 210 | |
---|
[752] | 211 | #define BROM_BASE 0xBFC00000 |
---|
[609] | 212 | #define BROM_SIZE 0x00100000 |
---|
| 213 | |
---|
[752] | 214 | #define FBUF_BASE 0xBFD00000 |
---|
[609] | 215 | #define FBUF_SIZE 0x00200000 |
---|
| 216 | |
---|
[752] | 217 | #define XICU_BASE 0x00F00000 |
---|
[609] | 218 | #define XICU_SIZE 0x00002000 |
---|
| 219 | |
---|
| 220 | #define BDEV_BASE 0xBFF10000 |
---|
| 221 | #define BDEV_SIZE 0x00000100 |
---|
| 222 | |
---|
[752] | 223 | #define MTTY_BASE 0xBFF20000 |
---|
[609] | 224 | #define MTTY_SIZE 0x00000100 |
---|
| 225 | |
---|
| 226 | #define MDMA_BASE 0x00F30000 |
---|
| 227 | #define MDMA_SIZE 0x00001000 * NB_DMA_CHANNELS // 4 Kbytes per channel |
---|
| 228 | |
---|
[752] | 229 | #define MEMC_BASE 0x00F40000 |
---|
[609] | 230 | #define MEMC_SIZE 0x00001000 |
---|
| 231 | |
---|
| 232 | #define SIMH_BASE 0xBFF50000 |
---|
| 233 | #define SIMH_SIZE 0x00001000 |
---|
| 234 | |
---|
[752] | 235 | #define CDMA_BASE 0xBFF60000 |
---|
[609] | 236 | #define CDMA_SIZE 0x00000100 |
---|
| 237 | |
---|
| 238 | #define MNIC_BASE 0xB0F80000 |
---|
| 239 | #define MNIC_SIZE 0x00080000 // 512 Kbytes (for 8 channels) |
---|
| 240 | |
---|
| 241 | bool stop_called = false; |
---|
| 242 | |
---|
| 243 | ///////////////////////////////// |
---|
| 244 | int _main(int argc, char *argv[]) |
---|
| 245 | { |
---|
| 246 | using namespace sc_core; |
---|
| 247 | using namespace soclib::caba; |
---|
| 248 | using namespace soclib::common; |
---|
| 249 | |
---|
| 250 | uint64_t ncycles = 0xFFFFFFFFFFFFFFFF; // simulated cycles |
---|
| 251 | char disk_name[256] = BDEV_IMAGE_NAME; // pathname to the disk image |
---|
| 252 | char nic_rx_name[256] = NIC_RX_NAME; // pathname to the rx packets file |
---|
| 253 | char nic_tx_name[256] = NIC_TX_NAME; // pathname to the tx packets file |
---|
| 254 | ssize_t threads_nr = 1; // simulator's threads number |
---|
| 255 | bool debug_ok = false; // trace activated |
---|
| 256 | size_t debug_period = 1; // trace period |
---|
[752] | 257 | size_t debug_memc_id = 0; // index of memc to be traced |
---|
[609] | 258 | size_t debug_proc_id = 0; // index of proc to be traced |
---|
| 259 | uint32_t debug_from = 0; // trace start cycle |
---|
| 260 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // monitoring frozen processor |
---|
| 261 | size_t xmax = CLUSTER_X; // number of clusters in a row |
---|
| 262 | size_t ymax = CLUSTER_Y; // number of clusters in a column |
---|
| 263 | size_t nprocs = NB_PROCS_MAX; // number of processors per cluster |
---|
| 264 | size_t xfb = FBUF_X_SIZE; // frameBuffer column number |
---|
| 265 | size_t yfb = FBUF_Y_SIZE; // frameBuffer lines number |
---|
| 266 | size_t fb_mode = 420; |
---|
[613] | 267 | size_t ram_size = RAM_SIZE; |
---|
[609] | 268 | size_t blk_size = BDEV_SECTOR_SIZE; |
---|
| 269 | size_t l1_i_ways = L1_IWAYS; |
---|
| 270 | size_t l1_d_ways = L1_DWAYS; |
---|
| 271 | size_t l1_i_sets = L1_ISETS; |
---|
| 272 | size_t l1_d_sets = L1_DSETS; |
---|
| 273 | size_t memc_sets = MEMC_SETS; |
---|
| 274 | size_t memc_ways = MEMC_WAYS; |
---|
| 275 | size_t xram_latency = XRAM_LATENCY; |
---|
[613] | 276 | size_t xicu_base = XICU_BASE; |
---|
| 277 | size_t mdma_base = MDMA_BASE; |
---|
| 278 | size_t memc_base = MEMC_BASE; |
---|
| 279 | bool isRamSizeSet = false; |
---|
[609] | 280 | size_t cluster_io_id; // index of cluster containing IOs |
---|
| 281 | struct timeval t1,t2; |
---|
| 282 | uint64_t ms1,ms2; |
---|
| 283 | |
---|
| 284 | ////////////// command line arguments ////////////////////// |
---|
| 285 | if (argc > 1) |
---|
| 286 | { |
---|
| 287 | for (int n = 1; n < argc; n = n + 2) |
---|
| 288 | { |
---|
| 289 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) |
---|
| 290 | { |
---|
| 291 | ncycles = atoi(argv[n + 1]); |
---|
| 292 | } |
---|
| 293 | else if( (strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc) ) |
---|
| 294 | { |
---|
| 295 | nprocs = atoi(argv[n+1]); |
---|
| 296 | assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)) && |
---|
| 297 | "NPROCS must be equal to 1, 2, or 4"); |
---|
| 298 | } |
---|
| 299 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) |
---|
| 300 | { |
---|
| 301 | threads_nr = atoi(argv[n + 1]); |
---|
| 302 | threads_nr = (threads_nr < 1) ? 1 : threads_nr; |
---|
| 303 | } |
---|
| 304 | else if( (strcmp(argv[n],"-XMAX") == 0) && (n+1<argc) ) |
---|
| 305 | { |
---|
| 306 | xmax = atoi(argv[n+1]); |
---|
| 307 | assert( ((xmax == 1) || (xmax == 2) || (xmax == 4) || (xmax == 8) || (xmax == 16)) |
---|
| 308 | && "The XMAX parameter must be 2, 4, 8, or 16" ); |
---|
| 309 | } |
---|
| 310 | else if( (strcmp(argv[n],"-YMAX") == 0) && (n+1<argc) ) |
---|
| 311 | { |
---|
| 312 | ymax = atoi(argv[n+1]); |
---|
| 313 | assert( ((ymax == 1) || (ymax == 2) || (ymax == 4) || (ymax == 8) || (ymax == 16)) |
---|
| 314 | && "The YMAX parameter must be 2, 4, 8, or 16" ); |
---|
| 315 | } |
---|
| 316 | else if((strcmp(argv[n], "-MEMSZ") == 0) && (n+1 < argc)) |
---|
| 317 | { |
---|
[613] | 318 | ram_size = atoi(argv[n+1]); |
---|
| 319 | isRamSizeSet = true; |
---|
[609] | 320 | } |
---|
| 321 | else if((strcmp(argv[n], "-MCWAYS") == 0) && (n+1 < argc)) |
---|
| 322 | { |
---|
| 323 | memc_ways = atoi(argv[n+1]); |
---|
| 324 | } |
---|
| 325 | else if((strcmp(argv[n], "-MCSETS") == 0) && (n+1 < argc)) |
---|
| 326 | { |
---|
| 327 | memc_sets = atoi(argv[n+1]); |
---|
| 328 | } |
---|
| 329 | else if((strcmp(argv[n], "-L1_IWAYS") == 0) && (n+1 < argc)) |
---|
| 330 | { |
---|
| 331 | l1_i_ways = atoi(argv[n+1]); |
---|
| 332 | } |
---|
| 333 | else if((strcmp(argv[n], "-L1_ISETS") == 0) && (n+1 < argc)) |
---|
| 334 | { |
---|
| 335 | l1_i_sets = atoi(argv[n+1]); |
---|
| 336 | } |
---|
| 337 | else if((strcmp(argv[n], "-L1_DWAYS") == 0) && (n+1 < argc)) |
---|
| 338 | { |
---|
| 339 | l1_d_ways = atoi(argv[n+1]); |
---|
| 340 | } |
---|
| 341 | else if((strcmp(argv[n], "-L1_DSETS") == 0) && (n+1 < argc)) |
---|
| 342 | { |
---|
| 343 | l1_d_sets = atoi(argv[n+1]); |
---|
| 344 | } |
---|
| 345 | else if((strcmp(argv[n], "-XLATENCY") == 0) && (n+1 < argc)) |
---|
| 346 | { |
---|
| 347 | xram_latency = atoi(argv[n+1]); |
---|
| 348 | } |
---|
| 349 | else if( (strcmp(argv[n],"-XFB") == 0) && (n+1<argc) ) |
---|
| 350 | { |
---|
| 351 | xfb = atoi(argv[n+1]); |
---|
| 352 | } |
---|
| 353 | else if( (strcmp(argv[n],"-YFB") == 0) && (n+1<argc) ) |
---|
| 354 | { |
---|
| 355 | yfb = atoi(argv[n+1]); |
---|
| 356 | } |
---|
| 357 | else if( (strcmp(argv[n], "-FBMODE") == 0) && (n+1 < argc)) |
---|
| 358 | { |
---|
| 359 | fb_mode = atoi(argv[n+1]); |
---|
| 360 | } |
---|
| 361 | else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) |
---|
| 362 | { |
---|
| 363 | std::cerr << "Warning: -SOFT is useless when using Almos, ignored" << std::endl; |
---|
| 364 | } |
---|
| 365 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) |
---|
| 366 | { |
---|
| 367 | strcpy(disk_name, argv[n + 1]); |
---|
| 368 | } |
---|
| 369 | else if( (strcmp(argv[n],"-BLKSZ") == 0) && (n+1<argc) ) |
---|
| 370 | { |
---|
| 371 | blk_size = atoi(argv[n+1]); |
---|
| 372 | assert(((blk_size % 512) == 0) && "BDEV: Block size must be multiple of 512 bytes"); |
---|
| 373 | } |
---|
| 374 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) |
---|
| 375 | { |
---|
| 376 | debug_ok = true; |
---|
| 377 | debug_from = atoi(argv[n + 1]); |
---|
| 378 | } |
---|
| 379 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) |
---|
| 380 | { |
---|
| 381 | debug_memc_id = atoi(argv[n + 1]); |
---|
| 382 | assert((debug_memc_id < (xmax * ymax)) && |
---|
| 383 | "debug_memc_id larger than xmax * ymax" ); |
---|
| 384 | } |
---|
| 385 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) |
---|
| 386 | { |
---|
| 387 | debug_proc_id = atoi(argv[n + 1]); |
---|
| 388 | assert((debug_proc_id < (xmax * ymax * nprocs)) && |
---|
| 389 | "debug_proc_id larger than XMAX * ymax * NB_PROCS"); |
---|
| 390 | } |
---|
| 391 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) |
---|
| 392 | { |
---|
| 393 | frozen_cycles = atoi(argv[n + 1]); |
---|
| 394 | } |
---|
| 395 | else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) |
---|
| 396 | { |
---|
| 397 | debug_period = atoi(argv[n + 1]); |
---|
| 398 | } |
---|
| 399 | else |
---|
| 400 | { |
---|
| 401 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
| 402 | std::cout << " The order is not important." << std::endl; |
---|
| 403 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
| 404 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
| 405 | std::cout << " -NPROCS number_of_processors_per_cluster" << std::endl; |
---|
| 406 | std::cout << " -THREADS simulator's openmp threads number" << std::endl; |
---|
| 407 | std::cout << " -XMAX number_of_clusters_in_a_row" << std::endl; |
---|
| 408 | std::cout << " -YMAX number_of_clusters_in_a_column" << std::endl; |
---|
| 409 | std::cout << " -MCWAYS memory_cache_number_of_ways" << std::endl; |
---|
| 410 | std::cout << " -MCSETS memory_cache_number_of_sets" << std::endl; |
---|
| 411 | std::cout << " -L1_IWAYS L1_instruction_cache_number_of_ways" << std::endl; |
---|
| 412 | std::cout << " -L1_ISETS L1_instruction_cache_number_of_sets" << std::endl; |
---|
| 413 | std::cout << " -L1_DWAYS L1_data_cache_number_of_ways" << std::endl; |
---|
| 414 | std::cout << " -XLATENCY external_ram_latency_value" << std::endl; |
---|
| 415 | std::cout << " -XFB fram_buffer_number_of_pixels" << std::endl; |
---|
| 416 | std::cout << " -YFB fram_buffer_number_of_lines" << std::endl; |
---|
| 417 | std::cout << " -FBMODE fram buffer subsampling integer value " |
---|
| 418 | "(YUV:420,YUV:422,RGB:0,RGB:16,RGB:32,RGBPAL:256)" << std::endl; |
---|
| 419 | std::cout << " -MEMSZ per-cluster memory size ( <= 12 MB when using Almos)" << std::endl; |
---|
| 420 | std::cout << " -L1_DSETS L1_data_cache_number_of_sets" << std::endl; |
---|
| 421 | std::cout << " -SOFT pathname_for_embedded_soft (GIET only)" << std::endl; |
---|
| 422 | std::cout << " -DISK pathname_for_disk_image" << std::endl; |
---|
| 423 | std::cout << " -BLKSZ sector size in bytes ( must be multiple of 512 bytes )" << std::endl; |
---|
| 424 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
| 425 | std::cout << " -FROZEN max_number_of_lines" << std::endl; |
---|
| 426 | std::cout << " -PERIOD number_of_cycles between trace" << std::endl; |
---|
| 427 | std::cout << " -MEMCID index_memc_to_be_traced" << std::endl; |
---|
| 428 | std::cout << " -PROCID index_proc_to_be_traced" << std::endl; |
---|
| 429 | exit(0); |
---|
| 430 | } |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | // checking hardware parameters |
---|
| 435 | assert( ( (xmax == 1) or (xmax == 2) or (xmax == 4) or |
---|
| 436 | (xmax == 8) or (xmax == 16) ) and |
---|
| 437 | "The XMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
| 438 | |
---|
| 439 | assert( ( (ymax == 1) or (ymax == 2) or (ymax == 4) or |
---|
| 440 | (ymax == 8) or (ymax == 16) ) and |
---|
| 441 | "The YMAX parameter must be 1, 2, 4, 8 or 16" ); |
---|
| 442 | |
---|
| 443 | assert( ( (nprocs == 1) or (nprocs == 2) or |
---|
| 444 | (nprocs == 4) or (nprocs == 8) ) and |
---|
| 445 | "The nprocs parameter must be 1, 2, 4 or 8" ); |
---|
| 446 | |
---|
| 447 | assert( (NB_DMA_CHANNELS < 9) and |
---|
| 448 | "The NB_DMA_CHANNELS parameter must be smaller than 9" ); |
---|
| 449 | |
---|
| 450 | assert( (NB_TTY_CHANNELS < 15) and |
---|
| 451 | "The NB_TTY_CHANNELS parameter must be smaller than 15" ); |
---|
| 452 | |
---|
| 453 | assert( (NB_NIC_CHANNELS < 9) and |
---|
| 454 | "The NB_NIC_CHANNELS parameter must be smaller than 9" ); |
---|
| 455 | |
---|
| 456 | assert( (vci_address_width == 32) and |
---|
| 457 | "VCI address width with ALMOS must be 32 bits" ); |
---|
| 458 | |
---|
| 459 | std::cout << std::endl; |
---|
| 460 | std::cout << " - XMAX = " << xmax << std::endl; |
---|
| 461 | std::cout << " - YMAX = " << ymax << std::endl; |
---|
| 462 | std::cout << " - NPROCS = " << nprocs << std::endl; |
---|
| 463 | std::cout << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS << std::endl; |
---|
| 464 | std::cout << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl; |
---|
| 465 | std::cout << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl; |
---|
| 466 | std::cout << " - MEMC_WAYS = " << memc_ways << std::endl; |
---|
| 467 | std::cout << " - MEMC_SETS = " << memc_sets << std::endl; |
---|
[613] | 468 | std::cout << " - RAM_SIZE = " << ram_size << std::endl; |
---|
[609] | 469 | std::cout << " - RAM_LATENCY = " << xram_latency << std::endl; |
---|
| 470 | std::cout << " - MAX_FROZEN = " << frozen_cycles << std::endl; |
---|
| 471 | std::cout << "[PROCS] " << nprocs * xmax * ymax << std::endl; |
---|
| 472 | |
---|
| 473 | std::cout << std::endl; |
---|
| 474 | // Internal and External VCI parameters definition |
---|
| 475 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
| 476 | vci_plen_width, |
---|
| 477 | vci_address_width, |
---|
| 478 | vci_rerror_width, |
---|
| 479 | vci_clen_width, |
---|
| 480 | vci_rflag_width, |
---|
| 481 | vci_srcid_width, |
---|
| 482 | vci_pktid_width, |
---|
| 483 | vci_trdid_width, |
---|
| 484 | vci_wrplen_width> vci_param_int; |
---|
| 485 | |
---|
| 486 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
| 487 | vci_plen_width, |
---|
| 488 | vci_address_width, |
---|
| 489 | vci_rerror_width, |
---|
| 490 | vci_clen_width, |
---|
| 491 | vci_rflag_width, |
---|
| 492 | vci_srcid_width, |
---|
| 493 | vci_pktid_width, |
---|
| 494 | vci_trdid_width, |
---|
| 495 | vci_wrplen_width> vci_param_ext; |
---|
| 496 | |
---|
| 497 | #if USE_OPENMP |
---|
| 498 | omp_set_dynamic(false); |
---|
| 499 | omp_set_num_threads(threads_nr); |
---|
| 500 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
| 501 | #endif |
---|
| 502 | |
---|
| 503 | // Define parameters depending on mesh size |
---|
| 504 | size_t x_width; |
---|
| 505 | size_t y_width; |
---|
| 506 | |
---|
| 507 | if (xmax == 1) x_width = 0; |
---|
| 508 | else if (xmax == 2) x_width = 1; |
---|
| 509 | else if (xmax <= 4) x_width = 2; |
---|
| 510 | else if (xmax <= 8) x_width = 3; |
---|
| 511 | else x_width = 4; |
---|
| 512 | |
---|
| 513 | if (ymax == 1) y_width = 0; |
---|
| 514 | else if (ymax == 2) y_width = 1; |
---|
| 515 | else if (ymax <= 4) y_width = 2; |
---|
| 516 | else if (ymax <= 8) y_width = 3; |
---|
| 517 | else y_width = 4; |
---|
| 518 | |
---|
[613] | 519 | if((xmax == 1) && (ymax == 1)) |
---|
| 520 | { |
---|
| 521 | cluster_io_id = 0; |
---|
| 522 | ram_size = (isRamSizeSet == true) ? ram_size : 0x8000000; |
---|
| 523 | xicu_base = 0x80f00000; |
---|
| 524 | memc_base = 0x80f40000; |
---|
| 525 | mdma_base = 0x80f30000; |
---|
| 526 | } |
---|
| 527 | else |
---|
| 528 | cluster_io_id = 0xbfc00000 >> (vci_address_width - x_width - y_width); // index of cluster containing IOs |
---|
[609] | 529 | |
---|
| 530 | ///////////////////// |
---|
| 531 | // Mapping Tables |
---|
| 532 | ///////////////////// |
---|
| 533 | |
---|
| 534 | // internal network |
---|
[613] | 535 | MappingTable maptabd(vci_address_width, |
---|
[609] | 536 | IntTab(x_width + y_width, 16 - x_width - y_width), |
---|
| 537 | IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), |
---|
| 538 | 0x00FFFF0000); |
---|
| 539 | |
---|
| 540 | for (size_t x = 0; x < xmax; x++) |
---|
| 541 | { |
---|
| 542 | for (size_t y = 0; y < ymax; y++) |
---|
| 543 | { |
---|
| 544 | sc_uint<vci_address_width> offset; |
---|
| 545 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
| 546 | << (vci_address_width-x_width-y_width); |
---|
| 547 | |
---|
| 548 | std::ostringstream si; |
---|
| 549 | si << "seg_xicu_" << x << "_" << y; |
---|
[613] | 550 | maptabd.add(Segment(si.str(), xicu_base + offset, XICU_SIZE, |
---|
[609] | 551 | IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
| 552 | |
---|
| 553 | std::ostringstream sd; |
---|
| 554 | sd << "seg_mdma_" << x << "_" << y; |
---|
[613] | 555 | maptabd.add(Segment(sd.str(), mdma_base + offset, MDMA_SIZE, |
---|
[609] | 556 | IntTab(cluster(x,y),MDMA_TGTID), false)); |
---|
| 557 | |
---|
| 558 | std::ostringstream sh; |
---|
| 559 | sh << "seg_ram_" << x << "_" << y; |
---|
[613] | 560 | maptabd.add(Segment(sh.str(), RAM_BASE + offset, ram_size, |
---|
[609] | 561 | IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
| 562 | |
---|
| 563 | std::ostringstream sconf; |
---|
| 564 | sconf << "seg_memc_config_" << x << "_" << y; |
---|
[614] | 565 | maptabd.add(Segment(sconf.str(), memc_base + offset, MEMC_SIZE, |
---|
[609] | 566 | IntTab(cluster(x,y),MEMC_TGTID), true, true)); |
---|
| 567 | |
---|
| 568 | if ( cluster(x,y) == cluster_io_id ) |
---|
| 569 | { |
---|
| 570 | maptabd.add(Segment("seg_mtty", MTTY_BASE, MTTY_SIZE, |
---|
| 571 | IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
| 572 | maptabd.add(Segment("seg_fbuf", FBUF_BASE, FBUF_SIZE, |
---|
| 573 | IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
| 574 | maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, |
---|
| 575 | IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
| 576 | maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, |
---|
| 577 | IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
| 578 | maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, |
---|
| 579 | IntTab(cluster(x,y),MNIC_TGTID), false)); |
---|
| 580 | maptabd.add(Segment("seg_cdma", CDMA_BASE, CDMA_SIZE, |
---|
| 581 | IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
| 582 | maptabd.add(Segment("seg_simh", SIMH_BASE, SIMH_SIZE, |
---|
| 583 | IntTab(cluster(x,y),SIMH_TGTID), false)); |
---|
| 584 | } |
---|
| 585 | } |
---|
| 586 | } |
---|
| 587 | std::cout << maptabd << std::endl; |
---|
| 588 | |
---|
| 589 | // external network |
---|
| 590 | MappingTable maptabx(vci_address_width, |
---|
| 591 | IntTab(x_width+y_width), |
---|
| 592 | IntTab(x_width+y_width), |
---|
| 593 | 0x00FFFF0000ULL); |
---|
| 594 | |
---|
| 595 | for (size_t x = 0; x < xmax; x++) |
---|
| 596 | { |
---|
| 597 | for (size_t y = 0; y < ymax ; y++) |
---|
[752] | 598 | { |
---|
[609] | 599 | |
---|
| 600 | sc_uint<vci_address_width> offset; |
---|
| 601 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
| 602 | << (vci_address_width-x_width-y_width); |
---|
| 603 | |
---|
| 604 | std::ostringstream sh; |
---|
| 605 | sh << "x_seg_memc_" << x << "_" << y; |
---|
| 606 | |
---|
| 607 | maptabx.add(Segment(sh.str(), RAM_BASE + offset, |
---|
[613] | 608 | ram_size, IntTab(cluster(x,y)), false)); |
---|
[609] | 609 | } |
---|
| 610 | } |
---|
| 611 | std::cout << maptabx << std::endl; |
---|
| 612 | |
---|
| 613 | //////////////////// |
---|
| 614 | // Signals |
---|
| 615 | /////////////////// |
---|
| 616 | |
---|
| 617 | std::cout << "Clock .. "; |
---|
| 618 | sc_clock signal_clk("clk"); |
---|
| 619 | std::cout << ". [OK]" << std::endl; |
---|
| 620 | sc_signal<bool> signal_resetn("resetn"); |
---|
| 621 | |
---|
| 622 | // Horizontal inter-clusters DSPIN signals |
---|
| 623 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_inc = |
---|
| 624 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", xmax-1, ymax, 3); |
---|
| 625 | |
---|
| 626 | DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_dec = |
---|
| 627 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", xmax-1, ymax, 3); |
---|
| 628 | |
---|
| 629 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_inc = |
---|
| 630 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", xmax-1, ymax, 2); |
---|
| 631 | DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_dec = |
---|
| 632 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", xmax-1, ymax, 2); |
---|
| 633 | |
---|
| 634 | // Vertical inter-clusters DSPIN signals |
---|
| 635 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_inc = |
---|
| 636 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", xmax, ymax-1, 3); |
---|
| 637 | DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_dec = |
---|
| 638 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", xmax, ymax-1, 3); |
---|
| 639 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_inc = |
---|
| 640 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", xmax, ymax-1, 2); |
---|
| 641 | DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_dec = |
---|
| 642 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", xmax, ymax-1, 2); |
---|
| 643 | |
---|
| 644 | // Mesh boundaries DSPIN signals |
---|
| 645 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_in = |
---|
| 646 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in" , xmax, ymax, 4, 3); |
---|
| 647 | DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_out = |
---|
| 648 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", xmax, ymax, 4, 3); |
---|
| 649 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_in = |
---|
| 650 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in" , xmax, ymax, 4, 2); |
---|
| 651 | DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_out = |
---|
| 652 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", xmax, ymax, 4, 2); |
---|
| 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 | |
---|
| 667 | TsarXbarCluster<dspin_cmd_width, |
---|
| 668 | dspin_rsp_width, |
---|
| 669 | vci_param_int, |
---|
| 670 | vci_param_ext>* clusters[xmax][ymax]; |
---|
| 671 | |
---|
| 672 | #if USE_OPENMP |
---|
| 673 | #pragma omp parallel |
---|
| 674 | { |
---|
| 675 | #pragma omp for |
---|
| 676 | #endif |
---|
| 677 | for (size_t i = 0; i < (xmax * ymax); i++) |
---|
| 678 | { |
---|
| 679 | size_t x = i / ymax; |
---|
| 680 | size_t y = i % ymax; |
---|
| 681 | |
---|
| 682 | #if USE_OPENMP |
---|
| 683 | #pragma omp critical |
---|
| 684 | { |
---|
| 685 | #endif |
---|
| 686 | std::cout << std::endl; |
---|
| 687 | std::cout << "Cluster_" << x << "_" << y << std::endl; |
---|
| 688 | std::cout << std::endl; |
---|
| 689 | |
---|
| 690 | std::ostringstream sc; |
---|
| 691 | sc << "cluster_" << x << "_" << y; |
---|
| 692 | clusters[x][y] = new TsarXbarCluster<dspin_cmd_width, |
---|
| 693 | dspin_rsp_width, |
---|
| 694 | vci_param_int, |
---|
| 695 | vci_param_ext> |
---|
| 696 | ( |
---|
| 697 | sc.str().c_str(), |
---|
| 698 | nprocs, |
---|
| 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, |
---|
| 708 | vci_srcid_width - x_width - y_width, // l_id width, |
---|
| 709 | MEMC_TGTID, |
---|
| 710 | XICU_TGTID, |
---|
| 711 | MDMA_TGTID, |
---|
| 712 | FBUF_TGTID, |
---|
| 713 | MTTY_TGTID, |
---|
| 714 | BROM_TGTID, |
---|
| 715 | MNIC_TGTID, |
---|
| 716 | CDMA_TGTID, |
---|
| 717 | BDEV_TGTID, |
---|
| 718 | SIMH_TGTID, |
---|
| 719 | memc_ways, |
---|
| 720 | memc_sets, |
---|
| 721 | l1_i_ways, |
---|
| 722 | l1_i_sets, |
---|
| 723 | l1_d_ways, |
---|
| 724 | l1_d_sets, |
---|
| 725 | xram_latency, |
---|
| 726 | (cluster(x,y) == cluster_io_id), |
---|
| 727 | xfb, |
---|
| 728 | yfb, |
---|
| 729 | disk_name, |
---|
| 730 | blk_size, |
---|
| 731 | NB_NIC_CHANNELS, |
---|
| 732 | nic_rx_name, |
---|
| 733 | nic_tx_name, |
---|
| 734 | NIC_TIMEOUT, |
---|
| 735 | NB_CMA_CHANNELS, |
---|
| 736 | loader, |
---|
| 737 | frozen_cycles, |
---|
| 738 | debug_from , |
---|
| 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 |
---|
| 756 | for (size_t x = 0; x < (xmax); x++){ |
---|
| 757 | for (size_t y = 0; y < ymax; y++){ |
---|
| 758 | clusters[x][y]->p_clk (signal_clk); |
---|
| 759 | clusters[x][y]->p_resetn (signal_resetn); |
---|
| 760 | } |
---|
| 761 | } |
---|
| 762 | |
---|
| 763 | // Inter Clusters horizontal connections |
---|
| 764 | if (xmax > 1){ |
---|
| 765 | for (size_t x = 0; x < (xmax-1); x++){ |
---|
| 766 | for (size_t y = 0; y < ymax; y++){ |
---|
| 767 | for (size_t k = 0; k < 3; k++){ |
---|
| 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]); |
---|
| 772 | } |
---|
| 773 | |
---|
| 774 | for (size_t k = 0; k < 2; k++){ |
---|
| 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]); |
---|
| 779 | } |
---|
| 780 | } |
---|
| 781 | } |
---|
| 782 | } |
---|
[752] | 783 | std::cout << std::endl << "Horizontal connections established" << std::endl; |
---|
[609] | 784 | |
---|
| 785 | // Inter Clusters vertical connections |
---|
| 786 | if (ymax > 1) { |
---|
| 787 | for (size_t y = 0; y < (ymax-1); y++){ |
---|
| 788 | for (size_t x = 0; x < xmax; x++){ |
---|
| 789 | for (size_t k = 0; k < 3; k++){ |
---|
| 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]); |
---|
| 794 | } |
---|
| 795 | |
---|
| 796 | for (size_t k = 0; k < 2; k++){ |
---|
| 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]); |
---|
| 801 | } |
---|
| 802 | } |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | std::cout << "Vertical connections established" << std::endl; |
---|
| 806 | |
---|
| 807 | // East & West boundary cluster connections |
---|
| 808 | for (size_t y = 0; y < ymax; y++) |
---|
| 809 | { |
---|
| 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 | |
---|
| 818 | for (size_t k = 0; k < 2; k++) |
---|
| 819 | { |
---|
| 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]); |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | // North & South boundary clusters connections |
---|
| 828 | for (size_t x = 0; x < xmax; x++) |
---|
| 829 | { |
---|
| 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 | |
---|
| 838 | for (size_t k = 0; k < 2; k++) |
---|
| 839 | { |
---|
| 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]); |
---|
| 844 | } |
---|
| 845 | } |
---|
| 846 | std::cout << "North, South, West, East connections established" << std::endl; |
---|
| 847 | std::cout << std::endl; |
---|
| 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 |
---|
| 858 | for (size_t x = 0; x < xmax ; x++){ |
---|
| 859 | for (size_t y = 0; y < ymax ; y++){ |
---|
| 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 | } |
---|
| 867 | |
---|
| 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; |
---|
| 873 | } |
---|
| 874 | } |
---|
| 875 | } |
---|
| 876 | } |
---|
| 877 | |
---|
| 878 | #define STATS_CYCLES 10000000 |
---|
| 879 | |
---|
| 880 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 881 | signal_resetn = true; |
---|
| 882 | |
---|
| 883 | uint64_t n = 0; |
---|
| 884 | |
---|
| 885 | while (!stop_called) { |
---|
| 886 | if (gettimeofday(&t1, NULL) != 0) { |
---|
| 887 | perror("gettimeofday"); |
---|
| 888 | return EXIT_FAILURE; |
---|
| 889 | } |
---|
| 890 | sc_start(STATS_CYCLES); |
---|
| 891 | n += STATS_CYCLES; |
---|
| 892 | if (gettimeofday(&t2, NULL) != 0) { |
---|
| 893 | perror("gettimeofday"); |
---|
| 894 | return EXIT_FAILURE; |
---|
| 895 | } |
---|
| 896 | ms1 = (uint64_t)t1.tv_sec * 1000ULL + (uint64_t)t1.tv_usec / 1000; |
---|
| 897 | ms2 = (uint64_t)t2.tv_sec * 1000ULL + (uint64_t)t2.tv_usec / 1000; |
---|
| 898 | std::cerr << "cycle " << n |
---|
| 899 | << " platform clock frequency " |
---|
| 900 | << (double)STATS_CYCLES / (double)(ms2 - ms1) |
---|
| 901 | << "Khz" << std::endl; |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | // Free memory |
---|
| 905 | for (size_t i = 0; i < (xmax * ymax); i++) |
---|
| 906 | { |
---|
| 907 | size_t x = i / ymax; |
---|
| 908 | size_t y = i % ymax; |
---|
| 909 | delete clusters[x][y]; |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, xmax - 1, ymax, 3); |
---|
| 913 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, xmax - 1, ymax, 3); |
---|
| 914 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, xmax - 1, ymax, 2); |
---|
| 915 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, xmax - 1, ymax, 2); |
---|
| 916 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, xmax, ymax - 1, 3); |
---|
| 917 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, xmax, ymax - 1, 3); |
---|
| 918 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, xmax, ymax - 1, 2); |
---|
| 919 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, xmax, ymax - 1, 2); |
---|
| 920 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_in, xmax, ymax, 4, 3); |
---|
| 921 | dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_false_cmd_out, xmax, ymax, 4, 3); |
---|
| 922 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_in, xmax, ymax, 4, 2); |
---|
| 923 | dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_false_rsp_out, xmax, ymax, 4, 2); |
---|
| 924 | |
---|
| 925 | return EXIT_SUCCESS; |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | |
---|
| 929 | void handler(int dummy = 0) { |
---|
| 930 | stop_called = true; |
---|
| 931 | sc_stop(); |
---|
| 932 | } |
---|
| 933 | |
---|
| 934 | void voidhandler(int dummy = 0) {} |
---|
| 935 | |
---|
| 936 | int sc_main (int argc, char *argv[]) |
---|
| 937 | { |
---|
| 938 | signal(SIGINT, handler); |
---|
| 939 | signal(SIGPIPE, voidhandler); |
---|
| 940 | |
---|
| 941 | try { |
---|
| 942 | return _main(argc, argv); |
---|
| 943 | } catch (std::exception &e) { |
---|
| 944 | std::cout << e.what() << std::endl; |
---|
| 945 | } catch (...) { |
---|
| 946 | std::cout << "Unknown exception occured" << std::endl; |
---|
| 947 | throw; |
---|
| 948 | } |
---|
| 949 | return 1; |
---|
| 950 | } |
---|
| 951 | |
---|
| 952 | |
---|
| 953 | // Local Variables: |
---|
| 954 | // tab-width: 3 |
---|
| 955 | // c-basic-offset: 3 |
---|
| 956 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 957 | // indent-tabs-mode: nil |
---|
| 958 | // End: |
---|
| 959 | |
---|
| 960 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|