Line 4... |
Line 4... |
#include <string.h>
|
#include <string.h>
|
#include <limits.h>
|
#include <limits.h>
|
#include <ctype.h>
|
#include <ctype.h>
|
#include <stdint.h>
|
#include <stdint.h>
|
#include <inttypes.h>
|
#include <inttypes.h>
|
|
|
|
|
#include <verilated.h> // Defines common routines
|
#include <verilated.h> // Defines common routines
|
#include "Vrouter.h" // From Verilating "router.v"
|
//#include "Vrouter1.h" included in parameter.h
|
#include "Vnoc.h"
|
#include "Vnoc.h"
|
#include "Vtraffic.h"
|
#include "Vtraffic.h"
|
#include "parameter.h"
|
#include "parameter.h"
|
|
#include "traffic_task_graph.h"
|
|
#include "traffic_synthetic.h"
|
|
|
|
|
|
|
#ifndef NC
|
|
#define NC (NX*NY)
|
|
#endif
|
|
|
|
#define RATIO_INIT 2
|
#define RATIO_INIT 2
|
|
|
#define SYNTHETIC 0
|
|
#define CUSTOM 1
|
|
#define DISABLE -1
|
#define DISABLE -1
|
|
|
#define MY_VL_SETBIT_W(data,bit) (data[VL_BITWORD_I(bit)] |= (VL_UL(1) << VL_BITBIT_I(bit)))
|
#define MY_VL_SETBIT_W(data,bit) (data[VL_BITWORD_I(bit)] |= (VL_UL(1) << VL_BITBIT_I(bit)))
|
|
|
#include "traffic_task_graph.h"
|
|
|
|
#define STND_DEV_EN 1
|
#define STND_DEV_EN 1
|
|
#define SYNTHETIC 0
|
|
#define CUSTOM 1
|
|
|
|
|
//Vrouter *router;
|
//Vrouter *router;
|
Vrouter *router[NC]; // Instantiation of module
|
//Vrouter1 *router1[NR]; // Included in parameter.h file
|
Vnoc *noc;
|
Vnoc *noc;
|
Vtraffic *traffic[NC];
|
Vtraffic *traffic[NE];
|
|
int reset,clk;
|
|
int TRAFFIC_TYPE=SYNTHETIC;
|
|
int PACKET_SIZE=5;
|
|
int MIN_PACKET_SIZE=5;
|
|
int MAX_PACKET_SIZE=5;
|
|
int MAX_PCK_NUM;
|
|
int MAX_SIM_CLKs;
|
|
int HOTSPOT_NUM;
|
|
int C0_p=100, C1_p=0, C2_p=0, C3_p=0;
|
char * TRAFFIC;
|
char * TRAFFIC;
|
unsigned char FIXED_SRC_DST_PAIR;
|
unsigned char FIXED_SRC_DST_PAIR;
|
unsigned char Xw=0,Yw=0;
|
unsigned char NEw=0;
|
unsigned long int main_time = 0; // Current simulation time
|
unsigned long int main_time = 0; // Current simulation time
|
unsigned int saved_time = 0;
|
unsigned int saved_time = 0;
|
unsigned int total_pck_num=0;
|
unsigned int total_pck_num=0;
|
unsigned int sum_clk_h2h,sum_clk_h2t;
|
unsigned int sum_clk_h2h,sum_clk_h2t;
|
double sum_clk_per_hop;
|
double sum_clk_per_hop;
|
const int CC=(C==0)? 1 : C;
|
const int CC=(C==0)? 1 : C;
|
|
|
unsigned int total_pck_num_per_class[CC]={0};
|
unsigned int total_pck_num_per_class[CC]={0};
|
unsigned int sum_clk_h2h_per_class[CC]={0};
|
unsigned int sum_clk_h2h_per_class[CC]={0};
|
unsigned int sum_clk_h2t_per_class[CC]={0};
|
unsigned int sum_clk_h2t_per_class[CC]={0};
|
double sum_clk_per_hop_per_class[CC]={0};
|
double sum_clk_per_hop_per_class[CC]={0};
|
|
unsigned int rsvd_core_total_pck_num[NE]= {0};
|
unsigned int rsvd_core_total_pck_num[NC]= {0};
|
unsigned int rsvd_core_worst_delay[NE] = {0};
|
unsigned int rsvd_core_worst_delay[NC] = {0};
|
unsigned int sent_core_total_pck_num[NE]= {0};
|
unsigned int sent_core_total_pck_num[NC]= {0};
|
unsigned int sent_core_worst_delay[NE] = {0};
|
unsigned int sent_core_worst_delay[NC] = {0};
|
unsigned int random_var[NE] = {100};
|
unsigned int random_var[NC] = {100};
|
|
|
|
unsigned int clk_counter;
|
unsigned int clk_counter;
|
unsigned int count_en;
|
unsigned int count_en;
|
unsigned int total_router;
|
unsigned int total_router;
|
|
|
int reset,clk;
|
|
|
|
char all_done=0;
|
char all_done=0;
|
|
|
unsigned int flit_counter =0;
|
unsigned int flit_counter =0;
|
|
|
int ratio=RATIO_INIT;
|
int ratio=RATIO_INIT;
|
double first_avg_latency_flit,current_avg_latency_flit;
|
double first_avg_latency_flit,current_avg_latency_flit;
|
|
|
double sc_time_stamp ();
|
double sc_time_stamp ();
|
int pow2( int );
|
int pow2( int );
|
|
|
|
|
|
|
|
|
|
|
#if (STND_DEV_EN)
|
#if (STND_DEV_EN)
|
//#include <math.h>
|
//#include <math.h>
|
double sqroot (double s){
|
double sqroot (double s){
|
int i;
|
int i;
|
double root = s/3;
|
double root = s/3;
|
Line 93... |
Line 77... |
double sum_clk_pow2=0;
|
double sum_clk_pow2=0;
|
double sum_clk_pow2_per_class[C];
|
double sum_clk_pow2_per_class[C];
|
double standard_dev( double , unsigned int, double);
|
double standard_dev( double , unsigned int, double);
|
#endif
|
#endif
|
|
|
void update_noc_statistic (
|
void update_noc_statistic ( int);
|
int
|
unsigned char pck_class_in_gen(unsigned int);
|
);
|
unsigned int pck_dst_gen_task_graph ( unsigned int);
|
|
|
|
|
void pck_dst_gen (
|
|
unsigned int,
|
|
unsigned int,
|
|
unsigned int,
|
|
unsigned int*,
|
|
unsigned int*
|
|
);
|
|
|
|
unsigned char pck_class_in_gen(
|
|
unsigned int
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void print_statistic (char *);
|
void print_statistic (char *);
|
void print_parameter();
|
void print_parameter();
|
void reset_all_register();
|
void reset_all_register();
|
unsigned int rnd_between (unsigned int, unsigned int );
|
unsigned int rnd_between (unsigned int, unsigned int );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int TRAFFIC_TYPE=SYNTHETIC;
|
|
int PACKET_SIZE=5;
|
|
int MIN_PACKET_SIZE=5;
|
|
int MAX_PACKET_SIZE=5;
|
|
int MAX_PCK_NUM;
|
|
int MAX_SIM_CLKs;
|
|
|
|
int C0_p=100, C1_p=0, C2_p=0, C3_p=0;
|
|
|
|
|
|
int HOTSPOT_NUM;
|
|
typedef struct HOTSPOT_NODE {
|
|
int ip_num;
|
|
char send_enable;
|
|
int percentage; // x10
|
|
} hotspot_st;
|
|
|
|
hotspot_st * hotspots;
|
|
|
|
|
|
|
|
|
|
|
|
void usage(){
|
void usage(){
|
printf(" ./simulator -f [Traffic Pattern file]\n\nor\n");
|
printf(" ./simulator -f [Traffic Pattern file]\n\nor\n");
|
|
|
|
|
printf(" ./simulator -t [Traffic Pattern] -s [MIN_PCK_SIZE] -m [MAX_PCK_SIZE] -n [MAX_PCK_NUM] c [MAX SIM CLKs] -i [INJECTION RATIO] -p [class traffic ratios (%%)] -h[HOTSPOT info] \n");
|
printf(" ./simulator -t [Traffic Pattern] -s [MIN_PCK_SIZE] -m [MAX_PCK_SIZE] -n [MAX_PCK_NUM] c [MAX SIM CLKs] -i [INJECTION RATIO] -p [class traffic ratios (%%)] -h[HOTSPOT info] \n");
|
printf(" Traffic Pattern: \"HOTSPOT\" \"RANDOM\" \"TORNADO\" \"BIT_REVERSE\" \"BIT_COMPLEMENT\" \"TRANSPOSE1\" \"TRANSPOSE2\"\n");
|
printf(" Traffic Pattern: \"HOTSPOT\" \"RANDOM\" \"TORNADO\" \"BIT_REVERSE\" \"BIT_COMPLEMENT\" \"TRANSPOSE1\" \"TRANSPOSE2\"\n");
|
printf(" MIN_PCK_SIZE: Minimum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size\n ");
|
printf(" MIN_PCK_SIZE: Minimum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size\n ");
|
printf(" MAX_PCK_SIZE: Maximum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size\n ");
|
printf(" MAX_PCK_SIZE: Maximum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size\n ");
|
|
|
printf(" MAX_PCK_NUM: total number of sent packets. Simulation will stop when total of sent packet by all nodes reach this number\n");
|
printf(" MAX_PCK_NUM: total number of sent packets. Simulation will stop when total of sent packet by all nodes reach this number\n");
|
printf(" MAX_SIM_CLKs: simulation clock limit. Simulation will stop when simulation clock number reach this value \n");
|
printf(" MAX_SIM_CLKs: simulation clock limit. Simulation will stop when simulation clock number reach this value \n");
|
printf(" INJECTION_RATIO: packet injection ratio");
|
printf(" INJECTION_RATIO: packet injection ratio");
|
printf(" class traffic ratios %%: The percentage of traffic injected for each class. represented in string whit each class ratio is separated by comma. \"n0,n1,n2..\" \n");
|
printf(" class traffic ratios %%: The percentage of traffic injected for each class. represented in string whit each class ratio is separated by comma. \"n0,n1,n2..\" \n");
|
printf(" hotspot traffic info: represented in a string with following format: \"HOTSPOT PERCENTAGE,HOTSPOT NUM,HOTSPOT CORE 1,HOTSPOT CORE 2,HOTSPOT CORE 3,HOTSPOT CORE 4,HOTSPOT CORE 5, ENABLE HOTSPOT CORES SEND \" \n");
|
printf(" hotspot traffic info: represented in a string with following format: \"HOTSPOT PERCENTAGE,HOTSPOT NUM,HOTSPOT CORE 1,HOTSPOT CORE 2,HOTSPOT CORE 3,HOTSPOT CORE 4,HOTSPOT CORE 5, ENABLE HOTSPOT CORES SEND \" \n");
|
Line 179... |
Line 115... |
pt = strtok (NULL, ",");
|
pt = strtok (NULL, ",");
|
}
|
}
|
return i;
|
return i;
|
}
|
}
|
|
|
|
|
|
unsigned int pck_dst_gen ( unsigned int core_num) {
|
|
if(TRAFFIC_TYPE==CUSTOM) 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);
|
|
}
|
|
|
|
|
|
|
void update_hotspot(char * str){
|
void update_hotspot(char * str){
|
int i;
|
int i;
|
int array[1000];
|
int array[1000];
|
int p;
|
int p;
|
int acuum=0;
|
int acuum=0;
|
Line 211... |
Line 156... |
}
|
}
|
if(acuum> 1000){
|
if(acuum> 1000){
|
printf("Warning: The hotspot traffic summation %f exceed than 100 percent. \n", (float) acuum /10);
|
printf("Warning: The hotspot traffic summation %f exceed than 100 percent. \n", (float) acuum /10);
|
|
|
}
|
}
|
|
|
hotspots=new_node;
|
hotspots=new_node;
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void processArgs (int argc, char **argv )
|
void processArgs (int argc, char **argv )
|
{
|
{
|
char c;
|
char c;
|
int p;
|
int p;
|
int array[10];
|
int array[10];
|
Line 269... |
Line 209... |
C0_p=array[0];
|
C0_p=array[0];
|
C1_p=array[1];
|
C1_p=array[1];
|
C2_p=array[2];
|
C2_p=array[2];
|
C3_p=array[3];
|
C3_p=array[3];
|
break;
|
break;
|
|
|
case 'h':
|
case 'h':
|
|
|
update_hotspot(optarg);
|
update_hotspot(optarg);
|
|
|
|
|
break;
|
break;
|
|
|
|
|
|
|
case '?':
|
case '?':
|
if (isprint (optopt))
|
if (isprint (optopt))
|
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
else
|
else
|
fprintf (stderr,
|
fprintf (stderr,
|
Line 295... |
Line 228... |
}
|
}
|
PACKET_SIZE=(MIN_PACKET_SIZE+MAX_PACKET_SIZE)/2;// average packet size
|
PACKET_SIZE=(MIN_PACKET_SIZE+MAX_PACKET_SIZE)/2;// average packet size
|
}
|
}
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
char change_injection_ratio=0,inject_done;
|
char change_injection_ratio=0,inject_done;
|
int i,j,x,y;//,report_delay_counter=0;
|
int i,j,x,y;//,report_delay_counter=0;
|
char file_name[100];
|
char file_name[100];
|
char deafult_out[] = {"result"};
|
char deafult_out[] = {"result"};
|
char * out_file_name;
|
char * out_file_name;
|
unsigned int dest_x, dest_y;
|
unsigned int dest_e_addr;
|
int flit_out_all_size = sizeof(router[0]->flit_out_all)/sizeof(router[0]->flit_out_all[0]);
|
|
while((0x1<<Xw) < NX)Xw++; //log2
|
|
while((0x1<<Yw) < NY)Yw++;
|
|
|
|
|
while((0x1<<NEw) < NE)NEw++;
|
|
while((0x1<<nxw) < T1){nxw++;maskx<<=1; maskx|=1;}
|
|
while((0x1<<nyw) < T2){nyw++;masky<<=1; masky|=1;}
|
|
|
Verilated::commandArgs(argc, argv); // Remember args
|
Verilated::commandArgs(argc, argv); // Remember args
|
|
Vrouter_new();
|
for(i=0;i<NC;i++) router[i] = new Vrouter; // Create instance
|
|
noc = new Vnoc;
|
noc = new Vnoc;
|
for(i=0;i<NC;i++) traffic[i] = new Vtraffic;
|
for(i=0;i<NE;i++) traffic[i] = new Vtraffic;
|
|
|
processArgs ( argc, argv );
|
processArgs ( argc, argv );
|
|
|
|
|
FIXED_SRC_DST_PAIR = strcmp (TRAFFIC,"RANDOM") & strcmp(TRAFFIC,"HOTSPOT") & strcmp(TRAFFIC,"random") & strcmp(TRAFFIC,"hot spot") & strcmp(TRAFFIC,"CUSTOM from file");
|
FIXED_SRC_DST_PAIR = strcmp (TRAFFIC,"RANDOM") & strcmp(TRAFFIC,"HOTSPOT") & strcmp(TRAFFIC,"random") & strcmp(TRAFFIC,"hot spot") & strcmp(TRAFFIC,"CUSTOM from file");
|
Line 327... |
Line 261... |
|
|
reset=1;
|
reset=1;
|
reset_all_register();
|
reset_all_register();
|
noc->start_i=0;
|
noc->start_i=0;
|
|
|
|
for (i=0;i<NE;i++){
|
for(x=0;x<NX;x++)for(y=0;y<NY;y++){
|
|
|
|
i=(y*NX)+x;
|
|
random_var[i] = 100;
|
random_var[i] = 100;
|
router[i]->current_x = x;
|
traffic[i]->current_e_addr = endp_addr_encoder(i);
|
router[i]->current_y = y;
|
|
traffic[i]->current_x = x;
|
|
traffic[i]->current_y = y;
|
|
traffic[i]->start=0;
|
traffic[i]->start=0;
|
traffic[i]->pck_class_in= pck_class_in_gen( i);
|
traffic[i]->pck_class_in= pck_class_in_gen( i);
|
pck_dst_gen ( x,y,i, &dest_x, &dest_y);
|
traffic[i]->pck_size_in=rnd_between(MIN_PACKET_SIZE,MAX_PACKET_SIZE);
|
traffic[i]->dest_x= dest_x;
|
dest_e_addr=pck_dst_gen (i);
|
traffic[i]->dest_y=dest_y;
|
traffic[i]->dest_e_addr= dest_e_addr;
|
|
//printf("src=%u, des_eaddr=%x, dest=%x\n", i,dest_e_addr, endp_addr_decoder(dest_e_addr));
|
traffic[i]->stop=0;
|
traffic[i]->stop=0;
|
if(TRAFFIC_TYPE==SYNTHETIC){
|
if(TRAFFIC_TYPE==SYNTHETIC){
|
traffic[i]->pck_size_in=PACKET_SIZE;
|
traffic[i]->pck_size_in=PACKET_SIZE;
|
traffic[i]->avg_pck_size_in=PACKET_SIZE;
|
traffic[i]->avg_pck_size_in=PACKET_SIZE;
|
traffic[i]->ratio=ratio;
|
traffic[i]->ratio=ratio;
|
traffic[i]->init_weight=1;
|
traffic[i]->init_weight=1;
|
}
|
}
|
|
|
|
|
}
|
}
|
//traffic[35]->init_weight=10;
|
|
|
|
|
|
|
|
main_time=0;
|
main_time=0;
|
print_parameter();
|
print_parameter();
|
if(strcmp(TRAFFIC,"CUSTOM from file")) printf("\n\n\n Flit injection ratio per router is =%f \n",(float)ratio*100/MAX_RATIO);
|
if(strcmp(TRAFFIC,"CUSTOM from file")) printf("\n\n\n Flit injection ratio per router is =%f \n",(float)ratio*100/MAX_RATIO);
|
//printf("\n\n\n delay= %u clk",router->delay);
|
//printf("\n\n\n delay= %u clk",router->delay);
|
Line 373... |
Line 297... |
if ((main_time % 4) == 0) {
|
if ((main_time % 4) == 0) {
|
clk = 1; // Toggle clock
|
clk = 1; // Toggle clock
|
if(count_en) clk_counter++;
|
if(count_en) clk_counter++;
|
inject_done= ((total_pck_num >= MAX_PCK_NUM) || (clk_counter>= MAX_SIM_CLKs) || total_active_routers == 0);
|
inject_done= ((total_pck_num >= MAX_PCK_NUM) || (clk_counter>= MAX_SIM_CLKs) || total_active_routers == 0);
|
//if(inject_done) printf("clk_counter=========%d\n",clk_counter);
|
//if(inject_done) printf("clk_counter=========%d\n",clk_counter);
|
for(y=0;y<NY;y++)for(x=0;x<NX;x++)
|
for (i=0;i<NE;i++){
|
{
|
|
i=(y*NX)+x;
|
|
// a packet has been received
|
// a packet has been received
|
if(traffic[i]->update & ~reset){
|
if(traffic[i]->update & ~reset){
|
update_noc_statistic (i) ;
|
update_noc_statistic (i) ;
|
|
|
}
|
}
|
// the header flit has been sent out
|
// the header flit has been sent out
|
if(traffic[i]->hdr_flit_sent ){
|
if(traffic[i]->hdr_flit_sent ){
|
traffic[i]->pck_class_in= pck_class_in_gen( i);
|
traffic[i]->pck_class_in= pck_class_in_gen( i);
|
sent_core_total_pck_num[i]++;
|
sent_core_total_pck_num[i]++;
|
if(!FIXED_SRC_DST_PAIR){
|
if(!FIXED_SRC_DST_PAIR){
|
pck_dst_gen ( x,y,i, &dest_x, &dest_y);
|
traffic[i]->pck_size_in=rnd_between(MIN_PACKET_SIZE,MAX_PACKET_SIZE);
|
traffic[i]->dest_x= dest_x;
|
dest_e_addr=pck_dst_gen (i);
|
traffic[i]->dest_y=dest_y;
|
traffic[i]->dest_e_addr= dest_e_addr;
|
|
//printf("src=%u, dest=%x\n", i,endp_addr_decoder(dest_e_addr));
|
|
|
}
|
}
|
}
|
}
|
|
|
if(traffic[i]->flit_out_wr==1) flit_counter++;
|
if(traffic[i]->flit_out_wr==1) flit_counter++;
|
|
|
}//for
|
}//for
|
if(inject_done) {
|
if(inject_done) {
|
for(x=0;x<NX;x++)for(y=0;y<NY;y++) if(traffic[(y*NX)+x]->pck_number>0) total_router = total_router +1;
|
for (i=0;i<NE;i++) if(traffic[i]->pck_number>0) total_router = total_router +1;
|
|
|
printf(" simulation clock cycles:%d\n",clk_counter);
|
printf(" simulation clock cycles:%d\n",clk_counter);
|
printf(" total received flits:%d\n",flit_counter);
|
printf(" total received flits:%d\n",flit_counter);
|
print_statistic(out_file_name);
|
print_statistic(out_file_name);
|
change_injection_ratio = 1;
|
change_injection_ratio = 1;
|
for(i=0;i<NC;i++) {
|
routers_final();
|
router[i]->final();
|
for(i=0;i<NE;i++) traffic[i]->final();
|
traffic[i]->final();
|
|
}
|
|
noc->final();
|
noc->final();
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
|
|
|
}//if
|
}//if
|
else
|
else
|
{
|
{
|
|
|
clk = 0;
|
clk = 0;
|
#if (NC<=64)
|
#if (NR<=64)
|
noc->ni_flit_in_wr =0;
|
noc->ni_flit_in_wr =0;
|
#else
|
#else
|
for(j=0;j<(sizeof(noc->ni_flit_in_wr)/sizeof(noc->ni_flit_in_wr[0])); j++) noc->ni_flit_in_wr[j]=0;
|
for(j=0;j<(sizeof(noc->ni_flit_in_wr)/sizeof(noc->ni_flit_in_wr[0])); j++) noc->ni_flit_in_wr[j]=0;
|
#endif
|
#endif
|
for(x=0;x<NX;x++)for(y=0;y<NY;y++){
|
|
i=(y*NX)+x;
|
|
|
|
|
|
router[i]->flit_in_we_all = noc->router_flit_out_we_all[i];
|
connect_all_routers_to_noc ();
|
router[i]->credit_in_all = noc->router_credit_out_all[i];
|
|
router[i]->congestion_in_all = noc->router_congestion_out_all[i];
|
|
//router[i]->iport_weight_in_all = noc->router_iport_weight_out_all[i];
|
|
|
|
for(j=0;j<flit_out_all_size;j++)router[i]->flit_in_all[j] = noc->router_flit_out_all[i][j];
|
|
|
|
|
for (i=0;i<NE;i++){
|
|
traffic[i]->current_r_addr = noc->er_addr[i];
|
|
|
noc->router_flit_in_we_all[i] = router[i]->flit_out_we_all ;
|
|
noc->router_credit_in_all[i] = router[i]->credit_out_all;
|
|
noc->router_congestion_in_all[i]= router[i]->congestion_out_all;
|
|
//noc->router_iport_weight_in_all[i]= router[i]->iport_weight_out_all;
|
|
|
|
for(j=0;j<flit_out_all_size;j++) noc->router_flit_in_all[i][j] = router[i]->flit_out_all[j] ;
|
|
#if (Fpay<=32)
|
#if (Fpay<=32)
|
traffic[i]->flit_in = noc->ni_flit_out [i];
|
traffic[i]->flit_in = noc->ni_flit_out [i];
|
#else
|
#else
|
for(j=0;j<(sizeof(traffic[i]->flit_out)/sizeof(traffic[i]->flit_out[0])); j++) traffic[i]->flit_in[j] = noc->ni_flit_out [i][j];
|
for(j=0;j<(sizeof(traffic[i]->flit_out)/sizeof(traffic[i]->flit_out[0])); j++) traffic[i]->flit_in[j] = noc->ni_flit_out [i][j];
|
#endif
|
#endif
|
Line 455... |
Line 365... |
noc->ni_flit_in [i] = traffic[i]->flit_out;
|
noc->ni_flit_in [i] = traffic[i]->flit_out;
|
#else
|
#else
|
for(j=0;j<(sizeof(traffic[i]->flit_out)/sizeof(traffic[i]->flit_out[0])); j++) noc->ni_flit_in [i][j] = traffic[i]->flit_out[j];
|
for(j=0;j<(sizeof(traffic[i]->flit_out)/sizeof(traffic[i]->flit_out[0])); j++) noc->ni_flit_in [i][j] = traffic[i]->flit_out[j];
|
#endif
|
#endif
|
|
|
#if (NC<=64)
|
#if (NE<=64)
|
if(traffic[i]->flit_out_wr) noc->ni_flit_in_wr = noc->ni_flit_in_wr | ((vluint64_t)1<<i);
|
if(traffic[i]->flit_out_wr) noc->ni_flit_in_wr = noc->ni_flit_in_wr | ((vluint64_t)1<<i);
|
traffic[i]->flit_in_wr= ((noc->ni_flit_out_wr >> i) & 0x01);
|
traffic[i]->flit_in_wr= ((noc->ni_flit_out_wr >> i) & 0x01);
|
#else
|
#else
|
if(traffic[i]->flit_out_wr) MY_VL_SETBIT_W(noc->ni_flit_in_wr ,i);
|
if(traffic[i]->flit_out_wr) MY_VL_SETBIT_W(noc->ni_flit_in_wr ,i);
|
traffic[i]->flit_in_wr= (VL_BITISSET_W(noc->ni_flit_out_wr,i)>0);
|
traffic[i]->flit_in_wr= (VL_BITISSET_W(noc->ni_flit_out_wr,i)>0);
|
#endif
|
#endif
|
|
|
|
|
|
|
}//for
|
}//for
|
|
|
|
|
}//else
|
}//else
|
//if(main_time > 20 && main_time < 30 ) traffic->start=1; else traffic->start=0;
|
//if(main_time > 20 && main_time < 30 ) traffic->start=1; else traffic->start=0;
|
//if(main_time == saved_time+25) router[0]->flit_in_we_all=0;
|
//if(main_time == saved_time+25) router1[0]->flit_in_we_all=0;
|
//if((main_time % 250)==0) printf("router->all_done =%u\n",router->all_done);
|
//if((main_time % 250)==0) printf("router->all_done =%u\n",router->all_done);
|
|
|
|
|
noc-> clk = clk;
|
noc-> clk = clk;
|
noc-> reset = reset;
|
noc-> reset = reset;
|
|
|
|
for(i=0;i<NE;i++) {
|
for(i=0;i<NC;i++) {
|
#if (NE<=64)
|
#if (NC<=64)
|
|
traffic[i]->start= ((noc->start_o >>i)& 0x01);
|
traffic[i]->start= ((noc->start_o >>i)& 0x01);
|
#else
|
#else
|
traffic[i]->start= (VL_BITISSET_W(noc->start_o, i)>0);
|
traffic[i]->start= (VL_BITISSET_W(noc->start_o, i)>0);
|
#endif
|
#endif
|
traffic[i]->reset= reset;
|
traffic[i]->reset= reset;
|
traffic[i]->clk = clk;
|
traffic[i]->clk = clk;
|
router[i]->reset= reset;
|
|
router[i]->clk= clk ;
|
|
|
|
}
|
}
|
|
|
|
connect_routers_reset_clk();
|
|
|
|
//evaluate
|
noc->eval();
|
noc->eval();
|
|
routers_eval();
|
|
for(i=0;i<NE;i++) traffic[i]->eval();
|
|
|
|
//router1[0]->eval(); // Evaluate model
|
for(i=0;i<NC;i++) {
|
|
router[i]->eval();
|
|
traffic[i]->eval();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//router[0]->eval(); // Evaluate model
|
|
//printf("clk=%x\n",router->clk );
|
//printf("clk=%x\n",router->clk );
|
|
|
main_time++;
|
main_time++;
|
//getchar();
|
//getchar();
|
|
|
|
|
}
|
|
for(i=0;i<NC;i++) {
|
|
router[i]->final();
|
|
traffic[i]->final();
|
|
} // Done simulating
|
} // Done simulating
|
|
|
|
routers_final();
|
|
for(i=0;i<NE;i++) traffic[i]->final();
|
noc->final();
|
noc->final();
|
|
|
}
|
}
|
|
|
|
|
Line 527... |
Line 422... |
|
|
/*************
|
/*************
|
* sc_time_stamp
|
* sc_time_stamp
|
*
|
*
|
* **********/
|
* **********/
|
|
|
|
|
|
|
double sc_time_stamp () { // Called by $time in Verilog
|
double sc_time_stamp () { // Called by $time in Verilog
|
return main_time;
|
return main_time;
|
}
|
}
|
|
|
int pow2( int num){
|
int pow2( int num){
|
Line 549... |
Line 441... |
* update_noc_statistic
|
* update_noc_statistic
|
*
|
*
|
*
|
*
|
*********************************/
|
*********************************/
|
|
|
|
void update_noc_statistic ( int core_num){
|
|
|
void update_noc_statistic (
|
|
|
|
int core_num
|
|
)
|
|
{
|
|
|
|
unsigned int clk_num_h2h =traffic[core_num]->time_stamp_h2h;
|
unsigned int clk_num_h2h =traffic[core_num]->time_stamp_h2h;
|
unsigned int clk_num_h2t =traffic[core_num]->time_stamp_h2t;
|
unsigned int clk_num_h2t =traffic[core_num]->time_stamp_h2t;
|
unsigned int distance=traffic[core_num]->distance;
|
unsigned int distance=traffic[core_num]->distance;
|
unsigned int class_num=traffic[core_num]->pck_class_out;
|
unsigned int class_num=traffic[core_num]->pck_class_out;
|
unsigned int src_x=traffic[core_num]->src_x;
|
unsigned int src_e_addr=traffic[core_num]->src_e_addr;
|
unsigned int src_y=traffic[core_num]->src_y;
|
unsigned int src = endp_addr_decoder (src_e_addr);
|
|
|
unsigned int src = (src_y*NX)+src_x;
|
|
|
|
|
|
|
|
|
|
total_pck_num+=1;
|
total_pck_num+=1;
|
|
|
if((total_pck_num & 0Xffff )==0 ) printf(" packet sent total=%d\n",total_pck_num);
|
if((total_pck_num & 0Xffff )==0 ) printf(" packet sent total=%d\n",total_pck_num);
|
|
|
|
|
sum_clk_h2h+=clk_num_h2h;
|
sum_clk_h2h+=clk_num_h2h;
|
sum_clk_h2t+=clk_num_h2t;
|
sum_clk_h2t+=clk_num_h2t;
|
#if (STND_DEV_EN)
|
#if (STND_DEV_EN)
|
sum_clk_pow2+=(double)clk_num_h2h * (double) clk_num_h2h;
|
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;
|
sum_clk_pow2_per_class[class_num]+=(double)clk_num_h2h * (double) clk_num_h2h;
|
#endif
|
#endif
|
|
|
sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance);
|
sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance);
|
total_pck_num_per_class[class_num]+=1;
|
total_pck_num_per_class[class_num]+=1;
|
sum_clk_h2h_per_class[class_num]+=clk_num_h2h ;
|
sum_clk_h2h_per_class[class_num]+=clk_num_h2h ;
|
sum_clk_h2t_per_class[class_num]+=clk_num_h2t ;
|
sum_clk_h2t_per_class[class_num]+=clk_num_h2t ;
|
sum_clk_per_hop_per_class[class_num]+= ((double)clk_num_h2h/(double)distance);
|
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;
|
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 (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 (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;
|
|
|
|
|
}
|
}
|
|
|
/*************************
|
|
*
|
|
* update
|
|
*
|
|
*
|
|
************************/
|
|
|
|
|
|
|
|
|
|
|
|
void print_statistic (char * out_file_name){
|
void print_statistic (char * out_file_name){
|
double avg_latency_per_hop, avg_latency_flit, avg_latency_pck, avg_throughput,min_avg_latency_per_class;
|
double avg_latency_per_hop, avg_latency_flit, avg_latency_pck, avg_throughput,min_avg_latency_per_class;
|
int i;
|
int i;
|
Line 669... |
Line 531... |
std_dev= (total_pck_num_per_class[i]>0)? standard_dev( sum_clk_pow2_per_class[i],total_pck_num_per_class[i], avg_latency_flit):0;
|
std_dev= (total_pck_num_per_class[i]>0)? standard_dev( sum_clk_pow2_per_class[i],total_pck_num_per_class[i], avg_latency_flit):0;
|
// sprintf(file_name,"%s_std%u.txt",out_file_name,i);
|
// sprintf(file_name,"%s_std%u.txt",out_file_name,i);
|
// update_file( file_name,avg_throughput,std_dev);
|
// update_file( file_name,avg_throughput,std_dev);
|
|
|
#endif
|
#endif
|
|
|
|
|
}//for
|
}//for
|
current_avg_latency_flit=min_avg_latency_per_class;
|
current_avg_latency_flit=min_avg_latency_per_class;
|
|
|
for (i=0;i<NC;i++) {
|
for (i=0;i<NE;i++) {
|
printf ("\n\nCore %d\n",i);
|
printf ("\n\nCore %d\n",i);
|
printf ("\n\ttotal number of received packets: %u\n",rsvd_core_total_pck_num[i]);
|
printf ("\n\ttotal number of received packets: %u\n",rsvd_core_total_pck_num[i]);
|
printf ("\n\tworst-case-delay of received pckets (clks): %u\n",rsvd_core_worst_delay[i] );
|
printf ("\n\tworst-case-delay of received pckets (clks): %u\n",rsvd_core_worst_delay[i] );
|
printf ("\n\ttotal number of sent packets: %u\n",traffic[i]->pck_number);
|
printf ("\n\ttotal number of sent packets: %u\n",traffic[i]->pck_number);
|
printf ("\n\tworst-case-delay of sent pckets (clks): %u\n",sent_core_worst_delay[i] );
|
printf ("\n\tworst-case-delay of sent pckets (clks): %u\n",sent_core_worst_delay[i] );
|
}
|
}
|
|
|
|
|
|
|
}
|
}
|
|
|
void print_parameter (){
|
|
|
|
|
void print_parameter (){
|
printf ("Router parameters: \n");
|
printf ("Router parameters: \n");
|
printf ("\tTopology: %s\n",TOPOLOGY);
|
printf ("\tTopology: %s\n",TOPOLOGY);
|
printf ("\tRouting algorithm: %s\n",ROUTE_NAME);
|
printf ("\tRouting algorithm: %s\n",ROUTE_NAME);
|
printf ("\tVC_per port: %d\n", V);
|
printf ("\tVC_per port: %d\n", V);
|
printf ("\tBuffer_width: %d\n", B);
|
printf ("\tBuffer_width: %d\n", B);
|
printf ("\tRouter num in row: %d \n",NX);
|
if((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)){
|
printf ("\tRouter num in column: %d \n",NY);
|
printf ("\tRouter num in row: %d \n",T1);
|
|
printf ("\tRouter num in column: %d \n",T2);
|
|
}else if ((strcmp (TOPOLOGY,"RING")==0)||(strcmp (TOPOLOGY,"LINE")==0)){
|
|
printf ("\t Total Router num: %d \n",T1);
|
|
}
|
|
else{
|
|
printf ("\tK: %d \n",T1);
|
|
printf ("\tL: %d \n",T2);
|
|
}
|
printf ("\tNumber of Class: %d\n", C);
|
printf ("\tNumber of Class: %d\n", C);
|
printf ("\tFlit data width: %d \n", Fpay);
|
printf ("\tFlit data width: %d \n", Fpay);
|
printf ("\tVC reallocation mechanism: %s \n", VC_REALLOCATION_TYPE);
|
printf ("\tVC reallocation mechanism: %s \n", VC_REALLOCATION_TYPE);
|
printf ("\tVC/sw combination mechanism: %s \n", COMBINATION_TYPE);
|
printf ("\tVC/sw combination mechanism: %s \n", COMBINATION_TYPE);
|
printf ("\troute-subfunction: %s \n", ROUTE_SUBFUNC );
|
|
printf ("\tAVC_ATOMIC_EN:%d \n", AVC_ATOMIC_EN);
|
printf ("\tAVC_ATOMIC_EN:%d \n", AVC_ATOMIC_EN);
|
printf ("\tCongestion Index:%d \n",CONGESTION_INDEX);
|
printf ("\tCongestion Index:%d \n",CONGESTION_INDEX);
|
printf ("\tADD_PIPREG_AFTER_CROSSBAR:%d\n",ADD_PIPREG_AFTER_CROSSBAR);
|
printf ("\tADD_PIPREG_AFTER_CROSSBAR:%d\n",ADD_PIPREG_AFTER_CROSSBAR);
|
printf ("\tSSA_EN enabled:%s \n",SSA_EN);
|
printf ("\tSSA_EN enabled:%s \n",SSA_EN);
|
printf ("\tSwitch allocator arbitration type:%s \n",SWA_ARBITER_TYPE);
|
printf ("\tSwitch allocator arbitration type:%s \n",SWA_ARBITER_TYPE);
|
|
printf ("\tMinimum supported packet size:%d flit(s) \n",MIN_PCK_SIZE);
|
|
|
|
|
printf ("\nSimulation parameters\n");
|
printf ("\nSimulation parameters\n");
|
#if(DEBUG_EN)
|
#if(DEBUG_EN)
|
printf ("\tDebuging is enabled\n");
|
printf ("\tDebuging is enabled\n");
|
Line 745... |
Line 610... |
*
|
*
|
* *******************/
|
* *******************/
|
|
|
void reset_all_register (void){
|
void reset_all_register (void){
|
int i;
|
int i;
|
|
|
|
|
|
|
total_router=0;
|
total_router=0;
|
total_pck_num=0;
|
total_pck_num=0;
|
sum_clk_h2h=0;
|
sum_clk_h2h=0;
|
sum_clk_h2t=0;
|
sum_clk_h2t=0;
|
#if (STND_DEV_EN)
|
#if (STND_DEV_EN)
|
Line 826... |
Line 688... |
|
|
unsigned char pck_class_in_gen(
|
unsigned char pck_class_in_gen(
|
unsigned int core_num
|
unsigned int core_num
|
|
|
) {
|
) {
|
|
|
unsigned char pck_class_in;
|
unsigned char pck_class_in;
|
unsigned char rnd=rand()%100;
|
unsigned char rnd=rand()%100;
|
|
|
pck_class_in= ( rnd < C0_p )? 0:
|
pck_class_in= ( rnd < C0_p )? 0:
|
( rnd < (C0_p+C1_p) )? 1:
|
( rnd < (C0_p+C1_p) )? 1:
|
( rnd < (C0_p+C1_p+C2_p))?2:3;
|
( rnd < (C0_p+C1_p+C2_p))?2:3;
|
|
|
|
|
|
|
return pck_class_in;
|
return pck_class_in;
|
}
|
}
|
|
|
|
|
/**********************************
|
|
|
|
pck_dst_gen
|
|
|
|
*********************************/
|
|
|
|
|
|
|
|
|
|
void pck_dst_gen_2D (
|
|
unsigned int current_x,
|
|
unsigned int current_y,
|
|
unsigned int core_num,
|
|
unsigned int *dest_x,
|
|
unsigned int *dest_y
|
|
){
|
|
|
|
|
|
unsigned int rnd=0,nc=NX*NY;
|
|
unsigned int rnd100=0;
|
|
unsigned int max_percent=100/HOTSPOT_NUM;
|
|
int i;
|
|
|
|
traffic[core_num]->pck_size_in=rnd_between(MIN_PACKET_SIZE,MAX_PACKET_SIZE);
|
|
|
|
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
|
|
|
|
do{
|
|
rnd=rand()%nc;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
|
|
(*dest_y) = (rnd / NX );
|
|
(*dest_x) = (rnd % NX );
|
|
|
|
|
|
}
|
|
|
|
else if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
|
|
|
|
unsigned int rnd1000=0;
|
|
int i;
|
|
|
|
|
|
do{
|
|
rnd=rand()%nc;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
|
|
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){
|
|
rnd = core_num; // turn off the core
|
|
(*dest_y) = (rnd / NX );
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
}
|
|
}
|
|
|
|
for (i=0;i<HOTSPOT_NUM; i++){
|
|
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
|
|
rnd = hotspots[i].ip_num;
|
|
(*dest_y) = (rnd / NX );
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
}
|
|
|
|
}
|
|
(*dest_y) = (rnd / NX );
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
|
|
|
|
} else if(( strcmp(TRAFFIC ,"TRANSPOSE1")==0)|| (strcmp (TRAFFIC,"transposed 1")==0)){
|
|
|
|
(*dest_x) = NX-current_y-1;
|
|
(*dest_y) = NY-current_x-1;
|
|
|
|
|
|
|
|
} else if(( strcmp(TRAFFIC ,"TRANSPOSE2")==0)|| (strcmp (TRAFFIC,"transposed 2")==0)){
|
|
(*dest_x) = current_y;
|
|
(*dest_y) = current_x;
|
|
|
|
|
|
|
|
} else if(( strcmp(TRAFFIC ,"BIT_REVERSE")==0)|| (strcmp (TRAFFIC,"bit reverse")==0)){
|
|
unsigned int joint_addr= (current_x<<Xw)+current_y;
|
|
unsigned int reverse_addr=0;
|
|
unsigned int pos=0;
|
|
for(i=0; i<(Xw+Yw); i++){//reverse the address
|
|
pos= (((Xw+Yw)-1)-i);
|
|
reverse_addr|= ((joint_addr >> pos) & 0x01) << i;
|
|
// reverse_addr[i] = joint_addr [((Xw+Yw)-1)-i];
|
|
}
|
|
(*dest_x) = reverse_addr>>Yw;
|
|
(*dest_y) = reverse_addr&(0xFF>> (8-Yw));
|
|
|
|
|
|
|
|
|
|
} else if(( strcmp(TRAFFIC ,"BIT_COMPLEMENT") ==0)|| (strcmp (TRAFFIC,"bit complement")==0)){
|
|
|
|
(*dest_x) = (~current_x) &(0xFF>> (8-Xw));
|
|
(*dest_y) = (~current_y) &(0xFF>> (8-Yw));
|
|
|
|
|
|
} else if(( strcmp(TRAFFIC ,"TORNADO") == 0)|| (strcmp (TRAFFIC,"tornado")==0)){
|
|
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
|
|
(*dest_x) = ((current_x + ((NX/2)-1))%NX);
|
|
(*dest_y) = ((current_y + ((NY/2)-1))%NY);
|
|
|
|
|
|
} else if( strcmp(TRAFFIC ,"CUSTOM") == 0){
|
|
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
|
|
if(current_x ==0 && current_y == 0 ){
|
|
(*dest_x) = NX-1;
|
|
(*dest_y) = NY-1;
|
|
}else{// make it invalid
|
|
(*dest_x) = current_x;
|
|
(*dest_y) = current_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC);
|
|
(*dest_x) = current_x;
|
|
(*dest_y) = current_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pck_dst_gen_1D (
|
|
unsigned int current_x,
|
|
unsigned int core_num,
|
|
unsigned int *dest_x
|
|
|
|
){
|
|
|
|
|
|
unsigned int rnd=0,nc=NX;
|
|
unsigned int rnd100=0;
|
|
unsigned int max_percent=100/HOTSPOT_NUM;
|
|
int i;
|
|
|
|
traffic[core_num]->pck_size_in=rnd_between(MIN_PACKET_SIZE,MAX_PACKET_SIZE);
|
|
|
|
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
|
|
|
|
do{
|
|
rnd=rand()%nc;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
|
|
}
|
|
|
|
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
|
|
|
|
unsigned int rnd1000=0;
|
|
int i;
|
|
|
|
|
|
do{
|
|
rnd=rand()%nc;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
|
|
rnd1000=rand()%1000; // generate a random number between 0 & 1000
|
|
|
|
for (i=0;i<HOTSPOT_NUM; i++){
|
|
//printf("%u==0 && %u == %u\n", hotspots[i].send_enable , core_num , hotspots[i].ip_num);
|
|
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){
|
|
rnd = core_num; // turn off the core
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
}
|
|
}
|
|
|
|
for (i=0;i<HOTSPOT_NUM; i++){
|
|
//printf("%u<%u && %u |= %u\n", rnd1000 , hotspots[i].percentage , core_num ,hotspots[i].ip_num);
|
|
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
|
|
rnd = hotspots[i].ip_num;
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
}
|
|
|
|
}
|
|
(*dest_x) = (rnd % NX );
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
if(( strcmp(TRAFFIC ,"TRANSPOSE1")==0)|| (strcmp (TRAFFIC,"transposed 1")==0)){
|
|
|
|
//(*dest_x) = (current_x<4)? NX-current_x-1: current_x;
|
|
(*dest_x) = NX-current_x-1;
|
|
// (*dest_y) = NY-current_x-1;
|
|
return;
|
|
|
|
|
|
}
|
|
if(( strcmp(TRAFFIC ,"TRANSPOSE2")==0)|| (strcmp (TRAFFIC,"transposed 2")==0)){
|
|
(*dest_x) = NX-current_x-1;
|
|
// (*dest_x) = current_y;
|
|
// (*dest_y) = current_x;
|
|
return;
|
|
|
|
}
|
|
|
|
if(( strcmp(TRAFFIC ,"BIT_REVERSE")==0)|| (strcmp (TRAFFIC,"bit reverse")==0)){
|
|
|
|
unsigned int reverse_addr=0;
|
|
unsigned int pos=0;
|
|
for(i=0; i<(Xw); i++){//reverse the address
|
|
pos= (((Xw)-1)-i);
|
|
reverse_addr|= ((current_x >> pos) & 0x01) << i;
|
|
// reverse_addr[i] = joint_addr [((Xw+Yw)-1)-i];
|
|
}
|
|
(*dest_x) = reverse_addr;
|
|
return;
|
|
|
|
}
|
|
|
|
if(( strcmp(TRAFFIC ,"BIT_COMPLEMENT") ==0)|| (strcmp (TRAFFIC,"bit complement")==0)){
|
|
|
|
(*dest_x) = (~current_x) &(0xFF>> (8-Xw));
|
|
return;
|
|
//(*dest_y) = (~current_y) &(0xFF>> (8-Yw));
|
|
|
|
|
|
}
|
|
|
|
if(( strcmp(TRAFFIC ,"TORNADO") == 0)|| (strcmp (TRAFFIC,"tornado")==0)){
|
|
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
|
|
(*dest_x) = ((current_x + ((NX/2)-1))%NX);
|
|
// (*dest_y) = ((current_y + ((NY/2)-1))%NY);
|
|
return;
|
|
|
|
}
|
|
|
|
if( strcmp(TRAFFIC ,"CUSTOM") == 0){
|
|
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
|
|
if(current_x ==0 ){
|
|
(*dest_x) = NX-1;
|
|
// (*dest_y) = NY-1;
|
|
}else{// make it invalid
|
|
(*dest_x) = current_x;
|
|
//(*dest_y) = current_y;
|
|
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC);
|
|
(*dest_x) = current_x;
|
|
|
|
|
|
}
|
|
|
|
unsigned int rnd_between (unsigned int a, unsigned int b){
|
|
unsigned int rnd,diff,min;
|
|
if(a==b) return a;
|
|
diff= (a<b) ? b-a+1 : a-b+1;
|
|
min= (a<b) ? a : b;
|
|
rnd = (rand() % diff) + min;
|
|
return rnd;
|
|
}
|
|
|
|
void update_injct_var(unsigned int src, unsigned int injct_var){
|
void update_injct_var(unsigned int src, unsigned int injct_var){
|
//printf("before%u=%u\n",src,random_var[src]);
|
//printf("before%u=%u\n",src,random_var[src]);
|
random_var[src]= rnd_between(100-injct_var, 100+injct_var);
|
random_var[src]= rnd_between(100-injct_var, 100+injct_var);
|
//printf("after=%u\n",random_var[src]);
|
//printf("after=%u\n",random_var[src]);
|
Line 1126... |
Line 709... |
|
|
unsigned int pck_dst_gen_task_graph ( unsigned int src){
|
unsigned int pck_dst_gen_task_graph ( unsigned int src){
|
task_t task;
|
task_t task;
|
float f,v;
|
float f,v;
|
|
|
|
|
|
|
|
|
int index = task_graph_abstract[src].active_index;
|
int index = task_graph_abstract[src].active_index;
|
|
|
if(index == DISABLE){
|
if(index == DISABLE){
|
traffic[src]->ratio=0;
|
traffic[src]->ratio=0;
|
traffic[src]->stop=1;
|
traffic[src]->stop=1;
|
Line 1168... |
Line 748... |
f= f * MAX_RATIO / 100;
|
f= f * MAX_RATIO / 100;
|
|
|
traffic[src]->ratio=(unsigned int)f;
|
traffic[src]->ratio=(unsigned int)f;
|
traffic[src]->init_weight=task.initial_weight;
|
traffic[src]->init_weight=task.initial_weight;
|
|
|
|
|
|
|
|
|
if (task.burst_sent >= task.burst_size){
|
if (task.burst_sent >= task.burst_size){
|
task.burst_sent=0;
|
task.burst_sent=0;
|
task_graph_abstract[src].active_index=task_graph_abstract[src].active_index+1;
|
task_graph_abstract[src].active_index=task_graph_abstract[src].active_index+1;
|
if(task_graph_abstract[src].active_index>=task_graph_abstract[src].total_index) task_graph_abstract[src].active_index=0;
|
if(task_graph_abstract[src].active_index>=task_graph_abstract[src].total_index) task_graph_abstract[src].active_index=0;
|
|
|
}
|
}
|
|
|
|
|
update_by_index(task_graph_data[src],index,task);
|
update_by_index(task_graph_data[src],index,task);
|
|
|
if (task.byte_sent >= task.bytes){ // This task is done remove it from the queue
|
if (task.byte_sent >= task.bytes){ // This task is done remove it from the queue
|
remove_by_index(&task_graph_data[src],index);
|
remove_by_index(&task_graph_data[src],index);
|
task_graph_abstract[src].total_index = task_graph_abstract[src].total_index-1;
|
task_graph_abstract[src].total_index = task_graph_abstract[src].total_index-1;
|
Line 1195... |
Line 771... |
}
|
}
|
if(task_graph_abstract[src].active_index>=task_graph_abstract[src].total_index) task_graph_abstract[src].active_index=0;
|
if(task_graph_abstract[src].active_index>=task_graph_abstract[src].total_index) task_graph_abstract[src].active_index=0;
|
}
|
}
|
|
|
return task.dst;
|
return task.dst;
|
|
|
|
|
|
|
|
|
}
|
}
|
|
|
|
|
|
|
|
|
void pck_dst_gen (
|
|
unsigned int current_x,
|
|
unsigned int current_y,
|
|
unsigned int core_num,
|
|
unsigned int *dest_x,
|
|
unsigned int *dest_y
|
|
){
|
|
|
|
if(TRAFFIC_TYPE==CUSTOM){
|
|
int dest = pck_dst_gen_task_graph ( core_num);
|
|
(*dest_y) = (dest / NX );
|
|
(*dest_x) = (dest % NX );
|
|
// printf ("%d->%d (%d,%d)\n",core_num,dest,(*dest_y),(*dest_x) );
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
if((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)){
|
|
pck_dst_gen_2D (
|
|
current_x,
|
|
current_y,
|
|
core_num,
|
|
dest_x,
|
|
dest_y
|
|
);
|
|
return;
|
|
}
|
|
|
|
dest_y=0;
|
|
pck_dst_gen_1D (
|
|
current_x,
|
|
core_num,
|
|
dest_x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|