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/] [input_ports.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
//`define MONITORE_PATH
3
 
4
/**********************************************************************
5
 **     File: input_ports.sv
6
 **
7
 **     Copyright (C) 2014-2017  Alireza Monemi
8
 **
9
 **     This file is part of ProNoC
10
 **
11
 **     ProNoC ( stands for Prototype Network-on-chip)  is free software:
12
 **     you can redistribute it and/or modify it under the terms of the GNU
13
 **     Lesser General Public License as published by the Free Software Foundation,
14
 **     either version 2 of the License, or (at your option) any later version.
15
 **
16
 **     ProNoC is distributed in the hope that it will be useful, but WITHOUT
17
 **     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
 **     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
19
 **     Public License for more details.
20
 **
21
 **     You should have received a copy of the GNU Lesser General Public
22
 **     License along with ProNoC. If not, see .
23
 **
24
 **
25
 **     Description:
26
 **     NoC router input Port. It consists of input buffer, control FIFO
27
 **     and request masking/generation control modules
28
 **
29
 **************************************************************/
30
 
31 54 alirezamon
 
32
 
33
 
34 48 alirezamon
module input_ports
35
        import pronoc_pkg::*;
36
#(
37
        parameter P=5
38
)(
39
                        current_r_addr,
40
                        neighbors_r_addr,
41
                        ivc_num_getting_sw_grant,// for non spec ivc_num_getting_first_sw_grant,
42
                        any_ivc_sw_request_granted_all,
43
                        flit_in_all,
44
                        flit_in_wr_all,
45
                        reset_ivc_all,
46
                        flit_is_tail_all,
47
                        ivc_request_all,
48 54 alirezamon
                        dest_port_all,
49 48 alirezamon
                        flit_out_all,
50 54 alirezamon
 
51 48 alirezamon
                        assigned_ovc_not_full_all,
52
                        ovc_is_assigned_all,
53
                        sel,
54
                        port_pre_sel,
55
                        swap_port_presel,
56
                        nonspec_first_arbiter_granted_ivc_all,
57 54 alirezamon
                        credit_out_all,
58 48 alirezamon
 
59 54 alirezamon
                        destport_clear,
60 48 alirezamon
                        vc_weight_is_consumed_all,
61
                        iport_weight_is_consumed_all,
62
                        iport_weight_all,
63
                        oports_weight_all,
64
                        granted_dest_port_all,
65
                        refresh_w_counter,
66
                        ivc_info,
67
                        vsa_ctrl_in,
68
                        ssa_ctrl_in,
69
                        smart_ctrl_in,
70
                        credit_init_val_out,
71
                        reset,
72
                        clk
73
                );
74
 
75
 
76
 
77
        localparam
78
                PV = V * P,
79
                VV = V * V,
80
                PVV = PV * V,
81
                P_1 = ( SELF_LOOP_EN=="NO")?  P-1 : P,
82
                PP_1 = P * P_1,
83
                VP_1 = V * P_1,
84
                PVP_1 = PV * P_1,
85
                PFw = P*Fw,
86
                W= WEIGHTw,
87
                WP= W * P,
88
                WPP = WP * P,
89
                PVDSTPw= PV * DSTPw,
90
                PRAw= P * RAw;
91
 
92
 
93
 
94
        input   reset,clk;
95
        input   [RAw-1 : 0] current_r_addr;
96
        input   [PRAw-1:  0]  neighbors_r_addr;
97
        output  [PV-1 : 0] ivc_num_getting_sw_grant;
98
        input   [P-1 : 0] any_ivc_sw_request_granted_all;
99
        input   [PFw-1 : 0] flit_in_all;
100
        input   [P-1 : 0] flit_in_wr_all;
101
        output  [PV-1 : 0] reset_ivc_all;
102
        output  [PV-1 : 0] flit_is_tail_all;
103
        output  [PV-1 : 0] ivc_request_all;
104 54 alirezamon
        output  [PV-1 : 0] credit_out_all;
105
 
106 48 alirezamon
        output  [PVP_1-1 : 0] dest_port_all;
107
        output  [PFw-1 : 0] flit_out_all;
108 54 alirezamon
 
109 48 alirezamon
        input   [PV-1  : 0] assigned_ovc_not_full_all;
110
        output  [PV-1  : 0] ovc_is_assigned_all;
111
        input   [PV-1 : 0] sel;
112
        input   [PPSw-1 : 0] port_pre_sel;
113
        input   [PV-1  : 0]  swap_port_presel;
114
        input   [PV-1 : 0] nonspec_first_arbiter_granted_ivc_all;
115
 
116 54 alirezamon
 
117 48 alirezamon
        output  [WP-1 : 0] iport_weight_all;
118
        output  [PV-1 : 0] vc_weight_is_consumed_all;
119
        output  [P-1 : 0] iport_weight_is_consumed_all;
120
        input   [PP_1-1 : 0] granted_dest_port_all;
121
        output  [WPP-1 : 0] oports_weight_all;
122 54 alirezamon
 
123
 
124
 
125 48 alirezamon
        output  ivc_info_t ivc_info [P-1 : 0][V-1 : 0];
126
        input   vsa_ctrl_t  vsa_ctrl_in [P-1: 0];
127
        input   ssa_ctrl_t  ssa_ctrl_in [P-1: 0];
128
        input   smart_ctrl_t  smart_ctrl_in [P-1 : 0];
129
        output  [CRDTw-1 : 0 ] credit_init_val_out [P-1 : 0][V-1 : 0];
130
 
131
        input refresh_w_counter;
132
 
133 54 alirezamon
        input   [DSTPw-1 : 0] destport_clear [P-1 : 0][V-1 : 0];
134 48 alirezamon
 
135
        genvar i;
136
        generate
137 54 alirezamon
                for(i=0;i
138
 
139
 
140
 
141 48 alirezamon
 
142
                        input_queue_per_port
143
                        // iport_reg_base
144
                                #(
145
                                        .SW_LOC(i),
146
                                        .P(P)
147
                                )
148
                                the_input_queue_per_port
149
                                (
150 54 alirezamon
                                        .credit_out(credit_out_all [(i+1)*V-1 : i*V]),
151 48 alirezamon
                                        .current_r_addr(current_r_addr),
152
                                        .neighbors_r_addr(neighbors_r_addr),
153
                                        .ivc_num_getting_sw_grant(ivc_num_getting_sw_grant  [(i+1)*V-1 : i*V]),// for non spec ivc_num_getting_first_sw_grant,
154
                                        .any_ivc_sw_request_granted(any_ivc_sw_request_granted_all  [i]),
155
                                        .flit_in(flit_in_all[(i+1)*Fw-1 : i*Fw]),
156
                                        .flit_in_wr(flit_in_wr_all[i]),
157
                                        .reset_ivc(reset_ivc_all [(i+1)*V-1 : i*V]),
158
                                        .flit_is_tail(flit_is_tail_all  [(i+1)*V-1 : i*V]),
159
                                        .ivc_request(ivc_request_all [(i+1)*V-1 : i*V]),
160
                                        .dest_port(dest_port_all [(i+1)*P_1*V-1 : i*P_1*V]),
161
                                        .flit_out(flit_out_all [(i+1)*Fw-1 : i*Fw]),
162
                                        .assigned_ovc_not_full(assigned_ovc_not_full_all [(i+1)*V-1 : i*V]),
163
                                        .ovc_is_assigned(ovc_is_assigned_all [(i+1)*V-1 : i*V]),
164
                                        .sel(sel [(i+1)*V-1 : i*V]),
165
                                        .port_pre_sel(port_pre_sel),
166
                                        .swap_port_presel(swap_port_presel[(i+1)*V-1 : i*V]),
167
                                        .nonspec_first_arbiter_granted_ivc(nonspec_first_arbiter_granted_ivc_all[(i+1)*V-1 : i*V]),
168
                                        .reset(reset),
169
                                        .clk(clk),
170
 
171 54 alirezamon
                                        .destport_clear(destport_clear [i]),
172 48 alirezamon
                                        .iport_weight(iport_weight_all[(i+1)*W-1 : i*W]),
173
                                        .oports_weight(oports_weight_all[(i+1)*WP-1 : i*WP]),
174
                                        .vc_weight_is_consumed(vc_weight_is_consumed_all [(i+1)*V-1 : i*V]),
175
                                        .iport_weight_is_consumed(iport_weight_is_consumed_all[i]),
176
                                        .refresh_w_counter(refresh_w_counter),
177
                                        .granted_dest_port(granted_dest_port_all[(i+1)*P_1-1 : i*P_1]),
178
                                        .ivc_info(ivc_info[i]),
179
                                        .vsa_ctrl_in(vsa_ctrl_in [i]),
180
                                        .smart_ctrl_in(smart_ctrl_in [i]),
181
                                        .ssa_ctrl_in(ssa_ctrl_in [i]),
182
                                        .credit_init_val_out(credit_init_val_out[i])
183
 
184
                                );
