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 56

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 56 alirezamon
module mesh_torus_noc_top #(
37
        parameter NOC_ID=0
38
) (
39 48 alirezamon
    reset,
40
    clk,
41
    chan_in_all,
42 54 alirezamon
    chan_out_all,
43
    router_event
44 48 alirezamon
);
45
 
46 56 alirezamon
    `NOC_CONF
47 48 alirezamon
 
48
        input   clk,reset;
49 54 alirezamon
        //Endpoints ports
50 48 alirezamon
        input   smartflit_chanel_t chan_in_all  [NE-1 : 0];
51
        output  smartflit_chanel_t chan_out_all [NE-1 : 0];
52
 
53 54 alirezamon
        //Events
54
        output  router_event_t  router_event [NR-1 : 0][MAX_P-1 : 0];
55
 
56 48 alirezamon
        //all routers port
57
        smartflit_chanel_t    router_chan_in   [NR-1 :0][MAX_P-1 : 0];
58
        smartflit_chanel_t    router_chan_out  [NR-1 :0][MAX_P-1 : 0];
59
 
60 56 alirezamon
        wire [RAw-1 : 0] current_r_addr [NR-1 : 0];
61 48 alirezamon
 
62
        genvar x,y,l;
63
        generate
64
        /* verilator lint_off WIDTH */
65
                if( TOPOLOGY == "RING" || TOPOLOGY == "LINE") begin : ring_line
66
                        /* verilator lint_on WIDTH */
67
                        for  (x=0;   x
68
 
69
 
70
                                assign current_r_addr [x] = x[RAw-1: 0];
71
 
72
                                router_top #(
73 56 alirezamon
                                        .NOC_ID(NOC_ID),
74 48 alirezamon
                                        .P               (MAX_P          )
75
                                        ) the_router (
76 54 alirezamon
                                        .current_r_id    (x),
77 48 alirezamon
                                        .current_r_addr  (current_r_addr [x]),
78
                                        .chan_in         (router_chan_in [x]),
79
                                        .chan_out        (router_chan_out[x]),
80 54 alirezamon
                                        .router_event    (router_event[x]),
81 48 alirezamon
                                        .clk             (clk            ),
82
                                        .reset           (reset          ));
83
 
84
                                if(x    <   NX-1) begin: not_last_node
85
                                        assign  router_chan_in[x][FORWARD] = router_chan_out [(x+1)][BACKWARD];
86
                                end else begin :last_node
87
                                        /* verilator lint_off WIDTH */
88
                                        if(TOPOLOGY == "LINE") begin : line_last_x
89
                                        /* verilator lint_on WIDTH */
90
                                                assign  router_chan_in[x][FORWARD]= {SMARTFLIT_CHANEL_w{1'b0}};
91
                                        end else begin : ring_last_x
92
                                                assign router_chan_in[x][FORWARD]= router_chan_out [0][BACKWARD];
93
                                        end
94
                                end
95
 
96
                                if(x>0)begin :not_first_x
97
                                        assign router_chan_in[x][BACKWARD]= router_chan_out [(x-1)][FORWARD];
98
                                end else begin :first_x
99
                                        /* verilator lint_off WIDTH */
100
                                        if(TOPOLOGY == "LINE") begin : line_first_x
101
                                                /* verilator lint_on WIDTH */
102
                                                assign  router_chan_in[x][BACKWARD]={SMARTFLIT_CHANEL_w{1'b0}};
103
                                        end else begin : ring_first_x
104
                                                assign  router_chan_in[x][BACKWARD]= router_chan_out [(NX-1)][FORWARD];
105
                                        end
106
                                end
107
 
108
                                // connect other local ports
109
                                for  (l=0;   l
110
                                        localparam ENDPID = `endp_id(x,0,l);
111
                                        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
112
                                        assign router_chan_in[x][LOCALP]= chan_in_all [ENDPID];
113
                                        assign chan_out_all [ENDPID] = router_chan_out[x][LOCALP];
114
 
115
                                end// locals
