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 55

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

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

powered by: WebSVN 2.1.0

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