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

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_noc/] [traffic_gen_top.sv] - Diff between revs 48 and 54

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 48 Rev 54
Line 1... Line 1...
`timescale  1ns/1ps
`include "pronoc_def.v"
 
 
module  traffic_gen_top
module  traffic_gen_top
                import pronoc_pkg::*;
                import pronoc_pkg::*;
        #(
        #(
                parameter MAX_RATIO = 1000,
                parameter MAX_RATIO = 1000,
Line 37... Line 37...
                distance,
                distance,
                pck_class_out,
                pck_class_out,
                time_stamp_h2h,
                time_stamp_h2h,
                time_stamp_h2t,
                time_stamp_h2t,
                pck_size_o,
                pck_size_o,
 
                mcast_dst_num_o,
 
 
                reset,
                reset,
                clk
                clk
 
 
        );
        );
Line 76... Line 77...
        output [Cw-1                    :0] pck_class_out;
        output [Cw-1                    :0] pck_class_out;
 
 
        // the current endpoint address
        // the current endpoint address
        input  [EAw-1                   :0] current_e_addr;
        input  [EAw-1                   :0] current_e_addr;
        // the destination endpoint address
        // the destination endpoint address
        input  [EAw-1                   :0] dest_e_addr;
        input  [DAw-1                   :0] dest_e_addr;
 
 
        output [PCK_CNTw-1              :0] pck_number;
        output [PCK_CNTw-1              :0] pck_number;
        input  [PCK_SIZw-1              :0] pck_size_in;
        input  [PCK_SIZw-1              :0] pck_size_in;
 
 
        output reg sent_done;
        output reg sent_done;
Line 91... Line 92...
        input                               report;
        input                               report;
        input  [DELAYw-1                        :0] start_delay;
        input  [DELAYw-1                        :0] start_delay;
        // the received packet source endpoint address
        // the received packet source endpoint address
        output [EAw-1        :   0]    src_e_addr;
        output [EAw-1        :   0]    src_e_addr;
        output [PCK_SIZw-1   :   0]    pck_size_o;
        output [PCK_SIZw-1   :   0]    pck_size_o;
 
        output [NEw-1 : 0] mcast_dst_num_o;
 
 
 
 
        logic  [Fw-1                   :0] flit_out;
        logic  [Fw-1                   :0] flit_out;
        output  logic                       flit_out_wr;
        output  logic                       flit_out_wr;
        output  [Cw-1 : 0] flit_out_class;
        output  [Cw-1 : 0] flit_out_class;
