PriorityEncoder.v

This module encodes a vector of input logic levels to a binary value, where the value is the binary value of the position in the vector of the most significant bit that is non zero in the vector, counting from the least-significant end. Another output indicates whether any bit is high. This module is stateless.

Ports | Parameters | Notes | Example | Timing diagram

Ports

<
ininputThe vector of input logic levels.
activeoutputWhen asserted, indicates that at least one of the bits of the input vector is non zero.
outoutput   The encoded output, where its binary value points to the position of the most-significant nonzero bit of the input vector.

Parameters

w1The bit width of the output vector. The number of bits of the input is two raised to this parameter (2w).

Example instantiation:

wire	[3:0]	c1;
wire	[1:0]	out;
PriorityEncoder #(.w(2)) pe (.in(c1), .active(active), .out(out));

Timing diagram for the example above.

Timing (logic) diagram for w = 2.

Timing