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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 alirezamon
`include "pronoc_def.v"
2 48 alirezamon
 
3 56 alirezamon
module  traffic_gen_top #(
4
        parameter NOC_ID=0,
5
        parameter MAX_RATIO = 1000,
6
        parameter ENDP_ID   = 100000
7
)
8 48 alirezamon
        (
9
 
10
                //noc port
11
                chan_in,
12
                chan_out,
13
 
14
                //input
15
                ratio,// real injection ratio  = (MAX_RATIO/100)*ratio
16
                pck_size_in,
17
                current_e_addr,
18
                dest_e_addr,
19
                pck_class_in,
20
                start,
21
                stop,
22
                report,
23
                init_weight,
24
                start_delay,
25
 
26
                //output
27
                pck_number,
28
                sent_done, // tail flit has been sent
29
                hdr_flit_sent,
30
                update, // update the noc_analayzer
31
                src_e_addr,
32
                flit_out_class,
33
                flit_out_wr,
34
                flit_in_wr,
35
 
36
                distance,
37
                pck_class_out,
38
                time_stamp_h2h,
39
                time_stamp_h2t,
40
                pck_size_o,
41 54 alirezamon
                mcast_dst_num_o,
42 48 alirezamon
 
43
                reset,
44
                clk
45
 
46
        );
47 56 alirezamon
 
48
 
49
        `NOC_CONF
50
 
51
 
52 48 alirezamon
 
53
        localparam
54
                RATIOw= $clog2(MAX_RATIO);
55
 
56
        //      Vw =    $clog2(V);
57
 
58
        input   smartflit_chanel_t      chan_in;
59
        output  smartflit_chanel_t      chan_out;
60
 
61
 
62
 
63
 
64
        localparam
65
                PCK_CNTw = log2(MAX_PCK_NUM+1),
66 56 alirezamon
                CLK_CNTw = log2(MAX_SIM_CLKs+1),
67 48 alirezamon
                AVG_PCK_SIZw = log2(10*MAX_PCK_SIZ+1),
68 56 alirezamon
                /* verilator lint_off WIDTH */
69 48 alirezamon
                W=WEIGHTw,
70
                PORT_B = (TOPOLOGY!="FMESH")?  LB :
71
                (ENDP_ID < NE_MESH_TORI)? LB :B; // in FMESH, the buffer size of endpoints connected to edge routers non-local ports are B not LB
72
                /* verilator lint_on WIDTH */
73
        input reset, clk;
74
        input  [RATIOw-1                :0] ratio;
75
        input                               start,stop;
76
        output                              update;
77
        output [CLK_CNTw-1              :0] time_stamp_h2h,time_stamp_h2t;
78
        output [DISTw-1                 :0] distance;
79
        output [Cw-1                    :0] pck_class_out;
80
 
81
        // the current endpoint address
82
        input  [EAw-1                   :0] current_e_addr;
83
        // the destination endpoint address
84 54 alirezamon
        input  [DAw-1                   :0] dest_e_addr;
85 48 alirezamon
 
86
        output [PCK_CNTw-1              :0] pck_number;
87
        input  [PCK_SIZw-1              :0] pck_size_in;
88
 
89
        output reg sent_done;
90
        output reg hdr_flit_sent;
91
        input  [Cw-1                    :0] pck_class_in;
92
        input  [W-1                     :0] init_weight;
93
 
94
        input                               report;
95
        input  [DELAYw-1                        :0] start_delay;
96
        // the received packet source endpoint address
97
        output [EAw-1        :   0]    src_e_addr;
98
        output [PCK_SIZw-1   :   0]    pck_size_o;
99 54 alirezamon
        output [NEw-1 : 0] mcast_dst_num_o;
100 48 alirezamon
 
101
 
102
        logic  [Fw-1                   :0] flit_out;
103
        output  logic                       flit_out_wr;
104
        output  [Cw-1 : 0] flit_out_class;
105
        logic   [V-1                    :0] credit_in;
106
 
107
        logic   [Fw-1                   :0] flit_in;
108
        output logic                              flit_in_wr;
109
        logic  [V-1                :0] credit_out;
110
 
111
        // the connected router address
112
        wire  [RAw-1                   :0] current_r_addr;
113
 
114
 
115 54 alirezamon
        /* verilator lint_off WIDTH */
116
        wire [PCK_SIZw-1 : 0] pck_size_tmp= (PCK_TYPE == "SINGLE_FLIT" )?   1 : pck_size_in;
117
        /* verilator lint_on WIDTH */
118
 
119 48 alirezamon
        assign  chan_out.flit_chanel.flit = flit_out;
120
        assign  chan_out.flit_chanel.flit_wr = flit_out_wr;
121
        assign  chan_out.flit_chanel.credit = credit_out;
