- Timestamp:
- Mar 9, 2011, 4:11:43 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp
r137 r140 31 31 # define PARAM_VCI 4,8,32,1,1,1,8,4,4,1 32 32 33 # define USE_OLD_XCACHE 0 34 # define USE_VGMN 1 33 35 # define NB_PROC_MIN 1 34 36 # define NB_PROC_MAX 15 35 // min_latency,fifo_depth37 // fifo_depth 36 38 # define PARAM_RING_P 2 37 39 # define PARAM_RING_C 2 38 40 # define PARAM_RING_X 2 39 41 // pti , hwi , wti, irq 40 # define PARAM_XICU nb_proc, nb_proc, 0 , nb_proc 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 41 44 42 45 // * Debug … … 46 49 47 50 // * Simulation 48 # define FILE_DEFAULT "configuration/default.cfg"51 # define CONFIG_DEFAULT "configuration/default.cfg" 49 52 # define NCYCLES_DEFAULT 0 50 53 # define SOFT_DEFAULT "soft/bin.soft" … … 53 56 void usage (char * funcname) 54 57 { 55 std::cout << funcname << " [nb_cycle [file [soft]]] " << std::endl; 56 std::cout << " * nb_cycle : number of simulated cycle, if 0 then no stop condition. (default : " << NCYCLES_DEFAULT << " cycle(s))" << std::endl; 57 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))" << std::endl; 58 std::cout << " * soft : software executed by this platforms. (default : \"" << SOFT_DEFAULT << "\")" << std::endl; 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; 59 71 60 72 exit(1); … … 63 75 int _main(int argc, char *argv[]) 64 76 { 65 if ((argc < 1) or (argc > 4)) 66 { 67 std::cout << "Invalid parameters number." << std::endl; 68 usage(argv[0]); 69 } 70 71 #if not SOCVIEW 72 int ncycles = 0; 73 74 if (argc >= 2) 75 ncycles = std::atoi(argv[1]); 76 else 77 ncycles = NCYCLES_DEFAULT; 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 } 78 105 79 106 if (ncycles == 0) 80 107 ncycles = -1; 81 #endif82 108 83 109 uint32_t nb_proc; 110 uint32_t nb_cpu_by_cache; 111 uint32_t nb_dcache; 84 112 uint32_t iways, isets, iwords; 85 113 uint32_t dways, dsets, dwords; … … 88 116 89 117 std::ifstream inFile; 90 const char * filename = (argc>=3)?argv[2]:FILE_DEFAULT;118 const char * filename = config; 91 119 92 120 inFile.open(filename); … … 102 130 nb_proc =std::atoi(str.c_str()); 103 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]);} 104 136 iways =std::atoi(str.c_str()); 105 137 if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} … … 128 160 memc_heap_size =std::atoi(str.c_str()); 129 161 130 if (( nb_proc<NB_PROC_MIN) or131 ( nb_proc>NB_PROC_MAX))162 if (((nb_proc*nb_cpu_by_cache)<NB_PROC_MIN) or 163 ((nb_proc*nb_cpu_by_cache)>NB_PROC_MAX)) 132 164 { 133 165 std::cout << "Parameters nb_proc is out of bound." << std::endl; … … 135 167 } 136 168 137 char * soft;138 139 if (argc >= 4)140 soft = argv[3];141 else142 soft = SOFT_DEFAULT;143 144 169 std::cout << " * Parameters : " << std::endl; 145 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; 146 173 std::cout << " * iways : " << iways << std::endl; 147 174 std::cout << " * isets : " << isets << std::endl; … … 180 207 maptabp.add(Segment("mc_r" , MC_R_BASE , MC_R_SIZE , IntTab(2), false, true, IntTab(0))); 181 208 maptabp.add(Segment("mc_m" , MC_M_BASE , MC_M_SIZE , IntTab(2), true)); 182 // maptabp.add(Segment("ptba" , PTD_ADDR , TAB_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)); 183 211 maptabp.add(Segment("xicu" , XICU_BASE , XICU_SIZE , IntTab(3), false)); 184 212 maptabp.add(Segment("simhelper", SIMHELPER_BASE, SIMHELPER_SIZE, IntTab(4), false)); … … 187 215 188 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 // } 189 224 for (uint32_t i=0; i<nb_proc; ++i) 190 225 { … … 195 230 maptabc.add(Segment("mc_r" , MC_R_BASE , MC_R_SIZE , IntTab(nb_proc), false, false)); 196 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)); 197 233 maptabc.add(Segment("reset" , RESET_BASE , RESET_SIZE , IntTab(nb_proc), false, false)); 198 234 maptabc.add(Segment("excep" , EXCEP_BASE , EXCEP_SIZE , IntTab(nb_proc), false, false)); 199 235 maptabc.add(Segment("text" , TEXT_BASE , TEXT_SIZE , IntTab(nb_proc), false, false)); 200 //maptabc.add(Segment("ptba" , PTD_ADDR , TAB_SIZE , IntTab(nb_proc), false, false));236 //maptabc.add(Segment("ptba" , PTD_ADDR , TAB_SIZE , IntTab(nb_proc), false, false)); 201 237 202 238 std::cout << maptabc << std::endl; … … 204 240 soclib::common::MappingTable maptabx(32, IntTab(8), IntTab(8), 0x00300000); 205 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)); 206 243 maptabx.add(Segment("reset", RESET_BASE, RESET_SIZE, IntTab(0), false)); 207 244 maptabx.add(Segment("excep", EXCEP_BASE, EXCEP_SIZE, IntTab(0), false)); … … 215 252 sc_signal<bool> signal_resetn("resetn"); 216 253 217 sc_signal<bool> ** signal_proc_it = soclib::common::alloc_elems<sc_signal<bool> >("proc_it", nb_proc, 6);254 sc_signal<bool> *** signal_proc_it = soclib::common::alloc_elems<sc_signal<bool> >("proc_it", nb_proc, nb_cpu_by_cache, 6); 218 255 219 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); … … 236 273 soclib::caba::VciSignals<vci_param> signal_vci_tgt_cleanup_memc("vci_tgt_cleanup_memc"); 237 274 238 sc_signal<bool> * signal_tty_irq = soclib::common::alloc_elems<sc_signal<bool> >("signal_tty_irq", nb_proc);275 sc_signal<bool> ** signal_tty_irq = soclib::common::alloc_elems<sc_signal<bool> >("signal_tty_irq", nb_proc, nb_cpu_by_cache); 239 276 240 277 soclib::common::Loader loader(soft); … … 245 282 for (uint32_t i=0; i<nb_proc; ++i) 246 283 { 284 uint32_t num_cpu = i*nb_cpu_by_cache; 285 247 286 std::ostringstream str; 248 str << "proc_" << i; 249 250 proc[i] = new soclib::caba::VciCcXCacheWrapperV4<vci_param, proc_iss > (str.str().c_str(), i, maptabp, maptabc, IntTab(i),IntTab(i),IntTab(i) 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 251 291 ,iways, isets, iwords 252 292 ,dways, dsets, dwords 253 ,wnwords, wnlines, wtimeout 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 254 300 ); 255 301 … … 267 313 // x_init c_init p_tgt c_tgt 268 314 soclib::caba::VciMemCacheV4<vci_param> 269 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); 270 316 271 317 std::vector<std::string> tty_name; 272 for (uint32_t i=0; i<nb_proc ; ++i)318 for (uint32_t i=0; i<nb_proc*nb_cpu_by_cache; ++i) 273 319 { 274 320 std::ostringstream str; … … 308 354 { 309 355 proc[i]->p_clk(signal_clk); 310 proc[i]->p_resetn(signal_resetn); 311 proc[i]->p_irq[0](signal_proc_it[i][0]); 312 proc[i]->p_irq[1](signal_proc_it[i][1]); 313 proc[i]->p_irq[2](signal_proc_it[i][2]); 314 proc[i]->p_irq[3](signal_proc_it[i][3]); 315 proc[i]->p_irq[4](signal_proc_it[i][4]); 316 proc[i]->p_irq[5](signal_proc_it[i][5]); 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 } 317 366 proc[i]->p_vci_ini_rw(signal_vci_ini_rw_proc[i]); 318 367 proc[i]->p_vci_ini_c(signal_vci_ini_c_proc[i]); … … 328 377 tty.p_vci(signal_vci_tgt_tty); 329 378 for (uint32_t i=0; i<nb_proc; ++i) 330 tty.p_irq[i](signal_tty_irq[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]); 331 381 332 382 xicu.p_clk(signal_clk); … … 334 384 xicu.p_vci(signal_vci_tgt_xicu); 335 385 for (uint32_t i=0; i<nb_proc; ++i) 336 { 337 xicu.p_hwi[i](signal_tty_irq[i]); 338 xicu.p_irq[i](signal_proc_it[i][0]); 339 } 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 } 340 391 341 392 simhelper.p_clk(signal_clk); … … 392 443 debug(); 393 444 #elif DEBUG_TOP 394 for (int32_t i=0; i<ncycles; ++i) 445 446 uint32_t num_cycle=0; 447 while(1) 395 448 { 396 449 std::cout << std::endl 397 << std::dec << "===== [ cycle " << i<< " ]======" << std::endl450 << std::dec << "===== [ cycle " << num_cycle << " ]======" << std::endl 398 451 << std::endl; 399 452 … … 402 455 // for (uint32_t i=0; i<nb_proc; ++i) 403 456 // proc[i]->print_trace(1); 457 num_cycle ++; 404 458 } 405 459 #else … … 418 472 proc[i]->print_stats(); 419 473 420 soclib::common::dealloc_elems<sc_signal<bool> >(signal_tty_irq , nb_proc );474 soclib::common::dealloc_elems<sc_signal<bool> >(signal_tty_irq , nb_proc, nb_cpu_by_cache); 421 475 soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_tgt_proc , nb_proc); 422 476 soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_c_proc , nb_proc); 423 477 soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_rw_proc , nb_proc); 424 soclib::common::dealloc_elems<sc_signal<bool> >(signal_proc_it , nb_proc, 6);478 soclib::common::dealloc_elems<sc_signal<bool> >(signal_proc_it , nb_proc, nb_cpu_by_cache, 6); 425 479 426 480 for (uint32_t i=0; i<nb_proc; ++i)
Note: See TracChangeset
for help on using the changeset viewer.