| 1 | #include <systemc> | 
|---|
| 2 | #include <sys/time.h> | 
|---|
| 3 | #include <iostream> | 
|---|
| 4 | #include <sstream> | 
|---|
| 5 | #include <cstdlib> | 
|---|
| 6 | #include <cstdarg> | 
|---|
| 7 | #include <stdint.h> | 
|---|
| 8 | #include <fstream> | 
|---|
| 9 |  | 
|---|
| 10 | #include "mapping_table.h" | 
|---|
| 11 | #include "mips32.h" | 
|---|
| 12 | #include "vci_simhelper.h" | 
|---|
| 13 | #include "vci_simple_ram.h" | 
|---|
| 14 | #include "vci_multi_tty.h" | 
|---|
| 15 | #include "vci_xicu.h" | 
|---|
| 16 | #include "vci_simple_ring_fast.h" | 
|---|
| 17 | #include "vci_mem_cache_v4.h" | 
|---|
| 18 | #include "vci_cc_xcache_wrapper_v4.h" | 
|---|
| 19 | #include "alloc_elems.h" | 
|---|
| 20 |  | 
|---|
| 21 | #include "iss/gdbserver.h" | 
|---|
| 22 |  | 
|---|
| 23 | #include "segmentation.h" | 
|---|
| 24 |  | 
|---|
| 25 | //=========================================== | 
|---|
| 26 | // Define before include | 
|---|
| 27 | //=========================================== | 
|---|
| 28 |  | 
|---|
| 29 | // Parameters | 
|---|
| 30 | // * Platforms | 
|---|
| 31 | #  define PARAM_VCI                         4,8,32,1,1,1,8,4,4,1 | 
|---|
| 32 |  | 
|---|
| 33 | #  define USE_OLD_XCACHE                    0 | 
|---|
| 34 | #  define USE_VGMN                          1 | 
|---|
| 35 | #  define NB_PROC_MIN                       1 | 
|---|
| 36 | #  define NB_PROC_MAX                       15 | 
|---|
| 37 | //                                          fifo_depth | 
|---|
| 38 | #  define PARAM_RING_P                      2 | 
|---|
| 39 | #  define PARAM_RING_C                      2 | 
|---|
| 40 | #  define PARAM_RING_X                      2 | 
|---|
| 41 | //                                          pti    , hwi    , wti, irq | 
|---|
| 42 | #  define PARAM_XICU                        nb_proc*nb_cpu_by_cache, nb_proc*nb_cpu_by_cache, 0  , nb_proc*nb_cpu_by_cache | 
|---|
| 43 | //#define PARAM_XICU                        nb_proc, nb_proc, 0  , nb_proc | 
|---|
| 44 |  | 
|---|
| 45 | // * Debug | 
|---|
| 46 | #  define DEBUG_TOP                         0 | 
|---|
| 47 | #  define SOCVIEW                           0 | 
|---|
| 48 | #  define STOP_SIMULATION_NB_FRZ_CYCLES     100000 | 
|---|
| 49 |                                              | 
|---|
| 50 | // * Simulation                              | 
|---|
| 51 | #  define CONFIG_DEFAULT                      "configuration/default.cfg" | 
|---|
| 52 | #  define NCYCLES_DEFAULT                   0 | 
|---|
| 53 | #  define SOFT_DEFAULT                      "soft/bin.soft" | 
|---|
| 54 | //=========================================== | 
|---|
| 55 |  | 
|---|
| 56 | void usage (char * funcname) | 
|---|
| 57 | { | 
|---|
| 58 |   std::cout << funcname << " [option] " << std::endl; | 
|---|
| 59 |   std::cout << " * -NCYCLES int : number of simulated cycle, if 0 then no stop condition." << std::endl; | 
|---|
| 60 |   std::cout << "                  default : " << NCYCLES_DEFAULT << " cycle(s)" << std::endl; | 
|---|
| 61 |   std::cout << " * -CFG string  : configuration file" << std::endl; | 
|---|
| 62 |   std::cout << "                    - nb_proc," << std::endl; | 
|---|
| 63 |   std::cout << "                    - nb_cpu_by_cache, nb_dcache," << std::endl; | 
|---|
| 64 |   std::cout << "                    - iways, isets, iwords," << std::endl; | 
|---|
| 65 |   std::cout << "                    - dways, dsets, dwords," << std::endl; | 
|---|
| 66 |   std::cout << "                    - wnwords, wnlines, wtimeout," << std::endl; | 
|---|
| 67 |   std::cout << "                    - memc_nways, memc_nsets, memc_words, memc_heap_size." << std::endl; | 
|---|
| 68 |   std::cout << "                  default : \"" << CONFIG_DEFAULT << "\"" << std::endl; | 
|---|
| 69 |   std::cout << " * -SOFT string : software executed by this platform." << std::endl; | 
|---|
| 70 |   std::cout << "                  default : \"" << SOFT_DEFAULT << "\"" << std::endl; | 
|---|
| 71 |  | 
|---|
| 72 |   exit(1); | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | int _main(int argc, char *argv[]) | 
|---|
| 76 | { | 
|---|
| 77 |         int    ncycles = NCYCLES_DEFAULT; | 
|---|
| 78 |         char * config  = CONFIG_DEFAULT; | 
|---|
| 79 |         char * soft    = SOFT_DEFAULT; | 
|---|
| 80 |  | 
|---|
| 81 |         if (argc > 1) | 
|---|
| 82 |           { | 
|---|
| 83 |             for( int n=1 ; n<argc ; n=n+2 ) | 
|---|
| 84 |               { | 
|---|
| 85 |                 if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) ) | 
|---|
| 86 |                   { | 
|---|
| 87 |                     ncycles = atoi(argv[n+1]); | 
|---|
| 88 |                   } | 
|---|
| 89 |                 else if( (strcmp(argv[n],"-CFG") == 0) && (n+1<argc) ) | 
|---|
| 90 |                   { | 
|---|
| 91 |                     // strcpy(config, argv[n+1]); | 
|---|
| 92 |                     config = argv[n+1]; | 
|---|
| 93 |                   } | 
|---|
| 94 |                 else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) ) | 
|---|
| 95 |                   { | 
|---|
| 96 |                     // strcpy(soft, argv[n+1]); | 
|---|
| 97 |                     soft = argv[n+1]; | 
|---|
| 98 |                   } | 
|---|
| 99 |                 else | 
|---|
| 100 |                   { | 
|---|
| 101 |                     usage(argv[0]); | 
|---|
| 102 |                   } | 
|---|
| 103 |               } | 
|---|
| 104 |           } | 
|---|
| 105 |  | 
|---|
| 106 |         if (ncycles == 0) | 
|---|
| 107 |           ncycles = -1; | 
|---|
| 108 |  | 
|---|
| 109 |         uint32_t nb_proc; | 
|---|
| 110 |         uint32_t nb_cpu_by_cache; | 
|---|
| 111 |         uint32_t nb_dcache; | 
|---|
| 112 |         uint32_t iways, isets, iwords; | 
|---|
| 113 |         uint32_t dways, dsets, dwords; | 
|---|
| 114 |         uint32_t wnwords, wnlines, wtimeout; | 
|---|
| 115 |         uint32_t memc_nways, memc_nsets, memc_words, memc_heap_size; | 
|---|
| 116 |  | 
|---|
| 117 |         std::ifstream inFile; | 
|---|
| 118 |         const char * filename = config; | 
|---|
| 119 |  | 
|---|
| 120 |         inFile.open(filename); | 
|---|
| 121 |          | 
|---|
| 122 |         if (!inFile)  | 
|---|
| 123 |           { | 
|---|
| 124 |             std::cout << "Can't open file : \"" << filename << "\"." << std::endl; | 
|---|
| 125 |             usage(argv[0]); | 
|---|
| 126 |           } | 
|---|
| 127 |  | 
|---|
| 128 |         std::string str; | 
|---|
| 129 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 130 |         nb_proc         =std::atoi(str.c_str()); | 
|---|
| 131 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 132 |         nb_cpu_by_cache =std::atoi(str.c_str()); | 
|---|
| 133 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 134 |         nb_dcache       =std::atoi(str.c_str()); | 
|---|
| 135 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 136 |         iways           =std::atoi(str.c_str()); | 
|---|
| 137 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 138 |         isets           =std::atoi(str.c_str()); | 
|---|
| 139 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 140 |         iwords          =std::atoi(str.c_str()); | 
|---|
| 141 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 142 |         dways           =std::atoi(str.c_str()); | 
|---|
| 143 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 144 |         dsets           =std::atoi(str.c_str()); | 
|---|
| 145 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 146 |         dwords          =std::atoi(str.c_str()); | 
|---|
| 147 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 148 |         wnwords         =std::atoi(str.c_str()); | 
|---|
| 149 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 150 |         wnlines         =std::atoi(str.c_str()); | 
|---|
| 151 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 152 |         wtimeout        =std::atoi(str.c_str()); | 
|---|
| 153 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 154 |         memc_nways      =std::atoi(str.c_str()); | 
|---|
| 155 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 156 |         memc_nsets      =std::atoi(str.c_str()); | 
|---|
| 157 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 158 |         memc_words      =std::atoi(str.c_str()); | 
|---|
| 159 |         if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} | 
|---|
| 160 |         memc_heap_size  =std::atoi(str.c_str()); | 
|---|
| 161 |  | 
|---|
| 162 |         if (((nb_proc*nb_cpu_by_cache)<NB_PROC_MIN) or | 
|---|
| 163 |             ((nb_proc*nb_cpu_by_cache)>NB_PROC_MAX)) | 
|---|
| 164 |           { | 
|---|
| 165 |             std::cout << "Parameters nb_proc is out of bound." << std::endl; | 
|---|
| 166 |             usage(argv[0]); | 
|---|
| 167 |           } | 
|---|
| 168 |  | 
|---|
| 169 |         std::cout << "  * Parameters : " << std::endl; | 
|---|
| 170 |         std::cout << "    * nb_proc          : " << nb_proc          << std::endl; | 
|---|
| 171 |         std::cout << "    * nb_cpu_by_cache  : " << nb_cpu_by_cache  << std::endl; | 
|---|
| 172 |         std::cout << "    * nb_dcache        : " << nb_dcache        << std::endl; | 
|---|
| 173 |         std::cout << "    * iways            : " << iways            << std::endl; | 
|---|
| 174 |         std::cout << "    * isets            : " << isets            << std::endl; | 
|---|
| 175 |         std::cout << "    * iwords           : " << iwords           << std::endl; | 
|---|
| 176 |         std::cout << "    * dways            : " << dways            << std::endl; | 
|---|
| 177 |         std::cout << "    * dsets            : " << dsets            << std::endl; | 
|---|
| 178 |         std::cout << "    * dwords           : " << dwords           << std::endl; | 
|---|
| 179 |         std::cout << "    * wnwords          : " << wnwords          << std::endl; | 
|---|
| 180 |         std::cout << "    * wnlines          : " << wnlines          << std::endl; | 
|---|
| 181 |         std::cout << "    * wtimeout         : " << wtimeout         << std::endl; | 
|---|
| 182 |         std::cout << "    * memc_nways       : " << memc_nways       << std::endl; | 
|---|
| 183 |         std::cout << "    * memc_nsets       : " << memc_nsets       << std::endl; | 
|---|
| 184 |         std::cout << "    * memc_words       : " << memc_words       << std::endl; | 
|---|
| 185 |         std::cout << "    * memc_heap_size   : " << memc_heap_size   << std::endl; | 
|---|
| 186 |         std::cout << "  * Simulation : " << std::endl; | 
|---|
| 187 |         std::cout << "    * ncycles          : " << ncycles          << std::endl; | 
|---|
| 188 |         std::cout << "    * soft             : " << soft             << std::endl; | 
|---|
| 189 |  | 
|---|
| 190 |         using namespace sc_core; | 
|---|
| 191 |         // Avoid repeating these everywhere | 
|---|
| 192 |         using soclib::common::IntTab; | 
|---|
| 193 |         using soclib::common::Segment; | 
|---|
| 194 |  | 
|---|
| 195 |         // Define VCI parameters | 
|---|
| 196 |         typedef soclib::caba::VciParams<PARAM_VCI> vci_param; | 
|---|
| 197 |         typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; | 
|---|
| 198 |         // Mapping table | 
|---|
| 199 |  | 
|---|
| 200 |         soclib::common::MappingTable maptabp(32, IntTab(8), IntTab(8), 0x00300000); // size, level_addr_bits, level_id_bits, cacheability_mask | 
|---|
| 201 |  | 
|---|
| 202 |         maptabp.add(Segment("reset"    , RESET_BASE    , RESET_SIZE    , IntTab(2), true)); | 
|---|
| 203 |         maptabp.add(Segment("excep"    , EXCEP_BASE    , EXCEP_SIZE    , IntTab(2), true)); | 
|---|
| 204 |  | 
|---|
| 205 |         maptabp.add(Segment("tty"      , TTY_BASE      , TTY_SIZE      , IntTab(1), false)); | 
|---|
| 206 |         maptabp.add(Segment("text"     , TEXT_BASE     , TEXT_SIZE     , IntTab(2), true)); | 
|---|
| 207 |         maptabp.add(Segment("mc_r"     , MC_R_BASE     , MC_R_SIZE     , IntTab(2), false, true, IntTab(0))); | 
|---|
| 208 |         maptabp.add(Segment("mc_m"     , MC_M_BASE     , MC_M_SIZE     , IntTab(2), true)); | 
|---|
| 209 |       //maptabp.add(Segment("mc_u"     , MC_U_BASE     , MC_U_SIZE     , IntTab(2), false)); | 
|---|
| 210 |       //maptabp.add(Segment("ptba"     , PTD_ADDR      , TAB_SIZE      , IntTab(2), true)); | 
|---|
| 211 |         maptabp.add(Segment("xicu"     , XICU_BASE     , XICU_SIZE     , IntTab(3), false)); | 
|---|
| 212 |         maptabp.add(Segment("simhelper", SIMHELPER_BASE, SIMHELPER_SIZE, IntTab(4), false)); | 
|---|
| 213 |   | 
|---|
| 214 |         std::cout << maptabp << std::endl; | 
|---|
| 215 |  | 
|---|
| 216 |         soclib::common::MappingTable maptabc(32, IntTab(8), IntTab(8), 0x00300000); | 
|---|
| 217 |         // for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 218 |         //   for (uint32_t j=0; j<nb_cpu_by_cache; ++j) | 
|---|
| 219 |         //   { | 
|---|
| 220 |         //     std::ostringstream str; | 
|---|
| 221 |         //     str << "c_proc_" << i << "_" << j; | 
|---|
| 222 |         //     maptabc.add(Segment(str.str().c_str(), C_PROC_BASE+(i*nb_cpu_by_cache+j)*C_PROC_SPAN, C_PROC_SIZE , IntTab(i), false, true, IntTab(i))); | 
|---|
| 223 |         //   } | 
|---|
| 224 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 225 |         { | 
|---|
| 226 |           std::ostringstream str; | 
|---|
| 227 |           str << "c_proc_" << i; | 
|---|
| 228 |           maptabc.add(Segment(str.str().c_str(), C_PROC_BASE+i*C_PROC_SPAN, C_PROC_SIZE , IntTab(i), false, true, IntTab(i))); | 
|---|
| 229 |         } | 
|---|
| 230 |         maptabc.add(Segment("mc_r"    , MC_R_BASE  , MC_R_SIZE   , IntTab(nb_proc), false, false)); | 
|---|
| 231 |         maptabc.add(Segment("mc_m"    , MC_M_BASE  , MC_M_SIZE   , IntTab(nb_proc), false, false)); | 
|---|
| 232 |         // maptabc.add(Segment("mc_u"    , MC_U_BASE  , MC_U_SIZE   , IntTab(nb_proc), false, false)); | 
|---|
| 233 |         maptabc.add(Segment("reset"   , RESET_BASE , RESET_SIZE  , IntTab(nb_proc), false, false)); | 
|---|
| 234 |         maptabc.add(Segment("excep"   , EXCEP_BASE , EXCEP_SIZE  , IntTab(nb_proc), false, false)); | 
|---|
| 235 |         maptabc.add(Segment("text"    , TEXT_BASE  , TEXT_SIZE   , IntTab(nb_proc), false, false)); | 
|---|
| 236 |       //maptabc.add(Segment("ptba"    , PTD_ADDR   , TAB_SIZE    , IntTab(nb_proc), false, false)); | 
|---|
| 237 |  | 
|---|
| 238 |         std::cout << maptabc << std::endl; | 
|---|
| 239 |          | 
|---|
| 240 |         soclib::common::MappingTable maptabx(32, IntTab(8), IntTab(8), 0x00300000); | 
|---|
| 241 |         maptabx.add(Segment("xram" , MC_M_BASE , MC_M_SIZE , IntTab(0), false)); | 
|---|
| 242 |         // maptabx.add(Segment("uram" , MC_U_BASE , MC_U_SIZE , IntTab(0), false)); | 
|---|
| 243 |         maptabx.add(Segment("reset", RESET_BASE, RESET_SIZE, IntTab(0), false)); | 
|---|
| 244 |         maptabx.add(Segment("excep", EXCEP_BASE, EXCEP_SIZE, IntTab(0), false)); | 
|---|
| 245 |         maptabx.add(Segment("text" , TEXT_BASE , TEXT_SIZE , IntTab(0), false)); | 
|---|
| 246 |         // maptabx.add(Segment("ptba" , PTD_ADDR  , TAB_SIZE  , IntTab(0), false)); | 
|---|
| 247 |          | 
|---|
| 248 |         std::cout << maptabx << std::endl; | 
|---|
| 249 |  | 
|---|
| 250 |         // Signals | 
|---|
| 251 |         sc_clock        signal_clk("clk"); | 
|---|
| 252 |         sc_signal<bool> signal_resetn("resetn"); | 
|---|
| 253 |     | 
|---|
| 254 |         sc_signal<bool> *** signal_proc_it = soclib::common::alloc_elems<sc_signal<bool> >("proc_it", nb_proc, nb_cpu_by_cache, 6); | 
|---|
| 255 |  | 
|---|
| 256 |         soclib::caba::VciSignals<vci_param> * signal_vci_ini_rw_proc = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("vci_ini_rw_proc", nb_proc); | 
|---|
| 257 |         soclib::caba::VciSignals<vci_param> * signal_vci_ini_c_proc  = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("vci_ini_c_proc" , nb_proc); | 
|---|
| 258 |         soclib::caba::VciSignals<vci_param> * signal_vci_tgt_proc    = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("vci_tgt_proc"   , nb_proc); | 
|---|
| 259 |  | 
|---|
| 260 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_tty("vci_tgt_tty"); | 
|---|
| 261 |  | 
|---|
| 262 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_simhelper("signal_vci_tgt_simhelper"); | 
|---|
| 263 |  | 
|---|
| 264 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_rom("vci_tgt_rom"); | 
|---|
| 265 |  | 
|---|
| 266 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_xram("vci_tgt_xram"); | 
|---|
| 267 |  | 
|---|
| 268 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_xicu("vci_tgt_xicu"); | 
|---|
| 269 |  | 
|---|
| 270 |         soclib::caba::VciSignals<vci_param> signal_vci_ixr_memc("vci_ixr_memc"); | 
|---|
| 271 |         soclib::caba::VciSignals<vci_param> signal_vci_ini_memc("vci_ini_memc"); | 
|---|
| 272 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_memc("vci_tgt_memc"); | 
|---|
| 273 |         soclib::caba::VciSignals<vci_param> signal_vci_tgt_cleanup_memc("vci_tgt_cleanup_memc"); | 
|---|
| 274 |  | 
|---|
| 275 |         sc_signal<bool> ** signal_tty_irq = soclib::common::alloc_elems<sc_signal<bool> >("signal_tty_irq", nb_proc, nb_cpu_by_cache); | 
|---|
| 276 |  | 
|---|
| 277 |         soclib::common::Loader loader(soft); | 
|---|
| 278 |  | 
|---|
| 279 |         soclib::common::GdbServer<soclib::common::Mips32ElIss>::set_loader(loader); | 
|---|
| 280 |  | 
|---|
| 281 |         soclib::caba::VciCcXCacheWrapperV4<vci_param, proc_iss > * proc [nb_proc]; | 
|---|
| 282 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 283 |           { | 
|---|
| 284 |             uint32_t num_cpu = i*nb_cpu_by_cache; | 
|---|
| 285 |  | 
|---|
| 286 |             std::ostringstream str; | 
|---|
| 287 |             str << "proc_" << num_cpu; | 
|---|
| 288 |  | 
|---|
| 289 |             proc[i] = new soclib::caba::VciCcXCacheWrapperV4<vci_param, proc_iss > (str.str().c_str(), num_cpu, maptabp, maptabc, IntTab(i),IntTab(i),IntTab(i) | 
|---|
| 290 | #if USE_OLD_XCACHE | 
|---|
| 291 |                                                                                     ,iways, isets, iwords | 
|---|
| 292 |                                                                                     ,dways, dsets, dwords | 
|---|
| 293 | #else | 
|---|
| 294 |                                                                                     ,nb_cpu_by_cache    | 
|---|
| 295 |                                                                                     ,nb_dcache | 
|---|
| 296 |                                                                                     ,iways*nb_cpu_by_cache, isets, iwords | 
|---|
| 297 |                                                                                     ,dways*nb_cpu_by_cache, dsets, dwords | 
|---|
| 298 |                                                                                     ,wnwords, wnlines*nb_cpu_by_cache, wtimeout | 
|---|
| 299 | #endif | 
|---|
| 300 |                                                                                     ); | 
|---|
| 301 |  | 
|---|
| 302 | #if not USE_OLD_XCACHE | 
|---|
| 303 |             proc[i]->stop_simulation(STOP_SIMULATION_NB_FRZ_CYCLES); | 
|---|
| 304 | #endif | 
|---|
| 305 |           } | 
|---|
| 306 |  | 
|---|
| 307 |         soclib::caba::VciSimpleRam<vci_param>  | 
|---|
| 308 |         rom ("rom", IntTab(0), maptabp, loader); | 
|---|
| 309 |  | 
|---|
| 310 |         soclib::caba::VciSimpleRam<vci_param>  | 
|---|
| 311 |         xram("xram", IntTab(0), maptabx, loader); | 
|---|
| 312 |  | 
|---|
| 313 |         //                                  x_init    c_init          p_tgt     c_tgt | 
|---|
| 314 |         soclib::caba::VciMemCacheV4<vci_param>  | 
|---|
| 315 |         memc("memc",maptabp,maptabc,maptabx,IntTab(0),IntTab(nb_proc),IntTab(2),IntTab(nb_proc), memc_nways, memc_nsets, memc_words, memc_heap_size); | 
|---|
| 316 |  | 
|---|
| 317 |         std::vector<std::string> tty_name; | 
|---|
| 318 |         for (uint32_t i=0; i<nb_proc*nb_cpu_by_cache; ++i) | 
|---|
| 319 |           { | 
|---|
| 320 |             std::ostringstream str; | 
|---|
| 321 |             str << "tty_" << i; | 
|---|
| 322 |  | 
|---|
| 323 |             tty_name.push_back(str.str()); | 
|---|
| 324 |           } | 
|---|
| 325 |          | 
|---|
| 326 |         soclib::caba::VciMultiTty<vci_param>  | 
|---|
| 327 |         tty("tty",IntTab(1),maptabp,tty_name); | 
|---|
| 328 |  | 
|---|
| 329 |         soclib::caba::VciXicu<vci_param>  | 
|---|
| 330 |         xicu("xicu", maptabp, IntTab(3), PARAM_XICU); | 
|---|
| 331 |  | 
|---|
| 332 |         // soclib::caba::VciTimer<vci_param>  | 
|---|
| 333 |         // timer("timer", IntTab(3), maptabp, nb_proc); | 
|---|
| 334 |  | 
|---|
| 335 |         soclib::caba::VciSimhelper<vci_param>  | 
|---|
| 336 |         simhelper("simhelper", IntTab(4), maptabp); | 
|---|
| 337 |  | 
|---|
| 338 |         //                  initiatior | target  | 
|---|
| 339 |         // interconnect_p : proc       | rom, tty, memc, xicu, simhelper | 
|---|
| 340 |         // interconnect_c : proc, memc | proc, memc | 
|---|
| 341 |         // interconnect_x : memc       | xram | 
|---|
| 342 |  | 
|---|
| 343 |         soclib::caba::VciSimpleRingFast<vci_param,40,33>  | 
|---|
| 344 |         interconnect_p("interconnect_p",maptabp, IntTab(), PARAM_RING_P,nb_proc  , 5        ); | 
|---|
| 345 |  | 
|---|
| 346 |         soclib::caba::VciSimpleRingFast<vci_param,40,33> | 
|---|
| 347 |         interconnect_c("interconnect_c",maptabc, IntTab(), PARAM_RING_C,nb_proc+1, nb_proc+1); | 
|---|
| 348 |  | 
|---|
| 349 |         soclib::caba::VciSimpleRingFast<vci_param,40,33> | 
|---|
| 350 |         interconnect_x("interconnect_x",maptabx, IntTab(), PARAM_RING_X,1        , 1        ); | 
|---|
| 351 |  | 
|---|
| 352 |         // Net-List | 
|---|
| 353 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 354 |           { | 
|---|
| 355 |             proc[i]->p_clk(signal_clk);   | 
|---|
| 356 |             proc[i]->p_resetn(signal_resetn); | 
|---|
| 357 |             for (uint32_t j=0; j<nb_cpu_by_cache; ++j) | 
|---|
| 358 |               { | 
|---|
| 359 |                 proc[i]->p_irq[j][0](signal_proc_it[i][j][0]); | 
|---|
| 360 |                 proc[i]->p_irq[j][1](signal_proc_it[i][j][1]); | 
|---|
| 361 |                 proc[i]->p_irq[j][2](signal_proc_it[i][j][2]); | 
|---|
| 362 |                 proc[i]->p_irq[j][3](signal_proc_it[i][j][3]); | 
|---|
| 363 |                 proc[i]->p_irq[j][4](signal_proc_it[i][j][4]); | 
|---|
| 364 |                 proc[i]->p_irq[j][5](signal_proc_it[i][j][5]); | 
|---|
| 365 |               } | 
|---|
| 366 |             proc[i]->p_vci_ini_rw(signal_vci_ini_rw_proc[i]); | 
|---|
| 367 |             proc[i]->p_vci_ini_c(signal_vci_ini_c_proc[i]); | 
|---|
| 368 |             proc[i]->p_vci_tgt(signal_vci_tgt_proc[i]); | 
|---|
| 369 |           } | 
|---|
| 370 |  | 
|---|
| 371 |         rom.p_clk(signal_clk); | 
|---|
| 372 |         rom.p_resetn(signal_resetn); | 
|---|
| 373 |         rom.p_vci(signal_vci_tgt_rom); | 
|---|
| 374 |  | 
|---|
| 375 |         tty.p_clk(signal_clk); | 
|---|
| 376 |         tty.p_resetn(signal_resetn); | 
|---|
| 377 |         tty.p_vci(signal_vci_tgt_tty); | 
|---|
| 378 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 379 |           for (uint32_t j=0; j<nb_cpu_by_cache; ++j) | 
|---|
| 380 |             tty.p_irq[i*nb_cpu_by_cache+j](signal_tty_irq[i][j]);  | 
|---|
| 381 |  | 
|---|
| 382 |         xicu.p_clk(signal_clk); | 
|---|
| 383 |         xicu.p_resetn(signal_resetn); | 
|---|
| 384 |         xicu.p_vci(signal_vci_tgt_xicu); | 
|---|
| 385 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 386 |           for (uint32_t j=0; j<nb_cpu_by_cache; ++j) | 
|---|
| 387 |           { | 
|---|
| 388 |             xicu.p_hwi[i*nb_cpu_by_cache+j](signal_tty_irq[i][j]); | 
|---|
| 389 |             xicu.p_irq[i*nb_cpu_by_cache+j](signal_proc_it[i][j][0]); | 
|---|
| 390 |           } | 
|---|
| 391 |  | 
|---|
| 392 |         simhelper.p_clk(signal_clk); | 
|---|
| 393 |         simhelper.p_resetn(signal_resetn); | 
|---|
| 394 |         simhelper.p_vci(signal_vci_tgt_simhelper); | 
|---|
| 395 |  | 
|---|
| 396 |         memc.p_clk(signal_clk); | 
|---|
| 397 |         memc.p_resetn(signal_resetn); | 
|---|
| 398 |         memc.p_vci_tgt(signal_vci_tgt_memc); | 
|---|
| 399 |         memc.p_vci_tgt_cleanup(signal_vci_tgt_cleanup_memc); | 
|---|
| 400 |         memc.p_vci_ini(signal_vci_ini_memc); | 
|---|
| 401 |         memc.p_vci_ixr(signal_vci_ixr_memc); | 
|---|
| 402 |  | 
|---|
| 403 |         xram.p_clk(signal_clk); | 
|---|
| 404 |         xram.p_resetn(signal_resetn); | 
|---|
| 405 |         xram.p_vci(signal_vci_tgt_xram); | 
|---|
| 406 |          | 
|---|
| 407 |         interconnect_p.p_clk(signal_clk); | 
|---|
| 408 |         interconnect_p.p_resetn(signal_resetn); | 
|---|
| 409 |  | 
|---|
| 410 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 411 |         interconnect_p.p_to_initiator[i](signal_vci_ini_rw_proc[i]); | 
|---|
| 412 |  | 
|---|
| 413 |         interconnect_p.p_to_target[0](signal_vci_tgt_rom); | 
|---|
| 414 |         interconnect_p.p_to_target[1](signal_vci_tgt_tty); | 
|---|
| 415 |         interconnect_p.p_to_target[2](signal_vci_tgt_memc); | 
|---|
| 416 |         interconnect_p.p_to_target[3](signal_vci_tgt_xicu); | 
|---|
| 417 |         interconnect_p.p_to_target[4](signal_vci_tgt_simhelper); | 
|---|
| 418 |  | 
|---|
| 419 |         interconnect_c.p_clk(signal_clk); | 
|---|
| 420 |         interconnect_c.p_resetn(signal_resetn); | 
|---|
| 421 |  | 
|---|
| 422 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 423 |         interconnect_c.p_to_initiator[i](signal_vci_ini_c_proc[i]); | 
|---|
| 424 |         interconnect_c.p_to_initiator[nb_proc](signal_vci_ini_memc); | 
|---|
| 425 |  | 
|---|
| 426 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 427 |         interconnect_c.p_to_target[i](signal_vci_tgt_proc[i]); | 
|---|
| 428 |         interconnect_c.p_to_target[nb_proc](signal_vci_tgt_cleanup_memc); | 
|---|
| 429 |  | 
|---|
| 430 |         interconnect_x.p_clk(signal_clk); | 
|---|
| 431 |         interconnect_x.p_resetn(signal_resetn); | 
|---|
| 432 |  | 
|---|
| 433 |         interconnect_x.p_to_initiator[0](signal_vci_ixr_memc); | 
|---|
| 434 |  | 
|---|
| 435 |         interconnect_x.p_to_target[0](signal_vci_tgt_xram); | 
|---|
| 436 |  | 
|---|
| 437 |         sc_start(sc_core::sc_time(0, SC_NS)); | 
|---|
| 438 |         signal_resetn = false; | 
|---|
| 439 |         sc_start(sc_core::sc_time(1, SC_NS)); | 
|---|
| 440 |         signal_resetn = true; | 
|---|
| 441 |  | 
|---|
| 442 | #if SOCVIEW | 
|---|
| 443 |         debug(); | 
|---|
| 444 | #elif DEBUG_TOP | 
|---|
| 445 |  | 
|---|
| 446 |         uint32_t num_cycle=0; | 
|---|
| 447 |         while(1) | 
|---|
| 448 |           { | 
|---|
| 449 |             std::cout << std::endl | 
|---|
| 450 |                       << std::dec << "===== [ cycle " << num_cycle << " ]======" << std::endl | 
|---|
| 451 |                       << std::endl; | 
|---|
| 452 |              | 
|---|
| 453 |             sc_start(sc_core::sc_time(1, SC_NS)); | 
|---|
| 454 |              | 
|---|
| 455 |             // for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 456 |             //   proc[i]->print_trace(1); | 
|---|
| 457 |             num_cycle ++; | 
|---|
| 458 |           } | 
|---|
| 459 | #else | 
|---|
| 460 |         if (ncycles==-1) | 
|---|
| 461 |           sc_start(); | 
|---|
| 462 |         else | 
|---|
| 463 |           sc_start(sc_core::sc_time(ncycles, SC_NS)); | 
|---|
| 464 |  | 
|---|
| 465 |         // std::cout << "Hit ENTER to end simulation" << std::endl; | 
|---|
| 466 |         // char buf[1]; | 
|---|
| 467 |         // std::cin.getline(buf,1); | 
|---|
| 468 | #endif | 
|---|
| 469 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 470 |           proc[i]->print_cpi(); | 
|---|
| 471 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 472 |           proc[i]->print_stats(); | 
|---|
| 473 |  | 
|---|
| 474 |         soclib::common::dealloc_elems<sc_signal<bool>                     >(signal_tty_irq         , nb_proc, nb_cpu_by_cache); | 
|---|
| 475 |         soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_tgt_proc    , nb_proc); | 
|---|
| 476 |         soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_c_proc  , nb_proc); | 
|---|
| 477 |         soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_rw_proc , nb_proc); | 
|---|
| 478 |         soclib::common::dealloc_elems<sc_signal<bool>                     >(signal_proc_it         , nb_proc, nb_cpu_by_cache, 6); | 
|---|
| 479 |  | 
|---|
| 480 |         for (uint32_t i=0; i<nb_proc; ++i) | 
|---|
| 481 |           delete proc[i]; | 
|---|
| 482 |  | 
|---|
| 483 |         return EXIT_SUCCESS; | 
|---|
| 484 | } | 
|---|
| 485 |  | 
|---|
| 486 | int sc_main (int argc, char *argv[]) | 
|---|
| 487 | { | 
|---|
| 488 |   try { | 
|---|
| 489 |     return _main(argc, argv); | 
|---|
| 490 |   } catch (std::exception &e) { | 
|---|
| 491 |     std::cout << e.what() << std::endl; | 
|---|
| 492 |   } catch (...) { | 
|---|
| 493 |     std::cout << "Unknown exception occured" << std::endl; | 
|---|
| 494 |     throw; | 
|---|
| 495 |   } | 
|---|
| 496 |   return 1; | 
|---|
| 497 | } | 
|---|