-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathheaviside.sv
More file actions
25 lines (22 loc) · 856 Bytes
/
heaviside.sv
File metadata and controls
25 lines (22 loc) · 856 Bytes
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
// Copyright 2025 ETH Zurich and University of Bologna.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51
//
// Author: Luca Colagrande <colluca@iis.ee.ethz.ch>
//
// This module can be used to generate any mask that can be obtained by the
// Heaviside function (https://en.wikipedia.org/wiki/Heaviside_step_function).
// Specifically, it generates a mask with all and only the bits in
// the [0, x_i] interval asserted.
module heaviside #(
parameter int unsigned Width = 32,
/// Derived parameter *Do not override*
localparam int unsigned IdxWidth = cf_math_pkg::idx_width(Width),
localparam type idx_t = logic [IdxWidth-1:0],
localparam type mask_t = logic [Width-1:0]
) (
input idx_t x_i,
output mask_t mask_o
);
assign mask_o = (1 << (x_i + 1)) - 1;
endmodule