122 54 alirezamon
        assign  chan_out.smart_chanel = {SMART_CHANEL_w {1'b0}};
123 48 alirezamon
 
124
        assign flit_in   =  chan_in.flit_chanel.flit;
125
        assign flit_in_wr=  chan_in.flit_chanel.flit_wr;
126
        assign credit_in =  chan_in.flit_chanel.credit;
127
        assign current_r_addr = chan_in.ctrl_chanel.neighbors_r_addr;
128
 
129
        genvar i;
130
        generate
131
        for (i=0; i
132
                assign chan_out.ctrl_chanel.credit_init_val[i]= PORT_B;
133
        end
134
        endgenerate
135 54 alirezamon
 
136
        assign chan_out.ctrl_chanel.endp_port =1'b1;
137
        assign chan_out.ctrl_chanel.credit_release_en={V{1'b0}};
138
 
139 48 alirezamon
        //old traffic.v file
140
 
141
        reg [2:0]   ps,ns;
142
        localparam IDEAL =3'b001, SENT =3'b010, WAIT=3'b100;
143
 
144
        reg                                 inject_en,cand_wr_vc_en,pck_rd;
145 54 alirezamon
        reg    [PCK_SIZw-1              :0] pck_size;
146
        logic  [DAw-1                   :0] dest_e_addr_reg,dest_e_addr_o;
147 56 alirezamon
 
148
 
149
 
150
 
151 48 alirezamon
 
152
        // synopsys  translate_off
153
        // synthesis translate_off
154
 
155
        `ifdef MONITORE_PATH
156
 
157
 
158
                reg tt;
159
                always @(posedge clk) begin
160 56 alirezamon
                        if(`pronoc_reset)begin
161 48 alirezamon
                                tt<=1'b0;
162
                        end else begin
163
                                if(flit_out_wr && tt==1'b0 )begin
164
                                        $display( "%t: Injector: current_r_addr=%x,current_e_addr=%x,dest_e_addr=%x\n",$time, current_r_addr, current_e_addr, dest_e_addr);
165
                                        tt<=1'b1;
166
                                end
167
                        end
168
                end
169
        `endif
170
 
171
        // synthesis translate_on
172
        // synopsys  translate_on
173 56 alirezamon
 
174 48 alirezamon
 
175
        localparam
176
                HDR_DATA_w =  (MIN_PCK_SIZE==1)? CLK_CNTw : 0,
177
                HDR_Dw =  (MIN_PCK_SIZE==1)? CLK_CNTw : 1;
178
 
179
        wire [HDR_Dw-1 : 0] hdr_data_in,rd_hdr_data_out;
180
 
181 54 alirezamon
        pronoc_register #(.W(DAw)) reg2 (.in(dest_e_addr ), .out(dest_e_addr_reg), .reset(reset), .clk(clk));
182
 
183
 
184 48 alirezamon
 
185 56 alirezamon
        wire    [DSTPw-1                :   0] destport;
186
        wire    [V-1                    :   0] ovc_wr_in;
187
        wire    [V-1                    :   0] full_vc,empty_vc,nearly_full_vc;
188
        reg     [V-1                    :   0] wr_vc,wr_vc_next;
189
        wire    [V-1                    :   0] cand_vc;
190 48 alirezamon
 
191
 
192 56 alirezamon
        wire    [CLK_CNTw-1             :   0] wr_timestamp,pck_timestamp;
193
        wire                                   hdr_flit,tail_flit;
194
        reg     [PCK_SIZw-1             :   0] flit_counter;
195
        reg                                    flit_cnt_rst,flit_cnt_inc;
196
        wire                                   rd_hdr_flg,rd_tail_flg;
197
        wire    [Cw-1   :   0] rd_class_hdr;
198
        //  wire    [P_1-1      :   0] rd_destport_hdr;
199
        wire    [DAw-1      :   0] rd_des_e_addr;
200
        wire    [EAw-1      :   0] rd_src_e_addr;
201 54 alirezamon
 
202 56 alirezamon
        reg     [CLK_CNTw-1             :   0] rsv_counter;
203
        reg     [CLK_CNTw-1             :   0] clk_counter;
204
        wire    [Vw-1                   :   0] rd_vc_bin;//,wr_vc_bin;
205
        reg     [CLK_CNTw-1             :   0] rsv_time_stamp[V-1:0];
206
        reg     [PCK_SIZw-1             :   0] rsv_pck_size    [V-1:0];
207
        wire    [V-1                    :   0] rd_vc;
208
        wire                                   wr_vc_is_full,wr_vc_avb,wr_vc_is_empty;
209
        reg     [V-1                    :   0] credit_out_next;
210
        reg     [EAw-1     :   0] rsv_pck_src_e_addr        [V-1:0];
211
        reg     [Cw-1                   :   0] rsv_pck_class_in     [V-1:0];
212 48 alirezamon
 
213 56 alirezamon
        wire [CLK_CNTw-1             :   0] hdr_flit_timestamp;
214
        wire pck_wr,buffer_full,pck_ready,valid_dst;
215
        wire [CLK_CNTw-1 : 0] rd_timestamp;
216
 
217 48 alirezamon
 
218 56 alirezamon
        logic [DELAYw-1 : 0] start_delay_counter,start_delay_counter_next;
219
        logic  start_en_next , start_en;
220 48 alirezamon
 
221 56 alirezamon
        pronoc_register #(.W(1)) streg1 (.reset(reset),.clk(clk), .in(start_en_next), .out(start_en)    );
222
        pronoc_register #(.W(DELAYw)) streg2 (.reset(reset),.clk(clk), .in(start_delay_counter_next), .out(start_delay_counter) );
223
 
224
        always @(*) begin
225
                start_en_next =start_en;
226
                start_delay_counter_next= start_delay_counter;
227
                if(start)       begin
228
                        start_en_next=1'b1;
229
                        start_delay_counter_next={DELAYw{1'b0}};
230
                end else if(start_en && ~inject_en) begin
231
                        start_delay_counter_next= start_delay_counter + 1'b1;
232
                end
233
                if(stop) begin
234
                        start_en_next=1'b0;
235
                end
236
        end//always
237 48 alirezamon
 
238 56 alirezamon
        wire start_injection = (start_delay_counter == start_delay);
239 48 alirezamon
 
240 56 alirezamon
        check_destination_addr #(
241
                .NOC_ID(NOC_ID),
242
                .TOPOLOGY(TOPOLOGY),
243
                .T1(T1),
244
                .T2(T2),
245
                .T3(T3),
246
                .EAw(EAw),
247
                .SELF_LOOP_EN(SELF_LOOP_EN),
248
                .DAw(DAw),
249
                .CAST_TYPE(CAST_TYPE),
250
                .NE(NE)
251
        ) check_destination_addr (
252
                .dest_e_addr(dest_e_addr),
253
                .current_e_addr(current_e_addr),
254
                .dest_is_valid(valid_dst)
255
        );
256
 
257
        //assign hdr_flit_sent=pck_rd;
258 48 alirezamon
 
259 56 alirezamon
        injection_ratio_ctrl #  (
260
                .MAX_PCK_SIZ(MAX_PCK_SIZ),
261
                .MAX_RATIO(MAX_RATIO)
262
        ) pck_inject_ratio_ctrl (
263
                .en(inject_en),
264
                .pck_size_in(pck_size_tmp),
265
                .clk(clk),
266
                .reset(reset),
267
                .freez(buffer_full),
268
                .inject(pck_wr),
269
                .ratio(ratio)
270
        );
271
 
272 48 alirezamon
 
273 56 alirezamon
        output_vc_status #(
274
                .CRDTw(CRDTw),
275
                .V  (V),
276
                .B  (PORT_B)
277
        ) nic_ovc_status (
278
                .credit_init_val_in         ( chan_in.ctrl_chanel.credit_init_val),
279
                .wr_in                      (ovc_wr_in),
280
                .credit_in                  (credit_in),
281
                .nearly_full_vc             (nearly_full_vc),
282
                .full_vc                    (full_vc),
283
                .empty_vc                   (empty_vc),
284
                .cand_vc                    (cand_vc),
285
                .cand_wr_vc_en              (cand_wr_vc_en),
286
                .clk                        (clk),
287
                .reset                      (reset)
288
        );
289
 
290 48 alirezamon
 
291 56 alirezamon
        packet_gen #(
292
                .NOC_ID(NOC_ID),
293
                .P(MAX_P)
294
        )       packet_buffer (
295
                .reset(reset),
296
                .clk(clk),
297
                .pck_wr(pck_wr),
298
                .pck_rd(pck_rd),
299
                .current_r_addr(current_r_addr),
300
                .current_e_addr(current_e_addr),
301
                .clk_counter(clk_counter+1'b1),//in case of zero load latency, the flit will be injected in the next clock cycle
302
                .pck_number(pck_number),
303
                .dest_e_addr_in(dest_e_addr),
304
                .dest_e_addr_o(dest_e_addr_o),
305
                .pck_timestamp(pck_timestamp),
306
                .buffer_full(buffer_full),
307
                .pck_ready(pck_ready),
308
                .valid_dst(valid_dst),
309
                .destport(destport),
310
                .pck_size_in(pck_size_tmp),
311
                .pck_size_o(pck_size)
312
        );
313
 
314
        assign wr_timestamp    =pck_timestamp;
315
    assign  update      = flit_in_wr & flit_in[Fw-2];
316
        assign  hdr_flit    = (flit_counter == 0);
317
        assign  tail_flit   = (flit_counter ==  pck_size-1'b1);
318
 
319
        assign  time_stamp_h2h  = hdr_flit_timestamp - rd_timestamp;
320
        assign  time_stamp_h2t  = clk_counter - rd_timestamp;
321 48 alirezamon
 
322 56 alirezamon
        wire [FPAYw-1    :   0] flit_out_pyload;
323
        wire [1         :   0] flit_out_hdr;
324
        wire [FPAYw-1    :   0] flit_out_header_pyload;
325
        wire [Fw-1      :   0] hdr_flit_out;
326
 
327
        assign hdr_data_in = (MIN_PCK_SIZE==1)? wr_timestamp[HDR_Dw-1 : 0]  : {HDR_Dw{1'b0}};
328 48 alirezamon
 
329 56 alirezamon
        header_flit_generator #(
330
                .NOC_ID(NOC_ID),
331
                .DATA_w(HDR_DATA_w)
332
        ) the_header_flit_generator (
333
                .flit_out(hdr_flit_out),
334
                .vc_num_in(wr_vc),
335
                .class_in(pck_class_in),
336
                .dest_e_addr_in(dest_e_addr_o),
337
                .src_e_addr_in(current_e_addr),
338
                .weight_in(init_weight),
339
                .destport_in(destport),
340
                .data_in(hdr_data_in),
341
                .be_in({BEw{1'b1}} )// Be is not used in simulation as we dont sent real data
342
        );
343 48 alirezamon
 
344 56 alirezamon
    assign flit_out_class = pck_class_in;
345
        assign flit_out_hdr = {hdr_flit,tail_flit};
346 48 alirezamon
 
347 56 alirezamon
        assign flit_out_header_pyload = hdr_flit_out[FPAYw-1 : 0];
348 48 alirezamon
 
349
 
350 56 alirezamon
        /* verilator lint_off WIDTH */
351
        assign flit_out_pyload = (hdr_flit)  ?    flit_out_header_pyload :
352
                (tail_flit) ?     wr_timestamp:
353
                {pck_number,flit_counter};
354 48 alirezamon
                /* verilator lint_on WIDTH */
355 56 alirezamon
 
356
        assign flit_out = {flit_out_hdr, wr_vc, flit_out_pyload };
357 48 alirezamon
 
358 56 alirezamon
        //extract header flit info
359
    extract_header_flit_info #(
360
                .NOC_ID(NOC_ID),
361
                .DATA_w(HDR_DATA_w)
362
        ) header_extractor (
363
                .flit_in(flit_in),
364
                .flit_in_wr(flit_in_wr),
365
                .class_o(rd_class_hdr),
366
                .destport_o(),
367
                .dest_e_addr_o(rd_des_e_addr),
368
                .src_e_addr_o(rd_src_e_addr),
369
                .vc_num_o(rd_vc),
370
                .hdr_flit_wr_o( ),
371
                .hdr_flg_o(rd_hdr_flg),
372
                .tail_flg_o(rd_tail_flg),
373
                .weight_o( ),
374
                .be_o( ),
375
                .data_o(rd_hdr_data_out)
376
        );
377 48 alirezamon
 
378
 
379 56 alirezamon
        distance_gen #(
380
                .TOPOLOGY(TOPOLOGY),
381
                .T1(T1),
382
                .T2(T2),
383
                .T3(T3),
384
                .EAw(EAw),
385
                .DISTw(DISTw)
386
        ) the_distance_gen (
387
                .src_e_addr(src_e_addr),
388
                .dest_e_addr(current_e_addr),
389
                .distance(distance)
390
        );
391 48 alirezamon
 
392
 
393
        generate
394
        if(MIN_PCK_SIZE == 1) begin : sf_pck
395
                assign src_e_addr         = (rd_hdr_flg & rd_tail_flg)? rd_src_e_addr : rsv_pck_src_e_addr[rd_vc_bin];
396
                assign pck_class_out      = (rd_hdr_flg & rd_tail_flg)? rd_class_hdr : rsv_pck_class_in[rd_vc_bin];
397
                assign hdr_flit_timestamp = (rd_hdr_flg & rd_tail_flg)?  clk_counter : rsv_time_stamp[rd_vc_bin];
398
                assign rd_timestamp       =     (rd_hdr_flg & rd_tail_flg)? rd_hdr_data_out : flit_in[CLK_CNTw-1             :   0];
399
                assign pck_size_o         = (rd_hdr_flg & rd_tail_flg)? 1 : rsv_pck_size[rd_vc_bin];
400
        end else begin : no_sf_pck
401
                assign pck_size_o = rsv_pck_size[rd_vc_bin];
402
                assign src_e_addr            = rsv_pck_src_e_addr[rd_vc_bin];
403
                assign pck_class_out    = rsv_pck_class_in[rd_vc_bin];
404
                assign hdr_flit_timestamp = rsv_time_stamp[rd_vc_bin];
405
                assign rd_timestamp=flit_in[CLK_CNTw-1 :   0];
406
        end
407
 
408
 
409 56 alirezamon
        if(V==1) begin : v1
410 48 alirezamon
                assign rd_vc_bin=1'b0;
411
        // assign wr_vc_bin=1'b0;
412
        end else begin :vother
413
 
414
                one_hot_to_bin #( .ONE_HOT_WIDTH (V)) conv1
415
                (
416
                        .one_hot_code   (rd_vc),
417
                        .bin_code       (rd_vc_bin)
418
                );
419
        /*
420
    one_hot_to_bin #( .ONE_HOT_WIDTH (V)) conv2
421
    (
422
        .one_hot_code   (wr_vc),
423
        .bin_code       (wr_vc_bin)
424
    );
425
         */
426
        end
427
        endgenerate
428
 
429
 
430
        assign  ovc_wr_in   = (flit_out_wr ) ?      wr_vc : {V{1'b0}};
431
 
432
        /* verilator lint_off WIDTH */
433 56 alirezamon
        //assign  wr_vc_is_full           = (SSA_EN=="NO")?  | ( full_vc & wr_vc)  : | (nearly_full_vc & wr_vc);
434
        assign  wr_vc_is_full           = | ( full_vc & wr_vc);
435 48 alirezamon
    /* verilator lint_on WIDTH */
436
 
437
 
438
        generate
439
        /* verilator lint_off WIDTH */
440
                if(VC_REALLOCATION_TYPE ==  "NONATOMIC") begin : nanatom_b
441
                        /* verilator lint_on WIDTH */
442
                        assign wr_vc_avb    =  ~wr_vc_is_full;
443
                end else begin : atomic_b
444
                        assign wr_vc_is_empty   =  | ( empty_vc & wr_vc);
445
                        assign wr_vc_avb        =  wr_vc_is_empty;
446
                end
447
        endgenerate
448
 
449
        reg not_yet_sent_aflit_next,not_yet_sent_aflit;
450
 
451
        always @(*)begin
452
                wr_vc_next          = wr_vc;
453
                cand_wr_vc_en       = 1'b0;
454
                flit_out_wr         = 1'b0;
455
                flit_cnt_inc        = 1'b0;
456
                flit_cnt_rst        = 1'b0;
457
                credit_out_next     = {V{1'd0}};
458
                sent_done           = 1'b0;
459
                pck_rd              = 1'b0;
460
                hdr_flit_sent       =1'b0;
461
                ns                  = ps;
462
                pck_rd              =1'b0;
463
 
464
 
465
                not_yet_sent_aflit_next =not_yet_sent_aflit;
466
                case (ps)
467
                        IDEAL: begin
468
                                if(pck_ready ) begin
469
                                        if(wr_vc_avb && valid_dst)begin
470
 
471
                                                hdr_flit_sent=1'b1;
472
                                                flit_out_wr     = 1'b1;//sending header flit
473
                                                not_yet_sent_aflit_next = 1'b0;
474
                                                flit_cnt_inc = 1'b1;
475
                                                if (MIN_PCK_SIZE>1 || flit_out_hdr!=2'b11) begin
476
                                                        ns              = SENT;
477
                                                end else begin
478
                                                        pck_rd=1'b1;
479
                                                        flit_cnt_rst   = 1'b1;
480
                                                        sent_done       =1'b1;
481
                                                        cand_wr_vc_en   =1'b1;
482
                                                        if(cand_vc>0) begin
483
                                                                wr_vc_next  = cand_vc;
484
                                                        end  else ns = WAIT;
485
                                                end  //else
486
                                        end//wr_vc
487
                                end
488
 
489
                        end //IDEAL
490
                        SENT: begin
491
 
492
                                if(!wr_vc_is_full )begin
493
 
494
                                        flit_out_wr     = 1'b1;
495
                                        if(flit_counter  < pck_size-1) begin
496
                                                flit_cnt_inc = 1'b1;
497
                                        end else begin
498
                                                flit_cnt_rst   = 1'b1;
499
                                                sent_done       =1'b1;
500
                                                pck_rd=1'b1;
501
                                                cand_wr_vc_en   =1'b1;
502
                                                if(cand_vc>0) begin
503
                                                        wr_vc_next  = cand_vc;
504
                                                        ns          =IDEAL;
505
                                                end     else ns = WAIT;
506
                                        end//else
507
                                end // if wr_vc_is_full
508
                        end//SENT
509
                        WAIT:begin
510
 
511
                                cand_wr_vc_en   =1'b1;
512
                                if(cand_vc>0) begin
513
                                        wr_vc_next  = cand_vc;
514
                                        ns                  =IDEAL;
515
                                end
516
                        end
517
                        default: begin
518
                                ns                  =IDEAL;
519
                        end
520
                endcase
521
 
522
 
523
                // packet sink
524
                if(flit_in_wr) begin
525
                        credit_out_next = rd_vc;
526
                end else credit_out_next = {V{1'd0}};
527
        end
528
 
529 54 alirezamon
 
530
                always @ (`pronoc_clk_reset_edge )begin
531
                        if(`pronoc_reset) begin
532 48 alirezamon
                                inject_en       <= 1'b0;
533
                                ps              <= IDEAL;
534
                                wr_vc           <=1;
535
                                flit_counter    <= {PCK_SIZw{1'b0}};
536
                                credit_out      <= {V{1'd0}};
537
                                rsv_counter     <= 0;
538
                                clk_counter     <=  0;
539
                                not_yet_sent_aflit<=1'b1;
540
 
541
                        end else begin
542
                                //injection
543
                                not_yet_sent_aflit<=not_yet_sent_aflit_next;
544
                                inject_en <=  (start_injection |inject_en) & ~stop;
545
                                ps             <= ns;
546
                                clk_counter     <= clk_counter+1'b1;
547
                                wr_vc           <=wr_vc_next;
548
                                if (flit_cnt_rst)      flit_counter    <= {PCK_SIZw{1'b0}};
549
                                else if(flit_cnt_inc)   flit_counter    <= flit_counter + 1'b1;
550
                                credit_out      <= credit_out_next;
551 54 alirezamon
 
552 48 alirezamon
 
553
                                //sink
554
                                if(flit_in_wr) begin
555
                                        if (flit_in[Fw-1])begin //header flit
556
                                                rsv_pck_src_e_addr[rd_vc_bin]    <=  rd_src_e_addr;
557
                                                rsv_pck_class_in[rd_vc_bin]    <= rd_class_hdr;
558
                                                rsv_time_stamp[rd_vc_bin]   <= clk_counter;
559
                                                rsv_counter                 <= rsv_counter+1'b1;
560
                                                rsv_pck_size[rd_vc_bin] <=2;
561
                                                // distance        <= {{(32-8){1'b0}},flit_in[7:0]};
562
                                                `ifdef RSV_NOTIFICATION
563
                                                        // synopsys  translate_off
564
                                                        // synthesis translate_off
565
                                                        // last_pck_time<=$time;
566
                                                        $display ("total of %d pcks have been recived in core (%d)", rsv_counter,current_e_addr);
567
                                                        // synthesis translate_on
568
                                                        // synopsys  translate_on
569
                                                `endif
570
                                        end else begin
571
                                                 rsv_pck_size[rd_vc_bin] <=rsv_pck_size[rd_vc_bin]+1;
572
                                        end
573
                                end
574
                                // synopsys  translate_off
575
                                // synthesis translate_off
576
                                if(report) begin
577
                                        $display ("%t,\t total of %d pcks have been recived in core (%d)",$time ,rsv_counter,current_e_addr);
578
                                end
579
                                // synthesis translate_on
580
                                // synopsys  translate_on
581
 
582
 
583
 
584
 
585
 
586
                        end
587
                end//always
588
 
589
 
590 54 alirezamon
 
591
 
592
 
593
 
594
                wire [NE-1 :0] dest_mcast_all_endp1;
595
 
596
 
597
                generate
598
                        /* verilator lint_off WIDTH */
599
                        if(CAST_TYPE != "UNICAST") begin :mb_cast
600
                        /* verilator lint_on WIDTH */
601
 
602
                                wire [NEw-1 : 0] sum_temp;
603
                                wire is_unicast;
604
 
605 56 alirezamon
                                mcast_dest_list_decode #(
606
                                        .NOC_ID(NOC_ID)
607
                                ) decode1 (
608
                                        .dest_e_addr(dest_e_addr_o),
609
                                        .dest_o(dest_mcast_all_endp1),
610
                                        .row_has_any_dest(),
611
                                        .is_unicast(is_unicast)
612
                                );
613 54 alirezamon
 
614
                                /* verilator lint_off WIDTH */
615
                                if (CAST_TYPE == "BROADCAST_FULL") begin :bcastf
616
                                        assign mcast_dst_num_o = (is_unicast) ? 1 : (SELF_LOOP_EN == "NO")? NE-1 : NE;
617
                                end else  if ( CAST_TYPE == "BROADCAST_PARTIAL" )  begin :bcastp
618
 
619
                                        if (SELF_LOOP_EN == "NO") begin
620
                                                //check if injector node is included in partial list
621
                                                wire [NEw-1: 0]  current_enp_id;
622
                                                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod1 ( .id(current_enp_id), .code(current_e_addr));
623
                                                assign mcast_dst_num_o = (is_unicast) ? 1 : (MCAST_ENDP_LIST[current_enp_id]== 1'b1)?  MCAST_PRTLw-1 :  MCAST_PRTLw;
624
 
625
                                        end else begin
626
                                                assign mcast_dst_num_o = (is_unicast)? 1 :  MCAST_PRTLw;
627
                                        end
628
                                /* verilator lint_on WIDTH */
629
                                end else begin : mcast
630
                                        accumulator #(
631
                                                        .INw(NE),
632
                                                        .OUTw(NEw),
633
                                                        .NUM(NE)
634
                                                )accum
635
                                                (
636
                                                        .in_all(dest_mcast_all_endp1),
637
                                                        .out(sum_temp)
638
                                                );
639
                                        assign mcast_dst_num_o = sum_temp;
640
                                end
641
                        end
642
                endgenerate
643
 
644
 
645
 
646
 
647
 
648
/***************************************************************
649
 *                      simulation code
650
 * ************************************************************/
651
 
652
 
653
 
654
 
655
 
656
// synthesis translate_off
657
 
658 48 alirezamon
                wire [NEw-1: 0]  src_id,dst_id,current_id;
659
 
660
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod1 ( .id(current_id), .code(current_e_addr));
661 54 alirezamon
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod2 ( .id(dst_id), .code(rd_des_e_addr[EAw-1 : 0]));// only for unicast
662 48 alirezamon
                endp_addr_decoder  #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) decod3 ( .id(src_id), .code(rd_src_e_addr));
663
 
664
 
665 54 alirezamon
 
666
 
667
 
668
                wire [NE-1 :0] dest_mcast_all_endp2;
669
                generate
670
                if(CAST_TYPE != "UNICAST") begin :no_unicast
671 56 alirezamon
                        mcast_dest_list_decode #(
672
                                .NOC_ID(NOC_ID)
673
                        ) decode2 (
674
                                .dest_e_addr(rd_des_e_addr),
675
                                .dest_o(dest_mcast_all_endp2),
676
                                .row_has_any_dest(),
677
                                .is_unicast()
678
                        );
679
                end
680
                endgenerate
681 54 alirezamon
 
682
 
683 48 alirezamon
 
684
                always @(posedge clk) begin
685 54 alirezamon
                        /* verilator lint_off WIDTH */
686
                        if(CAST_TYPE == "UNICAST") begin
687
                                /* verilator lint_on WIDTH */
688
                                if(flit_out_wr && hdr_flit && dest_e_addr_o [EAw-1 : 0]  == current_e_addr  && SELF_LOOP_EN == "NO") begin
689
                                        $display("%t: ERROR: The self-loop is not enabled in the router while a packet is injected to the NoC with identical source and destination address in endpoint (%h).: %m",$time, dest_e_addr_o );
690
                                        $finish;
691
                                end
692
                                if(flit_in_wr && rd_hdr_flg && (rd_des_e_addr[EAw-1 : 0]  != current_e_addr )) begin
693
                                        $display("%t: ERROR: packet with destination %d (code %h) which is sent by source %d (code %h) has been recieved in wrong destination %d (code %h).  %m",$time,dst_id,rd_des_e_addr, src_id,rd_src_e_addr, current_id,current_e_addr);
694
                                        $finish;
695
                                end
696
 
697
                        end else begin
698
                                /* verilator lint_off WIDTH */
699
                                if((CAST_TYPE == "MULTICAST_FULL") || (CAST_TYPE == "MULTICAST_PARTIAL")) begin
700
                                /* verilator lint_on WIDTH */
701
 
702
                                        if(flit_out_wr && hdr_flit && dest_mcast_all_endp1[current_id]  == 1'b1  && SELF_LOOP_EN == "NO") begin
703
                                                $display("%t: ERROR: The self-loop is not enabled in the router while a packet is injected to the NoC with identical source and destination address in endpoint %d. destination nodes:0X%h. : %m",$time, current_id,dest_mcast_all_endp1 );
704
                                                $finish;
705
                                        end
706
                                end
707
                                if(flit_in_wr && rd_hdr_flg && (dest_mcast_all_endp2[current_id] !=1'b1 )) begin
708
                                        $display("%t: ERROR: packet with destination %b  which is sent by source %d (code %h) has been recieved in wrong destination %d (code %h).  %m",$time, dest_mcast_all_endp2, src_id,rd_src_e_addr, current_id,current_e_addr);
709
                                        $finish;
710
                                end
711
 
712
                                //check multicast packet size to be smaller than B & LB
713
                                if(flit_out_wr & hdr_flit & (mcast_dst_num_o>1) & (pck_size >B || pck_size> LB))begin
714
                                        $display("%t: ERROR: A multicast packat is injected to the NoC which has larger size (%d) than router buffer width.  %m",$time, pck_size);
715
                                        $finish;
716
                                end
717
 
718 48 alirezamon
                        end
719
                        if(update) begin
720
                                if (hdr_flit_timestamp<= rd_timestamp) begin
721
                                        $display("%t: ERROR: In destination %d packt which is sent by source %d, the time when header flit is recived (%d) should be larger than the packet timestamp %d.  %m",$time, current_id ,src_e_addr, hdr_flit_timestamp, rd_timestamp);
722
                                        $finish;
723
                                end
724
                                if( clk_counter <= rd_timestamp) begin
725
                                        $display("%t: ERROR: ERROR: In destination %d packt which is sent by source %d,, the current time (%d) should be larger than the packet timestamp %d.  %m",$time, current_id ,src_e_addr, clk_counter, rd_timestamp);
726
                                        $finish;
727
                                end
728
                        end//update
729
                        if(tail_flit & flit_out_wr) begin
730
                                if(wr_timestamp > clk_counter) begin
731
                                        $display("%t: ERROR: In src %d, the current time (%d) should be larger than or equal to the packet timestamp %d.  %m",$time, current_id, clk_counter, wr_timestamp);
732
                                        $finish;
733
                                end
734
                        end
735
 
736
                end
737 54 alirezamon
 
738 48 alirezamon
 
739
                `ifdef CHECK_PCKS_CONTENT
740 54 alirezamon
 
741 48 alirezamon
 
742
                        wire     [PCK_SIZw-1             :   0] rsv_flit_counter;
743
                        reg      [PCK_SIZw-1             :   0] old_flit_counter    [V-1   :   0];
744
                        wire     [PCK_CNTw-1             :   0] rsv_pck_number;
745
                        reg      [PCK_CNTw-1             :   0] old_pck_number  [V-1   :   0];
746
 
747
                        wire [PCK_CNTw+PCK_SIZw-1 : 0] statistics;
748
                        generate
749
                                if(PCK_CNTw+PCK_SIZw > Fw) assign statistics = {{(PCK_CNTw+PCK_SIZw-Fw){1'b0}},flit_in};
750
                        else  assign statistics = flit_in[PCK_CNTw+PCK_SIZw-1   :   0];
751
                        assign {rsv_pck_number,rsv_flit_counter}=statistics;
752
 
753
                        endgenerate
754
 
755
 
756
 
757
                                integer ii;
758 54 alirezamon
 
759
                                always @ (`pronoc_clk_reset_edge )begin
760
                                        if(`pronoc_reset) begin
761 48 alirezamon
                                                for(ii=0;ii
762
                                                        old_flit_counter[ii]<=0;
763
                                                end
764
                                        end else begin
765
                                                if(flit_in_wr)begin
766 54 alirezamon
                                                        if ( flit_in[Fw-1:Fw-2]==2'b10)  begin
767 48 alirezamon
                                                                old_pck_number[rd_vc_bin]<=0;
768
                                                                old_flit_counter[rd_vc_bin]<=0;
769
                                                        end else if ( flit_in[Fw-1:Fw-2]==2'b00)begin
770
                                                                old_pck_number[rd_vc_bin]<=rsv_pck_number;
771
                                                                old_flit_counter[rd_vc_bin]<=rsv_flit_counter;
772
                                                        end
773
 
774 54 alirezamon
                                                end //flit_in_wr
775 48 alirezamon
 
776 54 alirezamon
                                        end    //reset
777
                                end//always
778 48 alirezamon
 
779
 
780
                                always @(posedge clk) begin
781
                                        if(flit_in_wr && (flit_in[Fw-1:Fw-2]==2'b00) && (~reset))begin
782
                                                if( old_flit_counter[rd_vc_bin]!=rsv_flit_counter-1) $display("%t: Error: missmatch flit counter in %m. Expected %d but recieved %d",$time,old_flit_counter[rd_vc_bin]+1,rsv_flit_counter);
783
                                                if( old_pck_number[rd_vc_bin]!=rsv_pck_number && old_pck_number[rd_vc_bin]!=0)   $display("%t: Error: missmatch pck number in %m. expected %d but recieved %d",$time,old_pck_number[rd_vc_bin],rsv_pck_number);
784
 
785
                                        end
786
 
787
                                end
788 54 alirezamon
 
789 48 alirezamon
 
790
                        `endif
791
 
792 54 alirezamon
// synthesis translate_on
793
 
794
 
795
 
796
 
797
 
798 48 alirezamon
//                              `ifdef VERILATOR
799
//                                      logic  endp_is_active   /*verilator public_flat_rd*/ ;
800
//
801
//                                      always @ (*) begin
802
//                                              endp_is_active  = 1'b0;
803
//                                              if (chan_out.flit_chanel.flit_wr) endp_is_active=1'b1;
804
//                                              if (chan_out.flit_chanel.credit > {V{1'b0}} ) endp_is_active=1'b1;
805
//                                              if (chan_out.smart_chanel.requests > {SMART_NUM{1'b0}} ) endp_is_active=1'b1;
806
//                                      end
807
//                              `endif
808
 
809
endmodule
810
 
811
 
812
/*****************************
813
    injection_ratio_ctrl
814
 
815
*****************************/
816
module injection_ratio_ctrl #
817
        (
818
        parameter MAX_PCK_SIZ=10,
819
        parameter MAX_RATIO=100
820
)(
821
        en,
822
        pck_size_in, // average packet size in flit x10
823
        clk,
824
        reset,
825
        inject,// inject one packet
826
        freez,
827
        ratio // 0~100  flit injection ratio
828
);
829
 
830
 
831
        function integer log2;
832
        input integer number; begin
833
                log2=(number <=1) ? 1: 0;
834
                while(2**log2
835
                        log2=log2+1;
836
                end
837
        end
838
        endfunction // log2
839
 
840
 
841
        localparam PCK_SIZw= log2(MAX_PCK_SIZ);
842
 
843
 
844
        localparam CNTw    =   log2(MAX_RATIO);
845
        localparam STATE_INIT=   MAX_PCK_SIZ*MAX_RATIO;
846
        localparam STATEw    =   log2(MAX_PCK_SIZ*2*MAX_RATIO);
847
 
848
        input                       clk,reset,freez,en;
849
        output  reg                 inject;
850
        input   [CNTw-1     :   0]  ratio;
851
        input  [PCK_SIZw-1          :0] pck_size_in;
852
        reg    [PCK_SIZw-1          :0]pck_size;
853
 
854
        wire    [CNTw-1     :   0]  on_clks, off_clks;
855
        reg     [STATEw-1   :   0]  state,next_state;
856
        wire                        input_changed;
857
        reg     [CNTw-1     :   0]  ratio_old;
858
 
859
        always @(posedge clk ) ratio_old<=ratio;
860
 
861
        assign input_changed = (ratio_old!=ratio);
862
 
863
 
864
        assign on_clks = ratio;
865
        assign off_clks =MAX_RATIO-ratio;
866
 
867
        reg [PCK_SIZw-1 :0] flit_counter,next_flit_counter;
868
 
869
 
870
        reg sent,next_sent,next_inject;
871
 
872
 
873
 
874
        always @(*) begin
875
                next_state        =state;
876
                next_flit_counter =flit_counter;
877
                next_sent         =sent;
878
                if(en && ~freez ) begin
879
                        case(sent)
880
                                1'b1: begin
881
                                        /* verilator lint_off WIDTH */
882
                                        next_state          = state +  off_clks;
883
                                        /* verilator lint_on WIDTH */
884
                                        next_flit_counter = (flit_counter >= pck_size-1'b1) ? {PCK_SIZw{1'b0}} : flit_counter +1'b1;
885
                                        next_inject         = (flit_counter=={PCK_SIZw{1'b0}});
886
                                        if (next_flit_counter >= pck_size-1'b1) begin
887
                                                if( next_state  >= STATE_INIT ) next_sent =1'b0;
888
                                        end
889
                                end
890
                                1'b0:begin
891
                                        if( next_state  <  STATE_INIT ) next_sent  = 1'b1;
892
                                        next_inject= 1'b0;
893
                                        /* verilator lint_off WIDTH */
894
                                        next_state = state - on_clks;
895
                                        /* verilator lint_on WIDTH */
896
                                end
897
                        endcase
898
                end else begin
899
                        next_inject= 1'b0;
900
                end
901
        end
902
 
903
 
904
 
905
 
906 54 alirezamon
        always @ (`pronoc_clk_reset_edge )begin
907
                if(`pronoc_reset) begin
908 48 alirezamon
                                state       <=  STATE_INIT;
909
                                inject      <=  1'b0;
910
                                sent        <=  1'b1;
911
                                flit_counter<= 0;
912
                                pck_size<=2;
913
                        end else begin
914
                                if(input_changed)begin
915
                                        state       <=  STATE_INIT;
916
                                        inject      <=  1'b0;
917
                                        sent        <=  1'b1;
918
                                        flit_counter<= 0;
919
                                end
920
 
921
                                if(flit_counter=={PCK_SIZw{1'b0}}) pck_size<=pck_size_in;
922
                                state       <=  next_state;
923
                                if(ratio!={CNTw{1'b0}}) inject      <=  next_inject;
924
                                sent        <=  next_sent;
925
                                flit_counter<=  next_flit_counter;
926
 
927
                        end
928
                end
929
 
930
 
931
endmodule
932
 
933
 
934
 
935
 
936
/*************************************
937
       packet_buffer
938
**************************************/
939
 
940
 
941 54 alirezamon
module packet_gen
942 56 alirezamon
#(
943
        parameter NOC_ID=0,
944
        parameter P = 5
945 48 alirezamon
)(
946
        clk_counter,
947
        pck_wr,
948
        pck_rd,
949
        current_r_addr,
950
        current_e_addr,
951
        pck_number,
952 54 alirezamon
        dest_e_addr_in,
953
        dest_e_addr_o,
954 48 alirezamon
        pck_timestamp,
955
        destport,
956
        buffer_full,
957
        pck_ready,
958
        valid_dst,
959
        pck_size_in,
960
        pck_size_o,
961
        clk,
962
        reset
963
);
964 56 alirezamon
 
965 48 alirezamon
 
966 56 alirezamon
        `NOC_CONF
967 48 alirezamon
 
968
        localparam
969
        PCK_CNTw    =   log2(MAX_PCK_NUM+1),
970 56 alirezamon
        CLK_CNTw    =   log2(MAX_SIM_CLKs+1);
971
 
972 48 alirezamon
 
973
        input  reset,clk, pck_wr, pck_rd;
974
        input  [RAw-1  :0] current_r_addr;
975
        input  [EAw-1 : 0] current_e_addr;
976
        input  [CLK_CNTw-1 :0] clk_counter;
977
        input  [PCK_SIZw-1 :0] pck_size_in;
978 54 alirezamon
        input  [DAw-1  :0] dest_e_addr_in;
979
        output [DAw-1  :0] dest_e_addr_o;
980 48 alirezamon
        input  valid_dst;
981
 
982
        output [PCK_CNTw-1 :0] pck_number;
983
        output [CLK_CNTw-1 :0] pck_timestamp;
984
        output [PCK_SIZw-1 :0] pck_size_o;
985
        output buffer_full,pck_ready;
986
 
987
        output [DSTPw-1    :0] destport;
988
        reg    [PCK_CNTw-1 :0] packet_counter;
989
        wire   buffer_empty;
990
 
991
        assign pck_ready = ~buffer_empty & valid_dst;
992
 
993 54 alirezamon
        generate if(CAST_TYPE == "UNICAST") begin : uni
994 48 alirezamon
        conventional_routing #(
995 56 alirezamon
                .NOC_ID(NOC_ID),
996 48 alirezamon
                .TOPOLOGY(TOPOLOGY),
997
                .ROUTE_NAME(ROUTE_NAME),
998
                .ROUTE_TYPE(ROUTE_TYPE),
999
                .T1(T1),
1000
                .T2(T2),
1001
                .T3(T3),
1002
                .RAw(RAw),
1003
                .EAw(EAw),
1004
                .DSTPw(DSTPw),
1005
                .LOCATED_IN_NI(1)
1006
        )
1007
        routing_module
1008
        (
1009
                .reset(reset),
1010
                .clk(clk),
1011
                .current_r_addr(current_r_addr),
1012 54 alirezamon
                .dest_e_addr(dest_e_addr_o),
1013 48 alirezamon
                .src_e_addr(current_e_addr),
1014
                .destport(destport)
1015
        );
1016 54 alirezamon
        end endgenerate
1017
 
1018 48 alirezamon
        wire timestamp_fifo_nearly_full , timestamp_fifo_full;
1019
        assign buffer_full = (MIN_PCK_SIZE==1) ? timestamp_fifo_nearly_full : timestamp_fifo_full;
1020
 
1021 54 alirezamon
        wire  [DAw-1  :0] tmp1;
1022
        wire  [PCK_SIZw-1 : 0] tmp2;
1023 48 alirezamon
 
1024
        wire recieve_more_than_0;
1025
        fwft_fifo_bram #(
1026 54 alirezamon
                .DATA_WIDTH(CLK_CNTw+PCK_SIZw+DAw),
1027 48 alirezamon
                .MAX_DEPTH(TIMSTMP_FIFO_NUM)
1028
        )
1029
        timestamp_fifo
1030
        (
1031 54 alirezamon
                .din({dest_e_addr_in,pck_size_in,clk_counter}),
1032 48 alirezamon
                .wr_en(pck_wr),
1033
                .rd_en(pck_rd),
1034 54 alirezamon
                .dout({tmp1,tmp2,pck_timestamp}),
1035 48 alirezamon
                .full(timestamp_fifo_full),
1036
                .nearly_full(timestamp_fifo_nearly_full),
1037
                .recieve_more_than_0(recieve_more_than_0),
1038
                .recieve_more_than_1(),
1039
                .reset(reset),
1040
                .clk(clk)
1041
        );
1042
 
1043 54 alirezamon
        //assign dest_e_addr_o = dest_e_addr_in;
1044
 
1045
        assign dest_e_addr_o =tmp1;
1046
        /* verilator lint_off WIDTH */
1047
        assign pck_size_o = (PCK_TYPE == "SINGLE_FLIT" )?   1 : tmp2;
1048
        /* verilator lint_on WIDTH */
1049 48 alirezamon
        assign buffer_empty = ~recieve_more_than_0;
1050
 
1051
                                /*
1052
 
1053
    bram_based_fifo #(
1054
        .Dw(CLK_CNTw),
1055
        .B(TIMSTMP_FIFO_NUM)
1056
    )
1057
    timestamp_fifo
1058
    (
1059
        .din(clk_counter),
1060
        .wr_en(pck_wr),
1061
        .rd_en(pck_rd),
1062
        .dout(pck_timestamp),
1063
        .full(timestamp_fifo_full),
1064
        .nearly_full(timestamp_fifo_nearly_full),
1065
        .empty(buffer_empty),
1066
        .reset(reset),
1067
        .clk(clk)
1068
    );
1069
                                 */
1070
 
1071 54 alirezamon
        always @ (`pronoc_clk_reset_edge )begin
1072
                if(`pronoc_reset) begin
1073
                                packet_counter <= {PCK_CNTw{1'b0}};
1074 48 alirezamon
                        end else begin
1075
                                if(pck_rd) begin
1076
                                        packet_counter <= packet_counter+1'b1;
1077
 
1078
                                end
1079
                        end
1080
                end
1081
 
1082
                assign pck_number = packet_counter;
1083
 
1084
 
1085
endmodule
1086
 
1087
 
1088
 
1089
/********************
1090
 
1091
    distance_gen
1092
 
1093
********************/
1094
 
1095
module distance_gen #(
1096
        parameter TOPOLOGY  = "MESH",
1097
        parameter T1=4,
1098
        parameter T2=4,
1099
        parameter T3=4,
1100
        parameter EAw=2,
1101
        parameter DISTw=4
1102
 
1103
)(
1104
        src_e_addr,
1105
        dest_e_addr,
1106
        distance
1107
);
1108
 
1109
        input [EAw-1 : 0] src_e_addr;
1110
        input [EAw-1 : 0] dest_e_addr;
1111
        output [DISTw-1 : 0]   distance;
1112
 
1113
        generate
1114
        /* verilator lint_off WIDTH */
1115
        if (TOPOLOGY ==    "MESH" || TOPOLOGY ==  "TORUS" || TOPOLOGY == "RING" || TOPOLOGY == "LINE")begin : tori_noc
1116
        /* verilator lint_on WIDTH */
1117
 
1118
                mesh_torus_distance_gen #(
1119
                        .T1(T1),
1120
                        .T2(T2),
1121
                        .T3(T3),
1122
                        .TOPOLOGY(TOPOLOGY),
1123
                        .DISTw(DISTw),
1124
                        .EAw(EAw)
1125
                )
1126
                distance_gen
1127
                (
1128
                        .src_e_addr(src_e_addr),
1129
                        .dest_e_addr(dest_e_addr),
1130
                        .distance(distance)
1131
                );
1132
        /* verilator lint_off WIDTH */
1133
        end else if (TOPOLOGY ==    "FMESH") begin :fmesh
1134
        /* verilator lint_on WIDTH */
1135
                fmesh_distance_gen #(
1136
                        .T1(T1),
1137
                        .T2(T2),
1138
                        .T3(T3),
1139
                        .DISTw(DISTw),
1140
                        .EAw(EAw)
1141
                )
1142
                distance_gen
1143
                (
1144
                        .src_e_addr(src_e_addr),
1145
                        .dest_e_addr(dest_e_addr),
1146
                        .distance(distance)
1147
                );
1148
 
1149
        /* verilator lint_off WIDTH */
1150
        end else if (TOPOLOGY == "FATTREE" || TOPOLOGY == "TREE") begin : fat
1151
        /* verilator lint_on WIDTH */
1152
                fattree_distance_gen #(
1153
                        .K(T1),
1154
                        .L(T2)
1155
                )
1156
                distance_gen
1157
                (
1158
                        .src_addr_encoded(src_e_addr),
1159
                        .dest_addr_encoded(dest_e_addr),
1160
                        .distance(distance)
1161
                );
1162
        end else if (TOPOLOGY == "STAR") begin
1163
 
1164
                                assign distance =1 ;
1165
        end
1166
        endgenerate
1167
 
1168
endmodule
1169
 
1170
 
1171
 
1172
 
1173
 

powered by: WebSVN 2.1.0

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