185
 
186
                end//for
187
        endgenerate
188
 
189
endmodule
190
 
191
 
192
/**************************
193
 
194
    input_queue_per_port
195
 
196
 **************************/
197
 
198
module input_queue_per_port
199
                import pronoc_pkg::*;
200
        #(
201
                parameter P = 5,     // router port num
202
                parameter SW_LOC = 0
203
                )(
204
                        current_r_addr,
205 54 alirezamon
                        credit_out,
206 48 alirezamon
                        neighbors_r_addr,
207
                        ivc_num_getting_sw_grant,// for non spec ivc_num_getting_first_sw_grant,
208
                        any_ivc_sw_request_granted,
209
                        flit_in,
210
                        flit_in_wr,
211
                        reset_ivc,
212
                        flit_is_tail,
213
                        ivc_request,
214
                        dest_port,
215 54 alirezamon
                        flit_out,
216 48 alirezamon
                        assigned_ovc_not_full,
217
                        ovc_is_assigned,
218
                        sel,
219
                        port_pre_sel,
220
                        swap_port_presel,
221
                        reset,
222
                        clk,
223
                        nonspec_first_arbiter_granted_ivc,
224
                        destport_clear,
225
 
226
                        iport_weight,
227
                        oports_weight,
228
                        vc_weight_is_consumed,
229
                        iport_weight_is_consumed,
230
                        refresh_w_counter,
231
                        granted_dest_port,
232
                        ivc_info,
233
                        smart_ctrl_in,
234
                        vsa_ctrl_in,
235
                        ssa_ctrl_in,
236
                        credit_init_val_out
237
                );
238
 
239
 
240 54 alirezamon
 
241 48 alirezamon
 
242
 
243 54 alirezamon
        localparam
244
                PORT_B = port_buffer_size(SW_LOC),
245
                PORT_Bw= log2(PORT_B);
246 48 alirezamon
 
247
 
248
 
249
        localparam
250
                VV = V * V,
251
                VDSTPw = V * DSTPw,
252
                W = WEIGHTw,
253
                WP = W * P,
254
                P_1=( SELF_LOOP_EN=="NO")?  P-1 : P,
255
                VP_1 = V * P_1;
256
 
257
        localparam
258
        /* verilator lint_off WIDTH */
259
                OFFSET = (PORT_B%MIN_PCK_SIZE)? 1 :0,
260
                NON_ATOM_PCKS =  (PORT_B>MIN_PCK_SIZE)?  (PORT_B/MIN_PCK_SIZE)+ OFFSET : 1,
261
                MAX_PCK = (VC_REALLOCATION_TYPE== "ATOMIC")?  1 : NON_ATOM_PCKS + OVC_ALLOC_MODE,// min packet size is two hence the max packet number in buffer is (B/2)
262
                IGNORE_SAME_LOC_RD_WR_WARNING = ((SSA_EN=="YES")| SMART_EN)? "YES" : "NO";
263
 
264
 
265
        localparam
266
                ELw = log2(T3),
267
                Pw  = log2(P),
268
                PLw = (TOPOLOGY == "FMESH") ? Pw : ELw,
269
                VPLw= V * PLw,
270
                PRAw= P * RAw;
271
        /* verilator lint_on WIDTH */
272
 
273
 
274
        input reset, clk;
275 54 alirezamon
        output  [V-1 : 0] credit_out;
276 48 alirezamon
        input   [RAw-1 : 0] current_r_addr;
277
        input   [PRAw-1:  0]  neighbors_r_addr;
278
        output  [V-1 : 0] ivc_num_getting_sw_grant;
279
        input                      any_ivc_sw_request_granted;
280
        input   [Fw-1 : 0] flit_in;
281
        input                       flit_in_wr;
282
        output  [V-1 : 0] reset_ivc;
283
        output  [V-1 : 0] flit_is_tail;
284
        output  [V-1 : 0] ivc_request;
285
        output  [VP_1-1 : 0] dest_port;
286
        output  [Fw-1 : 0] flit_out;
287
        input   [V-1  : 0] assigned_ovc_not_full;
288
        output  [V-1  : 0] ovc_is_assigned;
289
        input   [V-1 : 0] sel;
290
        input   [V-1 : 0] nonspec_first_arbiter_granted_ivc;
291
 
292 54 alirezamon
        input   [DSTPw-1 : 0] destport_clear [V-1 : 0];
293
        output  [WEIGHTw-1 : 0] iport_weight;
294 48 alirezamon
        output  [V-1 : 0] vc_weight_is_consumed;
295
        output  iport_weight_is_consumed;
296
        input   refresh_w_counter;
297
        input   [P_1-1 : 0] granted_dest_port;
298
        output  [WP-1 : 0] oports_weight;
299
        input   [PPSw-1 : 0] port_pre_sel;
300
        input   [V-1  : 0]  swap_port_presel;
301
 
302
        output  ivc_info_t ivc_info [V-1 : 0];
303
        input   smart_ctrl_t  smart_ctrl_in;
304
        input   vsa_ctrl_t  vsa_ctrl_in;
305
        input   ssa_ctrl_t  ssa_ctrl_in;
306
        output  [CRDTw-1 : 0 ] credit_init_val_out [V-1 : 0];
307
 
308 54 alirezamon
        wire  [DSTPw-1 : 0] dest_port_encoded [V-1 : 0];
309
        //for multicast
310
        wire  [DSTPw-1 : 0] dest_port_multi   [V-1 : 0];
311
        wire  [V-1 : 0] multiple_dest,dst_onhot0;
312
        wire   [DSTPw-1 : 0] clear_dspt_mulicast  [V-1 : 0];
313
 
314
        wire  [VV-1 : 0] candidate_ovcs;
315
 
316 48 alirezamon
        wire [Cw-1 : 0] class_in;
317
        wire [DSTPw-1 : 0] destport_in,destport_in_encoded;
318
        wire [VDSTPw-1 : 0] lk_destination_encoded;
319
 
320 54 alirezamon
        wire [DAw-1 : 0] dest_e_addr_in;
321 48 alirezamon
        wire [EAw-1 : 0] src_e_addr_in;
322
        wire [V-1 : 0] vc_num_in;
323
        wire [V-1 : 0] hdr_flit_wr,flit_wr;
324 54 alirezamon
        wire [VV-1 : 0] assigned_ovc_num;
325 48 alirezamon
 
326
        wire [DSTPw-1 : 0] lk_destination_in_encoded;
327
        wire [WEIGHTw-1  : 0] weight_in;
328
        wire [Fw-1 : 0] buffer_out;
329
        wire hdr_flg_in,tail_flg_in;
330
        wire [V-1 : 0] ivc_not_empty;
331
        wire [Cw-1 : 0] class_out [V-1 : 0];
332
        wire [VPLw-1 : 0] endp_localp_num;
333
 
334
        wire [V-1 : 0] smart_hdr_en;
335
        wire [ELw-1 : 0] endp_l_in;
336
        wire [Pw-1 : 0] endp_p_in;
337
 
338
        wire [V-1 : 0] rd_hdr_fwft_fifo,wr_hdr_fwft_fifo,rd_hdr_fwft_fifo_delay,wr_hdr_fwft_fifo_delay;
339
 
340
        logic [V-1  : 0] ovc_is_assigned_next;
