OpenCores
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 42 to Rev 43
    Reverse comparison

Rev 42 → Rev 43

/parameter.v File deleted \ No newline at end of file
/parameter.h File deleted
/testbench.cpp File deleted
testbench.cpp Property changes : Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: fattree_noc_connection.sv =================================================================== --- fattree_noc_connection.sv (nonexistent) +++ fattree_noc_connection.sv (revision 43) @@ -0,0 +1,217 @@ +`timescale 1ns/1ps + +module fattree_noc_connection ( + clk, + reset, + start_i, + start_o, + router_flit_out_all, + router_flit_out_we_all, + router_credit_in_all, + router_credit_out_all, + router_flit_in_all, + router_flit_in_we_all, + router_congestion_in_all, + router_congestion_out_all, + + ni_flit_in, + ni_flit_in_wr, + ni_credit_out, + ni_flit_out, + ni_flit_out_wr, + ni_credit_in, + er_addr, + current_r_addr, + neighbors_r_all +); + + + `define INCLUDE_PARAM + `include"parameter.v" + + `define INCLUDE_TOPOLOGY_LOCALPARAM + `include "topology_localparam.v" + + + + localparam CONGw= (CONGESTION_INDEX==3)? 3: + (CONGESTION_INDEX==5)? 3: + (CONGESTION_INDEX==7)? 3: + (CONGESTION_INDEX==9)? 3: + (CONGESTION_INDEX==10)? 4: + (CONGESTION_INDEX==12)? 3:2; + + + + function integer addrencode; + input integer pos,k,n,kw; + integer pow,i,tmp;begin + addrencode=0; + pow=1; + for (i = 0; i
fattree_noc_connection.sv Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: mesh_torus_noc_connection.sv =================================================================== --- mesh_torus_noc_connection.sv (nonexistent) +++ mesh_torus_noc_connection.sv (revision 43) @@ -0,0 +1,433 @@ + +// synthesis translate_off +`timescale 1ns / 1ps +// synthesis translate_on + + +/********************************************************************** +** File: mesh_torus_noc.v +** +** Copyright (C) 2014-2017 Alireza Monemi +** +** This file is part of ProNoC +** +** ProNoC ( stands for Prototype Network-on-chip) is free software: +** you can redistribute it and/or modify it under the terms of the GNU +** Lesser General Public License as published by the Free Software Foundation, +** either version 2 of the License, or (at your option) any later version. +** +** ProNoC is distributed in the hope that it will be useful, but WITHOUT +** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General +** Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public +** License along with ProNoC. If not, see . +** +** +** Description: +** the NoC top module. It generate one of the mesh, torus, ring, or line topologies by +** connecting routers +** +**************************************************************/ + + + + +`define START_LOC(port_num,width) (width*(port_num+1)-1) +`define END_LOC(port_num,width) (width*port_num) +`define router_id(x,y) ((y * NX) + x) +`define endp_id(x,y,l) ((y * NX) + x) * NL + l +`define SELECT_WIRE(x,y,port,width) `router_id(x,y)] [`START_LOC(port,width) : `END_LOC(port,width ) + + +module mesh_torus_noc_connection ( + + reset, + clk, + router_flit_out_all, + router_flit_out_we_all, + router_credit_in_all, + + router_flit_in_all, + router_flit_in_we_all, + router_credit_out_all, + router_congestion_in_all, + router_congestion_out_all, + + ni_flit_in, + ni_flit_in_wr, + ni_credit_out, + ni_flit_out, + ni_flit_out_wr, + ni_credit_in, + start_i, + er_addr, + current_r_addr, + start_o + +); + + + + + + `define INCLUDE_PARAM + `include"parameter.v" + + `define INCLUDE_TOPOLOGY_LOCALPARAM + `include "topology_localparam.v" + + + localparam CONGw= (CONGESTION_INDEX==3)? 3: + (CONGESTION_INDEX==5)? 3: + (CONGESTION_INDEX==7)? 3: + (CONGESTION_INDEX==9)? 3: + (CONGESTION_INDEX==10)? 4: + (CONGESTION_INDEX==12)? 3:2; + + + localparam + PV = V * MAX_P, + Fw = 2+V+Fpay, //flit width; + PFw = MAX_P * Fw, + NEFw = NE * Fw, + NEV = NE * V, + CONG_ALw = CONGw * MAX_P; // congestion width per router + + + + input reset,clk; + + + + + + output [PFw-1 : 0] router_flit_out_all [NR-1 :0]; + output [MAX_P-1 : 0] router_flit_out_we_all [NR-1 :0]; + input [PV-1 : 0] router_credit_in_all [NR-1 :0]; + + input [PFw-1 : 0] router_flit_in_all [NR-1 :0]; + input [MAX_P-1 : 0] router_flit_in_we_all [NR-1 :0]; + output [PV-1 : 0] router_credit_out_all [NR-1 :0]; + input [CONG_ALw-1: 0] router_congestion_in_all[NR-1 :0]; + output [CONG_ALw-1: 0] router_congestion_out_all [NR-1 :0]; + + + input [Fw-1 : 0] ni_flit_in [NE-1 :0]; + input [NE-1 : 0] ni_flit_in_wr; + output [V-1 : 0] ni_credit_out [NE-1 :0]; + output [Fw-1 : 0] ni_flit_out [NE-1 :0]; + output [NE-1 : 0] ni_flit_out_wr; + input [V-1 : 0] ni_credit_in [NE-1 :0]; + + + input start_i; + + output [RAw-1 : 0] er_addr [NE-1 : 0]; + output [RAw-1 : 0] current_r_addr [NR-1 : 0]; + + + output [NE-1 : 0] start_o; + + // mesh torus + localparam + EAST = 1, + NORTH = 2, + WEST = 3, + SOUTH = 4; + //ring line + localparam + FORWARD = 1, + BACKWARD= 2; + + +genvar x,y,l; +generate + /* verilator lint_off WIDTH */ + if( TOPOLOGY == "RING" || TOPOLOGY == "LINE") begin : ring_line + /* verilator lint_on WIDTH */ + for (x=0; x0)begin :not_first_x + assign router_flit_out_all [`SELECT_WIRE(x,0,BACKWARD,Fw)] = router_flit_in_all [`SELECT_WIRE((x-1),0,FORWARD,Fw)]; + assign router_credit_out_all [`SELECT_WIRE(x,0,BACKWARD,V)] = router_credit_in_all [`SELECT_WIRE((x-1),0,FORWARD,V)] ; + assign router_flit_out_we_all [x][BACKWARD] = router_flit_in_we_all [`router_id((x-1),0)][FORWARD]; + assign router_congestion_out_all[`SELECT_WIRE(x,0,BACKWARD,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x-1),0,FORWARD,CONGw)]; + 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,BACKWARD,Fw)] = {Fw{1'b0}}; + assign router_credit_out_all [`SELECT_WIRE(x,0,BACKWARD,V)] = {V{1'b0}}; + assign router_flit_out_we_all [x][BACKWARD] = 1'b0; + assign router_congestion_out_all[`SELECT_WIRE(x,0,BACKWARD,CONGw)] = {CONGw{1'b0}}; + end else begin : ring_first_x + assign router_flit_out_all [`SELECT_WIRE(x,0,BACKWARD,Fw)] = router_flit_in_all [`SELECT_WIRE((NX-1),0,FORWARD,Fw)] ; + assign router_credit_out_all [`SELECT_WIRE(x,0,BACKWARD,V)] = router_credit_in_all [`SELECT_WIRE((NX-1),0,FORWARD,V)] ; + assign router_flit_out_we_all [x][BACKWARD] = router_flit_in_we_all [`router_id((NX-1),0)][FORWARD]; + assign router_congestion_out_all[`SELECT_WIRE(x,0,BACKWARD,CONGw)] = router_congestion_in_all [`SELECT_WIRE((NX-1),0,FORWARD,CONGw)]; + end + end + + // connect local ports + for (l=0; l0) begin : not_first_y + assign router_flit_out_all [`SELECT_WIRE(x,y,NORTH,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(y-1),SOUTH,Fw)]; + assign router_credit_out_all [`SELECT_WIRE(x,y,NORTH,V)] = router_credit_in_all [`SELECT_WIRE(x,(y-1),SOUTH,V)]; + assign router_flit_out_we_all [`router_id(x,y)][NORTH] = router_flit_in_we_all [`router_id(x,(y-1))][SOUTH]; + assign router_congestion_out_all [`SELECT_WIRE(x,y,NORTH,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(y-1),SOUTH,CONGw)]; + end else begin :first_y + /* verilator lint_off WIDTH */ + if(TOPOLOGY == "MESH") begin : first_y_mesh + /* verilator lint_on WIDTH */ + assign router_flit_out_all [`SELECT_WIRE(x,y,NORTH,Fw)] = {Fw{1'b0}}; + assign router_credit_out_all [`SELECT_WIRE(x,y,NORTH,V)] = {V{1'b0}}; + assign router_flit_out_we_all [`router_id(x,y)][NORTH] = 1'b0; + assign router_congestion_out_all [`SELECT_WIRE(x,y,NORTH,CONGw)] = {CONGw{1'b0}}; + /* verilator lint_off WIDTH */ + end else if(TOPOLOGY == "TORUS") begin :first_y_torus + /* verilator lint_on WIDTH */ + assign router_flit_out_all [`SELECT_WIRE(x,y,NORTH,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(NY-1),SOUTH,Fw)]; + assign router_credit_out_all [`SELECT_WIRE(x,y,NORTH,V)] = router_credit_in_all [`SELECT_WIRE(x,(NY-1),SOUTH,V)]; + assign router_flit_out_we_all [`router_id(x,y)][NORTH] = router_flit_in_we_all [`router_id(x,(NY-1))][SOUTH]; + assign router_congestion_out_all [`SELECT_WIRE(x,y,NORTH,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(NY-1),SOUTH,CONGw)]; + end//topology + end//y>0 + + + if(x>0)begin :not_first_x + assign router_flit_out_all [`SELECT_WIRE(x,y,WEST,Fw)] = router_flit_in_all [`SELECT_WIRE((x-1),y,EAST,Fw)] ; + assign router_credit_out_all [`SELECT_WIRE(x,y,WEST,V)] = router_credit_in_all [`SELECT_WIRE((x-1),y,EAST,V)] ; + assign router_flit_out_we_all [`router_id(x,y)][WEST] = router_flit_in_we_all [`router_id((x-1),y)][EAST]; + assign router_congestion_out_all [`SELECT_WIRE(x,y,WEST,CONGw)] = router_congestion_in_all [`SELECT_WIRE((x-1),y,EAST,CONGw)]; + end else begin :first_x + /* verilator lint_off WIDTH */ + if(TOPOLOGY == "MESH") begin :first_x_mesh + /* verilator lint_on WIDTH */ + assign router_flit_out_all [`SELECT_WIRE(x,y,WEST,Fw)] = {Fw{1'b0}}; + assign router_credit_out_all [`SELECT_WIRE(x,y,WEST,V)] = {V{1'b0}}; + assign router_flit_out_we_all [`router_id(x,y)][WEST] = 1'b0; + assign router_congestion_out_all [`SELECT_WIRE(x,y,WEST,CONGw)] = {CONGw{1'b0}}; + /* verilator lint_off WIDTH */ + end else if(TOPOLOGY == "TORUS") begin :first_x_torus + /* verilator lint_on WIDTH */ + assign router_flit_out_all [`SELECT_WIRE(x,y,WEST,Fw)] = router_flit_in_all [`SELECT_WIRE((NX-1),y,EAST,Fw)] ; + assign router_credit_out_all [`SELECT_WIRE(x,y,WEST,V)] = router_credit_in_all [`SELECT_WIRE((NX-1),y,EAST,V)] ; + assign router_flit_out_we_all [`router_id(x,y)][WEST] = router_flit_in_we_all [`router_id((NX-1),y)][EAST]; + assign router_congestion_out_all [`SELECT_WIRE(x,y,WEST,CONGw)] = router_congestion_in_all [`SELECT_WIRE((NX-1),y,EAST,CONGw)]; + end//topology + end + + if(y < NY-1) begin : firsty + assign router_flit_out_all [`SELECT_WIRE(x,y,SOUTH,Fw)] = router_flit_in_all [`SELECT_WIRE(x,(y+1),NORTH,Fw)]; + assign router_credit_out_all [`SELECT_WIRE(x,y,SOUTH,V)] = router_credit_in_all [`SELECT_WIRE(x,(y+1),NORTH,V)]; + assign router_flit_out_we_all [`router_id(x,y)][SOUTH] = router_flit_in_we_all [`router_id(x,(y+1))][NORTH]; + assign router_congestion_out_all [`SELECT_WIRE(x,y,SOUTH,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,(y+1),NORTH,CONGw)]; + end else begin : lasty + /* verilator lint_off WIDTH */ + if(TOPOLOGY == "MESH") begin :ly_mesh + /* 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 [`router_id(x,y)][4] = 1'b0; + assign router_congestion_out_all [`SELECT_WIRE(x,y,4,CONGw)] = {CONGw{1'b0}}; + /* verilator lint_off WIDTH */ + end else if(TOPOLOGY == "TORUS") begin :ly_torus + /* verilator lint_on WIDTH */ + assign router_flit_out_all [`SELECT_WIRE(x,y,SOUTH,Fw)] = router_flit_in_all [`SELECT_WIRE(x,0,NORTH,Fw)]; + assign router_credit_out_all [`SELECT_WIRE(x,y,SOUTH,V)] = router_credit_in_all [`SELECT_WIRE(x,0,NORTH,V)]; + assign router_flit_out_we_all [`router_id(x,y)][SOUTH] = router_flit_in_we_all [`router_id(x,0)][NORTH]; + assign router_congestion_out_all [`SELECT_WIRE(x,y,SOUTH,CONGw)] = router_congestion_in_all [`SELECT_WIRE(x,0,NORTH,CONGw)]; + end//topology + end + + + // endpoint(s) connection + // connect local ports + for (l=0; l
mesh_torus_noc_connection.sv Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: noc_connection.sv =================================================================== --- noc_connection.sv (revision 42) +++ noc_connection.sv (revision 43) @@ -1,11 +1,6 @@ `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 ) - module noc_connection ( /* @@ -37,32 +32,22 @@ ni_credit_out, ni_flit_out, ni_flit_out_wr, - ni_credit_in - + ni_credit_in, + er_addr,// endpoints connected to each router + current_r_addr, + neighbors_r_addr ); - function integer log2; - input integer number; begin - log2=(number <=1) ? 1: 0; - while(2**log20)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 - - 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 + + fattree_noc_connection connections + ( + .clk(clk), + .reset(reset), + .start_i(start_i), + .start_o(start_o), + .router_flit_out_all(router_flit_out_all), + .router_flit_out_we_all(router_flit_out_we_all), + .router_credit_in_all(router_credit_in_all), + .router_credit_out_all(router_credit_out_all), + .router_flit_in_all(router_flit_in_all), + .router_flit_in_we_all(router_flit_in_we_all), + .router_congestion_in_all(router_congestion_in_all), + .router_congestion_out_all(router_congestion_out_all), + .ni_flit_in(ni_flit_in), + .ni_flit_in_wr(ni_flit_in_wr), + .ni_credit_out(ni_credit_out), + .ni_flit_out(ni_flit_out), + .ni_flit_out_wr(ni_flit_out_wr), + .ni_credit_in(ni_credit_in), + .er_addr(er_addr), + .current_r_addr(current_r_addr), + .neighbors_r_all(neighbors_r_addr) + ); + /* verilator lint_off WIDTH */ + end else if( TOPOLOGY == "TREE") begin : fat + /* verilator lint_on WIDTH */ + + tree_noc_connection connections + ( + .clk(clk), + .reset(reset), + .start_i(start_i), + .start_o(start_o), + .router_flit_out_all(router_flit_out_all), + .router_flit_out_we_all(router_flit_out_we_all), + .router_credit_in_all(router_credit_in_all), + .router_credit_out_all(router_credit_out_all), + .router_flit_in_all(router_flit_in_all), + .router_flit_in_we_all(router_flit_in_we_all), + .router_congestion_in_all(router_congestion_in_all), + .router_congestion_out_all(router_congestion_out_all), + .ni_flit_in(ni_flit_in), + .ni_flit_in_wr(ni_flit_in_wr), + .ni_credit_out(ni_credit_out), + .ni_flit_out(ni_flit_out), + .ni_flit_out_wr(ni_flit_out_wr), + .ni_credit_in(ni_credit_in), + .er_addr(er_addr), + .current_r_addr(current_r_addr), + .neighbors_r_all(neighbors_r_addr) + ); + end else begin :mesh_torus - - - - for (x=0; x0) 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]); - -end -*/ - - end //y - end //x -end - -endgenerate - - - - start_delay_gen #( - .NC(NC) - - )delay_gen - ( - .clk(clk), - .reset(reset), - .start_i(start_i), - .start_o(start_o) - ); - - - -endmodule - - - -module start_delay_gen #( - parameter NC = 64 //number of cores - -)( - 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; - - 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 - - assign start_o=(cnt_increase | start)? start_o_reg : {NC{1'b0}}; - + endgenerate endmodule
/perl/gen_router_verilator_p.prl
0,0 → 1,123
#!/usr/bin/perl
 
use strict;
use warnings;
open(FILE, ">router_verilator.v") || die "Can not open: $!";
for (my $p=2; $p<20; $p++) {
 
print FILE "/**************
Port num = $p
****************/
 
module router_verilator_p$p
(
current_r_addr,
neighbors_r_addr,
flit_in_all,
flit_in_we_all,
credit_out_all,
congestion_in_all,
flit_out_all,
flit_out_we_all,
credit_in_all,
congestion_out_all,
clk,reset
);
 
localparam P=$p;
 
`define INCLUDE_PARAM
`include \"parameter.v\"
 
`define INCLUDE_TOPOLOGY_LOCALPARAM
`include \"topology_localparam.v\"
 
localparam CONGw= (CONGESTION_INDEX==3)? 3:
(CONGESTION_INDEX==5)? 3:
(CONGESTION_INDEX==7)? 3:
(CONGESTION_INDEX==9)? 3:
(CONGESTION_INDEX==10)? 4:
(CONGESTION_INDEX==12)? 3:2;
 
 
localparam
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,
PRAw = P * RAw;
 
input clk,reset;
input [RAw-1 : 0] current_r_addr;
input [PRAw-1 : 0] neighbors_r_addr;
input [PFw-1 : 0] flit_in_all;
input [P-1 : 0] flit_in_we_all;
output [PV-1 : 0] credit_out_all;
input [CONG_ALw-1 : 0] congestion_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;
 
router # (
.V(V),
.P(P),
.B(B),
.T1(T1),
.T2(T2),
.T3(T3),
.C(C),
.Fpay(Fpay),
.MUX_TYPE(MUX_TYPE),
.VC_REALLOCATION_TYPE(VC_REALLOCATION_TYPE),
.COMBINATION_TYPE(COMBINATION_TYPE),
.FIRST_ARBITER_EXT_P_EN(FIRST_ARBITER_EXT_P_EN),
.TOPOLOGY(TOPOLOGY),
.ROUTE_NAME(ROUTE_NAME),
.AVC_ATOMIC_EN(AVC_ATOMIC_EN),
.CONGESTION_INDEX(CONGESTION_INDEX),
.CONGw(CONGw),
.DEBUG_EN(DEBUG_EN),
.ADD_PIPREG_AFTER_CROSSBAR(ADD_PIPREG_AFTER_CROSSBAR),
.CVw(CVw),
.CLASS_SETTING(CLASS_SETTING),
.ESCAP_VC_MASK(ESCAP_VC_MASK),
.SSA_EN(SSA_EN),
.SWA_ARBITER_TYPE(SWA_ARBITER_TYPE),
.WEIGHTw(WEIGHTw),
.MIN_PCK_SIZE(MIN_PCK_SIZE)
)
the_router
(
.current_r_addr(current_r_addr),
.neighbors_r_addr(neighbors_r_addr),
.flit_in_all(flit_in_all),
.flit_in_we_all(flit_in_we_all),
.credit_out_all(credit_out_all),
.congestion_in_all(congestion_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),
.clk(clk),
.reset(reset)
 
);
endmodule
 
";
 
}
 
close(FILE);
 
 
 
perl/gen_router_verilator_p.prl Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: router_verilator.v =================================================================== --- router_verilator.v (revision 42) +++ router_verilator.v (revision 43) @@ -1,47 +1,244 @@ -module router_verilator +/************** +Port num = 2 +****************/ + +module router_verilator_p2 ( - current_x, - current_y, - - flit_in_all, - flit_in_we_all, - credit_out_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, + current_r_addr, + neighbors_r_addr, + flit_in_all, + flit_in_we_all, + credit_out_all, + congestion_in_all, + flit_out_all, + flit_out_we_all, + credit_in_all, + congestion_out_all, + clk,reset +); - clk,reset + localparam P=2; + `define INCLUDE_PARAM + `include "parameter.v" + + `define INCLUDE_TOPOLOGY_LOCALPARAM + `include "topology_localparam.v" + + + localparam CONGw= (CONGESTION_INDEX==3)? 3: + (CONGESTION_INDEX==5)? 3: + (CONGESTION_INDEX==7)? 3: + (CONGESTION_INDEX==9)? 3: + (CONGESTION_INDEX==10)? 4: + (CONGESTION_INDEX==12)? 3:2; + + + + localparam + 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, + PRAw = P * RAw; + + input clk,reset; + input [RAw-1 : 0] current_r_addr; + input [PRAw-1 : 0] neighbors_r_addr; + input [PFw-1 : 0] flit_in_all; + input [P-1 : 0] flit_in_we_all; + output [PV-1 : 0] credit_out_all; + input [CONG_ALw-1 : 0] congestion_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; + + router # ( + .V(V), + .P(P), + .B(B), + .T1(T1), + .T2(T2), + .T3(T3), + .C(C), + .Fpay(Fpay), + .MUX_TYPE(MUX_TYPE), + .VC_REALLOCATION_TYPE(VC_REALLOCATION_TYPE), + .COMBINATION_TYPE(COMBINATION_TYPE), + .FIRST_ARBITER_EXT_P_EN(FIRST_ARBITER_EXT_P_EN), + .TOPOLOGY(TOPOLOGY), + .ROUTE_NAME(ROUTE_NAME), + .AVC_ATOMIC_EN(AVC_ATOMIC_EN), + .CONGESTION_INDEX(CONGESTION_INDEX), + .CONGw(CONGw), + .DEBUG_EN(DEBUG_EN), + .ADD_PIPREG_AFTER_CROSSBAR(ADD_PIPREG_AFTER_CROSSBAR), + .CVw(CVw), + .CLASS_SETTING(CLASS_SETTING), + .ESCAP_VC_MASK(ESCAP_VC_MASK), + .SSA_EN(SSA_EN), + .SWA_ARBITER_TYPE(SWA_ARBITER_TYPE), + .WEIGHTw(WEIGHTw), + .MIN_PCK_SIZE(MIN_PCK_SIZE) + ) + the_router + ( + .current_r_addr(current_r_addr), + .neighbors_r_addr(neighbors_r_addr), + .flit_in_all(flit_in_all), + .flit_in_we_all(flit_in_we_all), + .credit_out_all(credit_out_all), + .congestion_in_all(congestion_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), + .clk(clk), + .reset(reset) + + ); +endmodule + +/************** +Port num = 3 +****************/ + +module router_verilator_p3 +( + current_r_addr, + neighbors_r_addr, + flit_in_all, + flit_in_we_all, + credit_out_all, + congestion_in_all, + flit_out_all, + flit_out_we_all, + credit_in_all, + congestion_out_all, + clk,reset ); + localparam P=3; + + `define INCLUDE_PARAM + `include "parameter.v" + + `define INCLUDE_TOPOLOGY_LOCALPARAM + `include "topology_localparam.v" + + + localparam CONGw= (CONGESTION_INDEX==3)? 3: + (CONGESTION_INDEX==5)? 3: + (CONGESTION_INDEX==7)? 3: + (CONGESTION_INDEX==9)? 3: + (CONGESTION_INDEX==10)? 4: + (CONGESTION_INDEX==12)? 3:2; + + + localparam + 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, + PRAw = P * RAw; + input clk,reset; + input [RAw-1 : 0] current_r_addr; + input [PRAw-1 : 0] neighbors_r_addr; + input [PFw-1 : 0] flit_in_all; + input [P-1 : 0] flit_in_we_all; + output [PV-1 : 0] credit_out_all; + input [CONG_ALw-1 : 0] congestion_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; - function integer log2; - input integer number; begin - log2=(number <=1) ? 1: 0; - while(2**log2
/simulator.cpp
6,42 → 6,39
#include <ctype.h>
#include <stdint.h>
#include <inttypes.h>
 
 
#include <verilated.h> // Defines common routines
#include "Vrouter.h" // From Verilating "router.v"
//#include "Vrouter1.h" included in parameter.h
#include "Vnoc.h"
#include "Vtraffic.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 SYNTHETIC 0
#define CUSTOM 1
#define RATIO_INIT 2
#define DISABLE -1
 
#define MY_VL_SETBIT_W(data,bit) (data[VL_BITWORD_I(bit)] |= (VL_UL(1) << VL_BITBIT_I(bit)))
 
#include "traffic_task_graph.h"
 
#define STND_DEV_EN 1
#define SYNTHETIC 0
#define CUSTOM 1
 
 
//Vrouter *router;
Vrouter *router[NC]; // Instantiation of module
//Vrouter1 *router1[NR]; // Included in parameter.h file
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;
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 int saved_time = 0;
unsigned int total_pck_num=0;
48,38 → 45,25
unsigned int sum_clk_h2h,sum_clk_h2t;
double sum_clk_per_hop;
const int CC=(C==0)? 1 : C;
 
unsigned int total_pck_num_per_class[CC]={0};
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 rsvd_core_total_pck_num[NE]= {0};
unsigned int rsvd_core_worst_delay[NE] = {0};
unsigned int sent_core_total_pck_num[NE]= {0};
unsigned int sent_core_worst_delay[NE] = {0};
unsigned int random_var[NE] = {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;
 
int ratio=RATIO_INIT;
double first_avg_latency_flit,current_avg_latency_flit;
 
double sc_time_stamp ();
int pow2( int );
 
 
 
 
 
#if (STND_DEV_EN)
//#include <math.h>
double sqroot (double s){
95,27 → 79,9
double standard_dev( double , unsigned int, double);
#endif
 
void update_noc_statistic (
int
);
 
 
void pck_dst_gen (
unsigned int,
unsigned int,
unsigned int,
unsigned int*,
unsigned int*
);
 
unsigned char pck_class_in_gen(
unsigned int
 
);
 
 
 
 
void update_noc_statistic ( int);
unsigned char pck_class_in_gen(unsigned int);
unsigned int pck_dst_gen_task_graph ( unsigned int);
void print_statistic (char *);
void print_parameter();
void reset_all_register();
123,42 → 89,12
 
 
 
 
 
 
 
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(){
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(" 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 ratio");
181,6 → 117,15
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){
int i;
int array[1000];
212,15 → 157,10
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 )
270,17 → 210,10
C1_p=array[1];
C2_p=array[2];
C3_p=array[3];
break;
case 'h':
break;
case 'h':
update_hotspot(optarg);
 
break;
break;
case '?':
if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
297,6 → 230,8
}
 
 
 
 
int main(int argc, char** argv) {
char change_injection_ratio=0,inject_done;
int i,j,x,y;//,report_delay_counter=0;
303,17 → 238,16
char file_name[100];
char deafult_out[] = {"result"};
char * out_file_name;
unsigned int dest_x, dest_y;
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++;
unsigned int dest_e_addr;
 
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
for(i=0;i<NC;i++) router[i] = new Vrouter; // Create instance
Vrouter_new();
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 );
327,36 → 261,26
 
reset=1;
reset_all_register();
noc->start_i=0;
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_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;
}
 
 
for (i=0;i<NE;i++){
random_var[i] = 100;
traffic[i]->current_e_addr = endp_addr_encoder(i);
traffic[i]->start=0;
traffic[i]->pck_class_in= pck_class_in_gen( i);
traffic[i]->pck_size_in=rnd_between(MIN_PACKET_SIZE,MAX_PACKET_SIZE);
dest_e_addr=pck_dst_gen (i);
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;
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();
if(strcmp(TRAFFIC,"CUSTOM from file")) printf("\n\n\n Flit injection ratio per router is =%f \n",(float)ratio*100/MAX_RATIO);
375,9 → 299,8
if(count_en) clk_counter++;
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(y=0;y<NY;y++)for(x=0;x<NX;x++)
{
i=(y*NX)+x;
for (i=0;i<NE;i++){
 
// a packet has been received
if(traffic[i]->update & ~reset){
update_noc_statistic (i) ;
388,9 → 311,11
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;
traffic[i]->dest_y=dest_y;
traffic[i]->pck_size_in=rnd_between(MIN_PACKET_SIZE,MAX_PACKET_SIZE);
dest_e_addr=pck_dst_gen (i);
traffic[i]->dest_e_addr= dest_e_addr;
//printf("src=%u, dest=%x\n", i,endp_addr_decoder(dest_e_addr));
 
}
}
 
398,50 → 323,35
 
}//for
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(" total received flits:%d\n",flit_counter);
print_statistic(out_file_name);
change_injection_ratio = 1;
for(i=0;i<NC;i++) {
router[i]->final();
traffic[i]->final();
}
routers_final();
for(i=0;i<NE;i++) traffic[i]->final();
noc->final();
return 0;
}
 
 
 
}//if
else
{
 
clk = 0;
#if (NC<=64)
#if (NR<=64)
noc->ni_flit_in_wr =0;
#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;
#endif
for(x=0;x<NX;x++)for(y=0;y<NY;y++){
i=(y*NX)+x;
#endif
connect_all_routers_to_noc ();
 
for (i=0;i<NE;i++){
traffic[i]->current_r_addr = noc->er_addr[i];
 
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];
 
 
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)
traffic[i]->flit_in = noc->ni_flit_out [i];
#else
457,7 → 367,7
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
 
#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);
traffic[i]->flit_in_wr= ((noc->ni_flit_out_wr >> i) & 0x01);
#else
464,24 → 374,19
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);
#endif
 
}//for
 
}//else
//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);
 
noc-> clk = clk;
noc-> reset = reset;
 
for(i=0;i<NC;i++) {
#if (NC<=64)
for(i=0;i<NE;i++) {
#if (NE<=64)
traffic[i]->start= ((noc->start_o >>i)& 0x01);
#else
traffic[i]->start= (VL_BITISSET_W(noc->start_o, i)>0);
488,25 → 393,16
#endif
traffic[i]->reset= reset;
traffic[i]->clk = clk;
router[i]->reset= reset;
router[i]->clk= clk ;
 
}
 
connect_routers_reset_clk();
//evaluate
noc->eval();
routers_eval();
for(i=0;i<NE;i++) traffic[i]->eval();
 
for(i=0;i<NC;i++) {
router[i]->eval();
traffic[i]->eval();
 
}
 
 
 
 
//router[0]->eval(); // Evaluate model
//router1[0]->eval(); // Evaluate model
//printf("clk=%x\n",router->clk );
 
main_time++;
513,11 → 409,10
//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();
 
}
529,9 → 424,6
* sc_time_stamp
*
* **********/
 
 
 
double sc_time_stamp () { // Called by $time in Verilog
return main_time;
}
551,63 → 443,33
*
*********************************/
 
 
 
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_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;
 
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);
unsigned int src_e_addr=traffic[core_num]->src_e_addr;
unsigned int src = endp_addr_decoder (src_e_addr);
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;
#endif
#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);
 
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;
 
 
}
 
/*************************
*
* update
*
*
************************/
 
 
 
 
 
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;
671,12 → 533,10
// update_file( file_name,avg_throughput,std_dev);
 
#endif
 
 
}//for
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\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] );
683,30 → 543,35
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] );
}
}
 
 
 
}
 
void print_parameter (){
 
printf ("Router parameters: \n");
printf ("\tTopology: %s\n",TOPOLOGY);
printf ("\tRouting algorithm: %s\n",ROUTE_NAME);
printf ("\tVC_per port: %d\n", V);
printf ("\tBuffer_width: %d\n", B);
printf ("\tRouter num in row: %d \n",NX);
printf ("\tRouter num in column: %d \n",NY);
if((strcmp (TOPOLOGY,"MESH")==0)||(strcmp (TOPOLOGY,"TORUS")==0)){
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 ("\tFlit data width: %d \n", Fpay);
printf ("\tVC reallocation mechanism: %s \n", VC_REALLOCATION_TYPE);
printf ("\tVC/sw combination mechanism: %s \n", COMBINATION_TYPE);
printf ("\troute-subfunction: %s \n", ROUTE_SUBFUNC );
printf ("\tAVC_ATOMIC_EN:%d \n", AVC_ATOMIC_EN);
printf ("\tCongestion Index:%d \n",CONGESTION_INDEX);
printf ("\tADD_PIPREG_AFTER_CROSSBAR:%d\n",ADD_PIPREG_AFTER_CROSSBAR);
printf ("\tSSA_EN enabled:%s \n",SSA_EN);
printf ("\tSwitch allocator arbitration type:%s \n",SWA_ARBITER_TYPE);
printf ("\tMinimum supported packet size:%d flit(s) \n",MIN_PCK_SIZE);
 
 
printf ("\nSimulation parameters\n");
747,9 → 612,6
 
void reset_all_register (void){
int i;
 
 
 
total_router=0;
total_pck_num=0;
sum_clk_h2h=0;
828,296 → 690,17
unsigned int core_num
 
) {
 
unsigned char pck_class_in;
unsigned char rnd=rand()%100;
 
pck_class_in= ( rnd < C0_p )? 0:
( rnd < (C0_p+C1_p) )? 1:
( rnd < (C0_p+C1_p+C2_p))?2:3;
 
 
 
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){
//printf("before%u=%u\n",src,random_var[src]);
random_var[src]= rnd_between(100-injct_var, 100+injct_var);
1128,9 → 711,6
task_t task;
float f,v;
 
 
 
 
int index = task_graph_abstract[src].active_index;
 
if(index == DISABLE){
1170,9 → 750,6
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;
1180,7 → 757,6
 
}
 
 
update_by_index(task_graph_data[src],index,task);
 
if (task.byte_sent >= task.bytes){ // This task is done remove it from the queue
1197,52 → 773,10
}
 
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);
 
}
 
 
 
 
/topology.h
0,0 → 1,100
#ifndef TOPOLOGY_H
#define TOPOLOGY_H
 
unsigned int nxw=0;
unsigned int nyw=0;
unsigned int maskx=0;
unsigned int masky=0;
 
unsigned int fattree_addrencode( unsigned int pos, unsigned int k, unsigned int l){
unsigned int pow,i,tmp=0;
unsigned int addrencode=0;
unsigned int kw=0;
while((0x1<<kw) < k)kw++;
pow=1;
for (i = 0; i <l; i=i+1 ) {
tmp=(pos/pow);
tmp=tmp%k;
// printf("tmp=%u\n",tmp);
tmp=tmp<<(i)*kw;
addrencode=addrencode | tmp;
pow=pow * k;
}
return addrencode;
}
 
 
unsigned int fattree_addrdecode(unsigned int addrencode , unsigned int k, unsigned int l){
unsigned int kw=0;
unsigned int mask=0;
unsigned int pow,i,tmp;
unsigned int pos=0;
while((0x1<<kw) < k){
kw++;
mask<<=1;
mask|=0x1;
}
pow=1;
for (i = 0; i <l; i=i+1 ) {
tmp = addrencode & mask;
//printf("tmp1=%u\n",tmp);
tmp=(tmp*pow);
pos= pos + tmp;
pow=pow * k;
addrencode>>=kw;
}
return pos;
}
 
 
void mesh_tori_addrencod_sep(unsigned int id, unsigned int *x, unsigned int *y, unsigned int *l){
(*l)=id%T3; // id%NL
(*x)=(id/T3)%T1;// (id/NL)%NX
(*y)=(id/T3)/T1;// (id/NL)/NX
}
 
 
void mesh_tori_addr_sep(unsigned int code, unsigned int *x, unsigned int *y, unsigned int *l){
(*x) = code & maskx;
code>>=nxw;
(*y) = code & masky;
code>>=nyw;
(*l) = code;
}
 
 
 
unsigned int mesh_tori_addr_join(unsigned int x, unsigned int y, unsigned int l){
 
unsigned int addrencode=0;
addrencode =(T3==1)? (y<<nxw | x) : (l<<(nxw+nyw)| (y<<nxw) | x);
return addrencode;
}
 
unsigned int mesh_tori_addrencode(unsigned int id){
unsigned int y, x, l;
mesh_tori_addrencod_sep(id,&x,&y,&l);
return mesh_tori_addr_join(x,y,l);
}
 
 
unsigned int endp_addr_encoder ( unsigned int id){
if((strcmp(TOPOLOGY ,"FATTREE")==0)||(strcmp(TOPOLOGY ,"TREE")==0)) {
return fattree_addrencode(id, T1, T2);
}
return mesh_tori_addrencode(id);
}
 
 
unsigned int endp_addr_decoder (unsigned int code){
if(strcmp(TOPOLOGY ,"FATTREE")==0 ||(strcmp(TOPOLOGY ,"TREE")==0)) {
return fattree_addrdecode(code, T1, T2);
}else{
unsigned int x, y, l;
mesh_tori_addr_sep(code,&x,&y,&l);
//if(code==0x1a) printf("code=%x,x=%u,y=%u,l=%u\n",code,x,y,l);
return ((y*T1)+x)*T3+l;
}
}
 
#endif
topology.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: traffic_gen_verilator.v =================================================================== --- traffic_gen_verilator.v (revision 42) +++ traffic_gen_verilator.v (revision 43) @@ -6,67 +6,52 @@ * Description: ***************************************/ module traffic_gen_verilator ( - //input + ratio, - avg_pck_size_in, - pck_size_in, - current_x, - current_y, - dest_x, - dest_y, + avg_pck_size_in, + pck_size_in, + current_r_addr, + current_e_addr, + dest_e_addr, pck_class_in, - start, - stop, - report, - init_weight, - //output + start, + stop, + report, + init_weight, + pck_number, sent_done, // tail flit has been sent hdr_flit_sent, update, // update the noc_analayzer + src_e_addr, + distance, - src_x, - src_y, pck_class_out, time_stamp_h2h, time_stamp_h2t, - //noc port + flit_out, flit_out_wr, credit_in, flit_in, flit_in_wr, - credit_out, + credit_out, + reset, clk ); - function integer log2; - input integer number; begin - log2=(number <=1) ? 1: 0; - while(2**log2 1)? log2(C): 1, Fw = 2+V+Fpay, RATIOw = log2(MAX_RATIO), @@ -73,108 +58,102 @@ 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), + + /* verilator lint_off WIDTH */ + DISTw = (TOPOLOGY=="FATTREE" || TOPOLOGY == "TREE") ? log2(2*L+1): log2(NR+1), + /* verilator lint_on WIDTH */ W = WEIGHTw; - - input reset, clk; + input reset, clk; input [RATIOw-1 :0] ratio; input start,stop; output update; output [CLK_CNTw-1 :0] time_stamp_h2h,time_stamp_h2t; - output [DSTw-1 :0] distance; - output [Xw-1 : 0] src_x; - output [Yw-1 : 0] src_y; - + output [DISTw-1 :0] distance; output [Cw-1 :0] pck_class_out; - input [Xw-1 :0] current_x; - input [Yw-1 :0] current_y; - input [Xw-1 :0] dest_x; - input [Yw-1 :0] dest_y; + // the connected router address + input [RAw-1 :0] current_r_addr; + // the current endpoint address + input [EAw-1 :0] current_e_addr; + // the destination endpoint adress + input [EAw-1 :0] dest_e_addr; + output [PCK_CNTw-1 :0] pck_number; + input [PCK_SIZw-1 :0] avg_pck_size_in; input [PCK_SIZw-1 :0] pck_size_in; - input [PCK_SIZw-1 :0] avg_pck_size_in; - output sent_done; - output hdr_flit_sent; + + 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; - input [V-1 :0] credit_in; + output flit_out_wr; + input [V-1 :0] credit_in; + input [Fw-1 :0] flit_in; input flit_in_wr; - output [V-1 :0] credit_out; + output [V-1 :0] credit_out; input report; + // the recieved packet source endpoint address + output [EAw-1 : 0] src_e_addr; - - traffic_gen #( - .V(V), - .B(B), - .NX(NX), - .NY(NY), - .Fpay(Fpay), - .C(C), - .VC_REALLOCATION_TYPE(VC_REALLOCATION_TYPE), - .TOPOLOGY(TOPOLOGY), - .ROUTE_NAME(ROUTE_NAME), - .MAX_PCK_NUM(MAX_PCK_NUM), - .MAX_SIM_CLKs(MAX_SIM_CLKs), - .MAX_PCK_SIZ(MAX_PCK_SIZ), - .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), - .dest_x(dest_x), - .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 - .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), - //noc - .flit_out(flit_out), - .flit_out_wr(flit_out_wr), - .credit_in(credit_in), - .flit_in(flit_in), - .flit_in_wr(flit_in_wr), - .credit_out(credit_out), - - .reset(reset), - .clk(clk) - - ); - - // always @(posedge start ) begin - // $display(" (%d,%d) start at %t",current_x, current_y,$time); - //end + traffic_gen #( + .V(V), + .B(B), + .T1(T1), + .T2(T2), + .T3(T3), + .Fpay(Fpay), + .VC_REALLOCATION_TYPE(VC_REALLOCATION_TYPE), + .TOPOLOGY(TOPOLOGY), + .ROUTE_NAME(ROUTE_NAME), + .C(C), + .MAX_PCK_NUM(MAX_PCK_NUM), + .MAX_SIM_CLKs(MAX_SIM_CLKs), + .MAX_PCK_SIZ(MAX_PCK_SIZ), + .TIMSTMP_FIFO_NUM(TIMSTMP_FIFO_NUM), + .MAX_RATIO(MAX_RATIO), + .SWA_ARBITER_TYPE(SWA_ARBITER_TYPE), + .WEIGHTw(WEIGHTw), + .MIN_PCK_SIZE(MIN_PCK_SIZE) + ) + the_traffic_gen + ( + .reset(reset), + .clk(clk), + .ratio(ratio), + .start(start), + .stop(stop), + .update(update), + .time_stamp_h2h(time_stamp_h2h), + .time_stamp_h2t(time_stamp_h2t), + .distance(distance), + .pck_class_out(pck_class_out), + .current_r_addr(current_r_addr), + .current_e_addr(current_e_addr), + .dest_e_addr(dest_e_addr), + .pck_number(pck_number), + .avg_pck_size_in(avg_pck_size_in), + .pck_size_in(pck_size_in), + .sent_done(sent_done), + .hdr_flit_sent(hdr_flit_sent), + .pck_class_in(pck_class_in), + .init_weight(init_weight), + .flit_out(flit_out), + .flit_out_wr(flit_out_wr), + .credit_in(credit_in), + .flit_in(flit_in), + .flit_in_wr(flit_in_wr), + .credit_out(credit_out), + .report(report), + .src_e_addr(src_e_addr) + ); + + endmodule
/traffic_synthetic.h
0,0 → 1,282
#ifndef TRAFFIC_SYNTHETIC_H
#define TRAFFIC_SYNTHETIC_H
 
 
#include "topology.h"
 
 
extern int TRAFFIC_TYPE;
extern int HOTSPOT_NUM;
extern char * TRAFFIC;
extern unsigned char NEw;
 
 
 
typedef struct HOTSPOT_NODE {
int ip_num;
char send_enable;
int percentage; // x10
} hotspot_st;
 
hotspot_st * hotspots;
 
 
// number, b:bit location W: number width log2(num)
int getBit(int num, int b, int W)
{
while(b<0) b+=W;
b%=W;
return (num >> b) & 0x1;
}
 
// number; b:bit location; W: number width log2(num); v: 1 assert the bit, 0 deassert the bit;
void setBit(int *num, int b, int W, int v)
{
while(b<0) b+=W;
b%=W;
int mask = 1 << b;
//printf("b=%d\n", b);
if (v == 0)*num = *num & ~mask; // assert bit
else *num = *num | mask; // deassert bit
}
 
 
 
 
unsigned int pck_dst_gen_2D (unsigned int core_num){
//for mesh-tori
unsigned int current_l,current_x, current_y;
unsigned int dest_l,dest_x,dest_y;
mesh_tori_addrencod_sep(core_num,&current_x,&current_y,&current_l);
 
unsigned int rnd=0;
unsigned int rnd100=0;
unsigned int max_percent=100/HOTSPOT_NUM;
int i;
 
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
do{
rnd=rand()%NE;
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
return endp_addr_encoder(rnd);
}
 
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
unsigned int rnd1000=0;
do{
rnd=rand()%NE;
}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
return endp_addr_encoder(rnd);
}
}
for (i=0;i<HOTSPOT_NUM; i++){
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
rnd = hotspots[i].ip_num;
return endp_addr_encoder(rnd);
}
}
return endp_addr_encoder(rnd);
}
 
if(( strcmp(TRAFFIC ,"TRANSPOSE1")==0)|| (strcmp (TRAFFIC,"transposed 1")==0)){
dest_x = T1-current_y-1;
dest_y = T2-current_x-1;
dest_l = T3-current_l-1;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
}
 
if(( strcmp(TRAFFIC ,"TRANSPOSE2")==0)|| (strcmp (TRAFFIC,"transposed 2")==0)){
dest_x = current_y;
dest_y = current_x;
dest_l = current_l;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
}
 
if(( strcmp(TRAFFIC ,"BIT_REVERSE")==0)|| (strcmp (TRAFFIC,"bit reverse")==0)){
//di = sb−i−1
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, NEw-i-1, NEw));
return endp_addr_encoder(tmp);
}
 
if(( strcmp(TRAFFIC ,"BIT_COMPLEMENT") ==0)|| (strcmp (TRAFFIC,"bit complement")==0)){
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, i, NEw)==0);
return endp_addr_encoder(tmp);
}
 
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 + ((T1/2)-1))%T1);
dest_y = ((current_y + ((T2/2)-1))%T2);
dest_l = current_l;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
}
 
if(( strcmp(TRAFFIC ,"SHUFFLE") == 0)|| (strcmp (TRAFFIC,"shuffle")==0)){
//di = si−1 mod b
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, i-1, NEw));
return endp_addr_encoder(tmp);
}
 
if(( strcmp(TRAFFIC ,"BIT_ROTATION") == 0)|| (strcmp (TRAFFIC,"bit rotation")==0)){
//di = si+1 mod b
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, i+1, NEw));
return endp_addr_encoder(tmp);
}
 
if(( strcmp(TRAFFIC ,"NEIGHBOR") == 0)|| (strcmp (TRAFFIC,"neighbor")==0)){
//dx = sx + 1 mod k
dest_x = (current_x + 1)%T1;
dest_y = (current_y + 1)%T2;
dest_l = current_l;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
}
if( strcmp(TRAFFIC ,"CUSTOM") == 0){
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
if(current_x ==0 && current_y == 0 && current_l==0 ){
// dest_x = T1-1;
// dest_y = T2-1;
// dest_l = T3-1;
dest_x = 0;
dest_y = 0;
dest_l = 1;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
}// make it invalid
dest_x = current_x;
dest_y = current_y;
dest_l = current_l;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
 
}
 
printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC);
dest_x = current_x;
dest_y = current_y;
dest_l = current_l;
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
}
 
 
 
 
unsigned int pck_dst_gen_1D (unsigned int core_num){
 
unsigned int rnd=0;
unsigned int rnd100=0;
unsigned int max_percent=100/HOTSPOT_NUM;
int i;
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
do{
rnd=rand()%NE;
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
 
return endp_addr_encoder(rnd);
}
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
unsigned int rnd1000=0;
int i;
do{
rnd=rand()%NE;
}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
return endp_addr_encoder(rnd);
}
}
for (i=0;i<HOTSPOT_NUM; i++){
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
rnd = hotspots[i].ip_num;
return endp_addr_encoder(rnd % NE );
}
}
return endp_addr_encoder(rnd % NE );
}
if(( strcmp(TRAFFIC ,"TRANSPOSE1")==0)|| (strcmp (TRAFFIC,"transposed 1")==0)){
return endp_addr_encoder(NE-core_num-1);
}
if(( strcmp(TRAFFIC ,"TRANSPOSE2")==0)|| (strcmp (TRAFFIC,"transposed 2")==0)){
return endp_addr_encoder(NE-core_num-1);
}
if(( strcmp(TRAFFIC ,"BIT_REVERSE")==0)|| (strcmp (TRAFFIC,"bit reverse")==0)){
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, NEw-i-1, NEw));
return endp_addr_encoder(tmp);
}
if(( strcmp(TRAFFIC ,"BIT_COMPLEMENT") ==0)|| (strcmp (TRAFFIC,"bit complement")==0)){
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, i, NEw)==0);
return endp_addr_encoder(tmp%NE);
}
if(( strcmp(TRAFFIC ,"TORNADO") == 0)|| (strcmp (TRAFFIC,"tornado")==0)){
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
return endp_addr_encoder((core_num + ((NE/2)-1))%NE);
}
 
if(( strcmp(TRAFFIC ,"SHUFFLE") == 0)|| (strcmp (TRAFFIC,"shuffle")==0)){
//di = si−1 mod b
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, i-1, NEw));
return endp_addr_encoder(tmp%NE);
}
 
if(( strcmp(TRAFFIC ,"BIT_ROTATION") == 0)|| (strcmp (TRAFFIC,"bit rotation")==0)){
//di = si+1 mod b
int tmp=0;
for(i=0; i< NEw; i++) setBit(&tmp , i, NEw, getBit(core_num, i+1, NEw));
return endp_addr_encoder(tmp%NE);
 
}
 
if(( strcmp(TRAFFIC ,"NEIGHBOR") == 0)|| (strcmp (TRAFFIC,"neighbor")==0)){
//dx = sx + 1 mod k
return endp_addr_encoder((core_num + 1)%NE);
}
if( strcmp(TRAFFIC ,"CUSTOM") == 0){
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
if(core_num ==2 ) return endp_addr_encoder(6);
return endp_addr_encoder(core_num);
}
 
printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC);
return endp_addr_encoder(core_num);
}
 
 
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;
}
 
 
 
 
 
 
#endif
traffic_synthetic.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: traffic_task_graph.h =================================================================== --- traffic_task_graph.h (revision 42) +++ traffic_task_graph.h (revision 43) @@ -1,9 +1,8 @@ - - #ifndef TRAFFIC_TASK_GRAPH_H #define TRAFFIC_TASK_GRAPH_H + #define SET_AUTO -1 @@ -52,8 +51,8 @@ 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]; +node_t * task_graph_data[NE]; +index_t task_graph_abstract[NE]; @@ -191,15 +190,15 @@ return 1; } -int calcualte_traffic_parameters(node_t * head[NC],index_t (* info)){ +int calcualte_traffic_parameters(node_t * head[NE],index_t (* info)){ int i,j; task_t task; - unsigned int max_bytes=0,accum[NC]; - unsigned int min_total[NC]; + unsigned int max_bytes=0,accum[NE]; + unsigned int min_total[NE]; //find the maximum bytes that an IP sends - for(i=0;i=NC) continue;// the destination address must be smaller than NC + if(n==0 || st.dst >=NE) 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
/tree_noc_connection.sv
0,0 → 1,210
// synthesis translate_off
`timescale 1ns / 1ps
// synthesis translate_on
 
module tree_noc_connection (
clk,
reset,
start_i,
start_o,
router_flit_out_all,
router_flit_out_we_all,
router_credit_in_all,
router_credit_out_all,
router_flit_in_all,
router_flit_in_we_all,
router_congestion_in_all,
router_congestion_out_all,
 
ni_flit_in,
ni_flit_in_wr,
ni_credit_out,
ni_flit_out,
ni_flit_out_wr,
ni_credit_in,
er_addr,
current_r_addr,
neighbors_r_all
);
 
`define INCLUDE_PARAM
`include"parameter.v"
`define INCLUDE_TOPOLOGY_LOCALPARAM
`include "topology_localparam.v"
localparam CONGw= (CONGESTION_INDEX==3)? 3:
(CONGESTION_INDEX==5)? 3:
(CONGESTION_INDEX==7)? 3:
(CONGESTION_INDEX==9)? 3:
(CONGESTION_INDEX==10)? 4:
(CONGESTION_INDEX==12)? 3:2;
function integer addrencode;
input integer pos,k,n,kw;
integer pow,i,tmp;begin
addrencode=0;
pow=1;
for (i = 0; i <n; i=i+1 ) begin
tmp=(pos/pow);
tmp=tmp%k;
tmp=tmp<<i*kw;
addrencode=addrencode | tmp;
pow=pow * k;
end
end
endfunction // log2
localparam
PV = V * MAX_P,
Fw = 2+V+Fpay, //flit width;
PFw = MAX_P * Fw,
NEFw = NE * Fw,
NEV = NE * V,
CONG_ALw = CONGw * MAX_P,
PLKw = MAX_P * LKw,
PLw = MAX_P * Lw,
PRAw = MAX_P * RAw; // {layer , Pos} width
input reset,clk;
output [PFw-1 : 0] router_flit_out_all [NR-1 :0];
output [MAX_P-1 : 0] router_flit_out_we_all [NR-1 :0];
input [PV-1 : 0] router_credit_in_all [NR-1 :0];
input [PFw-1 : 0] router_flit_in_all [NR-1 :0];
input [MAX_P-1 : 0] router_flit_in_we_all [NR-1 :0];
output [PV-1 : 0] router_credit_out_all[NR-1 :0];
input [CONG_ALw-1: 0] router_congestion_in_all[NR-1 :0];
output [CONG_ALw-1: 0] router_congestion_out_all [NR-1 :0];
input [Fw-1 : 0] ni_flit_in [NE-1 :0];
input [NE-1 : 0] ni_flit_in_wr;
output [V-1 : 0] ni_credit_out [NE-1 :0];
output [Fw-1 : 0] ni_flit_out [NE-1 :0];
output [NE-1 : 0] ni_flit_out_wr;
input [V-1 : 0] ni_credit_in [NE-1 :0];
 
wire [PLKw-1 : 0] neighbors_pos_all [NR-1 :0];//get a fixed value for each individual router
wire [PLw-1 : 0] neighbors_layer_all [NR-1 :0];
output [PRAw-1 : 0] neighbors_r_all [NR-1 :0];
output [RAw-1 : 0] er_addr [NE-1 : 0]; // provide router address for each connected endpoint
wire [LKw-1 : 0] current_pos_addr [NR-1 :0];
wire [Lw-1 : 0] current_layer_addr [NR-1 :0];
output [RAw-1 : 0] current_r_addr [NR-1 : 0];
input start_i;
output [NE-1 : 0] start_o;
localparam ROOT_L = L-1;
localparam ROOT_ID = 0;
assign current_layer_addr [ROOT_ID] = ROOT_L[Lw-1 : 0];
assign current_pos_addr [ROOT_ID] = {LKw{1'b0}};
assign current_r_addr[ROOT_ID] = {current_layer_addr [ROOT_ID],current_pos_addr[ROOT_ID]};
genvar pos,level,port;
generate
//connect all up connections
for (level = 1; level<L; level=level+1) begin : level_c
localparam NPOS = powi(K,level); // number of routers in this level
localparam L1 = L-1-level;
localparam level2= level - 1;
localparam L2 = L-1-level2;
for ( pos = 0; pos < NPOS; pos=pos+1 ) begin : pos_c
localparam ID1 = sum_powi ( K,level) + pos;
localparam FATTREE_EQ_POS1 = pos*(K**L1);
localparam ADR_CODE1=addrencode(FATTREE_EQ_POS1,K,L,Kw);
localparam POS2 = pos /K ;
localparam ID2 = sum_powi ( K,level-1) + (pos/K);
localparam PORT2= pos % K;
localparam FATTREE_EQ_POS2 = POS2*(K**L2);
localparam ADR_CODE2=addrencode(FATTREE_EQ_POS2,K,L,Kw);
// node_connection('Router[id1][k] to router[id2][pos%k];
assign router_flit_out_all [ID1][(K+1)*Fw-1 : K*Fw] = router_flit_in_all [ID2][(PORT2+1)*Fw-1 : PORT2*Fw];
assign router_flit_out_all [ID2][(PORT2+1)*Fw-1 : PORT2*Fw] = router_flit_in_all [ID1][(K+1)*Fw-1 : K*Fw];
 
assign router_credit_out_all [ID1][(K+1)*V-1 : K*V]= router_credit_in_all [ID2][(PORT2+1)*V-1 : PORT2*V];
assign router_credit_out_all [ID2][(PORT2+1)*V-1 : PORT2*V]= router_credit_in_all [ID1][(K+1)*V-1 : K*V];
 
 
assign router_flit_out_we_all[ID1][K] = router_flit_in_we_all [ID2][PORT2];
assign router_flit_out_we_all[ID2][PORT2] = router_flit_in_we_all [ID1][K];
 
assign router_congestion_out_all [ID1][(K+1)*CONGw-1 : K*CONGw] = router_congestion_in_all [ID2][(PORT2+1)*CONGw-1 : PORT2*CONGw];
assign router_congestion_out_all [ID2][(PORT2+1)*CONGw-1 : PORT2*CONGw] = router_congestion_in_all [ID1][(K+1)*CONGw-1 : K*CONGw];
assign neighbors_pos_all[ID1][(K+1)*LKw-1 : K*LKw] = ADR_CODE2 [LKw-1 :0];
assign neighbors_pos_all[ID2][(PORT2+1)*LKw-1 : PORT2*LKw] = ADR_CODE1[LKw-1 :0];
assign neighbors_layer_all[ID1][(K+1)*Lw-1 : K*Lw] = L2 [Lw-1 : 0];
assign neighbors_layer_all[ID2][(PORT2+1)*Lw-1 : PORT2*Lw] =L1 [Lw-1 : 0];
assign neighbors_r_all[ID1][(K+1)*RAw-1 : K*RAw] = {neighbors_layer_all[ID1][(K+1)*Lw-1 : K*Lw],neighbors_pos_all[ID1][(K+1)*LKw-1 : K*LKw]};
assign neighbors_r_all[ID2][(PORT2+1)*RAw-1 : PORT2*RAw] = {neighbors_layer_all[ID2][(PORT2+1)*Lw-1 : PORT2*Lw],neighbors_pos_all[ID2][(PORT2+1)*LKw-1 : PORT2*LKw]};
assign current_layer_addr [ID1] = L1[Lw-1 : 0];
assign current_pos_addr [ID1] = ADR_CODE1 [LKw-1 : 0];
assign current_r_addr [ID1] = {current_layer_addr [ID1],current_pos_addr[ID1]};
end// pos
end //level
for ( pos = 0; pos < NE; pos=pos+1 ) begin : endpoints
localparam RID= sum_powi(K,L-1)+(pos/K);
localparam RPORT = pos%K;
//connected router encoded address
localparam CURRENTPOS= addrencode(pos/K,K,L,Kw);
//$dotfile=$dotfile.node_connection('T',$i,undef,undef,'R',$r,undef,$i%($k));
assign router_flit_out_all [RID][(RPORT+1)*Fw-1 : RPORT*Fw] = ni_flit_in [pos];
assign router_credit_out_all [RID][(RPORT+1)*V-1 : RPORT*V] = ni_credit_in [pos];
assign router_flit_out_we_all [RID][RPORT] = ni_flit_in_wr [pos];
assign router_congestion_out_all[RID][(RPORT+1)*CONGw-1 : RPORT*CONGw] = {CONGw{1'b0}};
// assign neighbors_layer_all[RID][(RPORT+1)*Lw-1 : RPORT*Lw] = {Lw{1'b0}};
assign neighbors_r_all[RID][(RPORT+1)*RAw-1 : RPORT*RAw] = {RAw{1'b0}};
assign ni_flit_out [pos] = router_flit_in_all [RID][(RPORT+1)*Fw-1 : RPORT*Fw];
assign ni_flit_out_wr [pos] = router_flit_in_we_all[RID][RPORT];
assign ni_credit_out [pos] = router_credit_in_all [RID][(RPORT+1)*V-1 : RPORT*V];
assign er_addr [pos] = CURRENTPOS [RAw-1 : 0];
end//pos
endgenerate
start_delay_gen #(
.NC(NE)
)
delay_gen
(
.clk(clk),
.reset(reset),
.start_i(start_i),
.start_o(start_o)
);
 
 
endmodule
 
tree_noc_connection.sv Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.