8-to-3 Priority Encoder
Eight-input priority encoder with 3-bit output. Advanced data compression and interrupt handling concepts.
배울 내용
- Encode the highest-priority of 8 inputs into a 3-bit code.
- Read the 8-to-3 priority truth table — focusing on the priority masking.
- Use the V output to distinguish 'I0 active' from 'no input active'.
- Recognise 8-to-3 priority encoders inside the Intel 8259 PIC and equivalent.
- Apply for interrupt control, leading-1 detection, and resource allocation.
작동 원리
An 8-to-3 priority encoder takes 8 inputs (I0–I7, with I7 highest priority) and outputs a 3-bit code (Y2 Y1 Y0) indicating the index of the highest-priority active input. A separate valid (V) output signals whether any input was active.
If I7 is high, output is 111 regardless of other inputs. Else if I6 is high, output is 110. Else if I5 is high, output is 101. ... and so on down to I0 (output 000). If no input is high, V = 0.
Boolean expressions show the priority masking pattern: each output bit is OR'd over the inputs whose binary index has that bit set, but masked by inverted higher-priority inputs.
8-to-3 priority encoders are workhorses of CPU interrupt controllers. The classic Intel 8259 PIC implements this exact function plus cascading and acknowledgement.
진리표
Showing rows where each input is the highest active. Higher-priority inputs mask lower ones.
| 입력 | 출력 | ||||
|---|---|---|---|---|---|
| Active Highest | Y2 | Y1 | Y0 | V | |
| 0 | 0 | 0 | 0 | 0 | No inputs — V=0 |
| 0 | 0 | 0 | 0 | 1 | Only I0 → 000, V=1 |
| 1 | 0 | 0 | 1 | 1 | I1 highest → 001 |
| 1 | 0 | 1 | 0 | 1 | I2 highest → 010 |
| 1 | 0 | 1 | 1 | 1 | I3 highest → 011 |
| 1 | 1 | 0 | 0 | 1 | I4 highest → 100 |
| 1 | 1 | 0 | 1 | 1 | I5 highest → 101 |
| 1 | 1 | 1 | 0 | 1 | I6 highest → 110 |
| 1 | 1 | 1 | 1 | 1 | I7 highest → 111 |
불 대수식
High bit: set if any of the upper four inputs is active.
Middle bit: set when an upper input is active, with priority masking from higher bits.
Valid: OR of all inputs. Tells the consumer whether the encoded output is meaningful.
단계별로 시도해 보세요
위 임베드에서 입력을 설정한 후, 예상 결과를 읽고 직접 확인하세요.
- 1I0 = 1예상:
Y2Y1Y0=000, V=1관찰 포인트: Lowest priority — output 0, valid bit confirms it's a real signal not 'no input.' - 2I0 = 1 I3 = 1예상:
Y2Y1Y0=011, V=1관찰 포인트: Both I0 and I3 high. I3 has higher priority → output 011 (= 3). I0 is masked. - 3I7 = 1 I0 = 1예상:
Y2Y1Y0=111, V=1관찰 포인트: I7 has the highest priority of all 8 inputs. Even with I0 active, the output is 111 (= 7). - 4예상:
Y2Y1Y0=000, V=0관찰 포인트: No inputs active — V drops to 0 to signal 'no real event.' Without V the consumer would mistake this for 'I0 active.'
사용된 구성 요소
실제 응용 사례
8-line interrupt controller. The 8259 PIC takes 8 IRQ lines, encodes the highest-priority active one, and presents it as the active vector for the CPU to fetch.
Floating-point leading-1 detection. After arithmetic, the leading-1 detection of an 8-bit field uses an 8-to-3 priority encoder (often extended to 24 or 53 bits for IEEE 754).
8-source bus arbitration. A bus controller with 8 requesters uses an 8-to-3 priority encoder to grant the bus to the highest-priority requester.
Priority-based resource allocation. Allocating from 8 resource slots: a free-list bitmap fed to a priority encoder yields the lowest-numbered free slot in O(1).
Cache replacement policy. LRU bits across 8 cache ways feed a priority encoder to identify the least-recently-used way for eviction.