341
        logic [VV-1 : 0] assigned_ovc_num_next;
342
 
343
        wire odd_column = current_r_addr[0];
344
        wire [P-1 : 0] destport_one_hot [V-1 :0];
345
        wire [V-1 : 0] mux_out[V-1 : 0];
346
 
347 54 alirezamon
        wire [V-1 : 0] dstport_fifo_not_empty;
348
 
349
        logic  [WEIGHTw-1 : 0] iport_weight_next;
350
 
351 48 alirezamon
        assign smart_hdr_en  = (SMART_EN) ? smart_ctrl_in.ivc_num_getting_ovc_grant: {V{1'b0}};
352
        assign reset_ivc  = smart_ctrl_in.ivc_reset | ssa_ctrl_in.ivc_reset | vsa_ctrl_in.ivc_reset;
353
        assign ivc_num_getting_sw_grant = ssa_ctrl_in.ivc_num_getting_sw_grant | vsa_ctrl_in.ivc_num_getting_sw_grant;
354
        assign flit_wr =(flit_in_wr )? vc_num_in : {V{1'b0}};
355 54 alirezamon
        assign rd_hdr_fwft_fifo  = (ssa_ctrl_in.ivc_reset | vsa_ctrl_in.ivc_reset | (smart_ctrl_in.ivc_reset  & ~ smart_ctrl_in.ivc_single_flit_pck)) & ~ multiple_dest;
356 48 alirezamon
        assign wr_hdr_fwft_fifo  = hdr_flit_wr | (smart_hdr_en & ~ smart_ctrl_in.ivc_single_flit_pck);
357
        assign ivc_request = ivc_not_empty;
358
 
359
 
360 54 alirezamon
        wire  [V-1 : 0] flit_is_tail2;
361 48 alirezamon
 
362 54 alirezamon
 
363
        pronoc_register #(.W(V)) reg1(
364 48 alirezamon
                        .in             (ovc_is_assigned_next),
365
                        .reset  (reset ),
366
                        .clk    (clk   ),
367
                        .out    (ovc_is_assigned   ));
368
 
369 54 alirezamon
        pronoc_register #(.W(VV)) reg2(
370 48 alirezamon
                        .in             (assigned_ovc_num_next),
371
                        .reset  (reset ),
372
                        .clk    (clk   ),
373
                        .out    (assigned_ovc_num  ));
374
 
375 54 alirezamon
        pronoc_register #(.W(V)) reg3(
376 48 alirezamon
                        .in             (rd_hdr_fwft_fifo),
377
                        .reset  (reset ),
378
                        .clk    (clk   ),
379
                        .out    (rd_hdr_fwft_fifo_delay ));
380
 
381 54 alirezamon
        pronoc_register #(.W(V)) reg4(
382 48 alirezamon
                        .in             (wr_hdr_fwft_fifo),
383
                        .reset  (reset ),
384
                        .clk    (clk   ),
385
                        .out    (wr_hdr_fwft_fifo_delay ));
386
 
387 54 alirezamon
        pronoc_register #(.W(WEIGHTw), .RESET_TO(1)) reg5(
388
                        .in             (iport_weight_next ),
389
                        .reset  (reset ),
390
                        .clk    (clk   ),
391
                        .out    (iport_weight  ));
392 48 alirezamon
 
393 54 alirezamon
 
394
        pronoc_register #(.W(V)) credit_reg (
395
                        .in     (ivc_num_getting_sw_grant & ~ multiple_dest),
396
                        .reset  (reset),
397
                        .clk    (clk),
398
                        .out    (credit_out));
399
 
400
 
401
 
402
 
403
        always @ (*)begin
404
                iport_weight_next = iport_weight;
405
                if(hdr_flit_wr != {V{1'b0}})  iport_weight_next = (weight_in=={WEIGHTw{1'b0}})? 1 : weight_in; // the minimum weight is 1
406
        end
407 48 alirezamon
 
408
 
409
        //extract header flit info
410
        extract_header_flit_info #(
411
                        .DATA_w(0)
412
                )
413
                header_extractor
414
                (
415
                        .flit_in(flit_in),
416
                        .flit_in_wr(flit_in_wr),
417
                        .class_o(class_in),
418
                        .destport_o(destport_in),
419
                        .dest_e_addr_o(dest_e_addr_in),
420
                        .src_e_addr_o(src_e_addr_in),
421
                        .vc_num_o(vc_num_in),
422
                        .hdr_flit_wr_o(hdr_flit_wr),
423
                        .hdr_flg_o(hdr_flg_in),
424
                        .tail_flg_o(tail_flg_in),
425
                        .weight_o(weight_in),
426
                        .be_o( ),
427
                        .data_o( )
428
                );
429
 
430
 
431
 
432
        genvar i;
433
        generate
434
                /* verilator lint_off WIDTH */
435 54 alirezamon
                if (( TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS") && (T3>1) && CAST_TYPE== "UNICAST") begin : multi_local
436 48 alirezamon
                /* verilator lint_on WIDTH */
437
 
438
 
439
 
440
                                mesh_tori_endp_addr_decode #(
441
                                        .TOPOLOGY("MESH"),
442
                                        .T1(T1),
443
                                        .T2(T2),
444
                                        .T3(T3),
445
                                        .EAw(EAw)
446
                                )
447
                                endp_addr_decode
448
                                (
449
                                        .e_addr(dest_e_addr_in),
450
                                        .ex( ),
451
                                        .ey( ),
452
                                        .el(endp_l_in),
453
                                        .valid( )
454
                                );
455
                end
456
                /* verilator lint_off WIDTH */
457 54 alirezamon
                if ( TOPOLOGY == "FMESH" && CAST_TYPE== "UNICAST" ) begin : fmesh
458 48 alirezamon
                /* verilator lint_on WIDTH */
459
 
460
 
461
 
462
                        fmesh_endp_addr_decode #(
463
                                        .T1(T1),
464
                                        .T2(T2),
465
                                        .T3(T3),
466
                                        .EAw(EAw)
467
                                )
468
                                endp_addr_decode
469
                                (
470
                                        .e_addr(dest_e_addr_in),
471
                                        .ex(),
472
                                        .ey(),
473
                                        .ep(endp_p_in),
474
                                        .valid()
475
                                );
476
 
477
                end
478
                /* verilator lint_off WIDTH */
479
                if(TOPOLOGY=="FATTREE" && ROUTE_NAME == "NCA_STRAIGHT_UP") begin : fat
480
                        /* verilator lint_on WIDTH */
481
 
482
                        fattree_destport_up_select #(
483
                                        .K(T1),
484
                                        .SW_LOC(SW_LOC)
485
                                )
486
                                static_sel
487
                                (
488
                                        .destport_in(destport_in),
489
                                        .destport_o(destport_in_encoded)
490
                                );
491
 
492
                end else begin : other
493
                        assign destport_in_encoded = destport_in;
494
                end
495
 
496
 
497
                for (i=0;i
498
 
499
                        assign credit_init_val_out [i] = PORT_B [CRDTw-1 : 0 ];
500
 
501
 
502
                        one_hot_to_bin #(.ONE_HOT_WIDTH(V),.BIN_WIDTH(Vw)) conv (
503
                                        .one_hot_code(assigned_ovc_num[(i+1)*V-1 : i*V]),
504
                                        .bin_code(ivc_info[i].assigned_ovc_bin)
505
                                );
506
 
507 54 alirezamon
                assign ivc_info[i].single_flit_pck =
508
                        /* verilator lint_off WIDTH */
509
                        (PCK_TYPE == "SINGLE_FLIT")? 1'b1  :
510
                        /* verilator lint_on WIDTH */
511
                        (MIN_PCK_SIZE == 1)? flit_is_tail[i] & ~ovc_is_assigned[i] :  1'b0;
512 48 alirezamon
                        assign ivc_info[i].ivc_req = ivc_request[i];
513
                        assign ivc_info[i].class_num = class_out[i];
514
                        assign ivc_info[i].flit_is_tail = flit_is_tail[i];
515
                        assign ivc_info[i].assigned_ovc_not_full=assigned_ovc_not_full[i];