116
                        end//x
117
 
118
                end else begin :mesh_torus
119
                        for (y=0;    y
120
                                for (x=0;    x
121
                                localparam R_ADDR = (y<
122 54 alirezamon
                                localparam RID = (y * NX) +    x;
123
                                assign current_r_addr [RID] = R_ADDR[RAw-1 :0];
124 48 alirezamon
 
125
                                        router_top #(
126 56 alirezamon
                                                .NOC_ID(NOC_ID),
127 48 alirezamon
                                                .P               (MAX_P          )
128 54 alirezamon
                                        ) the_router (
129
                                                .current_r_id    (RID),
130
                                                .current_r_addr  (current_r_addr [RID]),
131
                                                .chan_in         (router_chan_in [RID]),
132
                                                .chan_out        (router_chan_out[RID]),
133
                                                .router_event    (router_event[RID]),
134 48 alirezamon
                                                .clk             (clk            ),
135
                                                .reset           (reset          ));
136
 
137
 
138
                                /*
139
    in [x,y][east] <------  out [x+1 ,y  ][west] ;
140
    in [x,y][north] <------ out [x   ,y-1][south] ;
141
    in [x,y][west] <------  out [x-1 ,y  ][east] ;
142
    in [x,y][south] <------ out [x   ,y+1][north] ;
143
                                 */
144
 
145
 
146
                                if(x    <    NX-1) begin: not_last_x
147
                                        assign router_chan_in[`router_id(x,y)][EAST]= router_chan_out [`router_id(x+1,y)][WEST];
148
                                        //assign    router_credit_in_all [`SELECT_WIRE(x,y,EAST,V)] = router_credit_out_all [`SELECT_WIRE((x+1),y,WEST,V)];
149
                                end else begin :last_x
150
                                        /* verilator lint_off WIDTH */
151
                                        if(TOPOLOGY == "MESH") begin :last_x_mesh
152
                                        /* verilator lint_on WIDTH */
153
                                                assign router_chan_in[`router_id(x,y)][EAST] = {SMARTFLIT_CHANEL_w{1'b0}};
154
                                        /* verilator lint_off WIDTH */
155
                                        end else if(TOPOLOGY == "TORUS") begin : last_x_torus
156
                                        /* verilator lint_on WIDTH */
157
                                                assign router_chan_in[`router_id(x,y)][EAST] = router_chan_out [`router_id(0,y)][WEST];
158
                                        /* verilator lint_off WIDTH */
159
                                        end else if(TOPOLOGY == "FMESH") begin : last_x_fmesh //connect to endp
160
                                        /* verilator lint_on WIDTH */
161
                                                localparam EAST_ID = NX*NY*NL + 2*NX + NY +y;
162
                                                assign router_chan_in [`router_id(x,y)][EAST] =    chan_in_all [EAST_ID];
163
                                                assign chan_out_all [EAST_ID] = router_chan_out [`router_id(x,y)][EAST];
164
                                        end //topology
165
                                end
166
 
167
 
168
                                if(y>0) begin : not_first_y
169
                                        assign router_chan_in[`router_id(x,y)][NORTH] =  router_chan_out [`router_id(x,(y-1))][SOUTH];
170
                                end else begin :first_y
171
                                        /* verilator lint_off WIDTH */
172
                                        if(TOPOLOGY == "MESH") begin : first_y_mesh
173
                                        /* verilator lint_on WIDTH */
174
                                                assign router_chan_in[`router_id(x,y)][NORTH] =  {SMARTFLIT_CHANEL_w{1'b0}};
175
                                        /* verilator lint_off WIDTH */
176
                                        end else if(TOPOLOGY == "TORUS") begin :first_y_torus
177
                                        /* verilator lint_on WIDTH */
178
                                                assign router_chan_in[`router_id(x,y)][NORTH] =  router_chan_out [`router_id(x,(NY-1))][SOUTH];
179
                                        /* verilator lint_off WIDTH */
180
                                        end else if(TOPOLOGY == "FMESH") begin : first_y_fmesh //connect to endp
181
                                        /* verilator lint_on WIDTH */
182
                                                localparam NORTH_ID = NX*NY*NL + x;
183
                                                assign router_chan_in [`router_id(x,y)][NORTH] =    chan_in_all [NORTH_ID];
184
                                                assign chan_out_all [NORTH_ID] = router_chan_out [`router_id(x,y)][NORTH];
185
                                        end//topology
186
                                end//y>0
187
 
188
 
189
                                if(x>0)begin :not_first_x
190
                                        assign    router_chan_in[`router_id(x,y)][WEST] =  router_chan_out [`router_id((x-1),y)][EAST];
191
                                end else begin :first_x
192
                                        /* verilator lint_off WIDTH */
193
                                        if(TOPOLOGY == "MESH") begin :first_x_mesh
194
                                        /* verilator lint_on WIDTH */
195
                                                assign    router_chan_in[`router_id(x,y)][WEST] =   {SMARTFLIT_CHANEL_w{1'b0}};
196
                                        /* verilator lint_off WIDTH */
197
                                        end else if(TOPOLOGY == "TORUS") begin :first_x_torus
198
                                        /* verilator lint_on WIDTH */
199
                                                assign    router_chan_in[`router_id(x,y)][WEST] =   router_chan_out [`router_id((NX-1),y)][EAST] ;
200
                                        /* verilator lint_off WIDTH */
201
                                        end else if(TOPOLOGY == "FMESH") begin : first_x_fmesh //connect to endp
202
                                        /* verilator lint_on WIDTH */
203
                                                localparam WEST_ID = NX*NY*NL +2*NX + y;
204
                                                assign router_chan_in [`router_id(x,y)][WEST] =    chan_in_all [WEST_ID];
205
                                                assign chan_out_all [WEST_ID] = router_chan_out [`router_id(x,y)][WEST];
206
                                        end//topology
207
                                end
208
 
209
                                if(y    <    NY-1) begin : firsty
210
                                        assign  router_chan_in[`router_id(x,y)][SOUTH] =    router_chan_out [`router_id(x,(y+1))][NORTH];
211
                                end else     begin : lasty
212
                                        /* verilator lint_off WIDTH */
213
                                        if(TOPOLOGY == "MESH") begin :ly_mesh
214
                                                /* verilator lint_on WIDTH */
215
                                                assign  router_chan_in[`router_id(x,y)][SOUTH]=  {SMARTFLIT_CHANEL_w{1'b0}};
216
                                                /* verilator lint_off WIDTH */
217
                                        end else if(TOPOLOGY == "TORUS") begin :ly_torus
218
                                                /* verilator lint_on WIDTH */
219
                                                assign  router_chan_in[`router_id(x,y)][SOUTH]=    router_chan_out [`router_id(x,0)][NORTH];
220
                                        end else if(TOPOLOGY == "FMESH") begin : ly_fmesh //connect to endp
221
                                                /* verilator lint_on WIDTH */
222
                                                localparam SOUTH_ID = NX*NY*NL + NX + x;
223
                                                assign router_chan_in [`router_id(x,y)][SOUTH] =    chan_in_all [SOUTH_ID];
224
                                                assign chan_out_all [SOUTH_ID] = router_chan_out [`router_id(x,y)][SOUTH];
225
                                        end//topology
226
                                end
227
 
228
 
229
                                // endpoint(s) connection
230
                                // connect other local ports
231
                                for  (l=0;   l
232
                                        localparam ENDPID = `endp_id(x,y,l);
233
                                        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
234
 
235
                                        assign router_chan_in [`router_id(x,y)][LOCALP] =    chan_in_all [ENDPID];
236
                                        assign chan_out_all [ENDPID] = router_chan_out [`router_id(x,y)][LOCALP];
237
 
238
                                end// locals
239
 
240
                                end //y
241
                                end //x
242
                                end// mesh_torus
243
 
244
                                endgenerate
245
 
246
endmodule

powered by: WebSVN 2.1.0

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