Decoder
ডিকোডার
ডিকোডার (Decoder)
ভূমিকা — Calculator-এর রহস্য
তোমার Calculator-এ যখন 5 দেখায়, তখন CPU কীভাবে Display-কে বলে কোন segment জ্বালাতে হবে?
7-segment display-এ ৭টি LED segment আছে (a, b, c, d, e, f, g)। '5' দেখাতে segments a, f, g, c, d জ্বালাতে হয়।
CPU শুধু 4-bit Binary (0101 = 5) পাঠায়। BCD-to-7-Segment Decoder সেই code-কে decode করে সঠিক segment জ্বালায়।
মজার তথ্য: প্রতিটি Digit Clock-এ, প্রতিটি LCD/LED Screen-এ Decoder কাজ করছে।
Decoder কেন দরকার?
CPU সব কিছু Binary-তে communicate করে। কিন্তু real world-এর device-গুলো specific signal চায়।
- Memory chip: কোন address-এ data write করবে?
- Display: কোন segment জ্বালাবে?
- I/O Port: কোন device-এ data পাঠাবে?
Decoder CPU-এর compact Binary code কে specific device signal-এ রূপান্তর করে।
চিত্রের মাধ্যমে বোঝো
2-to-4 Decoder:
A1 ──┐ ──── Y0
A0 ──┤ DECODER ──── Y1
│ ──── Y2
└ ──── Y3
(শুধু একটি Y line active হবে)
A1=0, A0=0 → Y0=1, Y1=0, Y2=0, Y3=0
A1=0, A0=1 → Y0=0, Y1=1, Y2=0, Y3=0
A1=1, A0=0 → Y0=0, Y1=0, Y2=1, Y3=0
A1=1, A0=1 → Y0=0, Y1=0, Y2=0, Y3=1
বাস্তব জীবনের সাথে মিল
উপমা: ডাকঘরের sorting system ভাবো। একটি পার্সেলে address (Binary code)। Decoder সেই address পড়ে ঠিক কোন box-এ পাঠাতে হবে তা বলে দেয়। একটি নির্দিষ্ট সময়ে শুধু একটি box-এ পার্সেল যায়।
Module 1: Decoder কী?
📌 সংজ্ঞা
Decoder হলো একটি Combinational Logic Circuit যার n টি input এবং 2ⁿ টি output থাকে। Input-এর Binary value অনুযায়ী একটিমাত্র output HIGH (1) হয়, বাকি সব LOW (0) থাকে।
n inputs → 2ⁿ outputs
(Few → Many)
| Decoder Type | Inputs | Outputs |
|---|---|---|
| 1-to-2 | 1 | 2 = 2¹ |
| 2-to-4 | 2 | 4 = 2² |
| 3-to-8 | 3 | 8 = 2³ |
| 4-to-16 | 4 | 16 = 2⁴ |
💡 Key rule: Decoder-এ একসময় শুধু একটি output HIGH।
Module 2: 2-to-4 Line Decoder
2টি input (A1, A0) এবং 4টি output (Y0, Y1, Y2, Y3)।
Truth Table
| A1 | A0 | Y3 | Y2 | Y1 | Y0 |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 |
Boolean Expressions
Y0 = Ā1 · Ā0 (A1=0, A0=0 → Y0=1)
Y1 = Ā1 · A0 (A1=0, A0=1 → Y1=1)
Y2 = A1 · Ā0 (A1=1, A0=0 → Y2=1)
Y3 = A1 · A0 (A1=1, A0=1 → Y3=1)
Logic Circuit
A1 ─┬─[NOT]─Ā1──┬──[AND]──── Y0 (Ā1·Ā0)
│ │
│ A0 ─┬─┤──[AND]──── Y1 (Ā1·A0)
│ │ │
│ [NOT]─Ā0─┤──[AND]──── Y2 (A1·Ā0)
│ │
└────────────┤──[AND]──── Y3 (A1·A0)
শুধু NOT + AND gate লাগে।
Enable Input
অনেক Decoder-এ একটি Enable (E) input থাকে:
- E=1: Decoder কাজ করে স্বাভাবিকভাবে
- E=0: সব output = 0 (Decoder disabled)
Enable ব্যবহার করে দুটো 2-to-4 Decoder মিলিয়ে একটি 3-to-8 Decoder তৈরি করা যায়।
Module 3: 3-to-8 Line Decoder
3 inputs (A2, A1, A0) এবং 8 outputs (Y0–Y7)।
Truth Table
| A2 | A1 | A0 | Active Output |
|---|---|---|---|
| 0 | 0 | 0 | Y0 |
| 0 | 0 | 1 | Y1 |
| 0 | 1 | 0 | Y2 |
| 0 | 1 | 1 | Y3 |
| 1 | 0 | 0 | Y4 |
| 1 | 0 | 1 | Y5 |
| 1 | 1 | 0 | Y6 |
| 1 | 1 | 1 | Y7 |
Boolean Expression Pattern
Y0 = Ā2·Ā1·Ā0
Y1 = Ā2·Ā1·A0
Y2 = Ā2·A1·Ā0
Y3 = Ā2·A1·A0
Y4 = A2·Ā1·Ā0
Y5 = A2·Ā1·A0
Y6 = A2·A1·Ā0
Y7 = A2·A1·A0
Pattern: Yn = Binary representation of n।
দুটো 2-to-4 Decoder দিয়ে 3-to-8 তৈরি
A2=0 → Lower Decoder (Y0–Y3) enabled
A2=1 → Upper Decoder (Y4–Y7) enabled
(A2 কে Enable হিসেবে ব্যবহার)
Module 4: BCD-to-7-Segment Decoder
7-Segment Display কী?
_
|_| ← segments a,b,c,d,e,f,g
|_|
a
___
f | | b
|_g_|
e | | c
|___|
d
7টি LED segment দিয়ে 0–9 সব digit দেখানো যায়।
Segment Pattern (Digit 0–9)
| Digit | a | b | c | d | e | f | g | Display |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | ০ |
| 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | ১ |
| 2 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | ২ |
| 3 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | ৩ |
| 4 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | ৪ |
| 5 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | ৫ |
| 6 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | ৬ |
| 7 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | ৭ |
| 8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ৮ |
| 9 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | ৯ |
কীভাবে কাজ করে
CPU পাঠায়: 0101 (BCD for 5)
↓
BCD-to-7-Segment Decoder
↓
Segments: a=1, b=0, c=1, d=1, e=0, f=1, g=1
↓
Display: '5' জ্বলে
ASCII art of digit 5
_
|_ ← segments a, f, g জ্বলছে
_| ← segments c, d, b-নেই জ্বলছে
Module 5: Decoder vs Encoder তুলনা
| বিষয় | Encoder | Decoder |
|---|---|---|
| Inputs | 2ⁿ | n |
| Outputs | n | 2ⁿ |
| Direction | Many → Few | Few → Many |
| Active | 1 input active | 1 output active |
| Use case | Keyboard, Interrupt | Display, Memory select |
| Built with | OR gates | AND + NOT gates |
| Example | 8-to-3 | 3-to-8 |
Module 6: বাস্তব প্রয়োগ
- 🔢 Calculator Display: BCD-to-7-Segment decoder সংখ্যা দেখায়
- ⏰ Digital Clock: ঘণ্টা ও মিনিটের display
- 💾 Memory Address Decoder: CPU যে address পাঠায়, সঠিক RAM chip select করে
- 🖥️ Demultiplexer: একটি input কে নির্বাচিত output-এ পাঠানো
- 📟 I/O Port Selection: কোন port-এ data যাবে তা select করা
🧠 মূল শিক্ষা
মনে রাখো: Decoder হলো "few → many" — n inputs → 2ⁿ outputs। একসময় শুধু একটি output HIGH। BCD-to-7-Segment Decoder সবচেয়ে common real-world example — calculator, clock-এ সর্বত্র। Decoder = AND + NOT gates, Encoder = OR gates।
🔁 নিজে পরীক্ষা করো
❓ প্রশ্ন ১: Decoder-এর সংজ্ঞা দাও।
✅ উত্তর: n inputs → 2ⁿ outputs। Input Binary code অনুযায়ী একটিমাত্র output HIGH হয়।
❓ প্রশ্ন ২: 2-to-4 Decoder-এ A1=1, A0=1 হলে কোন output HIGH হবে?
✅ উত্তর: Y3 (= A1·A0)
❓ প্রশ্ন ৩: BCD-to-7-Segment Decoder-এ input কত bit?
✅ উত্তর: 4 bit (BCD code 0000 থেকে 1001 = decimal 0–9)
❓ প্রশ্ন ৪: Decoder কোন ধরনের Gate দিয়ে তৈরি হয়?
✅ উত্তর: AND Gate এবং NOT Gate।
❓ প্রশ্ন ৫: Encoder এবং Decoder-এর মধ্যে মূল পার্থক্য কী?
✅ উত্তর: Encoder = Many to Few (2ⁿ→n); Decoder = Few to Many (n→2ⁿ)।
📝 HSC পরীক্ষার প্রস্তুতি
পরীক্ষায় যা আসতে পারে
🎯 BCD-to-7-Segment: এটাই সবচেয়ে বেশি আসে — কোন digit-এ কোন segment জ্বলে।
🎯 Truth Table: 2-to-4 বা 3-to-8 Decoder-এর Truth Table।
🎯 Boolean Expression: Y0, Y1... এর expression লেখো।
🎯 Encoder vs Decoder পার্থক্য।
সাধারণ ভুলসমূহ
⚠️ ভুল ১: "2n output" লেখা — সঠিক: 2ⁿ output (exponential)।
⚠️ ভুল ২: Decoder-এ একাধিক output HIGH বলা — সঠিক: শুধু একটি।
⚠️ ভুল ৩: 7-segment-এ segment letter (a–g) না জানা।
⚠️ ভুল ৪: Encoder এর সাথে Decoder গুলিয়ে ফেলা।
মনে রাখার কৌশল
💡 "Decoder = De-compress" — small → big, few → many।
💡 BCD digit 5 mnemonic: "5-এ b ও e বন্ধ" — b=0, e=0।
✅ সারাংশ
- Decoder: n inputs → 2ⁿ outputs (few → many)
- একটিমাত্র output একসময় HIGH
- 2-to-4 Decoder: Y0=Ā1Ā0, Y1=Ā1A0, Y2=A1Ā0, Y3=A1A0
- 3-to-8 Decoder: 8টি output, pattern follows binary representation
- BCD-to-7-Segment: 4-bit BCD → 7 segment control signals
- Built with: AND + NOT gates
- ব্যবহার: Display, Memory address, I/O port selection
- Encoder vs Decoder: Encoder=Many→Few, Decoder=Few→Many
সংখ্যা পদ্ধতি তুলনা — Encoder vs Decoder
| বিষয় | Encoder | Decoder |
|---|---|---|
| Input lines | 2ⁿ | n |
| Output lines | n | 2ⁿ |
| Direction | Compress | Expand |
| Active lines | 1 input | 1 output |
| Gates | OR | AND + NOT |
| Example | 8→3 | 3→8 |
🎯 অনুশীলন প্রশ্ন
-
সংজ্ঞা: Decoder কী? Encoder-এর সাথে পার্থক্য লেখো।
-
Truth Table: 2-to-4 Line Decoder-এর সম্পূর্ণ Truth Table তৈরি করো।
-
Boolean Expression: 2-to-4 Decoder-এর Y0, Y1, Y2, Y3-এর Boolean expression লেখো।
-
7-Segment: BCD-to-7-Segment Decoder-এ decimal digit 3 দেখাতে কোন কোন segment জ্বলবে?
-
BCD-to-7-Segment Table: Digit 0 থেকে 4 পর্যন্ত segment table তৈরি করো।
-
MCQ: Decoder-এ 3 inputs থাকলে output কতটি?
- (a) 3 (b) 6 (c) 8 (d) 9 উত্তর: (c) 8 (= 2³)