516
                        assign ivc_info[i].candidate_ovc=   candidate_ovcs [(i+1)*V-1 : i*V];
517
                        assign ivc_info[i].ovc_is_assigned = ovc_is_assigned[i];
518
                        assign ivc_info[i].assigned_ovc_num= assigned_ovc_num[(i+1)*V-1 : i*V];
519 54 alirezamon
                        assign ivc_info[i].dest_port_encoded=dest_port_encoded[i];
520 48 alirezamon
                        //assign ivc_info[i].getting_swa_first_arbiter_grant=nonspec_first_arbiter_granted_ivc[i];
521
                        //assign ivc_info[i].getting_swa_grant=ivc_num_getting_sw_grant[i];
522
                        if(P==MAX_P) begin :max_
523
                                assign ivc_info[i].destport_one_hot= destport_one_hot[i];
524
                        end else begin : no_max
525
                                assign ivc_info[i].destport_one_hot= {{(MAX_P-P){1'b0}},destport_one_hot[i]};
526
                        end
527
                        //synthesis translate_off
528
                        //check ivc info
529
                        //assigned ovc must be onehot coded
530
                        //assert property (@(posedge clk) $onehot0(ivc_info[i].assigned_ovc_num));
531
                        always @ (posedge clk )begin
532
                                if(~ $onehot0(ivc_info[i].assigned_ovc_num)) begin
533
                                        $display ("ERROR: assigned OVC is not ont-hot coded %d,%m",ivc_info[i].assigned_ovc_num);
534
                                        $finish;
535
                                end
536
                        end
537
                        //synthesis translate_on
538
 
539 54 alirezamon
 
540
 
541
 
542
 
543 48 alirezamon
                        class_ovc_table #(
544
                                        .CVw(CVw),
545
                                        .CLASS_SETTING(CLASS_SETTING),
546
                                        .C(C),
547
                                        .V(V)
548
                                )
549
                                class_table
550
                                (
551
                                        .class_in(class_out[i]),
552
                                        .candidate_ovcs(candidate_ovcs [(i+1)*V-1 : i*V])
553
                                );
554
 
555 54 alirezamon
                        if(PCK_TYPE == "MULTI_FLIT") begin : multi_flit
556 48 alirezamon
 
557
                                always @ (*) begin
558
                                        ovc_is_assigned_next[i] = ovc_is_assigned[i];
559
                                        if( vsa_ctrl_in.ivc_reset[i] |
560
                                                        ssa_ctrl_in.ivc_reset[i] |
561
                                                        smart_ctrl_in.ivc_reset[i]
562
                                                )       ovc_is_assigned_next[i] = 1'b0;
563
 
564
                                        else if( vsa_ctrl_in.ivc_num_getting_ovc_grant[i] |
565
                                                        (ssa_ctrl_in.ivc_num_getting_ovc_grant[i] & ~  ssa_ctrl_in.ivc_single_flit_pck[i])|
566
                                                        (smart_ctrl_in.ivc_num_getting_ovc_grant[i] & ~  smart_ctrl_in.ivc_single_flit_pck[i])
567
                                                )       ovc_is_assigned_next[i] = 1'b1;
568
                                end//always
569
 
570
 
571
                                always @(*) begin
572
                                        assigned_ovc_num_next[(i+1)*V-1 : i*V] = assigned_ovc_num[(i+1)*V-1 : i*V] ;
573
                                        if(vsa_ctrl_in.ivc_num_getting_ovc_grant[i] | ssa_ctrl_in.ivc_num_getting_ovc_grant[i] | smart_ctrl_in.ivc_num_getting_ovc_grant[i] ) begin
574
                                                assigned_ovc_num_next[(i+1)*V-1 : i*V] = mux_out[i];
575
                                        end
576
                                end
577
 
578
                                onehot_mux_1D #(
579
                                                .N  (3),
580
                                                .W  (V)
581
                                        ) hot_mux (
582
                                                .in     ({vsa_ctrl_in.ivc_granted_ovc_num[(i+1)*V-1 : i*V],
583
                                                                ssa_ctrl_in.ivc_granted_ovc_num[(i+1)*V-1 : i*V],
584
                                                                smart_ctrl_in.ivc_granted_ovc_num[(i+1)*V-1 : i*V]}),
585
                                                .sel        ({vsa_ctrl_in.ivc_num_getting_ovc_grant[i],ssa_ctrl_in.ivc_num_getting_ovc_grant[i],smart_ctrl_in.ivc_num_getting_ovc_grant[i]}  ),
586
                                                .out    (mux_out[i]   )
587
                                        );
588
 
589
 
590 54 alirezamon
                                /*
591 48 alirezamon
                                //tail fifo
592
                                fwft_fifo #(
593
                                        .DATA_WIDTH(1),
594
                                        .MAX_DEPTH (PORT_B),
595
                                        .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
596
                                )
597
                                tail_fifo
598
                                (
599
                                        .din (tail_flg_in),
600
                                        .wr_en (flit_wr[i]),   // Write enable
601
                                        .rd_en (ivc_num_getting_sw_grant[i]),   // Read the next word
602
                                        .dout (flit_is_tail[i]),    // Data out
603
                                        .full ( ),
604
                                        .nearly_full ( ),
605
                                        .recieve_more_than_0 ( ),
606
                                        .recieve_more_than_1 ( ),
607
                                        .reset (reset),
608
                                        .clk (clk)
609
                                );
610 54 alirezamon
                                */
611
 
612
                        end else begin :single_flit
613
                                //assign flit_is_tail[i]=1'b1;
614 48 alirezamon
                                assign ovc_is_assigned_next[i] = 1'b0;
615
 
616
                                always @(*) begin
617
                                        assigned_ovc_num_next[(i+1)*V-1 : i*V] = assigned_ovc_num[(i+1)*V-1 : i*V] ;
618
                                        if(vsa_ctrl_in.ivc_num_getting_ovc_grant[i] | ssa_ctrl_in.ivc_num_getting_ovc_grant[i]) begin
619
                                                assigned_ovc_num_next[(i+1)*V-1 : i*V] = mux_out[i];
620
                                        end
621
                                end
622
 
623
                                onehot_mux_1D #(
624
                                                .N  (2),
625
                                                .W  (V)
626
                                        ) hot_mux (
627
                                                .in     ({vsa_ctrl_in.ivc_granted_ovc_num[(i+1)*V-1 : i*V],
628
                                                                ssa_ctrl_in.ivc_granted_ovc_num[(i+1)*V-1 : i*V]}),
629
                                                .sel        ({vsa_ctrl_in.ivc_num_getting_ovc_grant[i],ssa_ctrl_in.ivc_num_getting_ovc_grant[i]}  ),
630
                                                .out    (mux_out[i]   )
631
                                        );
632
 
633
 
634
 
635
                        end
636
                        //dest_e_addr_in fifo
637
                        if(SMART_EN) begin : smart_
638
 
639
                                fwft_fifo #(
640
                                                .DATA_WIDTH(EAw),
641
                                                .MAX_DEPTH (MAX_PCK),
642
                                                .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
643
                                        )
644
                                        dest_e_addr_fifo
645
                                        (
646
                                                .din (dest_e_addr_in),
647
                                                .wr_en (wr_hdr_fwft_fifo[i]),   // Write enable
648
                                                .rd_en (rd_hdr_fwft_fifo[i]),   // Read the next word
649
                                                .dout (ivc_info[i].dest_e_addr),    // Data out
650
                                                .full ( ),
651
                                                .nearly_full ( ),
652
                                                .recieve_more_than_0 ( ),
653
                                                .recieve_more_than_1 ( ),
654
                                                .reset (reset),
655
                                                .clk (clk)
656
                                        );
657
 
658
                        end     else begin : no_smart
