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/] [mesh_torus_noc_top.sv] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
// synthesis translate_off
2
`timescale 1ns / 1ps
3
// synthesis translate_on
4
 
5
/**********************************************************************
6
**    File:  mesh_torus_noc.v
7
**
8
**    Copyright (C) 2014-2017  Alireza Monemi
9
**
10
**    This file is part of ProNoC
11
**
12
**    ProNoC ( stands for Prototype Network-on-chip)  is free software:
13
**    you can redistribute it and/or modify it under the terms of the GNU
14
**    Lesser General Public License as published by the Free Software Foundation,
15
**    either version 2 of the License, or (at your option) any later version.
16
**
17
**     ProNoC is distributed in the hope that it will be useful, but WITHOUT
18
**     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19
**     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
20
**     Public License for more details.
21
**
22
**     You should have received a copy of the GNU Lesser General Public
23
**     License along with ProNoC. If not, see .
24
**
25
**
26
**    Description:
27
**    the NoC top module. It generate one of the mesh, torus, ring, or line  topologies by
28
**    connecting routers
29
**
30
**************************************************************/
31
 
32
 
33
`define router_id(x,y)                         ((y * NX) +    x)
34
`define endp_id(x,y,l)                         ((y * NX) +    x) * NL + l
35
 
36
 
37
 
38
module mesh_torus_noc_top
39
                import pronoc_pkg::*;
40
        (
41
 
42
    reset,
43
    clk,
44
    chan_in_all,
45
    chan_out_all
46
);
47
 
48
 
49
        input   clk,reset;
50
        //local ports
51
        input   smartflit_chanel_t chan_in_all  [NE-1 : 0];
52
        output  smartflit_chanel_t chan_out_all [NE-1 : 0];
53
 
54
        //all routers port
55
        smartflit_chanel_t    router_chan_in   [NR-1 :0][MAX_P-1 : 0];
56
        smartflit_chanel_t    router_chan_out  [NR-1 :0][MAX_P-1 : 0];
57
 
58
        wire [RAw-1 : 0] current_r_addr [NR-1 : 0];
59
 
60
        // mesh torus
61
        localparam
62
                EAST   =       3'd1,
63
                NORTH  =       3'd2,
64
                WEST   =       3'd3,
65
                SOUTH  =       3'd4;
66
        //ring line
67
        localparam
68
                FORWARD =  2'd1,
69
                BACKWARD=  2'd2;
70
 
71
 
72
        genvar x,y,l;
73
        generate
74
        /* verilator lint_off WIDTH */
75
                if( TOPOLOGY == "RING" || TOPOLOGY == "LINE") begin : ring_line
76
                        /* verilator lint_on WIDTH */
77
                        for  (x=0;   x
78
 
79
 
80
                                assign current_r_addr [x] = x[RAw-1: 0];
81
 
82
                                router_top #(
83
                                        .P               (MAX_P          )
84
                                        ) the_router (
85
                                        .current_r_addr  (current_r_addr [x]),
86
                                        .chan_in         (router_chan_in [x]),
87
                                        .chan_out        (router_chan_out[x]),
88
                                        .clk             (clk            ),
89
                                        .reset           (reset          ));
90
 
91
                                if(x    <   NX-1) begin: not_last_node
92
                                        assign  router_chan_in[x][FORWARD] = router_chan_out [(x+1)][BACKWARD];
93
                                end else begin :last_node
94
                                        /* verilator lint_off WIDTH */
95
                                        if(TOPOLOGY == "LINE") begin : line_last_x
96
                                        /* verilator lint_on WIDTH */
97
                                                assign  router_chan_in[x][FORWARD]= {SMARTFLIT_CHANEL_w{1'b0}};
98
                                        end else begin : ring_last_x
99
                                                assign router_chan_in[x][FORWARD]= router_chan_out [0][BACKWARD];
100
                                        end
101
                                end
102
 
103
                                if(x>0)begin :not_first_x
104
                                        assign router_chan_in[x][BACKWARD]= router_chan_out [(x-1)][FORWARD];
105
                                end else begin :first_x
106
                                        /* verilator lint_off WIDTH */
107
                                        if(TOPOLOGY == "LINE") begin : line_first_x
108
                                                /* verilator lint_on WIDTH */
109
                                                assign  router_chan_in[x][BACKWARD]={SMARTFLIT_CHANEL_w{1'b0}};
110
                                        end else begin : ring_first_x
111
                                                assign  router_chan_in[x][BACKWARD]= router_chan_out [(NX-1)][FORWARD];
112
                                        end
113
                                end
114
 
115
                                // connect other local ports
116
                                for  (l=0;   l
117
                                        localparam ENDPID = `endp_id(x,0,l);