Line 106... Line 108...
 
 
        // the connected router address
        // the connected router address
        wire  [RAw-1                   :0] current_r_addr;
        wire  [RAw-1                   :0] current_r_addr;
 
 
 
 
 
        /* verilator lint_off WIDTH */
 
        wire [PCK_SIZw-1 : 0] pck_size_tmp= (PCK_TYPE == "SINGLE_FLIT" )?   1 : pck_size_in;
 
        /* verilator lint_on WIDTH */
 
 
        assign  chan_out.flit_chanel.flit = flit_out;
        assign  chan_out.flit_chanel.flit = flit_out;
        assign  chan_out.flit_chanel.flit_wr = flit_out_wr;
        assign  chan_out.flit_chanel.flit_wr = flit_out_wr;
        assign  chan_out.flit_chanel.credit = credit_out;
        assign  chan_out.flit_chanel.credit = credit_out;
 
        assign  chan_out.smart_chanel = {SMART_CHANEL_w {1'b0}};
 
 
        assign flit_in   =  chan_in.flit_chanel.flit;
        assign flit_in   =  chan_in.flit_chanel.flit;
        assign flit_in_wr=  chan_in.flit_chanel.flit_wr;
        assign flit_in_wr=  chan_in.flit_chanel.flit_wr;
        assign credit_in =  chan_in.flit_chanel.credit;
        assign credit_in =  chan_in.flit_chanel.credit;
        assign current_r_addr = chan_in.ctrl_chanel.neighbors_r_addr;
        assign current_r_addr = chan_in.ctrl_chanel.neighbors_r_addr;
Line 123... Line 129...
        for (i=0; i
        for (i=0; i
                assign chan_out.ctrl_chanel.credit_init_val[i]= PORT_B;
                assign chan_out.ctrl_chanel.credit_init_val[i]= PORT_B;
        end
        end
        endgenerate
        endgenerate
 
 
 
        assign chan_out.ctrl_chanel.endp_port =1'b1;
 
        assign chan_out.ctrl_chanel.credit_release_en={V{1'b0}};
 
 
        //old traffic.v file
        //old traffic.v file
 
 
        reg [2:0]   ps,ns;
        reg [2:0]   ps,ns;
        localparam IDEAL =3'b001, SENT =3'b010, WAIT=3'b100;
        localparam IDEAL =3'b001, SENT =3'b010, WAIT=3'b100;
 
 
        reg                                 inject_en,cand_wr_vc_en,pck_rd;
        reg                                 inject_en,cand_wr_vc_en,pck_rd;
        reg    [PCK_SIZw-1              :0] pck_size, pck_size_next;
        reg    [PCK_SIZw-1              :0] pck_size;
        reg    [EAw-1                    :0] dest_e_addr_reg;
        logic  [DAw-1                   :0] dest_e_addr_reg,dest_e_addr_o;
 
 
        // synopsys  translate_off
        // synopsys  translate_off
        // synthesis translate_off
        // synthesis translate_off
 
 
        `ifdef MONITORE_PATH
        `ifdef MONITORE_PATH
Line 165... Line 174...
                HDR_DATA_w =  (MIN_PCK_SIZE==1)? CLK_CNTw : 0,
                HDR_DATA_w =  (MIN_PCK_SIZE==1)? CLK_CNTw : 0,
                HDR_Dw =  (MIN_PCK_SIZE==1)? CLK_CNTw : 1;
                HDR_Dw =  (MIN_PCK_SIZE==1)? CLK_CNTw : 1;
 
 
        wire [HDR_Dw-1 : 0] hdr_data_in,rd_hdr_data_out;
        wire [HDR_Dw-1 : 0] hdr_data_in,rd_hdr_data_out;
 
 
 
        pronoc_register #(.W(DAw)) reg2 (.in(dest_e_addr ), .out(dest_e_addr_reg), .reset(reset), .clk(clk));
 
 
 
 
        `ifdef SYNC_RESET_MODE
 
                always @ (posedge clk )begin
 
                `else
 
                        always @ (posedge clk or posedge reset)begin
 
                        `endif
 
                        if(reset) begin
 
                                dest_e_addr_reg<={EAw{1'b0}};
 
                        end else begin
 
                                dest_e_addr_reg<=dest_e_addr;
 
                        end
 
                end
 
 
 
                wire    [DSTPw-1                :   0] destport;
                wire    [DSTPw-1                :   0] destport;
                wire    [V-1                    :   0] ovc_wr_in;
                wire    [V-1                    :   0] ovc_wr_in;
                wire    [V-1                    :   0] full_vc,empty_vc,nearly_full_vc;
                wire    [V-1                    :   0] full_vc,empty_vc,nearly_full_vc;
                reg     [V-1                    :   0] wr_vc,wr_vc_next;
                reg     [V-1                    :   0] wr_vc,wr_vc_next;
Line 192... Line 192...
                reg     [PCK_SIZw-1             :   0] flit_counter;
                reg     [PCK_SIZw-1             :   0] flit_counter;
                reg                                    flit_cnt_rst,flit_cnt_inc;
                reg                                    flit_cnt_rst,flit_cnt_inc;
                wire                                   rd_hdr_flg,rd_tail_flg;
                wire                                   rd_hdr_flg,rd_tail_flg;
                wire    [Cw-1   :   0] rd_class_hdr;
                wire    [Cw-1   :   0] rd_class_hdr;
                //  wire    [P_1-1      :   0] rd_destport_hdr;
                //  wire    [P_1-1      :   0] rd_destport_hdr;
                wire    [EAw-1      :   0] rd_des_e_addr, rd_src_e_addr;
                wire    [DAw-1      :   0] rd_des_e_addr;
 
                wire    [EAw-1      :   0] rd_src_e_addr;
 
 
                reg     [CLK_CNTw-1             :   0] rsv_counter;
                reg     [CLK_CNTw-1             :   0] rsv_counter;
                reg     [CLK_CNTw-1             :   0] clk_counter;
                reg     [CLK_CNTw-1             :   0] clk_counter;
                wire    [Vw-1                   :   0] rd_vc_bin;//,wr_vc_bin;
                wire    [Vw-1                   :   0] rd_vc_bin;//,wr_vc_bin;
                reg     [CLK_CNTw-1             :   0] rsv_time_stamp[V-1:0];
                reg     [CLK_CNTw-1             :   0] rsv_time_stamp[V-1:0];
                reg     [PCK_SIZw-1             :   0] rsv_pck_size    [V-1:0];
                reg     [PCK_SIZw-1             :   0] rsv_pck_size    [V-1:0];
Line 213... Line 215...
 
 
 
 
                logic [DELAYw-1 : 0] start_delay_counter,start_delay_counter_next;
                logic [DELAYw-1 : 0] start_delay_counter,start_delay_counter_next;
                logic  start_en_next , start_en;
                logic  start_en_next , start_en;
 
 
                register #(.W(1)) streg1 (.reset(reset),.clk(clk), .in(start_en_next), .out(start_en)   );
                pronoc_register #(.W(1)) streg1 (.reset(reset),.clk(clk), .in(start_en_next), .out(start_en)    );
                register #(.W(DELAYw)) streg2 (.reset(reset),.clk(clk), .in(start_delay_counter_next), .out(start_delay_counter)        );
                pronoc_register #(.W(DELAYw)) streg2 (.reset(reset),.clk(clk), .in(start_delay_counter_next), .out(start_delay_counter) );
 
 
 
 
 
 
                always @(*) begin
                always @(*) begin
                        start_en_next =start_en;
                        start_en_next =start_en;
Line 243... Line 245...
                                .TOPOLOGY(TOPOLOGY),
                                .TOPOLOGY(TOPOLOGY),
                                .T1(T1),
                                .T1(T1),
                                .T2(T2),
                                .T2(T2),
                                .T3(T3),
                                .T3(T3),
                                .EAw(EAw),
                                .EAw(EAw),
                                .SELF_LOOP_EN(SELF_LOOP_EN)
                                .SELF_LOOP_EN(SELF_LOOP_EN),
 
                                .DAw(DAw),
 
                                .CAST_TYPE(CAST_TYPE),
 
                                .NE(NE)
                        )
                        )
                        check_destination_addr(
                        check_destination_addr(
                                .dest_e_addr(dest_e_addr),
                                .dest_e_addr(dest_e_addr),
                                .current_e_addr(current_e_addr),
                                .current_e_addr(current_e_addr),
                                .dest_is_valid(valid_dst)
                                .dest_is_valid(valid_dst)
Line 263... Line 268...
                                .MAX_RATIO(MAX_RATIO)
                                .MAX_RATIO(MAX_RATIO)
                        )
                        )
                        pck_inject_ratio_ctrl
                        pck_inject_ratio_ctrl
                        (
                        (
                                .en(inject_en),
                                .en(inject_en),
                                .pck_size_in(pck_size_in),
                                .pck_size_in(pck_size_tmp),
                                .clk(clk),
                                .clk(clk),
                                .reset(reset),
                                .reset(reset),
                                .freez(buffer_full),
                                .freez(buffer_full),
                                .inject(pck_wr),
                                .inject(pck_wr),
                                .ratio(ratio)
                                .ratio(ratio)
Line 294... Line 299...
                                .reset                      (reset)
                                .reset                      (reset)
                        );
                        );
 
 
 
 
 
 
 
 
                packet_gen #(
                packet_gen #(
                                .P(MAX_P),
                                .P(MAX_P),
                                .T1(T1),
                                .PCK_TYPE(PCK_TYPE),
                                .T2(T2),
 
                                .T3(T3),
 
                                .RAw(RAw),
 
                                .EAw(EAw),
 
                                .TOPOLOGY(TOPOLOGY),
 
                                .DSTPw(DSTPw),
 
                                .ROUTE_NAME(ROUTE_NAME),
 
                                .ROUTE_TYPE(ROUTE_TYPE),
                                .ROUTE_TYPE(ROUTE_TYPE),
                                .MAX_PCK_NUM(MAX_PCK_NUM),
                                .MAX_PCK_NUM(MAX_PCK_NUM),
                                .MAX_SIM_CLKs(MAX_SIM_CLKs),
                                .MAX_SIM_CLKs(MAX_SIM_CLKs),
                                .TIMSTMP_FIFO_NUM(TIMSTMP_FIFO_NUM),
                                .TIMSTMP_FIFO_NUM(TIMSTMP_FIFO_NUM),
                                .MIN_PCK_SIZE(MIN_PCK_SIZE),
                                .MIN_PCK_SIZE(MIN_PCK_SIZE),
Line 321... Line 320...
                                .pck_rd(pck_rd),
                                .pck_rd(pck_rd),
                                .current_r_addr(current_r_addr),
                                .current_r_addr(current_r_addr),
                                .current_e_addr(current_e_addr),
                                .current_e_addr(current_e_addr),
                                .clk_counter(clk_counter+1'b1),//in case of zero load latency, the flit will be injected in the next clock cycle
                                .clk_counter(clk_counter+1'b1),//in case of zero load latency, the flit will be injected in the next clock cycle
                                .pck_number(pck_number),
                                .pck_number(pck_number),
                                .dest_e_addr(dest_e_addr_reg),
                                .dest_e_addr_in(dest_e_addr),
 
                                .dest_e_addr_o(dest_e_addr_o),
                                .pck_timestamp(pck_timestamp),
                                .pck_timestamp(pck_timestamp),
                                .buffer_full(buffer_full),
                                .buffer_full(buffer_full),
                                .pck_ready(pck_ready),
                                .pck_ready(pck_ready),
                                .valid_dst(valid_dst),
                                .valid_dst(valid_dst),
                                .destport(destport),
                                .destport(destport),
                                .pck_size_in(pck_size_in),
                                .pck_size_in(pck_size_tmp),
                                .pck_size_o(pck_size)
                                .pck_size_o(pck_size)
                        );
                        );
 
 
 
 
 
 
 
 
 
 
                assign wr_timestamp    =pck_timestamp;
                assign wr_timestamp    =pck_timestamp;
 
 
                assign  update      = flit_in_wr & flit_in[Fw-2];
                assign  update      = flit_in_wr & flit_in[Fw-2];
                assign  hdr_flit    = (flit_counter == 0);
                assign  hdr_flit    = (flit_counter == 0);
                assign  tail_flit   = (flit_counter ==  pck_size-1'b1);
                assign  tail_flit   = (flit_counter ==  pck_size-1'b1);
Line 364... Line 367...
                        the_header_flit_generator
                        the_header_flit_generator
                        (
                        (
                                .flit_out(hdr_flit_out),
                                .flit_out(hdr_flit_out),
                                .vc_num_in(wr_vc),
                                .vc_num_in(wr_vc),
                                .class_in(pck_class_in),
                                .class_in(pck_class_in),
                                .dest_e_addr_in(dest_e_addr_reg),
                                .dest_e_addr_in(dest_e_addr_o),
                                .src_e_addr_in(current_e_addr),
                                .src_e_addr_in(current_e_addr),
                                .weight_in(init_weight),
                                .weight_in(init_weight),
                                .destport_in(destport),
                                .destport_in(destport),
                                .data_in(hdr_data_in),
                                .data_in(hdr_data_in),
                                .be_in({BEw{1'b1}} )// Be is not used in simulation as we dont sent real data
                                .be_in({BEw{1'b1}} )// Be is not used in simulation as we dont sent real data
Line 567... Line 570...
                if(flit_in_wr) begin
                if(flit_in_wr) begin
                        credit_out_next = rd_vc;
                        credit_out_next = rd_vc;
                end else credit_out_next = {V{1'd0}};
                end else credit_out_next = {V{1'd0}};
        end
        end
 
 
        always @ (*)begin
 
                pck_size_next    = pck_size;
 
                if((tail_flit & flit_out_wr ) || not_yet_sent_aflit) pck_size_next  = pck_size_in;
 
        end
 
 
 
        `ifdef SYNC_RESET_MODE
                always @ (`pronoc_clk_reset_edge )begin
                always @ (posedge clk )begin
                        if(`pronoc_reset) begin
                `else
 
                        always @ (posedge clk or posedge reset)begin
 
                        `endif
 
                        if(reset) begin
 
                                inject_en       <= 1'b0;
                                inject_en       <= 1'b0;
                                ps              <= IDEAL;
                                ps              <= IDEAL;
                                wr_vc           <=1;
                                wr_vc           <=1;
                                flit_counter    <= {PCK_SIZw{1'b0}};
                                flit_counter    <= {PCK_SIZw{1'b0}};
                                credit_out      <= {V{1'd0}};
                                credit_out      <= {V{1'd0}};
                                rsv_counter     <= 0;
                                rsv_counter     <= 0;
                                clk_counter     <=  0;
                                clk_counter     <=  0;
                                //pck_size        <= 0;
 
                                not_yet_sent_aflit<=1'b1;
                                not_yet_sent_aflit<=1'b1;
 
 
                        end else begin
                        end else begin
                                //injection
                                //injection
                                not_yet_sent_aflit<=not_yet_sent_aflit_next;
                                not_yet_sent_aflit<=not_yet_sent_aflit_next;
Line 598... Line 592...
                                clk_counter     <= clk_counter+1'b1;
                                clk_counter     <= clk_counter+1'b1;
                                wr_vc           <=wr_vc_next;
                                wr_vc           <=wr_vc_next;
                                if (flit_cnt_rst)      flit_counter    <= {PCK_SIZw{1'b0}};
                                if (flit_cnt_rst)      flit_counter    <= {PCK_SIZw{1'b0}};
                                else if(flit_cnt_inc)   flit_counter    <= flit_counter + 1'b1;
                                else if(flit_cnt_inc)   flit_counter    <= flit_counter + 1'b1;
                                credit_out      <= credit_out_next;
                                credit_out      <= credit_out_next;
                                //pck_size  <= pck_size_next;
 
 
 
                                //sink
                                //sink
                                if(flit_in_wr) begin
                                if(flit_in_wr) begin
                                        if (flit_in[Fw-1])begin //header flit
                                        if (flit_in[Fw-1])begin //header flit
                                                rsv_pck_src_e_addr[rd_vc_bin]    <=  rd_src_e_addr;
                                                rsv_pck_src_e_addr[rd_vc_bin]    <=  rd_src_e_addr;
Line 637... Line 631...
 
 
                        end
                        end
                end//always
                end//always
 
 
 
 
                // synopsys  translate_off
 
 
 
 
 
 
 
 
                wire [NE-1 :0] dest_mcast_all_endp1;
 
 
 
 
 
                generate
 
                        /* verilator lint_off WIDTH */
 
                        if(CAST_TYPE != "UNICAST") begin :mb_cast
 
                        /* verilator lint_on WIDTH */
 
 
 
                                wire [NEw-1 : 0] sum_temp;
 
                                wire is_unicast;
 
 
 
                                mcast_dest_list_decode decode1 (
 
                                                .dest_e_addr(dest_e_addr_o),
 
                                                .dest_o(dest_mcast_all_endp1),
 
                                                .row_has_any_dest(),
 
                                                .is_unicast(is_unicast)
 
                                        );
 
 
 
                                /* verilator lint_off WIDTH */
 
                                if (CAST_TYPE == "BROADCAST_FULL") begin :bcastf
 
                                        assign mcast_dst_num_o = (is_unicast) ? 1 : (SELF_LOOP_EN == "NO")? NE-1 : NE;
 
                                end else  if ( CAST_TYPE == "BROADCAST_PARTIAL" )  begin :bcastp
 
 
 
                                        if (SELF_LOOP_EN == "NO") begin
 
                                                //check if injector node is included in partial list
 
                                                wire [NEw-1: 0]  current_enp_id;
 
                                                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod1 ( .id(current_enp_id), .code(current_e_addr));
 
                                                assign mcast_dst_num_o = (is_unicast) ? 1 : (MCAST_ENDP_LIST[current_enp_id]== 1'b1)?  MCAST_PRTLw-1 :  MCAST_PRTLw;
 
 
 
                                        end else begin
 
                                                assign mcast_dst_num_o = (is_unicast)? 1 :  MCAST_PRTLw;
 
                                        end
 
                                /* verilator lint_on WIDTH */
 
                                end else begin : mcast
 
                                        accumulator #(
 
                                                        .INw(NE),
 
                                                        .OUTw(NEw),
 
                                                        .NUM(NE)
 
                                                )accum
 
                                                (
 
                                                        .in_all(dest_mcast_all_endp1),
 
                                                        .out(sum_temp)
 
                                                );
 
                                        assign mcast_dst_num_o = sum_temp;
 
                                end
 
                        end
 
                endgenerate
 
 
 
 
 
 
 
 
 
 
 
/***************************************************************
 
 *                      simulation code
 
 * ************************************************************/
 
 
 
 
 
 
 
 
 
 
                // synthesis translate_off
                // synthesis translate_off
 
 
                localparam NEw=log2(NE);
 
                wire [NEw-1: 0]  src_id,dst_id,current_id;
                wire [NEw-1: 0]  src_id,dst_id,current_id;
 
 
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod1 ( .id(current_id), .code(current_e_addr));
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod1 ( .id(current_id), .code(current_e_addr));
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod2 ( .id(dst_id), .code(rd_des_e_addr));
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod2 ( .id(dst_id), .code(rd_des_e_addr[EAw-1 : 0]));// only for unicast
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod3 ( .id(src_id), .code(rd_src_e_addr));
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod3 ( .id(src_id), .code(rd_src_e_addr));
 
 
 
 
 
 
 
 
 
 
 
                wire [NE-1 :0] dest_mcast_all_endp2;
 
                generate
 
                if(CAST_TYPE != "UNICAST") begin :no_unicast
 
                        mcast_dest_list_decode decode2 (
 
                                        .dest_e_addr(rd_des_e_addr),
 
                                        .dest_o(dest_mcast_all_endp2),
 
                                        .row_has_any_dest(),
 
                                        .is_unicast()
 
                                );
 
                end endgenerate
 
 
 
 
 
 
                always @(posedge clk) begin
                always @(posedge clk) begin
                        if(flit_out_wr && hdr_flit && dest_e_addr_reg  == current_e_addr && SELF_LOOP_EN == "NO") begin
                        /* verilator lint_off WIDTH */
                                $display("%t: ERROR: The self-loop is not enabled in the router while a packet is injected to the NoC with identical source and destination address in endpoint (%h).: %m",$time, dest_e_addr );
                        if(CAST_TYPE == "UNICAST") begin
 
                                /* verilator lint_on WIDTH */
 
                                if(flit_out_wr && hdr_flit && dest_e_addr_o [EAw-1 : 0]  == current_e_addr  && SELF_LOOP_EN == "NO") begin
 
                                        $display("%t: ERROR: The self-loop is not enabled in the router while a packet is injected to the NoC with identical source and destination address in endpoint (%h).: %m",$time, dest_e_addr_o );
                                $finish;
                                $finish;
                        end
                        end
                        if(flit_in_wr && rd_hdr_flg && (rd_des_e_addr  != current_e_addr )) begin
                                if(flit_in_wr && rd_hdr_flg && (rd_des_e_addr[EAw-1 : 0]  != current_e_addr )) begin
                                $display("%t: ERROR: packet with destination %d (code %h) which is sent by source %d (code %h) has been recieved in wrong destination %d (code %h).  %m",$time,dst_id,rd_des_e_addr, src_id,rd_src_e_addr, current_id,current_e_addr);
                                $display("%t: ERROR: packet with destination %d (code %h) which is sent by source %d (code %h) has been recieved in wrong destination %d (code %h).  %m",$time,dst_id,rd_des_e_addr, src_id,rd_src_e_addr, current_id,current_e_addr);
                                $finish;
                                $finish;
                        end
                        end
 
 
 
                        end else begin
 
                                /* verilator lint_off WIDTH */
 
                                if((CAST_TYPE == "MULTICAST_FULL") || (CAST_TYPE == "MULTICAST_PARTIAL")) begin
 
                                /* verilator lint_on WIDTH */
 
 
 
                                        if(flit_out_wr && hdr_flit && dest_mcast_all_endp1[current_id]  == 1'b1  && SELF_LOOP_EN == "NO") begin
 
                                                $display("%t: ERROR: The self-loop is not enabled in the router while a packet is injected to the NoC with identical source and destination address in endpoint %d. destination nodes:0X%h. : %m",$time, current_id,dest_mcast_all_endp1 );
 
                                                $finish;
 
                                        end
 
                                end
 
                                if(flit_in_wr && rd_hdr_flg && (dest_mcast_all_endp2[current_id] !=1'b1 )) begin
 
                                        $display("%t: ERROR: packet with destination %b  which is sent by source %d (code %h) has been recieved in wrong destination %d (code %h).  %m",$time, dest_mcast_all_endp2, src_id,rd_src_e_addr, current_id,current_e_addr);
 
                                        $finish;
 
                                end
 
 
 
                                //check multicast packet size to be smaller than B & LB
 
                                if(flit_out_wr & hdr_flit & (mcast_dst_num_o>1) & (pck_size >B || pck_size> LB))begin
 
                                        $display("%t: ERROR: A multicast packat is injected to the NoC which has larger size (%d) than router buffer width.  %m",$time, pck_size);
 
                                        $finish;
 
                                end
 
 
 
                        end
                        if(update) begin
                        if(update) begin
                                if (hdr_flit_timestamp<= rd_timestamp) begin
                                if (hdr_flit_timestamp<= rd_timestamp) begin
                                        $display("%t: ERROR: In destination %d packt which is sent by source %d, the time when header flit is recived (%d) should be larger than the packet timestamp %d.  %m",$time, current_id ,src_e_addr, hdr_flit_timestamp, rd_timestamp);
                                        $display("%t: ERROR: In destination %d packt which is sent by source %d, the time when header flit is recived (%d) should be larger than the packet timestamp %d.  %m",$time, current_id ,src_e_addr, hdr_flit_timestamp, rd_timestamp);
                                        $finish;
                                        $finish;
                                end
                                end
Line 678... Line 773...
                                        $finish;
                                        $finish;
                                end
                                end
                        end
                        end
 
 
                end
                end
                // synthesis translate_on
 
                // synopsys  translate_on
 
 
 
 
 
                `ifdef CHECK_PCKS_CONTENT
                `ifdef CHECK_PCKS_CONTENT
                        // synopsys  translate_off
 
                        // synthesis translate_off
 
 
 
                        wire     [PCK_SIZw-1             :   0] rsv_flit_counter;
                        wire     [PCK_SIZw-1             :   0] rsv_flit_counter;
                        reg      [PCK_SIZw-1             :   0] old_flit_counter    [V-1   :   0];
                        reg      [PCK_SIZw-1             :   0] old_flit_counter    [V-1   :   0];
                        wire     [PCK_CNTw-1             :   0] rsv_pck_number;
                        wire     [PCK_CNTw-1             :   0] rsv_pck_number;
                        reg      [PCK_CNTw-1             :   0] old_pck_number  [V-1   :   0];
                        reg      [PCK_CNTw-1             :   0] old_pck_number  [V-1   :   0];
Line 702... Line 794...
                        endgenerate
                        endgenerate
 
 
 
 
 
 
                                integer ii;
                                integer ii;
                        `ifdef SYNC_RESET_MODE
 
                                always @ (posedge clk )begin
                                always @ (`pronoc_clk_reset_edge )begin
                                `else
                                        if(`pronoc_reset) begin
                                        always @ (posedge clk or posedge reset)begin
 
                                        `endif
 
                                        if(reset) begin
 
                                                for(ii=0;ii
                                                for(ii=0;ii
                                                        old_flit_counter[ii]<=0;
                                                        old_flit_counter[ii]<=0;
                                                end
                                                end
                                        end else begin
                                        end else begin
                                                if(flit_in_wr)begin
                                                if(flit_in_wr)begin
Line 721... Line 810...
                                                        end else if ( flit_in[Fw-1:Fw-2]==2'b00)begin
                                                        end else if ( flit_in[Fw-1:Fw-2]==2'b00)begin
                                                                old_pck_number[rd_vc_bin]<=rsv_pck_number;
                                                                old_pck_number[rd_vc_bin]<=rsv_pck_number;
                                                                old_flit_counter[rd_vc_bin]<=rsv_flit_counter;
                                                                old_flit_counter[rd_vc_bin]<=rsv_flit_counter;
                                                        end
                                                        end
 
 
                                                end
                                                end //flit_in_wr
 
 
                                        end
                                        end    //reset
                                end
                                end//always
 
 
 
 
                                always @(posedge clk) begin
                                always @(posedge clk) begin
                                        if(flit_in_wr && (flit_in[Fw-1:Fw-2]==2'b00) && (~reset))begin
                                        if(flit_in_wr && (flit_in[Fw-1:Fw-2]==2'b00) && (~reset))begin
                                                if( old_flit_counter[rd_vc_bin]!=rsv_flit_counter-1) $display("%t: Error: missmatch flit counter in %m. Expected %d but recieved %d",$time,old_flit_counter[rd_vc_bin]+1,rsv_flit_counter);
                                                if( old_flit_counter[rd_vc_bin]!=rsv_flit_counter-1) $display("%t: Error: missmatch flit counter in %m. Expected %d but recieved %d",$time,old_flit_counter[rd_vc_bin]+1,rsv_flit_counter);
                                                if( old_pck_number[rd_vc_bin]!=rsv_pck_number && old_pck_number[rd_vc_bin]!=0)   $display("%t: Error: missmatch pck number in %m. expected %d but recieved %d",$time,old_pck_number[rd_vc_bin],rsv_pck_number);
                                                if( old_pck_number[rd_vc_bin]!=rsv_pck_number && old_pck_number[rd_vc_bin]!=0)   $display("%t: Error: missmatch pck number in %m. expected %d but recieved %d",$time,old_pck_number[rd_vc_bin],rsv_pck_number);
 
 
                                        end
                                        end
 
 
                                end
                                end
                                // synthesis translate_on
 
                                // synopsys  translate_on
 
 
 
                        `endif
                        `endif
 
 
 
// synthesis translate_on
 
 
 
 
 
 
 
 
 
 
//                              `ifdef VERILATOR
//                              `ifdef VERILATOR
//                                      logic  endp_is_active   /*verilator public_flat_rd*/ ;
//                                      logic  endp_is_active   /*verilator public_flat_rd*/ ;
//
//
//                                      always @ (*) begin
//                                      always @ (*) begin
//                                              endp_is_active  = 1'b0;
//                                              endp_is_active  = 1'b0;
Line 852... Line 946...
        end
        end
 
 
 
 
 
 
 
 
        `ifdef SYNC_RESET_MODE
        always @ (`pronoc_clk_reset_edge )begin
                always @ (posedge clk )begin
                if(`pronoc_reset) begin
                `else
 
                        always @ (posedge clk or posedge reset)begin
 
                        `endif
 
                        if( reset) begin
 
                                state       <=  STATE_INIT;
                                state       <=  STATE_INIT;
                                inject      <=  1'b0;
                                inject      <=  1'b0;
                                sent        <=  1'b1;
                                sent        <=  1'b1;
                                flit_counter<= 0;
                                flit_counter<= 0;
                                pck_size<=2;
                                pck_size<=2;
Line 891... Line 981...
/*************************************
/*************************************
       packet_buffer
       packet_buffer
**************************************/
**************************************/
 
 
 
 
module packet_gen #(
module packet_gen
 
        import pronoc_pkg::*;
 
        #(
        parameter P = 5,
        parameter P = 5,
        parameter T1= 4,
        parameter PCK_TYPE = "SINGLE_FLIT",
        parameter T2= 4,
 
        parameter T3= 4,
 
        parameter RAw = 3,
 
        parameter EAw = 3,
 
        parameter TOPOLOGY  = "MESH",
 
        parameter DSTPw = 4,
 
        parameter ROUTE_NAME = "XY",
 
        parameter ROUTE_TYPE = "DETERMINISTIC",
        parameter ROUTE_TYPE = "DETERMINISTIC",
        parameter MAX_PCK_NUM   = 10000,
        parameter MAX_PCK_NUM   = 10000,
        parameter MAX_SIM_CLKs  = 100000,
        parameter MAX_SIM_CLKs  = 100000,
        parameter TIMSTMP_FIFO_NUM=16,
        parameter TIMSTMP_FIFO_NUM=16,
        parameter MIN_PCK_SIZE=2,
        parameter MIN_PCK_SIZE=2,
        parameter MAX_PCK_SIZ=100
        parameter MAX_PCK_SIZ=100
 
 
)(
)(
        clk_counter,
        clk_counter,
        pck_wr,
        pck_wr,
        pck_rd,
        pck_rd,
        current_r_addr,
        current_r_addr,
        current_e_addr,
        current_e_addr,
        pck_number,
        pck_number,
        dest_e_addr,
        dest_e_addr_in,
 
        dest_e_addr_o,
        pck_timestamp,
        pck_timestamp,
        destport,
        destport,
        buffer_full,
        buffer_full,
        pck_ready,
        pck_ready,
        valid_dst,
        valid_dst,
Line 947... Line 1032...
        input  reset,clk, pck_wr, pck_rd;
        input  reset,clk, pck_wr, pck_rd;
        input  [RAw-1  :0] current_r_addr;
        input  [RAw-1  :0] current_r_addr;
        input  [EAw-1 : 0] current_e_addr;
        input  [EAw-1 : 0] current_e_addr;
        input  [CLK_CNTw-1 :0] clk_counter;
        input  [CLK_CNTw-1 :0] clk_counter;
        input  [PCK_SIZw-1 :0] pck_size_in;
        input  [PCK_SIZw-1 :0] pck_size_in;
        input  [EAw-1  :0] dest_e_addr;
        input  [DAw-1  :0] dest_e_addr_in;
 
        output [DAw-1  :0] dest_e_addr_o;
        input  valid_dst;
        input  valid_dst;
 
 
        output [PCK_CNTw-1 :0] pck_number;
        output [PCK_CNTw-1 :0] pck_number;
        output [CLK_CNTw-1 :0] pck_timestamp;
        output [CLK_CNTw-1 :0] pck_timestamp;
        output [PCK_SIZw-1 :0] pck_size_o;
        output [PCK_SIZw-1 :0] pck_size_o;
Line 961... Line 1047...
        reg    [PCK_CNTw-1 :0] packet_counter;
        reg    [PCK_CNTw-1 :0] packet_counter;
        wire   buffer_empty;
        wire   buffer_empty;
 
 
        assign pck_ready = ~buffer_empty & valid_dst;
        assign pck_ready = ~buffer_empty & valid_dst;
 
 
 
        generate if(CAST_TYPE == "UNICAST") begin : uni
        conventional_routing #(
        conventional_routing #(
                .TOPOLOGY(TOPOLOGY),
                .TOPOLOGY(TOPOLOGY),
                .ROUTE_NAME(ROUTE_NAME),
                .ROUTE_NAME(ROUTE_NAME),
                .ROUTE_TYPE(ROUTE_TYPE),
                .ROUTE_TYPE(ROUTE_TYPE),
                .T1(T1),
                .T1(T1),
Line 979... Line 1065...
        routing_module
        routing_module
        (
        (
                .reset(reset),
                .reset(reset),
                .clk(clk),
                .clk(clk),
                .current_r_addr(current_r_addr),
                .current_r_addr(current_r_addr),
                .dest_e_addr(dest_e_addr),
                .dest_e_addr(dest_e_addr_o),
                .src_e_addr(current_e_addr),
                .src_e_addr(current_e_addr),
                .destport(destport)
                .destport(destport)
        );
        );
 
        end endgenerate
 
 
        wire timestamp_fifo_nearly_full , timestamp_fifo_full;
        wire timestamp_fifo_nearly_full , timestamp_fifo_full;
        assign buffer_full = (MIN_PCK_SIZE==1) ? timestamp_fifo_nearly_full : timestamp_fifo_full;
        assign buffer_full = (MIN_PCK_SIZE==1) ? timestamp_fifo_nearly_full : timestamp_fifo_full;
 
 
 
        wire  [DAw-1  :0] tmp1;
 
        wire  [PCK_SIZw-1 : 0] tmp2;
 
 
        wire recieve_more_than_0;
        wire recieve_more_than_0;
        fwft_fifo_bram #(
        fwft_fifo_bram #(
                .DATA_WIDTH(CLK_CNTw+PCK_SIZw),
                .DATA_WIDTH(CLK_CNTw+PCK_SIZw+DAw),
                .MAX_DEPTH(TIMSTMP_FIFO_NUM)
                .MAX_DEPTH(TIMSTMP_FIFO_NUM)
        )
        )
        timestamp_fifo
        timestamp_fifo
        (
        (
                .din({pck_size_in,clk_counter}),
                .din({dest_e_addr_in,pck_size_in,clk_counter}),
                .wr_en(pck_wr),
                .wr_en(pck_wr),
                .rd_en(pck_rd),
                .rd_en(pck_rd),
                .dout({pck_size_o,pck_timestamp}),
                .dout({tmp1,tmp2,pck_timestamp}),
                .full(timestamp_fifo_full),
                .full(timestamp_fifo_full),
                .nearly_full(timestamp_fifo_nearly_full),
                .nearly_full(timestamp_fifo_nearly_full),
                .recieve_more_than_0(recieve_more_than_0),
                .recieve_more_than_0(recieve_more_than_0),
                .recieve_more_than_1(),
                .recieve_more_than_1(),
                .reset(reset),
                .reset(reset),
                .clk(clk)
                .clk(clk)
        );
        );
 
 
 
        //assign dest_e_addr_o = dest_e_addr_in;
 
 
 
        assign dest_e_addr_o =tmp1;
 
        /* verilator lint_off WIDTH */
 
        assign pck_size_o = (PCK_TYPE == "SINGLE_FLIT" )?   1 : tmp2;
 
        /* verilator lint_on WIDTH */
        assign buffer_empty = ~recieve_more_than_0;
        assign buffer_empty = ~recieve_more_than_0;
 
 
                                /*
                                /*
 
 
    bram_based_fifo #(
    bram_based_fifo #(
Line 1029... Line 1124...
        .reset(reset),
        .reset(reset),
        .clk(clk)
        .clk(clk)
    );
    );
                                 */
                                 */
 
 
        `ifdef SYNC_RESET_MODE
        always @ (`pronoc_clk_reset_edge )begin
                always @ (posedge clk )begin
                if(`pronoc_reset) begin
                `else
 
                        always @ (posedge clk or posedge reset)begin
 
                        `endif
 
                        if(reset) begin
 
                                packet_counter <= {PCK_CNTw{1'b0}};
                                packet_counter <= {PCK_CNTw{1'b0}};
 
 
                        end else begin
                        end else begin
                                if(pck_rd) begin
                                if(pck_rd) begin
                                        packet_counter <= packet_counter+1'b1;
                                        packet_counter <= packet_counter+1'b1;
 
 
                                end
                                end

powered by: WebSVN 2.1.0

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