659
                                assign ivc_info[i].dest_e_addr = {EAw{1'bx}};
660
                        end
661
 
662
 
663
 
664
                        //class_fifo
665
                        if(C>1)begin :cb1
666
                                fwft_fifo #(
667
                                                .DATA_WIDTH(Cw),
668
                                                .MAX_DEPTH (MAX_PCK),
669
                                                .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
670
                                        )
671
                                        class_fifo
672
                                        (
673
                                                .din (class_in),
674
                                                .wr_en (wr_hdr_fwft_fifo[i]),   // Write enable
675
                                                .rd_en (rd_hdr_fwft_fifo[i]),   // Read the next word
676
                                                .dout (class_out[i]),    // Data out
677
                                                .full ( ),
678
                                                .nearly_full ( ),
679
                                                .recieve_more_than_0 ( ),
680
                                                .recieve_more_than_1 ( ),
681
                                                .reset (reset),
682
                                                .clk (clk)
683
 
684
                                        );
685
                        end else begin :c_num_1
686
                                assign class_out[i] = 1'b0;
687
                        end
688
 
689 54 alirezamon
 
690
                        //localparam CAST_TYPE = "UNICAST"; // multicast is not yet supported
691
                        /* verilator lint_off WIDTH */
692
                        if(CAST_TYPE!= "UNICAST") begin : muticast
693
                        /* verilator lint_on WIDTH */
694
 
695
                                // for multicast we send one packet to each direction in order. The priority is according to DoR routing dimentions
696
 
697
                                fwft_fifo_with_output_clear #(
698
                                        .DATA_WIDTH(DSTPw),
699
                                        .MAX_DEPTH (MAX_PCK),
700
                                        .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
701
                                )
702
                                dest_fifo
703
                                (
704
                                        .din(destport_in_encoded),
705
                                        .wr_en(wr_hdr_fwft_fifo[i]),   // Write enable
706
                                        .rd_en(rd_hdr_fwft_fifo[i]),   // Read the next word
707
                                        .dout(dest_port_multi[i]),    // Data out
708
                                        .full(),
709
                                        .nearly_full(),
710
                                        .recieve_more_than_0(),
711
                                        .recieve_more_than_1(),
712
                                        .reset(reset),
713
                                        .clk(clk),
714
                                        .clear(clear_dspt_mulicast [i])   // clear the  destination port once it got  the entire packet
715
                                );
716
 
717
                                //TODO remove multiple_dest[i] to see if it works?
718
 
719
                                assign clear_dspt_mulicast [i] = (reset_ivc[i] & multiple_dest[i]) ? dest_port_encoded[i] : {DSTPw{1'b0}};
720
 
721
                                // a fix priority arbiter.
722
                                multicast_dst_sel  sel(
723
                                        .destport_in(dest_port_multi[i]),
724
                                        .destport_out(dest_port_encoded[i])
725
                                );
726
 
727
                                //check if we have multiple port to send a packet to
728
                                is_onehot0 #(
729
                                        .IN_WIDTH(DSTPw)
730
                        )
731
                        one_h
732
                                (
733
                                        .in(dest_port_multi[i]),
734
                                        .result(dst_onhot0[i])
735
                        );
736
                                assign multiple_dest[i]=~dst_onhot0[i];
737
 
738
 
739
                end     else begin : unicast
740
                        assign multiple_dest[i] = 1'b0;
741
 
742
 
743 48 alirezamon
                        //lk_dst_fifo
744
                        fwft_fifo #(
745
                                        .DATA_WIDTH(DSTPw),
746
                                        .MAX_DEPTH (MAX_PCK),
747
                                        .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
748
                                )
749
                                lk_dest_fifo
750
                                (
751
                                        .din (lk_destination_in_encoded),
752
                                        .wr_en (wr_hdr_fwft_fifo_delay [i]),   // Write enable
753
                                        .rd_en (rd_hdr_fwft_fifo_delay [i]),   // Read the next word
754
                                        .dout (lk_destination_encoded  [(i+1)*DSTPw-1 : i*DSTPw]),    // Data out
755
                                        .full (),
756
                                        .nearly_full (),
757
                                        .recieve_more_than_0 (),
758
                                        .recieve_more_than_1 (),
759
                                        .reset (reset),
760
                                        .clk (clk)
761
 
762
                                );
763
 
764
 
765 54 alirezamon
 
766
                                /* verilator lint_off WIDTH */
767
                                if( ROUTE_TYPE=="DETERMINISTIC") begin : dtrmn_dest
768
                                /* verilator lint_on WIDTH */
769
                                        //destport_fifo
770
                                        fwft_fifo #(
771
                                                        .DATA_WIDTH(DSTPw),
772
                                                        .MAX_DEPTH (MAX_PCK),
773
                                                        .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
774
                                                )
775
                                                dest_fifo
776
                                                (
777
                                                        .din(destport_in_encoded),
778
                                                        .wr_en(wr_hdr_fwft_fifo[i]),   // Write enable
779
                                                        .rd_en(rd_hdr_fwft_fifo[i]),   // Read the next word
780
                                                        .dout(dest_port_encoded[i]),    // Data out
781
                                                        .full(),
782
                                                        .nearly_full(),
783
                                                        .recieve_more_than_0(),
784
                                                        .recieve_more_than_1(),
785
                                                        .reset(reset),
786
                                                        .clk(clk)
787
                                                );
788
 
789
                                end else begin : adptv_dest
790
 
791
                                        fwft_fifo_with_output_clear #(
792
                                                        .DATA_WIDTH(DSTPw),
793
                                                        .MAX_DEPTH (MAX_PCK),
794
                                                        .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
795
                                                )
796
                                                dest_fifo
797
                                                (
798
                                                        .din(destport_in_encoded),
799
                                                        .wr_en(wr_hdr_fwft_fifo[i]),   // Write enable
800
                                                        .rd_en(rd_hdr_fwft_fifo[i]),   // Read the next word
801
                                                        .dout(dest_port_encoded[i]),    // Data out
802
                                                        .full(),
803
                                                        .nearly_full(),
804
                                                        .recieve_more_than_0(),
805
                                                        .recieve_more_than_1(),
806
                                                        .reset(reset),
807
                                                        .clk(clk),
808
                                                        .clear(destport_clear[i])   // clear other destination ports once one of them is selected
809
                                                );
810
 
811
 
812
                                end
813
                end//unicast
814 48 alirezamon
 
815
 
816
                        destp_generator #(
817
                                        .TOPOLOGY(TOPOLOGY),
818
                                        .ROUTE_NAME(ROUTE_NAME),
819
                                        .ROUTE_TYPE(ROUTE_TYPE),
820
                                        .T1(T1),
821
                                        .NL(T3),
822
                                        .P(P),
823
                                        .DSTPw(DSTPw),
824
                                        .PLw(PLw),
825
                                        .PPSw(PPSw),
826
                                        .SELF_LOOP_EN (SELF_LOOP_EN),
827 54 alirezamon
                                        .SW_LOC(SW_LOC),
828
                                        .CAST_TYPE(CAST_TYPE)
829 48 alirezamon
                                )
830
                                decoder
831
                                (
832
                                        .destport_one_hot (destport_one_hot[i]),
833 54 alirezamon
                                        .dest_port_encoded(dest_port_encoded[i]),
834 48 alirezamon
                                        .dest_port_out(dest_port[(i+1)*P_1-1 : i*P_1]),
835
                                        .endp_localp_num(endp_localp_num[(i+1)*PLw-1 : i*PLw]),
836
                                        .swap_port_presel(swap_port_presel[i]),
837
                                        .port_pre_sel(port_pre_sel),
838
                                        .odd_column(odd_column)
839
                                );
840
 
841
 
842
                        /* verilator lint_off WIDTH */
