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