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_openpiton/] [piton_mesh.sv] - Blame information for rev 56

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 alirezamon
`timescale      1ns/1ps
2
 
3
`include "define.tmp.h"
4
 
5
/*********************************
6
 *
7
 *   pack openpiton routers ports
8
 *
9
 *      ******************************/
10
 
11
module piton_router_top
12
 
13
(
14
 
15
        clk,
16
        reset,
17
 
18
        current_r_addr,
19
 
20
        chan_in,
21
        chan_out
22
);
23
 
24
        import piton_pkg::*;
25
        import pronoc_pkg::*;
26
 
27
        localparam P=5;
28
 
29
 
30
        input   clk, reset;
31
        input   [RAw-1 : 0] current_r_addr;
32
 
33
 
34
        input  piton_chan_t chan_in  [P-1 : 0];
35
        output piton_chan_t chan_out [P-1 : 0];
36
 
37
 
38
        wire [`NOC_X_WIDTH-1:0] myLocX;       // thi
39
        wire [`NOC_Y_WIDTH-1:0] myLocY;
40
        wire [`NOC_CHIPID_WIDTH-1:0] myChipID;
41
 
42
 
43
        assign myLocY = (current_r_addr / `PITON_X_TILES ) % `PITON_Y_TILES ;
44
        assign myLocX = (current_r_addr % `PITON_X_TILES );
45
        assign myChipID =0;
46
 
47
        dynamic_node_top_wrap router
48
                (
49
                        .clk(clk),
50
                        .reset_in(reset),
51
                        // dataIn (to input blocks)
52
                        .dataIn_N(chan_in[NORTH].data),
53
                        .dataIn_E(chan_in[EAST ].data),
54
                        .dataIn_S(chan_in[SOUTH].data),
55
                        .dataIn_W(chan_in[WEST ].data),
56
                        .dataIn_P(chan_in[LOCAL].data),
57
                        // validIn (to input blocks)
58
                        .validIn_N(chan_in[NORTH].valid),
59
                        .validIn_E(chan_in[EAST ].valid),
60
                        .validIn_S(chan_in[SOUTH].valid),
61
                        .validIn_W(chan_in[WEST ].valid),
62
                        .validIn_P(chan_in[LOCAL].valid),
63
                        // yummy (from nighboring inputlocks)
64
                        .yummyIn_N(chan_in[NORTH].yummy),
65
                        .yummyIn_E(chan_in[EAST ].yummy),
66
                        .yummyIn_S(chan_in[SOUTH].yummy),
67
                        .yummyIn_W(chan_in[WEST ].yummy),
68
                        .yummyIn_P(chan_in[LOCAL].yummy),
69
                        // My Absolute Address
70
                        .myLocX(myLocX),
71
                        .myLocY(myLocY),
72
                        .myChipID(myChipID),
73
                        //.ec_cfg(15'b0),//ec_dyn_cfg[14:0]),
74
                        //.store_meter_partner_address_X(5'b0)
75
                        //.store_meter_partner_address_Y(5'b0)
76
                        // DataOut (from crossbar)
77
                        .dataOut_N(chan_out[NORTH].data),
78
                        .dataOut_E(chan_out[EAST ].data),
79
                        .dataOut_S(chan_out[SOUTH].data),
80
                        .dataOut_W(chan_out[WEST ].data),
81
                        .dataOut_P(chan_out[LOCAL].data),
82
                        // validOut (from crossbar)
83
                        .validOut_N(chan_out[NORTH].valid),
84
                        .validOut_E(chan_out[EAST ].valid),
85
                        .validOut_S(chan_out[SOUTH].valid),
86
                        .validOut_W(chan_out[WEST ].valid),
87
                        .validOut_P(chan_out[LOCAL].valid),
88
                        // yummyOut (to neighboring outpu
89
                        .yummyOut_N(chan_out[NORTH].yummy),
90
                        .yummyOut_E(chan_out[EAST ].yummy),
91
                        .yummyOut_W(chan_out[WEST].yummy),
92
                        .yummyOut_S(chan_out[SOUTH ].yummy),
93
                        .yummyOut_P(chan_out[LOCAL].yummy),
94
                        // thanksIn (to CGNO)
95
                        .thanksIn_P()//?
96
                );
