-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathstream_fork_dynamic.sv
More file actions
93 lines (85 loc) · 3.19 KB
/
stream_fork_dynamic.sv
File metadata and controls
93 lines (85 loc) · 3.19 KB
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
// 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:
// - Andreas Kurth <[email protected]>
`include "common_cells/assertions.svh"
/// Dynamic stream fork: Connects the input stream (ready-valid) handshake to a combination of output
/// stream handshake. The combination is determined dynamically through another stream, which
/// provides a bitmask for the fork. For each input stream handshake, every output stream handshakes
/// exactly once. The input stream only handshakes when all output streams have handshaked, but the
/// output streams do not have to handshake simultaneously.
///
/// This module has no data ports because stream data does not need to be forked: the data of the
/// input stream can just be applied at all output streams.
module stream_fork_dynamic #(
/// Number of output streams
parameter int unsigned N_OUP = 32'd0 // Synopsys DC requires a default value for parameters.
) (
/// Clock
input logic clk_i,
/// Asynchronous reset, active low
input logic rst_ni,
/// Input stream valid handshake,
input logic valid_i,
/// Input stream ready handshake
output logic ready_o,
/// Selection mask for the output handshake
input logic [N_OUP-1:0] sel_i,
/// Selection mask valid
input logic sel_valid_i,
/// Selection mask ready
output logic sel_ready_o,
/// Output streams valid handshakes
output logic [N_OUP-1:0] valid_o,
/// Output streams ready handshakes
input logic [N_OUP-1:0] ready_i
);
logic int_inp_valid, int_inp_ready;
logic [N_OUP-1:0] int_oup_valid, int_oup_ready;
// Output handshaking
for (genvar i = 0; i < N_OUP; i++) begin : gen_oups
always_comb begin
valid_o[i] = 1'b0;
int_oup_ready[i] = 1'b0;
if (sel_valid_i) begin
if (sel_i[i]) begin
valid_o[i] = int_oup_valid[i];
int_oup_ready[i] = ready_i[i];
end else begin
int_oup_ready[i] = 1'b1;
end
end
end
end
// Input handshaking
always_comb begin
int_inp_valid = 1'b0;
ready_o = 1'b0;
sel_ready_o = 1'b0;
if (sel_valid_i) begin
int_inp_valid = valid_i;
ready_o = int_inp_ready;
sel_ready_o = int_inp_ready;
end
end
stream_fork #(
.N_OUP ( N_OUP )
) i_fork (
.clk_i,
.rst_ni,
.valid_i ( int_inp_valid ),
.ready_o ( int_inp_ready ),
.valid_o ( int_oup_valid ),
.ready_i ( int_oup_ready )
);
`ifndef COMMON_CELLS_ASSERTS_OFF
`ASSERT_INIT(n_oup_0, N_OUP >= 1, "N_OUP must be at least 1!")
`endif
endmodule