12 / 63 · अवधारणा
Encoders and priority: choose one of several requests
Separate one-hot input assumptions from a priority encoder’s valid and selected index.
पाठ पढ़ना मुफ़्त है। प्रगति सेव करने के लिए नामांकन करें।
अनुवाद अभी उपलब्ध नहीं है। मूल पाठ दिखाया गया है। (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 , choose the highest index. Use valid=0 and index=00 for no request. Index=00 alone cannot distinguish no request from request r0.
| requests | valid | index |
|---|---|---|
| 1--- | 1 | 11 |
| 01-- | 1 | 10 |
| 001- | 1 | 01 |
| 0001 | 1 | 00 |
| 0000 | 0 | 00 |
A dash means either binary value gives the same result, not that a simulation X is permitted.
View waveform data
| Signal | Wave | Bus values |
|---|---|---|
| requests | 234523 | 0000 → 0001 → 0011 → 0110 → 1011 → 1000 |
| valid | 01.... | |
| index | 2.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
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:
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.
खुद आज़माएँ
Give index, valid and grant for 0101 and 0001. Why must index=00 not trigger service for r0 when requests are 0000?
व्याख्या पढ़ें
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.