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 32 to Rev 38
- ↔ Reverse comparison
Rev 32 → Rev 38
/traffic_tabel.h
File deleted
/custom_traffic.h
0,0 → 1,172
#ifndef CUSTOM_TRAFFIC_h |
#define CUSTOM_TRAFFIC_h |
|
|
#include <stdlib.h> |
#include <stdio.h> |
#include <string.h> |
#include "parameter.h" |
|
#define NC (NX*NY) |
#define DISABLE -1 |
#define MAX_FILE_LINE 50000 |
#define MAX_LINE_LEN 5000 |
|
|
struct TRAFFIC_PATTERN { |
unsigned int src; // ID of the source node (PE) |
unsigned int dst; // ID of the destination node (PE) |
float pir; //1~100 % |
unsigned int avg_pck_size; //in flit |
unsigned int min_pck_size; //in flit |
unsigned int max_pck_size; //in flit |
unsigned int total_pck_num; |
unsigned int initial_weight; |
|
unsigned int packet_sent; |
}TrafficTable[MAX_FILE_LINE]; |
|
int active_location [NC+1]; |
|
|
int global_index=0; |
unsigned int total_pck_num_custom=0; |
|
|
|
void addTO( |
struct TRAFFIC_PATTERN st |
){ |
|
TrafficTable[global_index++]=st; |
TrafficTable[global_index].src=-1; |
total_pck_num_custom+=st.total_pck_num; |
} |
|
|
|
struct TRAFFIC_PATTERN extract_traffic_data ( char * str, int * n) |
{ |
struct TRAFFIC_PATTERN st; |
*n=sscanf( str, "%u,%u,%f,%u,%u,%u,%u,%u", |
&st.src, |
&st.dst, |
&st.pir, |
&st.avg_pck_size, |
&st.min_pck_size, |
&st.max_pck_size, |
&st.total_pck_num, |
&st.initial_weight); |
return st; |
} |
|
|
char* removewhiteSpacses (char * oldstr ) { |
char *newstr = (char*) malloc(strlen(oldstr)+1); |
char *np = newstr, *op = oldstr; |
do { |
if (*op != ' ' && *op != '\t') |
*np++ = *op; |
} while (*op++); |
return newstr; |
} |
|
|
int compare ( const void *pa, const void *pb ) |
{ |
const int *a = (const int *) pa; |
const int *b = (const int *) pb; |
return a[0] - b[0]; |
} |
|
|
int load_traffic_file(char * file){ |
FILE * in; |
char * line = NULL; |
size_t len = 0; |
ssize_t read; |
|
struct TRAFFIC_PATTERN file_data[MAX_FILE_LINE]; |
struct TRAFFIC_PATTERN sorted[MAX_FILE_LINE]; |
char l[MAX_LINE_LEN]; |
|
struct TRAFFIC_PATTERN st; |
int index=0,i=0,n=0; |
|
for (i = 0; i < NC; i++) { |
active_location[i] = DISABLE ; |
} |
|
in = fopen(file,"rb"); |
|
|
|
if(in == NULL) |
{ |
printf("Error: cannot open %s file in read mode!\n",file); |
exit(1); |
} |
|
|
|
while (fgets(l,MAX_LINE_LEN, in) != NULL) { |
|
|
//while ((read = getline(&line, &len, in)) != -1) { |
line = removewhiteSpacses(l); |
//printf("%s", line); |
|
if(line[0] != '%' && line[0] != 0 ) { |
st=extract_traffic_data(line,&n); |
if(st.dst >=NC) continue;// the destination address must be smaller than NC |
file_data[index]= st; |
index++; |
|
if(index>MAX_FILE_LINE){ |
perror("error: MAX_FILE_LINE is smaller than the file line number\n"); |
} |
//addTO(data); |
} |
|
} |
|
// qsort(file_data, index, sizeof file_data[0], compare); |
|
//sort |
int j,m=0; |
for (i=0;i<NC;i++){ |
for (j=0;j<index;j++){ |
if(file_data[j].src==i){ |
sorted[m]=file_data[j]; |
m++; |
} |
} |
} |
|
j=-1; |
int src; |
for (i=0; i< index ; i++){ // the source address must be smaller than NC |
src= sorted[i].src; |
if(src >= NC) continue; |
addTO(sorted[i]); |
|
if(j!=src){ |
active_location[src]=i; |
j=src; |
|
} |
} |
|
|
|
|
fclose(in); |
|
|
return index; |
|
} |
|
#endif |
|
|
/noc_connection.sv
1,44 → 1,46
`timescale 1ns/1ps |
`timescale 1ns/1ps |
|
`define START_LOC(port_num,width) (width*(port_num+1)-1) |
`define END_LOC(port_num,width) (width*port_num) |
`define CORE_NUM(x,y) ((y * NX) + x) |
`define SELECT_WIRE(x,y,port,width) `CORE_NUM(x,y)] [`START_LOC(port,width) : `END_LOC(port,width ) |
`define START_LOC(port_num,width) (width*(port_num+1)-1) |
`define END_LOC(port_num,width) (width*port_num) |
`define CORE_NUM(x,y) ((y * NX) + x) |
`define SELECT_WIRE(x,y,port,width) `CORE_NUM(x,y)] [`START_LOC(port,width) : `END_LOC(port,width ) |
|
|
module noc_connection ( |
|
/* |
reset, |
clk, |
flit_out_all, |
flit_out_wr_all, |
credit_in_all, |
flit_in_all, |
flit_in_wr_all, |
credit_out_all |
*/ |
|
/* |
reset, |
clk, |
flit_out_all, |
flit_out_wr_all, |
credit_in_all, |
flit_in_all, |
flit_in_wr_all, |
credit_out_all |
*/ |
clk, |
reset, |
start_i, |
start_o, |
router_flit_out_all, |
router_flit_out_we_all, |
router_flit_out_we_all, |
router_credit_in_all, |
router_credit_out_all, |
router_flit_in_all, |
router_flit_in_all, |
router_flit_in_we_all, |
router_congestion_in_all, |
router_congestion_out_all, |
ni_flit_in, |
// router_iport_weight_in_all, |
// router_iport_weight_out_all, |
ni_flit_in, |
ni_flit_in_wr, |
ni_credit_out, |
ni_credit_out, |
ni_flit_out, |
ni_flit_out_wr, |
ni_credit_in |
|
|
); |
|
|
|
|
function integer log2; |
46,7 → 48,7
log2=(number <=1) ? 1: 0; |
while(2**log2<number) begin |
log2=log2+1; |
end |
end |
end |
endfunction // log2 |
|
57,12 → 59,11
end |
endfunction |
|
`define INCLUDE_PARAM |
|
`include"parameter.v" |
`define INCLUDE_PARAM |
`include"parameter.v" |
|
|
localparam CONGw= (CONGESTION_INDEX==3)? 3: |
|
localparam CONGw= (CONGESTION_INDEX==3)? 3: |
(CONGESTION_INDEX==5)? 3: |
(CONGESTION_INDEX==7)? 3: |
(CONGESTION_INDEX==9)? 3: |
70,130 → 71,165
(CONGESTION_INDEX==12)? 3:2; |
|
|
localparam PV = V * P, |
P_1 = P-1 , |
Fw = 2+V+Fpay, //flit width; |
PFw = P * Fw, |
NC = (TOPOLOGY=="RING")? NX : NX*NY, //number of cores |
NCFw = NC * Fw, |
NCV = NC * V; |
localparam |
PV = V * P, |
P_1 = P-1, |
Fw = 2+V+Fpay, //flit width; |
PFw = P * Fw, |
/* verilator lint_off WIDTH */ |
NC = (TOPOLOGY=="RING" || TOPOLOGY=="LINE")? NX : NX*NY, //number of cores |
/* verilator lint_on WIDTH */ |
NCFw = NC * Fw, |
NCV = NC * V, |
CONG_ALw = CONGw * P, // congestion width per router |
Xw = log2(NX), // number of node in x axis |
Yw = log2(NY), // number of node in y axis |
W= WEIGHTw, |
WP = W * P; |
|
|
localparam CONG_ALw= CONGw* P, // congestion width per router |
Xw = log2(NX), // number of node in x axis |
Yw = log2(NY); // number of node in y axis |
|
|
|
|
|
output [PFw-1 : 0] router_flit_out_all [NC-1 :0]; |
output [P-1 : 0] router_flit_out_we_all [NC-1 :0]; |
input [PV-1 : 0] router_credit_in_all [NC-1 :0]; |
|
|
|
output [PFw-1 : 0] router_flit_out_all [NC-1 : 0]; |
output [P-1 : 0] router_flit_out_we_all [NC-1 : 0]; |
input [PV-1 : 0] router_credit_in_all [NC-1 : 0]; |
|
|
input [PFw-1 : 0] router_flit_in_all [NC-1 : 0]; |
input [P-1 : 0] router_flit_in_we_all [NC-1 : 0]; |
output [PV-1 : 0] router_credit_out_all[NC-1: 0]; |
|
input [CONG_ALw-1 : 0] router_congestion_in_all [NC-1 :0]; |
output [CONG_ALw-1 : 0] router_congestion_out_all [NC-1 :0]; |
// input [WP-1 : 0] router_iport_weight_in_all [NC-1 :0]; |
// output [WP-1 : 0] router_iport_weight_out_all [NC-1 :0]; |
|
input [Fw-1 : 0] ni_flit_in [NC-1 : 0]; |
input [NC-1 : 0] ni_flit_in_wr; |
output [V-1 : 0] ni_credit_out [NC-1 : 0]; |
output [Fw-1 : 0] ni_flit_out [NC-1 : 0]; |
output [NC-1 : 0] ni_flit_out_wr; |
input [V-1 : 0] ni_credit_in [NC-1 : 0]; |
|
input clk,reset, start_i; |
|
|
output [NC-1 : 0] start_o; |
|
|
input [PFw-1 : 0] router_flit_in_all [NC-1 :0]; |
input [P-1 : 0] router_flit_in_we_all [NC-1 :0]; |
output [PV-1 : 0] router_credit_out_all [NC-1 :0]; |
|
input [CONG_ALw-1 : 0] router_congestion_in_all [NC-1 :0]; |
output [CONG_ALw-1 : 0] router_congestion_out_all [NC-1 :0]; |
|
input [Fw-1 : 0] ni_flit_in [NC-1 :0]; |
input [NC-1 : 0] ni_flit_in_wr; |
output [V-1 : 0] ni_credit_out [NC-1 :0]; |
output [Fw-1 : 0] ni_flit_out [NC-1 :0]; |
output [NC-1 : 0] ni_flit_out_wr; |
input [V-1 : 0] ni_credit_in [NC-1 :0]; |
|
input clk,reset, start_i; |
|
|
output [NC-1 :0] start_o; |
|
genvar x,y; |
generate |
if( TOPOLOGY == "RING") begin : ring |
for (x=0; x<NX; x=x+1) begin :ring_loop |
if(x < NX-1) begin: not_last_node |
assign router_flit_out_all [`SELECT_WIRE(x,0,1,Fw)] = router_flit_in_all [`SELECT_WIRE((x+1),0,2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,1,V)] = router_credit_in_all [`SELECT_WIRE((x+1),0,2,V)]; |
assign router_flit_out_we_all [x][1] = router_flit_in_we_all [`CORE_NUM((x+1),0)][2]; |
assign router_congestion_out_all[`SELECT_WIRE(x,0,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x+1),0,2,CONGw)]; |
end else begin :last_node |
assign router_flit_out_all [`SELECT_WIRE(x,0,1,Fw)] = router_flit_in_all [`SELECT_WIRE(0,0,2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,1,V)] = router_credit_in_all [`SELECT_WIRE(0,0,2,V)]; |
assign router_flit_out_we_all [x][1] = router_flit_in_we_all [`CORE_NUM(0,0)][2]; |
assign router_congestion_out_all [`SELECT_WIRE(x,0,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE(0,0,2,CONGw)]; |
end |
/* verilator lint_off WIDTH */ |
if( TOPOLOGY == "RING" || TOPOLOGY == "LINE") begin : ring_line |
/* verilator lint_on WIDTH */ |
for (x=0; x<NX; x=x+1) begin :ring_loop |
if(x < NX-1) begin: not_last_node |
assign router_flit_out_all [`SELECT_WIRE(x,0,1,Fw)] = router_flit_in_all [`SELECT_WIRE((x+1),0,2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,1,V)] = router_credit_in_all [`SELECT_WIRE((x+1),0,2,V)]; |
assign router_flit_out_we_all [x][1] = router_flit_in_we_all [`CORE_NUM((x+1),0)][2]; |
assign router_congestion_out_all[`SELECT_WIRE(x,0,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x+1),0,2,CONGw)]; |
// assign router_iport_weight_out_all[`SELECT_WIRE(x,0,1,W)] = router_iport_weight_in_all [`SELECT_WIRE((x+1),0,2,W)]; |
end else begin :last_node |
/* verilator lint_off WIDTH */ |
if(TOPOLOGY == "LINE") begin : line_last_x |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,0,1,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,0,1,V)]= {V{1'b0}}; |
assign router_flit_out_we_all [x][1] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,0,1,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,0,1,W)] = {W{1'b0}}; |
end else begin : ring_last_x |
assign router_flit_out_all [`SELECT_WIRE(x,0,1,Fw)] = router_flit_in_all [`SELECT_WIRE(0,0,2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,1,V)] = router_credit_in_all [`SELECT_WIRE(0,0,2,V)]; |
assign router_flit_out_we_all [x][1] = router_flit_in_we_all [`CORE_NUM(0,0)][2]; |
assign router_congestion_out_all [`SELECT_WIRE(x,0,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE(0,0,2,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,0,1,W)] = router_iport_weight_in_all [`SELECT_WIRE(0,0,2,W)]; |
end |
end |
if(x>0)begin :not_first_x |
assign router_flit_out_all [`SELECT_WIRE(x,0,2,Fw)] = router_flit_in_all [`SELECT_WIRE((x-1),0,1,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,2,V)] = router_credit_in_all [`SELECT_WIRE((x-1),0,1,V)] ; |
assign router_flit_out_we_all [x][2] = router_flit_in_we_all [`CORE_NUM((x-1),0)][1]; |
assign router_congestion_out_all [`SELECT_WIRE(x,0,2,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x-1),0,1,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,0,2,W)] = router_iport_weight_in_all [`SELECT_WIRE((x-1),0,1,W)]; |
end else begin :first_x |
/* verilator lint_off WIDTH */ |
if(TOPOLOGY == "LINE") begin : line_first_x |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,0,2,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,0,2,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [x][2] = 1'b0; |
assign router_congestion_out_all[`SELECT_WIRE(x,0,2,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all[`SELECT_WIRE(x,0,2,W)] = {W{1'b0}}; |
end else begin : ring_first_x |
|
// local port connection |
assign router_flit_out_all [`SELECT_WIRE(x,0,0,Fw)] = ni_flit_in [x]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,0,V)] = ni_credit_in [x]; |
assign router_flit_out_we_all [x][0] = ni_flit_in_wr [x]; |
assign router_congestion_out_all[`SELECT_WIRE(x,0,0,CONGw)] = {CONGw{1'b0}}; |
|
assign ni_flit_out [x] = router_flit_in_all [`SELECT_WIRE(x,0,0,Fw)]; |
assign ni_flit_out_wr [x] = router_flit_in_we_all[x][0]; |
assign ni_credit_out [x] = router_credit_in_all [`SELECT_WIRE(x,0,0,V)]; |
|
|
assign router_flit_out_all [`SELECT_WIRE(x,0,2,Fw)] = router_flit_in_all [`SELECT_WIRE((NX-1),0,1,Fw)] ; |
assign router_credit_out_all [`SELECT_WIRE(x,0,2,V)] = router_credit_in_all [`SELECT_WIRE((NX-1),0,1,V)] ; |
assign router_flit_out_we_all [x][2] = router_flit_in_we_all [`CORE_NUM((NX-1),0)][1]; |
assign router_congestion_out_all[`SELECT_WIRE(x,0,2,CONGw)] = router_congestion_in_all [`SELECT_WIRE((NX-1),0,1,CONGw)]; |
// assign router_iport_weight_out_all[`SELECT_WIRE(x,0,2,W)] = router_iport_weight_in_all [`SELECT_WIRE((NX-1),0,1,W)]; |
end |
end |
// local port connection |
assign router_flit_out_all [`SELECT_WIRE(x,0,0,Fw)] = ni_flit_in [x]; |
assign router_credit_out_all [`SELECT_WIRE(x,0,0,V)] = ni_credit_in[x]; |
assign router_flit_out_we_all [x][0] = ni_flit_in_wr [x]; |
assign router_congestion_out_all[`SELECT_WIRE(x,0,0,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all[`SELECT_WIRE(x,0,0,W)] = 1; |
|
assign ni_flit_out [x] = router_flit_in_all [`SELECT_WIRE(x,0,0,Fw)]; |
assign ni_flit_out_wr [x] = router_flit_in_we_all[x][0]; |
assign ni_credit_out [x] = router_credit_in_all [`SELECT_WIRE(x,0,0,V)]; |
end//x |
end else begin :mesh_torus |
|
|
end//x |
end else begin :mesh_torus |
|
|
|
|
|
|
|
|
|
|
for (x=0; x<NX; x=x+1) begin :x_loop |
for (y=0; y<NY; y=y+1) begin: y_loop |
localparam IP_NUM = (y * NX) + x; |
|
for (x=0; x<NX; x=x+1) begin :x_loop |
for (y=0; y<NY; y=y+1) begin: y_loop |
localparam IP_NUM = (y * NX) + x; |
|
/* |
router # ( |
.V (V), |
.P (P), |
.B (B), |
.NX (NX), |
.NY (NY), |
//.X (x), |
//.Y (y), |
.C (C), |
.Fpay (Fpay), |
.TOPOLOGY (TOPOLOGY), |
.MUX_TYPE (MUX_TYPE), |
.VC_REALLOCATION_TYPE(VC_REALLOCATION_TYPE), |
.VC_SW_COMB_TYPE (VC_SW_COMB_TYPE) |
) |
the_router |
( |
.X (x [Xw-1 :0]), |
.Y (y [Yw-1 :0]), |
.flit_in_all (router_flit_out_all [IP_NUM]), |
.flit_in_we_all (router_flit_out_we_all [IP_NUM]), |
.credit_out_all (router_credit_in_all [IP_NUM]), |
|
.flit_out_all (router_flit_in_all [IP_NUM]), |
.flit_out_we_all (router_flit_in_we_all [IP_NUM]), |
.credit_in_all (router_credit_out_all [IP_NUM]), |
|
.clk (clk), |
.reset (reset) |
router # ( |
.V (V), |
.P (P), |
.B (B), |
.NX (NX), |
.NY (NY), |
//.X (x), |
//.Y (y), |
.C (C), |
.Fpay (Fpay), |
.TOPOLOGY (TOPOLOGY), |
.MUX_TYPE (MUX_TYPE), |
.VC_REALLOCATION_TYPE(VC_REALLOCATION_TYPE), |
.VC_SW_COMB_TYPE (VC_SW_COMB_TYPE) |
) |
the_router |
( |
.X (x [Xw-1 :0]), |
.Y (y [Yw-1 :0]), |
.flit_in_all (router_flit_out_all [IP_NUM]), |
.flit_in_we_all (router_flit_out_we_all [IP_NUM]), |
.credit_out_all (router_credit_in_all [IP_NUM]), |
|
.flit_out_all (router_flit_in_all [IP_NUM]), |
.flit_out_we_all (router_flit_in_we_all [IP_NUM]), |
.credit_in_all (router_credit_out_all [IP_NUM]), |
|
.clk (clk), |
.reset (reset) |
|
); |
*/ |
); |
*/ |
/* |
in [x,y][1] <------ out [x+1 ,y ][3] ; |
in [x,y][2] <------ out [x ,y-1][4] ; |
in [x,y][3] <------ out [x-1 ,y ][1] ; |
in [x,y][4] <------ out [x ,y+1][2] ; |
|
in [x,y][1] <------ out [x+1 ,y ][3] ; |
in [x,y][2] <------ out [x ,y-1][4] ; |
in [x,y][3] <------ out [x-1 ,y ][1] ; |
in [x,y][4] <------ out [x ,y+1][2] ; |
|
port num |
local = 0 |
east = 1 |
200,137 → 236,166
north = 2 |
west = 3 |
south = 4 |
*/ |
|
|
if(x < NX-1) begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,1,Fw)] = router_flit_in_all [`SELECT_WIRE((x+1),y,3,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,1,V)] = router_credit_in_all [`SELECT_WIRE((x+1),y,3,V)]; |
assign router_flit_out_we_all [IP_NUM][1] = router_flit_in_we_all [`CORE_NUM((x+1),y)][3]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x+1),y,3,CONGw)]; |
end else begin |
if(TOPOLOGY == "MESH") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,1,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,1,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][1] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,1,CONGw)] = {CONGw{1'b0}}; |
end else if(TOPOLOGY == "TORUS") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,1,Fw)] = router_flit_in_all [`SELECT_WIRE(0,y,3,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,1,V)] = router_credit_in_all [`SELECT_WIRE(0,y,3,V)]; |
assign router_flit_out_we_all [IP_NUM][1] = router_flit_in_we_all [`CORE_NUM(0,y)][3]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE(0,y,3,CONGw)]; |
end //topology |
end |
|
|
if(y>0) begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,2,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(y-1),4,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,2,V)] = router_credit_in_all [`SELECT_WIRE(x,(y-1),4,V)]; |
assign router_flit_out_we_all [IP_NUM][2] = router_flit_in_we_all [`CORE_NUM(x,(y-1))][4]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,2,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(y-1),4,CONGw)]; |
end else begin |
if(TOPOLOGY == "MESH") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,2,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,2,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][2] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,2,CONGw)] = {CONGw{1'b0}}; |
end else if(TOPOLOGY == "TORUS") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,2,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(NY-1),4,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,2,V)] = router_credit_in_all [`SELECT_WIRE(x,(NY-1),4,V)]; |
assign router_flit_out_we_all [IP_NUM][2] = router_flit_in_we_all [`CORE_NUM(x,(NY-1))][4]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,2,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(NY-1),4,CONGw)]; |
end//topology |
end//y>0 |
|
|
if(x>0)begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,3,Fw)] = router_flit_in_all [`SELECT_WIRE((x-1),y,1,Fw)] ; |
assign router_credit_out_all [`SELECT_WIRE(x,y,3,V)] = router_credit_in_all [`SELECT_WIRE((x-1),y,1,V)] ; |
assign router_flit_out_we_all [IP_NUM][3] = router_flit_in_we_all [`CORE_NUM((x-1),y)][1]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,3,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x-1),y,1,CONGw)]; |
end else begin |
if(TOPOLOGY == "MESH") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,3,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,3,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][3] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,3,CONGw)] = {CONGw{1'b0}}; |
end else if(TOPOLOGY == "TORUS") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,3,Fw)] = router_flit_in_all [`SELECT_WIRE((NX-1),y,1,Fw)] ; |
assign router_credit_out_all [`SELECT_WIRE(x,y,3,V)] = router_credit_in_all [`SELECT_WIRE((NX-1),y,1,V)] ; |
assign router_flit_out_we_all [IP_NUM][3] = router_flit_in_we_all [`CORE_NUM((NX-1),y)][1]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,3,CONGw)] = router_congestion_in_all [`SELECT_WIRE((NX-1),y,1,CONGw)]; |
end//topology |
end |
|
if(y < NY-1)begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,4,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(y+1),2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,4,V)] = router_credit_in_all [`SELECT_WIRE(x,(y+1),2,V)]; |
assign router_flit_out_we_all [IP_NUM][4] = router_flit_in_we_all [`CORE_NUM(x,(y+1))][2]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(y+1),2,CONGw)]; |
end else begin |
if(TOPOLOGY == "MESH") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,4,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,4,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][4] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = {CONGw{1'b0}}; |
end else if(TOPOLOGY == "TORUS") begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,4,Fw)] = router_flit_in_all [`SELECT_WIRE(x,0,2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,4,V)] = router_credit_in_all [`SELECT_WIRE(x,0,2,V)]; |
assign router_flit_out_we_all [IP_NUM][4] = router_flit_in_we_all [`CORE_NUM(x,0)][2]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,0,2,CONGw)]; |
end//topology |
end |
|
//connection to the ip_core |
|
|
assign router_flit_out_all [`SELECT_WIRE(x,y,0,Fw)] = ni_flit_in [IP_NUM]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,0,V)] = ni_credit_in [IP_NUM]; |
assign router_flit_out_we_all [IP_NUM][0] = ni_flit_in_wr [IP_NUM]; |
assign router_congestion_out_all[`SELECT_WIRE(x,y,0,CONGw)] = {CONGw{1'b0}}; |
|
assign ni_flit_out [IP_NUM] = router_flit_in_all [`SELECT_WIRE(x,y,0,Fw)]; |
assign ni_flit_out_wr [IP_NUM] = router_flit_in_we_all[IP_NUM][0]; |
assign ni_credit_out [IP_NUM] = router_credit_in_all [`SELECT_WIRE(x,y,0,V)]; |
|
|
|
/* |
assign flit_out_all [(IP_NUM+1)*Fw-1 : IP_NUM*Fw] = ni_flit_out [IP_NUM]; |
assign flit_out_wr_all[IP_NUM] = ni_flit_out_wr [IP_NUM]; |
assign ni_credit_in [IP_NUM] = credit_in_all [(IP_NUM+1)*V-1 : IP_NUM*V]; |
assign ni_flit_in [IP_NUM] = flit_in_all [(IP_NUM+1)*Fw-1 : IP_NUM*Fw]; |
assign ni_flit_in_wr [IP_NUM] = flit_in_wr_all [IP_NUM]; |
assign credit_out_all [(IP_NUM+1)*V-1 : IP_NUM*V] = ni_credit_out [IP_NUM]; |
*/ |
*/ |
|
|
if(x < NX-1) begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,1,Fw)] = router_flit_in_all [`SELECT_WIRE((x+1),y,3,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,1,V)] = router_credit_in_all [`SELECT_WIRE((x+1),y,3,V)]; |
assign router_flit_out_we_all [IP_NUM][1] = router_flit_in_we_all [`CORE_NUM((x+1),y)][3]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x+1),y,3,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,1,W)] = router_iport_weight_in_all [`SELECT_WIRE((x+1),y,3,W)]; |
end else begin |
/* verilator lint_off WIDTH */ |
if(TOPOLOGY == "MESH") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,1,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,1,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][1] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,1,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,1,W)] = {W{1'b0}}; |
/* verilator lint_off WIDTH */ |
end else if(TOPOLOGY == "TORUS") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,1,Fw)] = router_flit_in_all [`SELECT_WIRE(0,y,3,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,1,V)] = router_credit_in_all [`SELECT_WIRE(0,y,3,V)]; |
assign router_flit_out_we_all [IP_NUM][1] = router_flit_in_we_all [`CORE_NUM(0,y)][3]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,1,CONGw)] = router_congestion_in_all [`SELECT_WIRE(0,y,3,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,1,W)] = router_iport_weight_in_all [`SELECT_WIRE(0,y,3,W)]; |
end //topology |
end |
|
|
if(y>0) begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,2,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(y-1),4,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,2,V)] = router_credit_in_all [`SELECT_WIRE(x,(y-1),4,V)]; |
assign router_flit_out_we_all [IP_NUM][2] = router_flit_in_we_all [`CORE_NUM(x,(y-1))][4]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,2,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(y-1),4,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,2,W)] = router_iport_weight_in_all [`SELECT_WIRE(x,(y-1),4,W)]; |
end else begin |
/* verilator lint_off WIDTH */ |
if(TOPOLOGY == "MESH") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,2,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,2,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][2] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,2,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,2,W)] = {W{1'b0}}; |
/* verilator lint_off WIDTH */ |
end else if(TOPOLOGY == "TORUS") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,2,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(NY-1),4,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,2,V)] = router_credit_in_all [`SELECT_WIRE(x,(NY-1),4,V)]; |
assign router_flit_out_we_all [IP_NUM][2] = router_flit_in_we_all [`CORE_NUM(x,(NY-1))][4]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,2,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(NY-1),4,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,2,W)] = router_iport_weight_in_all [`SELECT_WIRE(x,(NY-1),4,W)]; |
end//topology |
end//y>0 |
|
|
if(x>0)begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,3,Fw)] = router_flit_in_all [`SELECT_WIRE((x-1),y,1,Fw)] ; |
assign router_credit_out_all [`SELECT_WIRE(x,y,3,V)] = router_credit_in_all [`SELECT_WIRE((x-1),y,1,V)] ; |
assign router_flit_out_we_all [IP_NUM][3] = router_flit_in_we_all [`CORE_NUM((x-1),y)][1]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,3,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x-1),y,1,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,3,W)] = router_iport_weight_in_all [`SELECT_WIRE((x-1),y,1,W)]; |
end else begin |
/* verilator lint_off WIDTH */ |
if(TOPOLOGY == "MESH") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,3,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,3,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][3] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,3,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,3,W)] = {W{1'b0}}; |
/* verilator lint_off WIDTH */ |
end else if(TOPOLOGY == "TORUS") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,3,Fw)] = router_flit_in_all [`SELECT_WIRE((NX-1),y,1,Fw)] ; |
assign router_credit_out_all [`SELECT_WIRE(x,y,3,V)] = router_credit_in_all [`SELECT_WIRE((NX-1),y,1,V)] ; |
assign router_flit_out_we_all [IP_NUM][3] = router_flit_in_we_all [`CORE_NUM((NX-1),y)][1]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,3,CONGw)] = router_congestion_in_all [`SELECT_WIRE((NX-1),y,1,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,3,W)] = router_iport_weight_in_all [`SELECT_WIRE((NX-1),y,1,W)]; |
end//topology |
end |
|
if(y < NY-1)begin |
assign router_flit_out_all [`SELECT_WIRE(x,y,4,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(y+1),2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,4,V)] = router_credit_in_all [`SELECT_WIRE(x,(y+1),2,V)]; |
assign router_flit_out_we_all [IP_NUM][4] = router_flit_in_we_all [`CORE_NUM(x,(y+1))][2]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(y+1),2,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,4,W)] = router_iport_weight_in_all [`SELECT_WIRE(x,(y+1),2,W)]; |
end else begin |
/* verilator lint_off WIDTH */ |
if(TOPOLOGY == "MESH") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,4,Fw)] = {Fw{1'b0}}; |
assign router_credit_out_all [`SELECT_WIRE(x,y,4,V)] = {V{1'b0}}; |
assign router_flit_out_we_all [IP_NUM][4] = 1'b0; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,4,W)] = {W{1'b0}}; |
/* verilator lint_off WIDTH */ |
end else if(TOPOLOGY == "TORUS") begin |
/* verilator lint_on WIDTH */ |
assign router_flit_out_all [`SELECT_WIRE(x,y,4,Fw)] = router_flit_in_all [`SELECT_WIRE(x,0,2,Fw)]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,4,V)] = router_credit_in_all [`SELECT_WIRE(x,0,2,V)]; |
assign router_flit_out_we_all [IP_NUM][4] = router_flit_in_we_all [`CORE_NUM(x,0)][2]; |
assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,0,2,CONGw)]; |
// assign router_iport_weight_out_all [`SELECT_WIRE(x,y,4,W)] = router_iport_weight_in_all [`SELECT_WIRE(x,0,2,W)]; |
end//topology |
end |
|
//connection to the ip_core |
|
|
assign router_flit_out_all [`SELECT_WIRE(x,y,0,Fw)] = ni_flit_in [IP_NUM]; |
assign router_credit_out_all [`SELECT_WIRE(x,y,0,V)] = ni_credit_in [IP_NUM]; |
assign router_flit_out_we_all [IP_NUM][0] = ni_flit_in_wr [IP_NUM]; |
assign router_congestion_out_all[`SELECT_WIRE(x,y,0,CONGw)] = {CONGw{1'b0}}; |
// assign router_iport_weight_out_all[`SELECT_WIRE(x,y,0,W)] = 1; |
|
assign ni_flit_out [IP_NUM] = router_flit_in_all [`SELECT_WIRE(x,y,0,Fw)]; |
assign ni_flit_out_wr [IP_NUM] = router_flit_in_we_all [IP_NUM][0]; |
assign ni_credit_out [IP_NUM] = router_credit_in_all [`SELECT_WIRE(x,y,0,V)]; |
|
|
|
/* |
assign flit_out_all [(IP_NUM+1)*Fw-1 : IP_NUM*Fw] = ni_flit_out [IP_NUM]; |
assign flit_out_wr_all[IP_NUM] = ni_flit_out_wr [IP_NUM]; |
assign ni_credit_in [IP_NUM] = credit_in_all [(IP_NUM+1)*V-1 : IP_NUM*V]; |
assign ni_flit_in [IP_NUM] = flit_in_all [(IP_NUM+1)*Fw-1 : IP_NUM*Fw]; |
assign ni_flit_in_wr [IP_NUM] = flit_in_wr_all [IP_NUM]; |
assign credit_out_all [(IP_NUM+1)*V-1 : IP_NUM*V] = ni_credit_out [IP_NUM]; |
*/ |
|
/* |
/* |
always @(posedge clk) begin |
if(router_credit_out_all[IP_NUM]>0) $display("router_credit_out_all=%x %m",router_credit_out_all[IP_NUM]); |
if(router_credit_in_all[IP_NUM]>0) $display("router_credit_in_all=%x %m",router_credit_in_all[IP_NUM]); |
if(ni_credit_in [IP_NUM]>0) $display("ni_credit_in=%x %m",ni_credit_in[IP_NUM]); |
if(router_credit_out_all[IP_NUM]>0) $display("router_credit_out_all=%x %m",router_credit_out_all[IP_NUM]); |
if(router_credit_in_all[IP_NUM]>0) $display("router_credit_in_all=%x %m",router_credit_in_all[IP_NUM]); |
if(ni_credit_in [IP_NUM]>0) $display("ni_credit_in=%x %m",ni_credit_in[IP_NUM]); |
|
end |
*/ |
end |
*/ |
|
end //y |
end //x |
end |
|
end //y |
end //x |
end |
|
endgenerate |
|
|
|
start_delay_gen #( |
.NC(NC) |
start_delay_gen #( |
.NC(NC) |
|
)delay_gen |
( |
.clk(clk), |
.reset(reset), |
.start_i(start_i), |
.start_o(start_o) |
); |
)delay_gen |
( |
.clk(clk), |
.reset(reset), |
.start_i(start_i), |
.start_o(start_o) |
); |
|
|
|
339,52 → 404,51
|
|
module start_delay_gen #( |
parameter NC = 64 //number of cores |
parameter NC = 64 //number of cores |
|
)( |
clk, |
reset, |
start_i, |
start_o |
clk, |
reset, |
start_i, |
start_o |
); |
|
input reset,clk,start_i; |
output [NC-1 : 0] start_o; |
reg start_i_reg; |
wire start; |
wire cnt_increase; |
reg [NC-1 : 0] start_o_next; |
reg [NC-1 : 0] start_o_reg; |
|
assign start= start_i_reg|start_i; |
input reset,clk,start_i; |
output [NC-1 : 0] start_o; |
reg start_i_reg; |
wire start; |
wire cnt_increase; |
reg [NC-1 : 0] start_o_next; |
reg [NC-1 : 0] start_o_reg; |
|
assign start= start_i_reg|start_i; |
|
always @(*)begin |
if(NC[0]==1'b0)begin // odd |
start_o_next={start_o[NC-3:0],start_o[NC-2],start}; |
end else begin //even |
start_o_next={start_o[NC-3:0],start_o[NC-1],start}; |
|
end |
end |
|
reg [2:0] counter; |
assign cnt_increase=(counter==3'd0); |
always @(posedge clk or posedge reset) begin |
if(reset) begin |
|
start_o_reg <= {NC{1'b0}}; |
start_i_reg <=1'b0; |
counter <=2'd0; |
end else begin |
counter <= counter+3'd1; |
start_i_reg <=start_i; |
if(cnt_increase | start) start_o_reg <=start_o_next; |
|
always @(*)begin |
if(NC[0]==1'b0)begin // odd |
start_o_next={start_o[NC-3:0],start_o[NC-2],start}; |
end else begin //even |
start_o_next={start_o[NC-3:0],start_o[NC-1],start}; |
|
end |
end |
|
reg [2:0] counter; |
assign cnt_increase=(counter==3'd0); |
always @(posedge clk or posedge reset) begin |
if(reset) begin |
start_o_reg <= {NC{1'b0}}; |
start_i_reg <= 1'b0; |
counter <= 3'd0; |
end else begin |
counter <= counter+3'd1; |
start_i_reg <= start_i; |
if(cnt_increase | start) start_o_reg <= start_o_next; |
|
|
end//reset |
end //always |
end//reset |
end //always |
|
assign start_o=(cnt_increase | start)? start_o_reg : {NC{1'b0}}; |
assign start_o=(cnt_increase | start)? start_o_reg : {NC{1'b0}}; |
|
endmodule |
|
/parameter.h
1,46 → 1,40
#ifndef INCLUDE_PARAM |
#define INCLUDE_PARAM |
|
#define V 4 |
#define B 5 |
#define NX 8 |
#define NY 8 |
#define C 4 |
#define Fpay 32 |
#define MUX_TYPE "ONE_HOT" |
#define VC_REALLOCATION_TYPE "NONATOMIC" |
#define COMBINATION_TYPE "COMB_NONSPEC" |
#define FIRST_ARBITER_EXT_P_EN 0 |
#define TOPOLOGY "MESH" |
#define ROUTE_NAME "XY" |
#define C0_p 25 |
#define C1_p 25 |
#define C2_p 25 |
#define C3_p 25 |
#define TRAFFIC "RANDOM" |
#define HOTSPOT_PERCENTAGE 3 |
#define HOTSOPT_NUM 4 |
#define HOTSPOT_CORE_1 18 |
#define HOTSPOT_CORE_2 50 |
#define HOTSPOT_CORE_3 22 |
#define HOTSPOT_CORE_4 54 |
#define HOTSPOT_CORE_5 18 |
#define MAX_PCK_NUM 256000 |
#define MAX_SIM_CLKs 100000 |
#define MAX_PCK_SIZ 10 |
#define TIMSTMP_FIFO_NUM 8 |
#define PACKET_SIZE 4 |
#define DEBUG_EN 1 |
#define ROUTE_SUBFUNC "NORTH_LAST" |
#define AVC_ATOMIC_EN 0 |
#define CONGESTION_INDEX 3 |
#define STND_DEV_EN 0 |
#define AVG_LATENCY_METRIC "HEAD_2_TAIL" |
#define ADD_PIPREG_AFTER_CROSSBAR 0 |
#define CVw (C==0)? V : C * V |
#define CLASS_SETTING "16'b111111111111111" |
#define ESCAP_VC_MASK 4'b0001 |
#define SSA_EN "NO" |
#ifndef INCLUDE_PARAM |
#define INCLUDE_PARAM |
|
|
|
#endif |
|
|
//NoC parameters |
#define TOPOLOGY "MESH" |
#define NX 2 |
#define NY 2 |
#define V 2 |
#define B 4 |
#define Fpay 32 |
#define ROUTE_NAME "XY" |
#define SSA_EN "NO" |
#define CONGESTION_INDEX 3 |
#define ESCAP_VC_MASK 01 |
#define VC_REALLOCATION_TYPE "NONATOMIC" |
#define COMBINATION_TYPE "COMB_NONSPEC" |
#define MUX_TYPE "BINARY" |
#define C 0 |
#define DEBUG_EN 0 |
#define ADD_PIPREG_AFTER_CROSSBAR 0 |
#define SWA_ARBITER_TYPE "RRA" |
#define FIRST_ARBITER_EXT_P_EN 1 |
#define AVC_ATOMIC_EN 0 |
#define ROUTE_SUBFUNC "XY" |
|
|
int P=(strcmp (TOPOLOGY,"RING")==0 || strcmp (TOPOLOGY,"LINE")==0 ) ? 3 : 5; |
|
|
//simulation parameter |
#define AVG_LATENCY_METRIC "HEAD_2_TAIL" |
#define TIMSTMP_FIFO_NUM 16 |
|
|
#endif |
/parameter.v
1,46 → 1,41
`ifdef INCLUDE_PARAM |
|
|
|
|
parameter V=4; |
parameter TOPOLOGY="MESH"; |
parameter P=(TOPOLOGY=="RING")? 3 : 5; |
parameter B=5; |
parameter NX=8; |
parameter NY=8; |
parameter C=4; |
parameter Fpay=32; |
parameter MUX_TYPE="ONE_HOT"; |
parameter VC_REALLOCATION_TYPE="NONATOMIC"; |
parameter COMBINATION_TYPE="COMB_NONSPEC"; |
parameter FIRST_ARBITER_EXT_P_EN=0; |
parameter ROUTE_NAME="XY"; |
parameter CONGESTION_INDEX=3; |
parameter C0_p=25; |
parameter C1_p=25; |
parameter C2_p=25; |
parameter C3_p=25; |
parameter TRAFFIC="RANDOM"; |
parameter HOTSPOT_PERCENTAGE=3; |
parameter HOTSOPT_NUM=4; |
parameter HOTSPOT_CORE_1=18; |
parameter HOTSPOT_CORE_2=50; |
parameter HOTSPOT_CORE_3=22; |
parameter HOTSPOT_CORE_4=54; |
parameter HOTSPOT_CORE_5=18; |
parameter MAX_PCK_NUM=256000; |
parameter MAX_SIM_CLKs=100000; |
parameter MAX_PCK_SIZ=10; |
parameter TIMSTMP_FIFO_NUM=8; |
parameter ROUTE_TYPE = (ROUTE_NAME == "XY" || ROUTE_NAME == "TRANC_XY" )? "DETERMINISTIC" : |
(ROUTE_NAME == "DUATO" || ROUTE_NAME == "TRANC_DUATO" )? "FULL_ADAPTIVE": "PAR_ADAPTIVE"; |
parameter DEBUG_EN=1; |
parameter ROUTE_SUBFUNC= "NORTH_LAST"; |
parameter AVC_ATOMIC_EN= 0; |
parameter AVG_LATENCY_METRIC= "HEAD_2_TAIL"; |
parameter ADD_PIPREG_AFTER_CROSSBAR= 0; |
parameter CVw=(C==0)? V : C * V; |
parameter [CVw-1: 0] CLASS_SETTING = 16'b111111111111111; |
parameter [V-1 : 0] ESCAP_VC_MASK=4'b0001; |
parameter SSA_EN= "NO"; |
//NoC parameters |
localparam TOPOLOGY="MESH"; |
localparam NX= 2; |
localparam NY= 2; |
localparam V=2; |
localparam B=4; |
localparam Fpay=32; |
localparam ROUTE_NAME="XY"; |
localparam SSA_EN="NO"; |
localparam CONGESTION_INDEX=3; |
localparam ESCAP_VC_MASK=2'b01; |
localparam VC_REALLOCATION_TYPE="NONATOMIC"; |
localparam COMBINATION_TYPE="COMB_NONSPEC"; |
localparam MUX_TYPE="BINARY"; |
localparam C=0; |
localparam DEBUG_EN=0; |
localparam ADD_PIPREG_AFTER_CROSSBAR=1'b0; |
localparam SWA_ARBITER_TYPE="RRA"; |
localparam FIRST_ARBITER_EXT_P_EN=1; |
localparam AVC_ATOMIC_EN=0; |
localparam ROUTE_SUBFUNC="XY"; |
localparam CLASS_SETTING={V{1'b1}}; |
localparam CVw=(C==0)? V : C * V; |
|
localparam P=(TOPOLOGY=="RING" || TOPOLOGY=="LINE")? 3 : 5; |
localparam ROUTE_TYPE = (ROUTE_NAME == "XY" || ROUTE_NAME == "TRANC_XY" )? "DETERMINISTIC" : |
(ROUTE_NAME == "DUATO" || ROUTE_NAME == "TRANC_DUATO" )? "FULL_ADAPTIVE": "PAR_ADAPTIVE"; |
|
//simulation parameter |
localparam MAX_PCK_NUM = 100000000; |
localparam MAX_PCK_SIZ = 16383; |
localparam MAX_SIM_CLKs= 100000000; |
localparam TIMSTMP_FIFO_NUM = 16; |
|
|
|
`endif |
`endif |
/router_verilator.v
6,12 → 6,14
flit_in_all, |
flit_in_we_all, |
credit_out_all, |
congestion_in_all, |
congestion_in_all, |
//iport_weight_in_all, |
|
flit_out_all, |
flit_out_we_all, |
credit_in_all, |
congestion_out_all, |
//iport_weight_out_all, |
|
clk,reset |
|
47,15 → 49,17
(CONGESTION_INDEX==12)? 3:2; |
|
|
localparam Xw = log2(NX), |
Yw = log2(NY), |
PV = V * P, |
P_1 = P-1, |
Fw = 2+V+Fpay, //flit width; |
PFw = P*Fw, |
CONG_ALw= CONGw* P; // congestion width per router |
localparam |
Xw = log2(NX), |
Yw = log2(NY), |
PV = V * P, |
P_1 = P-1, |
Fw = 2+V+Fpay, //flit width; |
PFw = P * Fw, |
CONG_ALw = CONGw * P, // congestion width per router |
W = WEIGHTw, |
WP = W * P; |
|
|
input [Xw-1 : 0] current_x; |
input [Yw-1 : 0] current_y; |
|
63,11 → 67,13
input [P-1 : 0] flit_in_we_all; |
output [PV-1 : 0] credit_out_all; |
input [CONG_ALw-1 : 0] congestion_in_all; |
|
// input [WP-1 : 0] iport_weight_in_all; |
|
output [PFw-1 : 0] flit_out_all; |
output [P-1 : 0] flit_out_we_all; |
input [PV-1 : 0] credit_in_all; |
output [CONG_ALw-1 : 0] congestion_out_all; |
// output [WP-1 : 0] iport_weight_out_all; |
|
input clk,reset; |
|
74,7 → 80,7
|
|
router # ( |
.V(V), |
.V(V), |
.P(P), |
.B(B), |
.NX(NX), |
97,7 → 103,9
.CVw(CVw), |
.CLASS_SETTING(CLASS_SETTING), |
.ESCAP_VC_MASK(ESCAP_VC_MASK), |
.SSA_EN(SSA_EN) |
.SSA_EN(SSA_EN), |
.SWA_ARBITER_TYPE(SWA_ARBITER_TYPE), |
.WEIGHTw(WEIGHTw) |
|
|
) |
109,10 → 117,12
.flit_in_we_all(flit_in_we_all), |
.credit_out_all(credit_out_all), |
.congestion_in_all(congestion_in_all), |
// .iport_weight_in_all(iport_weight_in_all), |
.flit_out_all(flit_out_all), |
.flit_out_we_all(flit_out_we_all), |
.credit_in_all(credit_in_all), |
.congestion_out_all(congestion_out_all), |
// .iport_weight_out_all(iport_weight_out_all), |
.clk(clk), |
.reset(reset) |
|
/simulator.cpp
16,20 → 16,20
#include "Vrouter.h" // From Verilating "router.v" |
#include "Vnoc.h" |
#include "Vtraffic.h" |
#include "parameter.h" |
|
|
|
|
#include "parameter.h" |
//#include "traffic_tabel.h" |
|
|
#ifndef NC |
#define NC (NX*NY) |
#endif |
#define RATIO_INIT 2 |
|
unsigned char FIXED_SRC_DST_PAIR; |
#define SYNTHETIC 0 |
#define CUSTOM 1 |
#define DISABLE -1 |
|
unsigned char Xw=0,Yw=0; |
#include "traffic_task_graph.h" |
|
|
|
39,13 → 39,14
Vnoc *noc; |
Vtraffic *traffic[NC]; |
|
|
char * TRAFFIC; |
unsigned char FIXED_SRC_DST_PAIR; |
unsigned char Xw=0,Yw=0; |
unsigned long int main_time = 0; // Current simulation time |
unsigned int saved_time = 0; |
|
|
unsigned int total_pck_num=0; |
unsigned int sum_clk_h2h,sum_clk_h2t; |
|
double sum_clk_per_hop; |
const int CC=(C==0)? 1 : C; |
|
53,20 → 54,24
unsigned int sum_clk_h2h_per_class[CC]={0}; |
unsigned int sum_clk_h2t_per_class[CC]={0}; |
double sum_clk_per_hop_per_class[CC]={0}; |
|
unsigned int rsvd_core_total_pck_num[NC]= {0}; |
unsigned int rsvd_core_worst_delay[NC] = {0}; |
unsigned int sent_core_total_pck_num[NC]= {0}; |
unsigned int sent_core_worst_delay[NC] = {0}; |
unsigned int random_var[NC] = {100}; |
|
unsigned int clk_counter; |
unsigned int count_en; |
unsigned int total_router; |
|
int reset,clk; |
|
|
|
|
|
char all_done=0; |
|
unsigned int flit_counter =0; |
|
char ratio=RATIO_INIT; |
int ratio=RATIO_INIT; |
double first_avg_latency_flit,current_avg_latency_flit; |
|
double sc_time_stamp (); |
74,8 → 79,8
|
|
|
int reset,clk; |
|
|
#if (STND_DEV_EN) |
#include <math.h> |
double sum_clk_pow2=0; |
84,10 → 89,7
#endif |
|
void update_noc_statistic ( |
unsigned int, |
unsigned int, |
unsigned int, |
unsigned int |
int |
); |
|
|
109,34 → 111,52
|
void print_statistic (char *); |
void print_parameter(); |
void reset_all_register(); |
unsigned int rnd_between (unsigned int, unsigned int ); |
|
|
void reset_all_register(); |
|
|
|
char * TRAFFIC; |
|
int PACKET_SIZE; |
|
|
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 inject_ratios[100]; |
|
int C0_p=100, C1_p=0, C2_p=0, C3_p=0; |
|
|
int HOTSPOT_PERCENTAGE; |
int HOTSPOT_NUM; |
int HOTSPOT_CORE_1, HOTSPOT_CORE_2, HOTSPOT_CORE_3, HOTSPOT_CORE_4,HOTSPOT_CORE_5; |
typedef struct HOTSPOT_NODE { |
int ip_num; |
char send_enable; |
int percentage; // x10 |
} hotspot_st; |
|
hotspot_st * hotspots; |
|
|
|
|
|
void usage(){ |
printf(" ./simulator -t [Traffic Pattern] -s [PACKET_SIZE] -n [MAX_PCK_NUM] c [MAX_SIM_CLKs] -i [INJECTION_RATIO] -p [class traffic ratios %] -h[HOTSPOT info] \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(" Traffic Pattern: \"HOTSPOT\" \"RANDOM\" \"TORNADO\" \"BIT_REVERSE\" \"BIT_COMPLEMENT\" \"TRANSPOSE1\" \"TRANSPOSE2\"\n"); |
printf(" PACKET_SIZE: packet size in flit\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_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(" INJECTION_RATIO: packet injection ratios"); |
printf(" class traffic ratios %: The percentage of traffic injected for each class. represented in string whit each clas ratio is seprated by coma. \"n0,n1,n2..\" \n"); |
printf(" HOTSPOT info: represented in a string with following format: \"HOTSPOT_PERCENTAGE,HOTSOPT_NUM,HOTSPOT_CORE_1,HOTSPOT_CORE_2,HOTSPOT_CORE_3,HOTSPOT_CORE_4,HOTSPOT_CORE_5\" \n"); |
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(" 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"); |
} |
|
|
154,26 → 174,78
return i; |
} |
|
void update_hotspot(char * str){ |
int i; |
int array[1000]; |
int p; |
int acuum=0; |
hotspot_st * new_node; |
p= parse_string (str, array); |
if (p<4){ |
printf("Error in hotspot traffic parameters \n"); |
exit(1); |
} |
HOTSPOT_NUM=array[0]; |
if (p<1+HOTSPOT_NUM*3){ |
printf("Error in hotspot traffic parameters \n"); |
exit(1); |
} |
new_node = (hotspot_st *) malloc( HOTSPOT_NUM * sizeof(hotspot_st)); |
if( new_node == NULL){ |
printf("Error: cannot allocate memory for hotspot traffic\n"); |
exit(1); |
} |
for (i=1;i<3*HOTSPOT_NUM; i+=3){ |
new_node[i/3]. ip_num = array[i]; |
new_node[i/3]. send_enable=array[i+1]; |
new_node[i/3]. percentage = acuum + array[i+2]; |
acuum= new_node[i/3]. percentage; |
|
} |
if(acuum> 1000){ |
printf("Warning: The hotspot traffic summation %f exceed than 100 percent. \n", (float) acuum /10); |
|
} |
|
hotspots=new_node; |
} |
|
|
|
|
|
|
|
void processArgs (int argc, char **argv ) |
{ |
char c; |
int p; |
int array[10]; |
float f; |
|
/* don't want getopt to moan - I can do that just fine thanks! */ |
opterr = 0; |
if (argc < 2) usage(); |
while ((c = getopt (argc, argv, "t:s:n:c:i:p:h:")) != -1) |
while ((c = getopt (argc, argv, "t:s:m:n:c:i:p:h:f:")) != -1) |
{ |
switch (c) |
{ |
|
case 'f': |
TRAFFIC_TYPE=CUSTOM; |
TRAFFIC=(char *) "CUSTOM from file"; |
load_traffic_file(optarg,task_graph_data,task_graph_abstract); |
MAX_PCK_NUM=task_graph_total_pck_num; |
break; |
case 't': |
TRAFFIC=optarg; |
total_active_routers=-1; |
break; |
case 's': |
PACKET_SIZE=atoi(optarg); |
MIN_PACKET_SIZE=atoi(optarg); |
break; |
case 'm': |
MAX_PACKET_SIZE=atoi(optarg); |
break; |
case 'n': |
MAX_PCK_NUM=atoi(optarg); |
break; |
180,8 → 252,10
case 'c': |
MAX_SIM_CLKs=atoi(optarg); |
break; |
case 'i': |
ratio=atoi(optarg); |
case 'i': |
f=atof(optarg); |
f*=(MAX_RATIO/100); |
ratio= (int) f; |
break; |
case 'p': |
p= parse_string (optarg, array); |
190,15 → 264,11
C2_p=array[2]; |
C3_p=array[3]; |
break; |
|
case 'h': |
p= parse_string (optarg, array); |
HOTSPOT_PERCENTAGE=array[0]; |
HOTSPOT_NUM=array[1]; |
HOTSPOT_CORE_1=array[2]; |
HOTSPOT_CORE_2=array[3]; |
HOTSPOT_CORE_3=array[4]; |
HOTSPOT_CORE_4=array[5]; |
HOTSPOT_CORE_5=array[6]; |
|
update_hotspot(optarg); |
|
|
break; |
|
216,6 → 286,7
exit(1); |
} |
} |
PACKET_SIZE=(MIN_PACKET_SIZE+MAX_PACKET_SIZE)/2;// average packet size |
} |
|
|
231,23 → 302,18
while((0x1<<Yw) < NY)Yw++; |
|
|
processArgs ( argc, argv ); |
|
|
FIXED_SRC_DST_PAIR = strcmp (TRAFFIC,"RANDOM") & strcmp(TRAFFIC,"HOTSPOT") & strcmp(TRAFFIC,"random") & strcmp(TRAFFIC,"hot spot"); |
|
|
|
|
|
|
Verilated::commandArgs(argc, argv); // Remember args |
|
for(i=0;i<NC;i++) router[i] = new Vrouter; // Create instance |
noc = new Vnoc; |
for(i=0;i<NC;i++) traffic[i] = new Vtraffic; |
|
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"); |
|
|
|
/******************** |
* initialize input |
*********************/ |
255,29 → 321,38
reset=1; |
reset_all_register(); |
noc->start_i=0; |
|
|
for(x=0;x<NX;x++)for(y=0;y<NY;y++){ |
|
i=(y*NX)+x; |
random_var[i] = 100; |
router[i]->current_x = x; |
router[i]->current_y = y; |
traffic[i]->current_x = x; |
traffic[i]->current_y = y; |
traffic[i]->start=0; |
traffic[i]->pck_size_in=PACKET_SIZE; |
traffic[i]->ratio=ratio; |
traffic[i]->pck_class_in= pck_class_in_gen( i); |
pck_dst_gen ( x,y,i, &dest_x, &dest_y); |
traffic[i]->dest_x= dest_x; |
traffic[i]->dest_y=dest_y; |
traffic[i]->stop=0; |
if(TRAFFIC_TYPE==SYNTHETIC){ |
traffic[i]->pck_size_in=PACKET_SIZE; |
traffic[i]->avg_pck_size_in=PACKET_SIZE; |
traffic[i]->ratio=ratio; |
traffic[i]->init_weight=1; |
} |
|
|
} |
|
//traffic[35]->init_weight=10; |
|
|
|
|
main_time=0; |
print_parameter(); |
printf("\n\n\n Flit injection ratio per router is =%d \n",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); |
while (!Verilated::gotFinish()) { |
|
287,30 → 362,24
|
if(main_time == saved_time+21){ count_en=1; noc->start_i=1;}//for(i=0;i<NC;i++) traffic[i]->start=1;} |
if(main_time == saved_time+26) noc->start_i=0;// for(i=0;i<NC;i++) traffic[i]->start=0; |
|
|
|
|
if ((main_time % 4) == 0) { |
|
if ((main_time % 4) == 0) { |
clk = 1; // Toggle clock |
if(count_en) clk_counter++; |
inject_done= ((total_pck_num >= MAX_PCK_NUM) || (clk_counter>= MAX_SIM_CLKs)); |
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); |
for(x=0;x<NX;x++)for(y=0;y<NY;y++) |
for(y=0;y<NY;y++)for(x=0;x<NX;x++) |
{ |
i=(y*NX)+x; |
// a packet has been received |
if(traffic[i]->update & ~reset){ |
update_noc_statistic ( |
traffic[i]->time_stamp_h2h, |
traffic[i]->time_stamp_h2t, |
traffic[i]->distance, |
traffic[i]->pck_class_out |
) ; |
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]++; |
if(!FIXED_SRC_DST_PAIR){ |
pck_dst_gen ( x,y,i, &dest_x, &dest_y); |
traffic[i]->dest_x= dest_x; |
332,9 → 401,7
router[i]->final(); |
traffic[i]->final(); |
} |
noc->final(); |
|
|
noc->final(); |
return 0; |
} |
|
354,6 → 421,8
router[i]->flit_in_we_all = noc->router_flit_out_we_all[i]; |
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]; |
|
|
360,6 → 429,8
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] ; |
|
traffic[i]->flit_in = noc->ni_flit_out [i]; |
428,10 → 499,13
|
|
|
/************* |
* sc_time_stamp |
* |
* **********/ |
|
|
|
|
double sc_time_stamp () { // Called by $time in Verilog |
return main_time; |
} |
454,33 → 528,48
|
|
void update_noc_statistic ( |
unsigned int clk_num_h2h, |
unsigned int clk_num_h2t, |
unsigned int distance, |
unsigned int class_num |
|
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; |
unsigned int distance=traffic[core_num]->distance; |
unsigned int class_num=traffic[core_num]->pck_class_out; |
unsigned int src_x=traffic[core_num]->src_x; |
unsigned int src_y=traffic[core_num]->src_y; |
|
total_pck_num+=1; |
//if((total_pck_num & 0Xffff )==0 ) printf("total_pck_num=%d\n",total_pck_num); |
sum_clk_h2h+=clk_num_h2h; |
sum_clk_h2t+=clk_num_h2t; |
unsigned int src = (src_y*NX)+src_x; |
|
|
|
|
total_pck_num+=1; |
|
if((total_pck_num & 0Xffff )==0 ) printf(" packet sent total=%d\n",total_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; |
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); |
total_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); |
sum_clk_per_hop+= ((double)clk_num_h2h/(double)distance); |
total_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; |
|
|
} |
} |
|
/************************* |
* |
493,12 → 582,6
|
|
|
|
|
|
|
|
|
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; |
int i; |
506,7 → 589,7
double std_dev; |
#endif |
char file_name[100]; |
avg_throughput= ((double)(total_pck_num*PACKET_SIZE*100)/total_router )/clk_counter; |
avg_throughput= ((double)(flit_counter*100)/total_router )/clk_counter; |
printf(" Total active routers: %d \n",total_router); |
printf(" Avg throughput is: %f (flits/clk/node %%)\n", avg_throughput); |
avg_latency_flit = (double)sum_clk_h2h/total_pck_num; |
551,8 → 634,6
// update_file( file_name,avg_throughput,avg_latency_flit ); |
|
|
|
|
} |
if(min_avg_latency_per_class > avg_latency_flit) min_avg_latency_per_class=avg_latency_flit; |
|
567,6 → 648,13
}//for |
current_avg_latency_flit=min_avg_latency_per_class; |
|
for (i=0;i<NC;i++) { |
printf ("\n\nCore %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 pckets (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 pckets (clks): %u\n",sent_core_worst_delay[i] ); |
} |
|
|
|
589,36 → 677,39
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 ("\nSimulation parameters\n"); |
#if(DEBUG_EN) |
printf ("\tDebuging is enabled\n"); |
printf ("\tDebuging is enabled\n"); |
#else |
printf ("\tDebuging is disabled\n"); |
printf ("\tDebuging is disabled\n"); |
#endif |
|
printf ("Simulation parameters\n"); |
if(strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)printf ("\tOutput is the average latency on sending the packet head until receiving tail\n"); |
else printf ("\tOutput is the average latency on sending the packet head until receiving the head\n"); |
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); |
if(C>0) printf ("\ttraffic percentage of class 0 is : %d\n", C0_p); |
if(C>1) printf ("\ttraffic percentage of class 1 is : %d\n", C1_p); |
if(C>2) printf ("\ttraffic percentage of class 2 is : %d\n", C2_p); |
if(C>3) printf ("\ttraffic percentage of class 3 is : %d\n", C3_p); |
if((strcmp (TRAFFIC,"HOTSPOT")==0)|| (strcmp (TRAFFIC,"hot spot")==0)){ |
printf ("\tHot spot percentage: %u\n", HOTSPOT_PERCENTAGE); |
if(strcmp (TRAFFIC,"HOTSPOT")==0){ |
//printf ("\tHot spot percentage: %u\n", HOTSPOT_PERCENTAGE); |
printf ("\tNumber of hot spot cores: %d\n", HOTSPOT_NUM); |
|
} |
//printf ("\tTotal packets sent by one router: %u\n", TOTAL_PKT_PER_ROUTER); |
printf ("\t Simulation timeout =%d\n", MAX_SIM_CLKs); |
printf ("\t Simulation ends on total packet num of =%d\n", MAX_PCK_NUM); |
printf ("\tPacket size: %u flits\n",PACKET_SIZE); |
printf ("\t SSA_EN enabled:%s \n",SSA_EN); |
printf ("\tSimulation timeout =%d\n", MAX_SIM_CLKs); |
printf ("\tSimulation ends on total packet num of =%d\n", MAX_PCK_NUM); |
printf ("\tPacket size (min,max,average) in flits: (%u,%u,%u)\n",MIN_PACKET_SIZE,MAX_PACKET_SIZE,PACKET_SIZE); |
printf ("\tPacket injector FIFO width in flit:%u \n",TIMSTMP_FIFO_NUM); |
} |
|
|
|
|
|
/************************ |
* |
* reset system |
707,6 → 798,7
return pck_class_in; |
} |
|
|
/********************************** |
|
pck_dst_gen |
713,7 → 805,10
|
*********************************/ |
|
void pck_dst_gen ( |
|
|
|
void pck_dst_gen_2D ( |
unsigned int current_x, |
unsigned int current_y, |
unsigned int core_num, |
722,15 → 817,17
){ |
|
|
unsigned int rnd=0; |
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; |
rnd=rand()%nc; |
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core |
|
(*dest_y) = (rnd / NX ); |
738,26 → 835,42
|
|
} |
|
else if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){ |
|
unsigned int rnd1000=0; |
int i; |
|
|
do{ |
rnd=rand()%NC; |
rnd=rand()%nc; |
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core |
|
rnd100=rand()%100; |
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; |
|
if (rnd100 < HOTSPOT_PERCENTAGE && core_num !=HOTSPOT_CORE_1 ) rnd = HOTSPOT_CORE_1; |
else if((HOTSPOT_NUM > 1) && (rnd100 >= 20 ) && (rnd100 < (20+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_2 ) rnd = HOTSPOT_CORE_2; |
else if((HOTSPOT_NUM > 2) && (rnd100 >= 40) && (rnd100 < (40+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_3 ) rnd = HOTSPOT_CORE_3; |
else if((HOTSPOT_NUM > 3) && (rnd100 >= 60) && (rnd100 < (60+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_4 ) rnd = HOTSPOT_CORE_4; |
else if((HOTSPOT_NUM > 4) && (rnd100 >= 80) && (rnd100 < (80+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_5 ) rnd = HOTSPOT_CORE_5; |
|
|
|
(*dest_y) = (rnd / NX ); |
(*dest_x) = (rnd % NX ); |
|
|
} else if(( strcmp(TRAFFIC ,"TRANSPOSE1")==0)|| (strcmp (TRAFFIC,"transposed 1")==0)){ |
|
(*dest_x) = NX-current_y-1; |
770,6 → 883,7
(*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; |
791,7 → 905,7
(*dest_y) = (~current_y) &(0xFF>> (8-Yw)); |
|
|
} else if(( strcmp(TRAFFIC ,"TORNADO") == 0)|| (strcmp (TRAFFIC,"tornado")==0)){ |
} 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); |
802,7 → 916,7
if(current_x ==0 && current_y == 0 ){ |
(*dest_x) = NX-1; |
(*dest_y) = NY-1; |
}else{// make it unvalid |
}else{// make it invalid |
(*dest_x) = current_x; |
(*dest_y) = current_y; |
|
810,22 → 924,282
|
} |
|
else printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC); |
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){ |
//printf("before%u=%u\n",src,random_var[src]); |
random_var[src]= rnd_between(100-injct_var, 100+injct_var); |
//printf("after=%u\n",random_var[src]); |
} |
|
unsigned int pck_dst_gen_task_graph ( unsigned int src){ |
task_t task; |
float f,v; |
|
|
|
|
int index = task_graph_abstract[src].active_index; |
|
if(index == DISABLE){ |
traffic[src]->ratio=0; |
traffic[src]->stop=1; |
return src; //disable sending |
} |
|
if( read(task_graph_data[src],index,&task)==0){ |
traffic[src]->ratio=0; |
traffic[src]->stop=1; |
return src; //disable sending |
|
} |
|
if(sent_core_total_pck_num[src] & 0xFF){//sent 255 packets |
//printf("uu=%u\n",task.jnjct_var); |
update_injct_var(src, task.jnjct_var); |
|
} |
|
task_graph_total_pck_num++; |
task.pck_sent = task.pck_sent +1; |
task.burst_sent= task.burst_sent+1; |
task.byte_sent = task.byte_sent + (task.avg_pck_size * (Fpay/8) ); |
|
traffic[src]->pck_class_in= pck_class_in_gen(src); |
traffic[src]->avg_pck_size_in=task.avg_pck_size; |
traffic[src]->pck_size_in=rnd_between(task.min_pck_size,task.max_pck_size); |
|
f= task.injection_rate; |
v= random_var[src]; |
f*= (v /100); |
if(f>100) f= 100; |
f= f * MAX_RATIO / 100; |
|
traffic[src]->ratio=(unsigned int)f; |
traffic[src]->init_weight=task.initial_weight; |
|
|
|
|
if (task.burst_sent >= task.burst_size){ |
task.burst_sent=0; |
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; |
|
} |
|
|
update_by_index(task_graph_data[src],index,task); |
|
if (task.byte_sent >= task.bytes){ // This task is done remove it from the queue |
remove_by_index(&task_graph_data[src],index); |
task_graph_abstract[src].total_index = task_graph_abstract[src].total_index-1; |
if(task_graph_abstract[src].total_index==0){ //all tasks are done turned off the core |
task_graph_abstract[src].active_index=-1; |
traffic[src]->ratio=0; |
traffic[src]->stop=1; |
if(total_active_routers!=0) total_active_routers--; |
return src; |
} |
if(task_graph_abstract[src].active_index>=task_graph_abstract[src].total_index) task_graph_abstract[src].active_index=0; |
} |
|
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); |
|
} |
|
|
|
|
/testbench.cpp
151,11 → 151,13
traffic[i]->current_y = y; |
traffic[i]->start=0; |
traffic[i]->pck_size_in=PACKET_SIZE; |
traffic[i]->avg_pck_size_in=PACKET_SIZE; |
traffic[i]->ratio=ratio; |
traffic[i]->pck_class_in= pck_class_in_gen( i); |
pck_dst_gen ( x,y,i, &dest_x, &dest_y); |
traffic[i]->dest_x= dest_x; |
traffic[i]->dest_y=dest_y; |
traffic[i]->stop=0; |
|
} |
|
483,16 → 485,18
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 ("Simulation parameters\n"); |
#if(DEBUG_EN) |
printf ("\tDebuging is enabled\n"); |
#else |
printf ("\tDebuging is disabled\n"); |
#endif |
|
printf ("Simulation parameters\n"); |
if(strcmp (AVG_LATENCY_METRIC,"HEAD_2_TAIL")==0)printf ("\tOutput is the average latency on sending the packet head until receiving tail\n"); |
else printf ("\tOutput is the average latency on sending the packet head until receiving the head\n"); |
printf ("\tTraffic pattern:%s\n",TRAFFIC); |
506,10 → 510,11
|
} |
//printf ("\tTotal packets sent by one router: %u\n", TOTAL_PKT_PER_ROUTER); |
printf ("\t Simulation timeout =%d\n", MAX_SIM_CLKs); |
printf ("\t Simulation ends on total packet num of =%d\n", MAX_PCK_NUM); |
printf ("\tSimulation timeout =%d\n", MAX_SIM_CLKs); |
printf ("\tSimulation ends on total packet num of =%d\n", MAX_PCK_NUM); |
printf ("\tPacket size: %u flits\n",PACKET_SIZE); |
printf ("\t SSA_EN enabled:%s \n",SSA_EN); |
printf ("\tPacket injector FIFO width in flit:%u \n",TIMSTMP_FIFO_NUM); |
|
} |
|
|
620,7 → 625,10
|
*********************************/ |
|
void pck_dst_gen ( |
|
|
|
void pck_dst_gen_2D ( |
unsigned int current_x, |
unsigned int current_y, |
unsigned int core_num, |
724,15 → 732,136
|
|
|
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; |
int i; |
|
|
if(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 ); |
|
|
} |
else if (strcmp(TRAFFIC,"HOTSPOT")==0) { |
|
do{ |
rnd=rand()%nc; |
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core |
|
rnd100=rand()%100; |
|
if (rnd100 < HOTSPOT_PERCENTAGE && core_num !=HOTSPOT_CORE_1 ) rnd = HOTSPOT_CORE_1; |
else if((HOTSOPT_NUM > 1) && (rnd100 >= 20 ) && (rnd100 < (20+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_2 ) rnd = HOTSPOT_CORE_2; |
else if((HOTSOPT_NUM > 2) && (rnd100 >= 40) && (rnd100 < (40+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_3 ) rnd = HOTSPOT_CORE_3; |
else if((HOTSOPT_NUM > 3) && (rnd100 >= 60) && (rnd100 < (60+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_4 ) rnd = HOTSPOT_CORE_4; |
else if((HOTSOPT_NUM > 4) && (rnd100 >= 80) && (rnd100 < (80+HOTSPOT_PERCENTAGE)) && core_num!=HOTSPOT_CORE_5 ) rnd = HOTSPOT_CORE_5; |
|
|
|
// (*dest_y) = (rnd / NX ); |
(*dest_x) = (rnd % NX ); |
|
|
} else if( strcmp(TRAFFIC ,"TRANSPOSE1")==0){ |
|
(*dest_x) = NX-current_x-1; |
// (*dest_y) = NY-current_x-1; |
|
|
|
// } else if( strcmp(TRAFFIC ,"TRANSPOSE2")==0){ |
// (*dest_x) = current_y; |
// (*dest_y) = current_x; |
|
|
} else if( 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; |
|
} else if( 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){ |
//[(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 ){ |
(*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); |
|
} |
|
|
|
|
|
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((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)){ |
pck_dst_gen_2D ( |
current_x, |
current_y, |
core_num, |
dest_x, |
dest_y |
); |
} |
else { |
dest_y=0; |
pck_dst_gen_1D ( |
current_x, |
core_num, |
dest_x |
); |
|
} |
} |
|
|
|
|
|
|
|
|
/traffic_gen_verilator.v
8,14 → 8,17
module traffic_gen_verilator ( |
//input |
ratio, |
pck_size_in, |
avg_pck_size_in, |
pck_size_in, |
current_x, |
current_y, |
dest_x, |
dest_y, |
pck_class_in, |
start, |
report, |
start, |
stop, |
report, |
init_weight, |
//output |
pck_number, |
sent_done, // tail flit has been sent |
22,6 → 25,8
hdr_flit_sent, |
update, // update the noc_analayzer |
distance, |
src_x, |
src_y, |
pck_class_out, |
time_stamp_h2h, |
time_stamp_h2t, |
59,14 → 64,20
|
|
|
localparam Xw = log2(NX), // number of node in x axis |
Yw = log2(NY), // number of node in y axis |
Cw = (C > 1)? log2(C): 1, |
Fw = 2+V+Fpay, |
RATIOw = log2(100), |
PCK_CNTw = log2(MAX_PCK_NUM+1), |
CLK_CNTw = log2(MAX_SIM_CLKs+1), |
PCK_SIZw = log2(MAX_PCK_SIZ+1); |
localparam |
Xw = log2(NX), // number of node in x axis |
Yw = log2(NY), // number of node in y axis |
Cw = (C > 1)? log2(C): 1, |
Fw = 2+V+Fpay, |
RATIOw = log2(MAX_RATIO), |
PCK_CNTw = log2(MAX_PCK_NUM+1), |
CLK_CNTw = log2(MAX_SIM_CLKs+1), |
PCK_SIZw = log2(MAX_PCK_SIZ+1), |
/* verilator lint_off WIDTH */ |
NC = (TOPOLOGY=="RING" || TOPOLOGY=="LINE")? NX : NX*NY, //number of cores |
/* verilator lint_on WIDTH */ |
DSTw = log2(NC+1), |
W = WEIGHTw; |
|
|
|
73,10 → 84,13
|
input reset, clk; |
input [RATIOw-1 :0] ratio; |
input start; |
input start,stop; |
output update; |
output [CLK_CNTw-1 :0] time_stamp_h2h,time_stamp_h2t; |
output [31 :0] distance; |
output [DSTw-1 :0] distance; |
output [Xw-1 : 0] src_x; |
output [Yw-1 : 0] src_y; |
|
output [Cw-1 :0] pck_class_out; |
input [Xw-1 :0] current_x; |
input [Yw-1 :0] current_y; |
84,10 → 98,13
input [Yw-1 :0] dest_y; |
output [PCK_CNTw-1 :0] pck_number; |
input [PCK_SIZw-1 :0] pck_size_in; |
input [PCK_SIZw-1 :0] avg_pck_size_in; |
output sent_done; |
output hdr_flit_sent; |
input [Cw-1 :0] pck_class_in; |
input [W-1 :0] init_weight; |
|
|
// NOC interfaces |
output [Fw-1 :0] flit_out; |
output flit_out_wr; |
96,8 → 113,8
input flit_in_wr; |
output [V-1 :0] credit_out; |
input report; |
|
|
|
|
traffic_gen #( |
.V(V), |
112,12 → 129,15
.MAX_PCK_NUM(MAX_PCK_NUM), |
.MAX_SIM_CLKs(MAX_SIM_CLKs), |
.MAX_PCK_SIZ(MAX_PCK_SIZ), |
.TIMSTMP_FIFO_NUM(TIMSTMP_FIFO_NUM) |
.TIMSTMP_FIFO_NUM(TIMSTMP_FIFO_NUM), |
.MAX_RATIO(MAX_RATIO), |
.WEIGHTw(WEIGHTw) |
) |
the_traffic_gen |
( |
//input |
.ratio (ratio), |
.avg_pck_size_in(avg_pck_size_in), |
.pck_size_in(pck_size_in), |
.current_x(current_x), |
.current_y(current_y), |
125,7 → 145,9
.dest_y(dest_y), |
.pck_class_in(pck_class_in), |
.start(start), |
.stop(stop), |
.report (report), |
.init_weight(init_weight), |
//output |
.pck_number(pck_number), |
.sent_done(sent_done), // tail flit has been sent |
132,6 → 154,8
.hdr_flit_sent(hdr_flit_sent), |
.update(update), // update the noc_analayzer |
.distance(distance), |
.src_x(src_x), |
.src_y(src_y), |
.pck_class_out(pck_class_out), |
.time_stamp_h2h(time_stamp_h2h), |
.time_stamp_h2t(time_stamp_h2t), |
/traffic_task_graph.h
0,0 → 1,280
|
|
#ifndef TRAFFIC_TASK_GRAPH_H |
#define TRAFFIC_TASK_GRAPH_H |
|
|
#define SET_AUTO -1 |
|
|
|
#define MAX_LINE_LEN 1000 |
#define DEAFULT_INIT_WEIGHT 1 |
#define DEAFULT_MIN_PCK_SIZE 8 // must be larger than 1 |
|
|
|
typedef struct INDEX_INFO{ |
unsigned int active_index; |
unsigned int total_index; |
} index_t; |
|
|
|
typedef struct TRAFFIC_TASK { |
char enable; |
unsigned int src; |
unsigned int dst; // ID of the destination node (PE) |
unsigned int bytes; |
unsigned int initial_weight; |
unsigned int min_pck_size; //in flit |
unsigned int max_pck_size; //in flit |
|
unsigned int avg_pck_size; //in flit |
unsigned int estimated_total_pck_num; |
unsigned int burst_size; |
float injection_rate; |
unsigned int jnjct_var; |
|
unsigned int pck_sent; |
unsigned int byte_sent; |
unsigned int burst_sent; |
} task_t; |
|
|
|
typedef struct node { |
task_t task; |
struct node * next; |
} node_t; |
|
|
|
unsigned int total_active_routers=0; |
unsigned int task_graph_total_pck_num=0; |
node_t * task_graph_data[NC]; |
index_t task_graph_abstract[NC]; |
|
|
|
|
void push(node_t ** head, task_t task) { |
node_t * new_node; |
new_node = (node_t *) malloc(sizeof(node_t)); |
if( new_node == NULL){ |
printf("Error: cannot allocate memory in push function\n"); |
exit(1); |
} |
new_node->task=task; |
new_node->next = *head; |
*head = new_node; |
} |
|
int pop(node_t ** head) { |
// int retval = -1; |
node_t * next_node = NULL; |
|
if (*head == NULL) { |
return -1; |
} |
|
next_node = (*head)->next; |
//retval = (*head)->val; |
free(*head); |
*head = next_node; |
return 1; |
//return retval; |
} |
|
|
int remove_by_index(node_t ** head, int n) { |
int i = 0; |
// int retval = -1; |
node_t * current = *head; |
node_t * temp_node = NULL; |
|
if (n == 0) { |
return pop(head); |
} |
|
for (i = 0; i < n-1; i++) { |
if (current->next == NULL) { |
return -1; |
} |
current = current->next; |
} |
|
temp_node = current->next; |
//retval = temp_node->val; |
current->next = temp_node->next; |
free(temp_node); |
return 1; |
|
} |
|
|
int update_by_index(node_t * head,int loc, task_t task) { |
node_t * current = head; |
int i; |
for (i=0;i<loc && current != NULL;i++){ |
current = current->next; |
|
} |
if(current == NULL) return 0; |
current->task=task; |
return 1; |
|
} |
|
|
int read(node_t * head, int loc, task_t * task ) { |
node_t * current = head; |
int i; |
for (i=0;i<loc && current != NULL;i++){ |
current = current->next; |
|
} |
if(current == NULL) return 0; |
*task = current->task; |
return 1; |
} |
|
|
char* removewhiteSpacses (char * oldstr ) { |
char *newstr = (char*) malloc(strlen(oldstr)+1); |
char *np = newstr, *op = oldstr; |
do { |
if (*op != ' ' && *op != '\t') |
*np++ = *op; |
} while (*op++); |
return newstr; |
} |
|
|
int extract_traffic_data ( char * str, task_t* st) |
{ |
|
unsigned int src; |
unsigned int dst; // ID of the destination node (PE) |
unsigned int bytes; |
unsigned int initial_weight; |
unsigned int min_pck_size; //in flit |
unsigned int max_pck_size; //in flit |
unsigned int burst; |
float inject_rate; |
int jnjct_var; |
|
int n; |
n=sscanf( str, "%u,%u,%u,%u,%u,%u,%u,%f,%u",&src, &dst, &bytes, &initial_weight, &min_pck_size, &max_pck_size,&burst,&inject_rate,&jnjct_var); |
|
if (n<3) return 0; |
|
st->src = src; |
st->dst=dst; |
st->bytes=bytes; |
st->initial_weight=(n>3 && initial_weight >0 )? initial_weight :DEAFULT_INIT_WEIGHT; |
st->min_pck_size= (n>4 && min_pck_size>1 )? min_pck_size : DEAFULT_MIN_PCK_SIZE; |
st->max_pck_size= (n>5 && max_pck_size >= st->min_pck_size )? max_pck_size : st->min_pck_size; |
st->burst_size = (n>6 )? burst : SET_AUTO; |
st->injection_rate= (n>7 )? inject_rate : SET_AUTO; |
st->jnjct_var= (n>8 )? jnjct_var : 20; |
// |
st->avg_pck_size= (st->min_pck_size + st->max_pck_size)/2; |
st->estimated_total_pck_num = (bytes*8) /(st->avg_pck_size*Fpay); |
if(st->estimated_total_pck_num==0) st->estimated_total_pck_num= 1; |
task_graph_total_pck_num=task_graph_total_pck_num+st->estimated_total_pck_num; |
|
st->pck_sent=0; |
st->byte_sent=0; |
st->burst_sent=0; |
|
return 1; |
} |
|
int calcualte_traffic_parameters(node_t * head[NC],index_t (* info)){ |
int i,j; |
task_t task; |
|
unsigned int max_bytes=0,accum[NC]; |
unsigned int min_total[NC]; |
|
//find the maximum bytes that an IP sends |
for(i=0;i<NC;i++){ |
|
info[i].active_index=-1; |
j=0; |
accum[i]=0; |
if(head[i]!=NULL){ |
info[i].active_index=0; |
|
min_total[i] = -1; |
while( read(head[i],j,&task)==1){ |
accum[i]=accum[i]+task.bytes; |
if( min_total[i] > task.estimated_total_pck_num) min_total[i] = task.estimated_total_pck_num; |
j++; |
} |
info[i].total_index=j; |
if(max_bytes < accum[i]) max_bytes=accum[i]; |
} |
|
} |
|
|
for(i=0;i<NC;i++){ |
|
j=0; |
if(head[i]!=NULL){ |
while( read(head[i],j,&task)==1){ |
if(task.burst_size ==SET_AUTO) task.burst_size = task.estimated_total_pck_num/min_total[i]; |
if(task.injection_rate ==SET_AUTO) task.injection_rate= (float)(200*accum[i] / (3*max_bytes)); |
|
update_by_index(head[i],j,task); |
j++; |
} |
} |
} |
return 0; |
} |
|
|
|
|
|
void load_traffic_file(char * file, node_t * head[NC], index_t (* info)){ |
FILE * in; |
char * line = NULL; |
|
task_t st; |
char l[MAX_LINE_LEN]; |
in = fopen(file,"rb"); |
int n,i; |
|
if(in == NULL){ |
printf("Error: cannot open %s file in read mode!\n",file); |
exit(1); |
} |
|
for(i=0;i<NC;i++){ |
head[i]=NULL; |
} |
|
|
while (fgets(l,MAX_LINE_LEN, in) != NULL) { |
line = removewhiteSpacses(l); |
if(line[0] != '%' && line[0] != 0 ) { |
n=extract_traffic_data(line, &st); |
if(n==0 || st.dst >=NC) continue;// the destination address must be smaller than NC |
push(&head[st.src],st); |
} |
} |
fclose(in); |
calcualte_traffic_parameters(head,info); |
for(i=0;i<NC;i++){ |
if(info[i].total_index !=0) total_active_routers++; |
} |
} |
|
|
|
|
#endif |
traffic_task_graph.h
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property