File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ sources:
3939 - src/exp_backoff.sv
4040 - src/fifo_v3.sv
4141 - src/gray_to_binary.sv
42+ - src/heaviside.sv
4243 - src/isochronous_4phase_handshake.sv
4344 - src/isochronous_spill_register.sv
4445 - src/lfsr.sv
@@ -71,6 +72,7 @@ sources:
7172 - src/read.sv
7273 # Level 1
7374 - src/addr_decode_dync.sv
75+ - src/boxcar.sv
7476 - src/cdc_2phase.sv
7577 - src/cdc_4phase.sv
7678 - src/clk_int_div_static.sv
Original file line number Diff line number Diff line change 1+ // Copyright 2025 ETH Zurich and University of Bologna.
2+ // Solderpad Hardware License, Version 0.51, see LICENSE for details.
3+ // SPDX-License-Identifier: SHL-0.51
4+ //
5+ // Author: Luca Colagrande <colluca@iis.ee.ethz.ch>
6+
7+ // This module can be used to generate any mask that can be obtained
8+ // by a boxcar function (https://en.wikipedia.org/wiki/Boxcar_function).
9+ // Specifically, it generates a mask with all and only the bits in
10+ // the (lsb_i, msb_i] interval asserted.
11+ module boxcar # (
12+ parameter int unsigned Width = 32 ,
13+ // / Derived parameter *Do not override*
14+ localparam int unsigned IdxWidth = cf_math_pkg:: idx_width(Width),
15+ localparam type idx_t = logic [IdxWidth- 1 : 0 ],
16+ localparam type mask_t = logic [Width- 1 : 0 ]
17+ ) (
18+ input idx_t lsb_i,
19+ input idx_t msb_i,
20+ output mask_t mask_o
21+ );
22+
23+ mask_t low_mask, high_mask_n;
24+
25+ heaviside # (.Width (Width)) i_lo (.x_i (lsb_i), .mask_o (low_mask));
26+ heaviside # (.Width (Width)) i_hi (.x_i (msb_i), .mask_o (high_mask_n));
27+
28+ assign mask_o = ~ low_mask & high_mask_n;
29+
30+ endmodule
Original file line number Diff line number Diff line change 1+ // Copyright 2025 ETH Zurich and University of Bologna.
2+ // Solderpad Hardware License, Version 0.51, see LICENSE for details.
3+ // SPDX-License-Identifier: SHL-0.51
4+ //
5+ // Author: Luca Colagrande <colluca@iis.ee.ethz.ch>
6+
7+ // This module can be used to generate any mask that can be obtained by the
8+ // Heaviside function (https://en.wikipedia.org/wiki/Heaviside_step_function).
9+ // Specifically, it generates a mask with all and only the bits in
10+ // the [0, x_i] interval asserted.
11+ module heaviside # (
12+ parameter int unsigned Width = 32 ,
13+ // / Derived parameter *Do not override*
14+ localparam int unsigned IdxWidth = cf_math_pkg:: idx_width(Width),
15+ localparam type idx_t = logic [IdxWidth- 1 : 0 ],
16+ localparam type mask_t = logic [Width- 1 : 0 ]
17+ ) (
18+ input idx_t x_i,
19+ output mask_t mask_o
20+ );
21+
22+ assign mask_o = (1 << (x_i + 1 )) - 1 ;
23+
24+ endmodule
You can’t perform that action at this time.
0 commit comments