[source]

Entity arith_firstone

Ntinstd_logicrqst[N - 1 downto 0]std_logic_vectorgrntstd_logic_vector[N - 1 downto 0]toutstd_logicbinstd_logic_vector[log2ceil ( N ) - 1 downto 0]

Block Diagram of arith_firstone

Computes from an input word, a word of the same size that has, at most, one bit set. The output contains a set bit at the position of the rightmost set bit of the input if and only if such a set bit exists in the input.

A typical use case for this computation would be an arbitration over requests with a fixed and strictly ordered priority. The terminology of the interface assumes this use case and provides some useful extras:

Set tin <= '0' (no input token) to disallow grants altogether. Read tout (unused token) to see whether or any grant was issued. Read bin to obtain the binary index of the rightmost detected one bit.

The index starts at zero (0) in the rightmost bit position.

This implementation uses carry chains for wider implementations.

Generics

Name

Type

Default

Description

N

positive

Length of Token Chain

Ports

Name

Type

Direction

Description

tin

std_logic

in

Enable: Fed Token

rqst

std_logic_vector

in

Request: Token Requests

grnt

std_logic_vector

out

Grant: Token Output

tout

std_logic

out

Inactive: Unused Token

bin

std_logic_vector

out

Binary Grant Index