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/] [route_mesh.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
`timescale     1ns/1ps
2
 
3
/**********************************************************************
4
**      File:  route_mesh.v
5
**
6
**      Copyright (C) 2014-2017  Alireza Monemi
7
**
8
**      This file is part of ProNoC
9
**
10
**      ProNoC ( stands for Prototype Network-on-chip)  is free software:
11
**      you can redistribute it and/or modify it under the terms of the GNU
12
**      Lesser General Public License as published by the Free Software Foundation,
13
**      either version 2 of the License, or (at your option) any later version.
14
**
15
**      ProNoC is distributed in the hope that it will be useful, but WITHOUT
16
**      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17
**      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
18
**      Public License for more details.
19
**
20
**      You should have received a copy of the GNU Lesser General Public
21
**      License along with ProNoC. If not, see <http:**www.gnu.org/licenses/>.
22
**
23
**
24
**      Description:
25
**      Different routing algorithms (determinstic,partially adaptive and fully adaptive)
26
**      for 2D mesh-based topology
27
**
28
**************************************************************/
29
 
30
 
31
/********************************************
32
                    Deterministic
33
*********************************************/
34
 
35
 
36
    /*****************************************************
37
                    xy_mesh_routing
38
 
39
    *****************************************************/
40
 
41
 
42
 
43
module xy_mesh_routing #(
44
    parameter NX        =    4,
45
    parameter NY        =    3
46
)
47
(
48
    current_x,    // current router x address
49
    current_y,    // current router y address
50
    dest_x,        // destination x address
51
    dest_y,        // destination y address
52
    dstport_encoded    // router output port
53
 
54
);
55
 
56
 
57
    function integer log2;
58
      input integer number; begin
59
         log2=(number <=1) ? 1: 0;
60
         while(2**log2<number) begin
61
            log2=log2+1;
62
         end
63
      end
64
    endfunction // log2 
65
 
66
    localparam  P            =    5;    // router port number is always 5 in a mesh topology
67
 
68
    localparam  Xw            =    log2(NX),
69
                Yw            =    log2(NY),
70
                DSTw          =    P-1;
71
 
72
 
73
 
74
    input  [Xw-1        :0]    current_x;
75
    input  [Yw-1        :0]    current_y;
76
    input  [Xw-1        :0]    dest_x;
77
    input  [Yw-1        :0]    dest_y;
78
    output [DSTw-1      :0]    dstport_encoded;
79
 
80
 
81
    localparam OUT_BIN=0;
82
 
83
    localparam  LOCAL    =    (OUT_BIN==1)?    0    :  1 ,//5'b00001
84
                EAST     =    (OUT_BIN==1)?    1    :  2 ,//5'b00010 
85
                NORTH    =    (OUT_BIN==1)?    2    :  4 ,//5'b00100    
86
                WEST     =    (OUT_BIN==1)?    3    :  8 ,//5'b01000  
87
                SOUTH    =    (OUT_BIN==1)?    4    : 16 ;//5'b10000    
88
 
89
 
90
 
91
 
92
 
93
    reg [P-1 : 0] dstport_one_hot;
94
 
95
 
96
    always@(*)begin
97
            dstport_one_hot    = LOCAL [P-1    :0];
98
            if           (dest_x    > current_x)     dstport_one_hot    = EAST [P-1    :0];
99
            else if      (dest_x    < current_x)     dstport_one_hot    = WEST [P-1    :0];
100
            else begin
101
            if         (dest_y    > current_y)       dstport_one_hot    = SOUTH [P-1   :0];
102
            else if      (dest_y    < current_y)     dstport_one_hot    = NORTH [P-1   :0];
103
            end
104
    end
105
 
106
    mesh_tori_encode_dstport conv(
107
        .dstport_one_hot(dstport_one_hot),
108
        .dstport_encoded(dstport_encoded)
109
    );
110
 
111
 
112
endmodule
113
 
114
/********************************************
115
                    Partial adaptive
116
The west-first routing algorithm does not allow turns from north to west or from south to west.
117
The north last routing algorithm does not allow turns from north to east or from north to west.
118
The negetive fist routing algorithm does net allow turns from north to west or from east to south.
119
 
120
 
121
*********************************************/
122
 
123
/************************************
124
 
125
                west-first
126
 
127
*************************************/
128
module west_first_routing #(
129
        parameter NX    =   4,
130
        parameter NY    =   4
131
    )
132
    (
133
        current_x,  // current router x address
134
        current_y,  // current router y address
135
        dest_x,     // destination x address
136
        dest_y,     // destination y address
137
        destport    // router output port
138
 
139
    );
140
 
141
 
142
    function integer log2;
143
      input integer number; begin
144
         log2=(number <=1) ? 1: 0;
145
         while(2**log2<number) begin
146
            log2=log2+1;
147
         end
148
      end
149
    endfunction // log2 
150
 
151
    localparam  P   =   5,
152
                P_1 =    P-1,
153
                Xw  =   log2(NX),
154
                Yw  =   log2(NY);
155
 
156
    input  [Xw-1        :0] current_x;
157
    input  [Yw-1        :0] current_y;
158
    input  [Xw-1        :0] dest_x;
159
    input  [Yw-1        :0] dest_y;
160
    output [P_1-1       :0] destport;
161
 
162
    localparam  LOCAL=   3'd0,
163
                EAST =   3'd1,
164
                NORTH=   3'd2,
165
                WEST =   3'd3,
166
                SOUTH=   3'd4;
167
 
168
 
169
    wire x_plus,x_min,y_plus,y_min,same_x,same_y;
170
 
171
    mesh_dir #(
172
        .NX(NX),
173
        .NY(NY)
174
    )
175
    dir(
176
        .current_x(current_x),
177
        .current_y(current_y),
178
        .dest_x(dest_x),
179
        .dest_y(dest_y),
180
        .x_plus(x_plus),
181
        .x_min(x_min),
182
        .y_plus(y_plus),
183
        .y_min(y_min),
184
        .same_x(same_x),
185
        .same_y(same_y)
186
 
187
    );
188
 
189
    reg [4  :   0]  possible_out_port;
190
 
191
    //The west-first routing algorithm does not allow turns from north to west or from south to west. 
192
    always @(*)begin
193
        possible_out_port = 5'd0;
194
        if(same_x && same_y) begin
195
            possible_out_port [LOCAL]=1'b1;
196
        end
197
        else if       (x_min) begin
198
            possible_out_port [WEST]    = 1'b1;
199
        end
200
        else if (x_plus && y_min) begin
201
            possible_out_port [EAST]=1'b1;
202
            possible_out_port [NORTH]=1'b1;
203
        end
204
        else if(x_plus && y_plus) begin
205
            possible_out_port [EAST]=1'b1;
206
            possible_out_port [SOUTH]=1'b1;
207
        end
208
        else if( x_plus && same_y) begin
209
            possible_out_port [EAST]=1'b1;
210
        end
211
        else if(same_x && y_min) begin
212
            possible_out_port [NORTH]=1'b1;
213
        end
214
        else if(same_x && y_plus) begin
215
            possible_out_port [SOUTH]=1'b1;
216
        end
217
    end
218
 
219
    // code the destination port
220
    wire x,y,a,b;
221
    assign x = x_plus;
222
    assign y = y_min;
223
    assign a = possible_out_port[EAST] | possible_out_port[WEST];
224
    assign b = possible_out_port[NORTH]| possible_out_port[SOUTH];
225
    assign destport = {x,y,a,b};
226
endmodule
227
 
228
 
229
/************************************
230
 
231
 
232
             north-last
233
 
234
 
235
 *************************************/
236
 
237
 
238
module north_last_routing #(
239
        parameter NX    =   4,
240
        parameter NY    =   4
241
    )
242
    (
243
        current_x,  // current router x address
244
        current_y,  // current router y address
245
        dest_x,     // destination x address
246
        dest_y,     // destination y address
247
        destport    // router output port
248
 
249
    );
250
 
251
 
252
    function integer log2;
253
      input integer number; begin
254
         log2=(number <=1) ? 1: 0;
255
         while(2**log2<number) begin
256
            log2=log2+1;
257
         end
258
      end
259
    endfunction // log2 
260
 
261
    localparam  P   =   5,
262
                P_1 =    P-1,
263
                Xw  =   log2(NX),
264
                Yw  =   log2(NY);
265
 
266
    input  [Xw-1        :0] current_x;
267
    input  [Yw-1        :0] current_y;
268
    input  [Xw-1        :0] dest_x;
269
    input  [Yw-1        :0] dest_y;
270
    output [P_1-1       :0] destport;
271
 
272
    localparam  LOCAL=   3'd0,
273
                EAST =   3'd1,
274
                NORTH=   3'd2,
275
                WEST =   3'd3,
276
                SOUTH=   3'd4;
277
 
278
 
279
    wire x_plus,x_min,y_plus,y_min,same_x,same_y;
280
 
281
    mesh_dir #(
282
        .NX(NX),
283
        .NY(NY)
284
    )
285
    dir(
286
        .current_x(current_x),
287
        .current_y(current_y),
288
        .dest_x(dest_x),
289
        .dest_y(dest_y),
290
        .x_plus(x_plus),
291
        .x_min(x_min),
292
        .y_plus(y_plus),
293
        .y_min(y_min),
294
        .same_x(same_x),
295
        .same_y(same_y)
296
 
297
    );
298
 
299
    reg [4  :   0]  possible_out_port;
300
 
301
   // north last routing algorithm does not allow turns from north to east or from north to west.
302
 
303
    always @(*)begin
304
        possible_out_port   = 5'd0;
305
        if(same_x &&  same_y) begin
306
            possible_out_port [LOCAL]=1'b1;
307
        end
308
        else if (x_min && y_min) begin
309
            possible_out_port   [WEST]= 1'b1;
310
            //possible_out_port   [NORTH]= 1'b1;
311
        end
312
        else if (x_min && y_plus) begin
313
            possible_out_port   [WEST]= 1'b1;
314
            possible_out_port   [SOUTH]= 1'b1;
315
        end
316
        else if (x_plus &&  y_min) begin
317
            possible_out_port   [EAST]= 1'b1;
318
            //possible_out_port   [NORTH]= 1'b1;            
319
        end
320
        else if (x_plus &&  y_plus) begin
321
            possible_out_port   [EAST]= 1'b1;
322
            possible_out_port   [SOUTH]= 1'b1;
323
        end
324
        else if (x_min && same_y) begin
325
            possible_out_port   [WEST]= 1'b1;
326
        end
327
        else if (x_plus && same_y) begin
328
            possible_out_port   [EAST]= 1'b1;
329
        end
330
        else if (same_x && y_min) begin
331
            possible_out_port   [NORTH]= 1'b1;
332
        end
333
        else if (same_x && y_plus) begin
334
            possible_out_port   [SOUTH]= 1'b1;
335
        end
336
    end
337
 
338
 
339
    // code the destination port
340
    wire x,y,a,b;
341
    assign x = x_plus;
342
    assign y = y_min;
343
    assign a = possible_out_port[EAST] | possible_out_port[WEST];
344
    assign b = possible_out_port[NORTH]| possible_out_port[SOUTH];
345
    assign destport = {x,y,a,b};
346
endmodule
347
 
348
 
349
/****************************
350
 
351
 
352
        negetive-first
353
 
354
 
355
******************************/
356
 
357
 
358
module negetive_first_routing #(
359
        parameter NX    =   4,
360
        parameter NY    =   4
361
    )
362
    (
363
        current_x,  // current router x address
364
        current_y,  // current router y address
365
        dest_x,     // destination x address
366
        dest_y,     // destination y address
367
        destport    // router output port
368
 
369
    );
370
 
371
 
372
    function integer log2;
373
      input integer number; begin
374
         log2=(number <=1) ? 1: 0;
375
         while(2**log2<number) begin
376
            log2=log2+1;
377
         end
378
      end
379
    endfunction // log2 
380
 
381
    localparam  P   =   5,
382
                P_1 =    P-1,
383
                Xw  =   log2(NX),
384
                Yw  =   log2(NY);
385
 
386
    input  [Xw-1        :0] current_x;
387
    input  [Yw-1        :0] current_y;
388
    input  [Xw-1        :0] dest_x;
389
    input  [Yw-1        :0] dest_y;
390
    output [P_1-1       :0] destport;
391
 
392
    localparam  LOCAL=   3'd0,
393
                EAST =   3'd1,
394
                NORTH=   3'd2,
395
                WEST =   3'd3,
396
                SOUTH=   3'd4;
397
 
398
 
399
    wire x_plus,x_min,y_plus,y_min,same_x,same_y;
400
 
401
    mesh_dir #(
402
        .NX(NX),
403
        .NY(NY)
404
    )
405
    dir(
406
        .current_x(current_x),
407
        .current_y(current_y),
408
        .dest_x(dest_x),
409
        .dest_y(dest_y),
410
        .x_plus(x_plus),
411
        .x_min(x_min),
412
        .y_plus(y_plus),
413
        .y_min(y_min),
414
        .same_x(same_x),
415
        .same_y(same_y)
416
 
417
    );
418
 
419
    reg [4  :   0]  possible_out_port;
420
 
421
 // The negetive fist routing algorithm does net allow turns from north to west or from east to south.
422
 
423
    always @(*)begin
424
        possible_out_port   = 5'd0;
425
        if(same_x &&  same_y) begin
426
            possible_out_port [LOCAL]=1'b1;
427
        end
428
        else if (x_min && y_min) begin
429
            possible_out_port   [WEST]= 1'b1;
430
            //possible_out_port   [NORTH]= 1'b1;
431
        end
432
        else if (x_min && y_plus) begin
433
            possible_out_port   [WEST]= 1'b1;
434
            possible_out_port   [SOUTH]= 1'b1;
435
        end
436
        else if (x_plus &&  y_min) begin
437
            possible_out_port   [EAST]= 1'b1;
438
            possible_out_port   [NORTH]= 1'b1;
439
        end
440
        else if (x_plus &&  y_plus) begin
441
            //possible_out_port   [EAST]= 1'b1;
442
            possible_out_port   [SOUTH]= 1'b1;
443
        end
444
        else if (x_min && same_y) begin
445
            possible_out_port   [WEST]= 1'b1;
446
        end
447
        else if (x_plus && same_y) begin
448
            possible_out_port   [EAST]= 1'b1;
449
        end
450
        else if (same_x && y_min) begin
451
            possible_out_port   [NORTH]= 1'b1;
452
        end
453
        else if (same_x && y_plus) begin
454
            possible_out_port   [SOUTH]= 1'b1;
455
        end
456
    end
457
 
458
    // code the destination port
459
    wire x,y,a,b;
460
    assign x = x_plus;
461
    assign y = y_min;
462
    assign a = possible_out_port[EAST] | possible_out_port[WEST];
463
    assign b = possible_out_port[NORTH]| possible_out_port[SOUTH];
464
    assign destport = {x,y,a,b};
465
endmodule
466
 
467
 
468
/****************************************
469
 
470
            odd_even
471
 
472
***************************************/
473
 
474
 
475
 
476
 
477
module odd_even_routing #(
478
        parameter NX        =    4,
479
        parameter NY        =    4,
480
        parameter LOCATED_IN_NI        =    1 // 1: the router locaed inside ni                     
481
                                                  // 0: the routing module located inside router
482
    )
483
    (
484
        current_x,    // current router x address
485
        current_y,    // current router y address
486
        dest_x,        // destination x address
487
        dest_y,        // destination y address
488
        destport    // router output port
489
 
490
    );
491
 
492
 
493
 
494
 
495
    function integer log2;
496
      input integer number; begin
497
         log2=(number <=1) ? 1: 0;
498
         while(2**log2<number) begin
499
            log2=log2+1;
500
         end
501
      end
502
    endfunction // log2 
503
 
504
    localparam     P    =    5,
505
                P_1 =   P-1,
506
                Xw    =    log2(NX),
507
                Yw    =    log2(NY);
508
 
509
    input  [Xw-1        :0]    current_x;
510
    input  [Yw-1        :0]    current_y;
511
    input  [Xw-1        :0]    dest_x;
512
    input  [Yw-1        :0]    dest_y;
513
    output [P_1-1         :0]    destport;
514
 
515
 
516
 
517
    localparam LOCAL   =        3'd0;
518
    localparam EAST       =        3'd1;
519
    localparam NORTH   =        3'd2;
520
    localparam WEST       =        3'd3;
521
    localparam SOUTH   =        3'd4;
522
 
523
    wire signed [Xw        :0] xc;//current 
524
    wire signed [Xw        :0] xd;//destination
525
    wire signed [Yw        :0] yc;//current 
526
    wire signed [Yw        :0] yd;//destination
527
    wire signed [Xw        :0] xdiff;
528
    wire signed [Yw        :0] ydiff;
529
 
530
 
531
    assign     xc     ={1'b0, current_x [Xw-1        :0]};
532
    assign     yc     ={1'b0, current_y [Yw-1        :0]};
533
    assign    xd    ={1'b0, dest_x};
534
    assign    yd     ={1'b0, dest_y};
535
    assign     xdiff    = xd-xc;
536
    assign    ydiff    = yd-yc;
537
 
538
    reg [P-1    :    0]    possible_out_port;
539
 
540
 
541
 
542
    always @(*)begin
543
        possible_out_port = 5'd0;
544
        if (xdiff == 0 && ydiff == 0) begin
545
                possible_out_port [LOCAL]=1'b1;
546
        end
547
        else if(xdiff ==0) begin //currently in the same column as destination
548
            if( ydiff<0) begin
549
                possible_out_port [NORTH]=1'b1;
550
            end else begin
551
                possible_out_port [SOUTH]=1'b1;
552
            end
553
        end
554
        else if(ydiff == 0) begin //currently in the same row as destination
555
            if( xdiff<0) begin
556
                possible_out_port [WEST]=1'b1;
557
            end else begin
558
                possible_out_port [EAST]=1'b1;
559
            end
560
        end
561
        else begin
562
            if(xdiff>0)begin //east_bound
563
                if(ydiff == 0) begin
564
                    possible_out_port [EAST]=1'b1;
565
                end
566
                else begin
567
                    if(current_x[0] || (LOCATED_IN_NI    == 1)) begin
568
                        if( ydiff<0) begin
569
                            possible_out_port [NORTH]=1'b1;
570
                        end else begin
571
                            possible_out_port [SOUTH]=1'b1;
572
                        end
573
                    end
574
                    if(dest_x[0] || xdiff!=1) begin // //odd destination column or >= 2 columns to destination
575
                        possible_out_port [EAST]=1'b1;
576
                    end
577
                end
578
            end
579
            else begin // west_bound
580
                possible_out_port [WEST]    = 1'b1;
581
                if(current_x[0]== 1'b0) begin //even column
582
                    if( ydiff<0) begin
583
                        possible_out_port [NORTH]=1'b1;
584
                    end else begin
585
                        possible_out_port [SOUTH]=1'b1;
586
                    end
587
                end
588
            end
589
        end
590
        end
591
 
592
 
593
 
594
    // code the destination port
595
    wire x,y,a,b;
596
    assign x = (xdiff > 0);
597
    assign y = (ydiff < 0);
598
    assign a = possible_out_port[EAST] | possible_out_port[WEST];
599
    assign b = possible_out_port[NORTH]| possible_out_port[SOUTH];
600
    assign destport = {x,y,a,b};
601
 
602
 
603
 
604
 
605
endmodule
606
 
607
/***********************************
608
        fully adaptive
609
 
610
***********************************/
611
 
612
 
613
    /************************************
614
 
615
        Duato’s Fully Adaptive
616
The packet which can travel in both x & y dimension can not use the reserved VC in y axies
617
    *************************************/
618
 
619
 
620
 
621
module duato_mesh_routing #(
622
        parameter NX    =    4,
623
        parameter NY    =    4
624
    )
625
    (
626
        current_x,    // current router x address
627
        current_y,    // current router y address
628
        dest_x,        // destination x address
629
        dest_y,        // destination y address
630
        destport    // router output port
631
 
632
    );
633
 
634
 
635
 
636
 
637
    function integer log2;
638
      input integer number; begin
639
         log2=(number <=1) ? 1: 0;
640
         while(2**log2<number) begin
641
            log2=log2+1;
642
         end
643
      end
644
    endfunction // log2 
645
 
646
 
647
    localparam     P    =    5,
648
                P_1 =   P-1,
649
                Xw    =    log2(NX),
650
                Yw    =    log2(NY);
651
 
652
    input  [Xw-1        :0]    current_x;
653
    input  [Yw-1        :0]    current_y;
654
    input  [Xw-1        :0]    dest_x;
655
    input  [Yw-1        :0]    dest_y;
656
    output [P_1-1        :0]    destport;
657
 
658
 
659
 
660
    localparam  LOCAL=   3'd0,
661
                EAST =   3'd1,
662
                NORTH=   3'd2,
663
                WEST =   3'd3,
664
                SOUTH=   3'd4;
665
 
666
 
667
    wire x_plus,x_min,y_plus,y_min,same_x,same_y;
668
 
669
    mesh_dir #(
670
        .NX(NX),
671
        .NY(NY)
672
    )
673
    dir(
674
        .current_x(current_x),
675
        .current_y(current_y),
676
        .dest_x(dest_x),
677
        .dest_y(dest_y),
678
        .x_plus(x_plus),
679
        .x_min(x_min),
680
        .y_plus(y_plus),
681
        .y_min(y_min),
682
        .same_x(same_x),
683
        .same_y(same_y)
684
 
685
    );
686
 
687
 
688
    reg [P-1    :    0]    possible_out_port;
689
 
690
    always @(*)begin
691
        possible_out_port       = 5'd0;
692
        if(same_x &&  same_y) begin
693
            possible_out_port [LOCAL]=1'b1;
694
        end
695
        else if (x_min && y_min) begin
696
            possible_out_port   [WEST]= 1'b1;
697
            possible_out_port   [NORTH]= 1'b1;
698
        end
699
        else if (x_min && y_plus) begin
700
            possible_out_port   [WEST]= 1'b1;
701
            possible_out_port   [SOUTH]= 1'b1;
702
        end
703
        else if (x_plus &&  y_min) begin
704
            possible_out_port   [EAST]= 1'b1;
705
            possible_out_port   [NORTH]= 1'b1;
706
        end
707
        else if (x_plus &&  y_plus) begin
708
            possible_out_port   [EAST]= 1'b1;
709
            possible_out_port   [SOUTH]= 1'b1;
710
        end
711
        else if (x_min && same_y) begin
712
            possible_out_port   [WEST]= 1'b1;
713
        end
714
        else if (x_plus && same_y) begin
715
            possible_out_port   [EAST]= 1'b1;
716
        end
717
        else if (same_x && y_min) begin
718
            possible_out_port   [NORTH]= 1'b1;
719
        end
720
        else if (same_x && y_plus) begin
721
            possible_out_port   [SOUTH]= 1'b1;
722
        end
723
    end
724
 
725
 
726
    // code the destination port
727
    wire   x,y,a,b;
728
    assign x = x_plus;
729
    assign y = y_min;
730
    assign a = possible_out_port[EAST] | possible_out_port[WEST];
731
    assign b = possible_out_port[NORTH]| possible_out_port[SOUTH];
732
    assign destport = {x,y,a,b};
733
 
734
 
735
 
736
endmodule
737
 
738
 
739
 
740
 
741
 
742
module mesh_dir #(
743
    parameter NX   =    4,
744
    parameter NY   =    4
745
)(
746
    current_x,
747
    current_y,
748
    dest_x,
749
    dest_y,
750
    x_plus,
751
    x_min,
752
    y_plus,
753
    y_min,
754
    same_x,
755
    same_y
756
);
757
 
758
 
759
    function integer log2;
760
      input integer number; begin
761
         log2=(number <=1) ? 1: 0;
762
         while(2**log2<number) begin
763
            log2=log2+1;
764
         end
765
      end
766
    endfunction // log2 
767
 
768
    localparam  Xw          =   log2(NX),
769
                Yw          =   log2(NY);
770
 
771
    output x_plus;
772
    output x_min;
773
    output y_plus;
774
    output y_min;
775
    output same_x,same_y;
776
 
777
    input   [Xw-1       :   0] current_x;
778
    input   [Yw-1       :   0] current_y;
779
    input   [Xw-1       :   0] dest_x;
780
    input   [Yw-1       :   0] dest_y;
781
 
782
 
783
 
784
    assign same_x = (current_x == dest_x);
785
    assign same_y = (current_y == dest_y);
786
    assign x_plus = (dest_x  > current_x);
787
    assign x_min  = (dest_x  < current_x);
788
    assign y_plus = (dest_y  > current_y);
789
    assign y_min  = (dest_y  < current_y);
790
 
791
 
792
 
793
endmodule
794
 
795
 
796
 
797
 
798
module mesh_tori_encode_dstport (
799
    dstport_one_hot,
800
    dstport_encoded
801
);
802
 
803
    input  [4 : 0] dstport_one_hot;
804
    output [3 : 0] dstport_encoded;
805
 
806
 
807
     localparam
808
        //LOCAL=   3'd0,  
809
        EAST =   3'd1,
810
        NORTH=   3'd2,
811
        WEST =   3'd3,
812
        SOUTH=   3'd4;
813
 
814
    /************************
815
        destination-port_in
816
            x:  1 EAST, 0 WEST
817
            y:  1 NORTH, 0 SOUTH
818
            ab: 00 : LOCAL, 10: xdir, 01: ydir, 11 x&y dir
819
    *******************/
820
// code the destination port
821
    wire   x,y,a,b;
822
    assign x = dstport_one_hot[EAST];
823
    assign y = dstport_one_hot[NORTH];
824
    assign a = dstport_one_hot[EAST] | dstport_one_hot[WEST];
825
    assign b = dstport_one_hot[NORTH]| dstport_one_hot[SOUTH];
826
    assign dstport_encoded = {x,y,a,b};
827
 
828
endmodule
829
 
830
 
831
 
832
 

powered by: WebSVN 2.1.0

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