From c415fc6a42a37acc01343c412461be80aa2f81d0 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Fri, 12 Aug 2022 09:53:31 +0200 Subject: [PATCH] Add stream_join_dynamic --- Bender.yml | 1 + src/stream_join.sv | 20 ++++++++-------- src/stream_join_dynamic.sv | 47 ++++++++++++++++++++++++++++++++++++++ src_files.yml | 1 + 4 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 src/stream_join_dynamic.sv diff --git a/Bender.yml b/Bender.yml index ba296c10..c35cdfae 100644 --- a/Bender.yml +++ b/Bender.yml @@ -54,6 +54,7 @@ sources: - src/stream_fork.sv - src/stream_intf.sv - src/stream_join.sv + - src/stream_join_dynamic.sv - src/stream_mux.sv - src/stream_throttle.sv - src/lossy_valid_to_stream.sv diff --git a/src/stream_join.sv b/src/stream_join.sv index 2f210bc7..6e19916f 100644 --- a/src/stream_join.sv +++ b/src/stream_join.sv @@ -28,16 +28,14 @@ module stream_join #( input logic oup_ready_i ); - assign oup_valid_o = (&inp_valid_i); - for (genvar i = 0; i < N_INP; i++) begin : gen_inp_ready - assign inp_ready_o[i] = oup_valid_o & oup_ready_i; - end + stream_join_dynamic #( + .N_INP(N_INP) + ) i_stream_join_dynamic ( + .inp_valid_i(inp_valid_i), + .inp_ready_o(inp_ready_o), + .sel_i ({N_INP{1'b1}}), + .oup_valid_o(oup_valid_o), + .oup_ready_i(oup_ready_i) + ); -// pragma translate_off -`ifndef VERILATOR - initial begin: p_assertions - assert (N_INP >= 1) else $fatal(1, "N_INP must be at least 1!"); - end -`endif -// pragma translate_on endmodule diff --git a/src/stream_join_dynamic.sv b/src/stream_join_dynamic.sv new file mode 100644 index 00000000..e3c22b83 --- /dev/null +++ b/src/stream_join_dynamic.sv @@ -0,0 +1,47 @@ +// Copyright 2020 ETH Zurich and University of Bologna. +// Copyright and related rights are licensed under the Solderpad Hardware +// License, Version 0.51 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law +// or agreed to in writing, software, hardware and materials distributed under +// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +// Authors: +// - Luca Colagrande + +// Stream join dynamic: Joins a parametrizable number of input streams (i.e. valid-ready +// handshaking with dependency rules as in AXI4) to a single output stream. The subset of streams +// to join can be configured dynamically via `sel_i`. The output handshake happens only after +// there has been a handshake. The data channel flows outside of this module. +module stream_join_dynamic #( + /// Number of input streams + parameter int unsigned N_INP = 32'd0 // Synopsys DC requires a default value for parameters. +) ( + /// Input streams valid handshakes + input logic [N_INP-1:0] inp_valid_i, + /// Input streams ready handshakes + output logic [N_INP-1:0] inp_ready_o, + /// Selection mask for the output handshake + input logic [N_INP-1:0] sel_i, + /// Output stream valid handshake + output logic oup_valid_o, + /// Output stream ready handshake + input logic oup_ready_i +); + + // Corner case when `sel_i` is all 0s should not generate valid + assign oup_valid_o = &(inp_valid_i | ~sel_i) && |sel_i; + for (genvar i = 0; i < N_INP; i++) begin : gen_inp_ready + assign inp_ready_o[i] = oup_valid_o & oup_ready_i; + end + +// pragma translate_off +`ifndef VERILATOR + initial begin: p_assertions + assert (N_INP >= 1) else $fatal(1, "N_INP must be at least 1!"); + end +`endif +// pragma translate_on +endmodule diff --git a/src_files.yml b/src_files.yml index 64204a50..b3741b61 100644 --- a/src_files.yml +++ b/src_files.yml @@ -37,6 +37,7 @@ common_cells_all: - src/stream_fork.sv - src/stream_intf.sv - src/stream_join.sv + - src/stream_join_dynamic.sv - src/stream_mux.sv - src/stream_throttle.sv - src/sub_per_hash.sv