97
 
98
endmodule
99
 
100
/*********************
101
 * piton_mesh
102
 *
103
 * ********************/
104
 
105
`define router_id(x,y)                         ((y * NX) +    x)
106
`define endp_id(x,y,l)                         ((y * NX) +    x) * NL + l
107
 
108
 
109
module piton_mesh
110
 
111
(
112
 
113
        clk,
114
        reset,
115
 
116
        chan_in_all,
117
        chan_out_all
118
);
119
 
120
 
121
        import piton_pkg::*;
122
        import pronoc_pkg::*;
123
 
124
        input clk, reset;
125
 
126
 
127
        //local ports
128
        input   piton_chan_t chan_in_all  [NE-1 : 0];
129
        output  piton_chan_t chan_out_all [NE-1 : 0];
130
 
131
        //all routers port
132
        piton_chan_t    router_chan_in   [NR-1 :0][MAX_P-1 : 0];
133
        piton_chan_t    router_chan_out  [NR-1 :0][MAX_P-1 : 0];
134
 
135
        wire [RAw-1 : 0] current_r_addr [NR-1 : 0];
136
 
137
 
138
        // mesh torus
139
        localparam
140
                EAST   =       3'd1,
141
                NORTH  =       3'd2,
142
                WEST   =       3'd3,
143
                SOUTH  =       3'd4;
144
        //ring line
145
        localparam
146
                FORWARD =  2'd1,
147
                BACKWARD=  2'd2;
148
 
149
 
150
        genvar x,y,l;
151
        generate
152
        /* verilator lint_off WIDTH */
153
        if( TOPOLOGY == "RING" || TOPOLOGY == "LINE") begin : ring_line
154
        /* verilator lint_on WIDTH */
