forked from pulp-platform/FlooNoC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
floo_mesh_ruche.sv
183 lines (164 loc) · 7.72 KB
/
floo_mesh_ruche.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Copyright 2022 ETH Zurich and University of Bologna.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51
//
// Michael Rogenmoser <michaero@iis.ee.ethz.ch>
// Tim Fischer <fischeti@iis.ee.ethz.ch>
`include "floo_noc/typedef.svh"
/// A mesh topology with ruche channels and a configurable number of rows and columns
module floo_mesh_ruche
import floo_pkg::*;
#(
parameter int unsigned NumX = 4,
parameter int unsigned NumY = 4,
parameter int unsigned NumVirtChannels = 1,
parameter int unsigned NumPhysChannels = 1,
parameter int unsigned RucheFactor = 2,
parameter int unsigned NumRoutes = 5,
parameter route_algo_e RouteAlgo = IdTable,
parameter type flit_t = logic,
parameter type xy_id_t = logic
) (
input logic clk_i,
input logic rst_ni,
input logic [NumX-1:0][NumY-1:0][NumVirtChannels-1:0] valid_i,
output logic [NumX-1:0][NumY-1:0][NumVirtChannels-1:0] ready_o,
input flit_t [NumX-1:0][NumY-1:0][NumPhysChannels-1:0] data_i,
output logic [NumX-1:0][NumY-1:0][NumVirtChannels-1:0] valid_o,
input logic [NumX-1:0][NumY-1:0][NumVirtChannels-1:0] ready_i,
output flit_t [NumX-1:0][NumY-1:0][NumPhysChannels-1:0] data_o
);
flit_t [NumX-2:0][NumY-1:0][NumPhysChannels-1:0] pos_x_flit;
logic [NumX-2:0][NumY-1:0][NumVirtChannels-1:0] pos_x_ready, pos_x_valid;
flit_t [NumX-2:0][NumY-1:0][NumPhysChannels-1:0] neg_x_flit;
logic [NumX-2:0][NumY-1:0][NumVirtChannels-1:0] neg_x_ready, neg_x_valid;
flit_t [NumX-1:0][NumY-2:0][NumPhysChannels-1:0] pos_y_flit;
logic [NumX-1:0][NumY-2:0][NumVirtChannels-1:0] pos_y_ready, pos_y_valid;
flit_t [NumX-1:0][NumY-2:0][NumPhysChannels-1:0] neg_y_flit;
logic [NumX-1:0][NumY-2:0][NumVirtChannels-1:0] neg_y_ready, neg_y_valid;
flit_t [NumX-2:0][NumY-1:0][NumPhysChannels-1:0] ruche_pos_x_flit;
logic [NumX-2:0][NumY-1:0][NumVirtChannels-1:0] ruche_pos_x_ready, ruche_pos_x_valid;
flit_t [NumX-2:0][NumY-1:0][NumPhysChannels-1:0] ruche_neg_x_flit;
logic [NumX-2:0][NumY-1:0][NumVirtChannels-1:0] ruche_neg_x_ready, ruche_neg_x_valid;
flit_t [NumX-1:0][NumY-2:0][NumPhysChannels-1:0] ruche_pos_y_flit;
logic [NumX-1:0][NumY-2:0][NumVirtChannels-1:0] ruche_pos_y_ready, ruche_pos_y_valid;
flit_t [NumX-1:0][NumY-2:0][NumPhysChannels-1:0] ruche_neg_y_flit;
logic [NumX-1:0][NumY-2:0][NumVirtChannels-1:0] ruche_neg_y_ready, ruche_neg_y_valid;
for (genvar x = 0; x < NumX; x++) begin : gen_x
for (genvar y = 0; y < NumY; y++) begin : gen_y
xy_id_t current_id;
assign current_id = '{x: x, y: y};
flit_t [4:0][NumPhysChannels-1:0] in_flit;
logic [4:0][NumVirtChannels-1:0] in_ready, in_valid;
flit_t [4:0][NumPhysChannels-1:0] out_flit;
logic [4:0][NumVirtChannels-1:0] out_ready, out_valid;
flit_t [RucheWest:RucheNorth][NumPhysChannels-1:0] ruche_in_flit;
logic [RucheWest:RucheNorth][NumVirtChannels-1:0] ruche_in_ready, ruche_in_valid;
flit_t [RucheWest:RucheNorth][NumPhysChannels-1:0] ruche_out_flit;
logic [RucheWest:RucheNorth][NumVirtChannels-1:0] ruche_out_ready, ruche_out_valid;
always_comb begin
in_flit[West:North] = '0;
in_valid[West:North] = '0;
out_ready[West:North] = '0;
in_valid[Eject] = valid_i[x][y];
in_flit[Eject] = data_i[x][y];
ready_o[x][y] = in_ready[Eject];
valid_o[x][y] = out_valid[Eject];
data_o[x][y] = out_flit[Eject];
out_ready[Eject] = ready_i[x][y];
// Y
if (y < NumY-1) begin
in_flit[North] = neg_y_flit[x][y];
in_valid[North] = neg_y_valid[x][y];
neg_y_ready[x][y] = in_ready[North];
pos_y_flit[x][y] = out_flit[North];
pos_y_valid[x][y] = out_valid[North];
out_ready[North] = pos_y_ready[x][y];
end
if (y > 0) begin
in_flit[South] = pos_y_flit[x][y-1];
in_valid[South] = pos_y_valid[x][y-1];
pos_y_ready[x][y-1] = in_ready[South];
neg_y_flit[x][y-1] = out_flit[South];
neg_y_valid[x][y-1] = out_valid[South];
out_ready[South] = neg_y_ready[x][y-1];
end
// Y Rouche
if (y > RucheFactor) begin
ruche_in_flit[RucheSouth] = ruche_pos_y_flit[x][y-RucheFactor];
ruche_in_valid[RucheSouth] = ruche_pos_y_valid[x][y-RucheFactor];
ruche_pos_y_ready[x][y-RucheFactor] = ruche_in_ready[RucheSouth];
ruche_neg_y_flit[x][y-RucheFactor] = ruche_out_flit[RucheSouth];
ruche_neg_y_valid[x][y-RucheFactor] = ruche_out_valid[RucheSouth];
ruche_out_ready[RucheSouth] = ruche_neg_y_ready[x][y-RucheFactor];
end
if (y < NumY-RucheFactor) begin
ruche_in_flit[RucheNorth] = ruche_neg_y_flit[x][y];
ruche_in_valid[RucheNorth] = ruche_neg_y_valid[x][y];
ruche_neg_y_ready[x][y] = ruche_in_ready[RucheNorth];
ruche_pos_y_flit[x][y] = ruche_out_flit[RucheNorth];
ruche_pos_y_valid[x][y] = ruche_out_valid[RucheNorth];
ruche_out_ready[RucheNorth] = ruche_pos_y_ready[x][y];
end
// X
if (x < NumX-1) begin
in_flit[East] = neg_x_flit[x][y];
in_valid[East] = neg_x_valid[x][y];
neg_x_ready[x][y] = in_ready[East];
pos_x_flit[x][y] = out_flit[East];
pos_x_valid[x][y] = out_valid[East];
out_ready[East] = pos_x_ready[x][y];
end
if (x > 0) begin
in_flit[West] = pos_x_flit[x-1][y];
in_valid[West] = pos_x_valid[x-1][y];
pos_x_ready[x-1][y] = in_ready[West];
neg_x_flit[x-1][y] = out_flit[West];
neg_x_valid[x-1][y] = out_valid[West];
out_ready[West] = neg_x_ready[x-1][y];
end
// X Rouche
if (x > RucheFactor) begin
ruche_in_flit[RucheWest] = ruche_pos_x_flit[x-RucheFactor][y];
ruche_in_valid[RucheWest] = ruche_pos_x_valid[x-RucheFactor][y];
ruche_pos_x_ready[x-RucheFactor][y] = ruche_in_ready[RucheWest];
ruche_neg_x_flit[x-RucheFactor][y] = ruche_out_flit[RucheWest];
ruche_neg_x_valid[x-RucheFactor][y] = ruche_out_valid[RucheWest];
ruche_out_ready[RucheWest] = ruche_neg_x_ready[x-RucheFactor][y];
end
if (x < NumX-RucheFactor) begin
ruche_in_flit[RucheEast] = ruche_neg_x_flit[x][y];
ruche_in_valid[RucheEast] = ruche_neg_x_valid[x][y];
ruche_neg_x_ready[x][y] = ruche_in_ready[RucheEast];
ruche_pos_x_flit[x][y] = ruche_out_flit[RucheEast];
ruche_pos_x_valid[x][y] = ruche_out_valid[RucheEast];
ruche_out_ready[RucheEast] = ruche_pos_x_ready[x][y];
end
end
floo_router #(
.NumPhysChannels ( NumPhysChannels ),
.NumVirtChannels ( NumVirtChannels ),
.NumRoutes ( NumRoutes ),
.flit_t ( flit_t ),
.RouteAlgo ( RouteAlgo ),
.ChannelFifoDepth( 2 ),
.IdWidth ( $bits(xy_id_t) ),
.id_t ( xy_id_t ),
.addr_rule_t ( logic ),
.NumAddrRules ( 1 )
) i_floo_router (
.clk_i,
.rst_ni,
.test_enable_i ( 1'b0 ),
.xy_id_i ( current_id ),
.id_route_map_i ( '0 ),
.valid_i ( in_valid ),
.ready_o ( in_ready ),
.data_i ( in_flit ),
.valid_o ( out_valid ),
.ready_i ( out_ready ),
.data_o ( out_flit )
);
end
end
endmodule