prim_zero_counter

Count leading or trailing zeros in in_i.

COUNT_LEADING of 1 counts leading zeros; 0 counts trailing zeros. empty_o is high when every bit of in_i is zero. CntWidth is clog2(WIDTH) and must not be overwritten.

Parameters

Table 1. Parameters
NameTypeDefaultDescription
WIDTHint unsigned2Width of the input vector.
COUNT_LEADINGbit1'b00 counts trailing zeros; 1 counts leading zeros.
CntWidthint unsignedWIDTH > 1 ? $clog2(WIDTH) : 1Width of count_o; dependent, do not change.

Ports

Table 2. Ports
NameDirectionTypeDescription
in_iinputlogic [WIDTH-1:0]Vector whose zeros are counted.
count_ooutputlogic [CntWidth-1:0]Leading or trailing zero count.
empty_ooutputlogicHigh when every bit of in_i is zero.