Template: 2-to-4 Decoder
Two-bit decoder creating four output lines. Learn address decoding for memory and device selection.
学べること
- Convert a 2-bit binary code into one of 4 one-hot output lines.
- Read the 2-to-4 decoder truth table — exactly one output high per input code.
- Write per-output Boolean expressions as ANDs of input minterms.
- Recognise that decoders are universal address-selectors in memory.
- Distinguish decoders (no data) from DEMUXes (with data input).
仕組み
A decoder converts an N-bit input code into 2ᴺ output lines, exactly one of which is asserted high (one-hot). The 2-to-4 decoder takes a 2-bit input (A1, A0) and asserts one of four outputs (Y0–Y3) corresponding to the binary value of A1A0.
Mapping: - A1A0 = 00 → Y0 = 1, others = 0 - A1A0 = 01 → Y1 = 1, others = 0 - A1A0 = 10 → Y2 = 1, others = 0 - A1A0 = 11 → Y3 = 1, others = 0
Boolean: each output is a 2-input AND of the right combination of A1 and A0 (or their inverses). Y0 = ¬A1·¬A0, Y1 = ¬A1·A0, Y2 = A1·¬A0, Y3 = A1·A0.
Decoders are the heart of address-based selection — every memory chip, register file, and chip-select network uses one. A 16-bit address goes into a 16-to-65536 decoder to pick exactly one of 65,536 row lines in a memory array.
Many decoders include an enable input that gates all outputs to 0 when low — useful when one of several decoders should be active at a time.
真理値表
Each 2-bit input code asserts exactly one of 4 outputs.
| 入力 | 出力 | |||||
|---|---|---|---|---|---|---|
| A1 | A0 | Y0 | Y1 | Y2 | Y3 | |
| 0 | 0 | 1 | 0 | 0 | 0 | Code 00 → Y0 active |
| 0 | 1 | 0 | 1 | 0 | 0 | Code 01 → Y1 active |
| 1 | 0 | 0 | 0 | 1 | 0 | Code 10 → Y2 active |
| 1 | 1 | 0 | 0 | 0 | 1 | Code 11 → Y3 active |
ブール式
Outputs 0 and 1: AND of the input bits matched to the desired pattern.
Outputs 2 and 3: AND of the high-half input pattern.
順を追って試す
上の埋め込み回路で入力を設定し、期待される結果と一致するか確認しましょう。
- 1A1 = 0 A0 = 0期待値:
Y0=1, others=0観察ポイント: Code 00 → Y0 lights. The default state of any one-hot decoder. - 2A1 = 0 A0 = 1期待値:
Y1=1, others=0観察ポイント: Code 01 → Y1. The active line walks across the outputs as the input increments. - 3A1 = 1 A0 = 0期待値:
Y2=1, others=0観察ポイント: Code 10 → Y2. Notice exactly one output is always high. - 4A1 = 1 A0 = 1期待値:
Y3=1, others=0観察ポイント: Code 11 → Y3. All four codes have been visited; each activates a unique output.
使用コンポーネント
実世界での応用
Memory row decoder. A RAM chip's address decoder asserts exactly one row select line based on the address bits — the same pattern, just much wider (e.g., 14-to-16384).
CPU instruction decoder. The opcode field of an instruction goes into a decoder that activates one of N micro-operation control lines.
Chip-select generation. A 2-bit address routes one of 4 chip-select lines from the CPU to peripheral chips.
Display segment decoders. BCD-to-7-segment converters use decoder logic to drive the right segments for each digit.
State machine output decoding. A binary-encoded state goes into a decoder to produce one-hot state-active signals for downstream logic.