Skip to content

Commit 1aa9065

Browse files
committed
hw: Fix reduction routing logic and add comments to document code
1 parent 0796e3c commit 1aa9065

7 files changed

+32
-9
lines changed

hw/floo_nw_chimney.sv

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,8 @@ module floo_nw_chimney #(
236236
// Routing
237237
dst_t [NumNWAxiChannels-1:0] dst_id;
238238
dst_t narrow_aw_id_q, wide_aw_id_q;
239-
id_t [NumNWAxiChannels-1:0] mask;
240239
id_t narrow_aw_mask_q, wide_aw_mask_q;
241-
route_t [NumNWAxiChannels-1:0] route_out;
242240
id_t [NumNWAxiChannels-1:0] mcast_mask;
243-
id_t axi_aw_mask_q;
244241
id_t [NumNWAxiChannels-1:0] id_out;
245242
id_t [NumNWAxiChannels-1:0] mask_id;
246243

@@ -885,9 +882,9 @@ module floo_nw_chimney #(
885882
assign mcast_mask[WideR] = wide_ar_buf_hdr_out.hdr.mask;
886883
assign mcast_mask[WideB] = wide_aw_buf_hdr_out.hdr.mask;
887884

888-
`FFL(narrow_aw_mask_q, mask[NarrowAw], axi_narrow_aw_queue_valid_out &&
885+
`FFL(narrow_aw_mask_q, mcast_mask[NarrowAw], axi_narrow_aw_queue_valid_out &&
889886
axi_narrow_aw_queue_ready_in, '0)
890-
`FFL(wide_aw_mask_q, mask[WideAw], axi_wide_aw_queue_valid_out &&
887+
`FFL(wide_aw_mask_q, mcast_mask[WideAw], axi_wide_aw_queue_valid_out &&
891888
axi_wide_aw_queue_ready_in, '0)
892889

893890
end else begin: gen_no_mcast_mask

hw/floo_nw_router.sv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ module floo_nw_router #(
172172
rsvd: '0
173173
});
174174

175+
// Enable reduction for the B response.
176+
// Disable multicast for the B response.
175177
floo_router #(
176178
.NumInput ( NumInputs ),
177179
.NumOutput ( NumOutputs ),

hw/floo_output_arbiter.sv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// Author: Chen Wu <[email protected]>
66

7+
`include "common_cells/assertions.svh"
8+
79
module floo_output_arbiter import floo_pkg::*;
810
#(
911
/// Number of input ports
@@ -96,4 +98,7 @@ module floo_output_arbiter import floo_pkg::*;
9698

9799
assign ready_o = (reduce_valid_out)? reduce_ready_out : unicast_ready_out;
98100

101+
// Cannot have an output valid without at least one input valid
102+
`ASSERT(ValidOutInvalidIn, valid_o |-> |valid_i)
103+
99104
endmodule

hw/floo_reduction_arbiter.sv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module floo_reduction_arbiter import floo_pkg::*;
1111
/// Type definitions
1212
parameter type flit_t = logic,
1313
parameter type payload_t = logic,
14+
// Masks used to select which bits of the payload are part of the response,
15+
// allowing extraction of relevant bits and detection of any participant errors.
1416
parameter payload_t NarrowRspMask = '0,
1517
parameter payload_t WideRspMask = '0,
1618
parameter type id_t = logic
@@ -67,7 +69,8 @@ module floo_reduction_arbiter import floo_pkg::*;
6769
// We check every input port from which we expect a response
6870
for (int i = 0; i < NumRoutes; i++) begin
6971
if(in_route_mask[i]) begin
70-
// For every bit that is set in the mask, we assemble the response
72+
// Select only the bits of the payload that are part of the response
73+
// and check if at least one of the participants sent an error.
7174
automatic int j = 0;
7275
for (int k = 0; k < $bits(ReduceMask); k++) begin
7376
if (ReduceMask[k]) begin
@@ -76,6 +79,7 @@ module floo_reduction_arbiter import floo_pkg::*;
7679
end
7780
end
7881
// If one of the responses is an error, we return an error
82+
// otherwise we return the first response
7983
if(resp == axi_pkg::RESP_SLVERR) begin
8084
data_o = data_i[i];
8185
break;