843 54 alirezamon
                        if (( TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS") && (T3>1) && (CAST_TYPE== "UNICAST")) begin : multi_local
844 48 alirezamon
                                /* verilator lint_on WIDTH */
845
                                // the router has multiple local ports. Save the destination local port
846
 
847
 
848
 
849
                                fwft_fifo #(
850
                                                .DATA_WIDTH(ELw),
851
                                                .MAX_DEPTH (MAX_PCK),
852
                                                .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
853
                                        )
854
                                        local_dest_fifo
855
                                        (
856
                                                .din(endp_l_in),
857
                                                .wr_en(wr_hdr_fwft_fifo[i]),   // Write enable
858
                                                .rd_en(rd_hdr_fwft_fifo[i]),   // Read the next word
859
                                                .dout(endp_localp_num[(i+1)*PLw-1 : i*PLw]),    // Data out
860
                                                .full( ),
861
                                                .nearly_full( ),
862
                                                .recieve_more_than_0(),
863
                                                .recieve_more_than_1(),
864
                                                .reset(reset),
865
                                                .clk(clk)
866
                                        );
867
                        /* verilator lint_off WIDTH */
868 54 alirezamon
                        end else if ( TOPOLOGY == "FMESH" && CAST_TYPE== "UNICAST") begin : fmesh
869 48 alirezamon
                        /* verilator lint_on WIDTH */
870
 
871
                                fwft_fifo #(
872
                                                .DATA_WIDTH(Pw),
873
                                                .MAX_DEPTH (MAX_PCK),
874
                                                .IGNORE_SAME_LOC_RD_WR_WARNING(IGNORE_SAME_LOC_RD_WR_WARNING)
875
                                        )
876
                                        local_dest_fifo
877
                                        (
878
                                                .din(endp_p_in),
879
                                                .wr_en(wr_hdr_fwft_fifo[i]),   // Write enable
880
                                                .rd_en(rd_hdr_fwft_fifo[i]),   // Read the next word
881
                                                .dout(endp_localp_num[(i+1)*PLw-1 : i*PLw]),    // Data out
882
                                                .full( ),
883
                                                .nearly_full( ),
884
                                                .recieve_more_than_0(),
885
                                                .recieve_more_than_1(),
886
                                                .reset(reset),
887
                                                .clk(clk)
888
                                        );
889
 
890
                        end else begin : single_local
891
                                assign endp_localp_num[(i+1)*PLw-1 : i*PLw] = {PLw{1'bx}};
892
                        end
893
 
894
                        /* verilator lint_off WIDTH */
895
                        if(SWA_ARBITER_TYPE != "RRA")begin  : wrra
896
                                /* verilator lint_on WIDTH */
897
                                /*
898
                weight_control #(
899
                    .WEIGHTw(WEIGHTw)
900
                )
901
                wctrl_per_vc
902
                (
903
                    .sw_is_granted(ivc_num_getting_sw_grant[i]),
904
                    .flit_is_tail(flit_is_tail[i]),
905
                    .weight_is_consumed_o(vc_weight_is_consumed[i]),
906
                    .iport_weight(1),  //(iport_weight),
907
                    .clk(clk),
908
                    .reset(reset)
909
                );
910
                                 */
911
                                assign vc_weight_is_consumed[i] = 1'b1;
912
                        end else begin :no_wrra
913
                                assign vc_weight_is_consumed[i] = 1'bX;
914
                        end
915
 
916
                end//for i
917
 
918
 
919
                /* verilator lint_off WIDTH */
920
                if(SWA_ARBITER_TYPE != "RRA")begin  : wrra
921
                        /* verilator lint_on WIDTH */
922
                        wire granted_flit_is_tail;
923
 
924
                        onehot_mux_1D #(
925
                                        .W(1),
926
                                        .N(V)
927
                                )onehot_mux(
928
                                        .in(flit_is_tail),
929
                                        .out(granted_flit_is_tail),
930
                                        .sel(ivc_num_getting_sw_grant)
931
                                );
932
 
933
                        weight_control#(
934
                                        .ARBITER_TYPE(SWA_ARBITER_TYPE),
935
                                        .SW_LOC(SW_LOC),
936
                                        .WEIGHTw(WEIGHTw),
937
                                        .WRRA_CONFIG_INDEX(WRRA_CONFIG_INDEX),
938
                                        .P(P),
939
                                        .SELF_LOOP_EN(SELF_LOOP_EN)
940
                                )
941
                                wctrl_iport
942
                                (
943
                                        .sw_is_granted(any_ivc_sw_request_granted),
944
                                        .flit_is_tail(granted_flit_is_tail),
945
                                        .weight_is_consumed_o(iport_weight_is_consumed),
946
                                        .iport_weight(iport_weight),
947
                                        .oports_weight(oports_weight),
948
                                        .granted_dest_port(granted_dest_port),
949
                                        .refresh_w_counter(refresh_w_counter),
950
                                        .clk(clk),
951
                                        .reset(reset)
952
                                );
953
 
954
                end else begin :no_wrra
955
                        assign iport_weight_is_consumed=1'bX;
956
                        assign oports_weight = {WP{1'bX}};
957
                end
958
 
959
                /* verilator lint_off WIDTH */
960
                if(COMBINATION_TYPE == "COMB_NONSPEC") begin  : nonspec
961
                        /* verilator lint_on WIDTH */
962 54 alirezamon
 
963
 
964
 
965
 
966
                         /*
967
 
968
                        always @(posedge clk)
969
                                if ((ivc_not_empty & flit_is_tail2) != (ivc_not_empty & flit_is_tail))begin
970
                                        $display("ERROR:    %b !=%b",flit_is_tail2 , flit_is_tail ) ;
971
                                        $finish;
972
                                end
973
                        */
974
 
975 48 alirezamon
 
976
                        flit_buffer #(
977
                                        .B(PORT_B),   // buffer space :flit per VC
978
                                        .SSA_EN(SSA_EN)
979
                                )
980
                                the_flit_buffer
981
                                (
982
 
983
                                        .din(flit_in),     // Data in
984
                                        .vc_num_wr(vc_num_in),//write virtual channel
985
                                        .vc_num_rd(nonspec_first_arbiter_granted_ivc),//read virtual channel
986
                                        .wr_en(flit_in_wr),   // Write enable
987
                                        .rd_en(any_ivc_sw_request_granted),     // Read the next word
988
                                        .dout(buffer_out),    // Data out
989
                                        .vc_not_empty(ivc_not_empty),
990
                                        .reset(reset),
991
                                        .clk(clk),
992 54 alirezamon
                                        .ssa_rd(ssa_ctrl_in.ivc_num_getting_sw_grant),
993
                                        .multiple_dest( multiple_dest ),
994
                                        .sub_rd_ptr_ld(reset_ivc) ,
995
                                        .flit_is_tail(flit_is_tail)
996 48 alirezamon
                                );
997
 
998
                end else begin :spec//not nonspec comb
999
 
1000
 
1001
                        flit_buffer #(
1002
                                        .B(PORT_B),   // buffer space :flit per VC
1003
                                        .SSA_EN(SSA_EN)
1004
                                )
1005
                                the_flit_buffer
1006
                                (
1007
                                        .din(flit_in),     // Data in
1008 54 alirezamon
                                        .vc_num_wr(vc_num_in),//write virtual channel
1009
                                        .vc_num_rd(ivc_num_getting_sw_grant),//read virtual channel
1010 48 alirezamon
                                        .wr_en(flit_in_wr),   // Write enable
1011
                                        .rd_en(any_ivc_sw_request_granted),     // Read the next word
1012
                                        .dout(buffer_out),    // Data out
1013
                                        .vc_not_empty(ivc_not_empty),
1014
                                        .reset(reset),
1015
                                        .clk(clk),
1016 54 alirezamon
                                        .ssa_rd(ssa_ctrl_in.ivc_num_getting_sw_grant),
1017
                                        .multiple_dest(  multiple_dest ),
1018
                                        .sub_rd_ptr_ld(reset_ivc) ,
1019
                                        .flit_is_tail(flit_is_tail)
1020
 
1021 48 alirezamon
                                );
1022
 
1023 54 alirezamon
                end
1024
 
1025
 
1026
                /* verilator lint_off WIDTH */
1027
                if(CAST_TYPE== "UNICAST") begin : unicast
1028
                /* verilator lint_on WIDTH */
1029
                        look_ahead_routing #(
1030
                                .T1(T1),
1031
                                .T2(T2),
1032
                                .T3(T3),
1033
                                .T4(T4),
1034
                                .P(P),
1035
                                .RAw(RAw),
1036
                                .EAw(EAw),
1037
                                .DAw(DAw),
1038
                                .DSTPw(DSTPw),
1039
                                .SW_LOC(SW_LOC),
1040
                                .TOPOLOGY(TOPOLOGY),
1041
                                .ROUTE_NAME(ROUTE_NAME),
