URL
https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk
Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc
Compare Revisions
- This comparison shows the changes necessary to convert path
/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk/mpsoc/src_verilator
- from Rev 48 to Rev 54
- ↔ Reverse comparison
Rev 48 → Rev 54
/netrace_lib.h
39,7 → 39,7
int nt_packets_left = 0; |
|
|
int netrace_to_pronoc_map [64]; |
int * traffic_model_mapping; |
int pronoc_to_netrace_map [NE]; |
int pck_injct_in_pck_wr[NE]; |
|
63,7 → 63,7
|
|
void netrace_init( char * tracefile){ |
int i=0; |
int i=0; |
nt_open_trfile( tracefile ); |
if( ignore_dependencies ) { |
nt_disable_dependencies(); |
83,19 → 83,21
nt_start_cycle=nt_cycle; |
} |
|
waiting = (queue_t**) malloc( header->num_nodes * sizeof(queue_t*) ); |
inject = (queue_t**) malloc( header->num_nodes * sizeof(queue_t*) ); |
traverse = (queue_t**) malloc( header->num_nodes * sizeof(queue_t*) ); |
waiting = (queue_t**) malloc( NE * sizeof(queue_t*) ); |
inject = (queue_t**) malloc( NE * sizeof(queue_t*) ); |
traverse = (queue_t**) malloc( NE * sizeof(queue_t*) ); |
if( (waiting == NULL) || (inject == NULL) || (traverse == NULL) ) { |
printf( "ERROR: malloc fail queues\n" ); |
exit(0); |
} |
for( i = 0; i < header->num_nodes; ++i ) { |
|
for( i = 0; i < NE; ++i ) { |
waiting[i] = queue_new(); |
inject[i] = queue_new(); |
traverse[i] = queue_new(); |
} |
|
|
if( !reader_throttling ) { |
trace_packet = nt_read_packet(); |
} else if( !ignore_dependencies ) { |
122,6 → 124,7
|
void netrace_eval(unsigned int eval_num){ |
int i; |
unsigned int pronoc_src_id,pronoc_dst_id; |
|
if((reset==1) || (count_en==0)) return; |
|
140,7 → 143,8
queue_node_t* new_node = (queue_node_t*) nt_checked_malloc( sizeof(queue_node_t) ); |
new_node->packet = trace_packet; |
new_node->cycle = (trace_packet->cycle > nt_cycle) ? trace_packet->cycle : nt_cycle; |
queue_push( inject[trace_packet->src], new_node, new_node->cycle ); |
pronoc_src_id=traffic_model_mapping[trace_packet->src]; |
queue_push( inject[pronoc_src_id], new_node, new_node->cycle ); |
nt_total_rd_pck++; |
} else { |
printf( "ERROR: Malformed packet list" ); |
154,13 → 158,14
queue_node_t* new_node = (queue_node_t*) nt_checked_malloc( sizeof(queue_node_t) ); |
new_node->packet = trace_packet; |
new_node->cycle = (trace_packet->cycle > nt_cycle) ? trace_packet->cycle : nt_cycle; |
pronoc_src_id=traffic_model_mapping[trace_packet->src]; |
if( ignore_dependencies || nt_dependencies_cleared( trace_packet ) ) { |
// Add to inject queue |
queue_push( inject[trace_packet->src], new_node, new_node->cycle ); |
queue_push( inject[pronoc_src_id], new_node, new_node->cycle ); |
nt_total_rd_pck++; |
} else { |
// Add to waiting queue |
queue_push( waiting[trace_packet->src], new_node, new_node->cycle ); |
queue_push( waiting[pronoc_src_id], new_node, new_node->cycle ); |
nt_total_rd_pck++; |
} |
// Get another packet from trace |
184,21 → 189,20
|
|
// Inject where possible (max one per node) |
for( i = 0; i < header->num_nodes; ++i ) { |
//header->num_nodes; |
for( i = 0; i < NE; ++i ) { |
nt_packets_left |= !queue_empty( inject[i] ); |
//TODO define RRA if multiple netrace sources are mapped to one node. only one can sent packt at each cycle |
int pronoc_src = netrace_to_pronoc_map[i]; |
//TODO define sent vc policy |
int sent_vc = 0; |
|
if(pck_inj[pronoc_src]->pck_injct_in_pck_wr){ |
if(pck_inj[i]->pck_injct_in_pck_wr){ |
//the wr_pck should be asserted only for single cycle |
pck_inj[pronoc_src]->pck_injct_in_pck_wr = 0; |
pck_inj[i]->pck_injct_in_pck_wr = 0; |
continue; |
} |
|
pck_inj[pronoc_src]->pck_injct_in_pck_wr = 0; |
if((pck_inj[pronoc_src]->pck_injct_out_ready & (0x1<<sent_vc)) == 0){ |
pck_inj[i]->pck_injct_in_pck_wr = 0; |
if((pck_inj[i]->pck_injct_out_ready & (0x1<<sent_vc)) == 0){ |
//This pck injector is not ready yet |
continue; |
} |
214,13 → 218,14
} |
temp_node = (queue_node_t*) queue_pop_front( inject[i] ); |
temp_node->cycle = nt_cycle;//injection time |
queue_push( traverse[packet->dst], temp_node, temp_node->cycle ); |
pronoc_dst_id = traffic_model_mapping[packet->dst]; |
queue_push( traverse[pronoc_dst_id ], temp_node, temp_node->cycle ); |
long int ptr_addr = reinterpret_cast<long int> (temp_node); |
int flit_num = (nt_get_packet_size(packet)* 8) / Fpay; |
if(flit_num< pck_inj[pronoc_src]->min_pck_size) flit_num = pck_inj[pronoc_src]->min_pck_size; |
int pronoc_dst = netrace_to_pronoc_map[packet->dst]; |
if(flit_num< pck_inj[i]->min_pck_size) flit_num = pck_inj[i]->min_pck_size; |
|
if(IS_SELF_LOOP_EN ==0){ |
if(packet->dst == pronoc_src ){ |
if(pronoc_dst_id == i ){ |
fprintf(stderr,"ERROR: ProNoC is not configured with self-loop enable and Netrace aims to inject\n a " |
"packet with identical source and destination address. Enable the SELF_LOOP parameter\n" |
"in ProNoC and rebuild the simulation model\n"); |
228,21 → 233,21
} |
} |
unsigned int sent_class =0; |
pck_inj[pronoc_src]->pck_injct_in_data = ptr_addr; |
pck_inj[pronoc_src]->pck_injct_in_size = flit_num; |
pck_inj[pronoc_src]->pck_injct_in_endp_addr = endp_addr_encoder(pronoc_dst); |
pck_inj[pronoc_src]->pck_injct_in_class_num = sent_class; |
pck_inj[pronoc_src]->pck_injct_in_init_weight = 1; |
pck_inj[pronoc_src]->pck_injct_in_vc = 0x1<<sent_vc; |
pck_inj[pronoc_src]->pck_injct_in_pck_wr = 1; |
pck_inj[i]->pck_injct_in_data = ptr_addr; |
pck_inj[i]->pck_injct_in_size = flit_num; |
pck_inj[i]->pck_injct_in_endp_addr = endp_addr_encoder(pronoc_dst_id); |
pck_inj[i]->pck_injct_in_class_num = sent_class; |
pck_inj[i]->pck_injct_in_init_weight = 1; |
pck_inj[i]->pck_injct_in_vc = 0x1<<sent_vc; |
pck_inj[i]->pck_injct_in_pck_wr = 1; |
total_sent_pck_num++; |
|
#if (C>1) |
sent_stat[pronoc_src][sent_class].pck_num ++; |
sent_stat[pronoc_src][sent_class].flit_num +=flit_num; |
sent_stat[i][sent_class].pck_num ++; |
sent_stat[i][sent_class].flit_num +=flit_num; |
#else |
sent_stat[pronoc_src].pck_num ++; |
sent_stat[pronoc_src].flit_num +=flit_num; |
sent_stat[i].pck_num ++; |
sent_stat[i].flit_num +=flit_num; |
#endif |
} |
} |
294,6 → 299,8
exit(1); |
} |
*/ |
|
pronoc_src_id=traffic_model_mapping[packet->src]; |
update_statistic_at_ejection ( |
i,// core_num |
clk_num_h2h, // clk_num_h2h, |
300,13 → 307,10
(unsigned int) clk_num_h2t, // clk_num_h2t, |
pck_inj[i]->pck_injct_out_distance, // distance, |
pck_inj[i]->pck_injct_out_class_num,// class_num, |
packet->src// unsigned int src |
pronoc_src_id,// unsigned int src |
pck_inj[i]->pck_injct_out_size |
); |
#if(C>1) |
rsvd_stat[i][pck_inj[i]->pck_injct_out_class_num].flit_num +=pck_inj[i]->pck_injct_out_size; |
#else |
rsvd_stat[i].flit_num+=pck_inj[i]->pck_injct_out_size; |
#endif |
|
free( temp_node ); |
|
} |
314,7 → 318,7
} |
// Check for cleared dependences... or not |
if( !reader_throttling ) { |
for( i = 0; i < header->num_nodes; ++i ) { |
for( i = 0; i < NE; ++i ) { |
nt_packets_left |= !queue_empty( waiting[i] ); |
node_t* temp = waiting[i]->head; |
while( temp != NULL ) { |
341,8 → 345,9
void netrace_posedge_event(){ |
unsigned int i; |
clk = 1; // Toggle clock |
update_all_router_stat(); |
for(i=0;i<netrace_speed_up; i++) netrace_eval(i); |
connect_clk_reset_start_all(); |
//connect_clk_reset_start_all(); |
sim_eval_all(); |
//print total sent packet each 1024 clock cycles |
if(verbosity==1) if(nt_cycle&0x3FF) printf("\rTotal sent packet: %9d", total_sent_pck_num); |
349,13 → 354,12
} |
|
|
void netrace_clk_negedge_event( ){ |
void netrace_negedge_event( ){ |
int i; |
clk = 0; |
topology_connect_all_nodes (); |
connect_clk_reset_start_all(); |
//connect_clk_reset_start_all(); |
sim_eval_all(); |
|
} |
|
|
372,21 → 376,11
"\tNetrace end clock cycles: %llu\n" |
"\tNetrace duration clock cycles: %llu\n" |
"\tProNoC duration clock cycles: %llu\n" |
,nt_cycle,total_clock,pronoc_total_clock); |
"\tSimulation clock cycles: %llu\n" |
,nt_cycle,total_clock,pronoc_total_clock,pronoc_total_clock); |
|
|
|
print_statistic_new (pronoc_total_clock); |
/* |
printf("\t total , %u , %u, %u, %u \n",total_sent_pck_num, total_rsv_pck_num,total_sent_flit_number,total_rsv_flit_number); |
printf("\nper node\n"); |
for(i=0;i<NE;i++){ |
printf("\t %u , %u , %u , %u , %u \n", i,sent_core_total_pck_num[i],rsvd_core_total_pck_num[i], sent_core_total_flit_num[i],rsv_core_total_flit_num[i] |
sent_core_worst_delay[i], rsvd_core_worst_delay[i] |
|
); |
} |
*/ |
printf("Netrace simulation results-------------------\n"); |
} |
|
|
/simulator.cpp
19,8 → 19,12
#include <cstdlib> |
#include <iostream> |
|
|
#include "simulator.h" |
|
|
|
|
int main(int argc, char** argv) { |
char change_injection_ratio=0; |
int i,j,x,y;//,report_delay_counter=0; |
30,7 → 34,7
for(i=0;i<NE;i++) custom_traffic_table[i]=INJECT_OFF; //off |
Verilated::commandArgs(argc, argv); // Remember args |
processArgs ( argc, argv ); |
|
allocate_rsv_pck_counters(); |
if (class_percentage==NULL) { |
class_percentage = (int *) malloc(sizeof(int)); |
class_percentage[0]=100; |
38,11 → 42,10
|
|
Vrouter_new(); |
if( TRAFFIC_TYPE == NETRACE) for(i=0;i<NE;i++) pck_inj[i] = new Vpck_inj; |
if (ENDP_TYPE == PCK_INJECTOR) for(i=0;i<NE;i++) pck_inj[i] = new Vpck_inj; |
else for(i=0;i<NE;i++) traffic[i] = new Vtraffic; |
|
|
if( TRAFFIC_TYPE == NETRACE) netrace_init(netrace_file); |
|
FIXED_SRC_DST_PAIR = strcmp (TRAFFIC,"RANDOM") & strcmp(TRAFFIC,"HOTSPOT") & strcmp(TRAFFIC,"random") & strcmp(TRAFFIC,"hot spot") & strcmp(TRAFFIC,"TASK"); |
|
54,9 → 57,24
reset=1; |
reset_all_register(); |
start_i=0; |
|
mcast_init(); |
|
|
|
topology_init(); |
if( TRAFFIC_TYPE == NETRACE) pck_inj_init(); |
if( TRAFFIC_TYPE == NETRACE){ |
netrace_init(netrace_file); // should be called first to initiate header |
pck_inj_init((int)header->num_nodes); |
} |
else if (TRAFFIC_TYPE ==SYNFUL) { |
pck_inj_init(SYNFUL_ENDP_NUM); //should be called first to initiate node mapping needed by synful lib |
synful_init(synful_file,synful_SSExit,synful_random_seed,sim_end_clk_num,end_sim_pck_num); |
} |
else traffic_gen_init(); |
|
|
|
main_time=0; |
print_parameter(); |
if( thread_num>1) initial_threads(); |
71,16 → 89,22
if(main_time == saved_time+23) start_i=0; |
|
if(TRAFFIC_TYPE==NETRACE) netrace_posedge_event(); |
else if(TRAFFIC_TYPE ==SYNFUL) synful_posedge_event(); |
else traffic_clk_posedge_event(); |
|
|
//The valus of all registers and input ports valuse change @ posedge of the clock. Once clk is deasserted, as multiple modules are connected inside the testbench we need several eval for propogating combinational logic values |
//between modules when the clock . |
for (i=0;i<SMART_MAX+2;i++) { |
if(TRAFFIC_TYPE==NETRACE) netrace_clk_negedge_event( ); |
if(TRAFFIC_TYPE==NETRACE) netrace_negedge_event(); |
else if(TRAFFIC_TYPE ==SYNFUL) synful_negedge_event(); |
else traffic_clk_negedge_event( ); |
} |
|
if(simulation_done){ |
|
if( TRAFFIC_TYPE == NETRACE) netrace_final_report(); |
else if(TRAFFIC_TYPE ==SYNFUL) synful_final_report(); |
else traffic_gen_final_report(); |
sim_final_all(); |
return 0; |
101,51 → 125,71
void usage(char * bin_name){ |
printf("Usage:\n" |
" %s -t <synthetic Traffic Pattern name> [synthetic Traffic options]\n" |
" %s -f <Task file> [Task options] or\n" |
" %s -F <netrace file> [Netrace options] \n\n" |
" %s -f <Task file> [Task options]\n" |
" %s -F <netrace file> [Netrace options] \n" |
" %s -S <synful model file> [synful options]\n\n" |
"synthetic Traffic options:\n" |
" -t <Traffic Pattern> \"HOTSPOT\", \"RANDOM\", \"BIT_COMPLEMENT\" , \"BIT_REVERSE\",\n " |
" -t <Traffic Pattern> \"HOTSPOT\", \"RANDOM\", \"BIT_COMPLEMENT\" , \"BIT_REVERSE\",\n" |
" \"TORNADO\", \"TRANSPOSE1\", \"TRANSPOSE2\", \"SHUFFEL\", \"CUSTOM\"\n" |
" -m <Packet size info> packet size format Random-Range or Random-discrete:\n" |
" Random-Range : \"R,MIN,MAX\" : The injected packets' size in flits are\n" |
" randomly selected in range MIN <= PCK_size <=MAX \n" |
" randomly selected in range MIN <= PCK_size <=MAX \n" |
" Random-discrete: \"D,S1,S2,..Sn,P,P1,P2,P3,...Pn\": Si are the discrete\n" |
" set of numbers representing packet size. The injected packet size is\n" |
" randomly selected among these discrete values according to associated\n" |
" probability values.\n" |
" -c <sim_end_clk_num> Simulation will stop when simulation clock number reach this value\n" |
" -n <sim_end_pck_num> Simulation will stop when total of sent packets to the noc reaches this number\n" |
" set of numbers representing packet size. The injected packet size is\n" |
" randomly selected among these discrete values according to associated\n" |
" probability values.\n" |
" -c <sim_end_clk_num> The simulation will stop when the simulation clock number reaches this value\n" |
" -n <sim_end_pck_num> The simulation will stop when the total sent packets to the NoC reaches this number\n" |
" -i <injection ratio> flit injection ratio in percentage\n" |
" -p <class traffic ratios> The percentage of traffic injected for each class. represented in string\n" |
" each class ratio is separated by comma. \"n0,n1,n2..\" \n" |
" -h <HOTSPOT traffic format> represented in a string with following format:\n" |
" -p <class traffic ratios> The percentage of traffic injected for each class. Represented in\n" |
" comma-separated string format:\"n0,n1,n2..\" \n" |
" -h <HOTSPOT traffic format> represented in a string with the following format:\n" |
" total number of hotspot nodes, first hotspot node ID, first hotspot node\n" |
" send enable(1 or 0),first hotspot node percentage x10,second hotspot node ...\n" |
" -H <custom traffic pattern> custom traffic pattern: represented in a string with following format:\n" |
" \"SRC1,DEST1, SRC2,DEST2, .., SRCn, DESTn\" \n" |
" -T <thread-num> total number of threads. The default is one (no-thread). \n" |
" -T <thread-num> total number of threads. The default is one (no-thread).\n" |
" -u <Multi/Broadcast format> represented in a string with following format:\n" |
" \"ratio,min_pck_size,max_pck_size\"\n" |
" ratio:The percentage of Multicast/broadcast packets against total injected \n" |
" traffic. The Multicast/Broadcast packet size is randomly selected\n" |
" between min_pck_size and max_pck_size. The max_pck_size must be smaller or equal\n" |
" to the router buffer width. This filed is only valid when the NoC is configured\n" |
" with the Multicast/Broadcast feature support.\n" |
//" -Q Quick (fast) simulation. ignore evaluating non-active routers \n" |
" to speed up simulation time" |
//" to speed up simulation time" |
"\nTrace options:\n" |
" -f <Task file> path to the task file. any custom task file can be generated using ProNoC gui\n" |
" -f <Task file> Path to the task file. any custom task file can be generated using ProNoC gui\n" |
" -c <sim_end_clk_num> Simulation will stop when simulation clock number reach this value \n" |
" -T <thread-num> total number of threads. The default is one (no-thread). \n" |
" -T <thread-num> Total number of threads. The default is one (no-thread).\n" |
//" -Q Quick (fast) simulation. ignore evaluating non-active routers \n" |
" to speed up simulation time" |
//" to speed up simulation time" |
"\nNetrace options:\n" |
" -F <Netrace file> path to the task file. any custom task file can be generated using ProNoC gui\n" |
" -n <sim_end_pck_num> Simulation will stop when total of sent packets to the NoC reaches this number\n" |
" -F <Netrace file> Path to the task file. any custom task file can be generated using ProNoC gui\n" |
" -n <sim_end_pck_num> The simulation will stop when the total sent packets to the NoC reaches this number\n" |
" -d ignore dependencies\n" |
" -r <start region> start region\n" |
" -l reader throttling\n" |
" -v <level> Verbosity level. 0: off, 1:display a live number of injected packet,\n" |
" 3: print injected/ejected packets details, default is 1\n" |
" -T <thread-num> total number of threads. The default is one (no-thread). \n" |
" -s <speed-up-num> the speed-up-num is the ratio of netrace frequency to pronoc.The higher value\n" |
" results in higher injection ratio to the NoC. Default is one" |
" -r <start region> Start region\n" |
" -l Reader throttling\n" |
" -v <level> Verbosity level. 0: off, 1:display a live number of injected packets,\n" |
" 3: print injected/ejected packets details, The default value is 1\n" |
" -T <thread-num> Total number of threads. The default is one (no-thread).\n" |
" -s <speed-up-num> The speed-up-num is the ratio of netrace frequency to pronoc.The higher value\n" |
" results in higher injection ratio to the NoC. Default is one\n" |
//" -Q Quick (fast) simulation. ignore evaluating non-active routers \n" |
" to speed up simulation time" , |
bin_name,bin_name,bin_name |
//" to speed up simulation time" |
"\nsynful options:\n" |
" -S <model file> Path to the synful application model file\n" |
" -r <seed value> Seed value for random function\n" |
" -c <sim_end_clk_num> The simulation will stop when the simulation clock number reaches this value \n" |
" -s Exit at steady state\n" |
" -n <sim_end_pck_num> The simulation will stop when the total of sent packets to the NoC reaches this number\n" |
" -T <thread-num> Total number of threads. The default is one (no-thread).\n" |
" -v <level> Verbosity level. 0: off, 1:display a live number of injected packets,\n" |
" -w <flit-size> The synful flit size in Byte. It defines the number of flits that should be set to\n" |
" ProNoC for each synful packets. The ProNoC packet size is:\n" |
" Ceil(synful packet size/synful flit size).\n" |
" 3: print injected/ejected packets details, The default value is 1\n", |
bin_name,bin_name,bin_name,bin_name |
); |
|
} |
166,6 → 210,7
case 'F': |
TRAFFIC_TYPE=NETRACE; |
TRAFFIC=(char *) "NETRACE"; |
ENDP_TYPE = PCK_INJECTOR; |
netrace_file = optarg; |
break; |
case 'd': |
180,7 → 225,7
case 'v': |
verbosity= atoi(optarg); |
break; |
case 'T': |
case 'T': |
thread_num = atoi(optarg); |
break; |
case 'n': |
214,7 → 259,7
/* don't want getopt to moan - I can do that just fine thanks! */ |
opterr = 0; |
if (argc < 2) usage(argv[0]); |
while ((c = getopt (argc, argv, "t:m:n:c:i:p:h:H:f:T:Q")) != -1) |
while ((c = getopt (argc, argv, "t:m:n:c:i:p:h:H:f:T:u:Q")) != -1) |
{ |
switch (c) |
{ |
274,6 → 319,9
usage(argv[0]); |
exit(1); |
break; |
case 'u': |
update_mcast_traffic(optarg); |
break; |
case '?': |
if (isprint (optopt)) |
fprintf (stderr, "Unknown option `-%c'.\n", optopt); |
289,6 → 337,55
|
|
|
void synful_processArgs (int argc, char **argv) |
{ |
char c; |
/* don't want getopt to moan - I can do that just fine thanks! */ |
opterr = 0; |
if (argc < 2) usage(argv[0]); |
while ((c = getopt (argc, argv, "S:c:sn:v:T:r:w:")) != -1) |
{ |
switch (c) |
{ |
case 'S': |
TRAFFIC_TYPE=SYNFUL; |
TRAFFIC=(char *) "SYNFUL"; |
synful_file = optarg; |
ENDP_TYPE =PCK_INJECTOR; |
break; |
case 'c': |
sim_end_clk_num=atoi(optarg); |
break; |
case 's': |
synful_SSExit =true; |
break; |
case 'n': |
end_sim_pck_num=atoi(optarg); |
break; |
case 'v': |
verbosity= atoi(optarg); |
break; |
case 'w': |
synful_flitw= atoi(optarg); |
break; |
case 'T': |
thread_num = atoi(optarg); |
break; |
case 'r': |
synful_random_seed = atoi(optarg); |
break; |
case '?': |
if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); |
else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); |
default: |
usage(argv[0]); |
exit(1); |
}//switch |
}//while |
} |
|
|
|
int parse_string ( char * str, int * array) |
{ |
int i=0; |
308,14 → 405,110
|
|
|
unsigned int pck_dst_gen ( unsigned int core_num) { |
if(TRAFFIC_TYPE==TASK) return pck_dst_gen_task_graph ( core_num); |
if((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)) return pck_dst_gen_2D (core_num); |
return pck_dst_gen_1D (core_num); |
unsigned int pck_dst_gen_unicast ( unsigned int core_num, unsigned char * inject_en) { |
if(TRAFFIC_TYPE==TASK) return pck_dst_gen_task_graph ( core_num, inject_en); |
if((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)) return pck_dst_gen_2D (core_num, inject_en); |
return pck_dst_gen_1D (core_num, inject_en); |
} |
|
|
void mcast_full_rnd (unsigned int core_num){ |
unsigned int rnd; |
int a; |
for(;;) { |
DEST_ADDR_ASSIGN_RAND(traffic[core_num]->dest_e_addr); |
if((strcmp (SELF_LOOP_EN,"NO")==0)) DEST_ADDR_BIT_CLR(traffic[core_num]->dest_e_addr,core_num); |
DEST_ADDR_IS_ZERO(a,traffic[core_num]->dest_e_addr); |
//rnd = rand() & ~(0x1<<core_num); |
//rnd &= ((1<<NE) -1); |
//if(rnd!=0) return rnd; |
if(a!=1) return; |
} |
} |
|
|
void mcast_partial_rnd (unsigned int core_num){ |
unsigned int rnd;int a; |
//printf("m[%d]=%d\n",core_num,mcast_list_array[core_num]); |
if(mcast_list_array[core_num] == 1){ // the current node is located in multicast partial list |
unsigned int self_node_addr = endp_id_to_mcast_id(core_num);//current node location in multicast list |
self_node_addr++; |
for(;;){ |
DEST_ADDR_ASSIGN_RAND(traffic[core_num]->dest_e_addr); |
DEST_ADDR_BIT_CLR(traffic[core_num]->dest_e_addr,0); |
if((strcmp (SELF_LOOP_EN,"NO")==0)) DEST_ADDR_BIT_CLR(traffic[core_num]->dest_e_addr,self_node_addr); |
//rnd = rand() & ~((0x1<<(self_node_addr+1))|0x1); // generate a random multicast destination. remove the current node flag and unicast_flag from destination list |
//rnd &= ((1<<(MCAST_PRTLw+1)) -1); |
//printf("rnd=%d\n",rnd); |
DEST_ADDR_IS_ZERO(a,traffic[core_num]->dest_e_addr); |
if(a!=1) return; |
//if(rnd!=0) return rnd; |
} |
}else{ |
for(;;){ |
DEST_ADDR_ASSIGN_RAND(traffic[core_num]->dest_e_addr); |
DEST_ADDR_BIT_CLR(traffic[core_num]->dest_e_addr,0); |
DEST_ADDR_IS_ZERO(a,traffic[core_num]->dest_e_addr); |
if(a!=1) return; |
//rnd = rand() & ~0x1;// deassert the unicast flag |
//rnd &= ((1<<(MCAST_PRTLw+1)) -1); |
//if(rnd!=0) return rnd; |
} |
} |
//this function should not come here |
|
} |
|
|
|
|
void pck_dst_gen ( unsigned int core_num, unsigned char * inject_en) { |
|
unsigned int dest = pck_dst_gen_unicast (core_num, inject_en); |
if(IS_UNICAST){ |
traffic[core_num]->dest_e_addr= dest; |
return; |
} |
else if (*inject_en==0) return; |
//multicast |
DEST_ADDR_ASSIGN_ZERO(traffic[core_num]->dest_e_addr);//reset traffic[core_num]->dest_e_addr |
|
unsigned int dest_id = endp_addr_decoder (dest); |
//*inject_en = dest_id !=core_num; |
|
unsigned int rnd = rand() % 100; // 0~99 |
if(rnd >= mcast.ratio){ |
//send a unicast packet |
if((strcmp (SELF_LOOP_EN,"NO")==0) && dest_id==core_num){ |
*inject_en=0; |
return; |
} |
if(IS_MCAST_FULL){ |
//return (0x1<<dest_id);// for mcast-full |
DEST_ADDR_BIT_SET(traffic[core_num]->dest_e_addr,dest_id); |
return; |
} |
// IS_MCAST_PARTIAL | IS_BCAST_FULL | IS_BCAST_PARTIAL |
dest = (dest << 1) | 0x1; // {dest_coded,unicast_flag} |
DEST_ADDR_ASSIGN_INT(traffic[core_num]->dest_e_addr,dest); |
return; |
} |
traffic[core_num]->pck_size_in=rnd_between(mcast.min,mcast.max); |
|
if (IS_MCAST_FULL) { |
mcast_full_rnd (core_num); |
return; |
} |
if (IS_MCAST_PARTIAL){ |
mcast_partial_rnd(core_num); |
return; |
} |
|
return; //IS_BCAST_FULL | IS_BCAST_PARTIAL traffic[core_num]->dest_e_addr=0; |
} |
|
|
|
void update_hotspot(char * str){ |
int i; |
int array[1000]; |
350,6 → 543,23
hotspots=new_node; |
} |
|
void update_mcast_traffic(char * str){ |
int i; |
int array[10]; |
int p; |
int max_valid =(B > LB)? LB : B; |
p= parse_string (str, array); |
if(p>0) mcast.ratio =array[0]; |
if(p>1) mcast.min =array[1]; |
if(p>2) mcast.max =array[2]; |
|
if (mcast.ratio > 100) { printf("ERROR: The given multicast traffic ratio (%d) is larger than 100\n",mcast.ratio); exit(1);} |
if (mcast.min < MIN_PCK_SIZE){ printf("ERROR: The given multicast minimum packet size (%d) is larger than %d minimum packet size supported by the NoC\n",mcast.min, MIN_PCK_SIZE); exit(1);} |
if (mcast.max > max_valid) { printf("ERROR: The given multicast maximum packet size (%d) is larger than %d maximum router buffer size\n",mcast.max, max_valid); exit(1);}; |
|
|
} |
|
void update_custom_traffic (char * str){ |
int i; |
int array[10000]; |
435,13 → 645,17
fprintf(stderr,"ERROR: Wrong Packet size format %s. It should start with one of \"D\" or \"R\" letter\n",str); |
exit(1); |
} |
p=(MAX_PACKET_SIZE-MIN_PACKET_SIZE)+1; |
|
|
} |
|
void allocate_rsv_pck_counters (void) { |
int p=(MAX_PACKET_SIZE-MIN_PACKET_SIZE)+1; |
rsv_size_array = (unsigned int*) calloc ( p , sizeof(int)); |
if (rsv_size_array==NULL){ |
fprintf(stderr,"ERROR: cannot allocate memory for rsv_size_array\n"); |
exit(1); |
} |
|
} |
|
|
455,7 → 669,7
rsv_size_array = (unsigned int*) calloc ( p , sizeof(int)); |
if (rsv_size_array==NULL){ |
fprintf(stderr,"ERROR: cannot allocate (%d x int) memory for rsv_size_array. \n",p); |
exit(1); |
exit(1); |
} |
} |
|
467,6 → 681,11
|
void processArgs (int argc, char **argv ){ |
int i; |
|
mcast.ratio=50; |
mcast.min= MIN_PCK_SIZE; |
mcast.max= (B > LB)? LB : B; |
|
for( i = 1; i < argc; ++i ) { |
if( strcmp(argv[i], "-t") == 0 ) { |
synthetic_task_processArgs ( argc, argv ); |
478,9 → 697,12
} else if( strcmp(argv[i], "-F") == 0 ) { |
netrace_processArgs (argc, argv ); |
return; |
} else if ( strcmp(argv[i], "-S") == 0 ) { |
synful_processArgs (argc, argv ); |
return; |
} |
} |
fprintf (stderr, "you should define one one of Synthetic,Task or nettrace based simulation. \n"); |
fprintf (stderr, "You should pass one of the Synthetic-, Task-, Synfull- or Nettrace- based simulation as input argument. \n"); |
usage(argv[0]); |
exit(1); |
} |
507,7 → 729,7
for (i=0;i<NE;i++) if(traffic[i]->pck_number>0) total_active_endp = total_active_endp +1; |
printf("\nsimulation results-------------------\n"); |
printf("\tSimulation clock cycles:%d\n",clk_counter); |
printf("\n\tTotal injected packet in different size:\n"); |
printf("\n\tTotal received packet in different size:\n"); |
printf("\tflit_size,"); |
for (i=0;i<=(MAX_PACKET_SIZE - MIN_PACKET_SIZE);i++){ |
if(rsv_size_array[i]>0) printf("%u,",i+ MIN_PACKET_SIZE); |
529,17 → 751,18
int i; |
unsigned int dest_e_addr; |
for (i=0;i<NE;i++){ |
unsigned char inject_en; |
random_var[i] = 100; |
traffic[i]->current_e_addr = endp_addr_encoder(i); |
traffic[i]->start=0; |
traffic[i]->pck_class_in= pck_class_in_gen( i); |
traffic[i]->pck_size_in=get_new_pck_size(); |
dest_e_addr=pck_dst_gen (i); |
traffic[i]->dest_e_addr= dest_e_addr; |
if(dest_e_addr == INJECT_OFF) traffic[i]->stop=1; |
pck_dst_gen (i, &inject_en); |
//traffic[i]->dest_e_addr= dest_e_addr; |
if(inject_en == 0) traffic[i]->stop=1; |
//printf("src=%u, des_eaddr=%x, dest=%x\n", i,dest_e_addr, endp_addr_decoder(dest_e_addr)); |
if(inject_done) traffic[i]->stop=1; |
traffic[i]->start_delay=rnd_between(1,4*NE-2); |
traffic[i]->start_delay=rnd_between(11,4*NE-12); |
if(TRAFFIC_TYPE==SYNTHETIC){ |
//traffic[i]->avg_pck_size_in=AVG_PACKET_SIZE; |
traffic[i]->ratio=ratio; |
548,18 → 771,32
} |
} |
|
void pck_inj_init (void){ |
int i; |
void pck_inj_init (int model_node_num){ |
int i,tmp; |
for (i=0;i<NE;i++){ |
pck_inj[i]->current_e_addr = endp_addr_encoder(i); |
//TODO mapping should be done according to number of NE and should be set by the user larer |
netrace_to_pronoc_map[i]=(int)((i* NE)/header->num_nodes); |
pck_inj[i]->pck_injct_in_ready= (0x1<<V)-1; |
pck_inj[i]->pck_injct_in_pck_wr=0; |
//pronoc_to_netrace_map[i]=i; |
} |
std::cout << "Node mapping---------------------" << std::endl; |
std::cout << "\tMapping " << model_node_num << " " << TRAFFIC << " Nodes to " << NE << " ProNoC Nodes" << std::endl; |
std::cout << "\t" << TRAFFIC << "\tID \t<-> ProNoC ID "<< std::endl; |
traffic_model_mapping = (int *) malloc( model_node_num * sizeof(int)); |
for (i=0;i<model_node_num;i++){ |
//TODO mapping should be done according to number of NE and should be set by the user later |
if(NE<=model_node_num){ |
// we have less or equal number of injectors in traffic model thatn the number of modes in ProNoC |
// So we need to map multiples injector nodes from the model to one packet injector |
tmp = ((i* NE)/model_node_num); |
traffic_model_mapping[i]=tmp; |
} else { |
// we have more endpoints that what is defined in the model |
if(i<model_node_num) traffic_model_mapping[i]=i; |
} |
std::cout<< "\t\t" << i << "\t<->\t" << tmp << std::endl; |
|
} |
|
std::cout << "Node mapping---------------------" << std::endl; |
} |
|
/************* |
612,7 → 849,9
{ |
// Access specifier |
public: |
std::atomic<bool> ready; |
std::atomic<bool> eval; |
std::atomic<bool> copy; |
std::atomic<bool> update; |
// Data Members |
int n;//thread num |
int nr_per_thread; |
625,25 → 864,78
int i; |
unsigned int node=0; |
while(1){ |
while(!ready) std::this_thread::yield(); |
for(i=0;i<nr_per_thread;i++){ |
node= (n * nr_per_thread)+i; |
if (node >= NR) break; |
//if(router_is_active[node] | (Quick_sim_en==0)) |
single_router_eval(node); |
} |
for(i=0;i<ne_per_thread;i++){ |
node= (n * ne_per_thread)+i; |
if (node >= NE) break; |
if( TRAFFIC_TYPE == NETRACE) pck_inj[node]->eval(); |
else traffic[node]->eval(); |
} |
while(!eval && !copy && !update) std::this_thread::yield(); |
if(eval){ |
//connect_clk_reset_start |
for(i=0;i<ne_per_thread;i++){ |
node= (n * ne_per_thread)+i; |
if (node >= NE) break; |
if(ENDP_TYPE == PCK_INJECTOR){ |
pck_inj[node]->reset= reset; |
pck_inj[node]->clk = clk; |
} |
else { |
traffic[node]->start= start_i; |
traffic[node]->reset= reset; |
traffic[node]->clk = clk; |
} |
}//endp |
for(i=0;i<nr_per_thread;i++){ |
node= (n * nr_per_thread)+i; |
if (node >= NR) break; |
//if(router_is_active[node] | (Quick_sim_en==0)) |
single_router_reset_clk(node); |
} |
|
//eval |
for(i=0;i<nr_per_thread;i++){ |
node= (n * nr_per_thread)+i; |
if (node >= NR) break; |
//if(router_is_active[node] | (Quick_sim_en==0)) |
single_router_eval(node); |
} |
for(i=0;i<ne_per_thread;i++){ |
node= (n * ne_per_thread)+i; |
if (node >= NE) break; |
if(ENDP_TYPE == PCK_INJECTOR) pck_inj[node]->eval(); |
else traffic[node]->eval(); |
} |
eval=false; |
} |
|
if(copy){ |
for (int i=0; i<R2R_TABLE_SIZ; i++) { |
if( |
r2r_cnt_all[i].id1 >= (n * nr_per_thread) |
&& |
r2r_cnt_all[i].id1 < ((n+1) * nr_per_thread) |
) |
topology_connect_r2r(i); |
} |
|
|
for(i=0;i<ne_per_thread;i++){ |
node= (n * ne_per_thread)+i; |
if (node >= NE) break; |
topology_connect_r2e(node); |
} |
copy=false; |
} |
|
if(update){ |
for(i=0;i<nr_per_thread;i++){ |
node= (n * nr_per_thread)+i; |
if (node >= NR) break; |
single_router_st_update(node); |
} |
update=false; |
} |
|
//router1[n]->eval(); |
//if( TRAFFIC_TYPE == NETRACE) pck_inj[n]->eval(); |
//else traffic[n]->eval(); |
|
ready=false; |
|
if(n==0) break;//first thread is the main process |
} |
} |
651,7 → 943,9
Vthread(int x,int r,int e) |
{ |
n=x; nr_per_thread=r; ne_per_thread=e; |
ready=false; |
eval=false; |
copy =false; |
update=false; |
if(n!=0) { |
std::thread th {&Vthread::function,this}; |
th.detach(); |
698,25 → 992,52
void sim_eval_all (void){ |
int i; |
if(thread_num>1) { |
for(i=0;i<thread_num;i++) thread[i]->ready=true; |
for(i=0;i<thread_num;i++) thread[i]->eval=true; |
//thread_function (0); |
thread[0]->function(); |
for(i=0;i<thread_num;i++)while(thread[i]->ready); |
for(i=0;i<thread_num;i++)while(thread[i]->eval); |
}else{// no thread |
|
connect_clk_reset_start_all(); |
|
//routers_eval(); |
for(i=0;i<NR;i++){ |
//if(router_is_active[i] | (Quick_sim_en==0)) |
single_router_eval(i); |
} |
if( TRAFFIC_TYPE == NETRACE) for(i=0;i<NE;i++) pck_inj[i]->eval(); |
if(ENDP_TYPE == PCK_INJECTOR) for(i=0;i<NE;i++) pck_inj[i]->eval(); |
else for(i=0;i<NE;i++) traffic[i]->eval(); |
} |
} |
|
|
void topology_connect_all_nodes (void){ |
|
|
int i; |
if(thread_num>1) { |
for(i=0;i<thread_num;i++) thread[i]->copy=true; |
//thread_function (0); |
thread[0]->function(); |
for(i=0;i<thread_num;i++){ |
while(thread[i]->copy==true); |
} |
return; |
}//no thread |
for (int n=0; n<R2R_TABLE_SIZ; n++) { |
topology_connect_r2r(n); |
} |
|
for (int n=0;n<NE; n++){ |
topology_connect_r2e(n); |
} |
} |
|
|
void sim_final_all (void){ |
int i; |
routers_final(); |
if( TRAFFIC_TYPE == NETRACE) for(i=0;i<NE;i++) pck_inj[i]->final(); |
if(ENDP_TYPE == PCK_INJECTOR) for(i=0;i<NE;i++) pck_inj[i]->final(); |
else for(i=0;i<NE;i++) traffic[i]->final(); |
//noc->final(); |
} |
725,7 → 1046,7
int i; |
//noc-> clk = clk; |
//noc-> reset = reset; |
if( TRAFFIC_TYPE == NETRACE) { |
if(ENDP_TYPE == PCK_INJECTOR) { |
for(i=0;i<NE;i++) { |
pck_inj[i]->reset= reset; |
pck_inj[i]->clk = clk; |
732,8 → 1053,7
} |
}else { |
for(i=0;i<NE;i++) { |
start_o[i]=start_i; |
traffic[i]->start= start_o[i]; |
traffic[i]->start= start_i; |
traffic[i]->reset= reset; |
traffic[i]->clk = clk; |
} |
751,79 → 1071,90
for (i=0;i<NE;i++){ |
if(inject_done) traffic[i]->stop=1; |
} |
connect_clk_reset_start_all(); |
|
sim_eval_all(); |
} |
|
void update_traffic_injector_st (unsigned int i){ |
unsigned char inject_en; |
// a packet has been received |
if(traffic[i]->update & ~reset){ |
total_rsv_pck_num+=1; |
update_noc_statistic (i) ; |
} |
// the header flit has been sent out |
if(traffic[i]->hdr_flit_sent ){ |
traffic[i]->pck_class_in= pck_class_in_gen( i); |
traffic[i]->pck_size_in=get_new_pck_size(); |
if((!FIXED_SRC_DST_PAIR)| (!IS_UNICAST)){ |
pck_dst_gen (i, &inject_en); |
//traffic[i]->dest_e_addr= dest_e_addr; |
if(inject_en == 0) traffic[i]->stop=1; |
//printf("src=%u, dest=%x\n", i,endp_addr_decoder(dest_e_addr)); |
} |
} |
|
if(traffic[i]->flit_out_wr==1){ |
total_sent_flit_number++; |
if (!IS_UNICAST){ |
total_expect_rsv_flit_num+=traffic[i]->mcast_dst_num_o; |
}else{ |
total_expect_rsv_flit_num++; |
} |
#if (C>1) |
sent_stat [i][traffic[i]->flit_out_class].flit_num++; |
#else |
sent_stat [i].flit_num++; |
#endif |
} |
|
if(traffic[i]->flit_in_wr==1){ |
total_rsv_flit_number++; |
} |
|
if(traffic[i]->hdr_flit_sent==1){ |
total_sent_pck_num++; |
#if (C>1) |
sent_stat [i][traffic[i]->flit_out_class].pck_num++; |
#else |
sent_stat [i].pck_num++; |
#endif |
} |
} |
|
void update_all_traffic_injector_st(){ |
for (int i=0;i<NE;i++){ |
update_traffic_injector_st(i); |
} |
|
} |
|
|
|
void traffic_clk_posedge_event(void) { |
int i; |
unsigned int dest_e_addr; |
|
clk = 1; // Toggle clock |
if(count_en) clk_counter++; |
inject_done= ((total_sent_pck_num >= end_sim_pck_num) || (clk_counter>= sim_end_clk_num) || total_active_routers == 0); |
//if(inject_done) printf("clk_counter=========%d\n",clk_counter); |
total_rsv_flit_number_old=total_rsv_flit_number; |
for (i=0;i<NE;i++){ |
// a packet has been received |
if(traffic[i]->update & ~reset){ |
update_noc_statistic (i) ; |
} |
// the header flit has been sent out |
if(traffic[i]->hdr_flit_sent ){ |
traffic[i]->pck_class_in= pck_class_in_gen( i); |
sent_core_total_pck_num[i]++; |
traffic[i]->pck_size_in=get_new_pck_size(); |
if(!FIXED_SRC_DST_PAIR){ |
dest_e_addr=pck_dst_gen (i); |
traffic[i]->dest_e_addr= dest_e_addr; |
if(dest_e_addr == INJECT_OFF) traffic[i]->stop=1; |
//printf("src=%u, dest=%x\n", i,endp_addr_decoder(dest_e_addr)); |
} |
} |
update_all_router_stat(); |
update_all_traffic_injector_st(); |
|
if(traffic[i]->flit_out_wr==1){ |
total_sent_flit_number++; |
#if (C>1) |
sent_stat [i][traffic[i]->flit_out_class].flit_num++; |
#else |
sent_stat [i].flit_num++; |
#endif |
if(inject_done){ |
if(total_rsv_flit_number_old == total_rsv_flit_number){ |
ideal_rsv_cnt++; |
if(ideal_rsv_cnt >= NE*10){ |
traffic_gen_final_report( ); |
fprintf(stderr,"ERROR: The number of expected (%u) & received flits (%u) were not equal at the end of simulation\n",total_expect_rsv_flit_num, total_rsv_flit_number); |
exit(1); |
} |
if(traffic[i]->flit_in_wr==1){ |
total_rsv_flit_number++; |
#if (C>1) |
rsvd_stat [i][traffic[i]->pck_class_out].flit_num++; |
#else |
rsvd_stat [i].flit_num++; |
#endif |
} |
if(traffic[i]->hdr_flit_sent==1){ |
total_sent_pck_num++; |
#if (C>1) |
sent_stat [i][traffic[i]->flit_out_class].pck_num++; |
#else |
sent_stat [i].pck_num++; |
#endif |
} |
}else ideal_rsv_cnt=0; |
if(total_expect_rsv_flit_num == total_rsv_flit_number ) simulation_done=1; |
} |
|
}//for |
|
|
if(inject_done){ |
if(total_rsv_flit_number_old == total_rsv_flit_number){ |
ideal_rsv_cnt++; |
if(ideal_rsv_cnt >= 100){ |
print_statistic( ); |
fprintf(stderr,"ERROR: The number of sent (%u) & received flits (%u) were not equal at the end of simulation\n",total_sent_flit_number, total_rsv_flit_number); |
exit(1); |
} |
} |
if(total_sent_flit_number == total_rsv_flit_number ) simulation_done=1; |
} |
connect_clk_reset_start_all(); |
sim_eval_all(); |
|
} |
836,8 → 1167,40
* |
*********************************/ |
|
void update_rsvd_st ( |
statistic_t * rsvd_stat, |
unsigned int clk_num_h2h, |
unsigned int clk_num_h2t, |
unsigned int latency, |
unsigned int distance, |
unsigned int pck_size |
|
) { |
rsvd_stat->pck_num ++; |
rsvd_stat->flit_num+= pck_size; |
rsvd_stat->sum_clk_h2h +=(double)clk_num_h2h; |
rsvd_stat->sum_clk_h2t +=(double)clk_num_h2t; |
rsvd_stat->sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance); |
if (rsvd_stat->worst_latency < latency ) rsvd_stat->worst_latency=latency; |
if (rsvd_stat->min_latency==0 ) rsvd_stat->min_latency =latency; |
if (rsvd_stat->min_latency > latency ) rsvd_stat->min_latency =latency; |
#if (STND_DEV_EN) |
rsvd_stat->sum_clk_pow2 += (double)clk_num_h2h * (double) clk_num_h2h; |
#endif |
} |
|
void update_sent_st ( |
statistic_t * sent_stat, |
unsigned int latency |
) { |
|
if (sent_stat->worst_latency < latency ) sent_stat->worst_latency=latency; |
if (sent_stat->min_latency==0 ) sent_stat->min_latency =latency; |
if (sent_stat->min_latency > latency ) sent_stat->min_latency =latency; |
|
} |
|
|
void update_statistic_at_ejection ( |
int core_num, |
unsigned int clk_num_h2h, |
844,78 → 1207,36
unsigned int clk_num_h2t, |
unsigned int distance, |
unsigned int class_num, |
unsigned int src ){ |
unsigned int src, |
unsigned int pck_size |
){ |
|
total_rsv_pck_num+=1; |
|
if( TRAFFIC_TYPE != NETRACE){ |
|
//old st |
if((total_rsv_pck_num & 0Xffff )==0 ) printf(" packet sent total=%d\n",total_rsv_pck_num); |
sum_clk_h2h+=clk_num_h2h; |
sum_clk_h2t+=clk_num_h2t; |
#if (STND_DEV_EN) |
sum_clk_pow2+=(double)clk_num_h2h * (double) clk_num_h2h; |
sum_clk_pow2_per_class[class_num]+=(double)clk_num_h2h * (double) clk_num_h2h; |
#endif |
sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance); |
//printf("sum_clk_per_hop(%f)+= clk_num_h2h(%u)/distance(%u)\n",sum_clk_per_hop,clk_num_h2h,distance); |
total_rsv_pck_num_per_class[class_num]+=1; |
sum_clk_h2h_per_class[class_num]+=clk_num_h2h ; |
sum_clk_h2t_per_class[class_num]+=clk_num_h2t ; |
sum_clk_per_hop_per_class[class_num]+= ((double)clk_num_h2h/(double)distance); |
rsvd_core_total_pck_num[core_num]=rsvd_core_total_pck_num[core_num]+1; |
|
if (rsvd_core_worst_delay[core_num] < clk_num_h2t) rsvd_core_worst_delay[core_num] = (strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)? clk_num_h2t : clk_num_h2h; |
if (sent_core_worst_delay[src] < clk_num_h2t) sent_core_worst_delay[src] = (strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)? clk_num_h2t : clk_num_h2h; |
|
if(ENDP_TYPE == TRFC_INJECTOR) { |
if( traffic[core_num]->pck_size_o >= MIN_PACKET_SIZE && traffic[core_num]->pck_size_o <=MAX_PACKET_SIZE){ |
if(rsv_size_array!=NULL) rsv_size_array[traffic[core_num]->pck_size_o-MIN_PACKET_SIZE]++; |
if(rsv_size_array!=NULL) rsv_size_array[traffic[core_num]->pck_size_o-MIN_PACKET_SIZE]++; |
} |
} |
//new one TODO remove old st |
|
if(verbosity==0 && TRAFFIC_TYPE == NETRACE) if((total_rsv_pck_num & 0X1FFFF )==0 ) printf(" packet sent total=%d\n",total_rsv_pck_num); |
if(verbosity==0 && ( TRAFFIC_TYPE == NETRACE || TRAFFIC_TYPE ==SYNFUL)) if((total_rsv_pck_num & 0X1FFFF )==0 ) printf(" packet sent total=%d\n",total_rsv_pck_num); |
unsigned int latency = (strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)? clk_num_h2t : clk_num_h2h; |
#if(C>1) |
update_rsvd_st ( &rsvd_stat[core_num][class_num], clk_num_h2h, clk_num_h2t, latency, distance,pck_size); |
update_sent_st ( &sent_stat[src ][class_num], latency); |
#else |
update_rsvd_st ( &rsvd_stat[core_num], clk_num_h2h, clk_num_h2t, latency, distance,pck_size); |
update_sent_st ( &sent_stat[src ], latency); |
#endif |
|
rsvd_stat[core_num][class_num].pck_num ++; |
rsvd_stat[core_num][class_num].sum_clk_h2h +=clk_num_h2h; |
rsvd_stat[core_num][class_num].sum_clk_h2t +=clk_num_h2t; |
rsvd_stat[core_num][class_num].sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance); |
if (rsvd_stat[core_num][class_num].worst_latency < latency ) rsvd_stat[core_num][class_num].worst_latency =latency; |
if (rsvd_stat[core_num][class_num].min_latency==0 ) rsvd_stat[core_num][class_num].min_latency =latency; |
if (rsvd_stat[core_num][class_num].min_latency > latency ) rsvd_stat[core_num][class_num].min_latency =latency; |
if (sent_stat[src ][class_num].worst_latency < latency ) sent_stat[src ][class_num].worst_latency =latency; |
if (sent_stat[src ][class_num].min_latency==0 ) sent_stat[src ][class_num].min_latency =latency; |
if (sent_stat[src ][class_num].min_latency > latency ) sent_stat[src ][class_num].min_latency =latency; |
update_rsvd_st ( &endp_to_endp[src][core_num], clk_num_h2h, clk_num_h2t, latency, distance, pck_size); |
|
#if (STND_DEV_EN) |
rsvd_stat[core_num][class_num].sum_clk_pow2 += (double)clk_num_h2h * (double) clk_num_h2h; |
#endif |
#else |
rsvd_stat[core_num].pck_num ++; |
rsvd_stat[core_num].sum_clk_h2h +=(double)clk_num_h2h; |
rsvd_stat[core_num].sum_clk_h2t +=(double)clk_num_h2t; |
rsvd_stat[core_num].sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance); |
if (rsvd_stat[core_num].worst_latency < latency ) rsvd_stat[core_num].worst_latency=latency; |
if (rsvd_stat[core_num].min_latency==0 ) rsvd_stat[core_num].min_latency =latency; |
if (rsvd_stat[core_num].min_latency > latency ) rsvd_stat[core_num].min_latency =latency; |
if (sent_stat[src ].worst_latency < latency ) sent_stat[src ].worst_latency=latency; |
if (sent_stat[src ].min_latency==0 ) sent_stat[src ].min_latency =latency; |
if (sent_stat[src ].min_latency > latency ) sent_stat[src ].min_latency =latency; |
} |
|
#if (STND_DEV_EN) |
rsvd_stat[core_num].sum_clk_pow2 += (double)clk_num_h2h * (double) clk_num_h2h; |
#endif |
#endif |
|
|
|
|
|
} |
|
void update_noc_statistic ( int core_num){ |
unsigned int clk_num_h2h =traffic[core_num]->time_stamp_h2h; |
unsigned int clk_num_h2t =traffic[core_num]->time_stamp_h2t; |
923,10 → 1244,10
unsigned int class_num=traffic[core_num]->pck_class_out; |
unsigned int src_e_addr=traffic[core_num]->src_e_addr; |
unsigned int src = endp_addr_decoder (src_e_addr); |
unsigned int pck_size = traffic[core_num]-> pck_size_o; |
update_statistic_at_ejection ( core_num, clk_num_h2h, clk_num_h2t, distance, class_num, src,pck_size); |
|
update_statistic_at_ejection ( core_num, clk_num_h2h, clk_num_h2t, distance, class_num, src); |
|
|
} |
|
avg_st_t finilize_statistic (unsigned long int total_clk, statistic_t rsvd_stat){ |
1002,7 → 1323,14
|
void print_statistic_new (unsigned long int total_clk){ |
int i; |
printf("\n\t#node," |
|
|
print_router_st(); |
print_endp_to_endp_st("pck_num"); |
print_endp_to_endp_st("flit_num"); |
|
printf( "\n\tEndpoints Statistics:\n" |
"\t#EID," |
"sent_stat.pck_num," |
"rsvd_stat.pck_num," |
"sent_stat.flit_num," |
1078,109 → 1406,67
printf("\t%u,",i); |
print_st_single (total_clk, rsvd_stat_class[i],sent_stat_class[i] ); |
} |
} |
|
|
|
void print_statistic (void){ |
double avg_latency_per_hop, avg_latency_flit, avg_latency_pck, avg_throughput,min_avg_latency_per_class; |
int i; |
#if (STND_DEV_EN) |
double std_dev; |
#endif |
|
avg_throughput= ((double)(total_sent_flit_number*100)/total_active_endp )/clk_counter; |
printf(" Total active Endpoint: %d \n",total_active_endp); |
printf(" Avg throughput is: %f (flits/clk/Total active Endpoint %%)\n", avg_throughput); |
avg_latency_flit = (double)sum_clk_h2h/total_rsv_pck_num; |
avg_latency_pck = (double)sum_clk_h2t/total_rsv_pck_num; |
if(ratio==RATIO_INIT) first_avg_latency_flit=avg_latency_flit; |
#if (STND_DEV_EN) |
std_dev= standard_dev( sum_clk_pow2,total_rsv_pck_num, avg_latency_flit); |
printf(" standard_dev = %f\n",std_dev); |
#endif |
avg_latency_per_hop = (double)sum_clk_per_hop/total_rsv_pck_num; |
printf("\nall : \n"); |
printf(" Total number of packet = %d \n average latency per hop = %f \n",total_rsv_pck_num,avg_latency_per_hop); |
printf(" average packet latency = %f \n average flit latency = %f \n",avg_latency_pck, avg_latency_flit); |
min_avg_latency_per_class=1000000; |
printf(" Total injected packet in different size:\n"); |
for (i=0;i<=(MAX_PACKET_SIZE - MIN_PACKET_SIZE);i++){ |
if(rsv_size_array[i]>0) printf("\t %u flit_sized pck = %u\n",i+ MIN_PACKET_SIZE, rsv_size_array[i]); |
} |
printf("\n"); |
|
for(i=0;i<C;i++){ |
avg_throughput = (total_rsv_pck_num_per_class[i]>0)? ((double)(total_rsv_pck_num_per_class[i]*AVG_PACKET_SIZE*100)/total_active_endp )/clk_counter:0; |
avg_latency_flit = (total_rsv_pck_num_per_class[i]>0)? (double)sum_clk_h2h_per_class[i]/total_rsv_pck_num_per_class[i]:0; |
avg_latency_pck = (total_rsv_pck_num_per_class[i]>0)? (double)sum_clk_h2t_per_class[i]/total_rsv_pck_num_per_class[i]:0; |
avg_latency_per_hop = (total_rsv_pck_num_per_class[i]>0)? (double)sum_clk_per_hop_per_class[i]/total_rsv_pck_num_per_class[i]:0; |
printf ("\nclass : %d \n",i); |
printf (" Total number of packet = %d \n avg_throughput = %f \n average latency per hop = %f \n ",total_rsv_pck_num_per_class[i],avg_throughput,avg_latency_per_hop); |
printf (" average packet latency = %f \n average flit latency = %f \n",avg_latency_pck,avg_latency_flit); |
if(min_avg_latency_per_class > avg_latency_flit) min_avg_latency_per_class=avg_latency_flit; |
} |
|
#if (STND_DEV_EN) |
std_dev= (total_rsv_pck_num_per_class[i]>0)? standard_dev( sum_clk_pow2_per_class[i],total_rsv_pck_num_per_class[i], avg_latency_flit):0; |
printf(" standard_dev = %f\n",std_dev); |
#endif |
}//for |
current_avg_latency_flit=min_avg_latency_per_class; |
for (i=0;i<NE;i++) { |
printf ("\n\nEnd_point %d\n",i); |
printf ("\n\ttotal number of received packets: %u\n",rsvd_core_total_pck_num[i]); |
printf ("\n\tworst-case-delay of received packets (clks): %u\n",rsvd_core_worst_delay[i] ); |
printf ("\n\ttotal number of sent packets: %u\n",traffic[i]->pck_number); |
printf ("\n\tworst-case-delay of sent packets (clks): %u\n",sent_core_worst_delay[i] ); |
} |
|
print_statistic_new (clk_counter); |
|
|
} |
|
|
|
void print_parameter (){ |
printf ("NoC parameters:---------------- \n"); |
printf ("\tTopology: %s\n",TOPOLOGY); |
printf ("\tRouting algorithm: %s\n",ROUTE_NAME); |
printf ("\tVC_per port: %d\n", V); |
printf ("\tNon-local port buffer_width per VC: %d\n", B); |
printf ("\tLocal port buffer_width per VC: %d\n", LB); |
if((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)){ |
printf ("NoC parameters:---------------- \n"); |
printf ("\tTopology: %s\n",TOPOLOGY); |
printf ("\tRouting algorithm: %s\n",ROUTE_NAME); |
printf ("\tVC_per port: %d\n", V); |
printf ("\tNon-local port buffer_width per VC: %d\n", B); |
printf ("\tLocal port buffer_width per VC: %d\n", LB); |
|
#if defined (IS_MESH) || defined (IS_FMESH) || defined (IS_TORUS) |
printf ("\tRouter num in row: %d \n",T1); |
printf ("\tRouter num in column: %d \n",T2); |
printf ("\tEndpoint num per router: %d\n",T3); |
}else if ((strcmp (TOPOLOGY,"RING")==0)||(strcmp (TOPOLOGY,"LINE")==0)){ |
printf ("\tTotal Router num: %d \n",T1); |
printf ("\tEndpoint num per router: %d\n",T3); |
} |
else if ((strcmp (TOPOLOGY,"TREE")==0)||(strcmp (TOPOLOGY,"FATTREE")==0)){ |
printf ("\tK: %d \n",T1); |
printf ("\tL: %d \n",T2); |
} else{ //CUSTOM |
#elif defined (IS_LINE) || defined (IS_RING ) |
printf ("\tTotal Router num: %d \n",T1); |
printf ("\tEndpoint num per router: %d\n",T3); |
#elif defined (IS_FATTREE) || defined (IS_TREE) |
printf ("\tK: %d \n",T1); |
printf ("\tL: %d \n",T2); |
#elif defined (IS_STAR) |
printf ("\tTotal Endpoints number: %d \n",T1); |
#else//CUSTOM |
printf ("\tTotal Endpoints number: %d \n",T1); |
printf ("\tTotal Routers number: %d \n",T2); |
} |
printf ("\tNumber of Class: %d\n", C); |
printf ("\tFlit data width: %d \n", Fpay); |
printf ("\tVC reallocation mechanism: %s \n", VC_REALLOCATION_TYPE); |
printf ("\tVC/sw combination mechanism: %s \n", COMBINATION_TYPE); |
printf ("\tAVC_ATOMIC_EN:%d \n", AVC_ATOMIC_EN); |
printf ("\tCongestion Index:%d \n",CONGESTION_INDEX); |
printf ("\tADD_PIPREG_AFTER_CROSSBAR:%d\n",ADD_PIPREG_AFTER_CROSSBAR); |
printf ("\tSSA_EN enabled:%s \n",SSA_EN); |
printf ("\tSwitch allocator arbitration type:%s \n",SWA_ARBITER_TYPE); |
printf ("\tMinimum supported packet size:%d flit(s) \n",MIN_PCK_SIZE); |
printf ("\tLoop back is enabled:%s",SELF_LOOP_EN); |
printf ("\tNumber of multihop bypass (SMART max):%d \n",SMART_MAX); |
#endif |
|
printf ("\tNumber of Class: %d\n", C); |
printf ("\tFlit data width: %d \n", Fpay); |
printf ("\tVC reallocation mechanism: %s \n", VC_REALLOCATION_TYPE); |
printf ("\tVC/sw combination mechanism: %s \n", COMBINATION_TYPE); |
printf ("\tAVC_ATOMIC_EN:%d \n", AVC_ATOMIC_EN); |
printf ("\tCongestion Index:%d \n",CONGESTION_INDEX); |
printf ("\tADD_PIPREG_AFTER_CROSSBAR:%d\n",ADD_PIPREG_AFTER_CROSSBAR); |
printf ("\tSSA_EN enabled:%s \n",SSA_EN); |
printf ("\tSwitch allocator arbitration type:%s \n",SWA_ARBITER_TYPE); |
printf ("\tMinimum supported packet size:%d flit(s) \n",MIN_PCK_SIZE); |
printf ("\tLoop back is enabled:%s \n",SELF_LOOP_EN); |
printf ("\tNumber of multihop bypass (SMART max):%d \n",SMART_MAX); |
printf ("\tCastying type:%s.\n",CAST_TYPE); |
if (IS_MCAST_PARTIAL){ |
printf ("\tCAST LIST:%s\n",MCAST_ENDP_LIST); |
} |
printf ("NoC parameters:---------------- \n"); |
printf ("\nSimulation parameters-------------\n"); |
#if(DEBUG_EN) |
printf ("\tDebuging is enabled\n"); |
#else |
printf ("\tDebuging is disabled\n"); |
#endif |
#if(DEBUG_EN) |
printf ("\tDebuging is enabled\n"); |
#else |
printf ("\tDebuging is disabled\n"); |
#endif |
//if(strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)printf ("\tOutput is the average latency on sending the packet header until receiving tail\n"); |
//else printf ("\tOutput is the average latency on sending the packet header until receiving header flit at destination node\n"); |
printf ("\tTraffic pattern:%s\n",TRAFFIC); |
1191,17 → 1477,24
if(strcmp (TRAFFIC,"HOTSPOT")==0){ |
//printf ("\tHot spot percentage: %u\n", HOTSPOT_PERCENTAGE); |
printf ("\tNumber of hot spot cores: %d\n", HOTSPOT_NUM); |
} |
if (strcmp (CAST_TYPE,"UNICAST")){ |
printf ("\tMULTICAST traffic ratio: %d(%%), min: %d, max: %d\n", mcast.ratio,mcast.min,mcast.max); |
} |
|
|
//printf ("\tTotal packets sent by one router: %u\n", TOTAL_PKT_PER_ROUTER); |
if(sim_end_clk_num!=0) printf ("\tSimulation timeout =%d\n", sim_end_clk_num); |
if(end_sim_pck_num!=0) printf ("\tSimulation ends on total packet num of =%d\n", end_sim_pck_num); |
if(TRAFFIC_TYPE!=NETRACE && TRAFFIC_TYPE!=SYNFUL){ |
printf ("\tPacket size (min,max,average) in flits: (%u,%u,%u)\n",MIN_PACKET_SIZE,MAX_PACKET_SIZE,AVG_PACKET_SIZE); |
printf ("\tPacket injector FIFO width in flit:%u \n",TIMSTMP_FIFO_NUM); |
} |
//printf ("\tTotal packets sent by one router: %u\n", TOTAL_PKT_PER_ROUTER); |
if(sim_end_clk_num!=0) printf ("\tSimulation timeout =%d\n", sim_end_clk_num); |
if(end_sim_pck_num!=0) printf ("\tSimulation ends on total packet num of =%d\n", end_sim_pck_num); |
if(TRAFFIC_TYPE!=NETRACE){ |
printf ("\tPacket size (min,max,average) in flits: (%u,%u,%u)\n",MIN_PACKET_SIZE,MAX_PACKET_SIZE,AVG_PACKET_SIZE); |
printf ("\tPacket injector FIFO width in flit:%u \n",TIMSTMP_FIFO_NUM); |
} |
if( TRAFFIC_TYPE == SYNTHETIC) printf("\tFlit injection ratio per router is =%f (flits/clk/Total Endpoint %%)\n",(float)ratio*100/MAX_RATIO); |
printf ("Simulation parameters-------------\n"); |
if( TRAFFIC_TYPE == SYNTHETIC) printf("\tFlit injection ratio per router is =%f (flits/clk/Total Endpoint %%)\n",(float)ratio*100/MAX_RATIO); |
printf ("Simulation parameters-------------\n"); |
|
|
|
} |
|
|
1243,6 → 1536,7
|
} //for |
total_sent_flit_number=0; |
total_expect_rsv_flit_num=0; |
|
|
} |
1323,26 → 1617,33
//printf("after=%u\n",random_var[src]); |
} |
|
unsigned int pck_dst_gen_task_graph ( unsigned int src){ |
unsigned int pck_dst_gen_task_graph ( unsigned int src, unsigned char * inject_en){ |
task_t task; |
float f,v; |
|
*inject_en=1; |
int index = task_graph_abstract[src].active_index; |
|
if(index == DISABLE){ |
traffic[src]->ratio=0; |
traffic[src]->stop=1; |
return INJECT_OFF; //disable sending |
*inject_en=0; |
return INJECT_OFF; //disable sending |
} |
|
if( read(task_graph_data[src],index,&task)==0){ |
traffic[src]->ratio=0; |
traffic[src]->stop=1; |
return INJECT_OFF; //disable sending |
*inject_en=0; |
return INJECT_OFF; //disable sending |
|
} |
|
if(sent_core_total_pck_num[src] & 0xFF){//sent 255 packets |
#if (C>1) |
if(sent_stat[src][traffic[src]->flit_out_class].pck_num & 0xFF){//sent 255 packets |
#else |
if(sent_stat[src].pck_num & 0xFF){//sent 255 packets |
#endif |
|
//printf("uu=%u\n",task.jnjct_var); |
update_injct_var(src, task.jnjct_var); |
|
1383,6 → 1684,7
traffic[src]->ratio=0; |
traffic[src]->stop=1; |
if(total_active_routers!=0) total_active_routers--; |
*inject_en=0; |
return INJECT_OFF; |
} |
if(task_graph_abstract[src].active_index>=task_graph_abstract[src].total_index) task_graph_abstract[src].active_index=0; |
1392,7 → 1694,105
} |
|
|
void update_all_router_stat(void){ |
if(thread_num>1) { |
int i; |
for(i=0;i<thread_num;i++) thread[i]->update=true; |
//thread_function (0); |
thread[0]->function(); |
for(i=0;i<thread_num;i++)while(thread[i]->update==true); |
return; |
} |
//no thread |
for (int i=0; i<NR; i++) single_router_st_update(i); |
} |
|
void update_router_st ( |
unsigned int Pnum, |
unsigned int rid, |
EVENT * event |
|
){ |
|
for (int p=0;p<Pnum;p++){ |
if(event[p] & FLIT_IN_WR_FLG ) router_stat [rid][p].flit_num_in++; |
if(event[p] & PCK_IN_WR_FLG ) router_stat [rid][p].pck_num_in++; |
if(event[p] & FLIT_OUT_WR_FLG) router_stat [rid][p].flit_num_out++; |
if(event[p] & PCK_OUT_WR_FLG ) router_stat [rid][p].pck_num_out++; |
if(event[p] & FLIT_IN_BYPASSED)router_stat [rid][p].flit_num_in_bypassed++; |
else if( event[p] & FLIT_IN_WR_FLG){ |
router_stat [rid][p].flit_num_in_buffered++; |
int bypassed_times = (event[p] >> BYPASS_LSB); |
router_stat [rid][p].bypass_counter[bypassed_times]++; |
} |
} |
} |
|
|
void print_router_st (void) { |
|
//report router statistic |
printf("\n\n\tRouters' statistics:\n"); |
printf("\t#RID, #Port," |
"flit_in," |
"pck_in," |
"flit_out," |
"pck_out," |
"flit_in_buffered," |
"flit_in_bypassed," |
); |
if(SMART_MAX>0) for (int k=0;k<SMART_MAX+1;k++) printf("bypsd_%0d_times,",k); |
printf("\n"); |
|
for (int i=0; i<NR; i++){ |
|
for (int p=0;p<MAX_P;p++){ |
|
printf("\t%u,%u,",i,p); |
printf("%d,%d,%d,%d,%d,%d,", |
router_stat [i][p].flit_num_in, |
router_stat [i][p].pck_num_in, |
router_stat [i][p].flit_num_out, |
router_stat [i][p].pck_num_out, |
router_stat [i][p].flit_num_in_buffered, |
router_stat [i][p].flit_num_in_bypassed |
); |
if(SMART_MAX>0) for (int k=0;k<SMART_MAX+1;k++) printf("%d," ,router_stat [i][p].bypass_counter[k]); |
printf("\n"); |
router_stat_accum [i].flit_num_in += router_stat [i][p].flit_num_in; |
router_stat_accum [i].pck_num_in += router_stat [i][p].pck_num_in; |
router_stat_accum [i].flit_num_out += router_stat [i][p].flit_num_out; |
router_stat_accum [i].pck_num_out += router_stat [i][p].pck_num_out; |
router_stat_accum [i].flit_num_in_buffered += router_stat [i][p].flit_num_in_buffered; |
router_stat_accum [i].flit_num_in_bypassed += router_stat [i][p].flit_num_in_bypassed; |
if(SMART_MAX>0) for (int k=0;k<SMART_MAX+1;k++) router_stat_accum [i].bypass_counter[k]+= router_stat [i][p].bypass_counter[k]; |
|
} |
printf("\t%u,total,",i); |
printf("%d,%d,%d,%d,%d,%d,", |
router_stat_accum [i].flit_num_in, |
router_stat_accum [i].pck_num_in, |
router_stat_accum [i].flit_num_out, |
router_stat_accum [i].pck_num_out, |
router_stat_accum [i].flit_num_in_buffered, |
router_stat_accum [i].flit_num_in_bypassed |
); |
if(SMART_MAX>0) for (int k=0;k<SMART_MAX+1;k++) printf("%d," , router_stat_accum [i].bypass_counter[k]); |
printf("\n"); |
} |
} |
|
|
void print_endp_to_endp_st(const char * st) { |
printf ("\n\tEndp_to_Endp %s:\n\t#EID,",st); |
for (int src=0; src<NE; src++) printf ("%u,",src); |
printf ("\n"); |
for (int src=0; src<NE; src++){ |
printf ("\t%u,",src); |
for (int dst=0;dst<NE;dst++){ |
if(strcmp(st,"pck_num")==0) printf("%u,",endp_to_endp[src][dst].pck_num); |
if(strcmp(st,"flit_num")==0) printf("%u,",endp_to_endp[src][dst].flit_num); |
} |
printf ("\n"); |
} |
} |
/simulator.h
50,18 → 50,27
#endif |
|
|
#define xstr(s) str(s) |
#define str(s) #s |
|
|
//traffic type |
#define SYNTHETIC 0 |
#define TASK 1 |
#define NETRACE 2 |
#define SYNFUL 3 |
|
//injector type |
#define PCK_INJECTOR 0 |
#define TRFC_INJECTOR 1 |
|
#define STND_DEV_EN 1 |
|
|
int TRAFFIC_TYPE=SYNTHETIC; |
int ENDP_TYPE =TRFC_INJECTOR; |
|
|
void * addr1; |
void * addr2; |
|
int get_router_num (int , int ); |
|
75,18 → 84,26
#define CHAN_SIZE sizeof(router1[0]->chan_in[0]) |
|
#define conect_r2r(T1,r1,p1,T2,r2,p2) \ |
memcpy(&router##T1 [r1]->chan_in[p1] , &router##T2 [r2]->chan_out[p2], CHAN_SIZE ); |
memcpy(&router##T1 [r1]->chan_in[p1] , &router##T2 [r2]->chan_out[p2], CHAN_SIZE ) |
|
// router_is_active[get_router_num(T1,r1)] |=(( router##T1 [r1]-> ideal_port!=0) | (router##T2 [r2]-> active_port[p2]==1)) |
|
#define connect_r2gnd(T,r,p)\ |
memset(&router##T [r]->chan_in [p],0x00,CHAN_SIZE) |
memset(&router##T [r]->chan_in [p],0x00,CHAN_SIZE); |
|
|
#define connect_r2e(T,r,p,e) \ |
addr1=(TRAFFIC_TYPE==NETRACE)? &pck_inj[e]->chan_out : &traffic[e]->chan_out;\ |
addr2=(TRAFFIC_TYPE==NETRACE)? &pck_inj[e]->chan_in : &traffic[e]->chan_in;\ |
void * addr1, * addr2;\ |
addr1=(ENDP_TYPE == PCK_INJECTOR)? &pck_inj[e]->chan_out : &traffic[e]->chan_out;\ |
addr2=(ENDP_TYPE == PCK_INJECTOR)? &pck_inj[e]->chan_in : &traffic[e]->chan_in;\ |
memcpy(&router##T [r]->chan_in[p], addr1, CHAN_SIZE );\ |
memcpy(addr2, &router##T [r]->chan_out[p], CHAN_SIZE ); |
// router_is_active[get_router_num(T,r)] |= (TRAFFIC_TYPE==NETRACE)? \ |
memcpy(addr2, &router##T [r]->chan_out[p], CHAN_SIZE ) |
|
|
|
|
|
// router_is_active[get_router_num(T,r)] |= (ENDP_TYPE == PCK_INJECTOR)? \ |
(( router##T [r]-> ideal_port!=0) | (pck_inj[e]->pck_active_port==1)):\ |
(( router##T [r]-> ideal_port!=0) | (traffic[e]->traffic_active_port==1)) |
|
93,17 → 110,26
|
|
|
#define IS_SELF_LOOP_EN (strcmp(SELF_LOOP_EN ,"YES")==0) |
#define IS_SELF_LOOP_EN (strcmp(SELF_LOOP_EN ,"YES")==0) |
#define IS_UNICAST (strcmp(CAST_TYPE,"UNICAST")==0) |
#define IS_MCAST_FULL (strcmp(CAST_TYPE,"MULTICAST_FULL")==0) |
#define IS_MCAST_PARTIAL (strcmp(CAST_TYPE,"MULTICAST_PARTIAL")==0) |
#define IS_BCAST_FULL (strcmp(CAST_TYPE,"BROADCAST_FULL")==0) |
#define IS_BCAST_PARTIAL (strcmp(CAST_TYPE,"BROADCAST_PARTIAL")==0) |
|
|
#include "parameter.h" |
//alignas(64) int router_is_active [NR]={1}; |
|
|
int reset,clk; |
|
Vtraffic *traffic[NE]; // for synthetic and trace traffic pattern |
Vpck_inj *pck_inj[NE]; // for netrace |
|
|
|
|
|
unsigned int total_rsv_pck_num=0; |
unsigned int total_sent_pck_num=0; |
unsigned int end_sim_pck_num=0; |
116,12 → 142,7
int MIN_PACKET_SIZE=5; |
int MAX_PACKET_SIZE=5; |
|
unsigned int rsvd_core_total_pck_num[NE]= {0}; |
unsigned int rsvd_core_total_flit_num[NE]= {0}; |
unsigned int rsvd_core_worst_delay[NE] = {0}; |
unsigned int sent_core_total_pck_num[NE]= {0}; |
unsigned int sent_core_total_flit_num[NE]= {0}; |
unsigned int sent_core_worst_delay[NE] = {0}; |
|
unsigned int random_var[NE] = {100}; |
|
|
152,6 → 173,45
|
} avg_st_t; |
|
/* |
typedef struct packed { |
bit flit_wr_i; |
bit pck_wr_i; |
bit flit_wr_o; |
bit pck_wr_o; |
bit flit_in_bypassed; |
logic [BYPASSw-1 : 0] bypassed_num; |
} router_event_t; |
|
localparam BYPASSw = log2(SMART_NUM); |
*/ |
|
|
|
#define BYPASS_LSB 5 |
#define FLIT_IN_WR_FLG (1<<4) |
#define PCK_IN_WR_FLG (1<<3) |
#define FLIT_OUT_WR_FLG (1<<2) |
#define PCK_OUT_WR_FLG (1<<1) |
#define FLIT_IN_BYPASSED (1<<0) |
|
|
|
|
typedef struct router_st_struct { |
unsigned int pck_num_in; |
unsigned int flit_num_in; |
unsigned int pck_num_out; |
unsigned int flit_num_out; |
unsigned int flit_num_in_bypassed; |
unsigned int flit_num_in_buffered; |
unsigned int bypass_counter [SMART_NUM+1 ] ; |
} router_st_t; |
|
alignas(64) router_st_t router_stat [NR][MAX_P]; |
router_st_t router_stat_accum [NR]; |
|
|
#if (C>1) |
statistic_t sent_stat [NE][C]; |
statistic_t rsvd_stat [NE][C]; |
160,12 → 220,19
statistic_t rsvd_stat [NE]; |
#endif |
|
statistic_t endp_to_endp [NE][NE]; |
|
typedef struct mcast_struct { |
int ratio; |
int min; |
int max; |
}mcast_t; |
|
void update_statistic_at_ejection ( int , unsigned int, unsigned int, unsigned int, unsigned int, unsigned int ); |
|
void update_statistic_at_ejection ( int , unsigned int, unsigned int, unsigned int, unsigned int, unsigned int ,unsigned int); |
void update_noc_statistic ( int); |
unsigned char pck_class_in_gen(unsigned int); |
unsigned int pck_dst_gen_task_graph ( unsigned int); |
unsigned int pck_dst_gen_task_graph ( unsigned int, unsigned char *); |
void print_statistic (void); |
void print_parameter(); |
void reset_all_register(); |
176,7 → 243,7
void connect_clk_reset_start_all(void); |
unsigned int rnd_between (unsigned int, unsigned int ); |
void traffic_gen_init( void ); |
void pck_inj_init(void); |
void pck_inj_init(int); |
void traffic_gen_final_report(void); |
void processArgs (int, char ** ); |
void task_traffic_init (char * ); |
184,17 → 251,21
void update_pck_size(char *); |
void update_custom_traffic (char *); |
void update_hotspot(char * ); |
void update_mcast_traffic(char * str); |
void initial_threads (void); |
void print_statistic_new (unsigned long int); |
void allocate_rsv_pck_counters (void); |
void update_all_router_stat(void); |
void print_router_st(void); |
void print_endp_to_endp_st(const char *); |
void update_traffic_injector_st (unsigned int ); |
|
|
|
#include "topology_top.h" |
#include "traffic_task_graph.h" |
#include "traffic_synthetic.h" |
#include "netrace_lib.h" |
#include "synful_wrapper.h" |
|
|
#define RATIO_INIT 2 |
#define DISABLE -1 |
#define MY_VL_SETBIT_W(data,bit) (data[VL_BITWORD_I(bit)] |= (VL_UL(1) << VL_BITBIT_I(bit))) |
212,6 → 283,7
int * class_percentage; |
char * TRAFFIC; |
char * netrace_file; |
char * synful_file; |
unsigned char FIXED_SRC_DST_PAIR; |
unsigned char NEw=0; |
unsigned long int main_time = 0; // Current simulation time |
232,6 → 304,7
char all_done=0; |
unsigned int total_sent_flit_number =0; |
unsigned int total_rsv_flit_number =0; |
unsigned int total_expect_rsv_flit_num =0; |
unsigned int total_rsv_flit_number_old=0; |
int ratio=RATIO_INIT; |
double first_avg_latency_flit,current_avg_latency_flit; |
246,10 → 319,10
int thread_num =1; |
|
|
mcast_t mcast; |
|
|
|
|
#if (STND_DEV_EN) |
//#include <math.h> |
double sqroot (double s){ |
266,7 → 339,49
#endif |
|
|
// set data[bit] to 1 |
#define VL_BIT_SET_I(data, bit) data |= (VL_UL(1) << VL_BITBIT_I(bit)) |
#define VL_BIT_SET_Q(data, bit) data |= (1ULL << VL_BITBIT_Q(bit)) |
#define VL_BIT_SET_E(data, bit) data |= (VL_EUL(1) << VL_BITBIT_E(bit)) |
#define VL_BIT_SET_W(data, bit) (data)[VL_BITWORD_E(bit)] |= (VL_EUL(1) << VL_BITBIT_E(bit)) |
|
// set data[bit] to 0 |
#define VL_BIT_CLR_I(data, bit) data &= ~(VL_UL(1) << VL_BITBIT_I(bit)) |
#define VL_BIT_CLR_Q(data, bit) data &= ~(1ULL << VL_BITBIT_Q(bit)) |
#define VL_BIT_CLR_E(data, bit) data &= ~ (VL_EUL(1) << VL_BITBIT_E(bit)) |
#define VL_BIT_CLR_W(data, bit) (data)[VL_BITWORD_E(bit)] &= ~ (VL_EUL(1) << VL_BITBIT_E(bit)) |
|
|
#if (DAw<=VL_IDATASIZE) |
#define DEST_ADDR_BIT_SET(data, bit) VL_BIT_SET_I(data, bit) |
#define DEST_ADDR_BIT_CLR(data, bit) VL_BIT_CLR_I(data, bit) |
#define DEST_ADDR_ASSIGN_RAND(data) data = rand() & ((1<<DAw) -1) |
#define DEST_ADDR_ASSIGN_ZERO(data) data = 0 |
#define DEST_ADDR_ASSIGN_INT(data,val) data = val & ((1<<DAw) -1) |
#define DEST_ADDR_IS_ZERO(a,data) a= (data ==0) |
#elif (DAw<=VL_QUADSIZE) |
#define DEST_ADDR_BIT_SET(data, bit) VL_BIT_SET_Q(data, bit) |
#define DEST_ADDR_BIT_CLR(data, bit) VL_BIT_CLR_Q(data, bit) |
#define DEST_ADDR_ASSIGN_RAND(data) data = (rand()&0xFFFFFFFF) | \ |
(QData) (rand() & ((1ULL<<(DAw-32)) -1)) <<32 |
#define DEST_ADDR_ASSIGN_ZERO(data) data = 0ULL |
#define DEST_ADDR_ASSIGN_INT(data,val) data = val & ((1ULL<<32) -1) |
#define DEST_ADDR_IS_ZERO(a,data) a= (data == 0ULL) |
#else |
#define DEST_ADDR_BIT_SET(data, bit) VL_BIT_SET_W(data, bit) |
#define DEST_ADDR_BIT_CLR(data, bit) VL_BIT_CLR_W(data, bit) |
#define DEST_ADDR_ASSIGN_RAND(data) \ |
for(int n=0;n<=VL_BITWORD_E(DAw-1)-1;n++) (data)[n]=rand();\ |
(data)[VL_BITWORD_E(DAw-1)]=rand() & ((1ULL<<(VL_BITBIT_E(DAw-1)+1)) -1) |
#define DEST_ADDR_ASSIGN_ZERO(data) \ |
for(int n=0;n<=VL_BITWORD_E(DAw-1);n++) (data)[n]= 0 |
#define DEST_ADDR_ASSIGN_INT(data,val) (data)[0] = val |
|
#define DEST_ADDR_IS_ZERO(a,data) \ |
a=1; for(int n=0;n<=VL_BITWORD_E(DAw-1)-1;n++) \ |
if (a==1) a= ((data)[n]==0);\ |
if (a==1) a= ((data)[VL_BITWORD_E(DAw-1)] & ((1ULL<<(VL_BITBIT_E(DAw-1)+1)) -1))==0 |
#endif |
|
|
#endif |
|
/synful_wrapper.h
0,0 → 1,208
#ifndef _SYNFUL_WRAPPER_H |
#define _SYNFUL_WRAPPER_H |
|
|
#include <iostream> |
|
#include "synful/synful.h" |
|
bool synful_SSExit; |
int synful_random_seed=53432145; |
int synful_packets_left = 0; |
int synful_flitw =4; |
|
extern queue_t** synful_inject; |
queue_t** synful_traverse; |
|
|
|
|
|
void synful_init(char * fname, bool ss_exit, int seed,unsigned int max_clk, unsigned int max_pck){ |
//std::cout << "Initiating synful with: " << fname << "random seed:" << seed << std::endl; |
synful_model_init(fname, ss_exit,seed,max_clk, max_pck, traffic_model_mapping ); |
|
synful_inject = (queue_t**) malloc( NE * sizeof(queue_t*) ); |
synful_traverse = (queue_t**) malloc( NE * sizeof(queue_t*) ); |
|
if(synful_inject == NULL || synful_traverse == NULL ) { |
printf( "ERROR: malloc fail queues\n" ); |
exit(0); |
} |
for(int i = 0; i < NE; ++i ) { |
synful_inject[i] = queue_new(); |
synful_traverse[i] = queue_new(); |
} |
} |
|
|
void synful_final_report(){ |
int i; |
|
if(verbosity==1) printf("\e[?25h");//To re-enable the cursor: |
printf("\nSynful simulation results-------------------\n" |
"\tSimulation clock cycles: %llu\n" |
,synful_cycle); |
print_statistic_new (synful_cycle); |
} |
|
|
|
void synful_eval( ){ |
int i; |
unsigned int pronoc_src_id,pronoc_dst_id; |
|
if((reset==1) || (count_en==0)) return; |
|
if((( synful_cycle > sim_end_clk_num) || (total_sent_pck_num>= end_sim_pck_num )) && synful_packets_left==0 ) simulation_done=1; |
|
// Reset packets remaining check |
synful_packets_left = 0; |
|
synful_run_one_cycle (); |
|
|
// Inject where possible (max one per node) |
for( i = 0; i < NE; ++i ) { |
synful_packets_left |= !queue_empty( synful_inject[i] ); |
|
//TODO define sent vc policy |
int sent_vc = 0; |
|
if(pck_inj[i]->pck_injct_in_pck_wr){ |
//the wr_pck should be asserted only for single cycle |
pck_inj[i]->pck_injct_in_pck_wr = 0; |
continue; |
} |
|
pck_inj[i]->pck_injct_in_pck_wr = 0; |
if((pck_inj[i]->pck_injct_out_ready & (0x1<<sent_vc)) == 0){ |
//This pck injector is not ready yet |
continue; |
} |
|
pronoc_pck_t* temp_node = (pronoc_pck_t*) queue_peek_front( synful_inject[i] ); |
if( temp_node != NULL ) { |
if(verbosity>1) { |
printf( "Inject: %llu ", synful_cycle ); |
synful_print_packet( temp_node ); |
} |
temp_node = (pronoc_pck_t*) queue_pop_front( synful_inject[i] ); |
|
pronoc_dst_id = traffic_model_mapping[temp_node->dest]; |
queue_push( synful_traverse[pronoc_dst_id], temp_node, synful_cycle ); |
int flit_num = temp_node->packetSize / synful_flitw ; |
if (flit_num*synful_flitw !=temp_node->packetSize) flit_num++; |
if (flit_num < pck_inj[i]->min_pck_size) flit_num = pck_inj[i]->min_pck_size; |
|
if(IS_SELF_LOOP_EN ==0){ |
if(pronoc_dst_id == i ){ |
fprintf(stderr,"ERROR: ProNoC is not configured with self-loop enable and Netrace aims to inject\n a " |
"packet with identical source and destination address. Enable the SELF_LOOP parameter\n" |
"in ProNoC and rebuild the simulation model\n"); |
exit(1); |
} |
} |
|
unsigned int sent_class =0; |
long int ptr_addr = reinterpret_cast<long int> (temp_node); |
pck_inj[i]->pck_injct_in_data = ptr_addr; |
pck_inj[i]->pck_injct_in_size = flit_num; |
pck_inj[i]->pck_injct_in_endp_addr = endp_addr_encoder(pronoc_dst_id); |
pck_inj[i]->pck_injct_in_class_num = sent_class; |
pck_inj[i]->pck_injct_in_init_weight = 1; |
pck_inj[i]->pck_injct_in_vc = 0x1<<sent_vc; |
pck_inj[i]->pck_injct_in_pck_wr = 1; |
total_sent_pck_num++; |
|
#if (C>1) |
sent_stat[i][sent_class].pck_num ++; |
sent_stat[i][sent_class].flit_num +=flit_num; |
#else |
sent_stat[i].pck_num ++; |
sent_stat[i].flit_num +=flit_num; |
#endif |
}//temp!=NULL |
}//inject |
|
|
|
// Step all network components, Eject where possible |
for( i = 0; i < NE; ++i ) { |
synful_packets_left |= !queue_empty( synful_traverse[i] ); |
//check which pck injector got a packet |
if(pck_inj[i]->pck_injct_out_pck_wr==0) continue; |
//we have got a packet |
//printf( "data=%lx\n",pck_inj[i]->pck_injct_out_data); |
|
pronoc_pck_t* temp_node = (pronoc_pck_t*) pck_inj[i]->pck_injct_out_data; |
if( temp_node != NULL ) { |
if(verbosity>1) { |
printf( "Eject: %llu ", synful_cycle ); |
synful_print_packet(temp_node); |
} |
//send it to synful |
synful_Eject (temp_node); |
|
// remove from traverse |
|
queue_remove( synful_traverse[i], temp_node ); |
unsigned long long int clk_num_h2t= (synful_cycle - temp_node->cycle); |
unsigned int clk_num_h2h= clk_num_h2t - pck_inj[i]->pck_injct_out_h2t_delay; |
/* |
printf("clk_num_h2t (%llu) h2t_delay(%u)\n", clk_num_h2t , pck_inj[i]->pck_injct_out_h2t_delay); |
if(clk_num_h2t < pck_inj[i]->pck_injct_out_h2t_delay){ |
fprintf(stderr, "ERROR:clk_num_h2t (%llu) is smaller than injector h2t_delay(%u)\n", clk_num_h2t , pck_inj[i]->pck_injct_out_h2t_delay); |
exit(1); |
} |
*/ |
pronoc_src_id=traffic_model_mapping[temp_node->source]; |
update_statistic_at_ejection ( |
i,// core_num |
clk_num_h2h, // clk_num_h2h, |
(unsigned int) clk_num_h2t, // clk_num_h2t, |
pck_inj[i]->pck_injct_out_distance, // distance, |
pck_inj[i]->pck_injct_out_class_num,// class_num, |
pronoc_src_id, //temp_node->source |
pck_inj[i]->pck_injct_out_size |
); |
|
free( temp_node ); |
|
}//emp_node != NULL |
}//for |
|
synful_cycle++; |
|
//std::cout << synful_cycle << std::endl; |
|
} |
|
|
|
|
|
void synful_negedge_event( ){ |
int i; |
clk = 0; |
topology_connect_all_nodes (); |
//connect_clk_reset_start_all(); |
sim_eval_all(); |
} |
|
void synful_posedge_event(){ |
unsigned int i; |
clk = 1; // Toggle clock |
update_all_router_stat(); |
synful_eval(); |
//connect_clk_reset_start_all(); |
sim_eval_all(); |
//print total sent packet each 1024 clock cycles |
if(verbosity==1) if(synful_cycle&0x3FF) printf("\rTotal sent packet: %9d", total_sent_pck_num); |
} |
|
|
|
|
|
#endif |
/topology/custom/custom.h
0,0 → 1,6
|
//do not modify this line ===custom1=== |
#ifdef IS_custom1_noc |
#include "custom1_noc.h" |
#endif |
|
/topology/custom/custom1_noc.h
1,155 → 1,241
|
|
|
|
void topology_connect_all_nodes (void){ |
//Connect R0 input ports 0 to T0 output ports 0 |
connect_r2e(1,0,0,0); |
//Connect R0 input ports 1 to R14 output ports 3 |
conect_r2r(1,0,1,2,6,3); |
void single_r2r0(void){conect_r2r(1,0,1,2,6,3);} |
//Connect R0 input ports 2 to R13 output ports 3 |
conect_r2r(1,0,2,2,5,3); |
//Connect R1 input ports 0 to T1 output ports 0 |
connect_r2e(1,1,0,1); |
void single_r2r1(void){conect_r2r(1,0,2,2,5,3);} |
//Connect R1 input ports 1 to R7 output ports 3 |
conect_r2r(1,1,1,2,3,3); |
void single_r2r2(void){conect_r2r(1,1,1,2,3,3);} |
//Connect R1 input ports 2 to R2 output ports 2 |
conect_r2r(1,1,2,1,2,2); |
//Connect R2 input ports 0 to T2 output ports 0 |
connect_r2e(1,2,0,2); |
void single_r2r3(void){conect_r2r(1,1,2,1,2,2);} |
//Connect R2 input ports 1 to R15 output ports 2 |
conect_r2r(1,2,1,2,7,2); |
void single_r2r4(void){conect_r2r(1,2,1,2,7,2);} |
//Connect R2 input ports 2 to R1 output ports 2 |
conect_r2r(1,2,2,1,1,2); |
//Connect R3 input ports 0 to T3 output ports 0 |
connect_r2e(1,3,0,3); |
void single_r2r5(void){conect_r2r(1,2,2,1,1,2);} |
//Connect R3 input ports 1 to R15 output ports 3 |
conect_r2r(1,3,1,2,7,3); |
void single_r2r6(void){conect_r2r(1,3,1,2,7,3);} |
//Connect R3 input ports 2 to R4 output ports 2 |
conect_r2r(1,3,2,2,0,2); |
//Connect R4 input ports 0 to T4 output ports 0 |
connect_r2e(2,0,0,4); |
void single_r2r7(void){conect_r2r(1,3,2,2,0,2);} |
//Connect R4 input ports 1 to R9 output ports 2 |
conect_r2r(2,0,1,3,1,2); |
void single_r2r8(void){conect_r2r(2,0,1,3,1,2);} |
//Connect R4 input ports 2 to R3 output ports 2 |
conect_r2r(2,0,2,1,3,2); |
void single_r2r9(void){conect_r2r(2,0,2,1,3,2);} |
//Connect R4 input ports 3 to R6 output ports 3 |
conect_r2r(2,0,3,2,2,3); |
//Connect R5 input ports 0 to T5 output ports 0 |
connect_r2e(2,1,0,5); |
void single_r2r10(void){conect_r2r(2,0,3,2,2,3);} |
//Connect R5 input ports 1 to R11 output ports 4 |
conect_r2r(2,1,1,3,3,4); |
void single_r2r11(void){conect_r2r(2,1,1,3,3,4);} |
//Connect R5 input ports 2 to R6 output ports 2 |
conect_r2r(2,1,2,2,2,2); |
void single_r2r12(void){conect_r2r(2,1,2,2,2,2);} |
//Connect R5 input ports 3 to R13 output ports 2 |
conect_r2r(2,1,3,2,5,2); |
//Connect R6 input ports 0 to T6 output ports 0 |
connect_r2e(2,2,0,6); |
void single_r2r13(void){conect_r2r(2,1,3,2,5,2);} |
//Connect R6 input ports 1 to R9 output ports 3 |
conect_r2r(2,2,1,3,1,3); |
void single_r2r14(void){conect_r2r(2,2,1,3,1,3);} |
//Connect R6 input ports 2 to R5 output ports 2 |
conect_r2r(2,2,2,2,1,2); |
void single_r2r15(void){conect_r2r(2,2,2,2,1,2);} |
//Connect R6 input ports 3 to R4 output ports 3 |
conect_r2r(2,2,3,2,0,3); |
//Connect R7 input ports 0 to T7 output ports 0 |
connect_r2e(2,3,0,7); |
void single_r2r16(void){conect_r2r(2,2,3,2,0,3);} |
//Connect R7 input ports 1 to R12 output ports 3 |
conect_r2r(2,3,1,2,4,3); |
void single_r2r17(void){conect_r2r(2,3,1,2,4,3);} |
//Connect R7 input ports 2 to R14 output ports 2 |
conect_r2r(2,3,2,2,6,2); |
void single_r2r18(void){conect_r2r(2,3,2,2,6,2);} |
//Connect R7 input ports 3 to R1 output ports 1 |
conect_r2r(2,3,3,1,1,1); |
//Connect R12 input ports 0 to T8 output ports 0 |
connect_r2e(2,4,0,8); |
void single_r2r19(void){conect_r2r(2,3,3,1,1,1);} |
//Connect R12 input ports 1 to R8 output ports 4 |
conect_r2r(2,4,1,3,0,4); |
void single_r2r20(void){conect_r2r(2,4,1,3,0,4);} |
//Connect R12 input ports 2 to R10 output ports 3 |
conect_r2r(2,4,2,3,2,3); |
void single_r2r21(void){conect_r2r(2,4,2,3,2,3);} |
//Connect R12 input ports 3 to R7 output ports 1 |
conect_r2r(2,4,3,2,3,1); |
//Connect R13 input ports 0 to T9 output ports 0 |
connect_r2e(2,5,0,9); |
void single_r2r22(void){conect_r2r(2,4,3,2,3,1);} |
//Connect R13 input ports 1 to R8 output ports 2 |
conect_r2r(2,5,1,3,0,2); |
void single_r2r23(void){conect_r2r(2,5,1,3,0,2);} |
//Connect R13 input ports 2 to R5 output ports 3 |
conect_r2r(2,5,2,2,1,3); |
void single_r2r24(void){conect_r2r(2,5,2,2,1,3);} |
//Connect R13 input ports 3 to R0 output ports 2 |
conect_r2r(2,5,3,1,0,2); |
//Connect R14 input ports 0 to T10 output ports 0 |
connect_r2e(2,6,0,10); |
void single_r2r25(void){conect_r2r(2,5,3,1,0,2);} |
//Connect R14 input ports 1 to R8 output ports 3 |
conect_r2r(2,6,1,3,0,3); |
void single_r2r26(void){conect_r2r(2,6,1,3,0,3);} |
//Connect R14 input ports 2 to R7 output ports 2 |
conect_r2r(2,6,2,2,3,2); |
void single_r2r27(void){conect_r2r(2,6,2,2,3,2);} |
//Connect R14 input ports 3 to R0 output ports 1 |
conect_r2r(2,6,3,1,0,1); |
//Connect R15 input ports 0 to T11 output ports 0 |
connect_r2e(2,7,0,11); |
void single_r2r28(void){conect_r2r(2,6,3,1,0,1);} |
//Connect R15 input ports 1 to R10 output ports 4 |
conect_r2r(2,7,1,3,2,4); |
void single_r2r29(void){conect_r2r(2,7,1,3,2,4);} |
//Connect R15 input ports 2 to R2 output ports 1 |
conect_r2r(2,7,2,1,2,1); |
void single_r2r30(void){conect_r2r(2,7,2,1,2,1);} |
//Connect R15 input ports 3 to R3 output ports 1 |
conect_r2r(2,7,3,1,3,1); |
//Connect R8 input ports 0 to T12 output ports 0 |
connect_r2e(3,0,0,12); |
void single_r2r31(void){conect_r2r(2,7,3,1,3,1);} |
//Connect R8 input ports 1 to R11 output ports 1 |
conect_r2r(3,0,1,3,3,1); |
void single_r2r32(void){conect_r2r(3,0,1,3,3,1);} |
//Connect R8 input ports 2 to R13 output ports 1 |
conect_r2r(3,0,2,2,5,1); |
void single_r2r33(void){conect_r2r(3,0,2,2,5,1);} |
//Connect R8 input ports 3 to R14 output ports 1 |
conect_r2r(3,0,3,2,6,1); |
void single_r2r34(void){conect_r2r(3,0,3,2,6,1);} |
//Connect R8 input ports 4 to R12 output ports 1 |
conect_r2r(3,0,4,2,4,1); |
//Connect R9 input ports 0 to T13 output ports 0 |
connect_r2e(3,1,0,13); |
void single_r2r35(void){conect_r2r(3,0,4,2,4,1);} |
//Connect R9 input ports 1 to R11 output ports 3 |
conect_r2r(3,1,1,3,3,3); |
void single_r2r36(void){conect_r2r(3,1,1,3,3,3);} |
//Connect R9 input ports 2 to R4 output ports 1 |
conect_r2r(3,1,2,2,0,1); |
void single_r2r37(void){conect_r2r(3,1,2,2,0,1);} |
//Connect R9 input ports 3 to R6 output ports 1 |
conect_r2r(3,1,3,2,2,1); |
void single_r2r38(void){conect_r2r(3,1,3,2,2,1);} |
//Connect R9 input ports 4 to R10 output ports 2 |
conect_r2r(3,1,4,3,2,2); |
//Connect R10 input ports 0 to T14 output ports 0 |
connect_r2e(3,2,0,14); |
void single_r2r39(void){conect_r2r(3,1,4,3,2,2);} |
//Connect R10 input ports 1 to R11 output ports 2 |
conect_r2r(3,2,1,3,3,2); |
void single_r2r40(void){conect_r2r(3,2,1,3,3,2);} |
//Connect R10 input ports 2 to R9 output ports 4 |
conect_r2r(3,2,2,3,1,4); |
void single_r2r41(void){conect_r2r(3,2,2,3,1,4);} |
//Connect R10 input ports 3 to R12 output ports 2 |
conect_r2r(3,2,3,2,4,2); |
void single_r2r42(void){conect_r2r(3,2,3,2,4,2);} |
//Connect R10 input ports 4 to R15 output ports 1 |
conect_r2r(3,2,4,2,7,1); |
//Connect R11 input ports 0 to T15 output ports 0 |
connect_r2e(3,3,0,15); |
void single_r2r43(void){conect_r2r(3,2,4,2,7,1);} |
//Connect R11 input ports 1 to R8 output ports 1 |
conect_r2r(3,3,1,3,0,1); |
void single_r2r44(void){conect_r2r(3,3,1,3,0,1);} |
//Connect R11 input ports 2 to R10 output ports 1 |
conect_r2r(3,3,2,3,2,1); |
void single_r2r45(void){conect_r2r(3,3,2,3,2,1);} |
//Connect R11 input ports 3 to R9 output ports 1 |
conect_r2r(3,3,3,3,1,1); |
void single_r2r46(void){conect_r2r(3,3,3,3,1,1);} |
//Connect R11 input ports 4 to R5 output ports 1 |
conect_r2r(3,3,4,2,1,1); |
void single_r2r47(void){conect_r2r(3,3,4,2,1,1);} |
|
|
//Connect R0 input ports 0 to T0 output ports 0 |
void single_r2e0(void) {connect_r2e(1,0,0,0);} |
//Connect R1 input ports 0 to T1 output ports 0 |
void single_r2e1(void) {connect_r2e(1,1,0,1);} |
//Connect R2 input ports 0 to T2 output ports 0 |
void single_r2e2(void) {connect_r2e(1,2,0,2);} |
//Connect R3 input ports 0 to T3 output ports 0 |
void single_r2e3(void) {connect_r2e(1,3,0,3);} |
//Connect R4 input ports 0 to T4 output ports 0 |
void single_r2e4(void) {connect_r2e(2,0,0,4);} |
//Connect R5 input ports 0 to T5 output ports 0 |
void single_r2e5(void) {connect_r2e(2,1,0,5);} |
//Connect R6 input ports 0 to T6 output ports 0 |
void single_r2e6(void) {connect_r2e(2,2,0,6);} |
//Connect R7 input ports 0 to T7 output ports 0 |
void single_r2e7(void) {connect_r2e(2,3,0,7);} |
//Connect R12 input ports 0 to T8 output ports 0 |
void single_r2e8(void) {connect_r2e(2,4,0,8);} |
//Connect R13 input ports 0 to T9 output ports 0 |
void single_r2e9(void) {connect_r2e(2,5,0,9);} |
//Connect R14 input ports 0 to T10 output ports 0 |
void single_r2e10(void) {connect_r2e(2,6,0,10);} |
//Connect R15 input ports 0 to T11 output ports 0 |
void single_r2e11(void) {connect_r2e(2,7,0,11);} |
//Connect R8 input ports 0 to T12 output ports 0 |
void single_r2e12(void) {connect_r2e(3,0,0,12);} |
//Connect R9 input ports 0 to T13 output ports 0 |
void single_r2e13(void) {connect_r2e(3,1,0,13);} |
//Connect R10 input ports 0 to T14 output ports 0 |
void single_r2e14(void) {connect_r2e(3,2,0,14);} |
//Connect R11 input ports 0 to T15 output ports 0 |
void single_r2e15(void) {connect_r2e(3,3,0,15);} |
|
|
|
void (*r2r_func_ptr[48])() = { |
single_r2r0,single_r2r1,single_r2r2,single_r2r3,single_r2r4,single_r2r5,single_r2r6,single_r2r7,single_r2r8,single_r2r9 |
,single_r2r10,single_r2r11,single_r2r12,single_r2r13,single_r2r14,single_r2r15,single_r2r16,single_r2r17,single_r2r18,single_r2r19 |
,single_r2r20,single_r2r21,single_r2r22,single_r2r23,single_r2r24,single_r2r25,single_r2r26,single_r2r27,single_r2r28,single_r2r29 |
,single_r2r30,single_r2r31,single_r2r32,single_r2r33,single_r2r34,single_r2r35,single_r2r36,single_r2r37,single_r2r38,single_r2r39 |
,single_r2r40,single_r2r41,single_r2r42,single_r2r43,single_r2r44,single_r2r45,single_r2r46,single_r2r47}; |
void (*r2e_func_ptr[16])() = { |
single_r2e0,single_r2e1,single_r2e2,single_r2e3,single_r2e4,single_r2e5,single_r2e6,single_r2e7,single_r2e8,single_r2e9 |
,single_r2e10,single_r2e11,single_r2e12,single_r2e13,single_r2e14,single_r2e15}; |
|
void topology_connect_r2r (int n){ |
(*r2r_func_ptr[n])(); |
} |
|
void topology_connect_r2e (int n){ |
(*r2e_func_ptr[n])(); |
} |
|
|
|
void topology_init(void){ |
router1[0]->current_r_addr=0; |
router1[0]->current_r_id=0; |
router1[1]->current_r_addr=1; |
router1[1]->current_r_id=1; |
router1[2]->current_r_addr=2; |
router1[2]->current_r_id=2; |
router1[3]->current_r_addr=3; |
router1[3]->current_r_id=3; |
router2[0]->current_r_addr=4; |
router2[0]->current_r_id=4; |
router2[1]->current_r_addr=5; |
router2[1]->current_r_id=5; |
router2[2]->current_r_addr=6; |
router2[2]->current_r_id=6; |
router2[3]->current_r_addr=7; |
router2[3]->current_r_id=7; |
router2[4]->current_r_addr=8; |
router2[4]->current_r_id=8; |
router2[5]->current_r_addr=9; |
router2[5]->current_r_id=9; |
router2[6]->current_r_addr=10; |
router2[6]->current_r_id=10; |
router2[7]->current_r_addr=11; |
router2[7]->current_r_id=11; |
router3[0]->current_r_addr=12; |
router3[0]->current_r_id=12; |
router3[1]->current_r_addr=13; |
router3[1]->current_r_id=13; |
router3[2]->current_r_addr=14; |
router3[2]->current_r_id=14; |
router3[3]->current_r_addr=15; |
router3[3]->current_r_id=15; |
r2r_cnt_all[0] =(r2r_cnt_table_t){.id1=0, .t1=1, .r1=0, .p1=1,.id2=10, .t2=2, .r2=6, .p2=3 }; |
r2r_cnt_all[1] =(r2r_cnt_table_t){.id1=0, .t1=1, .r1=0, .p1=2,.id2=9, .t2=2, .r2=5, .p2=3 }; |
r2r_cnt_all[2] =(r2r_cnt_table_t){.id1=1, .t1=1, .r1=1, .p1=1,.id2=7, .t2=2, .r2=3, .p2=3 }; |
r2r_cnt_all[3] =(r2r_cnt_table_t){.id1=1, .t1=1, .r1=1, .p1=2,.id2=2, .t2=1, .r2=2, .p2=2 }; |
r2r_cnt_all[4] =(r2r_cnt_table_t){.id1=2, .t1=1, .r1=2, .p1=1,.id2=11, .t2=2, .r2=7, .p2=2 }; |
r2r_cnt_all[5] =(r2r_cnt_table_t){.id1=2, .t1=1, .r1=2, .p1=2,.id2=1, .t2=1, .r2=1, .p2=2 }; |
r2r_cnt_all[6] =(r2r_cnt_table_t){.id1=3, .t1=1, .r1=3, .p1=1,.id2=11, .t2=2, .r2=7, .p2=3 }; |
r2r_cnt_all[7] =(r2r_cnt_table_t){.id1=3, .t1=1, .r1=3, .p1=2,.id2=4, .t2=2, .r2=0, .p2=2 }; |
r2r_cnt_all[8] =(r2r_cnt_table_t){.id1=4, .t1=2, .r1=0, .p1=1,.id2=13, .t2=3, .r2=1, .p2=2 }; |
r2r_cnt_all[9] =(r2r_cnt_table_t){.id1=4, .t1=2, .r1=0, .p1=2,.id2=3, .t2=1, .r2=3, .p2=2 }; |
r2r_cnt_all[10] =(r2r_cnt_table_t){.id1=4, .t1=2, .r1=0, .p1=3,.id2=6, .t2=2, .r2=2, .p2=3 }; |
r2r_cnt_all[11] =(r2r_cnt_table_t){.id1=5, .t1=2, .r1=1, .p1=1,.id2=15, .t2=3, .r2=3, .p2=4 }; |
r2r_cnt_all[12] =(r2r_cnt_table_t){.id1=5, .t1=2, .r1=1, .p1=2,.id2=6, .t2=2, .r2=2, .p2=2 }; |
r2r_cnt_all[13] =(r2r_cnt_table_t){.id1=5, .t1=2, .r1=1, .p1=3,.id2=9, .t2=2, .r2=5, .p2=2 }; |
r2r_cnt_all[14] =(r2r_cnt_table_t){.id1=6, .t1=2, .r1=2, .p1=1,.id2=13, .t2=3, .r2=1, .p2=3 }; |
r2r_cnt_all[15] =(r2r_cnt_table_t){.id1=6, .t1=2, .r1=2, .p1=2,.id2=5, .t2=2, .r2=1, .p2=2 }; |
r2r_cnt_all[16] =(r2r_cnt_table_t){.id1=6, .t1=2, .r1=2, .p1=3,.id2=4, .t2=2, .r2=0, .p2=3 }; |
r2r_cnt_all[17] =(r2r_cnt_table_t){.id1=7, .t1=2, .r1=3, .p1=1,.id2=8, .t2=2, .r2=4, .p2=3 }; |
r2r_cnt_all[18] =(r2r_cnt_table_t){.id1=7, .t1=2, .r1=3, .p1=2,.id2=10, .t2=2, .r2=6, .p2=2 }; |
r2r_cnt_all[19] =(r2r_cnt_table_t){.id1=7, .t1=2, .r1=3, .p1=3,.id2=1, .t2=1, .r2=1, .p2=1 }; |
r2r_cnt_all[20] =(r2r_cnt_table_t){.id1=8, .t1=2, .r1=4, .p1=1,.id2=12, .t2=3, .r2=0, .p2=4 }; |
r2r_cnt_all[21] =(r2r_cnt_table_t){.id1=8, .t1=2, .r1=4, .p1=2,.id2=14, .t2=3, .r2=2, .p2=3 }; |
r2r_cnt_all[22] =(r2r_cnt_table_t){.id1=8, .t1=2, .r1=4, .p1=3,.id2=7, .t2=2, .r2=3, .p2=1 }; |
r2r_cnt_all[23] =(r2r_cnt_table_t){.id1=9, .t1=2, .r1=5, .p1=1,.id2=12, .t2=3, .r2=0, .p2=2 }; |
r2r_cnt_all[24] =(r2r_cnt_table_t){.id1=9, .t1=2, .r1=5, .p1=2,.id2=5, .t2=2, .r2=1, .p2=3 }; |
r2r_cnt_all[25] =(r2r_cnt_table_t){.id1=9, .t1=2, .r1=5, .p1=3,.id2=0, .t2=1, .r2=0, .p2=2 }; |
r2r_cnt_all[26] =(r2r_cnt_table_t){.id1=10, .t1=2, .r1=6, .p1=1,.id2=12, .t2=3, .r2=0, .p2=3 }; |
r2r_cnt_all[27] =(r2r_cnt_table_t){.id1=10, .t1=2, .r1=6, .p1=2,.id2=7, .t2=2, .r2=3, .p2=2 }; |
r2r_cnt_all[28] =(r2r_cnt_table_t){.id1=10, .t1=2, .r1=6, .p1=3,.id2=0, .t2=1, .r2=0, .p2=1 }; |
r2r_cnt_all[29] =(r2r_cnt_table_t){.id1=11, .t1=2, .r1=7, .p1=1,.id2=14, .t2=3, .r2=2, .p2=4 }; |
r2r_cnt_all[30] =(r2r_cnt_table_t){.id1=11, .t1=2, .r1=7, .p1=2,.id2=2, .t2=1, .r2=2, .p2=1 }; |
r2r_cnt_all[31] =(r2r_cnt_table_t){.id1=11, .t1=2, .r1=7, .p1=3,.id2=3, .t2=1, .r2=3, .p2=1 }; |
r2r_cnt_all[32] =(r2r_cnt_table_t){.id1=12, .t1=3, .r1=0, .p1=1,.id2=15, .t2=3, .r2=3, .p2=1 }; |
r2r_cnt_all[33] =(r2r_cnt_table_t){.id1=12, .t1=3, .r1=0, .p1=2,.id2=9, .t2=2, .r2=5, .p2=1 }; |
r2r_cnt_all[34] =(r2r_cnt_table_t){.id1=12, .t1=3, .r1=0, .p1=3,.id2=10, .t2=2, .r2=6, .p2=1 }; |
r2r_cnt_all[35] =(r2r_cnt_table_t){.id1=12, .t1=3, .r1=0, .p1=4,.id2=8, .t2=2, .r2=4, .p2=1 }; |
r2r_cnt_all[36] =(r2r_cnt_table_t){.id1=13, .t1=3, .r1=1, .p1=1,.id2=15, .t2=3, .r2=3, .p2=3 }; |
r2r_cnt_all[37] =(r2r_cnt_table_t){.id1=13, .t1=3, .r1=1, .p1=2,.id2=4, .t2=2, .r2=0, .p2=1 }; |
r2r_cnt_all[38] =(r2r_cnt_table_t){.id1=13, .t1=3, .r1=1, .p1=3,.id2=6, .t2=2, .r2=2, .p2=1 }; |
r2r_cnt_all[39] =(r2r_cnt_table_t){.id1=13, .t1=3, .r1=1, .p1=4,.id2=14, .t2=3, .r2=2, .p2=2 }; |
r2r_cnt_all[40] =(r2r_cnt_table_t){.id1=14, .t1=3, .r1=2, .p1=1,.id2=15, .t2=3, .r2=3, .p2=2 }; |
r2r_cnt_all[41] =(r2r_cnt_table_t){.id1=14, .t1=3, .r1=2, .p1=2,.id2=13, .t2=3, .r2=1, .p2=4 }; |
r2r_cnt_all[42] =(r2r_cnt_table_t){.id1=14, .t1=3, .r1=2, .p1=3,.id2=8, .t2=2, .r2=4, .p2=2 }; |
r2r_cnt_all[43] =(r2r_cnt_table_t){.id1=14, .t1=3, .r1=2, .p1=4,.id2=11, .t2=2, .r2=7, .p2=1 }; |
r2r_cnt_all[44] =(r2r_cnt_table_t){.id1=15, .t1=3, .r1=3, .p1=1,.id2=12, .t2=3, .r2=0, .p2=1 }; |
r2r_cnt_all[45] =(r2r_cnt_table_t){.id1=15, .t1=3, .r1=3, .p1=2,.id2=14, .t2=3, .r2=2, .p2=1 }; |
r2r_cnt_all[46] =(r2r_cnt_table_t){.id1=15, .t1=3, .r1=3, .p1=3,.id2=13, .t2=3, .r2=1, .p2=1 }; |
r2r_cnt_all[47] =(r2r_cnt_table_t){.id1=15, .t1=3, .r1=3, .p1=4,.id2=5, .t2=2, .r2=1, .p2=1 }; |
|
R2R_TABLE_SIZ=48; |
|
} |
/topology/custom/mesh4x4_noc.h
0,0 → 1,187
|
|
|
|
void topology_connect_all_nodes (void){ |
//Connect R8 input ports 0 to T8 output ports 0 |
connect_r2e(1,0,0,8); |
//Connect R8 input ports 1 to R9 output ports 3 |
conect_r2r(1,0,1,1,1,3); |
//Connect R8 input ports 2 to R4 output ports 4 |
conect_r2r(1,0,2,1,8,4); |
//Connect R8 port 3 to ground |
connect_r2gnd(1,0,3); |
//Connect R8 input ports 4 to R12 output ports 2 |
conect_r2r(1,0,4,1,12,2); |
//Connect R9 input ports 0 to T9 output ports 0 |
connect_r2e(1,1,0,9); |
//Connect R9 input ports 1 to R10 output ports 3 |
conect_r2r(1,1,1,1,2,3); |
//Connect R9 input ports 2 to R5 output ports 4 |
conect_r2r(1,1,2,1,9,4); |
//Connect R9 input ports 3 to R8 output ports 1 |
conect_r2r(1,1,3,1,0,1); |
//Connect R9 input ports 4 to R13 output ports 2 |
conect_r2r(1,1,4,1,13,2); |
//Connect R10 input ports 0 to T10 output ports 0 |
connect_r2e(1,2,0,10); |
//Connect R10 input ports 1 to R11 output ports 3 |
conect_r2r(1,2,1,1,3,3); |
//Connect R10 input ports 2 to R6 output ports 4 |
conect_r2r(1,2,2,1,10,4); |
//Connect R10 input ports 3 to R9 output ports 1 |
conect_r2r(1,2,3,1,1,1); |
//Connect R10 input ports 4 to R14 output ports 2 |
conect_r2r(1,2,4,1,14,2); |
//Connect R11 input ports 0 to T11 output ports 0 |
connect_r2e(1,3,0,11); |
//Connect R11 port 1 to ground |
connect_r2gnd(1,3,1); |
//Connect R11 input ports 2 to R7 output ports 4 |
conect_r2r(1,3,2,1,11,4); |
//Connect R11 input ports 3 to R10 output ports 1 |
conect_r2r(1,3,3,1,2,1); |
//Connect R11 input ports 4 to R15 output ports 2 |
conect_r2r(1,3,4,1,15,2); |
//Connect R0 input ports 0 to T0 output ports 0 |
connect_r2e(1,4,0,0); |
//Connect R0 input ports 1 to R1 output ports 3 |
conect_r2r(1,4,1,1,5,3); |
//Connect R0 port 2 to ground |
connect_r2gnd(1,4,2); |
//Connect R0 port 3 to ground |
connect_r2gnd(1,4,3); |
//Connect R0 input ports 4 to R4 output ports 2 |
conect_r2r(1,4,4,1,8,2); |
//Connect R1 input ports 0 to T1 output ports 0 |
connect_r2e(1,5,0,1); |
//Connect R1 input ports 1 to R2 output ports 3 |
conect_r2r(1,5,1,1,6,3); |
//Connect R1 port 2 to ground |
connect_r2gnd(1,5,2); |
//Connect R1 input ports 3 to R0 output ports 1 |
conect_r2r(1,5,3,1,4,1); |
//Connect R1 input ports 4 to R5 output ports 2 |
conect_r2r(1,5,4,1,9,2); |
//Connect R2 input ports 0 to T2 output ports 0 |
connect_r2e(1,6,0,2); |
//Connect R2 input ports 1 to R3 output ports 3 |
conect_r2r(1,6,1,1,7,3); |
//Connect R2 port 2 to ground |
connect_r2gnd(1,6,2); |
//Connect R2 input ports 3 to R1 output ports 1 |
conect_r2r(1,6,3,1,5,1); |
//Connect R2 input ports 4 to R6 output ports 2 |
conect_r2r(1,6,4,1,10,2); |
//Connect R3 input ports 0 to T3 output ports 0 |
connect_r2e(1,7,0,3); |
//Connect R3 port 1 to ground |
connect_r2gnd(1,7,1); |
//Connect R3 port 2 to ground |
connect_r2gnd(1,7,2); |
//Connect R3 input ports 3 to R2 output ports 1 |
conect_r2r(1,7,3,1,6,1); |
//Connect R3 input ports 4 to R7 output ports 2 |
conect_r2r(1,7,4,1,11,2); |
//Connect R4 input ports 0 to T4 output ports 0 |
connect_r2e(1,8,0,4); |
//Connect R4 input ports 1 to R5 output ports 3 |
conect_r2r(1,8,1,1,9,3); |
//Connect R4 input ports 2 to R0 output ports 4 |
conect_r2r(1,8,2,1,4,4); |
//Connect R4 port 3 to ground |
connect_r2gnd(1,8,3); |
//Connect R4 input ports 4 to R8 output ports 2 |
conect_r2r(1,8,4,1,0,2); |
//Connect R5 input ports 0 to T5 output ports 0 |
connect_r2e(1,9,0,5); |
//Connect R5 input ports 1 to R6 output ports 3 |
conect_r2r(1,9,1,1,10,3); |
//Connect R5 input ports 2 to R1 output ports 4 |
conect_r2r(1,9,2,1,5,4); |
//Connect R5 input ports 3 to R4 output ports 1 |
conect_r2r(1,9,3,1,8,1); |
//Connect R5 input ports 4 to R9 output ports 2 |
conect_r2r(1,9,4,1,1,2); |
//Connect R6 input ports 0 to T6 output ports 0 |
connect_r2e(1,10,0,6); |
//Connect R6 input ports 1 to R7 output ports 3 |
conect_r2r(1,10,1,1,11,3); |
//Connect R6 input ports 2 to R2 output ports 4 |
conect_r2r(1,10,2,1,6,4); |
//Connect R6 input ports 3 to R5 output ports 1 |
conect_r2r(1,10,3,1,9,1); |
//Connect R6 input ports 4 to R10 output ports 2 |
conect_r2r(1,10,4,1,2,2); |
//Connect R7 input ports 0 to T7 output ports 0 |
connect_r2e(1,11,0,7); |
//Connect R7 port 1 to ground |
connect_r2gnd(1,11,1); |
//Connect R7 input ports 2 to R3 output ports 4 |
conect_r2r(1,11,2,1,7,4); |
//Connect R7 input ports 3 to R6 output ports 1 |
conect_r2r(1,11,3,1,10,1); |
//Connect R7 input ports 4 to R11 output ports 2 |
conect_r2r(1,11,4,1,3,2); |
//Connect R12 input ports 0 to T12 output ports 0 |
connect_r2e(1,12,0,12); |
//Connect R12 input ports 1 to R13 output ports 3 |
conect_r2r(1,12,1,1,13,3); |
//Connect R12 input ports 2 to R8 output ports 4 |
conect_r2r(1,12,2,1,0,4); |
//Connect R12 port 3 to ground |
connect_r2gnd(1,12,3); |
//Connect R12 port 4 to ground |
connect_r2gnd(1,12,4); |
//Connect R13 input ports 0 to T13 output ports 0 |
connect_r2e(1,13,0,13); |
//Connect R13 input ports 1 to R14 output ports 3 |
conect_r2r(1,13,1,1,14,3); |
//Connect R13 input ports 2 to R9 output ports 4 |
conect_r2r(1,13,2,1,1,4); |
//Connect R13 input ports 3 to R12 output ports 1 |
conect_r2r(1,13,3,1,12,1); |
//Connect R13 port 4 to ground |
connect_r2gnd(1,13,4); |
//Connect R14 input ports 0 to T14 output ports 0 |
connect_r2e(1,14,0,14); |
//Connect R14 input ports 1 to R15 output ports 3 |
conect_r2r(1,14,1,1,15,3); |
//Connect R14 input ports 2 to R10 output ports 4 |
conect_r2r(1,14,2,1,2,4); |
//Connect R14 input ports 3 to R13 output ports 1 |
conect_r2r(1,14,3,1,13,1); |
//Connect R14 port 4 to ground |
connect_r2gnd(1,14,4); |
//Connect R15 input ports 0 to T15 output ports 0 |
connect_r2e(1,15,0,15); |
//Connect R15 port 1 to ground |
connect_r2gnd(1,15,1); |
//Connect R15 input ports 2 to R11 output ports 4 |
conect_r2r(1,15,2,1,3,4); |
//Connect R15 input ports 3 to R14 output ports 1 |
conect_r2r(1,15,3,1,14,1); |
//Connect R15 port 4 to ground |
connect_r2gnd(1,15,4); |
|
} |
|
void topology_init(void){ |
router1[0]->current_r_addr=0; |
router1[1]->current_r_addr=1; |
router1[2]->current_r_addr=2; |
router1[3]->current_r_addr=3; |
router1[4]->current_r_addr=4; |
router1[5]->current_r_addr=5; |
router1[6]->current_r_addr=6; |
router1[7]->current_r_addr=7; |
router1[8]->current_r_addr=8; |
router1[9]->current_r_addr=9; |
router1[10]->current_r_addr=10; |
router1[11]->current_r_addr=11; |
router1[12]->current_r_addr=12; |
router1[13]->current_r_addr=13; |
router1[14]->current_r_addr=14; |
router1[15]->current_r_addr=15; |
|
} |
/topology/fattree.h
24,9 → 24,16
|
|
|
inline void fatree_local_addr (unsigned int t1, unsigned int r1, unsigned int addr){ |
if (t1==1 ) router1[r1]->current_r_addr = addr; |
else router2[r1]->current_r_addr = addr; |
inline void fatree_local_addr (unsigned int t1, unsigned int r1, unsigned int addr, unsigned int id){ |
if (t1==1 ){ |
router1[r1]->current_r_addr = addr; |
router1[r1]->current_r_id = id; |
} |
else{ |
router2[r1]->current_r_addr = addr; |
router2[r1]->current_r_id = id; |
} |
|
} |
|
|
126,7 → 133,7
|
|
//fattree_connect(Ti(ID1),Ri(ID1),port,Ti(ID2),Ri(ID2),PORT2); |
r2r_cnt_all[num] =(r2r_cnt_table_t){.t1=Ti(ID1), .r1=Ri(ID1), .p1=port, .t2=Ti(ID2), .r2=Ri(ID2), .p2=PORT2 }; |
r2r_cnt_all[num] =(r2r_cnt_table_t){.id1=ID1, .t1=Ti(ID1), .r1=Ri(ID1), .p1=port, .id2=ID2, .t2=Ti(ID2), .r2=Ri(ID2), .p2=PORT2 }; |
unsigned int current_layer_addr = LEAVE_L; |
unsigned int current_pos_addr = ADRRENCODED; |
unsigned int addr = (current_layer_addr << LKw)| current_pos_addr; |
133,20 → 140,23
|
//printf( "[%u] = t1=%u, r1=%u, p1=%u, t2=%u, r2=%u, p2=%u \n", num, r2r_cnt_all[num].t1, r2r_cnt_all[num].r1, r2r_cnt_all[num].p1, r2r_cnt_all[num].t2, r2r_cnt_all[num].r2, r2r_cnt_all[num].p2 ); |
//assign current_r_addr [ID1] = {current_layer_addr [ID1],current_pos_addr[ID1]}; |
fatree_local_addr(Ti(ID1),Ri(ID1), addr); |
|
fatree_local_addr(Ti(ID1),Ri(ID1), addr, ID1); |
|
|
if(level==L-2){// |
current_layer_addr =0; |
current_pos_addr = POS_ADR_CODE2; |
addr = (current_layer_addr << LKw)| current_pos_addr; |
//assign current_r_addr [ID2] = {current_layer_addr [ID2],current_pos_addr[ID2]}; |
fatree_local_addr(Ti(ID2),Ri(ID2), addr); |
fatree_local_addr(Ti(ID2),Ri(ID2), addr, ID2); |
}//if |
num++; |
} |
} |
} |
|
R2R_TABLE_SIZ=num; |
|
for ( pos = 0; pos < NE; pos=pos+1 ) {// : }points |
unsigned int RID= NRL*(L-1)+(pos/K); |
unsigned int RPORT = pos%K; |
170,11 → 180,17
|
|
|
void topology_connect_r2r (int n){ |
fattree_connect(r2r_cnt_all[n]); |
} |
|
void topology_connect_r2e (int n){ |
connect_r2e(2,r2e_cnt_all[n].r1,r2e_cnt_all[n].p1,n); |
} |
|
|
|
|
/* |
void topology_connect_all_nodes (void){ |
|
unsigned int pos,level,port; |
201,9 → 217,9
} |
|
} |
*/ |
|
|
|
unsigned int get_mah_distance ( unsigned int id1, unsigned int id2){ |
|
unsigned int k =T1; |
/topology/mesh.h
135,10 → 135,24
} |
|
|
void topology_connect_r2r (int n){ |
conect_r2r(1,r2r_cnt_all[n].r1,r2r_cnt_all[n].p1,1,r2r_cnt_all[n].r2,r2r_cnt_all[n].p2); |
} |
|
void topology_connect_r2e (int n){ |
connect_r2e(1,r2e_cnt_all[n].r1,r2e_cnt_all[n].p1,n); |
} |
|
void topology_connect_all_nodes (void){ |
|
|
|
|
|
|
|
|
void topology_connect_all_nodes_old (void){ |
|
|
unsigned int x,y,l; |
#if defined (IS_LINE) || defined (IS_RING ) |
145,7 → 159,8
#define R2R_CHANELS_MESH_TORI 2 |
for (x=0; x<T1; x=x+1) { |
|
router1[x]->current_r_addr = x; |
router1[x]->current_r_addr = x; |
router1[x]->current_r_id = x; |
if(x < T1-1){// not_last_node |
//assign router_chan_in[x][FORWARD] = router_chan_out [(x+1)][BACKWARD]; |
conect_r2r(1,x,FORWARD,1,(x+1),BACKWARD); |
195,7 → 210,7
unsigned int ROUTER_NUM = (y * T1) + x; |
//assign current_r_addr [ROUTER_NUM] = R_ADDR[RAw-1 :0]; |
router1[ROUTER_NUM]->current_r_addr = R_ADDR; |
|
router1[ROUTER_NUM]->current_r_id = ROUTER_NUM; |
|
if(x < T1-1) {//: not_last_x |
//assign router_chan_in[`router_id(x,y)][EAST]= router_chan_out [`router_id(x+1,y)][WEST]; |
295,6 → 310,7
|
} |
|
#define fill_r2r_cnt(T1,R1,P1,T2,R2,P2) (r2r_cnt_table_t){.id1=R1,.t1=T1,.r1=R1,.p1=P1,.id2=R2,.t2=T2,.r2=R2,.p2=P2} |
|
void topology_init(void){ |
nxw=Log2(T1); |
301,6 → 317,196
nyw=Log2(T2); |
maskx = (0x1<<nxw)-1; |
masky = (0x1<<nyw)-1; |
unsigned int num=0; |
unsigned int x,y,l; |
#if defined (IS_LINE) || defined (IS_RING ) |
#define R2R_CHANELS_MESH_TORI 2 |
for (x=0; x<T1; x=x+1) { |
|
router1[x]->current_r_addr = x; |
router1[x]->current_r_id = x; |
if(x < T1-1){// not_last_node |
//assign router_chan_in[x][FORWARD] = router_chan_out [(x+1)][BACKWARD]; |
//conect_r2r(1,x,FORWARD,1,(x+1),BACKWARD); |
r2r_cnt_all[num]=fill_r2r_cnt(1,x,FORWARD,1,(x+1),BACKWARD); |
num++; |
} else { //last_node |
#if defined (IS_LINE) // : line_last_x |
//assign router_chan_in[x][FORWARD]= {SMARTFLIT_CHANEL_w{1'b0}}; |
connect_r2gnd(1,x,FORWARD); |
#else // : ring_last_x |
//assign router_chan_in[x][FORWARD]= router_chan_out [0][BACKWARD]; |
//conect_r2r(1,x,FORWARD,1,0,BACKWARD); |
r2r_cnt_all[num]=fill_r2r_cnt(1,x,FORWARD,1,0,BACKWARD); |
num++; |
#endif |
} |
|
if(x>0){// :not_first_x |
//assign router_chan_in[x][BACKWARD]= router_chan_out [(x-1)][FORWARD]; |
//conect_r2r(1,x,BACKWARD,1,(x-1),FORWARD); |
r2r_cnt_all[num]=fill_r2r_cnt(1,x,BACKWARD,1,(x-1),FORWARD); |
num++; |
}else {// :first_x |
#if defined (IS_LINE) // : line_first_x |
//assign router_chan_in[x][BACKWARD]={SMARTFLIT_CHANEL_w{1'b0}}; |
connect_r2gnd(1,x,BACKWARD); |
#else // : ring_first_x |
//assign router_chan_in[x][BACKWARD]= router_chan_out [(NX-1)][FORWARD]; |
//conect_r2r(1,x,BACKWARD,1,(T1-1),FORWARD); |
r2r_cnt_all[num]=fill_r2r_cnt(1,x,BACKWARD,1,(T1-1),FORWARD); |
num++; |
#endif |
} |
|
// connect other local ports |
for (l=0; l<T3; l=l+1) {// :locals |
unsigned int ENDPID = endp_id(x,0,l); |
unsigned int LOCALP = (l==0) ? l : l + R2R_CHANELS_MESH_TORI; // first local port is connected to router port 0. The rest are connected at the } |
//assign router_chan_in[x][LOCALP]= chan_in_all [ENDPID]; |
//assign chan_out_all [ENDPID] = router_chan_out[x][LOCALP]; |
//connect_r2e(1,x,LOCALP,ENDPID); |
r2e_cnt_all[ENDPID].r1=x; |
r2e_cnt_all[ENDPID].p1=LOCALP; |
er_addr [ENDPID] = x; |
|
}// locals |
}//x |
|
#else // :mesh_torus |
#define R2R_CHANELS_MESH_TORI 4 |
for (y=0; y<T2; y=y+1) {//: y_loop |
for (x=0; x<T1; x=x+1) {// :x_loop |
unsigned int R_ADDR = (y<<nxw) + x; |
unsigned int ROUTER_NUM = (y * T1) + x; |
//assign current_r_addr [ROUTER_NUM] = R_ADDR[RAw-1 :0]; |
router1[ROUTER_NUM]->current_r_addr = R_ADDR; |
router1[ROUTER_NUM]->current_r_id = ROUTER_NUM; |
|
if(x < T1-1) {//: not_last_x |
//assign router_chan_in[`router_id(x,y)][EAST]= router_chan_out [`router_id(x+1,y)][WEST]; |
//conect_r2r(1,router_id(x,y),EAST,1,router_id(x+1,y),WEST); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),EAST,1,router_id(x+1,y),WEST); |
num++; |
|
}else {// :last_x |
#if defined (IS_MESH) // :last_x_mesh |
// assign router_chan_in[`router_id(x,y)][EAST] = {SMARTFLIT_CHANEL_w{1'b0}}; |
connect_r2gnd(1,router_id(x,y),EAST); |
#elif defined (IS_TORUS) // : last_x_torus |
//assign router_chan_in[`router_id(x,y)][EAST] = router_chan_out [`router_id(0,y)][WEST]; |
//conect_r2r(1,router_id(x,y),EAST,1,router_id(0,y),WEST); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),EAST,1,router_id(0,y),WEST); |
num++; |
#elif defined (IS_FMESH) //:last_x_fmesh |
//connect to endp |
unsigned int EAST_ID = T1*T2*T3 + 2*T1 + T2 + y; |
//connect_r2e(1,router_id(x,y),EAST,EAST_ID); |
r2e_cnt_all[EAST_ID].r1=router_id(x,y); |
r2e_cnt_all[EAST_ID].p1=EAST; |
er_addr [EAST_ID] = R_ADDR; |
#endif//topology |
} |
|
|
if(y>0) {// : not_first_y |
//assign router_chan_in[`router_id(x,y)][NORTH] = router_chan_out [`router_id(x,(y-1))][SOUTH]; |
//conect_r2r(1,router_id(x,y),NORTH,1,router_id(x,(y-1)),SOUTH); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),NORTH,1,router_id(x,(y-1)),SOUTH); |
num++; |
}else {// :first_y |
#if defined (IS_MESH) // : first_y_mesh |
//assign router_chan_in[`router_id(x,y)][NORTH] = {SMARTFLIT_CHANEL_w{1'b0}}; |
connect_r2gnd(1,router_id(x,y),NORTH); |
#elif defined (IS_TORUS)// :first_y_torus |
//assign router_chan_in[`router_id(x,y)][NORTH] = router_chan_out [`router_id(x,(T2-1))][SOUTH]; |
//conect_r2r(1,router_id(x,y),NORTH,1,router_id(x,(T2-1)),SOUTH); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),NORTH,1,router_id(x,(T2-1)),SOUTH); |
num++; |
#elif defined (IS_FMESH) // :first_y_fmesh |
unsigned int NORTH_ID = T1*T2*T3 + x; |
//connect_r2e(1,router_id(x,y),NORTH,NORTH_ID); |
r2e_cnt_all[NORTH_ID].r1=router_id(x,y); |
r2e_cnt_all[NORTH_ID].p1=NORTH; |
er_addr [NORTH_ID] = R_ADDR; |
#endif//topology |
}//y>0 |
|
|
if(x>0){// :not_first_x |
//assign router_chan_in[`router_id(x,y)][WEST] = router_chan_out [`router_id((x-1),y)][EAST]; |
//conect_r2r(1,router_id(x,y),WEST,1,router_id((x-1),y),EAST); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),WEST,1,router_id((x-1),y),EAST); |
num++; |
|
}else {// :first_x |
|
#if defined (IS_MESH) // :first_x_mesh |
//assign router_chan_in[`router_id(x,y)][WEST] = {SMARTFLIT_CHANEL_w{1'b0}}; |
connect_r2gnd(1,router_id(x,y),WEST); |
|
#elif defined (IS_TORUS) // :first_x_torus |
//assign router_chan_in[`router_id(x,y)][WEST] = router_chan_out [`router_id((NX-1),y)][EAST] ; |
//conect_r2r(1,router_id(x,y),WEST,1,router_id((T1-1),y),EAST); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),WEST,1,router_id((T1-1),y),EAST); |
num++; |
#elif defined (IS_FMESH) // :first_x_fmesh |
unsigned int WEST_ID = T1*T2*T3 + 2*T1 + y; |
//connect_r2e(1,router_id(x,y),WEST,WEST_ID); |
r2e_cnt_all[WEST_ID].r1=router_id(x,y); |
r2e_cnt_all[WEST_ID].p1=WEST; |
er_addr [WEST_ID] = R_ADDR; |
#endif//topology |
} |
|
if(y < T2-1) {// : firsty |
//assign router_chan_in[`router_id(x,y)][SOUTH] = router_chan_out [`router_id(x,(y+1))][NORTH]; |
// conect_r2r(1,router_id(x,y),SOUTH,1,router_id(x,(y+1)),NORTH); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),SOUTH,1,router_id(x,(y+1)),NORTH); |
num++; |
}else {// : lasty |
|
#if defined (IS_MESH) // :ly_mesh |
|
//assign router_chan_in[`router_id(x,y)][SOUTH]= {SMARTFLIT_CHANEL_w{1'b0}}; |
connect_r2gnd(1,router_id(x,y),SOUTH); |
|
#elif defined (IS_TORUS) // :ly_torus |
//assign router_chan_in[`router_id(x,y)][SOUTH]= router_chan_out [`router_id(x,0)][NORTH]; |
// conect_r2r(1,router_id(x,y),SOUTH,1,router_id(x,0),NORTH); |
r2r_cnt_all[num]=fill_r2r_cnt(1,router_id(x,y),SOUTH,1,router_id(x,0),NORTH); |
num++; |
#elif defined (IS_FMESH) // :ly_Fmesh |
unsigned int SOUTH_ID = T1*T2*T3 + T1 + x; |
//connect_r2e(1,router_id(x,y),SOUTH,SOUTH_ID); |
r2e_cnt_all[SOUTH_ID].r1=router_id(x,y); |
r2e_cnt_all[SOUTH_ID].p1=SOUTH; |
er_addr [SOUTH_ID] = R_ADDR; |
#endif//topology |
} |
|
|
// endpoint(s) connection |
// connect other local ports |
for (l=0; l<T3; l=l+1) {// :locals |
unsigned int ENDPID = endp_id(x,y,l); |
unsigned int LOCALP = (l==0) ? l : l + R2R_CHANELS_MESH_TORI; // first local port is connected to router port 0. The rest are connected at the } |
|
//assign router_chan_in [`router_id(x,y)][LOCALP] = chan_in_all [ENDPID]; |
//assign chan_out_all [ENDPID] = router_chan_out [`router_id(x,y)][LOCALP]; |
//assign er_addr [ENDPID] = R_ADDR; |
// connect_r2e(1,router_id(x,y),LOCALP,ENDPID); |
r2e_cnt_all[ENDPID].r1=router_id(x,y); |
r2e_cnt_all[ENDPID].p1=LOCALP; |
er_addr [ENDPID] = R_ADDR; |
}// locals |
|
}//y |
}//x |
#endif |
|
R2R_TABLE_SIZ=num; |
|
} |
|
|
/topology/star.h
3,9 → 3,9
|
|
|
void topology_connect_all_nodes (void){ |
router1[0]->current_r_addr = 0; |
void topology_connect_all_nodes_old (void){ |
|
|
unsigned int pos; |
for ( pos = 0; pos < NE; pos=pos+1 ) {// : endpoints |
|
17,18 → 17,33
}//pos |
} |
|
void topology_connect_r2r (unsigned int n){ |
|
} |
|
void topology_connect_r2e (unsigned int n){ |
connect_r2e(1,0,n,n); |
} |
|
|
|
|
unsigned int endp_addr_encoder ( unsigned int id){ |
return id; |
} |
|
unsigned int endp_addr_decoder (unsigned int code){ |
return id; |
return code; |
} |
|
void topology_init (void){ |
router1[0]->current_r_addr = 0; |
router1[0]->current_r_id = 0; |
for ( int pos = 0; pos < NE; pos=pos+1 ) {// : endpoints |
er_addr [pos] = 0; |
|
} |
|
} |
|
#endif |
/topology/topology_top.h
1,6 → 1,32
#ifndef TOPOLOGY_TOP_H |
#define TOPOLOGY_TOP_H |
|
unsigned int R2R_TABLE_SIZ =0; |
|
#define CNT_R2R_SIZ (NR * MAX_P) //((NR1+NR2+1)*(K+1)) |
#define CNT_R2E_SIZ (NE+1) |
|
typedef struct R2R_CNT_TABLE { |
unsigned int id1; |
unsigned int t1; |
unsigned int r1; |
unsigned int p1; |
unsigned int id2; |
unsigned int t2; |
unsigned int r2; |
unsigned int p2; |
} r2r_cnt_table_t; |
|
r2r_cnt_table_t r2r_cnt_all[CNT_R2R_SIZ]; |
|
typedef struct R2E_CNT_TABLE { |
unsigned int r1; |
unsigned int p1; |
} r2e_cnt_table_t; |
|
r2e_cnt_table_t r2e_cnt_all[CNT_R2E_SIZ]; |
|
|
int get_router_num (int NR_num, int NR_id){ |
int offset=0; |
if(NR_num* sizeof(int) > sizeof(router_NRs)){ |
53,27 → 79,10
|
#define K T1 |
#define L T2 |
#define CNT_R2R_SIZ ((NR1+NR2+1)*(K+1)) |
#define CNT_R2E_SIZ (NE+1) |
|
typedef struct R2R_CNT_TABLE { |
unsigned int t1; |
unsigned int r1; |
unsigned int p1; |
unsigned int t2; |
unsigned int r2; |
unsigned int p2; |
} r2r_cnt_table_t; |
|
r2r_cnt_table_t r2r_cnt_all[CNT_R2R_SIZ]; |
|
typedef struct R2E_CNT_TABLE { |
unsigned int r1; |
unsigned int p1; |
} r2e_cnt_table_t; |
|
r2e_cnt_table_t r2e_cnt_all[CNT_R2E_SIZ]; |
|
inline void fattree_connect ( r2r_cnt_table_t in){ |
unsigned int t1 = in.t1; |
unsigned int r1 = in.r1; |
105,6 → 114,10
|
|
#if defined (IS_MESH) || defined (IS_FMESH) || defined (IS_TORUS) || defined (IS_LINE) || defined (IS_RING ) |
|
|
|
|
#include "mesh.h" |
#elif defined (IS_FATTREE) |
#include "fattree.h" |
121,6 → 134,7
unsigned int endp_addr_decoder (unsigned int code){ |
return code; |
} |
#include "custom.h" |
|
#endif |
|
/topology/tree.h
83,7 → 83,9
//assign current_pos_addr [ROOT_ID] = {LKw{1'b0}}; |
unsigned int addr = ROOT_L << LKw; |
router1[ROOT_ID]->current_r_addr = addr; |
router1[ROOT_ID]->current_r_id = ROOT_ID; |
|
|
unsigned int pos,level; |
unsigned int num = 0; |
//connect all up connections |
109,7 → 111,7
//assign router_chan_out [ID1][K] = router_chan_in [ID2][PORT2]; |
//assign router_chan_out [ID2][PORT2]= router_chan_in[ID1][K]; |
//bintree_connect(Ti(ID1),Ri(ID1),port,Ti(ID2),Ri(ID2),PORT2); |
r2r_cnt_all[num] =(r2r_cnt_table_t){.t1=Ti(ID1), .r1=Ri(ID1), .p1=K, .t2=Ti(ID2), .r2=Ri(ID2), .p2=PORT2 }; |
r2r_cnt_all[num] =(r2r_cnt_table_t){.id1=ID1, .t1=Ti(ID1), .r1=Ri(ID1), .p1=K,.id2=ID2, .t2=Ti(ID2), .r2=Ri(ID2), .p2=PORT2 }; |
|
|
|
120,6 → 122,8
unsigned int addr = (current_layer_addr << LKw)| current_pos_addr; |
|
router2[Ri(ID1)]->current_r_addr = addr; |
router2[Ri(ID1)]->current_r_id = ID1; |
|
//printf( "[%u] =(addr=%x), t1=%u, r1=%u, p1=%u, t2=%u, r2=%u, p2=%u \n", num,addr, r2r_cnt_all[num].t1, r2r_cnt_all[num].r1, r2r_cnt_all[num].p1, r2r_cnt_all[num].t2, r2r_cnt_all[num].r2, r2r_cnt_all[num].p2 ); |
|
|
133,6 → 137,7
|
} //level |
|
R2R_TABLE_SIZ=num; |
|
// connect }points |
|
154,6 → 159,15
} |
|
|
void topology_connect_r2r (int n){ |
fattree_connect(r2r_cnt_all[n]); |
} |
|
void topology_connect_r2e (int n){ |
connect_r2e(2,r2e_cnt_all[n].r1,r2e_cnt_all[n].p1,n); |
} |
|
/* |
void topology_connect_all_nodes (void){ |
unsigned int pos,level; |
unsigned int num=0; |
180,8 → 194,8
} |
} |
|
*/ |
|
|
unsigned int get_mah_distance ( unsigned int id1, unsigned int id2){ |
|
unsigned int k =T1; |
/traffic_synthetic.h
22,7 → 22,7
|
hotspot_st * hotspots; |
|
unsigned int pck_dst_gen_1D (unsigned int); |
unsigned int pck_dst_gen_1D (unsigned int, unsigned char *); |
|
// number, b:bit location W: number width log2(num) |
int getBit(int num, int b, int W) |
55,12 → 55,12
|
#if (defined (IS_MESH) || defined (IS_TORUS) || defined (IS_LINE) || defined (IS_RING) ) |
|
unsigned int pck_dst_gen_2D (unsigned int core_num){ |
unsigned int pck_dst_gen_2D (unsigned int core_num, unsigned char * inject_en){ |
//for mesh-tori |
unsigned int current_l,current_x, current_y; |
unsigned int dest_l,dest_x,dest_y; |
mesh_tori_addrencod_sep(core_num,¤t_x,¤t_y,¤t_l); |
|
* inject_en=1; |
unsigned int rnd=0; |
unsigned int rnd100=0; |
unsigned int max_percent=100/HOTSPOT_NUM; |
80,6 → 80,7
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){ |
//rnd = core_num; // turn off the core |
//return endp_addr_encoder(rnd); |
*inject_en=0; |
return INJECT_OFF; |
} |
} |
150,12 → 151,16
} |
|
if(( strcmp(TRAFFIC ,"CUSTOM") == 0)|| (strcmp (TRAFFIC,"custom")==0)){ |
if (custom_traffic_table[core_num]== INJECT_OFF) return INJECT_OFF; |
if (custom_traffic_table[core_num]== INJECT_OFF){ |
*inject_en=0; |
return INJECT_OFF; |
} |
return endp_addr_encoder(custom_traffic_table[core_num]); |
|
} |
|
fprintf (stderr,"ERROR: traffic %s is an unsupported traffic pattern\n",TRAFFIC); |
*inject_en=0; |
return INJECT_OFF; |
|
} |
162,14 → 167,14
|
#else |
|
unsigned int pck_dst_gen_2D (unsigned int core_num){ |
return pck_dst_gen_1D (core_num); |
unsigned int pck_dst_gen_2D (unsigned int core_num, unsigned char * inject_en){ |
return pck_dst_gen_1D (core_num,inject_en ); |
} |
|
#endif |
|
|
unsigned int pck_dst_gen_1D (unsigned int core_num){ |
unsigned int pck_dst_gen_1D (unsigned int core_num, unsigned char *inject_en){ |
|
unsigned int rnd=0; |
unsigned int rnd100=0; |
176,7 → 181,7
unsigned int max_percent=100/HOTSPOT_NUM; |
int i; |
|
|
*inject_en=1; |
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){ |
return endp_addr_encoder(get_rnd_ip(core_num)); |
} |
188,7 → 193,7
rnd1000=rand()%1000; // generate a random number between 0 & 1000 |
for (i=0;i<HOTSPOT_NUM; i++){ |
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){ |
|
*inject_en=0; |
return INJECT_OFF; |
} |
} |
248,12 → 253,16
} |
|
if(( strcmp(TRAFFIC ,"CUSTOM") == 0)|| (strcmp (TRAFFIC,"custom")==0)){ |
if (custom_traffic_table[core_num]== INJECT_OFF) return INJECT_OFF; |
if (custom_traffic_table[core_num]== INJECT_OFF){ |
*inject_en=0; |
return INJECT_OFF; |
} |
return endp_addr_encoder(custom_traffic_table[core_num]); |
|
} |
|
fprintf (stderr,"ERROR: traffic %s is an unsupported traffic pattern\n",TRAFFIC); |
*inject_en=0; |
return INJECT_OFF; |
} |
|
267,9 → 276,101
return rnd; |
} |
|
char mcast_list[1024]; |
|
void reverse(char str1[], int index, int size) |
{ |
char temp; |
|
temp = str1[index]; |
str1[index] = str1[size - index]; |
str1[size - index] = temp; |
|
if (index == size / 2) |
{ |
return; |
} |
reverse(str1, index + 1, size); |
} |
|
char * mcast_list_array; |
unsigned int MCAST_PRTLw=0; |
|
void mcast_init(){ |
mcast_list_array = (char *) malloc(NE * sizeof(char)); |
if (IS_MCAST_FULL){ |
for(int i=0; i< NE; i++) { |
mcast_list_array[i]=1; |
MCAST_PRTLw=NE; |
} |
return; |
} |
//partial |
|
int hex=0; |
int bin=0; |
char * temp_str; |
temp_str = (char *) malloc(strlen(MCAST_ENDP_LIST) * sizeof(char)); |
sscanf(MCAST_ENDP_LIST,"%s",temp_str ); |
|
char * t = strstr(temp_str, "\'h"); |
if(t) hex=1; |
else t = strstr(temp_str, "\'b"); |
if(t) bin=1; |
if(hex==0 && bin == 0){ |
fprintf (stderr,"ERROR: MCAST_ENDP_LIST (%s) is given in wrong format. Only hex ('h) and bin ('b) format is accepted. \n",MCAST_ENDP_LIST); |
exit(1); |
} |
|
t+=2; |
int size = strlen(t); |
reverse(t, 0, size - 1); |
|
int i=0; |
char u [2]; |
u [1] =0; |
|
if(hex){ |
for(i=0; i< size; i++) { |
unsigned int ch ; |
u[0] = t[i]; |
sscanf(u , "%x", &ch); |
ch&=0xf; |
mcast_list_array[i*4 ] = (ch & 0x1); |
mcast_list_array[i*4+1] = (ch & 0x2)>>1; |
mcast_list_array[i*4+2] = (ch & 0x4)>>2; |
mcast_list_array[i*4+3] = (ch & 0x8)>>3; |
} |
}else if(bin){ |
for(i=0; i< size; i++) { |
unsigned int ch ; |
u[0] = t[i]; |
sscanf(u , "%x", &ch); |
ch&=0xf; |
mcast_list_array[i ] = ch; |
} |
|
} |
|
for (i=0;i<NE;i++){ |
if(mcast_list_array[i] ==1) MCAST_PRTLw++; |
// printf("mcast_list_array[%u]=%u\n",i,mcast_list_array[i]); |
} |
// printf("mcastw=%u\n",MCAST_PRTLw); |
|
} |
|
|
unsigned int endp_id_to_mcast_id (unsigned int endp_id){ |
|
int i=0; |
if (IS_MCAST_FULL) return endp_id; |
int id=0; |
for (i=0;i<endp_id;i++) { |
if( mcast_list_array[i]==1) id++; |
} |
return id; |
} |
|
|
#endif |