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 48

Go to most recent revision | 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
    parameter TOPOLOGY = "MESH",
30
    parameter V    = 4,     // vc_num_per_port
31
    parameter P    = 5,     // router port num
32
    parameter Fw     = 36,
33
    parameter MUX_TYPE="BINARY",        //"ONE_HOT" or "BINARY"    
34
    parameter SSA_EN="YES", // "YES" , "NO"
35
    parameter SELF_LOOP_EN= "NO"
36
)
37
(
38
    granted_dest_port_all,
39
    flit_in_all,
40
    flit_out_all,
41
    flit_out_wr_all,
42
    ssa_flit_wr_all
43
 );
44
 
45
 
46
    function integer log2;
47
      input integer number; begin
48
         log2=(number <=1) ? 1: 0;
49
         while(2**log2<number) begin
50
            log2=log2+1;
51
         end
52
      end
53
    endfunction // log2 
54
 
55
    localparam
56
        PV = V * P,
57
        VV = V * V,
58
        PP = P * P,
59
        PVV = PV * V,
60
        P_1 = (SELF_LOOP_EN == "NO")? P-1 : P,
61
        VP_1 = V * P_1,
62
        PP_1 = P_1 * P,
63
        PVP_1 = PV * P_1,
64
        PFw = P*Fw,
65
        P_1Fw = P_1 * Fw,
66
        P_1w = log2(P_1);
67
 
68
 
69
    input [PP_1-1 : 0] granted_dest_port_all;
70
    input [PFw-1 : 0] flit_in_all;
71
    output [PFw-1 : 0] flit_out_all;
72
    output [P-1 : 0] flit_out_wr_all;
73
    input  [P-1 : 0] ssa_flit_wr_all;
74
 
75
 
76
    wire [P-1 : 0]  flit_we_mux_out;
77
    wire [P_1-1 : 0] granted_dest_port [P-1 : 0];
78
    wire [P_1Fw-1 : 0] mux_in [P-1 : 0];
79
    wire [P_1-1 : 0] mux_sel_pre [P-1 : 0];
80
    wire [P_1-1 : 0]  mux_sel [P-1 : 0];
81
    wire [P_1w-1 : 0] mux_sel_bin [P-1 : 0];
82
    wire [PP-1 : 0] flit_out_wr_gen;
83
 
84
    genvar i,j;
85
    generate
86
    for(i=0;i<P;i=i+1)begin : port_loop
87
        assign granted_dest_port[i] = granted_dest_port_all[(i+1)*P_1-1 : i*P_1];
88
        for(j=0;j<P;j=j+1)begin : port_loop2
89
            if(SELF_LOOP_EN == "NO") begin : nslp
90
                //remove sender port flit from flit list
91
                if(i>j)    begin :if1
92
                    assign mux_in[i][(j+1)*Fw-1 : j*Fw]=     flit_in_all[(j+1)*Fw-1 : j*Fw];
93
                    assign mux_sel_pre[i][j] =    granted_dest_port[j][i-1];
94
                end
95
                else if(i<j) begin :if2
96
                    assign mux_in[i][j*Fw-1 : (j-1)*Fw]=     flit_in_all[(j+1)*Fw-1 : j*Fw];
97
                    assign mux_sel_pre[i][j-1] =    granted_dest_port[j][i];
98
                end
99
            end else begin : slp
100
                assign mux_in[i][(j+1)*Fw-1 : j*Fw]=     flit_in_all[(j+1)*Fw-1 : j*Fw];
101
                assign mux_sel_pre[i][j] =    granted_dest_port[j][i];
102
            end
103
        end//for j
104
 
105
 
106
 
107
        /* verilator lint_off WIDTH */
108
        if (SSA_EN =="YES")begin :predict //If no output is granted replace the output port with SS port
109
        /* verilator lint_on WIDTH */
110
            add_ss_port #(
111
                .SW_LOC(i),
112
                    .P(P)
113
            )
114
            ss_port
115
            (
116
                .destport_in (mux_sel_pre[i]),
117
                .destport_out(mux_sel [i])
118
            );
119
 
120
        end else begin :nopredict
121
               assign mux_sel[i]= mux_sel_pre[i];
122
 
123
        end
124
 
125
        /* verilator lint_off WIDTH */
126
        if    (MUX_TYPE    ==    "ONE_HOT") begin : one_hot_gen
127
        /* verilator lint_on WIDTH */
128
            onehot_mux_1D #(
129
                .W (Fw),
130
                .N (P_1)
131
            )
132
            cross_mux
133
            (
134
                .in (mux_in [i]),
135
                .out (flit_out_all[(i+1)*Fw-1 : i*Fw]),
136
                .sel (mux_sel[i])
137
 
138
            );
139
        end else begin : binary
140
 
141
            one_hot_to_bin #(
142
                .ONE_HOT_WIDTH(P_1),
143
                .BIN_WIDTH(P_1w)
144
            )
145
            conv
146
            (
147
                .one_hot_code(mux_sel[i]),
148
                .bin_code(mux_sel_bin[i])
149
 
150
            );
151
 
152
 
153
            binary_mux #(
154
                .IN_WIDTH(P_1Fw),
155
                .OUT_WIDTH(Fw)
156
            )
157
            cross_mux
158
            (
159
                .mux_in(mux_in [i]),
160
                .mux_out(flit_out_all[(i+1)*Fw-1 : i*Fw]),
161
                .sel(mux_sel_bin[i])
162
 
163
            );
164
        end//binary
165
 
166
 
167
        if(SELF_LOOP_EN == "NO") begin : nslp
168
            add_sw_loc_one_hot #(
169
                .P(P),
170
                .SW_LOC(i)
171
            )
172
            add_sw_loc
173
            (
174
                .destport_in(granted_dest_port_all[(i+1)*P_1-1 : i*P_1]),
175
                .destport_out(flit_out_wr_gen [(i+1)*P-1 : i*P])
176
            );
177
        end else begin :slp
178
            assign flit_out_wr_gen [(i+1)*P-1 : i*P] = granted_dest_port_all[(i+1)*P_1-1 : i*P_1];
179
        end
180
 
181
    end//for i    
182
    endgenerate
183
 
184
    custom_or #(
185
        .IN_NUM(P),
186
        .OUT_WIDTH(P)
187
    )
188
    wide_or
189
    (
190
        .or_in(flit_out_wr_gen),
191
        .or_out(flit_we_mux_out)
192
    );
193
 
194
    assign    flit_out_wr_all = flit_we_mux_out | ssa_flit_wr_all;
195
 
196
 
197
 
198
endmodule

powered by: WebSVN 2.1.0

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