📄 main.cpp
字号:
TGlobalParams::routing_algorithm = ROUTING_TABLE_BASED; strcpy(TGlobalParams::routing_table_filename, arg_vet[i+2]); FILE* fp = fopen(TGlobalParams::routing_table_filename, "r"); if(fp==NULL) badInputFilename(TGlobalParams::routing_table_filename); fclose(fp); TGlobalParams::packet_injection_rate = 0; i++; } else badArgument(arg_vet[i+1], arg_vet[i]); i+=2; } else if(!strcmp(arg_vet[i],"-sel")) { if(!strcmp(arg_vet[i+1],"random")) TGlobalParams::selection_strategy = SEL_RANDOM; else if(!strcmp(arg_vet[i+1],"bufferlevel")) TGlobalParams::selection_strategy = SEL_BUFFER_LEVEL; else if(!strcmp(arg_vet[i+1],"nop")) TGlobalParams::selection_strategy = SEL_NOP; else badArgument(arg_vet[i+1], arg_vet[i]); i+=2; } else if(!strcmp(arg_vet[i],"-pir")) { float new_pir = atof(arg_vet[i+1]); if(new_pir>0) { TGlobalParams::packet_injection_rate = new_pir; i+=2; specifiedPir = true; } else badArgument(arg_vet[i+1], arg_vet[i]); } else if(!strcmp(arg_vet[i],"-dist")) { float new_por = 0; if(!strcmp(arg_vet[i+1],"poisson")) { new_por = TGlobalParams::packet_injection_rate; } else if(!strcmp(arg_vet[i+1],"burst")) { float burstness = atof(arg_vet[i+2]); new_por = TGlobalParams::packet_injection_rate/(1-burstness); i++; } else if(!strcmp(arg_vet[i+1],"pareto")) { float Aon = atof(arg_vet[i+2]); float Aoff = atof(arg_vet[i+3]); float r = atof(arg_vet[i+4]); new_por = TGlobalParams::packet_injection_rate*pow((1-r),(1/Aoff-1/Aon)); i+=3; } else if(!strcmp(arg_vet[i+1],"custom")) { new_por = atof(arg_vet[i+2]); i++; } else badArgument(arg_vet[i+1], arg_vet[i]); assert(new_por>=0 && new_por<=1); specifiedPor = true; TGlobalParams::probability_of_retransmission = new_por; i+=2; } else if(!strcmp(arg_vet[i],"-traffic")) { if(!strcmp(arg_vet[i+1],"random")) TGlobalParams::traffic_distribution = TRAFFIC_RANDOM; else if(!strcmp(arg_vet[i+1],"transpose1")) TGlobalParams::traffic_distribution = TRAFFIC_TRANSPOSE1; else if(!strcmp(arg_vet[i+1],"transpose2")) TGlobalParams::traffic_distribution = TRAFFIC_TRANSPOSE2; else if(!strcmp(arg_vet[i+1],"bitreversal")) TGlobalParams::traffic_distribution = TRAFFIC_BIT_REVERSAL; else if(!strcmp(arg_vet[i+1],"butterfly")) TGlobalParams::traffic_distribution = TRAFFIC_BUTTERFLY; else if(!strcmp(arg_vet[i+1],"shuffle")) TGlobalParams::traffic_distribution = TRAFFIC_SHUFFLE; else if(!strcmp(arg_vet[i+1],"table")) { TGlobalParams::traffic_distribution = TRAFFIC_TABLE_BASED; strcpy(TGlobalParams::traffic_table_filename, arg_vet[i+2]); FILE* fp = fopen(TGlobalParams::traffic_table_filename, "r"); if(fp==NULL) badInputFilename(TGlobalParams::traffic_table_filename); fclose(fp); i++; } else badArgument(arg_vet[i+1], arg_vet[i]); i+=2; } else if(!strcmp(arg_vet[i],"-hs")) { int node = atoi(arg_vet[i+1]); double percentage = atof(arg_vet[i+2]); if ( node>=0 && percentage >= 0.0) { pair<int,double> t(node,percentage); TGlobalParams::hotspots.push_back(t); i+=3; cout << "\n Added node " << node << " with P = " << percentage << endl; } else { cout << "\n Bad -hs arguments ! " << endl; exit(1); } } else if(!strcmp(arg_vet[i],"-warmup")) { int new_warmup = atoi(arg_vet[i+1]); if(new_warmup>=0) { TGlobalParams::stats_warm_up_time = new_warmup; i+=2; } else badArgument(arg_vet[i+1], arg_vet[i]); } else if(!strcmp(arg_vet[i],"-seed")) { int new_rnd_generator_seed = atoi(arg_vet[i+1]); if(new_rnd_generator_seed>=0) { TGlobalParams::rnd_generator_seed = new_rnd_generator_seed; i+=2; } else badArgument(arg_vet[i+1], arg_vet[i]); } else if(!strcmp(arg_vet[i],"-detailed")) { TGlobalParams::detailed = true; i++; } else if(!strcmp(arg_vet[i],"-volume")) { int new_vol = atoi(arg_vet[i+1]); if(new_vol>1) { TGlobalParams::max_volume_to_be_drained = new_vol; i+=2; } else badArgument(arg_vet[i+1], arg_vet[i]); } else if(!strcmp(arg_vet[i],"-sim")) { int new_sim = atoi(arg_vet[i+1]); if(new_sim>1) { TGlobalParams::simulation_time = new_sim; i+=2; } else badArgument(arg_vet[i+1], arg_vet[i]); } else badOption(arg_vet[i]); } while (i<arg_num); } // Check special cases if(specifiedPir && !specifiedPor) TGlobalParams::probability_of_retransmission = TGlobalParams::packet_injection_rate; if (TGlobalParams::routing_algorithm == ROUTING_XY && TGlobalParams::selection_strategy != SEL_RANDOM) { cout << "\n Warning: using -sel option in conjunction with XY static routing!" << endl; } // Show configuration if(TGlobalParams::verbose_mode > VERBOSE_OFF) showConfig(); // Signals sc_clock clock("clock", 1, SC_NS); sc_signal<bool> reset; // NoC instance TNoC* n = new TNoC("NoC"); n->clock(clock); n->reset(reset); // Trace signals sc_trace_file* tf = NULL; if(TGlobalParams::trace_mode) { tf = sc_create_vcd_trace_file(TGlobalParams::trace_filename); sc_trace(tf, reset, "reset"); sc_trace(tf, clock, "clock"); for(int i=0; i<TGlobalParams::mesh_dim_x; i++) { for(int j=0; j<TGlobalParams::mesh_dim_y; j++) { char label[30]; sprintf(label, "req_to_east(%02d)(%02d)", i, j); sc_trace(tf, n->req_to_east[i][j], label); sprintf(label, "req_to_west(%02d)(%02d)", i, j); sc_trace(tf, n->req_to_west[i][j], label); sprintf(label, "req_to_south(%02d)(%02d)", i, j); sc_trace(tf, n->req_to_south[i][j], label); sprintf(label, "req_to_north(%02d)(%02d)", i, j); sc_trace(tf, n->req_to_north[i][j], label); sprintf(label, "ack_to_east(%02d)(%02d)", i, j); sc_trace(tf, n->ack_to_east[i][j], label); sprintf(label, "ack_to_west(%02d)(%02d)", i, j); sc_trace(tf, n->ack_to_west[i][j], label); sprintf(label, "ack_to_south(%02d)(%02d)", i, j); sc_trace(tf, n->ack_to_south[i][j], label); sprintf(label, "ack_to_north(%02d)(%02d)", i, j); sc_trace(tf, n->ack_to_north[i][j], label);/* sprintf(label, "flit_to_east(%02d)(%02d)", i, j); sc_trace(tf, n->flit_to_east[i][j], label); sprintf(label, "flit_to_west(%02d)(%02d)", i, j); sc_trace(tf, n->flit_to_west[i][j], label); sprintf(label, "flit_to_south(%02d)(%02d)", i, j); sc_trace(tf, n->flit_to_south[i][j], label); sprintf(label, "flit_to_north(%02d)(%02d)", i, j); sc_trace(tf, n->flit_to_north[i][j], label);*/ } } } // Reset the chip and run the simulation reset.write(1); cout << "Reset..."; srand(TGlobalParams::rnd_generator_seed); // time(NULL)); sc_start(DEFAULT_RESET_TIME, SC_NS); reset.write(0); cout << " done! Now running for " << TGlobalParams::simulation_time << " cycles..." << endl; sc_start(TGlobalParams::simulation_time, SC_NS); // Close the simulation if(TGlobalParams::trace_mode) sc_close_vcd_trace_file(tf); cout << "Noxim simulation completed." << endl; cout << " ( " << sc_time_stamp().to_double()/1000 << " cycles executed)" << endl; // Show statistics TGlobalStats gs(n); gs.showStats(std::cout, TGlobalParams::detailed); if ((TGlobalParams::max_volume_to_be_drained>0) && (sc_time_stamp().to_double()/1000 >= TGlobalParams::simulation_time)) { cout << "\nWARNING! the number of flits specified with -volume option"<<endl; cout << "has not been reached. ( " << drained_volume << " instead of " << TGlobalParams::max_volume_to_be_drained << " )" <<endl; cout << "You might want to try an higher value of simulation cycles" << endl; cout << "using -sim option." << endl;#ifdef TESTING cout << "\n Sum of local drained flits: " << gs.drained_total << endl; cout << "\n Effective drained volume: " << drained_volume;#endif } /* for (int y=0; y<MESH_DIM_Y; y++) for (int x=0; x<MESH_DIM_X; x++) n->t[x][y]->r->stats.showStats(); */ time_t local = time(NULL); while ( time(NULL)-local< 40 ) ; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -