`timescale 1ns / 1ps /********************************************************************** ** File: wrra.v ** Date:2017-07-11 ** ** 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: ** Weighted round robin arbiter support for QoS support in NoC: ** Packets are injected with initial weights. The defualt value is 1. ** Weights are assigned to each input ports according to contention degree. ** The contention degree is calculated based on the accumulation of input ports ** weight sending packet to the same output ports. ** Swich allocator's output arbters' priority is lucked until the winner's ** input weight is not consumed. A weight is consumed when a packet is sent. ** ** PROPOGATE_EQUALL = (WRRA_CONFIG_INDEX==0 ); ** PROPOGATE_LIMITED = (WRRA_CONFIG_INDEX==1 ); ** PROPOGATE_NEQ1 = (WRRA_CONFIG_INDEX==2 ); ** PROPOGATE_NEQ2 = (WRRA_CONFIG_INDEX==3 ); *****************************************************************/ module wrra #( parameter ARBITER_WIDTH = 8, parameter WEIGHTw = 4, // maximum weight size in bits parameter EXT_P_EN = 1 ) ( ext_pr_en_i, clk, reset, request, grant, any_grant, weight_array, winner_weight_consumed ); localparam WEIGHT_ARRAYw= WEIGHTw * ARBITER_WIDTH; input ext_pr_en_i; input [ARBITER_WIDTH-1 : 0] request; output [ARBITER_WIDTH-1 : 0] grant; output any_grant; input clk; input reset; input [WEIGHT_ARRAYw-1 : 0] weight_array; output winner_weight_consumed; wire [WEIGHTw-1 : 0] weight [ARBITER_WIDTH-1 : 0]; wire [ARBITER_WIDTH-1: 0] weight_counter_is_reset; genvar i; generate for (i=0; i weight_i) | load_i; assign out = couner_zero; assign weight= (weight_i == {WEIGHTw{1'b0}} )? 1 : weight_i; // minimum weight is 1; always @(*)begin counter_next = counter; if(load) counter_next = weight- 1'b1 ; if(decr) counter_next = (couner_zero)? weight-1'b1 : counter - 1'b1; // if the couner has zero value then the load is active not decrese end `ifdef SYNC_RESET_MODE always @ (posedge clk )begin `else always @ (posedge clk or posedge reset)begin `endif if (reset)begin counter<= {WEIGHTw{1'b0}}; end else begin counter <= counter_next; end //else end //always endmodule /************** * weight_counter * ***************/ module classic_weight_counter #( parameter WEIGHTw=4 )( weight_i, decr, load_i, out, reset, clk ); input [WEIGHTw-1 : 0] weight_i; input reset,clk,decr,load_i; output out; wire [WEIGHTw-1 : 0] weight; reg [WEIGHTw-1 : 0] counter,counter_next; wire couner_zero, load; assign couner_zero = counter == {WEIGHTw{1'b0}}; assign load = (counter > weight_i) | load_i; assign out = couner_zero; assign weight= (weight_i == {WEIGHTw{1'b0}} )? 1 : weight_i; // minimum weight is 1; always @(*)begin counter_next = counter; if(load) counter_next = weight- 1'b1 ; if(decr && !couner_zero) counter_next = counter - 1'b1; // if the couner has zero value then the load is active not decrese end `ifdef SYNC_RESET_MODE always @ (posedge clk )begin `else always @ (posedge clk or posedge reset)begin `endif if (reset)begin counter<= {WEIGHTw{1'b0}}; end else begin counter <= counter_next; end //else end //always endmodule /*************** * weight_control ***************/ module weight_control #( parameter ARBITER_TYPE="WRRA", parameter SW_LOC=0, parameter WEIGHTw= 4, parameter WRRA_CONFIG_INDEX=0, parameter P=5, parameter SELF_LOOP_EN = "NO" ) ( sw_is_granted, flit_is_tail, iport_weight, granted_dest_port, weight_is_consumed_o, oports_weight, refresh_w_counter, clk, reset ); localparam W = WEIGHTw, WP = W * P, P_1 = (SELF_LOOP_EN=="NO") ? P-1 : P; localparam [W-1 : 0] INIT_WEIGHT = 1; localparam [W-1 : 0] MAX_WEIGHT = {W{1'b1}}-1'b1; localparam PROPOGATE_EQUALL = (WRRA_CONFIG_INDEX==0 ), PROPOGATE_LIMITED = (WRRA_CONFIG_INDEX==1 ), PROPOGATE_NEQ1 = (WRRA_CONFIG_INDEX==2 ), PROPOGATE_NEQ2 = (WRRA_CONFIG_INDEX==3 ); input sw_is_granted , flit_is_tail; input [WEIGHTw-1 : 0] iport_weight; input clk,reset; output weight_is_consumed_o; input [P_1-1 : 0] granted_dest_port; output [WP-1 : 0] oports_weight; input refresh_w_counter; // wire ivc_empty = ~ivc_not_empty; wire counter_is_reset; wire weight_dcrease_en = sw_is_granted & flit_is_tail; wire [P-1 : 0] dest_port; reg [W-1 : 0] oport_weight_counter [P-1 : 0]; reg [W-1 : 0] oport_weight [P-1 : 0]; generate if(SELF_LOOP_EN == "NO") begin : nslp add_sw_loc_one_hot #( .P(P), .SW_LOC(SW_LOC) ) add_sw_loc ( .destport_in(granted_dest_port), .destport_out(dest_port) ); end else begin : slp assign dest_port = granted_dest_port; end endgenerate assign oports_weight [W-1 : 0] = {W{1'b0}}; genvar i; generate if(PROPOGATE_EQUALL | PROPOGATE_LIMITED )begin : eq for (i=1;iiport_weight) oport_weight[i]<=iport_weight;// weight counter should always be smaller than iport weight else if (weight_dcrease_en)begin if( counter_is_reset ) begin oport_weight[i]<= (oport_weight_counter[i]>0)? oport_weight_counter[i]: 1; end//counter_reset else begin if (oport_weight_counter[i]>0 && oport_weight[i] < oport_weight_counter[i]) oport_weight[i]<= oport_weight_counter[i]; end end//weight_dcr end//else reset end //always assign oports_weight [(i+1)*W-1 : i*W] = oport_weight[i]; end //else end //for end /* verilator lint_off WIDTH */ if(ARBITER_TYPE == "WRRA_CLASSIC") begin : wrra_classic /* verilator lint_on WIDTH */ // use classic WRRA. only for compasrion with propsoed wrra classic_weight_counter #( .WEIGHTw(WEIGHTw) ) iport_weight_counter ( .load_i(refresh_w_counter), .weight_i(iport_weight), .reset(reset), .clk(clk), .decr(weight_dcrease_en), .out(counter_is_reset) ); end else begin : wrra_mine // weight counters weight_counter #( .WEIGHTw(WEIGHTw) ) iport_weight_counter ( .load_i(refresh_w_counter), .weight_i(iport_weight), .reset(reset), .clk(clk), .decr(weight_dcrease_en), .out(counter_is_reset) ); end endgenerate assign weight_is_consumed_o = counter_is_reset; // & flit_is_tail ; endmodule /*************** * wrra_contention_gen * generate contention based on number of request to * the same output port ***************/ module wrra_contention_gen #( parameter V=4, parameter P=5, parameter WRRA_CONFIG_INDEX=0, parameter WEIGHTw = 4, // WRRA width parameter SELF_LOOP_EN ="NO" )( ovc_is_assigned_all, ivc_request_all, dest_port_all, iport_weight_all, oports_weight_all, contention_all, limited_oport_weight_all ); function integer log2; input integer number; begin log2=(number <=1) ? 1: 0; while(2**log2 weight_sum [j]) ? weight_sum [j] : limited_oport_weight [j]; end end else begin : eq_or_actual for (j=0;jError running this command: diff -w -U 5 "" "/tmp/Qd4w9f"

diff: : No such file or directory