| 1 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // File: tsarv4_vgmn_generic_32_top.cpp |
|---|
| 3 | // Author: Alain Greiner |
|---|
| 4 | // Copyright: UPMC/LIP6 |
|---|
| 5 | // Date : november 5 2010 |
|---|
| 6 | // This program is released under the GNU public license |
|---|
| 7 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 8 | // This file define a generic TSAR architecture without virtual memory. |
|---|
| 9 | // - It uses the vci_vgmn as global interconnect |
|---|
| 10 | // - It uses the vci_local_crossbar as local interconnect |
|---|
| 11 | // - It uses the vci_cc_xcache (No MMU) |
|---|
| 12 | // The physical address space is 32 bits. |
|---|
| 13 | // The number of clusters cannot be larger than 256. |
|---|
| 14 | // The three parameters are |
|---|
| 15 | // - xmax : number of clusters in a row |
|---|
| 16 | // - ymax : number of clusters in a column |
|---|
| 17 | // - nprocs : number of processor per cluster |
|---|
| 18 | // |
|---|
| 19 | // Each cluster contains nprocs processors, one Memory Cache, |
|---|
| 20 | // and one XICU component. |
|---|
| 21 | // The peripherals BDEV, CDMA, FBUF, MTTY and the boot BROM |
|---|
| 22 | // are in the cluster containing address 0xBFC00000. |
|---|
| 23 | // - The bdev_irq is connected to IRQ_IN[0] |
|---|
| 24 | // - The cdma_irq is connected to IRQ_IN[1] |
|---|
| 25 | // - The tty_irq[i] is connected to IRQ_IN[i+2] |
|---|
| 26 | // For all clusters, the XICU component contains nprocs timers. |
|---|
| 27 | // |
|---|
| 28 | // As we target up to 256 clusters, each cluster can contain |
|---|
| 29 | // at most 16 Mbytes (in a 4Gbytes address space). |
|---|
| 30 | // - Each memory cache contains 9 Mbytes. |
|---|
| 31 | // - The Frame buffer contains 2 Mbytes. |
|---|
| 32 | // - The Boot ROM contains 1 Mbytes. |
|---|
| 33 | // |
|---|
| 34 | // General policy for 32 bits address decoding: |
|---|
| 35 | // To simplifly, all segments base addresses are aligned |
|---|
| 36 | // on 1 Mbyte addresses. Therefore the 12 address MSB bits |
|---|
| 37 | // define the target in the direct address space. |
|---|
| 38 | // In these 12 bits, the (x_width + y_width) MSB bits define |
|---|
| 39 | // the cluster index, and the 4 LSB bits define the local index: |
|---|
| 40 | // |
|---|
| 41 | // | X_ID | Y_ID |---| L_ID | OFFSET | |
|---|
| 42 | // |x_width|y_width|---| 4 | 20 | |
|---|
| 43 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 44 | |
|---|
| 45 | #include <systemc> |
|---|
| 46 | #include <sys/time.h> |
|---|
| 47 | #include <iostream> |
|---|
| 48 | #include <sstream> |
|---|
| 49 | #include <cstdlib> |
|---|
| 50 | #include <cstdarg> |
|---|
| 51 | #include <stdint.h> |
|---|
| 52 | |
|---|
| 53 | #include "mapping_table.h" |
|---|
| 54 | #include "mips32.h" |
|---|
| 55 | #include "vci_simple_ram.h" |
|---|
| 56 | #include "vci_multi_tty.h" |
|---|
| 57 | #include "vci_mem_cache_v4.h" |
|---|
| 58 | #include "vci_cc_vcache_wrapper_v4.h" |
|---|
| 59 | //#include "vci_xicu.h" |
|---|
| 60 | #include "vci_multi_icu.h" |
|---|
| 61 | #include "vci_vgmn.h" |
|---|
| 62 | #include "vci_framebuffer.h" |
|---|
| 63 | #include "vci_dma_tsar_v2.h" |
|---|
| 64 | #include "vci_block_device_tsar_v4.h" |
|---|
| 65 | //#include "vci_block_device.h" |
|---|
| 66 | //#include "vci_io_bridge.h" |
|---|
| 67 | #include "gdbserver.h" |
|---|
| 68 | |
|---|
| 69 | //#define SECTOR_SIZE 2048 |
|---|
| 70 | #define SECTOR_SIZE 512 |
|---|
| 71 | |
|---|
| 72 | #define FBUF_XSIZE 128 |
|---|
| 73 | #define FBUF_YSIZE 128 |
|---|
| 74 | |
|---|
| 75 | #define NB_TTYS 9 |
|---|
| 76 | |
|---|
| 77 | ////////////////////////////////////////////// |
|---|
| 78 | // segments definition in direct space. |
|---|
| 79 | // There is 16 Mbytes address space per cluster. |
|---|
| 80 | // The 8 MSB bits define the cluster index (x,y), |
|---|
| 81 | // even if the number of clusters is less than 256. |
|---|
| 82 | // Each memory cache contains up to 9 Mbytes. |
|---|
| 83 | // There is one MEMC segment and one XICU segment per cluster |
|---|
| 84 | // The peripherals BDEV, FBUF, MTTY, CDMA and the boot BROM |
|---|
| 85 | // are mapped in cluster containing address 0xBFC00000 |
|---|
| 86 | |
|---|
| 87 | //#define MEMC_BASE 0x00000000 |
|---|
| 88 | //#define MEMC_SIZE 0x00900000 |
|---|
| 89 | |
|---|
| 90 | #define BROM_BASE 0xBFC00000 |
|---|
| 91 | #define BROM_SIZE 0x00010000 |
|---|
| 92 | |
|---|
| 93 | #define USER_BASE 0x00000000 |
|---|
| 94 | #define USER_SIZE 0x01000000 |
|---|
| 95 | |
|---|
| 96 | #define KERNEL_BASE 0x80000000 |
|---|
| 97 | #define KERNEL_SIZE 0x00100000 |
|---|
| 98 | |
|---|
| 99 | //#define XICU_BASE 0x00900000 |
|---|
| 100 | //#define XICU_SIZE 0x00001000 |
|---|
| 101 | |
|---|
| 102 | #define MTTY_BASE 0x90000000 |
|---|
| 103 | #define MTTY_SIZE 0x00000200 |
|---|
| 104 | |
|---|
| 105 | #define TIM_BASE 0x91000000 |
|---|
| 106 | #define TIM_SIZE 0x00000080 |
|---|
| 107 | |
|---|
| 108 | #define BDEV_BASE 0x92000000 |
|---|
| 109 | #define BDEV_SIZE 0x00000020 |
|---|
| 110 | |
|---|
| 111 | #define CDMA_BASE 0x93000000 |
|---|
| 112 | #define CDMA_SIZE 0x00000100 |
|---|
| 113 | |
|---|
| 114 | #define FBUF_BASE 0x96000000 |
|---|
| 115 | #define FBUF_SIZE 0x00004000 |
|---|
| 116 | |
|---|
| 117 | //#define IOB_BASE 0x9E000000 |
|---|
| 118 | //#define IOB_SIZE 0x00000100 |
|---|
| 119 | |
|---|
| 120 | #define ICU_BASE 0x9F000000 |
|---|
| 121 | #define ICU_SIZE 0x00000100 |
|---|
| 122 | |
|---|
| 123 | /* Pour ALMOS |
|---|
| 124 | |
|---|
| 125 | #define BOOT_INFO_BLOCK 0xbfc08000 |
|---|
| 126 | #define KERNEL_BIN_IMG 0xbfc10000 |
|---|
| 127 | |
|---|
| 128 | */ |
|---|
| 129 | |
|---|
| 130 | //////////////////////////////////////////////////////////////////// |
|---|
| 131 | // TGTID & SRCID definition in direct space |
|---|
| 132 | // For all components: global TGTID = global SRCID = cluster_index |
|---|
| 133 | // For processors, the local SRCID is between 0 & nprocs-1 |
|---|
| 134 | |
|---|
| 135 | #define PROC_SRCID 0 |
|---|
| 136 | #define BDEV_SRCID 1 |
|---|
| 137 | #define CDMA_SRCID 2 |
|---|
| 138 | |
|---|
| 139 | #define MEMC_TGTID 4 |
|---|
| 140 | #define BROM_TGTID 1 |
|---|
| 141 | //#define XICU_TGTID 2 |
|---|
| 142 | #define ICU_TGTID 2 |
|---|
| 143 | #define MTTY_TGTID 3 |
|---|
| 144 | //#define IOB_TGTID 0 |
|---|
| 145 | #define BDEV_TGTID 0 |
|---|
| 146 | #define CDMA_TGTID 5 |
|---|
| 147 | #define FBUF_TGTID 6 |
|---|
| 148 | |
|---|
| 149 | //////////////////////////////////////////////////////////////////// |
|---|
| 150 | // TGTID & SRCID definition in IO space |
|---|
| 151 | |
|---|
| 152 | //#define IOB_TGTID_IO 0 |
|---|
| 153 | //#define BDEV_TGTID_IO 1 |
|---|
| 154 | //#define CDMA_TGTID_IO 2 |
|---|
| 155 | //#define FBUF_TGTID_IO 3 |
|---|
| 156 | |
|---|
| 157 | //#define IOB_SRCID_IO 0 |
|---|
| 158 | //#define BDEV_SRCID_IO 1 |
|---|
| 159 | //#define CDMA_SRCID_IO 2 |
|---|
| 160 | |
|---|
| 161 | //////////////////////////////////////////////////////// |
|---|
| 162 | // TGTID & SRCID definition in coherence space |
|---|
| 163 | // For all components: global TGTID = global SRCID = cluster_index |
|---|
| 164 | // For MEMC : local SRCID = local TGTID = nprocs |
|---|
| 165 | // For processors : local SRCID = local TGTID = PROC_ID |
|---|
| 166 | |
|---|
| 167 | /////////////// |
|---|
| 168 | // VCI format |
|---|
| 169 | #define cell_width 4 |
|---|
| 170 | #define address_width 32 // 40 Ã terme |
|---|
| 171 | #define address_width_io 32 |
|---|
| 172 | #define plen_width 8 |
|---|
| 173 | #define error_width 1 |
|---|
| 174 | #define clen_width 1 |
|---|
| 175 | #define rflag_width 1 |
|---|
| 176 | #define srcid_width 14 |
|---|
| 177 | #define pktid_width 4 |
|---|
| 178 | #define trdid_width 4 |
|---|
| 179 | #define wrplen_width 1 |
|---|
| 180 | |
|---|
| 181 | // cluster index (computed from x,y coordinates) |
|---|
| 182 | #define cluster(x,y) (y + ymax*x) |
|---|
| 183 | |
|---|
| 184 | ///////////////////////////////// |
|---|
| 185 | int _main(int argc, char *argv[]) |
|---|
| 186 | { |
|---|
| 187 | using namespace sc_core; |
|---|
| 188 | using namespace soclib::caba; |
|---|
| 189 | using namespace soclib::common; |
|---|
| 190 | |
|---|
| 191 | char soft_name[128] = "giet_vm171/soft.elf"; // pathname to binary code |
|---|
| 192 | char disk_name[128] = "giet_vm171/apps/display/images.raw"; // pathname to the disk image |
|---|
| 193 | size_t ncycles = 1000000000; // simulated cycles |
|---|
| 194 | size_t nprocs = 1; // number of processors per cluster |
|---|
| 195 | bool debug_ok = false; // debug activated |
|---|
| 196 | size_t from_cycle = 0; // debug start cycle |
|---|
| 197 | size_t to_cycle = 1000000000; // debug end cycle |
|---|
| 198 | |
|---|
| 199 | ////////////// command line arguments ////////////////////// |
|---|
| 200 | if (argc > 1) |
|---|
| 201 | { |
|---|
| 202 | for( int n=1 ; n<argc ; n=n+2 ) |
|---|
| 203 | { |
|---|
| 204 | if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) ) |
|---|
| 205 | { |
|---|
| 206 | ncycles = atoi(argv[n+1]); |
|---|
| 207 | } |
|---|
| 208 | else if( (strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc) ) |
|---|
| 209 | { |
|---|
| 210 | nprocs = atoi(argv[n+1]); |
|---|
| 211 | assert( (nprocs <= 8) && "The number of processors per cluster cannot be larger than 8"); |
|---|
| 212 | } |
|---|
| 213 | else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) ) |
|---|
| 214 | { |
|---|
| 215 | strcpy(soft_name, argv[n+1]); |
|---|
| 216 | } |
|---|
| 217 | else if( (strcmp(argv[n],"-DISK") == 0) && (n+1<argc) ) |
|---|
| 218 | { |
|---|
| 219 | strcpy(disk_name, argv[n+1]); |
|---|
| 220 | } |
|---|
| 221 | else if( (strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) ) |
|---|
| 222 | { |
|---|
| 223 | debug_ok = true; |
|---|
| 224 | from_cycle = atoi(argv[n+1]); |
|---|
| 225 | } |
|---|
| 226 | else if( (strcmp(argv[n],"-TOCYCLE") == 0) && (n+1<argc) ) |
|---|
| 227 | { |
|---|
| 228 | to_cycle = atoi(argv[n+1]); |
|---|
| 229 | } |
|---|
| 230 | else |
|---|
| 231 | { |
|---|
| 232 | std::cout << " Arguments on the command line are (key,value) couples." << std::endl; |
|---|
| 233 | std::cout << " The order is not important." << std::endl; |
|---|
| 234 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
|---|
| 235 | std::cout << " -SOFT elf_file_name" << std::endl; |
|---|
| 236 | std::cout << " -DISK disk_image_file_name" << std::endl; |
|---|
| 237 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
|---|
| 238 | std::cout << " -NPROCS number_of_processors_per_cluster" << std::endl; |
|---|
| 239 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
|---|
| 240 | std::cout << " -TOCYCLE debug_end_cycle" << std::endl; |
|---|
| 241 | exit(0); |
|---|
| 242 | } |
|---|
| 243 | } |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | std::cout << std::endl << "*********** TSAR ARCHITECTURE **************" << std::endl |
|---|
| 247 | << " - Interconnect = VGMN & CROSSBAR" << std::endl |
|---|
| 248 | << " - Number of clusters 1" << std::endl |
|---|
| 249 | << " - Number of processors per cluster = " << nprocs << std::endl |
|---|
| 250 | << "**********************************************" << std::endl |
|---|
| 251 | << std::endl; |
|---|
| 252 | |
|---|
| 253 | |
|---|
| 254 | // Define VCI parameters |
|---|
| 255 | typedef soclib::caba::VciParams<cell_width, |
|---|
| 256 | plen_width, |
|---|
| 257 | address_width, |
|---|
| 258 | error_width, |
|---|
| 259 | clen_width, |
|---|
| 260 | rflag_width, |
|---|
| 261 | srcid_width, |
|---|
| 262 | pktid_width, |
|---|
| 263 | trdid_width, |
|---|
| 264 | wrplen_width> vci_param; |
|---|
| 265 | |
|---|
| 266 | typedef soclib::caba::VciParams<cell_width, |
|---|
| 267 | plen_width, |
|---|
| 268 | address_width_io, |
|---|
| 269 | error_width, |
|---|
| 270 | clen_width, |
|---|
| 271 | rflag_width, |
|---|
| 272 | srcid_width, |
|---|
| 273 | pktid_width, |
|---|
| 274 | trdid_width, |
|---|
| 275 | wrplen_width> vci_param_io; |
|---|
| 276 | ///////////////////// |
|---|
| 277 | // Mapping Tables |
|---|
| 278 | ///////////////////// |
|---|
| 279 | |
|---|
| 280 | // direct network |
|---|
| 281 | MappingTable maptabd(address_width, |
|---|
| 282 | IntTab(12), |
|---|
| 283 | IntTab(srcid_width), |
|---|
| 284 | 0xFFF00000); |
|---|
| 285 | |
|---|
| 286 | // maptabd.add(Segment("d_seg_memc", MEMC_BASE, MEMC_SIZE, IntTab(MEMC_TGTID), true)); |
|---|
| 287 | maptabd.add(Segment("d_seg_memc_user", USER_BASE, USER_SIZE, IntTab(MEMC_TGTID), true)); |
|---|
| 288 | maptabd.add(Segment("d_seg_memc_kernel", KERNEL_BASE, KERNEL_SIZE, IntTab(MEMC_TGTID), true)); |
|---|
| 289 | maptabd.add(Segment("d_seg_brom", BROM_BASE, BROM_SIZE, IntTab(BROM_TGTID), true)); |
|---|
| 290 | // maptabd.add(Segment("d_seg_xicu", XICU_BASE, XICU_SIZE, IntTab(XICU_TGTID), false)); |
|---|
| 291 | maptabd.add(Segment("d_seg_icu", ICU_BASE, ICU_SIZE, IntTab(ICU_TGTID), false)); |
|---|
| 292 | maptabd.add(Segment("d_seg_mtty", MTTY_BASE, MTTY_SIZE, IntTab(MTTY_TGTID), false)); |
|---|
| 293 | |
|---|
| 294 | //maptabd.add(Segment("d_seg_tim" , TIM_BASE , TIM_SIZE , IntTab(MEMC_TGTID ), false)); |
|---|
| 295 | maptabd.add(Segment("d_seg_bdev", BDEV_BASE, BDEV_SIZE, IntTab(BDEV_TGTID ), false)); |
|---|
| 296 | maptabd.add(Segment("d_seg_cdma", CDMA_BASE, CDMA_SIZE, IntTab(CDMA_TGTID ), false)); |
|---|
| 297 | maptabd.add(Segment("d_seg_fbuf", FBUF_BASE, FBUF_SIZE, IntTab(FBUF_TGTID ), false)); |
|---|
| 298 | |
|---|
| 299 | std::cout << maptabd << std::endl; |
|---|
| 300 | |
|---|
| 301 | // coherence network |
|---|
| 302 | MappingTable maptabc(address_width, |
|---|
| 303 | IntTab(12), |
|---|
| 304 | IntTab(srcid_width), |
|---|
| 305 | 0xF0000000); |
|---|
| 306 | |
|---|
| 307 | std::ostringstream sm; |
|---|
| 308 | sm << "c_seg_memc_0"; |
|---|
| 309 | // maptabc.add(Segment(sm.str(), MEMC_BASE, MEMC_SIZE, IntTab(nprocs), false)); |
|---|
| 310 | maptabc.add(Segment(sm.str(), USER_BASE, USER_SIZE, IntTab(nprocs), false)); |
|---|
| 311 | maptabc.add(Segment("c_seb_memc_kernel", KERNEL_BASE, KERNEL_SIZE, IntTab(nprocs), false)); |
|---|
| 312 | // the segment base and size will be modified |
|---|
| 313 | // when the segmentation of the coherence space will be simplified |
|---|
| 314 | |
|---|
| 315 | std::ostringstream sr; |
|---|
| 316 | sr << "c_seg_brom_0"; |
|---|
| 317 | maptabc.add(Segment(sr.str(), BROM_BASE, BROM_SIZE, IntTab(nprocs), false)); |
|---|
| 318 | |
|---|
| 319 | sc_uint<address_width> avoid_collision = 0; |
|---|
| 320 | for ( size_t p = 0 ; p < nprocs ; p++) |
|---|
| 321 | { |
|---|
| 322 | sc_uint<address_width> base = USER_SIZE + KERNEL_SIZE + (p*0x100000); |
|---|
| 323 | // the following test is to avoid a collision between the c_seg_brom segment |
|---|
| 324 | // and a c_seg_proc segment (all segments base addresses being multiple of 1Mbytes) |
|---|
| 325 | if ( base == BROM_BASE ) avoid_collision = 0x100000; |
|---|
| 326 | std::ostringstream sp; |
|---|
| 327 | sp << "c_seg_proc_" << p; |
|---|
| 328 | maptabc.add(Segment(sp.str(), base + avoid_collision, 0x20, IntTab(p), false, true, IntTab(p))); |
|---|
| 329 | // the two last arguments will be removed |
|---|
| 330 | // when the segmentation of the coherence space will be simplified |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | std::cout << maptabc << std::endl; |
|---|
| 334 | |
|---|
| 335 | // external network |
|---|
| 336 | MappingTable maptabx(address_width, IntTab(1), IntTab(srcid_width), 0xF0000000); |
|---|
| 337 | |
|---|
| 338 | // maptabx.add(Segment("seg_memc_x", MEMC_BASE, MEMC_SIZE, IntTab(0), false)); |
|---|
| 339 | maptabx.add(Segment("seg_memc_x_user", USER_BASE, USER_SIZE, IntTab(0), false)); |
|---|
| 340 | maptabx.add(Segment("seg_memc_x_kernel", KERNEL_BASE, KERNEL_SIZE, IntTab(0), false)); |
|---|
| 341 | |
|---|
| 342 | std::cout << maptabx << std::endl; |
|---|
| 343 | |
|---|
| 344 | //////////////////// |
|---|
| 345 | // Signals |
|---|
| 346 | /////////////////// |
|---|
| 347 | |
|---|
| 348 | sc_clock signal_clk("clk"); |
|---|
| 349 | sc_signal<bool> signal_resetn("resetn"); |
|---|
| 350 | sc_signal<bool> signal_false; |
|---|
| 351 | |
|---|
| 352 | // IRQ signals (one signal per proc) |
|---|
| 353 | sc_signal<bool>* signal_proc_it = |
|---|
| 354 | alloc_elems<sc_signal<bool> >("signal_proc_it", nprocs); |
|---|
| 355 | |
|---|
| 356 | sc_signal<bool>* signal_irq_mtty = |
|---|
| 357 | alloc_elems<sc_signal<bool> >("signal_irq_mtty", NB_TTYS); |
|---|
| 358 | |
|---|
| 359 | sc_signal<bool> signal_irq_bdev; |
|---|
| 360 | sc_signal<bool> signal_irq_cdma; |
|---|
| 361 | |
|---|
| 362 | sc_signal<bool> empty; |
|---|
| 363 | |
|---|
| 364 | // Direct VCI signals |
|---|
| 365 | |
|---|
| 366 | VciSignals<vci_param>* signal_vci_ini_d_proc = |
|---|
| 367 | alloc_elems<VciSignals<vci_param> >("signal_vci_ini_d_proc", nprocs); |
|---|
| 368 | VciSignals<vci_param_io> signal_vci_ini_d_bdev("signal_vci_ini_d_bdev"); |
|---|
| 369 | VciSignals<vci_param_io> signal_vci_ini_d_cdma("signal_vci_ini_d_cdma"); |
|---|
| 370 | |
|---|
| 371 | VciSignals<vci_param> signal_vci_tgt_d_memc("signal_vci_tgt_d_memc"); |
|---|
| 372 | VciSignals<vci_param> signal_vci_tgt_d_brom("signal_vci_tgt_d_brom"); |
|---|
| 373 | // VciSignals<vci_param> signal_vci_tgt_d_xicu("signal_vci_tgt_d_xicu"); |
|---|
| 374 | VciSignals<vci_param> signal_vci_tgt_d_icu("signal_vci_tgt_d_icu"); |
|---|
| 375 | VciSignals<vci_param> signal_vci_tgt_d_mtty("signal_vci_tgt_d_mtty"); |
|---|
| 376 | VciSignals<vci_param_io> signal_vci_tgt_d_bdev("signal_vci_tgt_d_bdev"); |
|---|
| 377 | VciSignals<vci_param_io> signal_vci_tgt_d_cmda("signal_vci_tgt_d_cmda"); |
|---|
| 378 | VciSignals<vci_param_io> signal_vci_tgt_d_fbuf("signal_vci_tgt_d_fbuf"); |
|---|
| 379 | |
|---|
| 380 | // Coherence VCI signals |
|---|
| 381 | |
|---|
| 382 | VciSignals<vci_param>* signal_vci_ini_c_proc = |
|---|
| 383 | alloc_elems<VciSignals<vci_param> >("signal_vci_ini_c_proc", nprocs); |
|---|
| 384 | |
|---|
| 385 | VciSignals<vci_param>* signal_vci_tgt_c_proc = |
|---|
| 386 | alloc_elems<VciSignals<vci_param> >("signal_vci_tgt_c_proc", nprocs); |
|---|
| 387 | |
|---|
| 388 | VciSignals<vci_param> signal_vci_ini_c_memc("signal_vci_ini_c_memc"); |
|---|
| 389 | VciSignals<vci_param> signal_vci_tgt_c_memc("signal_vci_tgt_c_memc"); |
|---|
| 390 | |
|---|
| 391 | // Xternal network VCI signals |
|---|
| 392 | |
|---|
| 393 | VciSignals<vci_param> signal_vci_tgt_x_xram("signal_vci_tgt_x_xram"); |
|---|
| 394 | VciSignals<vci_param> signal_vci_ini_x_memc("signal_vci_ini_x_memc"); |
|---|
| 395 | |
|---|
| 396 | //////////////////////////// |
|---|
| 397 | // Components |
|---|
| 398 | //////////////////////////// |
|---|
| 399 | |
|---|
| 400 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | soclib::common::Loader loader(soft_name); |
|---|
| 404 | proc_iss::set_loader(loader); |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | // External RAM |
|---|
| 408 | VciSimpleRam<vci_param> xram( |
|---|
| 409 | "xram", |
|---|
| 410 | IntTab(0), |
|---|
| 411 | maptabx, |
|---|
| 412 | loader); |
|---|
| 413 | |
|---|
| 414 | // External network |
|---|
| 415 | VciVgmn<vci_param> xnoc( |
|---|
| 416 | "xnoc", |
|---|
| 417 | maptabx, |
|---|
| 418 | 1, // initiators |
|---|
| 419 | 1, // targets |
|---|
| 420 | 2, |
|---|
| 421 | 2); |
|---|
| 422 | |
|---|
| 423 | // Direct network |
|---|
| 424 | VciVgmn<vci_param> dnoc( |
|---|
| 425 | "dnoc", |
|---|
| 426 | maptabd, |
|---|
| 427 | nprocs+2, // nb of initiators |
|---|
| 428 | 7, // nb of targets |
|---|
| 429 | 2, 2); //latence, FIFO depth |
|---|
| 430 | |
|---|
| 431 | // Coherence network |
|---|
| 432 | VciVgmn<vci_param> cnoc( |
|---|
| 433 | "cnoc", |
|---|
| 434 | maptabc, |
|---|
| 435 | nprocs+1, |
|---|
| 436 | nprocs+1, |
|---|
| 437 | 2, 2); |
|---|
| 438 | |
|---|
| 439 | // Peripherals : TTY, Frame Buffer, Block Device, Boot ROM, & DMA |
|---|
| 440 | VciSimpleRam<vci_param> brom( |
|---|
| 441 | "brom", |
|---|
| 442 | IntTab(BROM_TGTID), |
|---|
| 443 | maptabd, |
|---|
| 444 | loader); |
|---|
| 445 | |
|---|
| 446 | VciMultiTty<vci_param> mtty( |
|---|
| 447 | "mtty", |
|---|
| 448 | IntTab(MTTY_TGTID), |
|---|
| 449 | maptabd, |
|---|
| 450 | "tty0","tty1","tty2","tty3", |
|---|
| 451 | "tty4","tty5","tty6","tty7", |
|---|
| 452 | "tty8", NULL); |
|---|
| 453 | |
|---|
| 454 | VciFrameBuffer<vci_param_io> fbuf( |
|---|
| 455 | "fbuf", |
|---|
| 456 | IntTab(FBUF_TGTID), |
|---|
| 457 | maptabd, |
|---|
| 458 | FBUF_XSIZE, |
|---|
| 459 | FBUF_YSIZE); |
|---|
| 460 | |
|---|
| 461 | VciBlockDeviceTsarV4<vci_param_io> bdev( |
|---|
| 462 | // VciBlockDevice<vci_param_io> bdev( |
|---|
| 463 | "bdev", |
|---|
| 464 | maptabd, |
|---|
| 465 | IntTab(BDEV_SRCID), // SRCID_D |
|---|
| 466 | IntTab(BDEV_TGTID), // TGTID_D |
|---|
| 467 | disk_name, |
|---|
| 468 | SECTOR_SIZE, |
|---|
| 469 | 32); // burst size |
|---|
| 470 | |
|---|
| 471 | VciDmaTsarV2<vci_param_io> cdma( |
|---|
| 472 | "cdma", |
|---|
| 473 | maptabd, |
|---|
| 474 | IntTab(CDMA_SRCID), // SRCID_D |
|---|
| 475 | IntTab(CDMA_TGTID), // TGTID_D |
|---|
| 476 | 64); |
|---|
| 477 | |
|---|
| 478 | // processors (nprocs per cluster) |
|---|
| 479 | |
|---|
| 480 | VciCcVCacheWrapperV4<vci_param, proc_iss> *proc[nprocs]; |
|---|
| 481 | |
|---|
| 482 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
|---|
| 483 | { |
|---|
| 484 | |
|---|
| 485 | std::ostringstream sp; |
|---|
| 486 | sp << "proc_" << "_" << p; |
|---|
| 487 | |
|---|
| 488 | proc[p] = new VciCcVCacheWrapperV4<vci_param, proc_iss>( |
|---|
| 489 | sp.str().c_str(), |
|---|
| 490 | p, |
|---|
| 491 | maptabd, maptabc, |
|---|
| 492 | IntTab(PROC_SRCID+p), // SRCID_D |
|---|
| 493 | IntTab(PROC_SRCID+p), // SRCID_C |
|---|
| 494 | IntTab(PROC_SRCID+p), // TGTID_C |
|---|
| 495 | 4,4, // itlb ways, sets |
|---|
| 496 | 4,4, // dtlb ways, sets |
|---|
| 497 | 4,64,16,4,64,16, // Icache and Dcache sizes (way, set, words) |
|---|
| 498 | 4,8, |
|---|
| 499 | 20000000, |
|---|
| 500 | from_cycle, |
|---|
| 501 | false |
|---|
| 502 | ); |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | // memory caches (one per cluster) |
|---|
| 506 | VciMemCacheV4<vci_param> memc( |
|---|
| 507 | sm.str().c_str(), |
|---|
| 508 | maptabd, maptabc, maptabx, |
|---|
| 509 | IntTab(0), // SRCID_X |
|---|
| 510 | IntTab(nprocs), // SRCID_C |
|---|
| 511 | IntTab(MEMC_TGTID), // TGTID_D |
|---|
| 512 | IntTab(nprocs), // TGTID_C |
|---|
| 513 | 16,256,16, // CACHE SIZE |
|---|
| 514 | 4096, // HEAP SIZE |
|---|
| 515 | 4,4, // TRANSACTION and UPDATE TAB lines |
|---|
| 516 | from_cycle, |
|---|
| 517 | debug_ok |
|---|
| 518 | ); |
|---|
| 519 | /* |
|---|
| 520 | // XICU (one per cluster) |
|---|
| 521 | VciXicu<vci_param> xicu( |
|---|
| 522 | "vci_xicu", |
|---|
| 523 | maptabd, |
|---|
| 524 | IntTab(XICU_TGTID), // TGTID_D |
|---|
| 525 | nprocs, // number of TIMERS |
|---|
| 526 | NB_TTYS, // number of hard IRQs |
|---|
| 527 | nprocs+1, // number of soft IRQs |
|---|
| 528 | nprocs); // number of output IRQ lines |
|---|
| 529 | */ |
|---|
| 530 | // ICU |
|---|
| 531 | /* |
|---|
| 532 | VciIcu<vci_param> icu( |
|---|
| 533 | "vci_icu", |
|---|
| 534 | IntTab(ICU_TGTID), // TGTID_D |
|---|
| 535 | maptabd, |
|---|
| 536 | NB_TTYS + 2 // number of hard IRQs |
|---|
| 537 | ); |
|---|
| 538 | */ |
|---|
| 539 | VciMultiIcu<vci_param> *icu; |
|---|
| 540 | icu = new VciMultiIcu<vci_param>("icu", |
|---|
| 541 | IntTab(ICU_TGTID), |
|---|
| 542 | maptabd, |
|---|
| 543 | 32, // number of irq in |
|---|
| 544 | 1); //NB_PROCS number of irq out |
|---|
| 545 | |
|---|
| 546 | |
|---|
| 547 | std::cout << "all components created" << std::endl; |
|---|
| 548 | |
|---|
| 549 | /////////////////////////////////////////////////////////////// |
|---|
| 550 | // Net-list |
|---|
| 551 | /////////////////////////////////////////////////////////////// |
|---|
| 552 | |
|---|
| 553 | // External Ram (one instance) |
|---|
| 554 | xram.p_clk (signal_clk); |
|---|
| 555 | xram.p_resetn (signal_resetn); |
|---|
| 556 | xram.p_vci (signal_vci_tgt_x_xram); |
|---|
| 557 | |
|---|
| 558 | // External Network (one instance) |
|---|
| 559 | xnoc.p_clk (signal_clk); |
|---|
| 560 | xnoc.p_resetn (signal_resetn); |
|---|
| 561 | xnoc.p_to_target[0] (signal_vci_tgt_x_xram); |
|---|
| 562 | xnoc.p_to_initiator[0] (signal_vci_ini_x_memc); |
|---|
| 563 | |
|---|
| 564 | // Direct Network (one instance) |
|---|
| 565 | dnoc.p_clk (signal_clk); |
|---|
| 566 | dnoc.p_resetn (signal_resetn); |
|---|
| 567 | dnoc.p_to_target[MEMC_TGTID] (signal_vci_tgt_d_memc); |
|---|
| 568 | dnoc.p_to_target[BROM_TGTID] (signal_vci_tgt_d_brom); |
|---|
| 569 | // dnoc.p_to_target[XICU_TGTID] (signal_vci_tgt_d_xicu); |
|---|
| 570 | dnoc.p_to_target[ICU_TGTID] (signal_vci_tgt_d_icu); |
|---|
| 571 | dnoc.p_to_target[MTTY_TGTID] (signal_vci_tgt_d_mtty); |
|---|
| 572 | dnoc.p_to_target[BDEV_TGTID] (signal_vci_tgt_d_bdev); |
|---|
| 573 | dnoc.p_to_target[CDMA_TGTID] (signal_vci_tgt_d_cmda); |
|---|
| 574 | dnoc.p_to_target[FBUF_TGTID] (signal_vci_tgt_d_fbuf); |
|---|
| 575 | |
|---|
| 576 | dnoc.p_to_initiator[BDEV_SRCID] (signal_vci_ini_d_bdev); |
|---|
| 577 | dnoc.p_to_initiator[CDMA_SRCID] (signal_vci_ini_d_cdma); |
|---|
| 578 | |
|---|
| 579 | // Coherence Network (one instance) |
|---|
| 580 | cnoc.p_clk (signal_clk); |
|---|
| 581 | cnoc.p_resetn (signal_resetn); |
|---|
| 582 | cnoc.p_to_initiator[nprocs] (signal_vci_ini_c_memc); |
|---|
| 583 | cnoc.p_to_target[nprocs] (signal_vci_tgt_c_memc); |
|---|
| 584 | |
|---|
| 585 | // Processors |
|---|
| 586 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
|---|
| 587 | { |
|---|
| 588 | dnoc.p_to_initiator[p] (signal_vci_ini_d_proc[p]); |
|---|
| 589 | cnoc.p_to_initiator[p] (signal_vci_ini_c_proc[p]); |
|---|
| 590 | cnoc.p_to_target[p] (signal_vci_tgt_c_proc[p]); |
|---|
| 591 | |
|---|
| 592 | proc[p]->p_clk (signal_clk); |
|---|
| 593 | proc[p]->p_resetn (signal_resetn); |
|---|
| 594 | proc[p]->p_vci_ini_d (signal_vci_ini_d_proc[p]); |
|---|
| 595 | proc[p]->p_vci_ini_c (signal_vci_ini_c_proc[p]); |
|---|
| 596 | proc[p]->p_vci_tgt_c (signal_vci_tgt_c_proc[p]); |
|---|
| 597 | proc[p]->p_irq[0] (signal_proc_it[p]); |
|---|
| 598 | for ( size_t j = 1 ; j < 6 ; j++ ) |
|---|
| 599 | { |
|---|
| 600 | proc[p]->p_irq[j] (signal_false); |
|---|
| 601 | } |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | |
|---|
| 605 | /* |
|---|
| 606 | // XICU |
|---|
| 607 | xicu.p_clk (signal_clk); |
|---|
| 608 | xicu.p_resetn (signal_resetn); |
|---|
| 609 | xicu.p_vci (signal_vci_tgt_d_xicu); |
|---|
| 610 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
|---|
| 611 | { |
|---|
| 612 | xicu.p_irq[p] (signal_proc_it[p]); |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | for(size_t i=0 ; i<NB_TTYS ; i++) |
|---|
| 616 | { |
|---|
| 617 | xicu.p_hwi[i] (signal_irq_mtty[i]); |
|---|
| 618 | } |
|---|
| 619 | */ |
|---|
| 620 | // ICU |
|---|
| 621 | icu->p_clk (signal_clk); |
|---|
| 622 | icu->p_resetn (signal_resetn); |
|---|
| 623 | icu->p_vci (signal_vci_tgt_d_icu); |
|---|
| 624 | icu->p_irq_out[0] (signal_proc_it[0]); |
|---|
| 625 | |
|---|
| 626 | for (size_t i = 0 ; i < 32 ; i++ ) |
|---|
| 627 | { |
|---|
| 628 | // if ( i < NB_TIMERS ) icu->p_irq_in[i] (signal_irq_tim[i]); |
|---|
| 629 | if ( i < 8 ) icu->p_irq_in[i] (signal_false); |
|---|
| 630 | else if ( i == 8) icu->p_irq_in[i] (signal_irq_cdma); |
|---|
| 631 | else if ( i < 16 ) icu->p_irq_in[i] (signal_false); |
|---|
| 632 | else if ( i < (16 + NB_TTYS) ) icu->p_irq_in[i] (signal_irq_mtty[i-16]); |
|---|
| 633 | else if ( i < 31 ) icu->p_irq_in[i] (signal_false); |
|---|
| 634 | else icu->p_irq_in[i] (signal_irq_bdev); |
|---|
| 635 | } |
|---|
| 636 | |
|---|
| 637 | // MEMC |
|---|
| 638 | memc.p_clk (signal_clk); |
|---|
| 639 | memc.p_resetn (signal_resetn); |
|---|
| 640 | memc.p_vci_tgt (signal_vci_tgt_d_memc); |
|---|
| 641 | memc.p_vci_ini (signal_vci_ini_c_memc); |
|---|
| 642 | memc.p_vci_tgt_cleanup (signal_vci_tgt_c_memc); |
|---|
| 643 | memc.p_vci_ixr (signal_vci_ini_x_memc); |
|---|
| 644 | |
|---|
| 645 | brom.p_clk (signal_clk); |
|---|
| 646 | brom.p_resetn (signal_resetn); |
|---|
| 647 | brom.p_vci (signal_vci_tgt_d_brom); |
|---|
| 648 | |
|---|
| 649 | mtty.p_clk (signal_clk); |
|---|
| 650 | mtty.p_resetn (signal_resetn); |
|---|
| 651 | mtty.p_vci (signal_vci_tgt_d_mtty); |
|---|
| 652 | |
|---|
| 653 | for(size_t i=0 ; i<NB_TTYS ; i++) |
|---|
| 654 | { |
|---|
| 655 | mtty.p_irq[i] (signal_irq_mtty[i]); |
|---|
| 656 | } |
|---|
| 657 | |
|---|
| 658 | bdev.p_clk (signal_clk); |
|---|
| 659 | bdev.p_resetn (signal_resetn); |
|---|
| 660 | bdev.p_irq (signal_irq_bdev); |
|---|
| 661 | bdev.p_vci_target (signal_vci_tgt_d_bdev); |
|---|
| 662 | bdev.p_vci_initiator (signal_vci_ini_d_bdev); |
|---|
| 663 | |
|---|
| 664 | cdma.p_clk (signal_clk); |
|---|
| 665 | cdma.p_resetn (signal_resetn); |
|---|
| 666 | cdma.p_irq (signal_irq_cdma); |
|---|
| 667 | cdma.p_vci_target (signal_vci_tgt_d_cmda); |
|---|
| 668 | cdma.p_vci_initiator (signal_vci_ini_d_cdma); |
|---|
| 669 | |
|---|
| 670 | fbuf.p_clk (signal_clk); |
|---|
| 671 | fbuf.p_resetn (signal_resetn); |
|---|
| 672 | fbuf.p_vci (signal_vci_tgt_d_fbuf); |
|---|
| 673 | |
|---|
| 674 | |
|---|
| 675 | std::cout << "all components connected" << std::endl; |
|---|
| 676 | |
|---|
| 677 | //////////////////////////////////////////////////////// |
|---|
| 678 | // Simulation |
|---|
| 679 | /////////////////////////////////////////////////////// |
|---|
| 680 | |
|---|
| 681 | sc_start(sc_core::sc_time(0, SC_NS)); |
|---|
| 682 | signal_resetn = false; |
|---|
| 683 | |
|---|
| 684 | sc_start(sc_core::sc_time(1, SC_NS)); |
|---|
| 685 | signal_resetn = true; |
|---|
| 686 | char buf[1]; |
|---|
| 687 | |
|---|
| 688 | for(size_t i=1 ; i<ncycles ; i++) |
|---|
| 689 | { |
|---|
| 690 | sc_start(sc_core::sc_time(1, SC_NS)); |
|---|
| 691 | |
|---|
| 692 | if( debug_ok && (i > from_cycle) && (i < to_cycle) ) |
|---|
| 693 | { |
|---|
| 694 | std::cout << std::dec << "*************** cycle " << i << " ***********************" << std::endl; |
|---|
| 695 | proc[0]->print_trace(); |
|---|
| 696 | std::cout << std::endl; |
|---|
| 697 | |
|---|
| 698 | memc.print_trace(); |
|---|
| 699 | std::cout << std::endl; |
|---|
| 700 | |
|---|
| 701 | icu->print_trace(); |
|---|
| 702 | std::cout << std::endl; |
|---|
| 703 | |
|---|
| 704 | // bdev.print_trace(); |
|---|
| 705 | // std::cout << std::endl; |
|---|
| 706 | |
|---|
| 707 | xram.print_trace(); |
|---|
| 708 | std::cout << std::endl; |
|---|
| 709 | } |
|---|
| 710 | } |
|---|
| 711 | |
|---|
| 712 | std::cout << "Hit ENTER to end simulation" << std::endl; |
|---|
| 713 | std::cin.getline(buf,1); |
|---|
| 714 | |
|---|
| 715 | // for ( size_t p = 0 ; p < nprocs ; p++ ) |
|---|
| 716 | // proc[p]->print_stats(); |
|---|
| 717 | |
|---|
| 718 | return EXIT_SUCCESS; |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | int sc_main (int argc, char *argv[]) |
|---|
| 722 | { |
|---|
| 723 | try { |
|---|
| 724 | return _main(argc, argv); |
|---|
| 725 | } catch (std::exception &e) { |
|---|
| 726 | std::cout << e.what() << std::endl; |
|---|
| 727 | } catch (...) { |
|---|
| 728 | std::cout << "Unknown exception occured" << std::endl; |
|---|
| 729 | throw; |
|---|
| 730 | } |
|---|
| 731 | return 1; |
|---|
| 732 | } |
|---|