1042
                                .ROUTE_TYPE(ROUTE_TYPE)
1043
                        )
1044
                        lk_routing
1045
                        (
1046
                                .current_r_addr(current_r_addr),
1047
                                .neighbors_r_addr(neighbors_r_addr),
1048
                                .dest_e_addr(dest_e_addr_in),
1049
                                .src_e_addr(src_e_addr_in),
1050
                                .destport_encoded(destport_in_encoded),
1051
                                .lkdestport_encoded(lk_destination_in_encoded),
1052
                                .reset(reset),
1053
                                .clk(clk)
1054
                        );
1055
                end // unicast
1056
 
1057
 
1058
 
1059 48 alirezamon
        endgenerate
1060
 
1061 54 alirezamon
 
1062 48 alirezamon
 
1063
        header_flit_update_lk_route_ovc #(
1064
                .P(P)
1065
        )
1066
        the_flit_update
1067
        (
1068
                .flit_in (buffer_out),
1069
                .flit_out (flit_out),
1070
                .vc_num_in(ivc_num_getting_sw_grant),
1071
                .lk_dest_all_in (lk_destination_encoded),
1072
                .assigned_ovc_num (assigned_ovc_num),
1073
                .any_ivc_sw_request_granted(any_ivc_sw_request_granted),
1074
                .lk_dest_not_registered(lk_destination_in_encoded),
1075
                .sel (sel),
1076
                .reset (reset),
1077
                .clk (clk)
1078
        );
1079
 
1080
 
1081
 
1082
        //synthesis translate_off
1083
        //synopsys  translate_off
1084
        generate
1085
        if(DEBUG_EN) begin :debg
1086
 
1087 54 alirezamon
 
1088
 
1089 48 alirezamon
                always @ (posedge clk) begin
1090
                        if((|vsa_ctrl_in.ivc_num_getting_sw_grant)  & (|ssa_ctrl_in.ivc_num_getting_sw_grant))begin
1091
                                $display("%t: ERROR: VSA/SSA conflict: an input port cannot get both sva and ssa grant at the same time %m",$time);
1092
                                $finish;
1093
                        end
1094
                end//always
1095
 
1096
                for (i=0;i
1097
                always @ (posedge clk) begin
1098
                        if(vsa_ctrl_in.ivc_num_getting_ovc_grant[i] | ssa_ctrl_in.ivc_num_getting_ovc_grant[i] | (smart_ctrl_in.ivc_num_getting_ovc_grant[i] & (PCK_TYPE == "MULTI_FLIT"))  )begin
1099
                                if( ~ $onehot (mux_out[i])) begin
1100
                                        $display("%t: ERROR: granted OVC num is not onehot coded %b: %m",$time,mux_out[i]);
1101
                                        $finish;
1102
                                end
1103
                        end
1104
                        if( ~ $onehot0( {vsa_ctrl_in.ivc_num_getting_ovc_grant[i],ssa_ctrl_in.ivc_num_getting_ovc_grant[i],(smart_ctrl_in.ivc_num_getting_ovc_grant[i]&& (PCK_TYPE == "MULTI_FLIT"))})) begin
1105
                                $display("%t: ERROR: ivc num %d getting more than one ovc grant from VSA,SSA,SMART: %m",$time,i);
1106
                                $finish;
1107
                        end
1108
                end//always
1109
 
1110 54 alirezamon
 
1111
 
1112
                always @(posedge clk) begin
1113
                        if((dest_port [(i+1)*P_1-1 : i*P_1] == {P_1{1'b0}})  && (ivc_request[i]==1'b1)) begin
1114
                                $display ("%t: ERROR: The destination port is not set for an active IVC request: %m \n",$time);
1115
                                $finish;
1116
                        end
1117
                end
1118
                end//for
1119
 
1120 48 alirezamon
                /* verilator lint_off WIDTH */
1121 54 alirezamon
                if (( TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS") && CAST_TYPE== "UNICAST") begin : mesh_based
1122 48 alirezamon
                /* verilator lint_on WIDTH */
1123
 
1124
                                debug_mesh_tori_route_ckeck #(
1125
                                                .T1(T1),
1126
                                                .T2(T2),
1127
                                                .T3(T3),
1128
                                                .ROUTE_TYPE(ROUTE_TYPE),
1129
                                                .V(V),
1130
                                                .AVC_ATOMIC_EN(AVC_ATOMIC_EN),
1131
                                                .SW_LOC(SW_LOC),
1132
                                                .ESCAP_VC_MASK(ESCAP_VC_MASK),
1133
                                                .TOPOLOGY(TOPOLOGY),
1134
                                                .DSTPw(DSTPw),
1135
                                                .RAw(RAw),
1136
                                                .EAw(EAw)
1137
                                        )
1138
                                        route_ckeck
1139
                                        (
1140
                                                .reset(reset),
1141
                                                .clk(clk),
1142
                                                .hdr_flg_in(hdr_flg_in),
1143
                                                .flit_in_wr(flit_in_wr),
1144
                                                .vc_num_in(vc_num_in),
1145
                                                .flit_is_tail(flit_is_tail),
1146
                                                .ivc_num_getting_sw_grant(ivc_num_getting_sw_grant),
1147
                                                .current_r_addr(current_r_addr),
1148
                                                .dest_e_addr_in(dest_e_addr_in),
1149
                                                .src_e_addr_in(src_e_addr_in),
1150
                                                .destport_in(destport_in)
1151
                                        );
1152
                end//mesh
1153
        end//DEBUG_EN
1154
        endgenerate
1155
 
1156
        `ifdef MONITORE_PATH
1157
                genvar j;
1158
                reg[V-1 :0] t1;
1159
                generate
1160
                        for (j=0;j
1161
                                always @(posedge clk) begin
1162
                                        if(reset)begin
1163
                                                t1[j]<=1'b0;
1164
                                        end else begin
1165
                                                if(flit_in_wr >0 && vc_num_in[j] && t1[j]==0)begin
1166
                                                        $display("%t : Parser:current_r=%h, class_in=%h, destport_in=%h, dest_e_addr_in=%h, src_e_addr_in=%h, vc_num_in=%h,hdr_flit_wr=%h, hdr_flg_in=%h,tail_flg_in=%h ",$time,current_r_addr, class_in, destport_in, dest_e_addr_in, src_e_addr_in, vc_num_in,hdr_flit_wr, hdr_flg_in,tail_flg_in);
1167
                                                        t1[j]<=1;
1168
                                                end
1169
                                        end
1170
                                end
1171
                        end
1172
                endgenerate
1173
        `endif
1174
        // synopsys  translate_on
1175
        // synthesis translate_on
1176
 
1177
 
1178
 
1179
 
1180
endmodule
1181
 
1182
 
1183
 
1184
 
1185
 
1186
// decode and mask the destination port according to routing algorithm and topology
1187
module destp_generator #(
1188
        parameter TOPOLOGY="MESH",
1189
        parameter ROUTE_NAME="XY",
1190
        parameter ROUTE_TYPE="DETERMINISTIC",
1191
        parameter T1=3,
1192
        parameter NL=1,
1193
        parameter P=5,
1194
        parameter DSTPw=4,
1195
        parameter PLw=1,
1196
        parameter PPSw=4,
1197
        parameter SW_LOC=0,
1198 54 alirezamon
        parameter SELF_LOOP_EN="NO",
1199
        parameter CAST_TYPE = "UNICAST"
1200 48 alirezamon
 
1201
)
1202
(
1203
        destport_one_hot,
1204
        dest_port_encoded,
1205
        dest_port_out,
1206
        endp_localp_num,
1207
        swap_port_presel,
1208
        port_pre_sel,
1209
        odd_column
1210
);
1211
 
1212
        localparam P_1= ( SELF_LOOP_EN=="NO")?  P-1 : P;
1213
        input [DSTPw-1 : 0]  dest_port_encoded;
1214
        input [PLw-1 : 0] endp_localp_num;
1215
        output [P_1-1: 0] dest_port_out;
1216
        output [P-1 : 0] destport_one_hot;
1217
        input             swap_port_presel;
1218
        input  [PPSw-1 : 0] port_pre_sel;
1219
        input odd_column;
1220
 
1221
        generate
1222 54 alirezamon
 
1223
        /* verilator lint_off WIDTH */
1224
        if(CAST_TYPE!= "UNICAST") begin : muticast
1225
        /* verilator lint_on WIDTH */
1226
                // destination port is not coded for multicast/broadcast
1227
                if( SELF_LOOP_EN=="NO") begin : nslp
1228
                        remove_sw_loc_one_hot #(
1229
                                        .P(P),
1230
                                        .SW_LOC(SW_LOC)
1231
                                )
1232
                                remove_sw_loc
1233
                                (
1234
                                        .destport_in(dest_port_encoded),
1235
                                        .destport_out(dest_port_out)
1236
                                );
1237
                end else begin : slp
1238
                        assign dest_port_out = dest_port_encoded;
1239
                end
1240
        /* verilator lint_off WIDTH */
1241
        end else if(TOPOLOGY == "FATTREE" ) begin : fat
1242
        /* verilator lint_on WIDTH */
1243 48 alirezamon
                        fattree_destp_generator #(
1244
                                .K(T1),
1245
                                .P(P),
1246
                                .SW_LOC(SW_LOC),
1247
                                .DSTPw(DSTPw),
1248
                                .SELF_LOOP_EN(SELF_LOOP_EN)
1249
                                )
1250
                        destp_generator
1251
                        (
1252
                                .dest_port_in_encoded(dest_port_encoded),
1253
                                .dest_port_out(dest_port_out)
1254
                        );
1255 54 alirezamon
        /* verilator lint_off WIDTH */
1256 48 alirezamon
        end else  if (TOPOLOGY == "TREE") begin :tree
1257 54 alirezamon
        /* verilator lint_on WIDTH */
1258 48 alirezamon
                tree_destp_generator #(
1259
                        .K(T1),
1260
                        .P(P),
1261
                        .SW_LOC(SW_LOC),
1262
                        .DSTPw(DSTPw),
1263
                        .SELF_LOOP_EN(SELF_LOOP_EN)
1264
                )
