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 54

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

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

powered by: WebSVN 2.1.0

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