Digital Logic DesignDigital Logic Design
How computers work with 0s and 1s — number systems, gates, K-maps, adders, flip-flops, counters, and sequential circuits. Computer কীভাবে 0 আর 1 দিয়ে কাজ করে — number system, gate, K-map, adder, flip-flop, counter আর sequential circuit।
- Number Systems and CodesNumber Systems and Codes
- Boolean Algebra and Logic GatesBoolean Algebra and Logic Gates
- Karnaugh Map (K-map)Karnaugh Map (K-map)
- Combinational CircuitsCombinational Circuits
- Flip-FlopsFlip-Flops
- Counters and RegistersCounters and Registers
- Sequential Circuit DesignSequential Circuit Design
- Practice QuestionsPractice Questions
1. Number Systems and Codes1. Number Systems and Codes
A number system is a way to write numbers. Each system has a base (also called radix). The base tells how many symbols the system uses.
- Decimal — base 10. Symbols: 0–9. This is our normal system.
- Binary — base 2. Symbols: 0 and 1. Computers use this.
- Octal — base 8. Symbols: 0–7.
- Hexadecimal (hex) — base 16. Symbols: 0–9 and A–F (A=10, B=11, C=12, D=13, E=14, F=15).
Each digit has a place value. In base r, the place values are powers of r: ... r³, r², r¹, r⁰ before the point, and r⁻¹, r⁻² after the point.
Number system হলো সংখ্যা লেখার নিয়ম। প্রতিটি system-এর একটা base (বা radix) থাকে। Base বলে দেয় ওই system-এ কয়টা symbol ব্যবহার হয়।
- Decimal — base 10। Symbol: 0–9। এটাই আমাদের স্বাভাবিক system।
- Binary — base 2। Symbol: 0 আর 1। Computer এটা ব্যবহার করে।
- Octal — base 8। Symbol: 0–7।
- Hexadecimal (hex) — base 16। Symbol: 0–9 আর A–F (A=10, B=11, C=12, D=13, E=14, F=15)।
প্রতিটি digit-এর একটা place value আছে। Base r হলে place value গুলো r-এর power: point-এর আগে ... r³, r², r¹, r⁰ আর point-এর পরে r⁻¹, r⁻²।
Binary → DecimalBinary → Decimal
Multiply each bit by its place value, then add:
1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 32 + 0 + 8 + 4 + 0 + 1 = 45.
So (101101)₂ = (45)₁₀.
প্রতিটি bit-কে তার place value দিয়ে গুণ করে যোগ করি:
1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 32 + 0 + 8 + 4 + 0 + 1 = 45।
তাই (101101)₂ = (45)₁₀।
Decimal → BinaryDecimal → Binary
For the whole part: divide by 2 again and again. Keep the remainders. Read the remainders from bottom to top.
For the fraction part: multiply by 2 again and again. Keep the whole-number digit each time. Read from top to bottom.
Whole part-এর জন্য: বারবার 2 দিয়ে ভাগ করি আর remainder রাখি। Remainder গুলো নিচ থেকে উপরে পড়ি।
Fraction part-এর জন্য: বারবার 2 দিয়ে গুণ করি। প্রতিবার whole-number digit-টা রাখি। উপর থেকে নিচে পড়ি।
Whole part 45:
| Division | Quotient | Remainder |
|---|---|---|
| 45 ÷ 2 | 22 | 1 (LSB) |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 (MSB) |
Read bottom to top: 45 = (101101)₂.
Fraction part 0.625: 0.625×2 = 1.25 → 0.25×2 = 0.5 → 0.5×2 = 1.0 → stop.
Read top to bottom: 0.625 = (.101)₂. So (45.625)₁₀ = (101101.101)₂.
Whole part 45:
| ভাগ | Quotient | Remainder |
|---|---|---|
| 45 ÷ 2 | 22 | 1 (LSB) |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 (MSB) |
নিচ থেকে উপরে পড়ি: 45 = (101101)₂।
Fraction part 0.625: 0.625×2 = 1.25 → 0.25×2 = 0.5 → 0.5×2 = 1.0 → শেষ।
উপর থেকে নিচে পড়ি: 0.625 = (.101)₂। তাই (45.625)₁₀ = (101101.101)₂।
Octal and Hex ↔ Binary (the shortcut)Octal আর Hex ↔ Binary (shortcut)
Octal and hex are just "packed" binary. This makes conversion very fast:
- Binary → octal: group bits in 3s from the point. Each group is one octal digit.
- Binary → hex: group bits in 4s from the point. Each group is one hex digit.
- Going the other way, expand each digit into 3 or 4 bits.
Octal আর hex আসলে "packed" binary। তাই conversion খুব দ্রুত হয়:
- Binary → octal: point থেকে 3 bit করে group করি। প্রতিটি group একটা octal digit।
- Binary → hex: point থেকে 4 bit করে group করি। প্রতিটি group একটা hex digit।
- উল্টো দিকে গেলে প্রতিটি digit-কে 3 বা 4 bit-এ ভেঙে লিখি।
Octal: group in 3s → 10 111 011 → pad left → 010 111 011 → 2 7 3 → (273)₈.
Hex: group in 4s → 1011 1011 → B B → (BB)₁₆.
Check via decimal: 10111011₂ = 128+32+16+8+2+1 = 187. And 2×64+7×8+3 = 187 ✓, 11×16+11 = 187 ✓.
Octal: 3 bit করে group → 10 111 011 → বামে pad → 010 111 011 → 2 7 3 → (273)₈।
Hex: 4 bit করে group → 1011 1011 → B B → (BB)₁₆।
Decimal দিয়ে check: 10111011₂ = 128+32+16+8+2+1 = 187। আর 2×64+7×8+3 = 187 ✓, 11×16+11 = 187 ✓।
428 ÷ 16 = 26, remainder 12 (C). 26 ÷ 16 = 1, remainder 10 (A). 1 ÷ 16 = 0, remainder 1.
Read bottom to top: (428)₁₀ = (1AC)₁₆. Check: 1×256 + 10×16 + 12 = 428 ✓.
428 ÷ 16 = 26, remainder 12 (C)। 26 ÷ 16 = 1, remainder 10 (A)। 1 ÷ 16 = 0, remainder 1।
নিচ থেকে উপরে পড়ি: (428)₁₀ = (1AC)₁₆। Check: 1×256 + 10×16 + 12 = 428 ✓।
Binary ArithmeticBinary Arithmetic
Addition rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).
Subtraction rules: 0−0=0, 1−0=1, 1−1=0, 0−1=1 with a borrow of 1 from the next column.
Addition-এর নিয়ম: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 লিখি, 1 carry), 1+1+1=11 (1 লিখি, 1 carry)।
Subtraction-এর নিয়ম: 0−0=0, 1−0=1, 1−1=0, 0−1=1 আর পরের column থেকে 1 borrow।
carry: 1 1 1 0
1 0 1 1 (11)
+ 0 1 1 0 (6)
---------
1 0 0 0 1 (17) ✓
carry: 1 1 1 0
1 0 1 1 (11)
+ 0 1 1 0 (6)
---------
1 0 0 0 1 (17) ✓
1's and 2's Complement1's আর 2's Complement
Complements let us do subtraction using only addition. That is why hardware loves them.
- 1's complement: flip every bit. Example: 1's complement of 0101 is 1010.
- 2's complement: 1's complement + 1. Example: 2's complement of 0101 is 1011.
Subtraction rule (A − B): take the 2's complement of B and add it to A.
- If there is a final carry, discard it. The answer is positive.
- If there is no carry, the answer is negative. Take the 2's complement of the result to get the magnitude.
Complement ব্যবহার করলে শুধু addition দিয়েই subtraction করা যায়। এজন্যই hardware-এ এটা এত জনপ্রিয়।
- 1's complement: প্রতিটি bit উল্টে দাও। Example: 0101-এর 1's complement হলো 1010।
- 2's complement: 1's complement + 1। Example: 0101-এর 2's complement হলো 1011।
Subtraction-এর নিয়ম (A − B): B-এর 2's complement নিয়ে A-এর সাথে যোগ করো।
- শেষে carry থাকলে সেটা ফেলে দাও। উত্তর positive।
- Carry না থাকলে উত্তর negative। Result-এর 2's complement নিলে magnitude পাওয়া যায়।
Step 1: 23 = 00010111, 17 = 00010001.
Step 2: 2's complement of 17: flip → 11101110, add 1 → 11101111.
Step 3: add: 00010111 + 11101111 = 100000110.
Step 4: there is a carry out → discard it. Result = 00000110 = +6 ✓.
Step 1: 23 = 00010111, 17 = 00010001।
Step 2: 17-এর 2's complement: flip → 11101110, +1 → 11101111।
Step 3: যোগ করি: 00010111 + 11101111 = 100000110।
Step 4: carry আছে → ফেলে দিই। Result = 00000110 = +6 ✓।
2's complement of 23 (00010111): flip → 11101000, add 1 → 11101001.
Add: 00010001 + 11101001 = 11111010. No carry out → answer is negative.
Magnitude: 2's complement of 11111010 → 00000101 + 1 = 00000110 = 6. So the answer is −6 ✓.
23 (00010111)-এর 2's complement: flip → 11101000, +1 → 11101001।
যোগ করি: 00010001 + 11101001 = 11111010। কোনো carry নেই → উত্তর negative।
Magnitude: 11111010-এর 2's complement → 00000101 + 1 = 00000110 = 6। তাই উত্তর −6 ✓।
Signed Number RangesSigned Number Ranges
With n bits, we can represent signed numbers in three ways. 2's complement is the winner because it has one zero and simple hardware.
n bit দিয়ে signed number তিনভাবে লেখা যায়। 2's complement সবচেয়ে ভালো, কারণ এতে zero একটাই আর hardware সহজ।
| RepresentationRepresentation | Range (n bits)Range (n bit) | Range for 8 bits8 bit-এর জন্য range | ZerosZero |
|---|---|---|---|
| Sign-magnitude | −(2ⁿ⁻¹−1) … +(2ⁿ⁻¹−1) | −127 … +127 | two (+0, −0)দুইটা (+0, −0) |
| 1's complement | −(2ⁿ⁻¹−1) … +(2ⁿ⁻¹−1) | −127 … +127 | twoদুইটা |
| 2's complement | −2ⁿ⁻¹ … +(2ⁿ⁻¹−1) | −128 … +127 | oneএকটা |
BCD, Gray Code, ASCIIBCD, Gray Code, ASCII
BCD (Binary Coded Decimal, 8421 code): each decimal digit is written as its own 4-bit binary. Example: 59 = 0101 1001 in BCD. Note: this is different from pure binary (59 = 111011). Codes 1010–1111 are invalid in BCD. In BCD addition, if a digit sum is more than 9, add 6 (0110) to correct it.
Gray code: only one bit changes between two consecutive numbers. This avoids glitches in position sensors and helps in K-maps.
- Binary → Gray: keep the MSB. Then each Gray bit = current binary bit XOR previous binary bit.
- Gray → Binary: keep the MSB. Then each binary bit = previous binary bit XOR current Gray bit.
ASCII: a 7-bit code for characters. 'A' = 65 (41 in hex), 'a' = 97 (61 in hex), '0' = 48 (30 in hex).
BCD (Binary Coded Decimal, 8421 code): প্রতিটি decimal digit-কে আলাদা করে 4-bit binary-তে লেখা হয়। Example: 59 = BCD-তে 0101 1001। খেয়াল করো: এটা pure binary (59 = 111011) থেকে আলাদা। BCD-তে 1010–1111 code গুলো invalid। BCD addition-এ কোনো digit-এর যোগফল 9-এর বেশি হলে 6 (0110) যোগ করে ঠিক করতে হয়।
Gray code: পরপর দুইটা সংখ্যার মধ্যে মাত্র একটা bit বদলায়। এতে position sensor-এ glitch হয় না, আর K-map-এও এটা কাজে লাগে।
- Binary → Gray: MSB একই থাকে। তারপর প্রতিটি Gray bit = current binary bit XOR আগের binary bit।
- Gray → Binary: MSB একই থাকে। তারপর প্রতিটি binary bit = আগের binary bit XOR current Gray bit।
ASCII: character-এর জন্য 7-bit code। 'A' = 65 (hex-এ 41), 'a' = 97 (hex-এ 61), '0' = 48 (hex-এ 30)।
MSB: keep 1. Next: 1⊕0 = 1. Next: 0⊕1 = 1. Next: 1⊕1 = 0.
So binary 1011 → Gray 1110.
MSB: 1 রাখি। পরে: 1⊕0 = 1। পরে: 0⊕1 = 1। পরে: 1⊕1 = 0।
তাই binary 1011 → Gray 1110।
| Decimal | Binary | Gray | BCD |
|---|---|---|---|
| 0 | 000 | 000 | 0000 |
| 1 | 001 | 001 | 0001 |
| 2 | 010 | 011 | 0010 |
| 3 | 011 | 010 | 0011 |
| 4 | 100 | 110 | 0100 |
| 5 | 101 | 111 | 0101 |
| 6 | 110 | 101 | 0110 |
| 7 | 111 | 100 | 0111 |
2. Boolean Algebra and Logic Gates2. Boolean Algebra and Logic Gates
Boolean algebra works with only two values: 0 (false) and 1 (true). A logic gate is a small circuit that does one Boolean operation. We write NOT A as A′ (or \(\overline{A}\)), A AND B as A·B (or just AB), and A OR B as A+B.
Boolean algebra শুধু দুইটা value নিয়ে কাজ করে: 0 (false) আর 1 (true)। Logic gate হলো ছোট একটা circuit যেটা একটা Boolean operation করে। আমরা NOT A-কে লিখি A′ (বা \(\overline{A}\)), A AND B-কে লিখি A·B (বা শুধু AB), আর A OR B-কে লিখি A+B।
All gates in one truth tableসব gate এক truth table-এ
| A | B | AND AB | OR A+B | NAND (AB)′ | NOR (A+B)′ | XOR A⊕B | XNOR (A⊕B)′ |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Quick memory helpers: AND = 1 only when all inputs are 1. OR = 1 when any input is 1. XOR = 1 when the inputs are different. XNOR = 1 when the inputs are equal. NOT A means the opposite of A.
মনে রাখার সহজ উপায়: AND = 1 হয় শুধু যখন সব input 1। OR = 1 হয় যখন যেকোনো input 1। XOR = 1 হয় যখন input দুটো আলাদা। XNOR = 1 হয় যখন input দুটো সমান। NOT A মানে A-এর উল্টো।
Boolean LawsBoolean Laws
| LawLaw | OR formOR form | AND formAND form |
|---|---|---|
| Identity | A + 0 = A | A · 1 = A |
| Null (domination) | A + 1 = 1 | A · 0 = 0 |
| Idempotent | A + A = A | A · A = A |
| Complement | A + A′ = 1 | A · A′ = 0 |
| Involution | (A′)′ = A | |
| Commutative | A + B = B + A | AB = BA |
| Associative | (A+B)+C = A+(B+C) | (AB)C = A(BC) |
| Distributive | A(B+C) = AB + AC | A + BC = (A+B)(A+C) |
| Absorption | A + AB = A | A(A+B) = A |
| Absorption 2 | A + A′B = A + B | A(A′+B) = AB |
| De Morgan | (A+B)′ = A′ · B′ | (AB)′ = A′ + B′ |
De Morgan's Theorems (proof by truth table)De Morgan's Theorems (truth table দিয়ে প্রমাণ)
De Morgan's theorems: (A·B)′ = A′ + B′ and (A+B)′ = A′·B′. In words: break the bar, change the operator. The truth table below proves both — matching columns are shaded.
De Morgan's theorem: (A·B)′ = A′ + B′ আর (A+B)′ = A′·B′। কথায় বললে: bar ভাঙো, operator বদলাও। নিচের truth table দুটোই প্রমাণ করে — মিলে যাওয়া column গুলো shade করা।
| A | B | A′ | B′ | (AB)′ | A′+B′ | (A+B)′ | A′B′ |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
The yellow pair matches row by row, and the green pair matches row by row. So both theorems are proved. ✓
হলুদ pair প্রতি row-তে মিলে গেছে, আর সবুজ pair-ও প্রতি row-তে মিলে গেছে। তাই দুটো theorem-ই প্রমাণিত। ✓
Simplification — worked examplesSimplification — worked example
Use distributive law backwards: A + A′B = (A + A′)(A + B) = 1 · (A + B) = A + B.
Distributive law উল্টোভাবে ব্যবহার করি: A + A′B = (A + A′)(A + B) = 1 · (A + B) = A + B।
Step 1: AB + AB′ = A(B + B′) = A·1 = A.
Step 2: F = A + A′B. Step 3: by the rule above, F = A + B.
Step 1: AB + AB′ = A(B + B′) = A·1 = A।
Step 2: F = A + A′B। Step 3: আগের নিয়ম থেকে, F = A + B।
Multiply out: AA + AB′ + AB + BB′ = A + A(B′ + B) + 0 = A + A = A.
Shortcut: (A+B)(A+B′) = A + BB′ = A + 0 = A (using the second distributive law).
গুণ করে খুলি: AA + AB′ + AB + BB′ = A + A(B′ + B) + 0 = A + A = A।
Shortcut: (A+B)(A+B′) = A + BB′ = A + 0 = A (দ্বিতীয় distributive law দিয়ে)।
Universal Gates: NAND and NORUniversal Gates: NAND আর NOR
NAND and NOR are called universal gates because any Boolean function can be built using only NAND (or only NOR). This is a BUET favorite. Here is how to build the basic gates from NAND:
- NOT from NAND: join both inputs. NAND(A, A) = (A·A)′ = A′.
- AND from NAND: NAND, then NOT. ((AB)′)′ = AB. Needs 2 NAND gates.
- OR from NAND: invert both inputs first, then NAND. (A′·B′)′ = A + B (De Morgan). Needs 3 NAND gates.
- NOR from NAND: OR then NOT → 4 NAND gates.
- XOR from NAND: needs 4 NAND gates (a classic exam question).
NAND আর NOR-কে universal gate বলা হয়, কারণ শুধু NAND (বা শুধু NOR) দিয়ে যেকোনো Boolean function বানানো যায়। এটা BUET-এর খুব প্রিয় প্রশ্ন। NAND দিয়ে basic gate গুলো বানানোর নিয়ম:
- NAND দিয়ে NOT: দুই input একসাথে জুড়ে দাও। NAND(A, A) = (A·A)′ = A′।
- NAND দিয়ে AND: NAND, তারপর NOT। ((AB)′)′ = AB। ২টা NAND লাগে।
- NAND দিয়ে OR: আগে দুই input invert করো, তারপর NAND। (A′·B′)′ = A + B (De Morgan)। ৩টা NAND লাগে।
- NAND দিয়ে NOR: OR তারপর NOT → ৪টা NAND।
- NAND দিয়ে XOR: ৪টা NAND লাগে (classic exam প্রশ্ন)।
The trick: do not force one gate type for both. Give each function the gate type that fits it best:
- F₁ = A + B with NOR: G₁ = NOR(A, B) = (A+B)′. Then G₂ = NOR(G₁, G₁) = ((A+B)′)′ = A + B. → 2 NOR gates.
- F₂ = A·B with NAND: G₃ = NAND(A, B) = (AB)′. Then G₄ = NAND(G₃, G₃) = ((AB)′)′ = AB. → 2 NAND gates.
Total: 4 gates (2 NAND + 2 NOR).
Why this is minimum: with NAND only, OR needs 3 gates and AND needs 2 → 5 gates. With NOR only, OR needs 2 and AND needs 3 → 5 gates. Mixing wins with 4.
Trick: দুটোর জন্যই এক gate type জোর করে ব্যবহার কোরো না। যে function-এর জন্য যে gate type ভালো, সেটাই দাও:
- NOR দিয়ে F₁ = A + B: G₁ = NOR(A, B) = (A+B)′। তারপর G₂ = NOR(G₁, G₁) = ((A+B)′)′ = A + B। → ২টা NOR gate।
- NAND দিয়ে F₂ = A·B: G₃ = NAND(A, B) = (AB)′। তারপর G₄ = NAND(G₃, G₃) = ((AB)′)′ = AB। → ২টা NAND gate।
মোট: ৪টা gate (2 NAND + 2 NOR)।
এটা কেন minimum: শুধু NAND দিয়ে OR-এ লাগে ৩টা আর AND-এ ২টা → ৫টা gate। শুধু NOR দিয়ে OR-এ ২টা আর AND-এ ৩টা → ৫টা gate। মিশিয়ে নিলে ৪টাতেই হয়।
SOP, POS, Minterms and MaxtermsSOP, POS, Minterm আর Maxterm
A minterm (mᵢ) is an AND term that uses every variable once. It is 1 for exactly one input row. A maxterm (Mᵢ) is an OR term that uses every variable once. It is 0 for exactly one row.
- SOP (Sum of Products): OR of AND terms. Example: F = A′BC + AB′.
- POS (Product of Sums): AND of OR terms. Example: F = (A+B)(A′+C).
- Canonical SOP: F = Σm(list of rows where F = 1). Canonical POS: F = ΠM(rows where F = 0).
- Same function: the minterm list and maxterm list together cover all 2ⁿ rows. Example (3 variables): F = Σm(1,3,5,7) = ΠM(0,2,4,6).
Minterm (mᵢ) হলো এমন একটা AND term যেখানে প্রতিটি variable একবার করে থাকে। এটা ঠিক একটা input row-এর জন্য 1 হয়। Maxterm (Mᵢ) হলো এমন OR term যেটা ঠিক একটা row-এর জন্য 0 হয়।
- SOP (Sum of Products): AND term গুলোর OR। Example: F = A′BC + AB′।
- POS (Product of Sums): OR term গুলোর AND। Example: F = (A+B)(A′+C)।
- Canonical SOP: F = Σm(যেসব row-তে F = 1)। Canonical POS: F = ΠM(যেসব row-তে F = 0)।
- একই function: minterm list আর maxterm list মিলে সব 2ⁿ row cover করে। Example (3 variable): F = Σm(1,3,5,7) = ΠM(0,2,4,6)।
| RowRow | A B C | MintermMinterm | MaxtermMaxterm |
|---|---|---|---|
| 0 | 0 0 0 | m₀ = A′B′C′ | M₀ = A+B+C |
| 1 | 0 0 1 | m₁ = A′B′C | M₁ = A+B+C′ |
| 2 | 0 1 0 | m₂ = A′BC′ | M₂ = A+B′+C |
| 3 | 0 1 1 | m₃ = A′BC | M₃ = A+B′+C′ |
| 4 | 1 0 0 | m₄ = AB′C′ | M₄ = A′+B+C |
| 5 | 1 0 1 | m₅ = AB′C | M₅ = A′+B+C′ |
| 6 | 1 1 0 | m₆ = ABC′ | M₆ = A′+B′+C |
| 7 | 1 1 1 | m₇ = ABC | M₇ = A′+B′+C′ |
3. Karnaugh Map (K-map)3. Karnaugh Map (K-map)
A K-map is a grid form of a truth table. Cells that are next to each other differ in only one variable (Gray code order). So when two neighboring cells are both 1, that variable can be dropped. This makes simplification visual and fast.
Grouping rules:
- Groups must be rectangles of size 1, 2, 4, 8, or 16 — always a power of 2.
- The map wraps around: the left edge touches the right edge, and the top touches the bottom. Corners are neighbors too.
- Make groups as large as possible, and use as few groups as possible.
- Every 1 must be inside at least one group. Groups may overlap.
- A group of 2 removes 1 variable, a group of 4 removes 2, a group of 8 removes 3.
A group that cannot be made bigger is a prime implicant. If some 1 is covered by only one prime implicant, that group is an essential prime implicant — it must appear in the answer.
K-map হলো truth table-এর grid রূপ। পাশাপাশি cell গুলোর মধ্যে মাত্র একটা variable আলাদা হয় (Gray code order)। তাই পাশাপাশি দুইটা cell-ই 1 হলে সেই variable বাদ দেওয়া যায়। এতে simplification চোখে দেখে দ্রুত করা যায়।
Grouping-এর নিয়ম:
- Group হতে হবে rectangle, size 1, 2, 4, 8 বা 16 — সবসময় power of 2।
- Map wrap around করে: বাম edge ডান edge-কে ছোঁয়, উপর নিচকে ছোঁয়। চার কোণাও পরস্পরের neighbor।
- Group যত বড় সম্ভব করো, আর group সংখ্যা যত কম সম্ভব রাখো।
- প্রতিটি 1 অন্তত একটা group-এ থাকতে হবে। Group overlap করতে পারে।
- 2-এর group ১টা variable বাদ দেয়, 4-এর group ২টা, 8-এর group ৩টা।
যে group আর বড় করা যায় না, সেটা prime implicant। কোনো 1 যদি শুধু একটা prime implicant-এ থাকে, তবে সেটা essential prime implicant — উত্তরে সেটা থাকতেই হবে।
Map layouts (note the Gray code order 00, 01, 11, 10)Map-এর গঠন (Gray code order 00, 01, 11, 10 খেয়াল করো)
| 2-var | B=0 | B=1 |
|---|---|---|
| A=0 | m₀ | m₁ |
| A=1 | m₂ | m₃ |
| 3-var | BC=00 | BC=01 | BC=11 | BC=10 |
|---|---|---|---|---|
| A=0 | m₀ | m₁ | m₃ | m₂ |
| A=1 | m₄ | m₅ | m₇ | m₆ |
| 4-var | CD=00 | CD=01 | CD=11 | CD=10 |
|---|---|---|---|---|
| AB=00 | m₀ | m₁ | m₃ | m₂ |
| AB=01 | m₄ | m₅ | m₇ | m₆ |
| AB=11 | m₁₂ | m₁₃ | m₁₅ | m₁₄ |
| AB=10 | m₈ | m₉ | m₁₁ | m₁₀ |
Worked example 1 (3 variables)Worked example 1 (3 variable)
| F | BC=00 | BC=01 | BC=11 | BC=10 |
|---|---|---|---|---|
| A=0 | 0 | 1 | 1 | 1 |
| A=1 | 0 | 1 | 1 | 0 |
Green group (m₁, m₃, m₅, m₇ — the two middle columns): a group of 4. In all four cells C = 1, while A and B both change. So this group gives just C.
Blue cell (m₂): pair it with its neighbor m₃ (green cell beside it). In m₂ and m₃: A = 0, B = 1, C changes. So this pair gives A′B.
Answer: F = C + A′B.
সবুজ group (m₁, m₃, m₅, m₇ — মাঝের দুই column): 4-এর group। চার cell-এই C = 1, আর A ও B দুটোই বদলায়। তাই এই group দেয় শুধু C।
নীল cell (m₂): পাশের m₃ (সবুজ cell)-এর সাথে pair করি। m₂ আর m₃-তে: A = 0, B = 1, C বদলায়। তাই এই pair দেয় A′B।
উত্তর: F = C + A′B।
Worked example 2 (4 variables, with don't-cares)Worked example 2 (4 variable, don't-care সহ)
A don't-care (written X or d) is an input that never happens, or whose output we do not care about. We may count an X as 1 if it helps make a bigger group, otherwise we treat it as 0.
Don't-care (X বা d লেখা হয়) হলো এমন input যেটা কখনো আসে না, বা যার output নিয়ে আমাদের মাথাব্যথা নেই। X-কে 1 ধরা যায় যদি তাতে বড় group বানানো যায়, নাহলে 0 ধরি।
| F | CD=00 | CD=01 | CD=11 | CD=10 |
|---|---|---|---|---|
| AB=00 | X | 1 | 1* | X |
| AB=01 | 0 | X | 1 | 0 |
| AB=11 | 0 | 0 | 1 | 0 |
| AB=10 | 0 | 0 | 1 | 0 |
Green group (column CD=11: m₃, m₇, m₁₅, m₁₁): a group of 4. C = 1 and D = 1 stay fixed → term CD.
Yellow group (top row: m₀(X), m₁, m₃, m₂(X)): a group of 4 using two don't-cares. A = 0, B = 0 stay fixed → term A′B′.
The X at m₅ is not needed, so we leave it as 0.
Answer: F = CD + A′B′. (The cell marked * belongs to both groups — overlap is fine.)
সবুজ group (column CD=11: m₃, m₇, m₁₅, m₁₁): 4-এর group। C = 1 আর D = 1 fixed থাকে → term CD।
হলুদ group (উপরের row: m₀(X), m₁, m₃, m₂(X)): দুইটা don't-care ব্যবহার করে 4-এর group। A = 0, B = 0 fixed → term A′B′।
m₅-এর X দরকার নেই, তাই ওটাকে 0 ধরি।
উত্তর: F = CD + A′B′। (* চিহ্নের cell-টা দুই group-এই আছে — overlap-এ সমস্যা নেই।)
Worked example 3 (4 variables — real BUET question)Worked example 3 (4 variable — আসল BUET প্রশ্ন)
Step 1 — fill the map. Rows are WX (Gray order 00, 01, 11, 10), columns are YZ. Put 1 at minterms 6, 7, 8, 9 and X at don't-cares 3, 4, 5:
Step 1 — map পূরণ করি। Row হলো WX (Gray order 00, 01, 11, 10), column হলো YZ। Minterm 6, 7, 8, 9-এ 1 বসাই আর don't-care 3, 4, 5-এ X:
| F | YZ=00 | YZ=01 | YZ=11 | YZ=10 |
|---|---|---|---|---|
| WX=00 | 0 | 0 | X | 0 |
| WX=01 | X | X | 1 | 1 |
| WX=11 | 0 | 0 | 0 | 0 |
| WX=10 | 1 | 1 | 0 | 0 |
Step 2 — make the groups as big as possible.
- Green group (whole row WX=01): m₄(X), m₅(X), m₇(1), m₆(1) — a group of 4. The two don't-cares make the pair m₆, m₇ grow into a full row. In all four cells W = 0 and X = 1, while Y and Z both change → term W′X.
- Blue group (m₈, m₉): a pair. W = 1, X = 0, Y = 0 stay fixed, only Z changes → term WX′Y′. No neighbor can make it a group of 4 (m₁₀, m₁₁, m₁₂, m₁₃ are all 0).
- The don't-care at m₃ is not needed — leave it as 0.
Answer: F = W′X + WX′Y′.
Check: m₆ (0110): W′X = 1 ✓. m₇ (0111): W′X = 1 ✓. m₈ (1000): WX′Y′ = 1 ✓. m₉ (1001): WX′Y′ = 1 ✓. No extra 1s outside the list (besides don't-cares) ✓.
Step 2 — group যত বড় সম্ভব করি।
- সবুজ group (পুরো row WX=01): m₄(X), m₅(X), m₇(1), m₆(1) — 4-এর group। দুইটা don't-care-এর কল্যাণে m₆, m₇ pair-টা পুরো row হয়ে গেল। চার cell-এই W = 0 আর X = 1, আর Y ও Z দুটোই বদলায় → term W′X।
- নীল group (m₈, m₉): একটা pair। W = 1, X = 0, Y = 0 fixed থাকে, শুধু Z বদলায় → term WX′Y′। কোনো neighbor দিয়েই এটাকে 4-এর group করা যায় না (m₁₀, m₁₁, m₁₂, m₁₃ সবই 0)।
- m₃-এর don't-care-টা দরকার নেই — 0 ধরি।
উত্তর: F = W′X + WX′Y′।
Check: m₆ (0110): W′X = 1 ✓। m₇ (0111): W′X = 1 ✓। m₈ (1000): WX′Y′ = 1 ✓। m₉ (1001): WX′Y′ = 1 ✓। List-এর বাইরে (don't-care ছাড়া) কোনো বাড়তি 1 নেই ✓।
Full flow: truth table → K-map → minimal SOP → circuitপুরো flow: truth table → K-map → minimal SOP → circuit
Step 1 — truth table:
Step 1 — truth table:
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
So F = Σm(3, 5, 6, 7). Step 2 — K-map:
তাহলে F = Σm(3, 5, 6, 7)। Step 2 — K-map:
| F | BC=00 | BC=01 | BC=11 | BC=10 |
|---|---|---|---|---|
| A=0 | 0 | 0 | 1 | 0 |
| A=1 | 0 | 1 | 1 | 1 |
Step 3 — groups: three pairs, each including m₇ (red cell):
- m₃ + m₇ (green + red): B and C stay 1 → BC.
- m₅ + m₇ (blue + red): A and C stay 1 → AC.
- m₆ + m₇ (yellow + red): A and B stay 1 → AB.
Minimal SOP: F = AB + BC + CA.
Step 4 — circuit: three 2-input AND gates feeding one 3-input OR gate.
Step 3 — group: তিনটা pair, প্রতিটাতে m₇ (লাল cell) আছে:
- m₃ + m₇ (সবুজ + লাল): B আর C = 1 থাকে → BC।
- m₅ + m₇ (নীল + লাল): A আর C = 1 থাকে → AC।
- m₆ + m₇ (হলুদ + লাল): A আর B = 1 থাকে → AB।
Minimal SOP: F = AB + BC + CA।
Step 4 — circuit: তিনটা 2-input AND gate একটা 3-input OR gate-এ যাবে।
4. Combinational Circuits4. Combinational Circuits
A combinational circuit has no memory. Its output depends only on the current inputs. Adders, multiplexers, decoders, encoders and comparators are all combinational.
Combinational circuit-এর কোনো memory নেই। এর output শুধু current input-এর উপর নির্ভর করে। Adder, multiplexer, decoder, encoder আর comparator সবই combinational।
Half AdderHalf Adder
A half adder adds two 1-bit numbers A and B. It gives a Sum and a Carry.
Half adder দুইটা 1-bit সংখ্যা A আর B যোগ করে। এটা একটা Sum আর একটা Carry দেয়।
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Full AdderFull Adder
A full adder adds three bits: A, B, and a carry-in (Cin). It is the building block of real adders.
Full adder তিনটা bit যোগ করে: A, B আর একটা carry-in (Cin)। আসল adder-এর building block এটাই।
| A | B | Cin | Sum | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
A full adder = two half adders + one OR gate. The first half adder adds A and B. The second adds that sum with Cin. The OR combines the two carries.
Full adder = দুইটা half adder + একটা OR gate। প্রথম half adder-টা A আর B যোগ করে। দ্বিতীয়টা সেই sum-এর সাথে Cin যোগ করে। OR gate দুইটা carry মেলায়।
Ripple Carry AdderRipple Carry Adder
To add two 4-bit numbers, chain four full adders. The carry-out of each stage goes to the carry-in of the next stage. The carry "ripples" from right to left — so the last sum bit must wait for all earlier carries. This makes the ripple carry adder simple but slow. (Faster designs use carry look-ahead.)
দুইটা 4-bit সংখ্যা যোগ করতে চারটা full adder-কে chain করা হয়। প্রতিটা stage-এর carry-out পরের stage-এর carry-in-এ যায়। Carry ডান থেকে বামে "ripple" করে — তাই শেষ sum bit-কে আগের সব carry-র জন্য অপেক্ষা করতে হয়। এজন্য ripple carry adder সহজ কিন্তু slow। (দ্রুত design-এ carry look-ahead ব্যবহার হয়।)
Half and Full SubtractorHalf আর Full Subtractor
A half subtractor computes A − B: a Difference and a Borrow. A full subtractor also takes a borrow-in (Bin).
Half subtractor A − B বের করে: একটা Difference আর একটা Borrow। Full subtractor একটা borrow-in (Bin)-ও নেয়।
| A | B | D | Bout |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
Multiplexer (MUX)Multiplexer (MUX)
A multiplexer is a data selector. A 4:1 MUX has 4 data inputs (I₀–I₃), 2 select lines (S₁S₀), and 1 output. The select lines choose which input reaches the output.
Multiplexer হলো data selector। একটা 4:1 MUX-এ থাকে 4টা data input (I₀–I₃), 2টা select line (S₁S₀) আর 1টা output। Select line ঠিক করে কোন input output-এ যাবে।
| S₁ | S₀ | Y |
|---|---|---|
| 0 | 0 | I₀ |
| 0 | 1 | I₁ |
| 1 | 0 | I₂ |
| 1 | 1 | I₃ |
A 2ⁿ:1 MUX needs n select lines. General rule: a function of n variables can be built with a 2ⁿ⁻¹:1 MUX — put n−1 variables on the select lines, and feed each input with 0, 1, the last variable, or its complement.
একটা 2ⁿ:1 MUX-এ n-টা select line লাগে। General নিয়ম: n variable-এর function একটা 2ⁿ⁻¹:1 MUX দিয়ে বানানো যায় — n−1টা variable select line-এ দাও, আর প্রতিটা input-এ দাও 0, 1, শেষ variable-টা, বা তার complement।
Group the minterms by the AB value, and see what F does as C changes:
| A B | C=0 (minterm) | C=1 (minterm) | Input value |
|---|---|---|---|
| 0 0 | m₀: F=0 | m₁: F=1 | I₀ = C |
| 0 1 | m₂: F=1 | m₃: F=0 | I₁ = C′ |
| 1 0 | m₄: F=0 | m₅: F=0 | I₂ = 0 |
| 1 1 | m₆: F=1 | m₇: F=1 | I₃ = 1 |
So connect: I₀ = C, I₁ = C′, I₂ = 0, I₃ = 1. Done — no extra gates except one NOT.
AB-এর value ধরে minterm গুলো ভাগ করি, আর দেখি C বদলালে F কী করে:
| A B | C=0 (minterm) | C=1 (minterm) | Input value |
|---|---|---|---|
| 0 0 | m₀: F=0 | m₁: F=1 | I₀ = C |
| 0 1 | m₂: F=1 | m₃: F=0 | I₁ = C′ |
| 1 0 | m₄: F=0 | m₅: F=0 | I₂ = 0 |
| 1 1 | m₆: F=1 | m₇: F=1 | I₃ = 1 |
তাহলে connect করি: I₀ = C, I₁ = C′, I₂ = 0, I₃ = 1। শেষ — একটা NOT ছাড়া আর কোনো gate লাগেনি।
Demultiplexer (DEMUX)Demultiplexer (DEMUX)
A demultiplexer is the opposite of a MUX: 1 data input, n select lines, 2ⁿ outputs. The select lines choose which output receives the input. A 1:4 DEMUX: Y₀ = S₁′S₀′D, Y₁ = S₁′S₀D, Y₂ = S₁S₀′D, Y₃ = S₁S₀D. A DEMUX is really a decoder with an enable input used as the data line.
Demultiplexer হলো MUX-এর উল্টো: 1টা data input, nটা select line, 2ⁿটা output। Select line ঠিক করে কোন output-এ input যাবে। 1:4 DEMUX: Y₀ = S₁′S₀′D, Y₁ = S₁′S₀D, Y₂ = S₁S₀′D, Y₃ = S₁S₀D। আসলে DEMUX হলো একটা decoder, যার enable input-টাকে data line হিসেবে ব্যবহার করা হয়।
DecoderDecoder
An n-to-2ⁿ decoder turns on exactly one of its 2ⁿ outputs — the one whose number matches the input. A 3:8 decoder gives all 8 minterms of the 3 inputs: output Dᵢ = mᵢ.
Implementing functions: since a decoder produces every minterm, any function = OR of the right decoder outputs. One decoder + a few OR gates can build several functions at once.
একটা n-to-2ⁿ decoder তার 2ⁿটা output-এর মধ্যে ঠিক একটা on করে — যেটার নম্বর input-এর সাথে মেলে। 3:8 decoder ৩টা input-এর সব ৮টা minterm দেয়: output Dᵢ = mᵢ।
Function implement করা: decoder যেহেতু সব minterm বানায়, তাই যেকোনো function = দরকারি decoder output গুলোর OR। একটা decoder + কয়েকটা OR gate দিয়ে একসাথে কয়েকটা function বানানো যায়।
From the full adder truth table: S = Σm(1, 2, 4, 7) and Cout = Σm(3, 5, 6, 7).
So: S = OR of decoder outputs D₁, D₂, D₄, D₇. Cout = OR of D₃, D₅, D₆, D₇. Done.
Full adder-এর truth table থেকে: S = Σm(1, 2, 4, 7) আর Cout = Σm(3, 5, 6, 7)।
তাহলে: S = decoder output D₁, D₂, D₄, D₇-এর OR। Cout = D₃, D₅, D₆, D₇-এর OR। শেষ।
Step 1 — write XOR as minterms. A ⊕ B = Σm(1, 2). A high-active (active-HIGH) 2:4 decoder gives all four minterms: D₀ = A′B′, D₁ = A′B, D₂ = AB′, D₃ = AB.
| A | B | D₀ | D₁ | D₂ | D₃ | A⊕B |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 0 |
Step 2 — the easy way (if an OR gate were given): A⊕B = m₁ + m₂ = D₁ + D₂. Just OR those two outputs.
Step 3 — but the question gives a NOR gate. Key fact: for any input, exactly one decoder output is 1. So D₁ + D₂ = 1 happens exactly when D₀ = 0 and D₃ = 0. In other words:
A ⊕ B = (m₀ + m₃)′ = NOR(D₀, D₃)
Answer: put A, B on the decoder select inputs (enable tied HIGH), and feed D₀ and D₃ into the NOR gate. The NOR output is A ⊕ B. Check the table: NOR(D₀, D₃) = 0, 1, 1, 0 down the rows — exactly the XOR column. ✓
Step 1 — XOR-কে minterm আকারে লিখি। A ⊕ B = Σm(1, 2)। একটা high-active (active-HIGH) 2:4 decoder সব চারটা minterm দেয়: D₀ = A′B′, D₁ = A′B, D₂ = AB′, D₃ = AB।
| A | B | D₀ | D₁ | D₂ | D₃ | A⊕B |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 0 |
Step 2 — সহজ পথ (OR gate দেওয়া থাকলে): A⊕B = m₁ + m₂ = D₁ + D₂। ওই দুই output-কে শুধু OR করলেই হতো।
Step 3 — কিন্তু প্রশ্নে NOR gate দেওয়া। Key fact: যেকোনো input-এ decoder-এর ঠিক একটা output 1 হয়। তাই D₁ + D₂ = 1 হয় ঠিক তখনই, যখন D₀ = 0 আর D₃ = 0। মানে:
A ⊕ B = (m₀ + m₃)′ = NOR(D₀, D₃)
উত্তর: A, B-কে decoder-এর select input-এ দাও (enable HIGH-তে বাঁধা), আর D₀ ও D₃-কে NOR gate-এ দাও। NOR-এর output-ই A ⊕ B। Table দিয়ে check: NOR(D₀, D₃) = row ধরে 0, 1, 1, 0 — ঠিক XOR column-টাই। ✓
Encoder and Priority EncoderEncoder আর Priority Encoder
An encoder is the opposite of a decoder: 2ⁿ inputs, n outputs. It outputs the binary number of the active input. Problem: what if two inputs are active at once? A priority encoder fixes this — the highest-numbered active input wins. It also has a valid bit (V) that is 1 when at least one input is active.
Encoder হলো decoder-এর উল্টো: 2ⁿটা input, nটা output। যে input active, তার binary নম্বরটা output দেয়। সমস্যা: একসাথে দুইটা input active হলে কী হবে? Priority encoder এটা সমাধান করে — সবচেয়ে বড় নম্বরের active input জেতে। এতে একটা valid bit (V)-ও থাকে, অন্তত একটা input active হলে যেটা 1 হয়।
| 4:2 priority encoder (X = don't care)4:2 priority encoder (X = don't care) | Y₁ | Y₀ | V | |||
|---|---|---|---|---|---|---|
| D₃ | D₂ | D₁ | D₀ | |||
| 0 | 0 | 0 | 0 | X | X | 0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | X | 0 | 1 | 1 |
| 0 | 1 | X | X | 1 | 0 | 1 |
| 1 | X | X | X | 1 | 1 | 1 |
Comparator (briefly)Comparator (সংক্ষেপে)
A comparator compares two numbers. For 1-bit inputs A and B:
- A > B when A=1, B=0 → output AB′
- A = B when bits match → output XNOR: (A⊕B)′
- A < B when A=0, B=1 → output A′B
Multi-bit comparators compare from the MSB down: the first different bit decides.
Comparator দুইটা সংখ্যা তুলনা করে। 1-bit input A আর B-এর জন্য:
- A > B যখন A=1, B=0 → output AB′
- A = B যখন bit মিলে যায় → output XNOR: (A⊕B)′
- A < B যখন A=0, B=1 → output A′B
Multi-bit comparator MSB থেকে নিচে তুলনা করে: প্রথম যে bit আলাদা, সেটাই সিদ্ধান্ত দেয়।
Identify the Circuit from a Truth Table (Real Exam!)Truth Table দেখে Circuit চেনা (Real Exam!)
Sometimes the exam gives you only a truth table and asks: "which circuit is this?" Do not panic — run this simple checklist:
- Count inputs and outputs first. This alone removes most wrong guesses. n inputs and 2ⁿ outputs → think decoder. Many data inputs plus select lines and 1 output → think MUX. 2 or 3 inputs with 2 outputs → think adder family.
- Two outputs, one looks like XOR and one looks like "majority"? That pair is Sum + Carry → it is an adder (half adder for 2 inputs, full adder for 3).
- Exactly one output is 1 in every row (one-hot)? → decoder (or demultiplexer).
- The output just copies one chosen input, picked by the select lines? → multiplexer.
- One output that is 1 when the count of 1s is odd (a pure XOR column)? → parity generator/checker. Output 1 only when the inputs are equal → comparator (XNOR).
মাঝে মাঝে exam-এ শুধু একটা truth table দিয়ে জিজ্ঞেস করে: "এটা কোন circuit?" ঘাবড়িও না — এই সহজ checklist-টা চালাও:
- আগে input আর output গোনো। এতেই বেশিরভাগ ভুল guess বাদ পড়ে। nটা input আর 2ⁿটা output → decoder ভাবো। অনেকগুলো data input + select line আর 1টা output → MUX ভাবো। 2 বা 3টা input আর 2টা output → adder family ভাবো।
- দুইটা output, একটা XOR-এর মতো আর একটা "majority"-র মতো? এই জোড়া হলো Sum + Carry → এটা adder (2 input হলে half adder, 3 input হলে full adder)।
- প্রতি row-তে ঠিক একটা output-ই 1 (one-hot)? → decoder (বা demultiplexer)।
- Select line দিয়ে বাছাই করা একটা input-কে output শুধু copy করে? → multiplexer।
- একটা output, যেটা 1-এর সংখ্যা odd হলে 1 (পুরোপুরি XOR column)? → parity generator/checker। Input দুটো সমান হলেই শুধু output 1 → comparator (XNOR)।
| X | Y | Z | S | C |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Walk the checklist: 3 inputs, 2 outputs → adder family suspect. Look at S: it is 1 exactly when the number of 1s in the inputs is odd → S = X ⊕ Y ⊕ Z. Look at C: it is 1 when two or more inputs are 1 (rows 011, 101, 110, 111) → C = XY + YZ + XZ, the majority function.
Sum = 3-input XOR and Carry = majority — that is exactly a full adder: S is the sum bit, C is the carry-out. Done.
Checklist ধরে চলো: 3টা input, 2টা output → adder family সন্দেহ। S দেখো: input-এ 1-এর সংখ্যা odd হলেই S = 1 → S = X ⊕ Y ⊕ Z। C দেখো: দুই বা তার বেশি input 1 হলে C = 1 (row 011, 101, 110, 111) → C = XY + YZ + XZ, মানে majority function।
Sum = 3-input XOR আর Carry = majority — এটা হুবহু একটা full adder: S হলো sum bit, C হলো carry-out। শেষ।
5. Flip-Flops5. Flip-Flops
A sequential circuit has memory. Its output depends on the inputs and the current state. The basic memory elements are latches and flip-flops — each stores 1 bit.
- Latch: level-sensitive. While the enable/clock is high, the output follows the inputs the whole time.
- Flip-flop: edge-triggered. The output can change only at a clock edge (rising ↑ or falling ↓). The rest of the time it holds its value.
Notation: Q = present state, Q⁺ (or Q(t+1)) = next state.
Sequential circuit-এর memory আছে। এর output নির্ভর করে input আর current state — দুটোর উপরেই। Basic memory element হলো latch আর flip-flop — প্রতিটা 1 bit রাখে।
- Latch: level-sensitive। Enable/clock high থাকা পুরো সময়টা output input-কে follow করে।
- Flip-flop: edge-triggered। Output শুধু clock edge-এ (rising ↑ বা falling ↓) বদলাতে পারে। বাকি সময় value ধরে রাখে।
Notation: Q = present state, Q⁺ (বা Q(t+1)) = next state।
SR Latch (with NOR gates)SR Latch (NOR gate দিয়ে)
Two cross-coupled NOR gates make an SR latch. S = set (make Q = 1), R = reset (make Q = 0).
দুইটা cross-coupled NOR gate মিলে একটা SR latch হয়। S = set (Q = 1 করা), R = reset (Q = 0 করা)।
| S | R | Q⁺ | Meaningমানে |
|---|---|---|---|
| 0 | 0 | Q | hold (no change)hold (কোনো change নেই) |
| 1 | 0 | 1 | setset |
| 0 | 1 | 0 | resetreset |
| 1 | 1 | — | invalid / forbiddeninvalid / নিষিদ্ধ |
S = R = 1 is forbidden: both outputs go 0 (they should be complements), and when S, R return to 0 the final state is unpredictable — it becomes a race.
S = R = 1 নিষিদ্ধ: দুই output-ই 0 হয়ে যায় (অথচ তাদের complement হওয়ার কথা), আর S, R আবার 0 হলে শেষ state কী হবে বলা যায় না — race হয়ে যায়।
Clocked SR, D, JK, T — the four flip-flopsClocked SR, D, JK, T — চারটা flip-flop
A clocked SR flip-flop adds a clock: S and R work only when the clock allows. It still has the invalid S=R=1 problem.
A D flip-flop fixes the invalid state: it has one input D, and R is just D′ inside. At the clock edge, Q simply copies D. Characteristic equation: Q⁺ = D. It is the standard 1-bit storage cell.
A JK flip-flop is an SR where J=K=1 is allowed and means toggle (Q flips). Characteristic equation: Q⁺ = JQ′ + K′Q.
A T flip-flop has one input T: T=0 holds, T=1 toggles. Characteristic equation: Q⁺ = T ⊕ Q. Make one by tying J = K = T. Toggling divides the clock frequency by 2, so T flip-flops build counters.
Clocked SR flip-flop-এ একটা clock যোগ হয়: S আর R শুধু clock অনুমতি দিলে কাজ করে। কিন্তু S=R=1-এর invalid সমস্যাটা থেকেই যায়।
D flip-flop সেই invalid state ঠিক করে: এতে একটাই input D, আর ভিতরে R = D′। Clock edge-এ Q শুধু D-কে copy করে। Characteristic equation: Q⁺ = D। এটাই standard 1-bit storage cell।
JK flip-flop হলো এমন SR যেখানে J=K=1 allowed, আর তার মানে toggle (Q উল্টে যায়)। Characteristic equation: Q⁺ = JQ′ + K′Q।
T flip-flop-এ একটা input T: T=0 মানে hold, T=1 মানে toggle। Characteristic equation: Q⁺ = T ⊕ Q। J = K = T জুড়ে দিলেই T flip-flop হয়। Toggle করলে clock frequency অর্ধেক হয়, তাই T flip-flop দিয়ে counter বানানো হয়।
| SR | JK | D | T | ||||
|---|---|---|---|---|---|---|---|
| S R | Q⁺ | J K | Q⁺ | D | Q⁺ | T | Q⁺ |
| 0 0 | Q | 0 0 | Q | 0 | 0 | 0 | Q |
| 0 1 | 0 | 0 1 | 0 | 1 | 1 | 1 | Q′ |
| 1 0 | 1 | 1 0 | 1 | ||||
| 1 1 | — | 1 1 | Q′ | ||||
Excitation tables (needed for design — memorize!)Excitation table (design-এর জন্য লাগবেই — মুখস্থ করো!)
A characteristic table answers: "given the inputs, what is Q⁺?" An excitation table answers the reverse design question: "I want to go from Q to Q⁺ — what inputs do I need?"
Characteristic table বলে: "input দিলে Q⁺ কী হবে?" আর excitation table উল্টো design প্রশ্নের উত্তর দেয়: "Q থেকে Q⁺-তে যেতে চাই — কী input লাগবে?"
| Q → Q⁺ | S R | J K | D | T |
|---|---|---|---|---|
| 0 → 0 | 0 X | 0 X | 0 | 0 |
| 0 → 1 | 1 0 | 1 X | 1 | 1 |
| 1 → 0 | 0 1 | X 1 | 0 | 1 |
| 1 → 1 | X 0 | X 0 | 1 | 0 |
Race-around condition and master-slave JKRace-around condition আর master-slave JK
Race-around: in a level-triggered JK flip-flop with J = K = 1, the output toggles once, but the clock is still high — so it toggles again, and again, many times in one clock pulse. The final value is unpredictable.
It happens when the clock pulse width is much longer than the propagation delay of the flip-flop.
Fixes:
- Master-slave JK: two latches in series. The master reads the inputs while the clock is high; the slave copies the master when the clock goes low. The output changes only once per clock pulse.
- Edge-triggered JK: respond only to the narrow moment of the clock edge (the modern fix).
Race-around: level-triggered JK flip-flop-এ J = K = 1 হলে output একবার toggle করে, কিন্তু clock তখনও high — তাই আবার toggle করে, আবারও — এক clock pulse-এর মধ্যে অনেকবার। শেষ value কী হবে বলা যায় না।
এটা তখনই হয় যখন clock pulse-এর width flip-flop-এর propagation delay-র চেয়ে অনেক বড়।
সমাধান:
- Master-slave JK: দুইটা latch পরপর। Clock high থাকলে master input পড়ে; clock low হলে slave master-কে copy করে। প্রতি clock pulse-এ output মাত্র একবার বদলায়।
- Edge-triggered JK: শুধু clock edge-এর সরু মুহূর্তটায় respond করে (আধুনিক সমাধান)।
Edge vs level triggeringEdge vs level triggering
| Level-triggered (latch)Level-triggered (latch) | Edge-triggered (flip-flop)Edge-triggered (flip-flop) | |
|---|---|---|
| RespondsRespond করে | whole time clock is high (or low)clock high (বা low) থাকার পুরো সময় | only at the rising ↑ or falling ↓ edgeশুধু rising ↑ বা falling ↓ edge-এ |
| SymbolSymbol | plain clock inputসাধারণ clock input | triangle (▷) at the clock pin; a bubble too if falling-edgeclock pin-এ triangle (▷); falling-edge হলে সাথে bubble |
| Problemসমস্যা | transparent — race-around possibletransparent — race-around হতে পারে | safe — output changes once per edgesafe — প্রতি edge-এ একবারই output বদলায় |
Flip-flop conversion (worked example)Flip-flop conversion (worked example)
Step 1: write the desired behavior (D flip-flop) and, for each row, look up the JK inputs from the JK excitation table:
| D | Q | Q⁺ | J | K |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | X |
| 0 | 1 | 0 | X | 1 |
| 1 | 0 | 1 | 1 | X |
| 1 | 1 | 1 | X | 0 |
Step 2: solve J and K as functions of D and Q (tiny K-maps):
J: 1 when D=1,Q=0; X when Q=1 → J = D.
K: 1 when D=0,Q=1; X when Q=0 → K = D′.
Step 3: circuit — feed D to J, and D through a NOT gate to K.
Step 1: কাঙ্ক্ষিত behavior (D flip-flop) লিখি, আর প্রতিটা row-এর জন্য JK excitation table থেকে JK input বসাই:
| D | Q | Q⁺ | J | K |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | X |
| 0 | 1 | 0 | X | 1 |
| 1 | 0 | 1 | 1 | X |
| 1 | 1 | 1 | X | 0 |
Step 2: D আর Q-এর function হিসেবে J আর K বের করি (ছোট K-map):
J: D=1,Q=0 হলে 1; Q=1 হলে X → J = D।
K: D=0,Q=1 হলে 1; Q=0 হলে X → K = D′।
Step 3: circuit — D-কে J-তে দাও, আর D-কে একটা NOT gate দিয়ে K-তে দাও।
Other useful conversions (same method): JK → T: tie J = K = T. D → T: D = T ⊕ Q. T → D: T = D ⊕ Q.
আরও দরকারি conversion (একই পদ্ধতি): JK → T: J = K = T জুড়ে দাও। D → T: D = T ⊕ Q। T → D: T = D ⊕ Q।
Clock Division with D Flip-Flops (Real Exam!)D Flip-Flop দিয়ে Clock Division (Real Exam!)
Here is a trick every D flip-flop hides: connect D = Q′ (feed the inverted output back to the input). Now at every active clock edge, Q copies its own opposite — so Q toggles on every edge.
Think about what toggling means for frequency. The input clock makes one full cycle per period. But Q needs two clock edges (one to go high, one to go low) to finish one of its own cycles. So:
প্রতিটা D flip-flop-এর ভিতরে একটা trick লুকানো আছে: D = Q′ connect করো (inverted output-টা input-এ ফেরত দাও)। এখন প্রতিটা active clock edge-এ Q তার নিজের উল্টোটা copy করে — মানে Q প্রতি edge-এ toggle করে।
Toggle করা মানে frequency-র জন্য কী, ভাবো। Input clock প্রতি period-এ একটা পুরো cycle দেয়। কিন্তু Q-এর নিজের একটা cycle শেষ করতে দুইটা clock edge লাগে (একটায় high, আরেকটায় low)। তাই:
The October 2017 question: convert a 100 MHz clock to 50 MHz and 25 MHz using only D flip-flops.
- FF1: clock it with the 100 MHz input, tie D₁ = Q₁′. Q₁ toggles every edge → Q₁ is a clean 50 MHz square wave.
- FF2: use Q₁ as the clock of FF2, tie D₂ = Q₂′. Q₂ toggles on every edge of Q₁ → Q₂ is 25 MHz.
That is the whole answer: two D flip-flops in series, each with its own Q′ wired back to its D. Take 50 MHz from Q₁ and 25 MHz from Q₂. Each stage also outputs a perfect 50% duty cycle — a bonus you can mention.
October 2017-এর প্রশ্ন: শুধু D flip-flop দিয়ে 100 MHz clock-কে 50 MHz আর 25 MHz-এ convert করো।
- FF1: 100 MHz input দিয়ে clock দাও, D₁ = Q₁′ বেঁধে দাও। Q₁ প্রতি edge-এ toggle করে → Q₁ হলো পরিষ্কার 50 MHz square wave।
- FF2: Q₁-কে FF2-এর clock বানাও, D₂ = Q₂′ বেঁধে দাও। Q₂ Q₁-এর প্রতি edge-এ toggle করে → Q₂ হলো 25 MHz।
এটাই পুরো উত্তর: দুইটা D flip-flop পরপর, প্রতিটার নিজের Q′ তার নিজের D-তে ফেরত। Q₁ থেকে 50 MHz আর Q₂ থেকে 25 MHz নাও। প্রতিটা stage-এর output-এ duty cycle-ও ঠিক 50% হয় — এটা বললে extra credit।
Follow the toggles edge by edge (FF1 clocked by CLK rising edges, FF2 clocked by Q₁ rising edges):
Edge ধরে ধরে toggle গুলো follow করো (FF1 পায় CLK-এর rising edge, FF2 পায় Q₁-এর rising edge):
| CLK rising edgeCLK rising edge | startশুরু | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|---|
| Q₁ (50 MHz) | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
| Q₂ (25 MHz) | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
Read the table: Q₁ completes one cycle every 2 CLK periods (half frequency), and Q₂ toggles only when Q₁ rises (edges 1, 3, 5, 7) — one cycle every 4 CLK periods, a quarter of the frequency. ✓
Table-টা পড়ো: Q₁ প্রতি 2টা CLK period-এ একটা cycle শেষ করে (অর্ধেক frequency), আর Q₂ শুধু Q₁ rise করলে toggle করে (edge 1, 3, 5, 7) — প্রতি 4টা CLK period-এ একটা cycle, মানে frequency-র এক-চতুর্থাংশ। ✓
6. Counters and Registers6. Counters and Registers
Asynchronous (ripple) counterAsynchronous (ripple) counter
A ripple counter uses T (or JK with J=K=1) flip-flops in a chain. Only the first flip-flop gets the clock. Each next flip-flop is clocked by the output of the previous one. Each stage divides the frequency by 2.
Look at the waveform below for a 3-bit ripple counter (negative-edge triggered):
- Q₀ toggles on every falling edge of CLK → half the frequency.
- Q₁ toggles on every falling edge of Q₀ → one quarter.
- Q₂ toggles on every falling edge of Q₁ → one eighth.
- Reading Q₂Q₁Q₀ gives 000, 001, 010, … 111, 000 — it counts 0 to 7 (mod-8).
Ripple counter-এ T (বা J=K=1 করা JK) flip-flop গুলো chain করা থাকে। শুধু প্রথম flip-flop clock পায়। পরের প্রতিটা flip-flop-এর clock আসে আগেরটার output থেকে। প্রতিটা stage frequency অর্ধেক করে।
নিচের waveform-টা দেখো — 3-bit ripple counter (negative-edge triggered):
- Q₀ CLK-এর প্রতিটা falling edge-এ toggle করে → frequency অর্ধেক।
- Q₁ Q₀-এর প্রতিটা falling edge-এ toggle করে → এক-চতুর্থাংশ।
- Q₂ Q₁-এর প্রতিটা falling edge-এ toggle করে → এক-অষ্টমাংশ।
- Q₂Q₁Q₀ পড়লে পাই 000, 001, 010, … 111, 000 — মানে 0 থেকে 7 গোনে (mod-8)।
Mod-N with reset: to make a mod-6 counter from a mod-8 ripple counter, detect the count 6 (110) with a NAND on Q₂ and Q₁, and use its output to clear all flip-flops. The counter then runs 0–5.
Drawback: the clock ripples through the chain, so delays add up: total delay = n × tpd. At high speed, the outputs can be read while still changing — glitches.
Reset দিয়ে mod-N: mod-8 ripple counter থেকে mod-6 বানাতে, count 6 (110)-কে Q₂ আর Q₁-এর উপর একটা NAND দিয়ে detect করো, আর তার output দিয়ে সব flip-flop clear করো। তখন counter 0–5 গোনে।
অসুবিধা: clock টা chain-এর ভিতর দিয়ে ripple করে, তাই delay জমতে থাকে: মোট delay = n × tpd। বেশি speed-এ output বদলাতে বদলাতেই পড়া হয়ে যেতে পারে — glitch হয়।
Synchronous counter design (BUET favorite — full worked example)Synchronous counter design (BUET favorite — পুরো worked example)
In a synchronous counter every flip-flop gets the same clock. Logic gates decide which ones toggle. No ripple delay.
Design a mod-8 (3-bit) up counter with JK flip-flops.
Step 1: write the state sequence: 000 → 001 → 010 → 011 → 100 → 101 → 110 → 111 → 000.
Step 2: build the excitation table. For each bit, compare Q with Q⁺ and use the JK excitation table (0→0: J=0,K=X; 0→1: J=1,K=X; 1→0: J=X,K=1; 1→1: J=X,K=0):
Synchronous counter-এ প্রতিটা flip-flop একই clock পায়। কোনটা toggle করবে তা ঠিক করে logic gate। কোনো ripple delay নেই।
JK flip-flop দিয়ে একটা mod-8 (3-bit) up counter design করি।
Step 1: state sequence লিখি: 000 → 001 → 010 → 011 → 100 → 101 → 110 → 111 → 000।
Step 2: excitation table বানাই। প্রতিটা bit-এর জন্য Q আর Q⁺ তুলনা করে JK excitation table বসাই (0→0: J=0,K=X; 0→1: J=1,K=X; 1→0: J=X,K=1; 1→1: J=X,K=0):
| PresentPresent | NextNext | FF2 | FF1 | FF0 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Q₂ | Q₁ | Q₀ | Q₂⁺ | Q₁⁺ | Q₀⁺ | J₂ | K₂ | J₁ | K₁ | J₀ | K₀ |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | X | 0 | X | 1 | X |
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | X | 1 | X | X | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 | 0 | X | X | 0 | 1 | X |
| 0 | 1 | 1 | 1 | 0 | 0 | 1 | X | X | 1 | X | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | X | 0 | 0 | X | 1 | X |
| 1 | 0 | 1 | 1 | 1 | 0 | X | 0 | 1 | X | X | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | X | 0 | X | 0 | 1 | X |
| 1 | 1 | 1 | 0 | 0 | 0 | X | 1 | X | 1 | X | 1 |
Step 3: simplify each input with a K-map (variables Q₂, Q₁, Q₀):
- J₀ and K₀ are 1 or X in every row → J₀ = K₀ = 1 (bit 0 always toggles).
- J₁ is 1 exactly when Q₀ = 1 (rows 001, 101), X elsewhere possible → J₁ = K₁ = Q₀.
- J₂ is 1 at 011, X at 1xx → group gives J₂ = K₂ = Q₁Q₀.
Step 4: circuit — three JK flip-flops on one clock; J₀=K₀=1; J₁=K₁=Q₀; J₂=K₂ = AND of Q₁, Q₀.
Pattern to remember: for a binary up counter, each bit toggles when all lower bits are 1. So Jₙ = Kₙ = Q₀Q₁…Qₙ₋₁.
Step 3: প্রতিটা input K-map দিয়ে simplify করি (variable Q₂, Q₁, Q₀):
- J₀ আর K₀ প্রতিটা row-তে 1 বা X → J₀ = K₀ = 1 (bit 0 সবসময় toggle করে)।
- J₁ ঠিক তখনই 1 যখন Q₀ = 1 (row 001, 101), বাকিতে X → J₁ = K₁ = Q₀।
- J₂ 011-তে 1, 1xx-এ X → group করলে J₂ = K₂ = Q₁Q₀।
Step 4: circuit — তিনটা JK flip-flop এক clock-এ; J₀=K₀=1; J₁=K₁=Q₀; J₂=K₂ = Q₁ আর Q₀-এর AND।
মনে রাখার pattern: binary up counter-এ কোনো bit toggle করে যখন তার নিচের সব bit 1। তাই Jₙ = Kₙ = Q₀Q₁…Qₙ₋₁।
A MOD-12 counter counts 0000 → 0001 → … → 1011 (11) → back to 0000. Minimum flip-flops: ⌈log₂12⌉ = 4 (outputs Q₃Q₂Q₁Q₀).
Design (ripple + reset — the quick exam answer):
- Tie T = 1 on all four T flip-flops, so every flip-flop toggles when clocked.
- Chain them as a ripple counter: CLK drives FF0; Q₀ clocks FF1; Q₁ clocks FF2; Q₂ clocks FF3. By itself this is a mod-16 counter.
- Detect the first unwanted count, 12 = 1100: feed Q₃ and Q₂ into a NAND gate, and connect its output to the active-LOW CLEAR of all four flip-flops.
- The moment the counter reaches 1100, the NAND output drops to 0 and clears everything to 0000. So the visible count is 0 to 11 — exactly 12 states.
Why NAND on Q₃ and Q₂ only? 1100 is the first time Q₃ and Q₂ are both 1 (12 comes before 13, 14, 15), so checking just these two bits is enough.
Synchronous version (if the question bans ripple delay): give all flip-flops one common clock and derive T inputs from the excitation table (T = 1 when the bit must change; states 12–15 are don't-cares):
T₀ = 1; T₁ = Q₀; T₂ = Q₃′Q₁Q₀; T₃ = Q₁Q₀(Q₂ + Q₃)
Quick check at 1011 (11): T₀=1, T₁=1, T₂ = 0 (Q₃=1 blocks it), T₃ = 1·(0+1) = 1 → next state 0000 ✓.
MOD-12 counter গোনে 0000 → 0001 → … → 1011 (11) → আবার 0000। Minimum flip-flop: ⌈log₂12⌉ = 4টা (output Q₃Q₂Q₁Q₀)।
Design (ripple + reset — exam-এর দ্রুত উত্তর):
- চারটা T flip-flop-এই T = 1 বেঁধে দাও, তাহলে clock পেলেই প্রতিটা toggle করবে।
- Ripple counter-এর মতো chain করো: CLK যায় FF0-তে; Q₀ clock দেয় FF1-কে; Q₁ দেয় FF2-কে; Q₂ দেয় FF3-কে। এমনিতে এটা একটা mod-16 counter।
- প্রথম অবাঞ্ছিত count, 12 = 1100 detect করো: Q₃ আর Q₂-কে একটা NAND gate-এ দাও, আর তার output চার flip-flop-এর active-LOW CLEAR-এ লাগাও।
- Counter 1100-তে পৌঁছানো মাত্রই NAND-এর output 0 হয়ে সব 0000-তে clear করে দেয়। তাই দেখা যায় 0 থেকে 11 — ঠিক 12টা state।
শুধু Q₃ আর Q₂-তে NAND কেন? 1100-ই প্রথম জায়গা যেখানে Q₃ আর Q₂ দুটোই 1 (13, 14, 15-এর আগেই 12 আসে), তাই এই দুই bit check করাই যথেষ্ট।
Synchronous version (প্রশ্নে ripple delay নিষেধ থাকলে): সব flip-flop-কে এক common clock দাও, আর excitation table থেকে T input বের করো (bit বদলাতে হলে T = 1; state 12–15 হলো don't-care):
T₀ = 1; T₁ = Q₀; T₂ = Q₃′Q₁Q₀; T₃ = Q₁Q₀(Q₂ + Q₃)
1011 (11)-এ দ্রুত check: T₀=1, T₁=1, T₂ = 0 (Q₃=1 আটকে দেয়), T₃ = 1·(0+1) = 1 → next state 0000 ✓।
Up/down countersUp/down counter
A down counter counts 111 → 110 → … → 000. Rule: a bit toggles when all lower bits are 0 (use Q′ outputs: Jₙ = Kₙ = Q₀′Q₁′…). An up/down counter has a mode input M: M=0 count up (use Q's), M=1 count down (use Q′'s), mixed with AND-OR logic.
Down counter গোনে 111 → 110 → … → 000। নিয়ম: নিচের সব bit 0 হলে bit toggle করে (Q′ output ব্যবহার: Jₙ = Kₙ = Q₀′Q₁′…)। Up/down counter-এ একটা mode input M থাকে: M=0 হলে up (Q ব্যবহার), M=1 হলে down (Q′ ব্যবহার), AND-OR logic দিয়ে মেশানো।
Registers and shift registersRegister আর shift register
A register is a row of flip-flops that stores an n-bit word. A shift register moves its bits one place on every clock. Four types, named by how data goes in and out:
Register হলো এক সারি flip-flop যা একটা n-bit word রাখে। Shift register প্রতি clock-এ তার bit গুলো এক ঘর সরায়। Data কীভাবে ঢোকে আর বের হয়, সেই অনুযায়ী চার ধরন:
| Typeধরন | InputInput | OutputOutput | Clocks for n bits (in → out)n bit-এর জন্য clock (in → out) |
|---|---|---|---|
| SISO | Serial | Serial | n + n (load then read)(load তারপর read) |
| SIPO | Serial | Parallel | n |
| PISO | Parallel | Serial | 1 + n |
| PIPO | Parallel | Parallel | 1 |
Uses: serial data transfer (UART), multiplication/division by 2 (shift left/right), delay lines.
ব্যবহার: serial data transfer (UART), 2 দিয়ে গুণ/ভাগ (shift left/right), delay line।
Ring and Johnson countersRing আর Johnson counter
Ring counter: a shift register whose last output feeds back to the first input. Load one 1, and it circulates: 1000 → 0100 → 0010 → 0001 → 1000. With n flip-flops it has n states (mod-n).
Johnson (twisted ring) counter: feed back the complement of the last output. With n flip-flops it has 2n states. For n = 4: 0000 → 1000 → 1100 → 1110 → 1111 → 0111 → 0011 → 0001 → 0000 (8 states).
Ring counter: এমন shift register যার শেষ output প্রথম input-এ ফিরে যায়। একটা 1 load করলে সেটা ঘুরতে থাকে: 1000 → 0100 → 0010 → 0001 → 1000। n flip-flop-এ nটা state (mod-n)।
Johnson (twisted ring) counter: শেষ output-এর complement ফেরত দেওয়া হয়। n flip-flop-এ 2nটা state। n = 4 হলে: 0000 → 1000 → 1100 → 1110 → 1111 → 0111 → 0011 → 0001 → 0000 (৮টা state)।
7. Sequential Circuit Design7. Sequential Circuit Design
Moore vs Mealy machinesMoore vs Mealy machine
| Moore | Mealy | |
|---|---|---|
| Output depends onOutput নির্ভর করে | state onlyশুধু state-এর উপর | state + current inputstate + current input-এর উপর |
| Output written onOutput লেখা হয় | inside the state circlestate-এর circle-এর ভিতরে | on the arrow, as input/outputarrow-এর গায়ে, input/output আকারে |
| States neededState লাগে | usually moreসাধারণত বেশি | usually fewerসাধারণত কম |
| Output timingOutput-এর timing | stable for a full clockপুরো এক clock স্থির থাকে | reacts within the same clockএকই clock-এর মধ্যেই react করে |
Design steps (same every time — memorize the flow):
- Understand the problem → draw the state diagram.
- Write the state table (present state, input → next state, output).
- State assignment: give each state a binary code. n states need ⌈log₂n⌉ flip-flops.
- Pick a flip-flop type; use its excitation table to find each flip-flop input.
- Simplify the input and output equations with K-maps (unused states = don't-cares).
- Draw the circuit.
Design-এর ধাপ (প্রতিবার একই — flow-টা মুখস্থ করো):
- সমস্যাটা বুঝে → state diagram আঁকো।
- State table লেখো (present state, input → next state, output)।
- State assignment: প্রতিটা state-কে একটা binary code দাও। nটা state-এর জন্য ⌈log₂n⌉টা flip-flop লাগে।
- একটা flip-flop type বেছে নাও; তার excitation table দিয়ে প্রতিটা flip-flop input বের করো।
- Input আর output equation গুলো K-map দিয়ে simplify করো (unused state = don't-care)।
- Circuit আঁকো।
Full worked example: "101" sequence detector (Mealy, overlapping)পুরো worked example: "101" sequence detector (Mealy, overlapping)
Problem: a circuit reads one bit x per clock. Output y = 1 when the last three bits seen are 1, 0, 1. Overlap allowed (in 10101, "101" appears twice).
Step 1 — states (each state remembers useful progress):
- S0: no useful progress yet.
- S1: last bit was 1 (we have "1").
- S2: we have "10".
Transitions: from S2, input 1 completes "101" → output 1, and that final 1 can start a new pattern, so go to S1.
সমস্যা: circuit প্রতি clock-এ একটা bit x পড়ে। শেষ তিনটা bit 1, 0, 1 হলে output y = 1। Overlap allowed (10101-এ "101" দুইবার আছে)।
Step 1 — state (প্রতিটা state কাজের অগ্রগতি মনে রাখে):
- S0: এখনও কোনো কাজের progress নেই।
- S1: শেষ bit ছিল 1 (আমাদের হাতে "1")।
- S2: আমাদের হাতে "10"।
Transition: S2-তে থাকা অবস্থায় input 1 এলে "101" সম্পূর্ণ হয় → output 1, আর সেই শেষ 1-টাই নতুন pattern শুরু করতে পারে, তাই S1-এ যাও।
Step 2 — state table, and Step 3 — assignment: S0 = 00, S1 = 01, S2 = 10 (two D flip-flops A, B; state = AB). The combination 11 is unused → don't-care.
Step 2 — state table, আর Step 3 — assignment: S0 = 00, S1 = 01, S2 = 10 (দুইটা D flip-flop A, B; state = AB)। 11 combination-টা unused → don't-care।
| PresentPresent | x | NextNext | y | D_A | D_B | ||
|---|---|---|---|---|---|---|---|
| A | B | A⁺ | B⁺ | ||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
(For D flip-flops, D = next state bit, so the last two columns just copy A⁺ and B⁺.)
Step 4 & 5 — equations by K-map (variables A, B, x; cells 110 and 111 are don't-cares):
- D_A = 1 only at A′Bx′ (row 010). Grouping with don't-care 110 → D_A = Bx′.
- D_B = 1 at 001, 011, 101. Grouping with don't-care 111 → all cells with x = 1 → D_B = x.
- y = 1 at 101. Grouping with don't-care 111 → y = Ax.
Step 6 — circuit: D_A needs one AND (B, x′), D_B is just the input x, and y needs one AND (A, x). Two D flip-flops + two AND gates + one NOT. Done!
Sanity check with input 1, 0, 1: start 00 →(x=1) 01 →(x=0) 10 →(x=1) y = A·x = 1 ✓ and next state 01, ready for overlap. ✓
(D flip-flop-এ D = next state bit, তাই শেষ দুই column শুধু A⁺ আর B⁺-এর copy।)
Step 4 আর 5 — K-map দিয়ে equation (variable A, B, x; cell 110 আর 111 don't-care):
- D_A শুধু A′Bx′ (row 010)-তে 1। Don't-care 110-এর সাথে group করে → D_A = Bx′।
- D_B 001, 011, 101-এ 1। Don't-care 111-এর সাথে group করলে → x = 1-এর সব cell → D_B = x।
- y 101-এ 1। Don't-care 111-এর সাথে group করে → y = Ax।
Step 6 — circuit: D_A-র জন্য একটা AND (B, x′), D_B হলো শুধু input x, আর y-এর জন্য একটা AND (A, x)। দুইটা D flip-flop + দুইটা AND gate + একটা NOT। শেষ!
Sanity check — input 1, 0, 1 দিয়ে: শুরু 00 →(x=1) 01 →(x=0) 10 →(x=1) y = A·x = 1 ✓ আর next state 01, overlap-এর জন্য প্রস্তুত। ✓
Practice Questions (Admission Style)Practice Questions (Admission Style)
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Whole part: 156÷2=78 r0, 78÷2=39 r0, 39÷2=19 r1, 19÷2=9 r1, 9÷2=4 r1, 4÷2=2 r0, 2÷2=1 r0, 1÷2=0 r1. Bottom to top: 10011100.
Fraction: 0.375×2 = 0.75 → 0; 0.75×2 = 1.5 → 1; 0.5×2 = 1.0 → 1. Top to bottom: .011.
Check: 128+16+8+4 = 156 ✓ and 0.25+0.125 = 0.375 ✓.
Whole part: 156÷2=78 r0, 78÷2=39 r0, 39÷2=19 r1, 19÷2=9 r1, 9÷2=4 r1, 4÷2=2 r0, 2÷2=1 r0, 1÷2=0 r1। নিচ থেকে উপরে: 10011100।
Fraction: 0.375×2 = 0.75 → 0; 0.75×2 = 1.5 → 1; 0.5×2 = 1.0 → 1। উপর থেকে নিচে: .011।
Check: 128+16+8+4 = 156 ✓ আর 0.25+0.125 = 0.375 ✓।
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Step 1: A′B + AB = (A′ + A)B = 1·B = B.
Step 2: F = B + A′B′.
Step 3: use X + X′Y = X + Y with X = B, Y = A′: B + B′A′ = B + A′.
So F = A′ + B.
Step 1: A′B + AB = (A′ + A)B = 1·B = B।
Step 2: F = B + A′B′।
Step 3: X + X′Y = X + Y নিয়মটা ব্যবহার করি, X = B, Y = A′: B + B′A′ = B + A′।
তাহলে F = A′ + B।
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Show Answerউত্তর দেখুন
Step 1: 45 = 00101101, 58 = 00111010.
Step 2: 2's complement of 58: flip → 11000101, add 1 → 11000110.
Step 3: add: 00101101 + 11000110 = 11110011. No carry out.
Step 4: no carry → the answer is negative. Magnitude = 2's complement of 11110011 = 00001100 + 1 = 00001101 = 13.
So 45 − 58 = −13 ✓.
Step 1: 45 = 00101101, 58 = 00111010।
Step 2: 58-এর 2's complement: flip → 11000101, +1 → 11000110।
Step 3: যোগ: 00101101 + 11000110 = 11110011। কোনো carry নেই।
Step 4: carry নেই → উত্তর negative। Magnitude = 11110011-এর 2's complement = 00001100 + 1 = 00001101 = 13।
তাহলে 45 − 58 = −13 ✓।
Show Answerউত্তর দেখুন
Fill the 4-variable map (rows AB = 00, 01, 11, 10; columns CD = 00, 01, 11, 10):
| F | CD=00 | CD=01 | CD=11 | CD=10 |
|---|---|---|---|---|
| AB=00 | 1 | 1 | 0 | 1 |
| AB=01 | 1 | 1 | 0 | 1 |
| AB=11 | 1 | 1 | 0 | 1 |
| AB=10 | 1 | 1 | 0 | 0 |
Group 1 (green, 8 cells): the two left columns (CD = 00, 01) → C = 0 fixed → C′.
Group 2 (blue + green corners, 4 cells): m0, m2, m4, m6 — rows A = 0, column D = 0 → A′D′.
Group 3 (yellow, 4 cells): m4, m6, m12, m14 — B = 1, D = 0 → BD′.
All 1s covered → F = C′ + A′D′ + BD′.
4-variable map পূরণ করি (row AB = 00, 01, 11, 10; column CD = 00, 01, 11, 10):
| F | CD=00 | CD=01 | CD=11 | CD=10 |
|---|---|---|---|---|
| AB=00 | 1 | 1 | 0 | 1 |
| AB=01 | 1 | 1 | 0 | 1 |
| AB=11 | 1 | 1 | 0 | 1 |
| AB=10 | 1 | 1 | 0 | 0 |
Group 1 (সবুজ, ৮ cell): বাম দুই column (CD = 00, 01) → C = 0 fixed → C′।
Group 2 (নীল + সবুজ, ৪ cell): m0, m2, m4, m6 — A = 0, D = 0 → A′D′।
Group 3 (হলুদ, ৪ cell): m4, m6, m12, m14 — B = 1, D = 0 → BD′।
সব 1 covered → F = C′ + A′D′ + BD′।
Show Answerউত্তর দেখুন
Check each select combination against the minterm list:
AB = 00 → m₀ (C=0, in list), m₁ (C=1, not) → F = C′ → I₀ = C′.
AB = 01 → m₂ (C=0, in list), m₃ (not) → I₁ = C′.
AB = 10 → m₄ (not), m₅ (C=1, in list) → I₂ = C.
AB = 11 → m₆ (not), m₇ (C=1, in list) → I₃ = C.
Bonus: notice F = C′ when A=0 and F = C when A=1. So F = A′C′ + AC = (A⊕C)′ — the MUX makes this easy to see.
প্রতিটা select combination-কে minterm list-এর সাথে মিলাই:
AB = 00 → m₀ (C=0, list-এ আছে), m₁ (নেই) → F = C′ → I₀ = C′।
AB = 01 → m₂ (C=0, আছে), m₃ (নেই) → I₁ = C′।
AB = 10 → m₄ (নেই), m₅ (C=1, আছে) → I₂ = C।
AB = 11 → m₆ (নেই), m₇ (C=1, আছে) → I₃ = C।
Bonus: খেয়াল করো A=0 হলে F = C′ আর A=1 হলে F = C, তাই F = A′C′ + AC = (A⊕C)′ — MUX-টাই এটা প্রমাণ করে দিল।
Show Answerউত্তর দেখুন
Excitation table (states 101, 110, 111 unused → all X):
| Q₂ Q₁ Q₀ | Q₂⁺ Q₁⁺ Q₀⁺ | J₂ K₂ | J₁ K₁ | J₀ K₀ |
|---|---|---|---|---|
| 0 0 0 | 0 0 1 | 0 X | 0 X | 1 X |
| 0 0 1 | 0 1 0 | 0 X | 1 X | X 1 |
| 0 1 0 | 0 1 1 | 0 X | X 0 | 1 X |
| 0 1 1 | 1 0 0 | 1 X | X 1 | X 1 |
| 1 0 0 | 0 0 0 | X 1 | 0 X | 0 X |
K-maps (with the three unused states as don't-cares):
J₀: 1 at 000, 010; 0 at 100 → depends only on Q₂ → J₀ = Q₂′. K₀: 1 wherever defined → K₀ = 1.
J₁: 1 at 001, 0 at 000 and 100 → J₁ = Q₀. K₁: 1 at 011, 0 at 010 → K₁ = Q₀.
J₂: 1 only at 011 → J₂ = Q₁Q₀. K₂: 1 at 100, X elsewhere → K₂ = 1.
Circuit: three JK flip-flops on a common clock with these inputs.
Excitation table (state 101, 110, 111 unused → সব X):
| Q₂ Q₁ Q₀ | Q₂⁺ Q₁⁺ Q₀⁺ | J₂ K₂ | J₁ K₁ | J₀ K₀ |
|---|---|---|---|---|
| 0 0 0 | 0 0 1 | 0 X | 0 X | 1 X |
| 0 0 1 | 0 1 0 | 0 X | 1 X | X 1 |
| 0 1 0 | 0 1 1 | 0 X | X 0 | 1 X |
| 0 1 1 | 1 0 0 | 1 X | X 1 | X 1 |
| 1 0 0 | 0 0 0 | X 1 | 0 X | 0 X |
K-map (unused তিনটা state don't-care ধরে):
J₀: 000, 010-তে 1; 100-তে 0 → শুধু Q₂-এর উপর নির্ভর → J₀ = Q₂′। K₀: যেখানে defined সেখানেই 1 → K₀ = 1।
J₁: 001-এ 1, 000 আর 100-এ 0 → J₁ = Q₀। K₁: 011-এ 1, 010-এ 0 → K₁ = Q₀।
J₂: শুধু 011-এ 1 → J₂ = Q₁Q₀। K₂: 100-এ 1, বাকিতে X → K₂ = 1।
Circuit: এক clock-এ তিনটা JK flip-flop, উপরের input গুলো দিয়ে।
Show Answerউত্তর দেখুন
Step 1 — states: S0 = "last bit was not 1", S1 = "last bit was 1". Two states → one flip-flop (S0: Q=0, S1: Q=1).
Step 2 — transitions: S0 --1/0--> S1; S0 --0/0--> S0; S1 --1/1--> S1 (two 1s in a row → output 1, stay for overlap); S1 --0/0--> S0.
Step 3 — state table:
| Q | x | Q⁺ | y |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
Step 4 — equations: for a D flip-flop, D = Q⁺. From the table, Q⁺ = x in every row → D = x. Output y = 1 only when Q=1 and x=1 → y = Qx.
Circuit: one D flip-flop fed by x, and one AND gate on Q and x. Check with input 0,1,1,1: y = 0,0,1,1 ✓.
Step 1 — state: S0 = "শেষ bit 1 ছিল না", S1 = "শেষ bit 1 ছিল"। দুই state → একটা flip-flop (S0: Q=0, S1: Q=1)।
Step 2 — transition: S0 --1/0--> S1; S0 --0/0--> S0; S1 --1/1--> S1 (পরপর দুই 1 → output 1, overlap-এর জন্য S1-এই থাকো); S1 --0/0--> S0।
Step 3 — state table:
| Q | x | Q⁺ | y |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
Step 4 — equation: D flip-flop-এ D = Q⁺। Table থেকে প্রতিটা row-তে Q⁺ = x → D = x। Output y = 1 শুধু Q=1 আর x=1 হলে → y = Qx।
Circuit: x দিয়ে চালানো একটা D flip-flop, আর Q ও x-এর উপর একটা AND gate। Input 0,1,1,1 দিয়ে check: y = 0,0,1,1 ✓।
Show Answerউত্তর দেখুন
Step 1: put A and B on the decoder select inputs (enable tied HIGH). A high-active decoder gives every minterm: D₀ = A′B′, D₁ = A′B, D₂ = AB′, D₃ = AB.
Step 2: XOR is A ⊕ B = Σm(1, 2). With an OR gate we would just do D₁ + D₂ — but we only have a NOR.
Step 3: for any input, exactly one decoder output is 1. So "D₁ or D₂ is active" happens exactly when "neither D₀ nor D₃ is active". Therefore A ⊕ B = (D₀ + D₃)′ = NOR(D₀, D₃).
Check every row: A=B=0 → D₀=1 → NOR = 0 ✓. A=0,B=1 → D₀=D₃=0 → NOR = 1 ✓. A=1,B=0 → NOR = 1 ✓. A=B=1 → D₃=1 → NOR = 0 ✓. (This exact question came in April 2024.)
Step 1: A আর B-কে decoder-এর select input-এ দাও (enable HIGH-তে বাঁধা)। High-active decoder সব minterm দেয়: D₀ = A′B′, D₁ = A′B, D₂ = AB′, D₃ = AB।
Step 2: XOR হলো A ⊕ B = Σm(1, 2)। OR gate থাকলে শুধু D₁ + D₂ করতাম — কিন্তু আমাদের হাতে আছে NOR।
Step 3: যেকোনো input-এ decoder-এর ঠিক একটা output 1 হয়। তাই "D₁ বা D₂ active" ঘটে ঠিক তখনই, যখন "D₀ বা D₃ কোনোটাই active না"। অতএব A ⊕ B = (D₀ + D₃)′ = NOR(D₀, D₃)।
প্রতিটা row check: A=B=0 → D₀=1 → NOR = 0 ✓। A=0,B=1 → D₀=D₃=0 → NOR = 1 ✓। A=1,B=0 → NOR = 1 ✓। A=B=1 → D₃=1 → NOR = 0 ✓। (ঠিক এই প্রশ্নটাই April 2024-এ এসেছিল।)
Show Answerউত্তর দেখুন
Step 1 — flip-flop count: MOD-12 needs 2ⁿ ≥ 12 → n = ⌈log₂12⌉ = 4. Outputs Q₃Q₂Q₁Q₀.
Step 2 — counting: tie T = 1 on every flip-flop so each toggles. CLK drives FF0; Q₀ clocks FF1; Q₁ clocks FF2; Q₂ clocks FF3. This alone counts 0–15 (mod-16).
Step 3 — reset at 12: the counter must show only 0–11, so the first forbidden state is 12 = 1100. Feed Q₃ and Q₂ into a NAND gate and connect its output to the active-LOW CLEAR of all four flip-flops. When 1100 appears, NAND output = 0 → counter instantly clears to 0000.
Step 4 — why Q₃, Q₂ are enough: counting up from 0, the very first state with Q₃ = Q₂ = 1 is 1100 (states 13–15 never come). So checking only these two bits uniquely detects 12.
(Synchronous alternative: common clock and T₀ = 1, T₁ = Q₀, T₂ = Q₃′Q₁Q₀, T₃ = Q₁Q₀(Q₂ + Q₃). This exact question came in April 2017.)
Step 1 — flip-flop সংখ্যা: MOD-12-এর জন্য দরকার 2ⁿ ≥ 12 → n = ⌈log₂12⌉ = 4। Output Q₃Q₂Q₁Q₀।
Step 2 — গোনা: প্রতিটা flip-flop-এ T = 1 বাঁধো, যাতে সবাই toggle করে। CLK যায় FF0-তে; Q₀ clock দেয় FF1-কে; Q₁ দেয় FF2-কে; Q₂ দেয় FF3-কে। এমনিতে এটা 0–15 গোনে (mod-16)।
Step 3 — 12-তে reset: counter-কে শুধু 0–11 দেখাতে হবে, তাই প্রথম নিষিদ্ধ state হলো 12 = 1100। Q₃ আর Q₂-কে একটা NAND gate-এ দাও, আর তার output চার flip-flop-এর active-LOW CLEAR-এ লাগাও। 1100 আসা মাত্র NAND output = 0 → counter সাথে সাথে 0000-তে clear হয়।
Step 4 — শুধু Q₃, Q₂ কেন যথেষ্ট: 0 থেকে উপরে গুনলে Q₃ = Q₂ = 1 হওয়া প্রথম state-ই 1100 (13–15 কখনো আসেই না)। তাই এই দুই bit check করলেই 12 uniquely ধরা পড়ে।
(Synchronous বিকল্প: common clock আর T₀ = 1, T₁ = Q₀, T₂ = Q₃′Q₁Q₀, T₃ = Q₁Q₀(Q₂ + Q₃)। ঠিক এই প্রশ্নটাই April 2017-তে এসেছিল।)
Show Answerউত্তর দেখুন
Step 1 — find the ratio: 80 MHz ÷ 10 MHz = 8 = 2³. Each toggling D flip-flop divides by 2, so we need n = 3 stages.
Step 2 — wiring: in every flip-flop, connect its own Q′ back to its own D (D = Q′), so it toggles on every active clock edge. Clock FF1 with the 80 MHz input; clock FF2 with Q₁; clock FF3 with Q₂.
Step 3 — stage frequencies: Q₁ = 80/2 = 40 MHz, Q₂ = 40/2 = 20 MHz, Q₃ = 20/2 = 10 MHz. Take the final output from Q₃; it is a clean square wave with 50% duty cycle.
Why this works: with D = Q′, every edge loads the opposite of the current output, so Q needs 2 input edges for 1 full cycle → frequency halves at every stage. (Same idea as the October 2017 question: 100 MHz → 50 MHz → 25 MHz with 2 flip-flops.)
Step 1 — ratio বের করো: 80 MHz ÷ 10 MHz = 8 = 2³। প্রতিটা toggle করা D flip-flop 2 দিয়ে ভাগ করে, তাই লাগবে n = 3টা stage।
Step 2 — wiring: প্রতিটা flip-flop-এ তার নিজের Q′ তার নিজের D-তে ফেরত দাও (D = Q′), যাতে প্রতিটা active clock edge-এ toggle করে। FF1-কে 80 MHz input দিয়ে clock দাও; FF2-কে Q₁ দিয়ে; FF3-কে Q₂ দিয়ে।
Step 3 — stage-এর frequency: Q₁ = 80/2 = 40 MHz, Q₂ = 40/2 = 20 MHz, Q₃ = 20/2 = 10 MHz। Final output নাও Q₃ থেকে; এটা 50% duty cycle-এর পরিষ্কার square wave।
কেন কাজ করে: D = Q′ হলে প্রতি edge-এ বর্তমান output-এর উল্টোটা load হয়, তাই Q-এর 1টা পুরো cycle-এ 2টা input edge লাগে → প্রতি stage-এ frequency অর্ধেক। (October 2017-এর প্রশ্নের same idea: 2টা flip-flop দিয়ে 100 MHz → 50 MHz → 25 MHz।)
Show Answerউত্তর দেখুন
Step 1 — counts: 2 inputs, 2 outputs → adder family is the first suspect.
Step 2 — read P: P = 1 only when A and B differ (01 and 10) → P = A ⊕ B. That is exactly the sum bit of adding two 1-bit numbers.
Step 3 — read Q: Q = 1 only when both inputs are 1 → Q = AB. That is exactly the carry bit (1 + 1 = 10₂).
Step 4 — cross-check: 1+1 gives Sum 0, Carry 1 — the table shows P=0, Q=1 for (1,1). ✓ It cannot be a full adder (that needs 3 inputs) and it is not one-hot, so not a decoder. So: half adder.
Step 1 — গোনা: 2টা input, 2টা output → প্রথম সন্দেহ adder family।
Step 2 — P পড়ো: A আর B আলাদা হলেই শুধু P = 1 (01 আর 10) → P = A ⊕ B। এটাই দুইটা 1-bit সংখ্যা যোগের sum bit।
Step 3 — Q পড়ো: দুই input-ই 1 হলে শুধু Q = 1 → Q = AB। এটাই carry bit (1 + 1 = 10₂)।
Step 4 — মিলিয়ে দেখো: 1+1 দিলে Sum 0, Carry 1 — table-এ (1,1)-এর জন্য P=0, Q=1। ✓ এটা full adder হতে পারে না (তার 3টা input লাগে), আর one-hot-ও না, তাই decoder-ও না। সুতরাং: half adder।