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 48

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

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

powered by: WebSVN 2.1.0

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