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/] [crossbar.v] - Blame information for rev 56

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
`timescale     1ns/1ps
2
/**********************************************************************
3
**      File: crossbar.v
4
**
5
**      Copyright (C) 2014-2017  Alireza Monemi
6
**
7
**      This file is part of ProNoC
8
**
9
**      ProNoC ( stands for Prototype Network-on-chip)  is free software:
10
**      you can redistribute it and/or modify it under the terms of the GNU
11
**      Lesser General Public License as published by the Free Software Foundation,
12
**      either version 2 of the License, or (at your option) any later version.
13
**
14
**      ProNoC is distributed in the hope that it will be useful, but WITHOUT
15
**      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
**      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
17
**      Public License for more details.
18
**
19
**      You should have received a copy of the GNU Lesser General Public
20
**      License along with ProNoC. If not, see <http:**www.gnu.org/licenses/>.
21
**
22
**
23
**      Description:
24
**      NoC router crosbar module
25
**
26
**************************************************************/
27
 
28
module crossbar #(
29 56 alirezamon
    parameter NOC_ID=0,
30 48 alirezamon
    parameter TOPOLOGY = "MESH",
31
    parameter V    = 4,     // vc_num_per_port
32
    parameter P    = 5,     // router port num
33
    parameter Fw     = 36,
34
    parameter MUX_TYPE="BINARY",        //"ONE_HOT" or "BINARY"    
35
    parameter SSA_EN="YES", // "YES" , "NO"
36
    parameter SELF_LOOP_EN= "NO"
37
)
38
(
39
    granted_dest_port_all,
40
    flit_in_all,
41
    flit_out_all,
42
    flit_out_wr_all,
43
    ssa_flit_wr_all
44
 );
45
 
46
 
47
    function integer log2;
48
      input integer number; begin
49
         log2=(number <=1) ? 1: 0;
50
         while(2**log2<number) begin
51
            log2=log2+1;
52
         end
53
      end
54
    endfunction // log2 
55
 
56
    localparam
57
        PV = V * P,
58
        VV = V * V,
59
        PP = P * P,
60
        PVV = PV * V,
61
        P_1 = (SELF_LOOP_EN == "NO")? P-1 : P,
62
        VP_1 = V * P_1,
63
        PP_1 = P_1 * P,
64
        PVP_1 = PV * P_1,
65
        PFw = P*Fw,
66
        P_1Fw = P_1 * Fw,
67
        P_1w = log2(P_1);
68
 
69
 
70
    input [PP_1-1 : 0] granted_dest_port_all;
71
    input [PFw-1 : 0] flit_in_all;
72
    output [PFw-1 : 0] flit_out_all;
73
    output [P-1 : 0] flit_out_wr_all;
74
    input  [P-1 : 0] ssa_flit_wr_all;
75
 
76
 
77
    wire [P-1 : 0]  flit_we_mux_out;
78
    wire [P_1-1 : 0] granted_dest_port [P-1 : 0];
79
    wire [P_1Fw-1 : 0] mux_in [P-1 : 0];
80
    wire [P_1-1 : 0] mux_sel_pre [P-1 : 0];
81
    wire [P_1-1 : 0]  mux_sel [P-1 : 0];
82
    wire [P_1w-1 : 0] mux_sel_bin [P-1 : 0];
83
    wire [PP-1 : 0] flit_out_wr_gen;
84
 
85
    genvar i,j;
86
    generate
87
    for(i=0;i<P;i=i+1)begin : port_loop
88
        assign granted_dest_port[i] = granted_dest_port_all[(i+1)*P_1-1 : i*P_1];
89
        for(j=0;j<P;j=j+1)begin : port_loop2
90
            if(SELF_LOOP_EN == "NO") begin : nslp
91
                //remove sender port flit from flit list
92
                if(i>j)    begin :if1
93
                    assign mux_in[i][(j+1)*Fw-1 : j*Fw]=     flit_in_all[(j+1)*Fw-1 : j*Fw];
94
                    assign mux_sel_pre[i][j] =    granted_dest_port[j][i-1];
95
                end
96
                else if(i<j) begin :if2
97
                    assign mux_in[i][j*Fw-1 : (j-1)*Fw]=     flit_in_all[(j+1)*Fw-1 : j*Fw];
98
                    assign mux_sel_pre[i][j-1] =    granted_dest_port[j][i];
99
                end
100
            end else begin : slp
101
                assign mux_in[i][(j+1)*Fw-1 : j*Fw]=     flit_in_all[(j+1)*Fw-1 : j*Fw];
102
                assign mux_sel_pre[i][j] =    granted_dest_port[j][i];
103
            end
104
        end//for j
105
 
106
 
107
 
108
        /* verilator lint_off WIDTH */
109
        if (SSA_EN =="YES")begin :predict //If no output is granted replace the output port with SS port
110
        /* verilator lint_on WIDTH */
111
            add_ss_port #(
112 56 alirezamon
                .NOC_ID(NOC_ID),
113 48 alirezamon
                .SW_LOC(i),
114
                    .P(P)
115
            )
116
            ss_port
117
            (
118
                .destport_in (mux_sel_pre[i]),
119
                .destport_out(mux_sel [i])
120
            );
121
 
122
        end else begin :nopredict
123
               assign mux_sel[i]= mux_sel_pre[i];
124
 
125
        end
126
 
127
        /* verilator lint_off WIDTH */
128
        if    (MUX_TYPE    ==    "ONE_HOT") begin : one_hot_gen
129
        /* verilator lint_on WIDTH */
130
            onehot_mux_1D #(
131
                .W (Fw),
132
                .N (P_1)
133
            )
134
            cross_mux
135
            (
136
                .in (mux_in [i]),
137
                .out (flit_out_all[(i+1)*Fw-1 : i*Fw]),
138
                .sel (mux_sel[i])
139
 
140
            );
141
        end else begin : binary
142
 
143
            one_hot_to_bin #(
144
                .ONE_HOT_WIDTH(P_1),
145
                .BIN_WIDTH(P_1w)
146
            )
147
            conv
148
            (
149
                .one_hot_code(mux_sel[i]),
150
                .bin_code(mux_sel_bin[i])
151
 
152
            );
153
 
154
 
155
            binary_mux #(
156
                .IN_WIDTH(P_1Fw),
157
                .OUT_WIDTH(Fw)
158
            )
159
            cross_mux
160
            (
161
                .mux_in(mux_in [i]),
162
                .mux_out(flit_out_all[(i+1)*Fw-1 : i*Fw]),
163
                .sel(mux_sel_bin[i])
164
 
165
            );
166
        end//binary
167
 
168
 
169
        if(SELF_LOOP_EN == "NO") begin : nslp
170
            add_sw_loc_one_hot #(
171
                .P(P),
172
                .SW_LOC(i)
173
            )
174
            add_sw_loc
175
            (
176
                .destport_in(granted_dest_port_all[(i+1)*P_1-1 : i*P_1]),
177
                .destport_out(flit_out_wr_gen [(i+1)*P-1 : i*P])
178
            );
179
        end else begin :slp
180
            assign flit_out_wr_gen [(i+1)*P-1 : i*P] = granted_dest_port_all[(i+1)*P_1-1 : i*P_1];
181
        end
182
 
183
    end//for i    
184
    endgenerate
185
 
186
    custom_or #(
187
        .IN_NUM(P),
188
        .OUT_WIDTH(P)
189
    )
190
    wide_or
191
    (
192
        .or_in(flit_out_wr_gen),
193
        .or_out(flit_we_mux_out)
194
    );
195
 
196
    assign    flit_out_wr_all = flit_we_mux_out | ssa_flit_wr_all;
197
 
198
 
199
 
200
endmodule

powered by: WebSVN 2.1.0

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