155
                for  (x=0;   x
156
 
157
 
158
                        assign current_r_addr [x] = x[RAw-1: 0];
159
 
160
                        piton_router_top the_router (
161
                                                .current_r_addr  (current_r_addr [x]),
162
                                                .chan_in         (router_chan_in [x]),
163
                                                .chan_out        (router_chan_out[x]),
164
                                                .clk             (clk            ),
165
                                                .reset           (reset          ));
166
 
167
                                if(x    <   NX-1) begin: not_last_node
168
                                        assign  router_chan_in[x][FORWARD] = router_chan_out [(x+1)][BACKWARD];
169
                                end else begin :last_node
170
                                        /* verilator lint_off WIDTH */
171
                                        if(TOPOLOGY == "LINE") begin : line_last_x
172
                                                /* verilator lint_on WIDTH */
173
                                                assign  router_chan_in[x][FORWARD]= {PITON_CHANEL_w{1'b0}};
174
                                        end else begin : ring_last_x
175
                                                assign router_chan_in[x][FORWARD]= router_chan_out [0][BACKWARD];
176
                                        end
177
                                end
178
 
179
                                if(x>0)begin :not_first_x
180
                                        assign router_chan_in[x][BACKWARD]= router_chan_out [(x-1)][FORWARD];
181
                                end else begin :first_x
182
                                        /* verilator lint_off WIDTH */
183
                                        if(TOPOLOGY == "LINE") begin : line_first_x
184
                                                /* verilator lint_on WIDTH */
185
                                                assign  router_chan_in[x][BACKWARD]={PITON_CHANEL_w{1'b0}};
186
                                        end else begin : ring_first_x
187
                                                assign  router_chan_in[x][BACKWARD]= router_chan_out [(NX-1)][FORWARD];
188
                                        end
189
                                end
190
 
191
                                // connect other local ports
192
                                for  (l=0;   l
193
                                        localparam ENDPID = `endp_id(x,0,l);
194
                                        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
195
                                        assign router_chan_in[x][LOCALP]= chan_in_all [ENDPID];
196
                                        assign chan_out_all [ENDPID] = router_chan_out[x][LOCALP];
197
 
198
                                end// locals
199
                        end//x
200
 
201
                end else begin :mesh_torus
202
                        for (y=0;    y
203
                                for (x=0;    x
204
                                        localparam R_ADDR = (y<
205
                                        localparam ROUTER_NUM = (y * NX) +    x;
206
                                        assign current_r_addr [ROUTER_NUM] = R_ADDR[RAw-1 :0];
207
 
208
                                        piton_router_top  the_router (
209
                                                        .current_r_addr  (current_r_addr [ROUTER_NUM]),
210
                                                        .chan_in         (router_chan_in [ROUTER_NUM]),
211
                                                        .chan_out        (router_chan_out[ROUTER_NUM]),
212
                                                        .clk             (clk            ),
213
                                                        .reset           (reset          ));
214
 
215
 
216
                                        /*
217
    in [x,y][east] <------  out [x+1 ,y  ][west] ;
218
    in [x,y][north] <------ out [x   ,y-1][south] ;
219
    in [x,y][west] <------  out [x-1 ,y  ][east] ;
220
    in [x,y][south] <------ out [x   ,y+1][north] ;
221
                                         */
222
 
223
 
224
                                        if(x    <    NX-1) begin: not_last_x
225
                                                assign router_chan_in[`router_id(x,y)][EAST]= router_chan_out [`router_id(x+1,y)][WEST];
226
                                                //assign    router_credit_in_all [`SELECT_WIRE(x,y,EAST,V)] = router_credit_out_all [`SELECT_WIRE((x+1),y,WEST,V)];
227
                                        end else begin :last_x
228
                                                /* verilator lint_off WIDTH */
229
                                                if(TOPOLOGY == "MESH") begin :last_x_mesh
230
                                                        /* verilator lint_on WIDTH */
231
                                                        assign router_chan_in[`router_id(x,y)][EAST] = {PITON_CHANEL_w{1'b0}};
232
                                                        /* verilator lint_off WIDTH */
233
                                                end else if(TOPOLOGY == "TORUS") begin : last_x_torus
234
                                                        /* verilator lint_on WIDTH */
235
                                                        assign router_chan_in[`router_id(x,y)][EAST] = router_chan_out [`router_id(0,y)][WEST];
236
                                                        /* verilator lint_off WIDTH */
237
                                                end else if(TOPOLOGY == "FMESH") begin : last_x_fmesh //connect to endp
238
                                                        /* verilator lint_on WIDTH */
239
                                                        localparam EAST_ID = NX*NY*NL + 2*NX + NY +y;
240
                                                        assign router_chan_in [`router_id(x,y)][EAST] =    chan_in_all [EAST_ID];
241
                                                        assign chan_out_all [EAST_ID] = router_chan_out [`router_id(x,y)][EAST];
242
                                                end //topology
243
                                        end
244
 
245
 
246
                                        if(y>0) begin : not_first_y
247
                                                assign router_chan_in[`router_id(x,y)][NORTH] =  router_chan_out [`router_id(x,(y-1))][SOUTH];
248
                                        end else begin :first_y
249
                                                /* verilator lint_off WIDTH */
250
                                                if(TOPOLOGY == "MESH") begin : first_y_mesh
251
                                                        /* verilator lint_on WIDTH */
252
                                                        assign router_chan_in[`router_id(x,y)][NORTH] =  {PITON_CHANEL_w{1'b0}};
253
                                                        /* verilator lint_off WIDTH */
254
                                                end else if(TOPOLOGY == "TORUS") begin :first_y_torus
255
                                                        /* verilator lint_on WIDTH */
256
                                                        assign router_chan_in[`router_id(x,y)][NORTH] =  router_chan_out [`router_id(x,(NY-1))][SOUTH];
257
                                                        /* verilator lint_off WIDTH */
258
                                                end else if(TOPOLOGY == "FMESH") begin : first_y_fmesh //connect to endp
259
                                                        /* verilator lint_on WIDTH */
260
                                                        localparam NORTH_ID = NX*NY*NL + x;
261
                                                        assign router_chan_in [`router_id(x,y)][NORTH] =    chan_in_all [NORTH_ID];
262
                                                        assign chan_out_all [NORTH_ID] = router_chan_out [`router_id(x,y)][NORTH];
263
                                                end//topology
264
                                        end//y>0
265
 
266
 
267
                                        if(x>0)begin :not_first_x
268
                                                assign    router_chan_in[`router_id(x,y)][WEST] =  router_chan_out [`router_id((x-1),y)][EAST];
269
                                        end else begin :first_x
270
                                                /* verilator lint_off WIDTH */
271
                                                if(TOPOLOGY == "MESH") begin :first_x_mesh
272
                                                        /* verilator lint_on WIDTH */
273
                                                        assign    router_chan_in[`router_id(x,y)][WEST] =   {PITON_CHANEL_w{1'b0}};
274
                                                        /* verilator lint_off WIDTH */
275
                                                end else if(TOPOLOGY == "TORUS") begin :first_x_torus
276
                                                        /* verilator lint_on WIDTH */
277
                                                        assign    router_chan_in[`router_id(x,y)][WEST] =   router_chan_out [`router_id((NX-1),y)][EAST] ;
278
                                                        /* verilator lint_off WIDTH */
279
                                                end else if(TOPOLOGY == "FMESH") begin : first_x_fmesh //connect to endp
280
                                                        /* verilator lint_on WIDTH */
281
                                                        localparam WEST_ID = NX*NY*NL +2*NX + y;
282
                                                        assign router_chan_in [`router_id(x,y)][WEST] =    chan_in_all [WEST_ID];
283
                                                        assign chan_out_all [WEST_ID] = router_chan_out [`router_id(x,y)][WEST];
284
                                                end//topology
285
                                        end
286
 
287
                                        if(y    <    NY-1) begin : firsty
288
                                                assign  router_chan_in[`router_id(x,y)][SOUTH] =    router_chan_out [`router_id(x,(y+1))][NORTH];
289
                                        end else     begin : lasty
290
                                                /* verilator lint_off WIDTH */
291
                                                if(TOPOLOGY == "MESH") begin :ly_mesh
292
                                                        /* verilator lint_on WIDTH */
293
                                                        assign  router_chan_in[`router_id(x,y)][SOUTH]=  {PITON_CHANEL_w{1'b0}};
294
                                                        /* verilator lint_off WIDTH */
295
                                                end else if(TOPOLOGY == "TORUS") begin :ly_torus
296
                                                        /* verilator lint_on WIDTH */
297
                                                        assign  router_chan_in[`router_id(x,y)][SOUTH]=    router_chan_out [`router_id(x,0)][NORTH];
298
                                                end else if(TOPOLOGY == "FMESH") begin : ly_fmesh //connect to endp
299
                                                        /* verilator lint_on WIDTH */
300
                                                        localparam SOUTH_ID = NX*NY*NL + NX + x;
301
                                                        assign router_chan_in [`router_id(x,y)][SOUTH] =    chan_in_all [SOUTH_ID];
302
                                                        assign chan_out_all [SOUTH_ID] = router_chan_out [`router_id(x,y)][SOUTH];
303
                                                end//topology
304
                                        end
305
 
306
 
307
                                        // endpoint(s) connection
308
                                        // connect other local ports
309
                                        for  (l=0;   l
310
                                                localparam ENDPID = `endp_id(x,y,l);
311
                                                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
312
 
313
                                                assign router_chan_in [`router_id(x,y)][LOCALP] =    chan_in_all [ENDPID];
314
                                                assign chan_out_all [ENDPID] = router_chan_out [`router_id(x,y)][LOCALP];
315
 
316
                                        end// locals
317
 
318
                                end //y
319
                        end //x
320
                end// mesh_torus
321
 
322
        endgenerate
323
 
324
endmodule
325
 
326
 
327
 
328
 
329
module piton_mesh_pronoc_wrap
330
 
331
 
332
        (
333
 
334
                        clk,
335
                        reset,
336
 
337
                        chan_in_all,
338
                        chan_out_all
339
                );
340
        import piton_pkg::*;
341
        import pronoc_pkg::*;
342
 
343
        input   clk,reset;
344
        //local ports  ProNoC interface
345
        input   smartflit_chanel_t chan_in_all  [NE-1 : 0];
346
        output  smartflit_chanel_t chan_out_all [NE-1 : 0];
347
 
348
 
349
 
350
        //piton interface
351
        piton_chan_t piton_chan_in_all  [NE-1 : 0];
352
        piton_chan_t piton_chan_out_all [NE-1 : 0];
353
 
354
 
355
        piton_mesh pmesh(
356
 
357
                .clk         (clk         ),
358
                .reset       (reset       ),
359
                .chan_in_all (piton_chan_in_all ),
360
                .chan_out_all(piton_chan_out_all)
361
                );
362
 
363
        localparam
364
                NX = T1,
365
                NY = T2,
366
                RXw = log2(NX),    // number of node in x axis
367
                RYw = log2(NY),
368
                EXw = log2(NX),    // number of node in x axis
369
                EYw = log2(NY);   // number of node in y axis
370
 
371
 
372
        wire [RXw-1 : 0] current_x [NE-1 : 0];
373
        wire [RYw-1 : 0] current_y [NE-1 : 0];
374
        reg [`XY_WIDTH-1:0] myLocX [NE-1 : 0];       // thi
375
        reg [`XY_WIDTH-1:0] myLocY [NE-1 : 0];
376
        reg [`CHIP_ID_WIDTH-1:0] myChipID[NE-1 : 0];
377
 
378
        genvar i;
379
        generate
380
        for (i=0; i
381
 
382
 
383
                mesh_tori_router_addr_decode #(
384
                                .TOPOLOGY(TOPOLOGY),
385
                                .T1(T1),
386
                                .T2(T2),
387
                                .T3(T3),
388
                                .RAw(RAw)
389
                        )
390
                        r_addr_decode
391
                        (
392
                                .r_addr(i[RAw-1:0]),
393
                                .rx(current_x[i]),
394
                                .ry(current_y[i]),
395
                                .valid()
396
                        );
397
 
398
 
399
                always @(*) begin
400
                        myLocX[i]   = {`XY_WIDTH{1'b0}};
401
                        myLocY[i]   = {`XY_WIDTH{1'b0}};
402
                        myChipID[i] = {`CHIP_ID_WIDTH{1'b0}};
403
 
404
                        myLocX[i]  [RXw-1 : 0] = current_x[i];
405
                        myLocY[i]  [RYw-1 : 0] = current_y[i];
406
 
407
                end
408
 
409
                piton_to_pronoc_wrapper #(.NOC_NUM(1),.TILE_NUM(i),.CHIP_SET_PORT(0),.FLATID_WIDTH(FLATID_WIDTH)) pi2pr_wrapper1
410
                        (
411
                                .default_chipid(myChipID[i]), .default_coreid_x(myLocX[i]), .default_coreid_y(myLocY[i]), .flat_tileid(i[FLATID_WIDTH-1 : 0]),
412
                                .reset(reset),
413
                                .clk (clk),
414
                                .dataIn (piton_chan_out_all[i].data),
415
                                .validIn(piton_chan_out_all[i].valid),
416
                                .yummyIn(piton_chan_out_all[i].yummy),
417
                                .chan_out(chan_out_all[i]),
418
                                .current_r_addr_i(i[RAw-1:0])
419
                        );
420
 
421
                pronoc_to_piton_wrapper  #(.NOC_NUM(1),.TILE_NUM(i),.FLATID_WIDTH(FLATID_WIDTH)) pr2pi_wrapper1
422
                        (
423
                                .default_chipid(myChipID[i]), .default_coreid_x(myLocX[i]), .default_coreid_y(myLocY[i]), .flat_tileid(i[FLATID_WIDTH-1:0]),
424
                                .reset(reset),
425
                                .clk (clk),
426
                                .dataOut (piton_chan_in_all[i].data ),
427
                                .validOut(piton_chan_in_all[i].valid ),
428
                                .yummyOut(piton_chan_in_all[i].yummy ),
429
                                .chan_in (chan_in_all[i] ),
430
                                .current_r_addr_o( )
431
                        );
432
 
433
        end
434
        endgenerate
435
 
436
endmodule
437
 
438
 
439
 
440
 

powered by: WebSVN 2.1.0

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