118
                                        localparam LOCALP = (l==0) ? l : l + R2R_CHANELS_MESH_TORI; // first local port is connected to router port 0. The rest are connected at the end
119
                                        assign router_chan_in[x][LOCALP]= chan_in_all [ENDPID];
120
                                        assign chan_out_all [ENDPID] = router_chan_out[x][LOCALP];
121
 
122
                                end// locals
123
                        end//x
124
 
125
                end else begin :mesh_torus
126
                        for (y=0;    y
127
                                for (x=0;    x
128
                                localparam R_ADDR = (y<
129
                                localparam ROUTER_NUM = (y * NX) +    x;
130
                                assign current_r_addr [ROUTER_NUM] = R_ADDR[RAw-1 :0];
131
 
132
                                        router_top #(
133
                                                .P               (MAX_P          )
134
                                        ) the_router (
135
                                                .current_r_addr  (current_r_addr [ROUTER_NUM]),
136
                                                .chan_in         (router_chan_in [ROUTER_NUM]),
137
                                                .chan_out        (router_chan_out[ROUTER_NUM]),
138
                                                .clk             (clk            ),
139
                                                .reset           (reset          ));
140
 
141
 
142
                                /*
143
    in [x,y][east] <------  out [x+1 ,y  ][west] ;
144
    in [x,y][north] <------ out [x   ,y-1][south] ;
145
    in [x,y][west] <------  out [x-1 ,y  ][east] ;
146
    in [x,y][south] <------ out [x   ,y+1][north] ;
147
                                 */
148
 
149
 
150
                                if(x    <    NX-1) begin: not_last_x
151
                                        assign router_chan_in[`router_id(x,y)][EAST]= router_chan_out [`router_id(x+1,y)][WEST];
152
                                        //assign    router_credit_in_all [`SELECT_WIRE(x,y,EAST,V)] = router_credit_out_all [`SELECT_WIRE((x+1),y,WEST,V)];
153
                                end else begin :last_x
154
                                        /* verilator lint_off WIDTH */
155
                                        if(TOPOLOGY == "MESH") begin :last_x_mesh
156
                                        /* verilator lint_on WIDTH */
157
                                                assign router_chan_in[`router_id(x,y)][EAST] = {SMARTFLIT_CHANEL_w{1'b0}};
158
                                        /* verilator lint_off WIDTH */
159
                                        end else if(TOPOLOGY == "TORUS") begin : last_x_torus
160
                                        /* verilator lint_on WIDTH */
161
                                                assign router_chan_in[`router_id(x,y)][EAST] = router_chan_out [`router_id(0,y)][WEST];
162
                                        /* verilator lint_off WIDTH */
163
                                        end else if(TOPOLOGY == "FMESH") begin : last_x_fmesh //connect to endp
164
                                        /* verilator lint_on WIDTH */
165
                                                localparam EAST_ID = NX*NY*NL + 2*NX + NY +y;
166
                                                assign router_chan_in [`router_id(x,y)][EAST] =    chan_in_all [EAST_ID];
167
                                                assign chan_out_all [EAST_ID] = router_chan_out [`router_id(x,y)][EAST];
168
                                        end //topology
169
                                end
170
 
171
 
172
                                if(y>0) begin : not_first_y
173
                                        assign router_chan_in[`router_id(x,y)][NORTH] =  router_chan_out [`router_id(x,(y-1))][SOUTH];
174
                                end else begin :first_y
175
                                        /* verilator lint_off WIDTH */
176
                                        if(TOPOLOGY == "MESH") begin : first_y_mesh
177
                                        /* verilator lint_on WIDTH */
178
                                                assign router_chan_in[`router_id(x,y)][NORTH] =  {SMARTFLIT_CHANEL_w{1'b0}};
179
                                        /* verilator lint_off WIDTH */
180
                                        end else if(TOPOLOGY == "TORUS") begin :first_y_torus
181
                                        /* verilator lint_on WIDTH */
182
                                                assign router_chan_in[`router_id(x,y)][NORTH] =  router_chan_out [`router_id(x,(NY-1))][SOUTH];
183
                                        /* verilator lint_off WIDTH */
184
                                        end else if(TOPOLOGY == "FMESH") begin : first_y_fmesh //connect to endp
185
                                        /* verilator lint_on WIDTH */
186
                                                localparam NORTH_ID = NX*NY*NL + x;
187
                                                assign router_chan_in [`router_id(x,y)][NORTH] =    chan_in_all [NORTH_ID];
188
                                                assign chan_out_all [NORTH_ID] = router_chan_out [`router_id(x,y)][NORTH];
189
                                        end//topology
190
                                end//y>0
191
 
192
 
193
                                if(x>0)begin :not_first_x
194
                                        assign    router_chan_in[`router_id(x,y)][WEST] =  router_chan_out [`router_id((x-1),y)][EAST];
195
                                end else begin :first_x
196
                                        /* verilator lint_off WIDTH */
197
                                        if(TOPOLOGY == "MESH") begin :first_x_mesh
198
                                        /* verilator lint_on WIDTH */
199
                                                assign    router_chan_in[`router_id(x,y)][WEST] =   {SMARTFLIT_CHANEL_w{1'b0}};
200
                                        /* verilator lint_off WIDTH */
201
                                        end else if(TOPOLOGY == "TORUS") begin :first_x_torus
202
                                        /* verilator lint_on WIDTH */
203
                                                assign    router_chan_in[`router_id(x,y)][WEST] =   router_chan_out [`router_id((NX-1),y)][EAST] ;
204
                                        /* verilator lint_off WIDTH */
205
                                        end else if(TOPOLOGY == "FMESH") begin : first_x_fmesh //connect to endp
206
                                        /* verilator lint_on WIDTH */
207
                                                localparam WEST_ID = NX*NY*NL +2*NX + y;
208
                                                assign router_chan_in [`router_id(x,y)][WEST] =    chan_in_all [WEST_ID];
209
                                                assign chan_out_all [WEST_ID] = router_chan_out [`router_id(x,y)][WEST];
210
                                        end//topology
211
                                end
212
 
213
                                if(y    <    NY-1) begin : firsty
214
                                        assign  router_chan_in[`router_id(x,y)][SOUTH] =    router_chan_out [`router_id(x,(y+1))][NORTH];
215
                                end else     begin : lasty
216
                                        /* verilator lint_off WIDTH */
217
                                        if(TOPOLOGY == "MESH") begin :ly_mesh
218
                                                /* verilator lint_on WIDTH */
219
                                                assign  router_chan_in[`router_id(x,y)][SOUTH]=  {SMARTFLIT_CHANEL_w{1'b0}};
220
                                                /* verilator lint_off WIDTH */
221
                                        end else if(TOPOLOGY == "TORUS") begin :ly_torus
222
                                                /* verilator lint_on WIDTH */
223
                                                assign  router_chan_in[`router_id(x,y)][SOUTH]=    router_chan_out [`router_id(x,0)][NORTH];
224
                                        end else if(TOPOLOGY == "FMESH") begin : ly_fmesh //connect to endp
225
                                                /* verilator lint_on WIDTH */
226
                                                localparam SOUTH_ID = NX*NY*NL + NX + x;
227
                                                assign router_chan_in [`router_id(x,y)][SOUTH] =    chan_in_all [SOUTH_ID];
228
                                                assign chan_out_all [SOUTH_ID] = router_chan_out [`router_id(x,y)][SOUTH];
229
                                        end//topology
230
                                end
231
 
232
 
233
                                // endpoint(s) connection
234
                                // connect other local ports
235
                                for  (l=0;   l
236
                                        localparam ENDPID = `endp_id(x,y,l);
237
                                        localparam LOCALP = (l==0) ? l : l + R2R_CHANELS_MESH_TORI; // first local port is connected to router port 0. The rest are connected at the end
238
 
239
                                        assign router_chan_in [`router_id(x,y)][LOCALP] =    chan_in_all [ENDPID];
240
                                        assign chan_out_all [ENDPID] = router_chan_out [`router_id(x,y)][LOCALP];
241
 
242
                                end// locals
243
 
244
                                end //y
245
                                end //x
246
                                end// mesh_torus
247
 
248
                                endgenerate
249
 
250
endmodule

powered by: WebSVN 2.1.0

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