[621] | 1 | ///////////////////////////////////////////////////////////////////////// |
---|
[967] | 2 | // File: top.cpp (for tsar_generic_leti platform) |
---|
[792] | 3 | // Author: Alain Greiner |
---|
[621] | 4 | // Copyright: UPMC/LIP6 |
---|
[937] | 5 | // Date : february 2013 / updated january 2015 |
---|
[621] | 6 | // This program is released under the GNU public license |
---|
| 7 | ///////////////////////////////////////////////////////////////////////// |
---|
[681] | 8 | // This file define a generic TSAR architecture, fully compatible |
---|
| 9 | // with the VLSI Hardware prototype developped by CEA-LETI and LIP6 |
---|
| 10 | // in the framework of the SHARP project. |
---|
[792] | 11 | // |
---|
[621] | 12 | // The processor is a MIPS32 processor wrapped in a GDB server |
---|
[967] | 13 | // (this is defined in the tsar_leti_cluster). |
---|
[792] | 14 | // |
---|
[937] | 15 | // The main hardware parameters are the mesh size (X_SIZE & Y_SIZE), |
---|
| 16 | // and the number of processors per cluster (NB_PROCS_MAX). |
---|
| 17 | // The NB_PROCS_MAX parameter cannot be larger than 4. |
---|
[967] | 18 | // Others parameters are the frame buffer size, the disk controller type |
---|
| 19 | // (BDV or HBA), the number of TTY channels, the number of NIC channels, |
---|
| 20 | // and the number of CMA channels. |
---|
[621] | 21 | // |
---|
[937] | 22 | // All external peripherals are located in cluster[X_SIZE-1][Y_SIZE-1], |
---|
| 23 | // and are connected to an IO bus (implemented as a vci_local_crossbar): |
---|
[967] | 24 | // - DISK : block device controller (BDV / HBA) |
---|
| 25 | // - MNIC : multi-channel ethernet controller |
---|
| 26 | // - CDMA : multi-channel chained buffer dma controller |
---|
| 27 | // - MTTY : multi-channel tty controller |
---|
| 28 | // - FBUF : frame buffer controller |
---|
| 29 | // - IOPI : HWI to SWI translator |
---|
| 30 | // |
---|
[937] | 31 | // This IO bus is directly connected to the north ports of the CMD/RSP |
---|
| 32 | // routers in cluster[X_SIZE-1][y_SIZE-2] through VCI/DSPIN wrappers. |
---|
| 33 | // All other clusters in the upper row are empty: no processors, |
---|
| 34 | // no ram, no routers. |
---|
| 35 | // The X_SIZE parameter must be larger than 0, but no larger than 16. |
---|
| 36 | // The Y_SIZE parameter must be larger than 1, but no larger than 16. |
---|
| 37 | // |
---|
| 38 | // We don't use an external ROM, as the boot code is (pre)loaded |
---|
| 39 | // in RAM in cluster[0][0] at address 0x0. |
---|
| 40 | // |
---|
| 41 | // An optional RAMDISK of 32 Mbytes can be used in RAM of cluster[0][0]. |
---|
| 42 | // |
---|
[621] | 43 | // The physical address space is 40 bits. |
---|
| 44 | // The 8 address MSB bits define the cluster index. |
---|
| 45 | // |
---|
[937] | 46 | // Besides the processors, each cluster contains: |
---|
| 47 | // - 5 L1/L2 DSPIN routers implementing 5 separated NOCs |
---|
[628] | 48 | // - 1 vci_mem_cache |
---|
| 49 | // - 1 vci_xicu |
---|
[937] | 50 | // - 1 vci_simple_ram (to emulate the L3 cache). |
---|
[621] | 51 | // |
---|
[681] | 52 | // Each processor receives 4 consecutive IRQ lines from the local XICU. |
---|
[967] | 53 | // The number of PTI and WTI IRQs is bounded to 16. |
---|
[664] | 54 | // |
---|
[628] | 55 | // In all clusters, the MEMC IRQ line (signaling a late write error) |
---|
| 56 | // is connected to XICU HWI[8] |
---|
[621] | 57 | // |
---|
[628] | 58 | // For all external peripherals, the hardware interrupts (HWI) are |
---|
[664] | 59 | // translated to write interrupts (WTI) by the iopic component: |
---|
| 60 | // - IOPIC HWI[1:0] connected to IRQ_NIC_RX[1:0] |
---|
[792] | 61 | // - IOPIC HWI[3:2] connected to IRQ_NIC_TX[1:0] |
---|
[664] | 62 | // - IOPIC HWI[7:4] connected to IRQ_CMA_TX[3:0]] |
---|
[967] | 63 | // - IOPIC HWI[8] connected to IRQ_DISK |
---|
[664] | 64 | // - IOPIC HWI[15:9] unused (grounded) |
---|
| 65 | // - IOPIC HWI[23:16] connected to IRQ_TTY_RX[7:0]] |
---|
| 66 | // - IOPIC HWI[31:24] connected to IRQ_TTY_TX[7:0]] |
---|
[937] | 67 | // |
---|
| 68 | // The cluster internal architecture is defined in file tsar_leti_cluster, |
---|
| 69 | // that must be considered as an extension of this top.cpp file. |
---|
[628] | 70 | //////////////////////////////////////////////////////////////////////////// |
---|
| 71 | // The following parameters must be defined in the hard_config.h file : |
---|
[621] | 72 | // - X_WIDTH : number of bits for x coordinate (must be 4) |
---|
| 73 | // - Y_WIDTH : number of bits for y coordinate (must be 4) |
---|
[967] | 74 | // - P_WIDTH : number of bits for local processor coordinate |
---|
[681] | 75 | // - X_SIZE : number of clusters in a row (1,2,4,8,16) |
---|
| 76 | // - Y_SIZE : number of clusters in a column (1,2,4,8) |
---|
[628] | 77 | // - NB_PROCS_MAX : number of processors per cluster (1, 2 or 4) |
---|
[664] | 78 | // - NB_CMA_CHANNELS : number of CMA channels in I/0 cluster (4 max) |
---|
| 79 | // - NB_TTY_CHANNELS : number of TTY channels in I/O cluster (8 max) |
---|
[628] | 80 | // - NB_NIC_CHANNELS : number of NIC channels in I/O cluster (2 max) |
---|
[937] | 81 | // - FBUF_X_SIZE : number of pixels per line for frame buffer |
---|
| 82 | // - FBUF_Y_SIZE : number of lines for frame buffer |
---|
[967] | 83 | // - XCU_NB_HWI : number of XCU HWIs (must be 16) |
---|
| 84 | // - XCU_NB_PTI : number of XCU PTIs (must be 16) |
---|
| 85 | // - XCU_NB_WTI : number of XCU WTIs (must be 16) |
---|
| 86 | // - XCU_NB_OUT : number of XCU output (must be 16) |
---|
| 87 | // - USE_IOC_XYZ : IOC type (XYZ in HBA / BDV / SDC / RDK) |
---|
[792] | 88 | // |
---|
[621] | 89 | // Some other hardware parameters are not used when compiling the OS, |
---|
[628] | 90 | // and are only defined in this top.cpp file: |
---|
[792] | 91 | // - XRAM_LATENCY : external ram latency |
---|
[628] | 92 | // - L1_IWAYS : L1 cache instruction number of ways |
---|
| 93 | // - L1_ISETS : L1 cache instruction number of sets |
---|
| 94 | // - L1_DWAYS : L1 cache data number of ways |
---|
| 95 | // - L1_DSETS : L1 cache data number of sets |
---|
[967] | 96 | // - DISK_IMAGE_NAME : pathname for block device disk image |
---|
[621] | 97 | ///////////////////////////////////////////////////////////////////////// |
---|
| 98 | // General policy for 40 bits physical address decoding: |
---|
| 99 | // All physical segments base addresses are multiple of 1 Mbytes |
---|
[792] | 100 | // (=> the 24 LSB bits = 0, and the 16 MSB bits define the target) |
---|
[621] | 101 | // The (X_WIDTH + Y_WIDTH) MSB bits (left aligned) define |
---|
| 102 | // the cluster index, and the LADR bits define the local index: |
---|
| 103 | // |X_ID|Y_ID| LADR | OFFSET | |
---|
| 104 | // | 4 | 4 | 8 | 24 | |
---|
| 105 | ///////////////////////////////////////////////////////////////////////// |
---|
| 106 | // General policy for 14 bits SRCID decoding: |
---|
| 107 | // Each component is identified by (x_id, y_id, l_id) tuple. |
---|
| 108 | // |X_ID|Y_ID| L_ID | |
---|
| 109 | // | 4 | 4 | 6 | |
---|
| 110 | ///////////////////////////////////////////////////////////////////////// |
---|
| 111 | |
---|
| 112 | #include <systemc> |
---|
| 113 | #include <sys/time.h> |
---|
| 114 | #include <iostream> |
---|
| 115 | #include <sstream> |
---|
| 116 | #include <cstdlib> |
---|
| 117 | #include <cstdarg> |
---|
| 118 | #include <stdint.h> |
---|
| 119 | |
---|
| 120 | #include "gdbserver.h" |
---|
| 121 | #include "mapping_table.h" |
---|
[967] | 122 | |
---|
[621] | 123 | #include "tsar_leti_cluster.h" |
---|
[628] | 124 | #include "vci_local_crossbar.h" |
---|
| 125 | #include "vci_dspin_initiator_wrapper.h" |
---|
| 126 | #include "vci_dspin_target_wrapper.h" |
---|
| 127 | #include "vci_multi_tty.h" |
---|
| 128 | #include "vci_multi_nic.h" |
---|
| 129 | #include "vci_chbuf_dma.h" |
---|
| 130 | #include "vci_block_device_tsar.h" |
---|
[967] | 131 | #include "vci_multi_ahci.h" |
---|
[628] | 132 | #include "vci_framebuffer.h" |
---|
| 133 | #include "vci_iopic.h" |
---|
[967] | 134 | |
---|
[621] | 135 | #include "alloc_elems.h" |
---|
| 136 | |
---|
[967] | 137 | /////////////////////////////////////////////////// |
---|
| 138 | // Main hardware parameters values |
---|
| 139 | /////////////////////////////////////////////////// |
---|
| 140 | |
---|
[792] | 141 | #include "hard_config.h" |
---|
[621] | 142 | |
---|
[967] | 143 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 144 | // Secondary Hardware Parameters |
---|
| 145 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 146 | |
---|
| 147 | #define XMAX X_SIZE // actual number of columns in 2D mesh |
---|
| 148 | #define YMAX (Y_SIZE - 1) // actual number of rows in 2D mesh |
---|
| 149 | |
---|
| 150 | #define XRAM_LATENCY 0 |
---|
| 151 | |
---|
| 152 | #define MEMC_WAYS 16 |
---|
| 153 | #define MEMC_SETS 256 |
---|
| 154 | |
---|
| 155 | #define L1_IWAYS 4 |
---|
| 156 | #define L1_ISETS 64 |
---|
| 157 | |
---|
| 158 | #define L1_DWAYS 4 |
---|
| 159 | #define L1_DSETS 64 |
---|
| 160 | |
---|
[1029] | 161 | #define DISK_IMAGE_NAME "virt_hdd.dmg" |
---|
[967] | 162 | |
---|
| 163 | #define ROM_SOFT_NAME "../../softs/tsar_boot/preloader.elf" |
---|
| 164 | |
---|
| 165 | #define NORTH 0 |
---|
| 166 | #define SOUTH 1 |
---|
| 167 | #define EAST 2 |
---|
| 168 | #define WEST 3 |
---|
| 169 | |
---|
[621] | 170 | /////////////////////////////////////////////////// |
---|
| 171 | // Parallelisation |
---|
| 172 | /////////////////////////////////////////////////// |
---|
[967] | 173 | |
---|
[708] | 174 | #define USE_OPENMP _OPENMP |
---|
[621] | 175 | |
---|
| 176 | #if USE_OPENMP |
---|
| 177 | #include <omp.h> |
---|
| 178 | #endif |
---|
| 179 | |
---|
| 180 | /////////////////////////////////////////////////// |
---|
| 181 | // cluster index (from x,y coordinates) |
---|
| 182 | /////////////////////////////////////////////////// |
---|
| 183 | |
---|
[692] | 184 | #define cluster(x,y) ((y) + ((x) << Y_WIDTH)) |
---|
[621] | 185 | |
---|
| 186 | /////////////////////////////////////////////////////////// |
---|
[792] | 187 | // DSPIN parameters |
---|
[621] | 188 | /////////////////////////////////////////////////////////// |
---|
| 189 | |
---|
| 190 | #define dspin_cmd_width 39 |
---|
| 191 | #define dspin_rsp_width 32 |
---|
| 192 | |
---|
| 193 | /////////////////////////////////////////////////////////// |
---|
[792] | 194 | // VCI parameters |
---|
[621] | 195 | /////////////////////////////////////////////////////////// |
---|
| 196 | |
---|
| 197 | #define vci_cell_width_int 4 |
---|
| 198 | #define vci_cell_width_ext 8 |
---|
| 199 | #define vci_address_width 40 |
---|
| 200 | #define vci_plen_width 8 |
---|
| 201 | #define vci_rerror_width 1 |
---|
| 202 | #define vci_clen_width 1 |
---|
| 203 | #define vci_rflag_width 1 |
---|
| 204 | #define vci_srcid_width 14 |
---|
| 205 | #define vci_pktid_width 4 |
---|
| 206 | #define vci_trdid_width 4 |
---|
| 207 | #define vci_wrplen_width 1 |
---|
| 208 | |
---|
| 209 | |
---|
| 210 | |
---|
[664] | 211 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
[792] | 212 | // DEBUG Parameters default values |
---|
[664] | 213 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
[621] | 214 | |
---|
[681] | 215 | #define MAX_FROZEN_CYCLES 500000 |
---|
[621] | 216 | |
---|
[664] | 217 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
[792] | 218 | // LOCAL TGTID & SRCID definition |
---|
[621] | 219 | // For all components: global TGTID = global SRCID = cluster_index |
---|
[664] | 220 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
[621] | 221 | |
---|
[664] | 222 | #define MEMC_TGTID 0 |
---|
| 223 | #define XICU_TGTID 1 |
---|
| 224 | #define MTTY_TGTID 2 |
---|
[967] | 225 | #define DISK_TGTID 3 |
---|
[664] | 226 | #define FBUF_TGTID 4 |
---|
| 227 | #define MNIC_TGTID 5 |
---|
| 228 | #define CDMA_TGTID 6 |
---|
| 229 | #define IOPI_TGTID 7 |
---|
[621] | 230 | |
---|
[967] | 231 | #define DISK_SRCID NB_PROCS_MAX |
---|
[664] | 232 | #define CDMA_SRCID NB_PROCS_MAX + 1 |
---|
| 233 | #define IOPI_SRCID NB_PROCS_MAX + 2 |
---|
[628] | 234 | |
---|
[621] | 235 | bool stop_called = false; |
---|
| 236 | |
---|
| 237 | ///////////////////////////////// |
---|
| 238 | int _main(int argc, char *argv[]) |
---|
| 239 | { |
---|
| 240 | using namespace sc_core; |
---|
| 241 | using namespace soclib::caba; |
---|
| 242 | using namespace soclib::common; |
---|
| 243 | |
---|
[937] | 244 | uint32_t ncycles = 0xFFFFFFFF; // max simulated cycles |
---|
| 245 | size_t threads = 1; // simulator's threads number |
---|
| 246 | bool trace_ok = false; // trace activated |
---|
| 247 | uint32_t trace_from = 0; // trace start cycle |
---|
| 248 | bool trace_proc_ok = false; // detailed proc trace activated |
---|
| 249 | size_t trace_memc_ok = false; // detailed memc trace activated |
---|
| 250 | size_t trace_memc_id = 0; // index of memc to be traced |
---|
| 251 | size_t trace_proc_id = 0; // index of proc to be traced |
---|
| 252 | char soft_name[256] = ROM_SOFT_NAME; // pathname for ROM binary code |
---|
[967] | 253 | char disk_name[256] = DISK_IMAGE_NAME; // pathname for DISK image |
---|
[937] | 254 | uint32_t frozen_cycles = MAX_FROZEN_CYCLES; // for debug |
---|
[621] | 255 | struct timeval t1,t2; |
---|
| 256 | uint64_t ms1,ms2; |
---|
| 257 | |
---|
| 258 | ////////////// command line arguments ////////////////////// |
---|
| 259 | if (argc > 1) |
---|
| 260 | { |
---|
| 261 | for (int n = 1; n < argc; n = n + 2) |
---|
| 262 | { |
---|
| 263 | if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) |
---|
| 264 | { |
---|
| 265 | ncycles = (uint64_t) strtol(argv[n + 1], NULL, 0); |
---|
| 266 | } |
---|
[993] | 267 | else if ((strcmp(argv[n],"-SOFT") == 0) && (n + 1 < argc)) |
---|
| 268 | { |
---|
| 269 | strcpy(soft_name, argv[n + 1]); |
---|
| 270 | } |
---|
| 271 | else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) |
---|
| 272 | { |
---|
| 273 | strcpy(disk_name, argv[n + 1]); |
---|
| 274 | } |
---|
[621] | 275 | else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) |
---|
| 276 | { |
---|
| 277 | trace_ok = true; |
---|
| 278 | trace_from = (uint32_t) strtol(argv[n + 1], NULL, 0); |
---|
| 279 | } |
---|
| 280 | else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) |
---|
| 281 | { |
---|
| 282 | trace_memc_ok = true; |
---|
| 283 | trace_memc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
| 284 | size_t x = trace_memc_id >> Y_WIDTH; |
---|
| 285 | size_t y = trace_memc_id & ((1<<Y_WIDTH)-1); |
---|
| 286 | |
---|
[937] | 287 | assert( (x < XMAX) and (y < (YMAX)) and |
---|
[967] | 288 | "MEMCID parameter doesxn't fit valid XMAX/YMAX"); |
---|
[621] | 289 | } |
---|
| 290 | else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) |
---|
| 291 | { |
---|
| 292 | trace_proc_ok = true; |
---|
| 293 | trace_proc_id = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
[803] | 294 | size_t cluster_xy = trace_proc_id >> P_WIDTH ; |
---|
[621] | 295 | size_t x = cluster_xy >> Y_WIDTH; |
---|
| 296 | size_t y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
[803] | 297 | size_t l = trace_proc_id & ((1<<P_WIDTH)-1) ; |
---|
[621] | 298 | |
---|
[937] | 299 | assert( (x < XMAX) and (y < YMAX) and (l < NB_PROCS_MAX) and |
---|
[621] | 300 | "PROCID parameter refers a not valid processor"); |
---|
| 301 | } |
---|
| 302 | else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) |
---|
| 303 | { |
---|
[628] | 304 | threads = (size_t) strtol(argv[n + 1], NULL, 0); |
---|
| 305 | threads = (threads < 1) ? 1 : threads; |
---|
[621] | 306 | } |
---|
| 307 | else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) |
---|
| 308 | { |
---|
| 309 | frozen_cycles = (uint32_t) strtol(argv[n + 1], NULL, 0); |
---|
| 310 | } |
---|
| 311 | else |
---|
| 312 | { |
---|
| 313 | std::cout << " Arguments are (key,value) couples." << std::endl; |
---|
| 314 | std::cout << " The order is not important." << std::endl; |
---|
| 315 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
[937] | 316 | std::cout << " - NCYCLES number_of_simulated_cycles" << std::endl; |
---|
| 317 | std::cout << " - DEBUG debug_start_cycle" << std::endl; |
---|
| 318 | std::cout << " - THREADS simulator's threads number" << std::endl; |
---|
| 319 | std::cout << " - FROZEN max_number_of_lines" << std::endl; |
---|
| 320 | std::cout << " - MEMCID index_memc_to_be_traced" << std::endl; |
---|
| 321 | std::cout << " - PROCID index_proc_to_be_traced" << std::endl; |
---|
[621] | 322 | exit(0); |
---|
| 323 | } |
---|
| 324 | } |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | // checking hardware parameters |
---|
[937] | 328 | assert( ((X_SIZE <= 16) and (X_SIZE > 0)) and |
---|
[681] | 329 | "Illegal X_SIZE parameter" ); |
---|
[621] | 330 | |
---|
[937] | 331 | assert( ((Y_SIZE <= 16) and (Y_SIZE > 1)) and |
---|
[681] | 332 | "Illegal Y_SIZE parameter" ); |
---|
[621] | 333 | |
---|
[803] | 334 | assert( (P_WIDTH <= 2) and |
---|
| 335 | "P_WIDTH parameter cannot be larger than 2" ); |
---|
| 336 | |
---|
[664] | 337 | assert( (NB_PROCS_MAX <= 4) and |
---|
[681] | 338 | "Illegal NB_PROCS_MAX parameter" ); |
---|
[621] | 339 | |
---|
[967] | 340 | assert( (XCU_NB_HWI == 16) and |
---|
| 341 | "XCU_NB_HWI must be 16" ); |
---|
| 342 | |
---|
| 343 | assert( (XCU_NB_PTI == 16) and |
---|
| 344 | "XCU_NB_PTI must be 16" ); |
---|
| 345 | |
---|
| 346 | assert( (XCU_NB_WTI == 16) and |
---|
| 347 | "XCU_NB_WTI must be 16" ); |
---|
| 348 | |
---|
| 349 | assert( (XCU_NB_OUT == 16) and |
---|
| 350 | "XCU_NB_OUT must be 16" ); |
---|
| 351 | |
---|
[937] | 352 | assert( (NB_CMA_CHANNELS <= 4) and |
---|
[628] | 353 | "The NB_CMA_CHANNELS parameter cannot be larger than 4" ); |
---|
[621] | 354 | |
---|
[937] | 355 | assert( (NB_TTY_CHANNELS <= 8) and |
---|
[967] | 356 | "The NB_TTY_CHANNELS parameter cannot be larger than 8" ); |
---|
[621] | 357 | |
---|
[937] | 358 | assert( (NB_NIC_CHANNELS <= 2) and |
---|
[628] | 359 | "The NB_NIC_CHANNELS parameter cannot be larger than 2" ); |
---|
[621] | 360 | |
---|
| 361 | assert( (vci_address_width == 40) and |
---|
| 362 | "VCI address width with the GIET must be 40 bits" ); |
---|
| 363 | |
---|
| 364 | assert( (X_WIDTH == 4) and (Y_WIDTH == 4) and |
---|
[937] | 365 | "You must have X_WIDTH == Y_WIDTH == 4"); |
---|
[792] | 366 | |
---|
[621] | 367 | std::cout << std::endl; |
---|
| 368 | |
---|
[967] | 369 | std::cout << " - XMAX = " << XMAX << std::endl |
---|
| 370 | << " - YMAX = " << YMAX << std::endl |
---|
| 371 | << " - NB_PROCS_MAX = " << NB_PROCS_MAX << std::endl |
---|
| 372 | << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS << std::endl |
---|
| 373 | << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS << std::endl |
---|
| 374 | << " - NB_CMA_CHANNELS = " << NB_CMA_CHANNELS << std::endl |
---|
| 375 | << " - MEMC_WAYS = " << MEMC_WAYS << std::endl |
---|
| 376 | << " - MEMC_SETS = " << MEMC_SETS << std::endl |
---|
| 377 | << " - RAM_LATENCY = " << XRAM_LATENCY << std::endl |
---|
| 378 | << " - MAX_FROZEN = " << frozen_cycles << std::endl |
---|
| 379 | << " - MAX_CYCLES = " << ncycles << std::endl |
---|
| 380 | << " - RESET_ADDRESS = " << RESET_ADDRESS << std::endl |
---|
| 381 | << " - SOFT_FILENAME = " << soft_name << std::endl |
---|
| 382 | << " - DISK_IMAGENAME = " << disk_name << std::endl |
---|
| 383 | << " - OPENMP THREADS = " << threads << std::endl |
---|
| 384 | << " - DEBUG_PROCID = " << trace_proc_id << std::endl |
---|
| 385 | << " - DEBUG_MEMCID = " << trace_memc_id << std::endl; |
---|
[621] | 386 | |
---|
| 387 | std::cout << std::endl; |
---|
| 388 | |
---|
| 389 | // Internal and External VCI parameters definition |
---|
| 390 | typedef soclib::caba::VciParams<vci_cell_width_int, |
---|
| 391 | vci_plen_width, |
---|
| 392 | vci_address_width, |
---|
| 393 | vci_rerror_width, |
---|
| 394 | vci_clen_width, |
---|
| 395 | vci_rflag_width, |
---|
| 396 | vci_srcid_width, |
---|
| 397 | vci_pktid_width, |
---|
| 398 | vci_trdid_width, |
---|
| 399 | vci_wrplen_width> vci_param_int; |
---|
| 400 | |
---|
| 401 | typedef soclib::caba::VciParams<vci_cell_width_ext, |
---|
| 402 | vci_plen_width, |
---|
| 403 | vci_address_width, |
---|
| 404 | vci_rerror_width, |
---|
| 405 | vci_clen_width, |
---|
| 406 | vci_rflag_width, |
---|
| 407 | vci_srcid_width, |
---|
| 408 | vci_pktid_width, |
---|
| 409 | vci_trdid_width, |
---|
| 410 | vci_wrplen_width> vci_param_ext; |
---|
| 411 | |
---|
| 412 | #if USE_OPENMP |
---|
| 413 | omp_set_dynamic(false); |
---|
[628] | 414 | omp_set_num_threads(threads); |
---|
[621] | 415 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
| 416 | #endif |
---|
| 417 | |
---|
| 418 | |
---|
[628] | 419 | /////////////////////////////////////// |
---|
| 420 | // Direct Network Mapping Table |
---|
| 421 | /////////////////////////////////////// |
---|
[621] | 422 | |
---|
[792] | 423 | MappingTable maptabd(vci_address_width, |
---|
| 424 | IntTab(X_WIDTH + Y_WIDTH, 16 - X_WIDTH - Y_WIDTH), |
---|
| 425 | IntTab(X_WIDTH + Y_WIDTH, vci_srcid_width - X_WIDTH - Y_WIDTH), |
---|
[628] | 426 | 0x00FF000000ULL); |
---|
[621] | 427 | |
---|
[628] | 428 | // replicated segments |
---|
[937] | 429 | for (size_t x = 0; x < XMAX; x++) |
---|
[621] | 430 | { |
---|
[937] | 431 | for (size_t y = 0; y < (YMAX) ; y++) |
---|
[621] | 432 | { |
---|
| 433 | sc_uint<vci_address_width> offset; |
---|
[628] | 434 | offset = ((sc_uint<vci_address_width>)cluster(x,y)) << 32; |
---|
[621] | 435 | |
---|
| 436 | std::ostringstream si; |
---|
| 437 | si << "seg_xicu_" << x << "_" << y; |
---|
[792] | 438 | maptabd.add(Segment(si.str(), SEG_XCU_BASE + offset, SEG_XCU_SIZE, |
---|
[621] | 439 | IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
| 440 | |
---|
| 441 | std::ostringstream sd; |
---|
[628] | 442 | sd << "seg_mcfg_" << x << "_" << y; |
---|
[792] | 443 | maptabd.add(Segment(sd.str(), SEG_MMC_BASE + offset, SEG_MMC_SIZE, |
---|
[628] | 444 | IntTab(cluster(x,y),MEMC_TGTID), false)); |
---|
[621] | 445 | |
---|
| 446 | std::ostringstream sh; |
---|
| 447 | sh << "seg_memc_" << x << "_" << y; |
---|
[792] | 448 | maptabd.add(Segment(sh.str(), SEG_RAM_BASE + offset, SEG_RAM_SIZE, |
---|
[621] | 449 | IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
| 450 | } |
---|
| 451 | } |
---|
[628] | 452 | |
---|
[664] | 453 | // segments for peripherals in cluster(0,0) |
---|
[792] | 454 | maptabd.add(Segment("seg_tty0", SEG_TTY_BASE, SEG_TTY_SIZE, |
---|
[628] | 455 | IntTab(cluster(0,0),MTTY_TGTID), false)); |
---|
| 456 | |
---|
[792] | 457 | maptabd.add(Segment("seg_ioc0", SEG_IOC_BASE, SEG_IOC_SIZE, |
---|
[967] | 458 | IntTab(cluster(0,0),DISK_TGTID), false)); |
---|
[628] | 459 | |
---|
[937] | 460 | // segments for peripherals in cluster_io (XMAX-1,YMAX) |
---|
[628] | 461 | sc_uint<vci_address_width> offset; |
---|
[937] | 462 | offset = ((sc_uint<vci_address_width>)cluster(XMAX-1,YMAX)) << 32; |
---|
[628] | 463 | |
---|
[792] | 464 | maptabd.add(Segment("seg_mtty", SEG_TTY_BASE + offset, SEG_TTY_SIZE, |
---|
[937] | 465 | IntTab(cluster(XMAX-1, YMAX),MTTY_TGTID), false)); |
---|
[628] | 466 | |
---|
[792] | 467 | maptabd.add(Segment("seg_fbuf", SEG_FBF_BASE + offset, SEG_FBF_SIZE, |
---|
[937] | 468 | IntTab(cluster(XMAX-1, YMAX),FBUF_TGTID), false)); |
---|
[628] | 469 | |
---|
[967] | 470 | maptabd.add(Segment("seg_disk", SEG_IOC_BASE + offset, SEG_IOC_SIZE, |
---|
| 471 | IntTab(cluster(XMAX-1, YMAX),DISK_TGTID), false)); |
---|
[628] | 472 | |
---|
[792] | 473 | maptabd.add(Segment("seg_mnic", SEG_NIC_BASE + offset, SEG_NIC_SIZE, |
---|
[937] | 474 | IntTab(cluster(XMAX-1, YMAX),MNIC_TGTID), false)); |
---|
[628] | 475 | |
---|
[792] | 476 | maptabd.add(Segment("seg_cdma", SEG_CMA_BASE + offset, SEG_CMA_SIZE, |
---|
[937] | 477 | IntTab(cluster(XMAX-1, YMAX),CDMA_TGTID), false)); |
---|
[628] | 478 | |
---|
[792] | 479 | maptabd.add(Segment("seg_iopi", SEG_PIC_BASE + offset, SEG_PIC_SIZE, |
---|
[937] | 480 | IntTab(cluster(XMAX-1, YMAX),IOPI_TGTID), false)); |
---|
[628] | 481 | |
---|
[621] | 482 | std::cout << maptabd << std::endl; |
---|
| 483 | |
---|
[628] | 484 | ///////////////////////////////////////////////// |
---|
| 485 | // Ram network mapping table |
---|
| 486 | ///////////////////////////////////////////////// |
---|
[621] | 487 | |
---|
[792] | 488 | MappingTable maptabx(vci_address_width, |
---|
| 489 | IntTab(X_WIDTH+Y_WIDTH), |
---|
| 490 | IntTab(X_WIDTH+Y_WIDTH), |
---|
[628] | 491 | 0x00FF000000ULL); |
---|
[621] | 492 | |
---|
[937] | 493 | for (size_t x = 0; x < XMAX; x++) |
---|
[628] | 494 | { |
---|
[937] | 495 | for (size_t y = 0; y < (YMAX) ; y++) |
---|
[792] | 496 | { |
---|
[628] | 497 | sc_uint<vci_address_width> offset; |
---|
[792] | 498 | offset = (sc_uint<vci_address_width>)cluster(x,y) |
---|
[628] | 499 | << (vci_address_width-X_WIDTH-Y_WIDTH); |
---|
[621] | 500 | |
---|
[628] | 501 | std::ostringstream sh; |
---|
| 502 | sh << "x_seg_memc_" << x << "_" << y; |
---|
[621] | 503 | |
---|
[792] | 504 | maptabx.add(Segment(sh.str(), SEG_RAM_BASE + offset, |
---|
| 505 | SEG_RAM_SIZE, IntTab(cluster(x,y)), false)); |
---|
[628] | 506 | } |
---|
| 507 | } |
---|
| 508 | std::cout << maptabx << std::endl; |
---|
[621] | 509 | |
---|
[628] | 510 | //////////////////// |
---|
| 511 | // Signals |
---|
| 512 | /////////////////// |
---|
[621] | 513 | |
---|
[628] | 514 | sc_clock signal_clk("clk"); |
---|
| 515 | sc_signal<bool> signal_resetn("resetn"); |
---|
[621] | 516 | |
---|
[628] | 517 | // IRQs from external peripherals |
---|
[967] | 518 | sc_signal<bool> signal_irq_disk; |
---|
[628] | 519 | sc_signal<bool> signal_irq_mnic_rx[NB_NIC_CHANNELS]; |
---|
| 520 | sc_signal<bool> signal_irq_mnic_tx[NB_NIC_CHANNELS]; |
---|
[664] | 521 | sc_signal<bool> signal_irq_mtty_rx[NB_TTY_CHANNELS]; |
---|
[628] | 522 | sc_signal<bool> signal_irq_cdma[NB_CMA_CHANNELS]; |
---|
| 523 | sc_signal<bool> signal_irq_false; |
---|
| 524 | |
---|
[621] | 525 | // Horizontal inter-clusters DSPIN signals |
---|
[628] | 526 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cmd_inc = |
---|
[937] | 527 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", XMAX-1, YMAX); |
---|
[628] | 528 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cmd_dec = |
---|
[937] | 529 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", XMAX-1, YMAX); |
---|
[621] | 530 | |
---|
[628] | 531 | DspinSignals<dspin_rsp_width>** signal_dspin_h_rsp_inc = |
---|
[937] | 532 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", XMAX-1, YMAX); |
---|
[628] | 533 | DspinSignals<dspin_rsp_width>** signal_dspin_h_rsp_dec = |
---|
[937] | 534 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", XMAX-1, YMAX); |
---|
[628] | 535 | |
---|
| 536 | DspinSignals<dspin_cmd_width>** signal_dspin_h_m2p_inc = |
---|
[937] | 537 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_inc", XMAX-1, YMAX); |
---|
[628] | 538 | DspinSignals<dspin_cmd_width>** signal_dspin_h_m2p_dec = |
---|
[937] | 539 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_m2p_dec", XMAX-1, YMAX); |
---|
[628] | 540 | |
---|
| 541 | DspinSignals<dspin_rsp_width>** signal_dspin_h_p2m_inc = |
---|
[937] | 542 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_inc", XMAX-1, YMAX); |
---|
[628] | 543 | DspinSignals<dspin_rsp_width>** signal_dspin_h_p2m_dec = |
---|
[937] | 544 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_p2m_dec", XMAX-1, YMAX); |
---|
[628] | 545 | |
---|
| 546 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cla_inc = |
---|
[937] | 547 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_inc", XMAX-1, YMAX); |
---|
[628] | 548 | DspinSignals<dspin_cmd_width>** signal_dspin_h_cla_dec = |
---|
[937] | 549 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cla_dec", XMAX-1, YMAX); |
---|
[628] | 550 | |
---|
[621] | 551 | // Vertical inter-clusters DSPIN signals |
---|
[628] | 552 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cmd_inc = |
---|
[937] | 553 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", XMAX, YMAX-1); |
---|
[628] | 554 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cmd_dec = |
---|
[937] | 555 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", XMAX, YMAX-1); |
---|
[621] | 556 | |
---|
[628] | 557 | DspinSignals<dspin_rsp_width>** signal_dspin_v_rsp_inc = |
---|
[937] | 558 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", XMAX, YMAX-1); |
---|
[628] | 559 | DspinSignals<dspin_rsp_width>** signal_dspin_v_rsp_dec = |
---|
[937] | 560 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", XMAX, YMAX-1); |
---|
[621] | 561 | |
---|
[628] | 562 | DspinSignals<dspin_cmd_width>** signal_dspin_v_m2p_inc = |
---|
[937] | 563 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_m2p_inc", XMAX, YMAX-1); |
---|
[628] | 564 | DspinSignals<dspin_cmd_width>** signal_dspin_v_m2p_dec = |
---|
[937] | 565 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_m2p_dec", XMAX, YMAX-1); |
---|
[621] | 566 | |
---|
[628] | 567 | DspinSignals<dspin_rsp_width>** signal_dspin_v_p2m_inc = |
---|
[937] | 568 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_p2m_inc", XMAX, YMAX-1); |
---|
[628] | 569 | DspinSignals<dspin_rsp_width>** signal_dspin_v_p2m_dec = |
---|
[937] | 570 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_p2m_dec", XMAX, YMAX-1); |
---|
[628] | 571 | |
---|
| 572 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cla_inc = |
---|
[937] | 573 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cla_inc", XMAX, YMAX-1); |
---|
[628] | 574 | DspinSignals<dspin_cmd_width>** signal_dspin_v_cla_dec = |
---|
[937] | 575 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cla_dec", XMAX, YMAX-1); |
---|
[628] | 576 | |
---|
| 577 | // Mesh boundaries DSPIN signals (Most of those signals are not used...) |
---|
| 578 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cmd_in = |
---|
[937] | 579 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cmd_in" , XMAX, YMAX, 4); |
---|
[628] | 580 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cmd_out = |
---|
[937] | 581 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cmd_out", XMAX, YMAX, 4); |
---|
[628] | 582 | |
---|
| 583 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_rsp_in = |
---|
[937] | 584 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_rsp_in" , XMAX, YMAX, 4); |
---|
[628] | 585 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_rsp_out = |
---|
[937] | 586 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_rsp_out", XMAX, YMAX, 4); |
---|
[628] | 587 | |
---|
| 588 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_m2p_in = |
---|
[937] | 589 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_m2p_in" , XMAX, YMAX, 4); |
---|
[628] | 590 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_m2p_out = |
---|
[937] | 591 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_m2p_out", XMAX, YMAX, 4); |
---|
[628] | 592 | |
---|
| 593 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_p2m_in = |
---|
[937] | 594 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_p2m_in" , XMAX, YMAX, 4); |
---|
[628] | 595 | DspinSignals<dspin_rsp_width>*** signal_dspin_bound_p2m_out = |
---|
[937] | 596 | alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_bound_p2m_out", XMAX, YMAX, 4); |
---|
[628] | 597 | |
---|
| 598 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cla_in = |
---|
[937] | 599 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cla_in" , XMAX, YMAX, 4); |
---|
[628] | 600 | DspinSignals<dspin_cmd_width>*** signal_dspin_bound_cla_out = |
---|
[937] | 601 | alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_bound_cla_out", XMAX, YMAX, 4); |
---|
[628] | 602 | |
---|
| 603 | // VCI signals for iobus and peripherals |
---|
[967] | 604 | VciSignals<vci_param_int> signal_vci_ini_disk("signal_vci_ini_disk"); |
---|
[628] | 605 | VciSignals<vci_param_int> signal_vci_ini_cdma("signal_vci_ini_cdma"); |
---|
| 606 | VciSignals<vci_param_int> signal_vci_ini_iopi("signal_vci_ini_iopi"); |
---|
| 607 | |
---|
[792] | 608 | VciSignals<vci_param_int>* signal_vci_ini_proc = |
---|
[628] | 609 | alloc_elems<VciSignals<vci_param_int> >("signal_vci_ini_proc", NB_PROCS_MAX ); |
---|
| 610 | |
---|
| 611 | VciSignals<vci_param_int> signal_vci_tgt_memc("signal_vci_tgt_memc"); |
---|
| 612 | VciSignals<vci_param_int> signal_vci_tgt_xicu("signal_vci_tgt_xicu"); |
---|
[967] | 613 | VciSignals<vci_param_int> signal_vci_tgt_disk("signal_vci_tgt_disk"); |
---|
[628] | 614 | VciSignals<vci_param_int> signal_vci_tgt_mtty("signal_vci_tgt_mtty"); |
---|
| 615 | VciSignals<vci_param_int> signal_vci_tgt_fbuf("signal_vci_tgt_fbuf"); |
---|
| 616 | VciSignals<vci_param_int> signal_vci_tgt_mnic("signal_vci_tgt_mnic"); |
---|
| 617 | VciSignals<vci_param_int> signal_vci_tgt_cdma("signal_vci_tgt_cdma"); |
---|
| 618 | VciSignals<vci_param_int> signal_vci_tgt_iopi("signal_vci_tgt_iopi"); |
---|
| 619 | |
---|
| 620 | VciSignals<vci_param_int> signal_vci_cmd_to_noc("signal_vci_cmd_to_noc"); |
---|
| 621 | VciSignals<vci_param_int> signal_vci_cmd_from_noc("signal_vci_cmd_from_noc"); |
---|
[792] | 622 | |
---|
[621] | 623 | //////////////////////////// |
---|
[792] | 624 | // Loader |
---|
[621] | 625 | //////////////////////////// |
---|
| 626 | |
---|
[796] | 627 | #if USE_IOC_RDK |
---|
[795] | 628 | std::ostringstream ramdisk_name; |
---|
| 629 | ramdisk_name << disk_name << "@" << std::hex << SEG_RDK_BASE << ":"; |
---|
| 630 | soclib::common::Loader loader( soft_name, ramdisk_name.str().c_str() ); |
---|
[664] | 631 | #else |
---|
[692] | 632 | soclib::common::Loader loader( soft_name ); |
---|
[664] | 633 | #endif |
---|
[937] | 634 | |
---|
[939] | 635 | loader.memory_default(0x55); |
---|
[621] | 636 | |
---|
| 637 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
[630] | 638 | proc_iss::set_loader( loader ); |
---|
[621] | 639 | |
---|
[664] | 640 | ////////////////////////////////////////////////////////////// |
---|
[937] | 641 | // mesh construction: XMAX * YMAX clusters |
---|
[664] | 642 | ////////////////////////////////////////////////////////////// |
---|
[621] | 643 | |
---|
| 644 | TsarLetiCluster<dspin_cmd_width, |
---|
| 645 | dspin_rsp_width, |
---|
| 646 | vci_param_int, |
---|
[937] | 647 | vci_param_ext>* clusters[XMAX][YMAX]; |
---|
[621] | 648 | |
---|
| 649 | #if USE_OPENMP |
---|
| 650 | #pragma omp parallel |
---|
| 651 | { |
---|
| 652 | #pragma omp for |
---|
| 653 | #endif |
---|
[937] | 654 | for (size_t i = 0; i < (XMAX * YMAX); i++) |
---|
[621] | 655 | { |
---|
[937] | 656 | size_t x = i / (YMAX); |
---|
| 657 | size_t y = i % (YMAX); |
---|
[621] | 658 | |
---|
| 659 | #if USE_OPENMP |
---|
| 660 | #pragma omp critical |
---|
| 661 | { |
---|
| 662 | #endif |
---|
| 663 | std::cout << std::endl; |
---|
[792] | 664 | std::cout << "Cluster_" << std::dec << x << "_" << y |
---|
[628] | 665 | << " with cluster_xy = " << std::hex << cluster(x,y) << std::endl; |
---|
[621] | 666 | std::cout << std::endl; |
---|
| 667 | |
---|
[664] | 668 | std::ostringstream cluster_name; |
---|
| 669 | cluster_name << "cluster_" << std::dec << x << "_" << y; |
---|
| 670 | |
---|
[621] | 671 | clusters[x][y] = new TsarLetiCluster<dspin_cmd_width, |
---|
| 672 | dspin_rsp_width, |
---|
| 673 | vci_param_int, |
---|
| 674 | vci_param_ext> |
---|
| 675 | ( |
---|
[664] | 676 | cluster_name.str().c_str(), |
---|
[621] | 677 | NB_PROCS_MAX, |
---|
| 678 | x, |
---|
| 679 | y, |
---|
| 680 | cluster(x,y), |
---|
| 681 | maptabd, |
---|
| 682 | maptabx, |
---|
| 683 | RESET_ADDRESS, |
---|
| 684 | X_WIDTH, |
---|
| 685 | Y_WIDTH, |
---|
| 686 | vci_srcid_width - X_WIDTH - Y_WIDTH, // l_id width, |
---|
[803] | 687 | P_WIDTH, |
---|
[621] | 688 | MEMC_TGTID, |
---|
| 689 | XICU_TGTID, |
---|
| 690 | MTTY_TGTID, |
---|
[967] | 691 | DISK_TGTID, |
---|
[1029] | 692 | (USE_IOC_RDK == 1), |
---|
[692] | 693 | disk_name, |
---|
[621] | 694 | MEMC_WAYS, |
---|
| 695 | MEMC_SETS, |
---|
| 696 | L1_IWAYS, |
---|
| 697 | L1_ISETS, |
---|
| 698 | L1_DWAYS, |
---|
| 699 | L1_DSETS, |
---|
| 700 | XRAM_LATENCY, |
---|
| 701 | loader, |
---|
| 702 | frozen_cycles, |
---|
| 703 | trace_from, |
---|
[792] | 704 | trace_proc_ok, |
---|
[621] | 705 | trace_proc_id, |
---|
[792] | 706 | trace_memc_ok, |
---|
[621] | 707 | trace_memc_id |
---|
| 708 | ); |
---|
| 709 | |
---|
| 710 | #if USE_OPENMP |
---|
| 711 | } // end critical |
---|
| 712 | #endif |
---|
| 713 | } // end for |
---|
| 714 | #if USE_OPENMP |
---|
| 715 | } |
---|
| 716 | #endif |
---|
| 717 | |
---|
[937] | 718 | #if USE_PIC |
---|
[826] | 719 | |
---|
[628] | 720 | ////////////////////////////////////////////////////////////////// |
---|
[937] | 721 | // IO bus and external peripherals in cluster[X_SIZE-1][Y_SIZE-1] |
---|
[664] | 722 | // - 6 local targets : FBF, TTY, CMA, NIC, PIC, IOC |
---|
| 723 | // - 3 local initiators : IOC, CMA, PIC |
---|
| 724 | // There is no PROC, no MEMC and no XICU in this cluster, |
---|
| 725 | // but the crossbar has (NB_PROCS_MAX + 3) intiators and |
---|
| 726 | // 8 targets, in order to use the same SRCID and TGTID space |
---|
[792] | 727 | // (same mapping table for the internal components, |
---|
| 728 | // and for the external peripherals) |
---|
[628] | 729 | ////////////////////////////////////////////////////////////////// |
---|
[621] | 730 | |
---|
[664] | 731 | std::cout << std::endl; |
---|
| 732 | std::cout << " Building IO cluster (external peripherals)" << std::endl; |
---|
| 733 | std::cout << std::endl; |
---|
[792] | 734 | |
---|
[937] | 735 | size_t cluster_io = cluster(XMAX-1, YMAX); |
---|
[621] | 736 | |
---|
[792] | 737 | //////////// vci_local_crossbar |
---|
[628] | 738 | VciLocalCrossbar<vci_param_int>* |
---|
| 739 | iobus = new VciLocalCrossbar<vci_param_int>( |
---|
| 740 | "iobus", |
---|
| 741 | maptabd, // mapping table |
---|
| 742 | cluster_io, // cluster_xy |
---|
| 743 | NB_PROCS_MAX + 3, // number of local initiators |
---|
| 744 | 8, // number of local targets |
---|
[967] | 745 | DISK_TGTID ); // default target index |
---|
[621] | 746 | |
---|
[792] | 747 | //////////// vci_framebuffer |
---|
[628] | 748 | VciFrameBuffer<vci_param_int>* |
---|
| 749 | fbuf = new VciFrameBuffer<vci_param_int>( |
---|
| 750 | "fbuf", |
---|
| 751 | IntTab(cluster_io, FBUF_TGTID), |
---|
| 752 | maptabd, |
---|
| 753 | FBUF_X_SIZE, FBUF_Y_SIZE ); |
---|
[621] | 754 | |
---|
[967] | 755 | #if ( USE_IOC_HBA ) |
---|
| 756 | |
---|
| 757 | //////////// vci_multi_ahci |
---|
| 758 | std::vector<std::string> filenames; |
---|
| 759 | filenames.push_back(disk_name); // one single disk |
---|
| 760 | VciMultiAhci<vci_param_int>* |
---|
| 761 | disk = new VciMultiAhci<vci_param_int>( |
---|
| 762 | "disk", |
---|
| 763 | maptabd, |
---|
| 764 | IntTab(cluster_io, DISK_SRCID), |
---|
| 765 | IntTab(cluster_io, DISK_TGTID), |
---|
| 766 | filenames, |
---|
| 767 | 512, // block size |
---|
| 768 | 64, // burst size (bytes) |
---|
| 769 | 0 ); // disk latency |
---|
| 770 | |
---|
| 771 | #elif ( USE_IOC_BDV or USE_IOC_SDC ) |
---|
| 772 | |
---|
[792] | 773 | //////////// vci_block_device |
---|
[628] | 774 | VciBlockDeviceTsar<vci_param_int>* |
---|
[967] | 775 | disk = new VciBlockDeviceTsar<vci_param_int>( |
---|
| 776 | "disk", |
---|
[628] | 777 | maptabd, |
---|
[967] | 778 | IntTab(cluster_io, DISK_SRCID), |
---|
| 779 | IntTab(cluster_io, DISK_TGTID), |
---|
[692] | 780 | disk_name, |
---|
[628] | 781 | 512, // block size |
---|
[967] | 782 | 64, // burst size (bytes) |
---|
| 783 | 0 ); // disk latency |
---|
| 784 | #endif |
---|
[628] | 785 | |
---|
[792] | 786 | //////////// vci_multi_nic |
---|
[628] | 787 | VciMultiNic<vci_param_int>* |
---|
| 788 | mnic = new VciMultiNic<vci_param_int>( |
---|
[681] | 789 | "mnic", |
---|
[628] | 790 | IntTab(cluster_io, MNIC_TGTID), |
---|
| 791 | maptabd, |
---|
| 792 | NB_NIC_CHANNELS, |
---|
[937] | 793 | 0, // default MAC_4 address |
---|
| 794 | 0, // default MAC_2 address |
---|
[1004] | 795 | 1, // NIC_MODE_SYNTHESIS |
---|
| 796 | 12 ); // INTER_FRAME_GAP |
---|
[628] | 797 | |
---|
[792] | 798 | ///////////// vci_chbuf_dma |
---|
[628] | 799 | VciChbufDma<vci_param_int>* |
---|
| 800 | cdma = new VciChbufDma<vci_param_int>( |
---|
| 801 | "cdma", |
---|
| 802 | maptabd, |
---|
| 803 | IntTab(cluster_io, CDMA_SRCID), |
---|
| 804 | IntTab(cluster_io, CDMA_TGTID), |
---|
[937] | 805 | 64, // burst size |
---|
[1004] | 806 | NB_CMA_CHANNELS, |
---|
| 807 | 4 ); // number of pipelined bursts |
---|
[628] | 808 | |
---|
| 809 | ////////////// vci_multi_tty |
---|
| 810 | std::vector<std::string> vect_names; |
---|
| 811 | for (size_t id = 0; id < NB_TTY_CHANNELS; id++) |
---|
| 812 | { |
---|
| 813 | std::ostringstream term_name; |
---|
| 814 | term_name << "ext_" << id; |
---|
| 815 | vect_names.push_back(term_name.str().c_str()); |
---|
| 816 | } |
---|
| 817 | |
---|
[792] | 818 | VciMultiTty<vci_param_int>* |
---|
[628] | 819 | mtty = new VciMultiTty<vci_param_int>( |
---|
| 820 | "mtty", |
---|
| 821 | IntTab(cluster_io, MTTY_TGTID), |
---|
| 822 | maptabd, |
---|
| 823 | vect_names ); |
---|
| 824 | |
---|
| 825 | ///////////// vci_iopic |
---|
| 826 | VciIopic<vci_param_int>* |
---|
| 827 | iopic = new VciIopic<vci_param_int>( |
---|
| 828 | "iopic", |
---|
| 829 | maptabd, |
---|
| 830 | IntTab(cluster_io, IOPI_SRCID), |
---|
| 831 | IntTab(cluster_io, IOPI_TGTID), |
---|
[792] | 832 | 32 ); |
---|
[628] | 833 | |
---|
[792] | 834 | ////////////// vci_dspin wrappers |
---|
[628] | 835 | VciDspinTargetWrapper<vci_param_int, dspin_cmd_width, dspin_rsp_width>* |
---|
| 836 | wt_iobus = new VciDspinTargetWrapper<vci_param_int, dspin_cmd_width, dspin_rsp_width>( |
---|
[937] | 837 | "wt_iobus", |
---|
[628] | 838 | vci_srcid_width ); |
---|
| 839 | |
---|
| 840 | VciDspinInitiatorWrapper<vci_param_int, dspin_cmd_width, dspin_rsp_width>* |
---|
| 841 | wi_iobus = new VciDspinInitiatorWrapper<vci_param_int, dspin_cmd_width, dspin_rsp_width>( |
---|
[937] | 842 | "wi_iobus", |
---|
[628] | 843 | vci_srcid_width ); |
---|
| 844 | |
---|
| 845 | /////////////////////////////////////////////////////////////// |
---|
[937] | 846 | // IObus Net-list |
---|
[628] | 847 | /////////////////////////////////////////////////////////////// |
---|
| 848 | |
---|
[792] | 849 | // iobus |
---|
| 850 | iobus->p_clk (signal_clk); |
---|
[628] | 851 | iobus->p_resetn (signal_resetn); |
---|
| 852 | |
---|
| 853 | iobus->p_target_to_up (signal_vci_cmd_from_noc); |
---|
| 854 | iobus->p_initiator_to_up (signal_vci_cmd_to_noc); |
---|
| 855 | |
---|
| 856 | iobus->p_to_target[MEMC_TGTID] (signal_vci_tgt_memc); |
---|
| 857 | iobus->p_to_target[XICU_TGTID] (signal_vci_tgt_xicu); |
---|
| 858 | iobus->p_to_target[MTTY_TGTID] (signal_vci_tgt_mtty); |
---|
| 859 | iobus->p_to_target[FBUF_TGTID] (signal_vci_tgt_fbuf); |
---|
| 860 | iobus->p_to_target[MNIC_TGTID] (signal_vci_tgt_mnic); |
---|
[967] | 861 | iobus->p_to_target[DISK_TGTID] (signal_vci_tgt_disk); |
---|
[628] | 862 | iobus->p_to_target[CDMA_TGTID] (signal_vci_tgt_cdma); |
---|
| 863 | iobus->p_to_target[IOPI_TGTID] (signal_vci_tgt_iopi); |
---|
| 864 | |
---|
| 865 | for( size_t p=0 ; p<NB_PROCS_MAX ; p++ ) |
---|
| 866 | { |
---|
| 867 | iobus->p_to_initiator[p] (signal_vci_ini_proc[p]); |
---|
| 868 | } |
---|
[967] | 869 | iobus->p_to_initiator[DISK_SRCID] (signal_vci_ini_disk); |
---|
[628] | 870 | iobus->p_to_initiator[CDMA_SRCID] (signal_vci_ini_cdma); |
---|
| 871 | iobus->p_to_initiator[IOPI_SRCID] (signal_vci_ini_iopi); |
---|
| 872 | |
---|
| 873 | std::cout << " - IOBUS connected" << std::endl; |
---|
| 874 | |
---|
[967] | 875 | // disk |
---|
[1029] | 876 | #if ( USE_IOC_HBA or USE_IOC_BDV or USE_IOC_SDC ) |
---|
[967] | 877 | disk->p_clk (signal_clk); |
---|
| 878 | disk->p_resetn (signal_resetn); |
---|
| 879 | disk->p_vci_target (signal_vci_tgt_disk); |
---|
| 880 | disk->p_vci_initiator (signal_vci_ini_disk); |
---|
| 881 | #if USE_IOC_HBA |
---|
| 882 | disk->p_channel_irq[0] (signal_irq_disk); |
---|
| 883 | #else |
---|
| 884 | disk->p_irq (signal_irq_disk); |
---|
| 885 | #endif |
---|
[628] | 886 | |
---|
[967] | 887 | std::cout << " - DISK connected" << std::endl; |
---|
[1029] | 888 | #endif |
---|
[628] | 889 | |
---|
| 890 | // frame_buffer |
---|
| 891 | fbuf->p_clk (signal_clk); |
---|
| 892 | fbuf->p_resetn (signal_resetn); |
---|
| 893 | fbuf->p_vci (signal_vci_tgt_fbuf); |
---|
| 894 | |
---|
| 895 | std::cout << " - FBUF connected" << std::endl; |
---|
| 896 | |
---|
| 897 | // multi_nic |
---|
| 898 | mnic->p_clk (signal_clk); |
---|
| 899 | mnic->p_resetn (signal_resetn); |
---|
| 900 | mnic->p_vci (signal_vci_tgt_mnic); |
---|
| 901 | for ( size_t i=0 ; i<NB_NIC_CHANNELS ; i++ ) |
---|
| 902 | { |
---|
| 903 | mnic->p_rx_irq[i] (signal_irq_mnic_rx[i]); |
---|
| 904 | mnic->p_tx_irq[i] (signal_irq_mnic_tx[i]); |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | std::cout << " - MNIC connected" << std::endl; |
---|
| 908 | |
---|
| 909 | // chbuf_dma |
---|
| 910 | cdma->p_clk (signal_clk); |
---|
| 911 | cdma->p_resetn (signal_resetn); |
---|
| 912 | cdma->p_vci_target (signal_vci_tgt_cdma); |
---|
| 913 | cdma->p_vci_initiator (signal_vci_ini_cdma); |
---|
| 914 | for ( size_t i=0 ; i<NB_CMA_CHANNELS ; i++) |
---|
| 915 | { |
---|
| 916 | cdma->p_irq[i] (signal_irq_cdma[i]); |
---|
| 917 | } |
---|
| 918 | |
---|
| 919 | std::cout << " - CDMA connected" << std::endl; |
---|
| 920 | |
---|
| 921 | // multi_tty |
---|
| 922 | mtty->p_clk (signal_clk); |
---|
| 923 | mtty->p_resetn (signal_resetn); |
---|
| 924 | mtty->p_vci (signal_vci_tgt_mtty); |
---|
| 925 | for ( size_t i=0 ; i<NB_TTY_CHANNELS ; i++ ) |
---|
| 926 | { |
---|
[664] | 927 | mtty->p_irq[i] (signal_irq_mtty_rx[i]); |
---|
[628] | 928 | } |
---|
| 929 | |
---|
| 930 | std::cout << " - MTTY connected" << std::endl; |
---|
| 931 | |
---|
| 932 | // iopic |
---|
[664] | 933 | // NB_NIC_CHANNELS <= 2 |
---|
| 934 | // NB_CMA_CHANNELS <= 4 |
---|
[937] | 935 | // NB_TTY_CHANNELS <= 16 |
---|
[628] | 936 | iopic->p_clk (signal_clk); |
---|
| 937 | iopic->p_resetn (signal_resetn); |
---|
| 938 | iopic->p_vci_target (signal_vci_tgt_iopi); |
---|
| 939 | iopic->p_vci_initiator (signal_vci_ini_iopi); |
---|
[664] | 940 | for ( size_t i=0 ; i<32 ; i++) |
---|
[628] | 941 | { |
---|
| 942 | if (i < NB_NIC_CHANNELS) iopic->p_hwi[i] (signal_irq_mnic_rx[i]); |
---|
| 943 | else if(i < 2 ) iopic->p_hwi[i] (signal_irq_false); |
---|
| 944 | else if(i < 2+NB_NIC_CHANNELS) iopic->p_hwi[i] (signal_irq_mnic_tx[i-2]); |
---|
| 945 | else if(i < 4 ) iopic->p_hwi[i] (signal_irq_false); |
---|
| 946 | else if(i < 4+NB_CMA_CHANNELS) iopic->p_hwi[i] (signal_irq_cdma[i-4]); |
---|
[664] | 947 | else if(i < 8) iopic->p_hwi[i] (signal_irq_false); |
---|
[967] | 948 | else if(i == 8) iopic->p_hwi[i] (signal_irq_disk); |
---|
[664] | 949 | else if(i < 16) iopic->p_hwi[i] (signal_irq_false); |
---|
| 950 | else if(i < 16+NB_TTY_CHANNELS) iopic->p_hwi[i] (signal_irq_mtty_rx[i-16]); |
---|
[628] | 951 | else iopic->p_hwi[i] (signal_irq_false); |
---|
| 952 | } |
---|
| 953 | |
---|
[664] | 954 | std::cout << " - IOPIC connected" << std::endl; |
---|
| 955 | |
---|
[628] | 956 | // vci/dspin wrappers |
---|
| 957 | wi_iobus->p_clk (signal_clk); |
---|
| 958 | wi_iobus->p_resetn (signal_resetn); |
---|
| 959 | wi_iobus->p_vci (signal_vci_cmd_to_noc); |
---|
[937] | 960 | wi_iobus->p_dspin_cmd (signal_dspin_bound_cmd_in[XMAX-1][YMAX-1][NORTH]); |
---|
| 961 | wi_iobus->p_dspin_rsp (signal_dspin_bound_rsp_out[XMAX-1][YMAX-1][NORTH]); |
---|
[628] | 962 | |
---|
| 963 | // vci/dspin wrappers |
---|
| 964 | wt_iobus->p_clk (signal_clk); |
---|
| 965 | wt_iobus->p_resetn (signal_resetn); |
---|
| 966 | wt_iobus->p_vci (signal_vci_cmd_from_noc); |
---|
[937] | 967 | wt_iobus->p_dspin_cmd (signal_dspin_bound_cmd_out[XMAX-1][YMAX-1][NORTH]); |
---|
| 968 | wt_iobus->p_dspin_rsp (signal_dspin_bound_rsp_in[XMAX-1][YMAX-1][NORTH]); |
---|
[628] | 969 | |
---|
[937] | 970 | #endif // USE_PIC |
---|
[826] | 971 | |
---|
[628] | 972 | // Clock & RESET for clusters |
---|
[937] | 973 | for (size_t x = 0; x < (XMAX); x++) |
---|
[628] | 974 | { |
---|
[937] | 975 | for (size_t y = 0; y < (YMAX); y++) |
---|
[628] | 976 | { |
---|
| 977 | clusters[x][y]->p_clk (signal_clk); |
---|
| 978 | clusters[x][y]->p_resetn (signal_resetn); |
---|
| 979 | } |
---|
| 980 | } |
---|
| 981 | |
---|
| 982 | // Inter Clusters horizontal connections |
---|
[937] | 983 | if (XMAX > 1) |
---|
[628] | 984 | { |
---|
[937] | 985 | for (size_t x = 0; x < (XMAX-1); x++) |
---|
[628] | 986 | { |
---|
[937] | 987 | for (size_t y = 0; y < (YMAX); y++) |
---|
[628] | 988 | { |
---|
| 989 | clusters[x][y]->p_cmd_out[EAST] (signal_dspin_h_cmd_inc[x][y]); |
---|
| 990 | clusters[x+1][y]->p_cmd_in[WEST] (signal_dspin_h_cmd_inc[x][y]); |
---|
| 991 | clusters[x][y]->p_cmd_in[EAST] (signal_dspin_h_cmd_dec[x][y]); |
---|
| 992 | clusters[x+1][y]->p_cmd_out[WEST] (signal_dspin_h_cmd_dec[x][y]); |
---|
| 993 | |
---|
| 994 | clusters[x][y]->p_rsp_out[EAST] (signal_dspin_h_rsp_inc[x][y]); |
---|
| 995 | clusters[x+1][y]->p_rsp_in[WEST] (signal_dspin_h_rsp_inc[x][y]); |
---|
| 996 | clusters[x][y]->p_rsp_in[EAST] (signal_dspin_h_rsp_dec[x][y]); |
---|
| 997 | clusters[x+1][y]->p_rsp_out[WEST] (signal_dspin_h_rsp_dec[x][y]); |
---|
| 998 | |
---|
| 999 | clusters[x][y]->p_m2p_out[EAST] (signal_dspin_h_m2p_inc[x][y]); |
---|
| 1000 | clusters[x+1][y]->p_m2p_in[WEST] (signal_dspin_h_m2p_inc[x][y]); |
---|
| 1001 | clusters[x][y]->p_m2p_in[EAST] (signal_dspin_h_m2p_dec[x][y]); |
---|
| 1002 | clusters[x+1][y]->p_m2p_out[WEST] (signal_dspin_h_m2p_dec[x][y]); |
---|
| 1003 | |
---|
| 1004 | clusters[x][y]->p_p2m_out[EAST] (signal_dspin_h_p2m_inc[x][y]); |
---|
| 1005 | clusters[x+1][y]->p_p2m_in[WEST] (signal_dspin_h_p2m_inc[x][y]); |
---|
| 1006 | clusters[x][y]->p_p2m_in[EAST] (signal_dspin_h_p2m_dec[x][y]); |
---|
| 1007 | clusters[x+1][y]->p_p2m_out[WEST] (signal_dspin_h_p2m_dec[x][y]); |
---|
| 1008 | |
---|
| 1009 | clusters[x][y]->p_cla_out[EAST] (signal_dspin_h_cla_inc[x][y]); |
---|
| 1010 | clusters[x+1][y]->p_cla_in[WEST] (signal_dspin_h_cla_inc[x][y]); |
---|
| 1011 | clusters[x][y]->p_cla_in[EAST] (signal_dspin_h_cla_dec[x][y]); |
---|
| 1012 | clusters[x+1][y]->p_cla_out[WEST] (signal_dspin_h_cla_dec[x][y]); |
---|
[621] | 1013 | } |
---|
[628] | 1014 | } |
---|
| 1015 | } |
---|
[792] | 1016 | std::cout << std::endl << "Horizontal connections done" << std::endl; |
---|
[621] | 1017 | |
---|
[628] | 1018 | // Inter Clusters vertical connections |
---|
[937] | 1019 | if (YMAX > 1) |
---|
[628] | 1020 | { |
---|
[937] | 1021 | for (size_t y = 0; y < (YMAX-1); y++) |
---|
[628] | 1022 | { |
---|
[937] | 1023 | for (size_t x = 0; x < XMAX; x++) |
---|
[628] | 1024 | { |
---|
| 1025 | clusters[x][y]->p_cmd_out[NORTH] (signal_dspin_v_cmd_inc[x][y]); |
---|
| 1026 | clusters[x][y+1]->p_cmd_in[SOUTH] (signal_dspin_v_cmd_inc[x][y]); |
---|
| 1027 | clusters[x][y]->p_cmd_in[NORTH] (signal_dspin_v_cmd_dec[x][y]); |
---|
| 1028 | clusters[x][y+1]->p_cmd_out[SOUTH] (signal_dspin_v_cmd_dec[x][y]); |
---|
| 1029 | |
---|
| 1030 | clusters[x][y]->p_rsp_out[NORTH] (signal_dspin_v_rsp_inc[x][y]); |
---|
| 1031 | clusters[x][y+1]->p_rsp_in[SOUTH] (signal_dspin_v_rsp_inc[x][y]); |
---|
| 1032 | clusters[x][y]->p_rsp_in[NORTH] (signal_dspin_v_rsp_dec[x][y]); |
---|
| 1033 | clusters[x][y+1]->p_rsp_out[SOUTH] (signal_dspin_v_rsp_dec[x][y]); |
---|
| 1034 | |
---|
| 1035 | clusters[x][y]->p_m2p_out[NORTH] (signal_dspin_v_m2p_inc[x][y]); |
---|
| 1036 | clusters[x][y+1]->p_m2p_in[SOUTH] (signal_dspin_v_m2p_inc[x][y]); |
---|
| 1037 | clusters[x][y]->p_m2p_in[NORTH] (signal_dspin_v_m2p_dec[x][y]); |
---|
| 1038 | clusters[x][y+1]->p_m2p_out[SOUTH] (signal_dspin_v_m2p_dec[x][y]); |
---|
| 1039 | |
---|
| 1040 | clusters[x][y]->p_p2m_out[NORTH] (signal_dspin_v_p2m_inc[x][y]); |
---|
| 1041 | clusters[x][y+1]->p_p2m_in[SOUTH] (signal_dspin_v_p2m_inc[x][y]); |
---|
| 1042 | clusters[x][y]->p_p2m_in[NORTH] (signal_dspin_v_p2m_dec[x][y]); |
---|
| 1043 | clusters[x][y+1]->p_p2m_out[SOUTH] (signal_dspin_v_p2m_dec[x][y]); |
---|
| 1044 | |
---|
| 1045 | clusters[x][y]->p_cla_out[NORTH] (signal_dspin_v_cla_inc[x][y]); |
---|
| 1046 | clusters[x][y+1]->p_cla_in[SOUTH] (signal_dspin_v_cla_inc[x][y]); |
---|
| 1047 | clusters[x][y]->p_cla_in[NORTH] (signal_dspin_v_cla_dec[x][y]); |
---|
| 1048 | clusters[x][y+1]->p_cla_out[SOUTH] (signal_dspin_v_cla_dec[x][y]); |
---|
[621] | 1049 | } |
---|
[628] | 1050 | } |
---|
| 1051 | } |
---|
| 1052 | std::cout << std::endl << "Vertical connections done" << std::endl; |
---|
[621] | 1053 | |
---|
[628] | 1054 | // East & West boundary cluster connections |
---|
[937] | 1055 | for (size_t y = 0; y < (YMAX); y++) |
---|
[628] | 1056 | { |
---|
| 1057 | clusters[0][y]->p_cmd_in[WEST] (signal_dspin_bound_cmd_in[0][y][WEST]); |
---|
| 1058 | clusters[0][y]->p_cmd_out[WEST] (signal_dspin_bound_cmd_out[0][y][WEST]); |
---|
[937] | 1059 | clusters[XMAX-1][y]->p_cmd_in[EAST] (signal_dspin_bound_cmd_in[XMAX-1][y][EAST]); |
---|
| 1060 | clusters[XMAX-1][y]->p_cmd_out[EAST] (signal_dspin_bound_cmd_out[XMAX-1][y][EAST]); |
---|
[621] | 1061 | |
---|
[628] | 1062 | clusters[0][y]->p_rsp_in[WEST] (signal_dspin_bound_rsp_in[0][y][WEST]); |
---|
| 1063 | clusters[0][y]->p_rsp_out[WEST] (signal_dspin_bound_rsp_out[0][y][WEST]); |
---|
[937] | 1064 | clusters[XMAX-1][y]->p_rsp_in[EAST] (signal_dspin_bound_rsp_in[XMAX-1][y][EAST]); |
---|
| 1065 | clusters[XMAX-1][y]->p_rsp_out[EAST] (signal_dspin_bound_rsp_out[XMAX-1][y][EAST]); |
---|
[621] | 1066 | |
---|
[628] | 1067 | clusters[0][y]->p_m2p_in[WEST] (signal_dspin_bound_m2p_in[0][y][WEST]); |
---|
| 1068 | clusters[0][y]->p_m2p_out[WEST] (signal_dspin_bound_m2p_out[0][y][WEST]); |
---|
[937] | 1069 | clusters[XMAX-1][y]->p_m2p_in[EAST] (signal_dspin_bound_m2p_in[XMAX-1][y][EAST]); |
---|
| 1070 | clusters[XMAX-1][y]->p_m2p_out[EAST] (signal_dspin_bound_m2p_out[XMAX-1][y][EAST]); |
---|
[621] | 1071 | |
---|
[628] | 1072 | clusters[0][y]->p_p2m_in[WEST] (signal_dspin_bound_p2m_in[0][y][WEST]); |
---|
| 1073 | clusters[0][y]->p_p2m_out[WEST] (signal_dspin_bound_p2m_out[0][y][WEST]); |
---|
[937] | 1074 | clusters[XMAX-1][y]->p_p2m_in[EAST] (signal_dspin_bound_p2m_in[XMAX-1][y][EAST]); |
---|
| 1075 | clusters[XMAX-1][y]->p_p2m_out[EAST] (signal_dspin_bound_p2m_out[XMAX-1][y][EAST]); |
---|
[621] | 1076 | |
---|
[628] | 1077 | clusters[0][y]->p_cla_in[WEST] (signal_dspin_bound_cla_in[0][y][WEST]); |
---|
| 1078 | clusters[0][y]->p_cla_out[WEST] (signal_dspin_bound_cla_out[0][y][WEST]); |
---|
[937] | 1079 | clusters[XMAX-1][y]->p_cla_in[EAST] (signal_dspin_bound_cla_in[XMAX-1][y][EAST]); |
---|
| 1080 | clusters[XMAX-1][y]->p_cla_out[EAST] (signal_dspin_bound_cla_out[XMAX-1][y][EAST]); |
---|
[628] | 1081 | } |
---|
[621] | 1082 | |
---|
[664] | 1083 | std::cout << std::endl << "West & East boundaries connections done" << std::endl; |
---|
| 1084 | |
---|
[628] | 1085 | // North & South boundary clusters connections |
---|
[937] | 1086 | for (size_t x = 0; x < XMAX; x++) |
---|
[628] | 1087 | { |
---|
| 1088 | clusters[x][0]->p_cmd_in[SOUTH] (signal_dspin_bound_cmd_in[x][0][SOUTH]); |
---|
| 1089 | clusters[x][0]->p_cmd_out[SOUTH] (signal_dspin_bound_cmd_out[x][0][SOUTH]); |
---|
[937] | 1090 | clusters[x][YMAX-1]->p_cmd_in[NORTH] (signal_dspin_bound_cmd_in[x][YMAX-1][NORTH]); |
---|
| 1091 | clusters[x][YMAX-1]->p_cmd_out[NORTH] (signal_dspin_bound_cmd_out[x][YMAX-1][NORTH]); |
---|
[621] | 1092 | |
---|
[628] | 1093 | clusters[x][0]->p_rsp_in[SOUTH] (signal_dspin_bound_rsp_in[x][0][SOUTH]); |
---|
| 1094 | clusters[x][0]->p_rsp_out[SOUTH] (signal_dspin_bound_rsp_out[x][0][SOUTH]); |
---|
[937] | 1095 | clusters[x][YMAX-1]->p_rsp_in[NORTH] (signal_dspin_bound_rsp_in[x][YMAX-1][NORTH]); |
---|
| 1096 | clusters[x][YMAX-1]->p_rsp_out[NORTH] (signal_dspin_bound_rsp_out[x][YMAX-1][NORTH]); |
---|
[621] | 1097 | |
---|
[628] | 1098 | clusters[x][0]->p_m2p_in[SOUTH] (signal_dspin_bound_m2p_in[x][0][SOUTH]); |
---|
| 1099 | clusters[x][0]->p_m2p_out[SOUTH] (signal_dspin_bound_m2p_out[x][0][SOUTH]); |
---|
[937] | 1100 | clusters[x][YMAX-1]->p_m2p_in[NORTH] (signal_dspin_bound_m2p_in[x][YMAX-1][NORTH]); |
---|
| 1101 | clusters[x][YMAX-1]->p_m2p_out[NORTH] (signal_dspin_bound_m2p_out[x][YMAX-1][NORTH]); |
---|
[621] | 1102 | |
---|
[628] | 1103 | clusters[x][0]->p_p2m_in[SOUTH] (signal_dspin_bound_p2m_in[x][0][SOUTH]); |
---|
| 1104 | clusters[x][0]->p_p2m_out[SOUTH] (signal_dspin_bound_p2m_out[x][0][SOUTH]); |
---|
[937] | 1105 | clusters[x][YMAX-1]->p_p2m_in[NORTH] (signal_dspin_bound_p2m_in[x][YMAX-1][NORTH]); |
---|
| 1106 | clusters[x][YMAX-1]->p_p2m_out[NORTH] (signal_dspin_bound_p2m_out[x][YMAX-1][NORTH]); |
---|
[628] | 1107 | |
---|
| 1108 | clusters[x][0]->p_cla_in[SOUTH] (signal_dspin_bound_cla_in[x][0][SOUTH]); |
---|
| 1109 | clusters[x][0]->p_cla_out[SOUTH] (signal_dspin_bound_cla_out[x][0][SOUTH]); |
---|
[937] | 1110 | clusters[x][YMAX-1]->p_cla_in[NORTH] (signal_dspin_bound_cla_in[x][YMAX-1][NORTH]); |
---|
| 1111 | clusters[x][YMAX-1]->p_cla_out[NORTH] (signal_dspin_bound_cla_out[x][YMAX-1][NORTH]); |
---|
[628] | 1112 | } |
---|
| 1113 | |
---|
[664] | 1114 | std::cout << std::endl << "North & South boundaries connections done" << std::endl; |
---|
| 1115 | |
---|
[628] | 1116 | std::cout << std::endl; |
---|
| 1117 | |
---|
| 1118 | //////////////////////////////////////////////////////// |
---|
| 1119 | // Simulation |
---|
| 1120 | /////////////////////////////////////////////////////// |
---|
| 1121 | |
---|
| 1122 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
| 1123 | signal_resetn = false; |
---|
| 1124 | signal_irq_false = false; |
---|
| 1125 | |
---|
| 1126 | // set network boundaries signals default values |
---|
| 1127 | // for all boundary clusters but the IO cluster |
---|
[937] | 1128 | for (size_t x = 0; x < XMAX ; x++) |
---|
[628] | 1129 | { |
---|
[937] | 1130 | for (size_t y = 0; y < YMAX ; y++) |
---|
[628] | 1131 | { |
---|
| 1132 | for (size_t face = 0; face < 4; face++) |
---|
| 1133 | { |
---|
[937] | 1134 | if ( (x != XMAX-1) or (y != YMAX-1) or (face != NORTH) ) |
---|
[628] | 1135 | { |
---|
| 1136 | signal_dspin_bound_cmd_in [x][y][face].write = false; |
---|
| 1137 | signal_dspin_bound_cmd_in [x][y][face].read = true; |
---|
| 1138 | signal_dspin_bound_cmd_out[x][y][face].write = false; |
---|
| 1139 | signal_dspin_bound_cmd_out[x][y][face].read = true; |
---|
| 1140 | |
---|
| 1141 | signal_dspin_bound_rsp_in [x][y][face].write = false; |
---|
| 1142 | signal_dspin_bound_rsp_in [x][y][face].read = true; |
---|
| 1143 | signal_dspin_bound_rsp_out[x][y][face].write = false; |
---|
| 1144 | signal_dspin_bound_rsp_out[x][y][face].read = true; |
---|
| 1145 | } |
---|
| 1146 | |
---|
| 1147 | signal_dspin_bound_m2p_in [x][y][face].write = false; |
---|
| 1148 | signal_dspin_bound_m2p_in [x][y][face].read = true; |
---|
| 1149 | signal_dspin_bound_m2p_out[x][y][face].write = false; |
---|
| 1150 | signal_dspin_bound_m2p_out[x][y][face].read = true; |
---|
| 1151 | |
---|
| 1152 | signal_dspin_bound_p2m_in [x][y][face].write = false; |
---|
| 1153 | signal_dspin_bound_p2m_in [x][y][face].read = true; |
---|
| 1154 | signal_dspin_bound_p2m_out[x][y][face].write = false; |
---|
| 1155 | signal_dspin_bound_p2m_out[x][y][face].read = true; |
---|
| 1156 | |
---|
| 1157 | signal_dspin_bound_cla_in [x][y][face].write = false; |
---|
| 1158 | signal_dspin_bound_cla_in [x][y][face].read = true; |
---|
| 1159 | signal_dspin_bound_cla_out[x][y][face].write = false; |
---|
| 1160 | signal_dspin_bound_cla_out[x][y][face].read = true; |
---|
[621] | 1161 | } |
---|
[628] | 1162 | } |
---|
| 1163 | } |
---|
[621] | 1164 | |
---|
[826] | 1165 | #if USE_PIC == 0 |
---|
[937] | 1166 | signal_dspin_bound_cmd_in[XMAX-1][YMAX-1][NORTH].write = false; |
---|
| 1167 | signal_dspin_bound_rsp_out[XMAX-1][YMAX-1][NORTH].read = true; |
---|
| 1168 | signal_dspin_bound_cmd_out[XMAX-1][YMAX-1][NORTH].read = true; |
---|
| 1169 | signal_dspin_bound_rsp_in[XMAX-1][YMAX-1][NORTH].write = false; |
---|
[826] | 1170 | #endif |
---|
| 1171 | |
---|
[792] | 1172 | // set default values for VCI signals connected to unused ports on iobus |
---|
[664] | 1173 | signal_vci_tgt_memc.rspval = false; |
---|
| 1174 | signal_vci_tgt_xicu.rspval = false; |
---|
| 1175 | for ( size_t p = 0 ; p < NB_PROCS_MAX ; p++ ) signal_vci_ini_proc[p].cmdval = false; |
---|
| 1176 | |
---|
[628] | 1177 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 1178 | signal_resetn = true; |
---|
[621] | 1179 | |
---|
[792] | 1180 | if (gettimeofday(&t1, NULL) != 0) |
---|
[628] | 1181 | { |
---|
| 1182 | perror("gettimeofday"); |
---|
| 1183 | return EXIT_FAILURE; |
---|
| 1184 | } |
---|
[621] | 1185 | |
---|
[937] | 1186 | // simulation loop |
---|
[664] | 1187 | for (uint64_t n = 1; n < ncycles && !stop_called; n++) |
---|
| 1188 | { |
---|
[937] | 1189 | // Monitor a specific address for L1 cache |
---|
[664] | 1190 | // clusters[0][0]->proc[0]->cache_monitor(0x110002C078ULL); |
---|
[621] | 1191 | |
---|
[937] | 1192 | // Monitor a specific address for L2 cache |
---|
[939] | 1193 | // clusters[0][0]->memc->cache_monitor( 0x0000201E00ULL ); |
---|
[937] | 1194 | |
---|
| 1195 | // Monitor a specific address for one XRAM |
---|
[939] | 1196 | // clusters[0][0]->xram->start_monitor( 0x0000201E00ULL , 64); |
---|
[937] | 1197 | |
---|
[664] | 1198 | // stats display |
---|
| 1199 | if( (n % 5000000) == 0) |
---|
| 1200 | { |
---|
[621] | 1201 | |
---|
[792] | 1202 | if (gettimeofday(&t2, NULL) != 0) |
---|
[664] | 1203 | { |
---|
| 1204 | perror("gettimeofday"); |
---|
| 1205 | return EXIT_FAILURE; |
---|
| 1206 | } |
---|
[621] | 1207 | |
---|
[664] | 1208 | ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000; |
---|
| 1209 | ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000; |
---|
[792] | 1210 | std::cerr << "platform clock frequency " |
---|
[664] | 1211 | << (double) 5000000 / (double) (ms2 - ms1) << "Khz" << std::endl; |
---|
[621] | 1212 | |
---|
[792] | 1213 | if (gettimeofday(&t1, NULL) != 0) |
---|
[664] | 1214 | { |
---|
| 1215 | perror("gettimeofday"); |
---|
| 1216 | return EXIT_FAILURE; |
---|
| 1217 | } |
---|
| 1218 | } |
---|
[621] | 1219 | |
---|
[664] | 1220 | // trace display |
---|
| 1221 | if ( trace_ok and (n > trace_from) ) |
---|
| 1222 | { |
---|
| 1223 | std::cout << "****************** cycle " << std::dec << n ; |
---|
[937] | 1224 | std::cout << " ********************************************" << std::endl; |
---|
[621] | 1225 | |
---|
[664] | 1226 | size_t l = 0; |
---|
| 1227 | size_t x = 0; |
---|
| 1228 | size_t y = 0; |
---|
[621] | 1229 | |
---|
[664] | 1230 | if ( trace_proc_ok ) |
---|
| 1231 | { |
---|
[803] | 1232 | l = trace_proc_id & ((1<<P_WIDTH)-1) ; |
---|
| 1233 | x = (trace_proc_id >> P_WIDTH) >> Y_WIDTH ; |
---|
| 1234 | y = (trace_proc_id >> P_WIDTH) & ((1<<Y_WIDTH) - 1); |
---|
[621] | 1235 | |
---|
[664] | 1236 | std::ostringstream proc_signame; |
---|
| 1237 | proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ; |
---|
[681] | 1238 | clusters[x][y]->proc[l]->print_trace(1); |
---|
[664] | 1239 | clusters[x][y]->signal_vci_ini_proc[l].print_trace(proc_signame.str()); |
---|
[628] | 1240 | |
---|
[664] | 1241 | std::ostringstream xicu_signame; |
---|
| 1242 | xicu_signame << "[SIG]XICU_" << x << "_" << y ; |
---|
| 1243 | clusters[x][y]->xicu->print_trace(0); |
---|
| 1244 | clusters[x][y]->signal_vci_tgt_xicu.print_trace(xicu_signame.str()); |
---|
[937] | 1245 | |
---|
| 1246 | if ( clusters[x][y]->signal_proc_irq[0] ) |
---|
| 1247 | std::cout << "### IRQ_PROC_" << x << "_" << y << "_0" << std::endl; |
---|
| 1248 | if ( clusters[x][y]->signal_proc_irq[4] ) |
---|
| 1249 | std::cout << "### IRQ_PROC_" << x << "_" << y << "_1" << std::endl; |
---|
| 1250 | if ( clusters[x][y]->signal_proc_irq[8] ) |
---|
| 1251 | std::cout << "### IRQ_PROC_" << x << "_" << y << "_2" << std::endl; |
---|
| 1252 | if ( clusters[x][y]->signal_proc_irq[12] ) |
---|
| 1253 | std::cout << "### IRQ_PROC_" << x << "_" << y << "_3" << std::endl; |
---|
[664] | 1254 | } |
---|
[628] | 1255 | |
---|
[664] | 1256 | if ( trace_memc_ok ) |
---|
| 1257 | { |
---|
| 1258 | x = trace_memc_id >> Y_WIDTH; |
---|
| 1259 | y = trace_memc_id & ((1<<Y_WIDTH) - 1); |
---|
| 1260 | |
---|
| 1261 | std::ostringstream smemc; |
---|
| 1262 | smemc << "[SIG]MEMC_" << x << "_" << y; |
---|
| 1263 | std::ostringstream sxram; |
---|
| 1264 | sxram << "[SIG]XRAM_" << x << "_" << y; |
---|
| 1265 | |
---|
| 1266 | clusters[x][y]->memc->print_trace(); |
---|
| 1267 | clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str()); |
---|
| 1268 | clusters[x][y]->signal_vci_xram.print_trace(sxram.str()); |
---|
[792] | 1269 | } |
---|
[664] | 1270 | |
---|
| 1271 | // trace coherence signals |
---|
| 1272 | // clusters[0][0]->signal_dspin_m2p_proc[0].print_trace("[CC_M2P_0_0]"); |
---|
| 1273 | // clusters[0][1]->signal_dspin_m2p_proc[0].print_trace("[CC_M2P_0_1]"); |
---|
| 1274 | // clusters[1][0]->signal_dspin_m2p_proc[0].print_trace("[CC_M2P_1_0]"); |
---|
| 1275 | // clusters[1][1]->signal_dspin_m2p_proc[0].print_trace("[CC_M2P_1_1]"); |
---|
| 1276 | |
---|
| 1277 | // clusters[0][0]->signal_dspin_p2m_proc[0].print_trace("[CC_P2M_0_0]"); |
---|
| 1278 | // clusters[0][1]->signal_dspin_p2m_proc[0].print_trace("[CC_P2M_0_1]"); |
---|
| 1279 | // clusters[1][0]->signal_dspin_p2m_proc[0].print_trace("[CC_P2M_1_0]"); |
---|
| 1280 | // clusters[1][1]->signal_dspin_p2m_proc[0].print_trace("[CC_P2M_1_1]"); |
---|
| 1281 | |
---|
| 1282 | // trace xbar(s) m2p |
---|
| 1283 | // clusters[0][0]->xbar_m2p->print_trace(); |
---|
| 1284 | // clusters[1][0]->xbar_m2p->print_trace(); |
---|
| 1285 | // clusters[0][1]->xbar_m2p->print_trace(); |
---|
| 1286 | // clusters[1][1]->xbar_m2p->print_trace(); |
---|
[792] | 1287 | |
---|
[664] | 1288 | // trace router(s) m2p |
---|
| 1289 | // clusters[0][0]->router_m2p->print_trace(); |
---|
| 1290 | // clusters[1][0]->router_m2p->print_trace(); |
---|
| 1291 | // clusters[0][1]->router_m2p->print_trace(); |
---|
| 1292 | // clusters[1][1]->router_m2p->print_trace(); |
---|
[792] | 1293 | |
---|
[1029] | 1294 | #if ( USE_IOC_HBA or USE_IOC_BDV or USE_IOC_SDC ) |
---|
[826] | 1295 | #if USE_PIC |
---|
[664] | 1296 | // trace external ioc |
---|
[967] | 1297 | disk->print_trace(); |
---|
| 1298 | signal_vci_tgt_disk.print_trace("[SIG]DISK_TGT"); |
---|
| 1299 | signal_vci_ini_disk.print_trace("[SIG]DISK_INI"); |
---|
[621] | 1300 | |
---|
[664] | 1301 | // trace external iopic |
---|
| 1302 | iopic->print_trace(); |
---|
| 1303 | signal_vci_tgt_iopi.print_trace("[SIG]IOPI_TGT"); |
---|
| 1304 | signal_vci_ini_iopi.print_trace("[SIG]IOPI_INI"); |
---|
[937] | 1305 | |
---|
| 1306 | // trace external interrupts |
---|
[967] | 1307 | if (signal_irq_disk) std::cout << "### IRQ_DISK" << std::endl; |
---|
[897] | 1308 | #else |
---|
[967] | 1309 | clusters[0][0]->disk->print_trace(); |
---|
| 1310 | clusters[0][0]->signal_vci_tgt_disk.print_trace("[SIG]DISK_0_0"); |
---|
| 1311 | clusters[0][0]->signal_vci_ini_disk.print_trace("[SIG]DISK_0_0"); |
---|
[826] | 1312 | #endif |
---|
[1029] | 1313 | #endif |
---|
[621] | 1314 | |
---|
[664] | 1315 | } // end trace |
---|
[621] | 1316 | |
---|
[664] | 1317 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
| 1318 | } |
---|
| 1319 | // Free memory |
---|
[951] | 1320 | for (size_t i = 0 ; i < (XMAX * YMAX) ; i++) |
---|
[664] | 1321 | { |
---|
[951] | 1322 | size_t x = i / (YMAX); |
---|
| 1323 | size_t y = i % (YMAX); |
---|
[664] | 1324 | delete clusters[x][y]; |
---|
| 1325 | } |
---|
| 1326 | |
---|
| 1327 | return EXIT_SUCCESS; |
---|
[621] | 1328 | } |
---|
| 1329 | |
---|
[792] | 1330 | void handler(int dummy = 0) |
---|
[628] | 1331 | { |
---|
[621] | 1332 | stop_called = true; |
---|
| 1333 | sc_stop(); |
---|
| 1334 | } |
---|
| 1335 | |
---|
| 1336 | void voidhandler(int dummy = 0) {} |
---|
| 1337 | |
---|
| 1338 | int sc_main (int argc, char *argv[]) |
---|
| 1339 | { |
---|
| 1340 | signal(SIGINT, handler); |
---|
| 1341 | signal(SIGPIPE, voidhandler); |
---|
| 1342 | |
---|
| 1343 | try { |
---|
| 1344 | return _main(argc, argv); |
---|
| 1345 | } catch (std::exception &e) { |
---|
| 1346 | std::cout << e.what() << std::endl; |
---|
| 1347 | } catch (...) { |
---|
| 1348 | std::cout << "Unknown exception occured" << std::endl; |
---|
| 1349 | throw; |
---|
| 1350 | } |
---|
| 1351 | return 1; |
---|
| 1352 | } |
---|
| 1353 | |
---|
| 1354 | |
---|
| 1355 | // Local Variables: |
---|
| 1356 | // tab-width: 3 |
---|
| 1357 | // c-basic-offset: 3 |
---|
| 1358 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 1359 | // indent-tabs-mode: nil |
---|
| 1360 | // End: |
---|
| 1361 | |
---|
| 1362 | // vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3 |
---|