hw/floo_reduction_sync.sv

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ module floo_reduction_sync import floo_pkg::*;
2222
);
2323

2424
logic [NumRoutes-1:0] compare_same, same_and_valid;
25+
logic all_reduction_srcs_valid;
2526

26-
// Compute the mask of expected input ports to reduce from
27+
// Compute the input mask based on the selected input port's destination and mask fields.
28+
// This determines which input ports are expected to participate in the reduction.
2729
floo_route_xymask #(
2830
.NumRoutes ( NumRoutes ),
2931
.flit_t ( flit_t ),
@@ -39,11 +41,18 @@ module floo_reduction_sync import floo_pkg::*;
3941
// Compare whether the `mask` and `dst_id` are equal to the selected input port
4042
assign compare_same[in] = ((data_i[in].hdr.mask == data_i[sel_i].hdr.mask) &&
4143
(data_i[in].hdr.dst_id == data_i[sel_i].hdr.dst_id));
42-
// TODO(fischeti): Check with Chen what is done here
44+
45+
// Determine if this input should be considered valid for the reduction:
46+
// If we are at the dst node and the port is the local one, we don’t wait for a
47+
// response/reduction since it will stay locally [NoLoopBack].
4348
assign same_and_valid[in] = (data_i[sel_i].hdr.dst_id == xy_id_i && in == Eject) ||
4449
(compare_same[in] & valid_i[in]);
4550
end
4651

47-
assign valid_o = (in_route_mask_o == '0)? 1'b0 : &(same_and_valid | ~in_route_mask_o);
52+
// Reduction is valid only if all expected inputs [in_route_mask_o] are valid.
53+
// Inputs not involved in the reduction are ignored [~(in_route_mask_o)].
54+
assign all_reduction_srcs_valid = &(same_and_valid | ~in_route_mask_o);
4855

56+
// To have a valid output at least one input must be valid.
57+
assign valid_o = (in_route_mask_o == '0)? 1'b0 : (|valid_i & all_reduction_srcs_valid);
4958
endmodule

hw/floo_router.sv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ module floo_router
161161
assign in_ready[in][v] = |(masked_all_ready[in][v] & route_mask[in][v]);
162162
end else begin : gen_multicast
163163
// TODO(fischeti): Clarify with Chen
164+
// Logic to fork the multicast packet into multiple ports
164165
assign acc_masked_ready_d[in][v] = (in_ready[in][v]) ? '0 :
165166
(acc_masked_ready_q[in][v] | masked_all_ready[in][v]);
166167
assign current_accumulated[in][v] = acc_masked_ready_q[in][v] | masked_all_ready[in][v];
@@ -197,6 +198,8 @@ module floo_router
197198
.data_o ( out_data [out][v] )
198199
);
199200
end else begin : gen_red_arb
201+
// Arbiter to be instantiated for reduction operations.
202+
// Repsonses from a multicast request are also treated as reductions.
200203
floo_output_arbiter #(
201204
.NumRoutes ( NumInput ),
202205
.flit_t ( flit_t ),

hw/floo_wormhole_arbiter.sv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Michael Rogenmoser <[email protected]>
66

77
`include "common_cells/registers.svh"
8+
`include "common_cells/assertions.svh"
89

910
/// A wormhole arbiter
1011
module floo_wormhole_arbiter import floo_pkg::*;
@@ -75,4 +76,6 @@ module floo_wormhole_arbiter import floo_pkg::*;
7576
`FF(valid_q, valid_d, '0)
7677
`FF(last_q, last_out & ready_i, '0)
7778

79+
`ASSERT(InvalidCreation, valid_o |-> |valid_i)
80+
7881
endmodule

0 commit comments

Comments
 (0)