|
5 | 5 | `include "common_cells/assertions.svh" |
6 | 6 |
|
7 | 7 | /// A trailing zero counter / leading zero counter. |
8 | | -/// Set MODE to 0 for trailing zero counter => cnt_o is the number of trailing zeros (from the LSB) |
9 | | -/// Set MODE to 1 for leading zero counter => cnt_o is the number of leading zeros (from the MSB) |
| 8 | +/// Set MODE to TRAILING_ZERO_CNT for trailing zero counter => cnt_o is the number of trailing zeros (from the LSB) |
| 9 | +/// Set MODE to LEADING_ZERO_CNT for leading zero counter => cnt_o is the number of leading zeros (from the MSB) |
10 | 10 | /// If the input does not contain a one, `empty_o` is asserted. Additionally `cnt_o` contains |
11 | 11 | /// the maximum number of zeros - 1. For example: |
12 | | -/// in_i = 000_0000, empty_o = 1, cnt_o = 6 (mode = 0) |
13 | | -/// in_i = 000_0001, empty_o = 0, cnt_o = 0 (mode = 0) |
14 | | -/// in_i = 000_1000, empty_o = 0, cnt_o = 3 (mode = 0) |
| 12 | +/// in_i = 000_0000, empty_o = 1, cnt_o = 6 (mode = TRAILING_ZERO_CNT) |
| 13 | +/// in_i = 000_0001, empty_o = 0, cnt_o = 0 (mode = TRAILING_ZERO_CNT) |
| 14 | +/// in_i = 000_1000, empty_o = 0, cnt_o = 3 (mode = TRAILING_ZERO_CNT) |
15 | 15 | /// Furthermore, this unit contains a more efficient implementation for Verilator (simulation only). |
16 | 16 | /// This speeds up simulation significantly. |
17 | | -module lzc #( |
| 17 | +module lzc import lzc_pkg::*; #( |
18 | 18 | /// The width of the input vector. |
19 | 19 | parameter int unsigned WIDTH = 2, |
20 | | - /// Mode selection: 0 -> trailing zero, 1 -> leading zero |
21 | | - parameter bit MODE = 1'b0, |
| 20 | + /// Trailing or leading zero mode selection |
| 21 | + parameter lzc_mode_e MODE = TRAILING_ZERO_CNT, |
22 | 22 | /// Dependent parameter. Do **not** change! |
23 | 23 | /// |
24 | 24 | /// Width of the output signal with the zero count. |
@@ -51,7 +51,7 @@ module lzc #( |
51 | 51 |
|
52 | 52 | logic [WIDTH-1:0] in_tmp; |
53 | 53 |
|
54 | | - if (MODE) begin : g_flip |
| 54 | + if (MODE == LEADING_ZERO_CNT) begin : g_flip |
55 | 55 | // Mode 1 (leading zero): flip input vector |
56 | 56 | always_comb begin : flip_vector |
57 | 57 | for (int unsigned i = 0; i < WIDTH; i++) begin |
|
0 commit comments