Altifigence Academy

12 / 63 · Conceito

Encoders and priority: choose one of several requests

Separate one-hot input assumptions from a priority encoder’s valid and selected index.

A tradução ainda não está disponível. A aula original é exibida. (English)

Encoding needs an input contract

A decoderdecoder A circuit activating the output corresponding to an input code. An enable can force all outputs inactive. Learn more maps an address to a one-hotone-hot An encoding with exactly one bit set. If all-zero is also permitted, the condition is one-hot-or-zero. Learn more selection. An encoder maps an active input back to an address. A simple one-hot encoder assumes at most one active input; multiple requests require an explicit selection policy.

For requests r3r2r1r0r_3r_2r_1r_0, choose the highest index. Use valid=0 and index=00 for no request. Index=00 alone cannot distinguish no request from request r0.

requestsvalidindex
1---111
01--110
001-101
0001100
0000000

A dash means either binary value gives the same result, not that a simulation X is permitted.

valid=r3+r2+r1+r0,index1=r3+r2,index0=r3+r2r1valid=r_3+r_2+r_1+r_0,\quad index_1=r_3+r_2,\quad index_0=r_3+\overline{r_2}r_1
Each column is an independent request vector
View waveform data
Wave data: each character is one interval; a dot holds the previous state; p is a clock cycle.
SignalWaveBus values
requests2345230000 → 0001 → 0011 → 0110 → 1011 → 1000
valid01....
index2.345.00 → 01 → 10 → 11

An RTL if/else chain from request[3] down to request[1], with index defaulting to zero, makes priority explicit. Compute valid separately as OR reduction of all requests. Test all 16 combinations: a valid selection must point to an asserted request, with every higher request clear.

Fixed priority is not fairness. A permanently asserted r3 can starve r0. Fair arbitration requires a policy that usually remembers prior grants.

Lab · Observe request, selected address and grant together

Select one of several simultaneous requests

r3r2r1r0=1011; valid=1; index=11; grant=1000. Higher numbered requests take priority. When valid=0, index does not identify a selected request.

With the initial request 1011, r3 wins. Turn it off: r1 wins with index=01 and grant=0010. Toggling r0 must not change that selection while r1 remains asserted.

Compare Clear all with enabling only r0. Both give index=00, but their valid and grant values differ. A consumer that reads index alone could process a nonexistent request.

Decode index together with valid to obtain a one-hot-or-zero grant:

granti=valid(index=i)grant_i=valid\land(index=i)

Check three invariants: at most one grant is asserted, every granted position has an active request, and all requests above the selected position are zero. This lab does not consume requests or remember prior grants. A continuously asserted r3 can keep lower requests waiting: that is a property of fixed priority.

Experimente

Give index, valid and grant for 0101 and 0001. Why must index=00 not trigger service for r0 when requests are 0000?

Ler a explicação

0101 gives index=10, valid=1, grant=0100. 0001 gives index=00, valid=1, grant=0001. For 0000, index=00 is only the default; valid=0 and grant=0000 mean there is no request to serve.

Sua escolha vale neste navegador. Altere-a a qualquer momento no rodapé.