1265
                destp_generator
1266
                (
1267
                        .dest_port_in_encoded(dest_port_encoded),
1268
                        .dest_port_out(dest_port_out)
1269
                );
1270
        /* verilator lint_off WIDTH */
1271
        end else if(TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH"|| TOPOLOGY == "TORUS") begin : mesh
1272
                /* verilator lint_on WIDTH */
1273
                mesh_torus_destp_generator #(
1274
                        .TOPOLOGY(TOPOLOGY),
1275
                        .ROUTE_NAME(ROUTE_NAME),
1276
                        .ROUTE_TYPE(ROUTE_TYPE),
1277
                        .P(P),
1278
                        .DSTPw(DSTPw),
1279
                        .NL(NL),
1280
                        .PLw(PLw),
1281
                        .PPSw(PPSw),
1282
                        .SW_LOC(SW_LOC),
1283
                        .SELF_LOOP_EN(SELF_LOOP_EN)
1284
                )
1285
                destp_generator
1286
                (
1287
                        .dest_port_coded(dest_port_encoded),
1288
                        .endp_localp_num(endp_localp_num),
1289
                        .dest_port_out(dest_port_out),
1290
                        .swap_port_presel(swap_port_presel),
1291
                        .port_pre_sel(port_pre_sel),
1292
                        .odd_column(odd_column)// only needed for odd even routing
1293
                );
1294 54 alirezamon
                /* verilator lint_off WIDTH */
1295 48 alirezamon
        end else if (TOPOLOGY == "FMESH") begin :fmesh
1296 54 alirezamon
                /* verilator lint_on WIDTH */
1297 48 alirezamon
                fmesh_destp_generator  #(
1298
                        .ROUTE_NAME(ROUTE_NAME),
1299
                        .ROUTE_TYPE(ROUTE_TYPE),
1300
                        .P(P),
1301
                        .DSTPw(DSTPw),
1302
                        .NL(NL),
1303
                        .PLw(PLw),
1304
                        .PPSw(PPSw),
1305
                        .SW_LOC(SW_LOC),
1306
                        .SELF_LOOP_EN(SELF_LOOP_EN)
1307
                        )
1308
                        destp_generator
1309
                        (
1310
                                .dest_port_coded(dest_port_encoded),
1311
                                .endp_localp_num(endp_localp_num),
1312
                                .dest_port_out(dest_port_out),
1313
                                .swap_port_presel(swap_port_presel),
1314
                                .port_pre_sel(port_pre_sel),
1315
                                .odd_column(odd_column)                         // only needed for odd even routing
1316
                        );
1317
        end else begin :custom
1318
 
1319
                custom_topology_destp_decoder #(
1320
                        .ROUTE_TYPE(ROUTE_TYPE),
1321
                        .DSTPw(DSTPw),
1322
                        .P(P),
1323
                        .SW_LOC(SW_LOC),
1324
                        .SELF_LOOP_EN(SELF_LOOP_EN)
1325
                )
1326
                destp_generator
1327
                (
1328
                        .dest_port_in_encoded(dest_port_encoded),
1329
                        .dest_port_out(dest_port_out)
1330
                );
1331
        end
1332
 
1333
        if(SELF_LOOP_EN=="NO") begin : nslp
1334
                add_sw_loc_one_hot #(
1335
                                .P(P),
1336
                                .SW_LOC(SW_LOC)
1337
                )add
1338
                (
1339
                                .destport_in(dest_port_out),
1340
                                .destport_out(destport_one_hot)
1341
                );
1342
 
1343
        end else begin : slp
1344
                assign destport_one_hot = dest_port_out;
1345
        end
1346
 
1347
        endgenerate
1348
 
1349
 
1350
 
1351
 
1352
 
1353
 
1354
 
1355
 
1356
endmodule
1357
 
1358
/******************
1359
 *   custom_topology_destp_decoder
1360
 * ***************/
1361
 
1362
 
1363
module custom_topology_destp_decoder #(
1364
                parameter ROUTE_TYPE="DETERMINISTIC",
1365
                parameter DSTPw=4,
1366
                parameter P=5,
1367
                parameter SW_LOC=0,
1368
                parameter SELF_LOOP_EN="NO"
1369
                )(
1370
                dest_port_in_encoded,
1371
                dest_port_out
1372
                );
1373
 
1374
        localparam
1375
                P_1 = ( SELF_LOOP_EN=="NO")?  P-1 : P,
1376
                MAXW =2**DSTPw;
1377
 
1378
        input  [DSTPw-1 : 0] dest_port_in_encoded;
1379
        output [P_1-1 : 0] dest_port_out;
1380
 
1381
 
1382
        wire [MAXW-1 : 0] dest_port_one_hot;
1383
 
1384
        bin_to_one_hot #(
1385
                        .BIN_WIDTH(DSTPw),
1386
                        .ONE_HOT_WIDTH(MAXW)
1387
                )
1388
                conv
1389
                (
1390
                        .bin_code(dest_port_in_encoded),
1391
                        .one_hot_code(dest_port_one_hot)
1392
                );
1393
        generate
1394
        if( SELF_LOOP_EN=="NO") begin : nslp
1395
        remove_sw_loc_one_hot #(
1396
                        .P(P),
1397
                        .SW_LOC(SW_LOC)
1398
                )
1399
                remove_sw_loc
1400
                (
1401
                        .destport_in(dest_port_one_hot[P-1 : 0]),
1402
                        .destport_out(dest_port_out)
1403
                );
1404
        end else begin : slp
1405
                assign dest_port_out = dest_port_one_hot;
1406
        end
1407
        endgenerate
1408
        //synthesis translate_off
1409
        //synopsys  translate_off
1410
 
1411
        initial begin
1412
                if( ROUTE_TYPE != "DETERMINISTIC") begin
1413
                        $display("%t: ERROR: Custom topologies can only support deterministic routing in the current version of ProNoC",$time);
1414
                        $finish;
1415
                end
1416
        end
1417
 
1418
 
1419
        //synopsys  translate_on
1420
        //synthesis translate_on
1421
 
1422
endmodule

powered by: WebSVN 2.1.0

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