Digital Logic Design (DLD) Complete Course – University Level – Pak Notes Hub
⚑ University / College Level β€” BS Computer Science / Computer Engineering / Electrical Engineering

Digital Logic Design
Complete Course

Number Systems Β· Boolean Algebra Β· Logic Gates Β· Combinational & Sequential Circuits β€” Complete Guide in Easy English

πŸ“š 8 Units πŸŽ“ University Level ⚑ Circuit Diagrams πŸ“ Truth Tables πŸ”₯ Practical Examples
Unit 1

Number Systems & Codes

Understanding Binary, Octal, Decimal, Hexadecimal, BCD, Gray Code, ASCII and conversions

What is a Number System?

A number system is a mathematical notation for representing numbers using a consistent set of digits or symbols. In digital electronics and computers, different number systems are used to represent data.

Types of Number Systems

SystemBaseDigits UsedExample
Binary20, 1(1010)β‚‚
Octal80-7(752)β‚ˆ
Decimal100-9(125)₁₀
Hexadecimal160-9, A-F(3A7)₁₆

1. Binary Number System (Base 2)

Binary is the fundamental language of computers and digital circuits. It uses only two digits: 0 and 1.

Why Binary?

  • Digital circuits work with two states: ON (1) and OFF (0)
  • Easy to implement using electronic switches (transistors)
  • High noise immunity (clear distinction between 0 and 1)
  • All data in computers is ultimately stored in binary
Binary Number Representation

Position:    7    6    5    4    3    2    1    0
Value:     128   64   32   16    8    4    2    1
Binary:      1    0    1    0    1    1    0    1

(10101101)β‚‚ = 128 + 32 + 8 + 4 + 1 = (173)₁₀

2. Decimal Number System (Base 10)

The standard number system we use in everyday life. Uses digits 0-9.

Position:   3    2    1    0
Value:    1000  100   10    1
Decimal:    5    2    7    3

(5273)₁₀ = 5Γ—10Β³ + 2Γ—10Β² + 7Γ—10ΒΉ + 3Γ—10⁰ = 5000 + 200 + 70 + 3

3. Octal Number System (Base 8)

Uses digits 0-7. Often used as a shorthand for binary (each octal digit = 3 binary bits).

Position:   2    1    0
Value:     64    8    1
Octal:      7    5    2

(752)β‚ˆ = 7Γ—8Β² + 5Γ—8ΒΉ + 2Γ—8⁰ = 448 + 40 + 2 = (490)₁₀

4. Hexadecimal Number System (Base 16)

Uses digits 0-9 and letters A-F (A=10, B=11, C=12, D=13, E=14, F=15). Widely used in programming and memory addressing.

DecimalBinaryHexadecimal
000000
100011
101010A
111011B
121100C
131101D
141110E
151111F
(3A7)₁₆ = 3Γ—16Β² + 10Γ—16ΒΉ + 7Γ—16⁰ = 768 + 160 + 7 = (935)₁₀

Number System Conversions

1. Binary to Decimal

Example: Convert (1101)β‚‚ to Decimal

(1101)β‚‚ = 1Γ—2Β³ + 1Γ—2Β² + 0Γ—2ΒΉ + 1Γ—2⁰
        = 8 + 4 + 0 + 1
        = (13)₁₀

2. Decimal to Binary

Example: Convert (25)₁₀ to Binary

25 Γ· 2 = 12 remainder 1  (LSB)
12 Γ· 2 = 6  remainder 0
6  Γ· 2 = 3  remainder 0
3  Γ· 2 = 1  remainder 1
1  Γ· 2 = 0  remainder 1  (MSB)

Read from bottom to top: (11001)β‚‚

3. Binary to Octal

Group binary digits in groups of 3 from right to left

(101110101)β‚‚ 
= 101  110  101
=  5    6    5
= (565)β‚ˆ

4. Binary to Hexadecimal

Group binary digits in groups of 4 from right to left

(10111010)β‚‚
= 1011  1010
=  B     A
= (BA)₁₆

5. Octal to Binary

Convert each octal digit to 3-bit binary

(746)β‚ˆ
7 = 111
4 = 100
6 = 110
= (111100110)β‚‚

6. Hexadecimal to Binary

Convert each hex digit to 4-bit binary

(2F)₁₆
2 = 0010
F = 1111
= (00101111)β‚‚

Quick Conversion Table

DecimalBinaryOctalHexadecimal
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

Binary Codes

1. Binary Coded Decimal (BCD)

BCD represents each decimal digit (0-9) using 4 binary bits. Also called 8421 code.

Example: Convert (579)₁₀ to BCD

5 = 0101
7 = 0111
9 = 1001

(579)₁₀ = 0101 0111 1001 (BCD)
DecimalBCD (8421)Binary
000000000
100010001
501010101
910011001
120001 00101100
250010 010111001
πŸ’‘ BCD vs Pure Binary: BCD uses more bits but makes decimal-to-binary conversion easier for human-readable displays (like calculators and digital clocks).

2. Gray Code (Reflected Binary Code)

A binary code where two successive values differ by only one bit. Used in rotary encoders, error correction, and analog-to-digital converters.

DecimalBinaryGray CodeBits Changed
000000000-
1000100011 bit
2001000111 bit
3001100101 bit
4010001101 bit
5010101111 bit
6011001011 bit
7011101001 bit

Binary to Gray Code Conversion:

Method: MSB stays same, then XOR each adjacent pair

Binary:  1 0 1 1
         ↓ βŠ• βŠ• βŠ•
Gray:    1 1 1 0

Step by step:
G₃ = B₃ = 1
Gβ‚‚ = B₃ βŠ• Bβ‚‚ = 1 βŠ• 0 = 1
G₁ = Bβ‚‚ βŠ• B₁ = 0 βŠ• 1 = 1
Gβ‚€ = B₁ βŠ• Bβ‚€ = 1 βŠ• 1 = 0

Gray to Binary Conversion:

Method: MSB stays same, then XOR with previous binary bit

Gray:    1 1 1 0
         ↓ βŠ• βŠ• βŠ•
Binary:  1 0 1 1

Step by step:
B₃ = G₃ = 1
Bβ‚‚ = B₃ βŠ• Gβ‚‚ = 1 βŠ• 1 = 0
B₁ = Bβ‚‚ βŠ• G₁ = 0 βŠ• 1 = 1
Bβ‚€ = B₁ βŠ• Gβ‚€ = 1 βŠ• 0 = 1

ASCII Code (American Standard Code for Information Interchange)

A 7-bit code (128 characters) used to represent text in computers. Extended ASCII uses 8 bits (256 characters).

CharacterDecimalBinaryHexadecimal
A650100000141
B660100001042
Z90010110105A
a970110000161
b980110001062
0480011000030
1490011000131
Space320010000020

ASCII Ranges:

  • 0-31: Control characters (non-printable)
  • 32-47: Special characters and space
  • 48-57: Digits 0-9
  • 65-90: Uppercase letters A-Z
  • 97-122: Lowercase letters a-z
πŸ’‘ Quick Tip: To convert uppercase to lowercase in ASCII, add 32. To convert lowercase to uppercase, subtract 32. Example: 'A' (65) + 32 = 'a' (97)

Signed Number Representation

1. Sign-Magnitude

MSB indicates sign (0=positive, 1=negative). Remaining bits represent magnitude.

+5 = 0101    (MSB=0 means positive)
-5 = 1101    (MSB=1 means negative)

Problem: Two representations of zero (+0 and -0)
+0 = 0000
-0 = 1000

2. 1's Complement

Positive numbers: normal binary. Negative numbers: invert all bits.

+5 = 0101
-5 = 1010    (invert all bits of +5)

+7 = 0111
-7 = 1000    (invert all bits of +7)

Problem: Still has two zeros
+0 = 0000
-0 = 1111

3. 2's Complement (Most Common)

Positive numbers: normal binary. Negative numbers: invert all bits and add 1.

Example: Find 2's complement of +5

+5 = 0101
Invert:  1010
Add 1:   1011
-5 = 1011

Example: Find 2's complement of +7
+7 = 0111
Invert:  1000
Add 1:   1001
-7 = 1001

Advantage: Only one representation of zero
+0 = 0000

2's Complement Range for n bits:

  • Range: -2n-1 to +2n-1-1
  • 4-bit: -8 to +7
  • 8-bit: -128 to +127
  • 16-bit: -32,768 to +32,767

Binary Arithmetic

Binary Addition Rules:

  0 + 0 = 0
  0 + 1 = 1
  1 + 0 = 1
  1 + 1 = 10   (0 with carry 1)
1 + 1 + 1 = 11  (1 with carry 1)

Example: 1011 + 1101

    ₁₁₁     (carries)
    1011    (11 in decimal)
  + 1101    (13 in decimal)
  ------
   11000    (24 in decimal)

Binary Subtraction Rules:

  0 - 0 = 0
  1 - 0 = 1
  1 - 1 = 0
  0 - 1 = 1  (with borrow 1)

Example: 1101 - 1011

    1101    (13 in decimal)
  - 1011    (11 in decimal)
  ------
    0010    (2 in decimal)
✏️ Practice: 1) Convert (11010110)β‚‚ to Decimal, Octal, and Hexadecimal. 2) Convert (456)₁₀ to Binary, Octal, and Hexadecimal. 3) Convert (3F7)₁₆ to Binary. 4) Find 2's complement of (01101)β‚‚. 5) Add (1011)β‚‚ + (1110)β‚‚
Unit 2

Boolean Algebra

Laws, theorems, De Morgan's rules, simplification techniques and truth tables

What is Boolean Algebra?

Boolean Algebra is a branch of algebra that deals with binary variables and logical operations. Developed by George Boole in 1854, it forms the foundation of digital logic design.

Boolean Variables: Can have only two values: 0 (False) or 1 (True)

Basic Boolean Operations

1. AND Operation (Β·)

Output is 1 only when ALL inputs are 1. Symbol: · or ∧

Z = A Β· B   or   Z = A AND B   or   Z = AB

Truth Table:
A  B  |  Z=AΒ·B
0  0  |   0
0  1  |   0
1  0  |   0
1  1  |   1

2. OR Operation (+)

Output is 1 when AT LEAST ONE input is 1. Symbol: + or ∨

Z = A + B   or   Z = A OR B

Truth Table:
A  B  |  Z=A+B
0  0  |   0
0  1  |   1
1  0  |   1
1  1  |   1

3. NOT Operation (')

Output is the complement/inverse of input. Symbol: ' or Β¬ or β€Ύ

Z = A'   or   Z = NOT A   or   Z = Δ€

Truth Table:
A  |  Z=A'
0  |   1
1  |   0

Boolean Algebra Laws

1. Identity Laws

OR Identity
A + 0 = A
AND Identity
A Β· 1 = A

2. Null (Dominance) Laws

OR Null
A + 1 = 1
AND Null
A Β· 0 = 0

3. Idempotent Laws

OR Idempotent
A + A = A
AND Idempotent
A Β· A = A

4. Complement Laws

OR Complement
A + A' = 1
AND Complement
A Β· A' = 0
Double Negation
(A')' = A

5. Commutative Laws

OR Commutative
A + B = B + A
AND Commutative
A Β· B = B Β· A

6. Associative Laws

OR Associative
A+(B+C) = (A+B)+C
AND Associative
AΒ·(BΒ·C) = (AΒ·B)Β·C

7. Distributive Laws

AND over OR
AΒ·(B+C) = AΒ·B + AΒ·C
OR over AND
A+(BΒ·C) = (A+B)Β·(A+C)

8. Absorption Laws

Absorption 1
A + AΒ·B = A
Absorption 2
A Β· (A+B) = A
Absorption 3
A + A'Β·B = A + B
Absorption 4
A Β· (A'+B) = A Β· B

De Morgan's Theorems

De Morgan's Laws are fundamental theorems for complementing Boolean expressions:

Theorem 1:

(A + B)' = A' Β· B'

The complement of OR equals AND of complements

Proof by Truth Table:
A  B  |  A+B  (A+B)'  |  A'  B'  A'Β·B'
0  0  |   0      1    |   1   1    1     βœ“
0  1  |   1      0    |   1   0    0     βœ“
1  0  |   1      0    |   0   1    0     βœ“
1  1  |   1      0    |   0   0    0     βœ“

Theorem 2:

(A Β· B)' = A' + B'

The complement of AND equals OR of complements

Proof by Truth Table:
A  B  |  AΒ·B  (AΒ·B)'  |  A'  B'  A'+B'
0  0  |   0      1    |   1   1    1     βœ“
0  1  |   0      1    |   1   0    1     βœ“
1  0  |   0      1    |   0   1    1     βœ“
1  1  |   1      0    |   0   0    0     βœ“
πŸ’‘ De Morgan's Quick Rule: Break the bar, change the operation (+ to Β·, or Β· to +)

Extended De Morgan's:

(A + B + C)' = A' Β· B' Β· C'

(A Β· B Β· C)' = A' + B' + C'

(A + BΒ·C)' = A' Β· (B'+C')

(AΒ·B + CΒ·D)' = (A'+B') Β· (C'+D')

Boolean Expression Simplification

Example 1: Simplify AΒ·B + AΒ·B'

AΒ·B + AΒ·B'
= AΒ·(B + B')        Distributive law
= AΒ·1               Complement law: B+B'=1
= A                 Identity law: AΒ·1=A

Example 2: Simplify (A+B)Β·(A+B')

(A+B)Β·(A+B')
= A + BΒ·B'          Distributive law
= A + 0             Complement law: BΒ·B'=0
= A                 Identity law: A+0=A

Example 3: Simplify A + AΒ·B

A + AΒ·B
= AΒ·1 + AΒ·B         Identity law: A=AΒ·1
= AΒ·(1 + B)         Distributive law
= AΒ·1               Null law: 1+B=1
= A                 Identity law

Example 4: Simplify A'Β·BΒ·C + AΒ·BΒ·C + AΒ·BΒ·C'

A'Β·BΒ·C + AΒ·BΒ·C + AΒ·BΒ·C'
= BΒ·CΒ·(A'+A) + AΒ·BΒ·C'   Factor out BΒ·C
= BΒ·CΒ·1 + AΒ·BΒ·C'        Complement law
= BΒ·C + AΒ·BΒ·C'          Identity law
= BΒ·(C + AΒ·C')          Factor out B
= BΒ·(C + A)             Absorption law
= AΒ·B + BΒ·C             Distributive law

Standard Forms of Boolean Expressions

1. Sum of Products (SOP)

OR of AND terms. Each AND term is called a minterm.

F = A'Β·BΒ·C + AΒ·B'Β·C + AΒ·BΒ·C'

Example: F(A,B,C) = Ξ£m(1,3,5,7)
F = A'Β·B'Β·C + A'Β·BΒ·C + AΒ·B'Β·C + AΒ·BΒ·C

2. Product of Sums (POS)

AND of OR terms. Each OR term is called a maxterm.

F = (A+B+C)Β·(A+B'+C)Β·(A'+B+C')

Example: F(A,B,C) = Ξ M(0,2,4,6)
F = (A+B+C)Β·(A+B+C')Β·(A+B'+C)Β·(A+B'+C')

Truth Table to Boolean Expression

Example: Create expression from truth table

Truth Table:
A  B  C  |  F
0  0  0  |  0
0  0  1  |  1  ← m₁ = A'Β·B'Β·C
0  1  0  |  0
0  1  1  |  1  ← m₃ = A'Β·BΒ·C
1  0  0  |  1  ← mβ‚„ = AΒ·B'Β·C'
1  0  1  |  0
1  1  0  |  1  ← m₆ = AΒ·BΒ·C'
1  1  1  |  0

SOP Form (use rows where F=1):
F = A'Β·B'Β·C + A'Β·BΒ·C + AΒ·B'Β·C' + AΒ·BΒ·C'

Simplified:
F = A'Β·CΒ·(B'+B) + AΒ·C'Β·(B'+B)
F = A'Β·C + AΒ·C'

Canonical Forms

Minterms (m): Product terms with all variables present (in normal or complement form)

RowA B CMintermNotation
00 0 0A'Β·B'Β·C'mβ‚€
10 0 1A'Β·B'Β·Cm₁
20 1 0A'Β·BΒ·C'mβ‚‚
30 1 1A'Β·BΒ·Cm₃
41 0 0AΒ·B'Β·C'mβ‚„
51 0 1AΒ·B'Β·Cmβ‚…
61 1 0AΒ·BΒ·C'm₆
71 1 1AΒ·BΒ·Cm₇

Maxterms (M): Sum terms with all variables present

RowA B CMaxtermNotation
00 0 0A+B+CMβ‚€
10 0 1A+B+C'M₁
20 1 0A+B'+CMβ‚‚
30 1 1A+B'+C'M₃
41 0 0A'+B+CMβ‚„
51 0 1A'+B+C'Mβ‚…
61 1 0A'+B'+CM₆
71 1 1A'+B'+C'M₇
πŸ’‘ Quick Conversion: SOP to POS: F(A,B,C) = Ξ£m(1,3,5,7) = Ξ M(0,2,4,6). Use rows NOT in minterm list for maxterm list.

Consensus Theorem

AΒ·B + A'Β·C + BΒ·C = AΒ·B + A'Β·C

The term BΒ·C is redundant (consensus term)

Dual form:
(A+B)Β·(A'+C)Β·(B+C) = (A+B)Β·(A'+C)
✏️ Practice: 1) Simplify: A·B + A'·C + B·C 2) Apply De Morgan's: (A+B·C)' 3) Convert to SOP: F(A,B,C) with F=1 for rows 1,2,4,7 4) Prove: A+A·B = A using Boolean laws 5) Simplify: (A+B)·(A'+B)·(A+B')
Unit 3

Logic Gates

AND, OR, NOT, NAND, NOR, XOR, XNOR gates with symbols, truth tables, and diagrams

What is a Logic Gate?

A logic gate is a basic building block of digital circuits. It performs a logical operation on one or more binary inputs and produces a single binary output.

πŸ”Œ Basic Gates: AND, OR, NOT
⚑ Universal Gates: NAND, NOR
πŸ”„ Special Gates: XOR, XNOR
πŸ’‘ Used in CPUs, Memory, ALUs

1. AND Gate

Output is HIGH (1) only when ALL inputs are HIGH.

Symbol:
       A ────┐
             β”‚β•²
             β”‚ β•²
             β”‚  β”œβ”€β”€β”€ Y = AΒ·B
             β”‚ β•±
             β”‚β•±
       B β”€β”€β”€β”€β”˜

Boolean Expression: Y = A Β· B  or  Y = AB

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ Y=AΒ·B β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚   0   β”‚
β”‚ 0 β”‚ 1 β”‚   0   β”‚
β”‚ 1 β”‚ 0 β”‚   0   β”‚
β”‚ 1 β”‚ 1 β”‚   1   β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

Applications: Enable/disable signals, multiplication in ALU, conditional operations

2. OR Gate

Output is HIGH when AT LEAST ONE input is HIGH.

Symbol:
       A ────┐
             β”‚)
             β”‚ )
             β”‚  β”œβ”€β”€β”€ Y = A+B
             β”‚ )
             β”‚)
       B β”€β”€β”€β”€β”˜

Boolean Expression: Y = A + B

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ Y=A+B β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚   0   β”‚
β”‚ 0 β”‚ 1 β”‚   1   β”‚
β”‚ 1 β”‚ 0 β”‚   1   β”‚
β”‚ 1 β”‚ 1 β”‚   1   β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

Applications: Combining multiple enable signals, addition in ALU, error detection

3. NOT Gate (Inverter)

Output is the inverse of input. Single input gate.

Symbol:
       A ────▷○─── Y = A'

Boolean Expression: Y = A'  or  Y = Δ€

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ Y=A' β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚  1   β”‚
β”‚ 1 β”‚  0   β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜

Applications: Inverting signals, creating complement, clock signal inversion

4. NAND Gate (NOT-AND)

Output is LOW only when ALL inputs are HIGH. Complement of AND gate.

Symbol:
       A ────┐
             β”‚β•²
             β”‚ β•²
             β”‚  β”œβ—‹β”€β”€β”€ Y = (AΒ·B)'
             β”‚ β•±
             β”‚β•±
       B β”€β”€β”€β”€β”˜

Boolean Expression: Y = (A Β· B)'  or  Y = AΜ…Β·Μ…BΜ…

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ Y=(AΒ·B)'β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚    1    β”‚
β”‚ 0 β”‚ 1 β”‚    1    β”‚
β”‚ 1 β”‚ 0 β”‚    1    β”‚
β”‚ 1 β”‚ 1 β”‚    0    β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
πŸ’‘ Universal Gate: NAND gate can implement ANY logic function (AND, OR, NOT, etc.). It's the most commonly used gate in IC fabrication.

5. NOR Gate (NOT-OR)

Output is HIGH only when ALL inputs are LOW. Complement of OR gate.

Symbol:
       A ────┐
             β”‚)
             β”‚ )
             β”‚  β”œβ—‹β”€β”€β”€ Y = (A+B)'
             β”‚ )
             β”‚)
       B β”€β”€β”€β”€β”˜

Boolean Expression: Y = (A + B)'  or  Y = AΜ…+Μ…BΜ…

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ Y=(A+B)'β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚    1    β”‚
β”‚ 0 β”‚ 1 β”‚    0    β”‚
β”‚ 1 β”‚ 0 β”‚    0    β”‚
β”‚ 1 β”‚ 1 β”‚    0    β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
πŸ’‘ Universal Gate: NOR gate can also implement ANY logic function. Both NAND and NOR are universal gates.

6. XOR Gate (Exclusive-OR)

Output is HIGH when inputs are DIFFERENT.

Symbol:
       A ────┐
            ))
            ) )
            )  β”œβ”€β”€β”€ Y = AβŠ•B
            ) )
            ))
       B β”€β”€β”€β”€β”˜

Boolean Expression: Y = A βŠ• B = A'Β·B + AΒ·B'

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ Y=AβŠ•B β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚   0   β”‚
β”‚ 0 β”‚ 1 β”‚   1   β”‚
β”‚ 1 β”‚ 0 β”‚   1   β”‚
β”‚ 1 β”‚ 1 β”‚   0   β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

Applications: Addition circuits (Half Adder, Full Adder), parity checkers, data encryption

7. XNOR Gate (Exclusive-NOR)

Output is HIGH when inputs are SAME. Complement of XOR.

Symbol:
       A ────┐
            ))
            ) )
            )  β”œβ—‹β”€β”€β”€ Y = (AβŠ•B)'
            ) )
            ))
       B β”€β”€β”€β”€β”˜

Boolean Expression: Y = (A βŠ• B)' = AΒ·B + A'Β·B'

Truth Table:
β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ Y=(AβŠ•B)'β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚    1    β”‚
β”‚ 0 β”‚ 1 β”‚    0    β”‚
β”‚ 1 β”‚ 0 β”‚    0    β”‚
β”‚ 1 β”‚ 1 β”‚    1    β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Applications: Equality checker, comparators, error detection

Summary of All Gates

GateExpressionOutput 1 whenType
ANDAΒ·BALL inputs are 1Basic
ORA+BAT LEAST ONE input is 1Basic
NOTA'Input is 0Basic
NAND(AΒ·B)'AT LEAST ONE input is 0Universal
NOR(A+B)'ALL inputs are 0Universal
XORAβŠ•BInputs are DIFFERENTSpecial
XNOR(AβŠ•B)'Inputs are SAMESpecial

Complete Truth Table Comparison

β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”
β”‚ A β”‚ B β”‚ AND β”‚ OR β”‚ NOT β”‚ NAND β”‚ NOR β”‚ XOR β”‚ XNOR β”‚
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ 0 β”‚  0  β”‚ 0  β”‚ 1,0 β”‚  1   β”‚  1  β”‚  0  β”‚  1   β”‚
β”‚ 0 β”‚ 1 β”‚  0  β”‚ 1  β”‚ 1,0 β”‚  1   β”‚  0  β”‚  1  β”‚  0   β”‚
β”‚ 1 β”‚ 0 β”‚  0  β”‚ 1  β”‚ 0,1 β”‚  1   β”‚  0  β”‚  1  β”‚  0   β”‚
β”‚ 1 β”‚ 1 β”‚  1  β”‚ 1  β”‚ 0,1 β”‚  0   β”‚  0  β”‚  0  β”‚  1   β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜

Implementing Gates Using NAND

1. NOT using NAND:
   A ────NAND──── A'    (Connect both inputs together)
         β”‚
   A β”€β”€β”€β”€β”˜

2. AND using NAND:
   A ────┐
         NAND──NAND── AΒ·B
   B β”€β”€β”€β”€β”˜

3. OR using NAND:
   A ──NAND──┐
             NAND── A+B
   B ──NANDβ”€β”€β”˜

4. NOR using NAND:
   A ──NAND──┐
             NAND──NAND── (A+B)'
   B ──NANDβ”€β”€β”˜

Implementing Gates Using NOR

1. NOT using NOR:
   A ────NOR──── A'    (Connect both inputs together)
         β”‚
   A β”€β”€β”€β”€β”˜

2. OR using NOR:
   A ────┐
         NOR──NOR── A+B
   B β”€β”€β”€β”€β”˜

3. AND using NOR:
   A ──NOR──┐
            NOR── AΒ·B
   B ──NORβ”€β”€β”˜

4. NAND using NOR:
   A ──NOR──┐
            NOR──NOR── (AΒ·B)'
   B ──NORβ”€β”€β”˜

Multiple-Input Gates

3-Input AND Gate:

Y = AΒ·BΒ·C

A  B  C  |  Y
0  0  0  |  0
0  0  1  |  0
0  1  0  |  0
0  1  1  |  0
1  0  0  |  0
1  0  1  |  0
1  1  0  |  0
1  1  1  |  1  ← Only when ALL are 1

3-Input OR Gate:

Y = A+B+C

A  B  C  |  Y
0  0  0  |  0  ← Only when ALL are 0
0  0  1  |  1
0  1  0  |  1
0  1  1  |  1
1  0  0  |  1
1  0  1  |  1
1  1  0  |  1
1  1  1  |  1

3-Input XOR Gate:

Y = AβŠ•BβŠ•C  (Output 1 when ODD number of 1s)

A  B  C  |  Y
0  0  0  |  0
0  0  1  |  1  ← Odd (1)
0  1  0  |  1  ← Odd (1)
0  1  1  |  0
1  0  0  |  1  ← Odd (1)
1  0  1  |  0
1  1  0  |  0
1  1  1  |  1  ← Odd (3)

Tri-State Buffer

A special gate with 3 output states: HIGH (1), LOW (0), and HIGH-IMPEDANCE (Z - disconnected).

Symbol:
       Data ────▷──── Output
                β”‚
             Enable

Truth Table:
Enable  Data  |  Output
  0      X    |    Z     (High-impedance, disconnected)
  1      0    |    0
  1      1    |    1

Applications: Bus systems, memory interfacing, bidirectional data lines

Logic Gate IC Packages

IC NumberGate TypeDescription
7400NANDQuad 2-input NAND gates
7402NORQuad 2-input NOR gates
7404NOTHex inverters
7408ANDQuad 2-input AND gates
7432ORQuad 2-input OR gates
7486XORQuad 2-input XOR gates
74266XNORQuad 2-input XNOR gates
✏️ Practice: 1) Draw logic circuit for: Y = A·B + B·C' 2) Create truth table for 3-input NAND gate 3) Implement OR gate using only NAND gates 4) Find output of XOR gate when A=1, B=0 5) What is the output of: (A NAND B) OR (C XOR D) for A=1, B=1, C=0, D=1?
Unit 4

Combinational Circuits

Adders, Subtractors, Multiplexers, Demultiplexers, Encoders, Decoders, Comparators

What are Combinational Circuits?

Combinational circuits are logic circuits whose outputs depend ONLY on present inputs (no memory). Output changes immediately when input changes.

Characteristics:

  • No feedback loops
  • No memory elements (no flip-flops)
  • Output = f(present inputs only)
  • Faster than sequential circuits

1. Half Adder

Adds two 1-bit binary numbers. Produces SUM and CARRY.

Truth Table:
A  B  |  Sum  Carry
0  0  |   0     0
0  1  |   1     0
1  0  |   1     0
1  1  |   0     1

Boolean Expressions:
Sum = A βŠ• B  (XOR)
Carry = A Β· B  (AND)

Circuit Diagram:
A ───┐
     XOR──── Sum
B β”€β”€β”€β”˜

A ───┐
     AND──── Carry
B β”€β”€β”€β”˜

2. Full Adder

Adds THREE 1-bit binary numbers (A, B, and Carry-in). Produces SUM and CARRY-out.

Truth Table:
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

Boolean Expressions:
Sum = A βŠ• B βŠ• Cin
Cout = AΒ·B + CinΒ·(AβŠ•B)
     = AΒ·B + BΒ·Cin + AΒ·Cin

Implementation using Two Half Adders:
A ──┐           β”Œβ”€β”€β”€ Sum
    HA1 ── S ───HA2
B β”€β”€β”˜    C      β”‚
         β”‚      Cin
         └──ORβ”€β”€β”˜β”€β”€β”€ Cout

4-bit Binary Adder (Ripple Carry)

Connects 4 Full Adders in series

A₃B₃  Aβ‚‚Bβ‚‚  A₁B₁  Aβ‚€Bβ‚€
 β”‚ β”‚   β”‚ β”‚   β”‚ β”‚   β”‚ β”‚
 FA    FA    FA    FA
 β”‚     β”‚     β”‚     β”‚
C₄────C₃────C₂────C₁────Cβ‚€(0)

Sum: S₃ Sβ‚‚ S₁ Sβ‚€
Carry: Cβ‚„

3. Half Subtractor

Subtracts two 1-bit binary numbers.

Truth Table:
A  B  |  Diff  Borrow
0  0  |   0      0
0  1  |   1      1
1  0  |   1      0
1  1  |   0      0

Boolean Expressions:
Diff = A βŠ• B
Borrow = A'Β·B

4. Full Subtractor

Subtracts three bits (A - B - Bin).

Boolean Expressions:
Diff = A βŠ• B βŠ• Bin
Bout = A'Β·B + BinΒ·(AβŠ•B)'
     = A'Β·B + A'Β·Bin + BΒ·Bin

5. Multiplexer (MUX)

Data selector. Selects ONE of many inputs and forwards it to output based on select lines.

2:1 Multiplexer (2 inputs, 1 select line)

Block Diagram:
Iβ‚€ ──┐
     β”‚ MUX
I₁ ───  2:1  ──── Y
     β”‚
S  β”€β”€β”˜

Truth Table:
S  |  Y
0  |  Iβ‚€
1  |  I₁

Boolean Expression:
Y = S'Β·Iβ‚€ + SΒ·I₁

4:1 Multiplexer (4 inputs, 2 select lines)

Block Diagram:
Iβ‚€ ──┐
I₁ ─── MUX
Iβ‚‚ ─── 4:1  ──── Y
I₃ β”€β”€β”˜
S₁Sβ‚€

Truth Table:
S₁ Sβ‚€ |  Y
0  0  |  Iβ‚€
0  1  |  I₁
1  0  |  Iβ‚‚
1  1  |  I₃

Boolean Expression:
Y = S₁'Β·Sβ‚€'Β·Iβ‚€ + S₁'Β·Sβ‚€Β·I₁ + S₁·Sβ‚€'Β·Iβ‚‚ + S₁·Sβ‚€Β·I₃

Applications: Data routing, parallel-to-serial conversion, function generators, ALU input selection

6. Demultiplexer (DEMUX)

Data distributor. Routes ONE input to ONE of many outputs based on select lines.

1:4 Demultiplexer

Block Diagram:
        β”Œβ”€β”€β”€β”€ Yβ‚€
        β”‚
   D─────DEMUX Y₁
   1:4  β”‚
        │──── Yβ‚‚
        β”‚
        └──── Y₃
        S₁Sβ‚€

Truth Table:
S₁ Sβ‚€ |  Yβ‚€  Y₁  Yβ‚‚  Y₃
0  0  |   D   0   0   0
0  1  |   0   D   0   0
1  0  |   0   0   D   0
1  1  |   0   0   0   D

Boolean Expressions:
Yβ‚€ = S₁'Β·Sβ‚€'Β·D
Y₁ = S₁'Β·Sβ‚€Β·D
Yβ‚‚ = S₁·Sβ‚€'Β·D
Y₃ = S₁·Sβ‚€Β·D

Applications: Serial-to-parallel conversion, address decoding, communication systems

7. Encoder

Converts 2ⁿ input lines to n output lines. Only ONE input should be active at a time.

4:2 Encoder (4 inputs to 2 outputs)

Truth Table:
I₃ Iβ‚‚ I₁ Iβ‚€ |  Y₁ Yβ‚€
0  0  0  1  |  0  0
0  0  1  0  |  0  1
0  1  0  0  |  1  0
1  0  0  0  |  1  1

Boolean Expressions:
Y₁ = I₃ + Iβ‚‚
Yβ‚€ = I₃ + I₁

Priority Encoder: When multiple inputs are active, encodes the highest priority input.

Applications: Keyboard encoding, interrupt handling, data compression

8. Decoder

Converts n input lines to 2ⁿ output lines. Only ONE output is active for each input combination.

2:4 Decoder (2 inputs to 4 outputs)

Truth Table:
A₁ Aβ‚€ |  Y₃ Yβ‚‚ Y₁ Yβ‚€
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:
Yβ‚€ = A₁'Β·Aβ‚€'
Y₁ = A₁'Β·Aβ‚€
Yβ‚‚ = A₁·Aβ‚€'
Y₃ = A₁·Aβ‚€

Applications: Memory address decoding, instruction decoding, display drivers (7-segment)

9. 7-Segment Display Decoder

Converts 4-bit BCD to 7-segment display output.

7-Segment Display Layout:
     aaa
    f   b
     ggg
    e   c
     ddd

BCD to 7-Segment:
BCD  | abcdefg | Display
0000 | 1111110 |   0
0001 | 0110000 |   1
0010 | 1101101 |   2
0011 | 1111001 |   3
0100 | 0110011 |   4
0101 | 1011011 |   5
0110 | 1011111 |   6
0111 | 1110000 |   7
1000 | 1111111 |   8
1001 | 1111011 |   9

10. Magnitude Comparator

Compares two binary numbers and indicates whether they are equal, or one is greater/less than the other.

1-bit Comparator:

Truth Table:
A  B  |  A>B  A=B  ABoolean Expressions:
A > B = AΒ·B'
A = B = A'Β·B' + AΒ·B = (AβŠ•B)'
A < B = A'Β·B

2-bit Comparator:

Compare A₁Aβ‚€ with B₁Bβ‚€

A=B when: (Aβ‚βŠ•B₁)' Β· (Aβ‚€βŠ•Bβ‚€)'

A>B when: A₁·B₁' + (Aβ‚βŠ•B₁)'Β·Aβ‚€Β·Bβ‚€'

A

Applications: Sorting algorithms, control circuits, microprocessor ALU

Combinational Circuit Design Steps

Step-by-step Design Process:

  • Step 1: Problem Statement - Understand what the circuit should do
  • Step 2: Input/Output Identification - Determine number and type of I/O
  • Step 3: Truth Table - List all input combinations and desired outputs
  • Step 4: Boolean Expression - Derive from truth table (SOP or POS)
  • Step 5: Simplification - Use Boolean algebra or K-map
  • Step 6: Logic Diagram - Draw circuit using gates
  • Step 7: Verification - Test with all input combinations

Parity Generator & Checker

Even Parity Generator (3-bit):

Adds parity bit to make total 1s even

A  B  C  |  P (Parity bit)
0  0  0  |  0   (0 ones β†’ even, add 0)
0  0  1  |  1   (1 one β†’ odd, add 1)
0  1  0  |  1
0  1  1  |  0
1  0  0  |  1
1  0  1  |  0
1  1  0  |  0
1  1  1  |  1

P = A βŠ• B βŠ• C

Even Parity Checker:

Checks if total 1s (including parity bit) is even

Error = A βŠ• B βŠ• C βŠ• P
Error = 0 β†’ No error (even parity maintained)
Error = 1 β†’ Error detected (odd parity)

Applications: Error detection in data transmission, memory systems, communication protocols

Code Converter Circuits

1. Binary to Gray Code Converter:

For 3-bit (Bβ‚‚B₁Bβ‚€ β†’ Gβ‚‚G₁Gβ‚€):

Gβ‚‚ = Bβ‚‚
G₁ = Bβ‚‚ βŠ• B₁
Gβ‚€ = B₁ βŠ• Bβ‚€

2. Gray to Binary Code Converter:

For 3-bit (Gβ‚‚G₁Gβ‚€ β†’ Bβ‚‚B₁Bβ‚€):

Bβ‚‚ = Gβ‚‚
B₁ = Bβ‚‚ βŠ• G₁
Bβ‚€ = B₁ βŠ• Gβ‚€

3. BCD to Excess-3 Converter:

Excess-3 = BCD + 3. Used in arithmetic operations to avoid 0000 representation.

Arithmetic Logic Unit (ALU)

A combinational circuit that performs arithmetic (add, subtract) and logic (AND, OR, XOR) operations.

Simple 4-function ALU:

Inputs: A, B (n-bit data)
        S₁Sβ‚€ (2-bit operation select)

S₁ Sβ‚€ |  Operation
0  0  |  A AND B
0  1  |  A OR B
1  0  |  A XOR B
1  1  |  A + B
✏️ Practice: 1) Design a half adder and verify with truth table 2) Draw a 4:1 MUX circuit 3) Create truth table for 3:8 decoder 4) Design a 2-bit magnitude comparator 5) Implement full adder using two half adders and an OR gate
Unit 5

Sequential Circuits

Flip-flops (SR, JK, D, T), Latches, State diagrams, and Timing diagrams

What are Sequential Circuits?

Sequential circuits are logic circuits whose outputs depend on BOTH present inputs AND past outputs (memory). They have feedback loops and memory elements.

Combinational vs Sequential:

FeatureCombinationalSequential
MemoryNo memoryHas memory
Output depends onPresent inputs onlyPresent inputs + past state
FeedbackNo feedbackFeedback present
ClockNot neededUsually clock-driven
ElementsGates onlyGates + Flip-flops
ExamplesAdder, MUX, DecoderCounter, Register, FSM

Types of Sequential Circuits

  • Synchronous: State changes only at clock edges (clock-driven)
  • Asynchronous: State changes immediately when inputs change (no clock)

Memory Elements

1. Latch

Level-sensitive memory element. Changes output when enable signal is HIGH.

2. Flip-Flop

Edge-sensitive memory element. Changes output only at clock edge (rising or falling).

πŸ’‘ Key Difference: Latch is level-triggered (responds to signal level), Flip-flop is edge-triggered (responds to clock edge transition).

SR Latch (Set-Reset Latch)

Most basic memory element using NAND or NOR gates.

SR Latch using NOR gates:

Circuit:
S ──NOR──┬──── Q
    β”Œβ”€β”€β”€β”€β”˜
    β”‚
    └────┐
R ──NOR──┴──── Q'

Truth Table:
S  R  |  Q   Q'  |  State
0  0  |  Q   Q'  |  Hold (No change)
0  1  |  0   1   |  Reset
1  0  |  1   0   |  Set
1  1  |  0   0   |  Invalid (Not allowed!)

Characteristic Equation:
Q(next) = S + R'Β·Q
⚠️ Invalid State: S=R=1 produces Q=Q'=0, violating the rule that Q and Q' should be complements. Avoid this state!

SR Latch using NAND gates:

Truth Table (Active LOW inputs):
SΜ„  RΜ„  |  Q   Q'  |  State
0  0  |  1   1   |  Invalid
0  1  |  1   0   |  Set
1  0  |  0   1   |  Reset
1  1  |  Q   Q'  |  Hold

Gated SR Latch

SR Latch with enable signal. Changes only when Enable=1.

Block Diagram:
S ──┐
    Enable──── SR Latch ──── Q
R β”€β”€β”˜                   └──── Q'
EN

Truth Table:
EN  S  R  |  Q(next)
0   X  X  |  Q (Hold)
1   0  0  |  Q (Hold)
1   0  1  |  0 (Reset)
1   1  0  |  1 (Set)
1   1  1  |  Invalid

D Latch (Data Latch)

Eliminates invalid state of SR latch. Has only one data input.

Circuit:
D ──┬───────── S
    β”‚         SR Latch ──── Q
    └──NOT──  R

Truth Table:
EN  D  |  Q(next)
0   X  |  Q (Hold)
1   0  |  0
1   1  |  1

When EN=1: Q follows D
When EN=0: Q holds previous value

Flip-Flops (Edge-Triggered)

Clock Triggering Types:

  • Positive Edge Triggered: Changes at rising edge (0β†’1) ↑
  • Negative Edge Triggered: Changes at falling edge (1β†’0) ↓

1. SR Flip-Flop

Edge-triggered version of SR latch.

Symbol:
S ─────┐
       β”‚  SR
CLK ────  FF  ──── Q
       β”‚      └──── Q'
R β”€β”€β”€β”€β”€β”˜

Truth Table (Positive Edge Triggered):
S  R  |  Q(t+1)  |  Comment
0  0  |   Q(t)   |  No change
0  1  |    0     |  Reset
1  0  |    1     |  Set
1  1  |  Invalid |  Not allowed

Characteristic Equation:
Q(t+1) = S + R'Β·Q(t)

2. JK Flip-Flop

Most versatile flip-flop. Eliminates invalid state by toggling output when J=K=1.

Symbol:
J ─────┐
       β”‚  JK
CLK ────  FF  ──── Q
       β”‚      └──── Q'
K β”€β”€β”€β”€β”€β”˜

Truth Table:
J  K  |  Q(t+1)  |  Comment
0  0  |   Q(t)   |  No change (Hold)
0  1  |    0     |  Reset
1  0  |    1     |  Set
1  1  |   Q'(t)  |  Toggle

Characteristic Equation:
Q(t+1) = JΒ·Q'(t) + K'Β·Q(t)

Timing Diagram:

CLK  ──┐ β”Œβ”€β” β”Œβ”€β” β”Œβ”€β” β”Œβ”€β”
       β””β”€β”˜ β””β”€β”˜ β””β”€β”˜ β””β”€β”˜
J    ────────┐     β”Œβ”€β”€β”€β”€
K    ──┐     β””β”€β”€β”€β”€β”€β”˜
       └────────────────
Q    ──┐   β”Œβ”€β”€β”€β”   β”Œβ”€β”€β”€
       β””β”€β”€β”€β”˜   β””β”€β”€β”€β”˜

J=0,K=1 β†’ Reset (Q=0)
J=1,K=0 β†’ Set (Q=1)
J=1,K=1 β†’ Toggle
J=0,K=0 β†’ Hold

3. D Flip-Flop (Data/Delay Flip-Flop)

Stores one bit of data. Output Q follows input D at clock edge.

Symbol:
D ─────┐
       β”‚  D
CLK ────  FF  ──── Q
       β”‚      └──── Q'
       β””

Truth Table:
D  |  Q(t+1)
0  |    0
1  |    1

Characteristic Equation:
Q(t+1) = D

Note: No invalid state, simplest to use

Applications: Shift registers, data storage, delay elements, frequency division

4. T Flip-Flop (Toggle Flip-Flop)

Toggles output when T=1. Used in counters.

Symbol:
T ─────┐
       β”‚  T
CLK ────  FF  ──── Q
       β”‚      └──── Q'
       β””

Truth Table:
T  |  Q(t+1)  |  Comment
0  |   Q(t)   |  No change
1  |  Q'(t)   |  Toggle

Characteristic Equation:
Q(t+1) = TΒ·Q'(t) + T'Β·Q(t) = T βŠ• Q(t)

T Flip-Flop from JK: Connect J and K together β†’ T input

T Flip-Flop from D: Feed Q' XOR T to D input

Flip-Flop Conversion

Conversion Table:

Convert FromToMethod
JK to DDD = J = K'
JK to TTJ = K = T
D to JKJKJ = D, K = D'
D to TTD = T βŠ• Q
T to JKJKJ = K = T
T to DDD = T βŠ• Q

Example: Convert SR to JK

Excitation Table Comparison:

Q(t)  Q(t+1) |  S  R  |  J  K
  0     0    |  0  X  |  0  X
  0     1    |  1  0  |  1  X
  1     0    |  0  1  |  X  1
  1     1    |  X  0  |  X  0

Conversion Logic:
S = JΒ·Q'
R = KΒ·Q

Master-Slave Flip-Flop

Two flip-flops in series. Master captures input, slave outputs after clock.

Block Diagram:
J ──┐         β”Œβ”€β”€β”         β”Œβ”€β”€ Q
    Master FF β”‚  β”‚ Slave FF β”‚
K β”€β”€β”˜    Qβ”€β”€β”€β”€β”˜  └─── Q β”€β”€β”€β”˜β”€β”€ Q'
CLK ──┬──────────NOT────┐
      β”‚                 β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Operation:
1. When CLK=1: Master enabled, Slave disabled
   Master captures J, K inputs
2. When CLK=0: Master disabled, Slave enabled
   Slave copies Master output

Advantage: Prevents race conditions

Preset and Clear Inputs

Asynchronous inputs that override clock. Used for initialization.

Flip-Flop with Preset (PRE) and Clear (CLR):

PRE ────┐
        β”‚  FF
D   ─────     ──── Q
CLK ─────     └──── Q'
        β”‚
CLR β”€β”€β”€β”€β”˜

Truth Table:
PRE  CLR |  Q   Q'  |  Comment
 0    0  |  1   1   |  Invalid
 0    1  |  1   0   |  Preset (Set Q=1)
 1    0  |  0   1   |  Clear (Set Q=0)
 1    1  |  Operates normally with CLK/D

State Diagrams

Graphical representation of sequential circuit behavior showing states and transitions.

Example: 2-bit Binary Counter

         β”Œβ”€β”€β”€β”€β”€β”
      β”Œβ”€β”€β”‚  00 │──┐
      β”‚  β””β”€β”€β”€β”€β”€β”˜  β”‚
      β”‚     ↓     β”‚
      β”‚  β”Œβ”€β”€β”€β”€β”€β”  β”‚
      └──│  01 β”‚β†β”€β”˜
         β””β”€β”€β”€β”€β”€β”˜
            ↓
         β”Œβ”€β”€β”€β”€β”€β”
      β”Œβ”€β”€β”‚  10 │←─┐
      β”‚  β””β”€β”€β”€β”€β”€β”˜  β”‚
      β”‚     ↓     β”‚
      β”‚  β”Œβ”€β”€β”€β”€β”€β”  β”‚
      └──│  11 β”‚β”€β”€β”˜
         β””β”€β”€β”€β”€β”€β”˜
            ↓
         (back to 00)

States: 00 β†’ 01 β†’ 10 β†’ 11 β†’ 00...

State Table

Tabular representation of state transitions.

Example: JK Flip-Flop State Table

Present  Inputs |  Next
State    J   K  |  State
  0      0   0  |   0
  0      0   1  |   0
  0      1   0  |   1
  0      1   1  |   1
  1      0   0  |   1
  1      0   1  |   0
  1      1   0  |   1
  1      1   1  |   0

Excitation Tables

Shows required inputs to achieve desired state transitions. Used in flip-flop conversions.

Flip-FlopQ(t)β†’Q(t+1): 0β†’00β†’11β†’01β†’1
SRS=0, R=XS=1, R=0S=0, R=1S=X, R=0
JKJ=0, K=XJ=1, K=XJ=X, K=1J=X, K=0
DD=0D=1D=0D=1
TT=0T=1T=1T=0
πŸ’‘ X = Don't Care: Can be 0 or 1, doesn't matter. Used for optimization.
✏️ Practice: 1) Draw timing diagram for JK flip-flop with J=1, K=0 2) Design a T flip-flop using D flip-flop 3) Create state diagram for 3-bit up counter 4) Convert D flip-flop to JK flip-flop 5) What is the output of SR latch when S=1, R=1?
Unit 6

Counters & Registers

Up/Down counters, Ring counters, Shift registers, and Applications

What is a Counter?

A counter is a sequential circuit that goes through a predetermined sequence of states upon application of clock pulses. Counts number of clock pulses.

Types of Counters

⬆️ Up Counter: Counts 0β†’1β†’2β†’3...
⬇️ Down Counter: Counts 3β†’2β†’1β†’0...
πŸ”„ Up/Down Counter: Both directions
πŸ”’ Modulo-N: Counts 0 to N-1

1. Asynchronous (Ripple) Counter

Flip-flops are NOT clocked simultaneously. Output of one triggers the next.

2-bit Asynchronous Up Counter:

Circuit:
CLK ──┐ T-FF ┐   β”Œ T-FF ┐
      β”‚  T=1 β”‚Qβ‚€ β”‚  T=1 β”‚Q₁
      β””β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”˜

Timing Diagram:
CLK  ──┐ β”Œβ”€β” β”Œβ”€β” β”Œβ”€β” β”Œβ”€
       β””β”€β”˜ β””β”€β”˜ β””β”€β”˜ β””β”€β”˜
Qβ‚€   ──┐   β”Œβ”€β”€β”€β”   β”Œβ”€β”€β”€
       β””β”€β”€β”€β”˜   β””β”€β”€β”€β”˜
Q₁   ──┐       β”Œβ”€β”€β”€β”€β”€β”€β”€
       β””β”€β”€β”€β”€β”€β”€β”€β”˜

Count: 00 β†’ 01 β†’ 10 β†’ 11 β†’ 00...

MOD-4 Counter (counts 0-3)

3-bit Asynchronous Up Counter:

Counts: 000 β†’ 001 β†’ 010 β†’ 011 β†’ 100 β†’ 101 β†’ 110 β†’ 111 β†’ 000
MOD-8 Counter (8 states)

Disadvantage: Propagation delay (ripple effect)

2. Synchronous Counter

All flip-flops are clocked simultaneously. No ripple delay.

2-bit Synchronous Up Counter:

Circuit using JK Flip-Flops:
       β”Œβ”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”
Jβ‚€=1──│  JK  │──Q₀──│  JK  │──Q₁
Kβ‚€=1──│  FF0 β”‚      β”‚  FF1 β”‚
CLKβ”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜  Jβ‚β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜
                K₁

J₁ = K₁ = Qβ‚€

State Table:
Q₁ Qβ‚€ |  J₁K₁  Jβ‚€Kβ‚€ |  Next
 0  0  |   0X   11   |   01
 0  1  |   1X   11   |   10
 1  0  |   X0   11   |   11
 1  1  |   X1   11   |   00

3. Decade Counter (MOD-10)

Counts from 0 to 9, then resets to 0. Uses 4 flip-flops but only 10 states.

BCD Counter:
Count: 0000 β†’ 0001 β†’ 0010 β†’ ... β†’ 1001 β†’ 0000

IC 7490: Decade Counter chip

4. Ring Counter

Shift register with output fed back to input. Circulates single '1' bit.

4-bit Ring Counter:

D-FFβ‚€ β†’ D-FF₁ β†’ D-FFβ‚‚ β†’ D-FF₃ →┐
  ↑                              β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Sequence:
Q₃Qβ‚‚Q₁Qβ‚€
1000 β†’ 0100 β†’ 0010 β†’ 0001 β†’ 1000...

Applications: State machines, sequence generators

5. Johnson Counter (Twisted Ring)

Ring counter with inverted feedback. Has 2N states for N flip-flops.

4-bit Johnson Counter:

D-FFβ‚€ β†’ D-FF₁ β†’ D-FFβ‚‚ β†’ D-FF₃ →┐
  ↑                             NOT
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Sequence (8 states):
0000 β†’ 1000 β†’ 1100 β†’ 1110 β†’ 1111 β†’ 0111 β†’ 0011 β†’ 0001 β†’ 0000

Registers

A register is a group of flip-flops used to store multiple bits of data. Each flip-flop stores one bit.

1. Parallel-In Parallel-Out (PIPO) Register

All bits loaded and read simultaneously.

4-bit PIPO Register:

D₃──D-FF₃──Q₃    D₂──D-FF₂──Qβ‚‚    D₁──D-FF₁──Q₁    D₀──D-FF₀──Qβ‚€
       β”‚              β”‚              β”‚              β”‚
    CLK ─────────────────────────────────────────────

All data loaded at once on clock edge
All data read at once

2. Serial-In Serial-Out (SISO) Register

Data shifted in and out one bit at a time. Basic shift register.

4-bit SISO (Right Shift):

DIN ── D-FFβ‚€ ─ D-FF₁ ─ D-FFβ‚‚ ─ D-FF₃ ── DOUT
         β”‚       β”‚       β”‚       β”‚
      CLK ──────────────────────────

Example: Input 1011 (MSB first)
CLK  State
 0   0000  (Initial)
 1   1000  (Input 1)
 2   1100  (Input 0)
 3   1110  (Input 1)
 4   1111  (Input 1)

3. Serial-In Parallel-Out (SIPO) Register

Data shifted in serially, read out in parallel. Serial-to-parallel conversion.

Application: UART receiver, SPI communication

4. Parallel-In Serial-Out (PISO) Register

Data loaded in parallel, shifted out serially. Parallel-to-serial conversion.

Application: UART transmitter, data serialization

Shift Register Modes

ModeDescriptionApplication
Right ShiftBits shift right, divide by 2Division, serial output
Left ShiftBits shift left, multiply by 2Multiplication, serial output
Rotate RightMSB→LSB (circular)Rotation, code generation
Rotate LeftLSB→MSB (circular)Rotation, code generation
BidirectionalShift both directionsUniversal shift register

Universal Shift Register

Can perform all shift operations: left, right, parallel load, parallel read.

Mode Select (S₁Sβ‚€):
S₁ Sβ‚€ |  Operation
0  0  |  No change (Hold)
0  1  |  Shift Right
1  0  |  Shift Left
1  1  |  Parallel Load

IC 74195: 4-bit universal shift register

Applications of Counters

  • Frequency Division: MOD-N counter divides frequency by N
  • Digital Clock: MOD-60 for seconds/minutes, MOD-24 for hours
  • Event Counting: Counting products, pulses, events
  • Timing Circuits: Generating time delays
  • Address Generation: Memory addressing in CPUs
  • Sequence Generation: State machines, control logic

Applications of Registers

  • Data Storage: CPU registers (accumulator, program counter)
  • Data Transfer: Buffer between components
  • Serial Communication: UART, SPI, I2C
  • Arithmetic Operations: Shifting for multiply/divide
  • Timing & Synchronization: Pipeline registers
  • Data Serialization: Parallel to serial conversion

Counter ICs

IC NumberTypeDescription
7490DecadeMOD-10 asynchronous counter
7493Binary4-bit binary counter (MOD-16)
74190Up/DownSynchronous BCD up/down counter
74191Up/DownSynchronous binary up/down counter
74193Up/Down4-bit binary up/down counter
✏️ Practice: 1) Design a MOD-6 counter using JK flip-flops 2) Draw timing diagram for 3-bit ripple counter 3) Design a 4-bit SISO shift register 4) What is the output sequence of a 3-bit Johnson counter? 5) Calculate frequency at output of MOD-8 counter if input is 1 MHz
Unit 7

Memory Systems

RAM, ROM, SRAM, DRAM, Memory organization, and Address decoding

What is Memory?

Memory is a digital circuit that stores data in binary form. Essential component of all computer systems.

Memory Classification

Memory Hierarchy:

                Memory
                  β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                   β”‚
     Volatile            Non-Volatile
    (RAM)                (ROM)
        β”‚                   β”‚
   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
   β”‚         β”‚         β”‚         β”‚
 SRAM     DRAM       ROM      EPROM
                               EEPROM
                               Flash

1. RAM (Random Access Memory)

Volatile memory: Data lost when power off. Read and Write operations.

Types:

A) SRAM (Static RAM)

  • Uses flip-flops (6 transistors per bit)
  • Faster than DRAM
  • No refresh required
  • More expensive
  • Lower density
  • Used in: Cache memory, CPU registers

B) DRAM (Dynamic RAM)

  • Uses capacitors (1 transistor + 1 capacitor per bit)
  • Slower than SRAM
  • Requires periodic refresh (capacitor leaks)
  • Cheaper
  • Higher density
  • Used in: Main memory (system RAM)
FeatureSRAMDRAM
SpeedFast (2-10 ns)Slower (50-70 ns)
CostExpensiveCheap
DensityLowHigh
PowerLowHigh
RefreshNot neededNeeded
ComplexityComplex (6T)Simple (1T1C)
UsageCacheMain memory

2. ROM (Read-Only Memory)

Non-volatile memory: Data retained when power off. Primarily read operations.

Types:

A) Mask ROM

  • Programmed during manufacturing
  • Cannot be modified
  • Used in: BIOS, firmware, embedded systems

B) PROM (Programmable ROM)

  • One-time programmable by user
  • Uses fuses that can be blown
  • Cannot be erased once programmed

C) EPROM (Erasable PROM)

  • Can be erased using UV light
  • Reprogrammable
  • Has transparent window on top
  • Erase time: 15-20 minutes

D) EEPROM (Electrically Erasable PROM)

  • Can be erased electrically (byte-by-byte)
  • No UV light needed
  • Slower write, faster read
  • Used in: Configuration data, calibration

E) Flash Memory

  • Type of EEPROM, erases in blocks
  • Fast, high density
  • Used in: USB drives, SSDs, memory cards
TypeErase MethodWrite SpeedApplication
Mask ROMCannot eraseN/ABIOS, firmware
PROMCannot eraseFastOne-time programming
EPROMUV lightSlowDevelopment, testing
EEPROMElectrical (byte)Very slowConfig, calibration
FlashElectrical (block)MediumStorage, USB, SSD

Memory Organization

Memory Specifications:

  • Capacity: Total number of bits (M Γ— N)
  • M: Number of words (addressable locations)
  • N: Number of bits per word (word size)
  • Address lines: logβ‚‚(M) lines needed
Example: 1K Γ— 8 Memory

1K = 1024 words
8 = 8 bits per word

Total capacity: 1024 Γ— 8 = 8192 bits = 8 Kb = 1 KB

Address lines needed: logβ‚‚(1024) = 10 lines
Data lines: 8 lines

Memory Block Diagram:

Aβ‚€-A₉ (10 lines)  ────┐
                      β”‚ 1KΓ—8
CS (Chip Select) ────── Memory ──── Dβ‚€-D₇ (8 lines)
R/WΜ„ (Read/Write) ──────
                      β””

Address Range: 0x000 to 0x3FF (0 to 1023)

Common Memory Sizes:

SpecificationWordsAddress BitsTotal Capacity
256 Γ— 425681 Kb
1K Γ— 81024108 Kb = 1 KB
4K Γ— 840961232 Kb = 4 KB
64K Γ— 865,53616512 Kb = 64 KB
1M Γ— 81,048,576208 Mb = 1 MB

Memory Expansion

1. Word Expansion (Increasing Word Size)

Example: Create 1KΓ—16 using two 1KΓ—8 chips

Aβ‚€-A₉ ──┬─── 1KΓ—8 ──── Dβ‚€-D₇
        β”‚    Chip 1
CS  ────┼─── 1KΓ—8 ──── Dβ‚ˆ-D₁₅
        β”‚    Chip 2
R/WΜ„ β”€β”€β”€β”€β”˜

Same addresses, more data bits

2. Word Count Expansion (Increasing Number of Words)

Example: Create 2KΓ—8 using two 1KΓ—8 chips

Aβ‚€-A₉ ──┬─── 1KΓ—8 ──┐
        β”‚    Chip 1 β”œβ”€β”€β”€ Dβ‚€-D₇
A₁₀ ─────            β”‚
Decoder β”‚    1KΓ—8 β”€β”€β”€β”˜
        └─── Chip 2

A₁₀=0: Chip 1 (0x000-0x3FF)
A₁₀=1: Chip 2 (0x400-0x7FF)

Address Decoding

Process of selecting specific memory chip based on address.

Linear Decoding (Simple but wasteful):

A₁₀ ──NOT── CS̄₁ (Chip 1: A₁₀=0)
A₁₀ ──────── CSΜ„β‚‚ (Chip 2: A₁₀=1)

Full Decoding (Using Decoder):

A₁₀-A₁₁ ───┐
           2:4      CSΜ„β‚€ β†’ Chip 0
          Decoder   CS̄₁ β†’ Chip 1
                    CSΜ„β‚‚ β†’ Chip 2
                    CS̄₃ β†’ Chip 3

Memory Timing

Read Cycle Timing:

Memory Read Timing Diagram:

Address ──┐ Valid Address     β”Œβ”€β”€β”€
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CSΜ„    ────┐                  β”Œβ”€β”€β”€
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

R/WΜ„   ────────────────────────── (High for Read)

Data  ────────┐ Valid Data β”Œβ”€β”€β”€β”€β”€
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

         ←─ tACC ─→  (Access Time)

tACC: Time from address valid to data valid

Write Cycle Timing:

Address ──┐ Valid Address     β”Œβ”€β”€β”€
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CSΜ„    ────┐                  β”Œβ”€β”€β”€
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

R/WΜ„   ────┐                  β”Œβ”€β”€β”€ (Low for Write)
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data  ─────┐ Valid Data      β”Œβ”€β”€β”€β”€
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

         ←─ tWR ─→  (Write Time)

Memory ICs

IC NumberTypeCapacityOrganization
2114SRAM4 Kb1K Γ— 4
6116SRAM16 Kb2K Γ— 8
6264SRAM64 Kb8K Γ— 8
2732EPROM32 Kb4K Γ— 8
2764EPROM64 Kb8K Γ— 8
27C256EPROM256 Kb32K Γ— 8
✏️ Practice: 1) Calculate address lines needed for 16K Γ— 8 memory 2) Design memory system with 4K Γ— 8 using two 2K Γ— 8 chips 3) Compare SRAM vs DRAM 4) What is address range for 1K Γ— 8 memory starting at 0x2000? 5) Draw timing diagram for memory read cycle
Unit 8

Advanced Topics

PLDs, FPGAs, Karnaugh Maps, Quine-McCluskey method, and Modern Digital Design

Karnaugh Maps (K-Maps)

Karnaugh Map is a graphical method for simplifying Boolean expressions. Alternative to Boolean algebra.

2-Variable K-Map:

     B
A    0   1
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€
0 β”‚  0   1
1 β”‚  2   3

Example: F(A,B) = Ξ£m(1,2,3)

     B
A    0   1
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€
0 β”‚  0   1
1 β”‚  1   1

Grouping:
Group 1 (1,3): B
Group 2 (2,3): A

F = A + B

3-Variable K-Map:

       BC
A     00  01  11  10
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
 0 β”‚  0   1   3   2
 1 β”‚  4   5   7   6

Example: F(A,B,C) = Ξ£m(1,3,5,7)

       BC
A     00  01  11  10
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
 0 β”‚  0   1   1   0
 1 β”‚  0   1   1   0

Grouping: Vertical column (1,3,5,7)
F = C

Gray code ordering! (00,01,11,10)

4-Variable K-Map:

         CD
AB      00  01  11  10
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
 00  β”‚  0   1   3   2
 01  β”‚  4   5   7   6
 11  β”‚ 12  13  15  14
 10  β”‚  8   9  11  10

Rules for Grouping:
1. Group size: 1, 2, 4, 8, 16 (powers of 2)
2. Groups should be rectangular
3. Make largest possible groups
4. Groups can overlap
5. Groups can wrap around edges
6. Minimize number of groups

Example: Simplify using K-Map

F(A,B,C,D) = Ξ£m(0,2,5,7,8,10,13,15)

         CD
AB      00  01  11  10
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
 00  β”‚  1   0   0   1      Group 1: m(0,2,8,10) = B'D'
 01  β”‚  0   1   1   0      Group 2: m(5,7,13,15) = BD
 11  β”‚  0   1   1   0
 10  β”‚  1   0   0   1

F = B'D' + BD = B βŠ• D

Don't Care Conditions (X):

F(A,B,C) = Ξ£m(1,3,7) + d(5,6)
d = don't care (can be 0 or 1)

Use X strategically to make larger groups!

       BC
A     00  01  11  10
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
 0 β”‚  0   1   1   0
 1 β”‚  0   X   1   X

Include d(5) in group with m(1,7)
F = C

Quine-McCluskey Method

Tabular method for simplification. Better for >4 variables and computer implementation.

Steps:

  • Step 1: List minterms in binary grouped by number of 1s
  • Step 2: Compare adjacent groups, combine terms differing by 1 bit
  • Step 3: Replace differing bit with dash (-)
  • Step 4: Repeat until no more combinations possible
  • Step 5: Create prime implicant table
  • Step 6: Select minimum set of prime implicants
Example: F(A,B,C) = Ξ£m(1,3,5,6,7)

Step 1: List by number of 1s
Group 0: m₁ = 001
Group 1: m₃ = 011
         mβ‚… = 101
Group 2: m₆ = 110
         m₇ = 111

Step 2: Combine (differ by 1 bit)
m₁,m₃: 0-1  (BC)
m₁,mβ‚…: -01  (A'C)
m₃,m₇: -11  (BC)
mβ‚…,m₇: 1-1  (AC)
m₆,m₇: 11-  (AB)

Step 3: Prime Implicants
BC, A'C, AC, AB

Step 4: Minimum cover
F = A'C + AB + BC

Programmable Logic Devices (PLDs)

ICs that can be programmed to implement custom logic functions. User-configurable hardware.

Types of PLDs

1. PROM (Programmable ROM)

  • Fixed AND array, programmable OR array
  • Simple, but limited flexibility

2. PAL (Programmable Array Logic)

  • Programmable AND array, fixed OR array
  • Fast, low cost
  • Cannot share product terms between outputs

3. PLA (Programmable Logic Array)

  • Both AND and OR arrays programmable
  • More flexible than PAL
  • Can share product terms
  • Slower than PAL
PLD Structure:

Inputs β†’ AND Array β†’ OR Array β†’ Outputs

PAL: Programmable AND, Fixed OR
PLA: Programmable AND, Programmable OR
PROM: Fixed AND, Programmable OR
FeaturePALPLAPROM
AND ArrayProgrammableProgrammableFixed
OR ArrayFixedProgrammableProgrammable
SpeedFastMediumFast
FlexibilityMediumHighLow
CostLowMediumLow

Complex PLDs (CPLDs)

Multiple PAL/PLA blocks connected via programmable interconnects.

  • More logic capacity than simple PLDs
  • Non-volatile (retains configuration when powered off)
  • Predictable timing
  • Examples: Xilinx CoolRunner, Altera MAX
  • Applications: Glue logic, state machines, interface logic

Field-Programmable Gate Arrays (FPGAs)

Most advanced and flexible PLDs. Array of configurable logic blocks (CLBs).

FPGA Structure:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CLB   CLB   CLB   CLB   CLB  β”‚
β”‚   β”‚     β”‚     β”‚     β”‚     β”‚   β”‚
β”‚  CLB   CLB   CLB   CLB   CLB  β”‚ ← Configurable Logic Blocks
β”‚   β”‚     β”‚     β”‚     β”‚     β”‚   β”‚
β”‚  CLB   CLB   CLB   CLB   CLB  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        Programmable Interconnects

Each CLB contains:
- Look-Up Tables (LUTs) for logic
- Flip-flops for storage
- Multiplexers for routing

FPGA Features:

  • Very high logic capacity (millions of gates)
  • Reconfigurable (can be reprogrammed)
  • Contains RAM blocks, DSP blocks, I/O blocks
  • Volatile configuration (needs external memory)
  • Complex, requires specialized tools

FPGA vs CPLD:

FeatureCPLDFPGA
Capacity10K gates1M+ gates
ArchitecturePAL-basedLUT-based
ConfigurationNon-volatileVolatile (SRAM)
TimingPredictableUnpredictable
PowerLowHigh
CostLowHigh
UseSimple logicComplex systems

FPGA Applications

  • Prototyping: ASIC design verification
  • DSP: Signal processing, image processing
  • Communication: Modems, routers, base stations
  • Aerospace: Satellites, avionics (radiation-tolerant)
  • Industrial: Motor control, robotics
  • AI/ML: Neural network acceleration
  • Automotive: ADAS, autonomous driving
  • Medical: Medical imaging, diagnostics

FPGA Vendors

VendorFPGA FamilyFeatures
Xilinx (AMD)Spartan, Artix, Kintex, VirtexMarket leader, high performance
Intel (Altera)Cyclone, Arria, StratixGood tools, wide adoption
LatticeiCE40, ECP5, CrossLinkLow power, small size
MicrochipPolarFire, IGLOOLow power, secure

Hardware Description Languages (HDLs)

Used to design and program FPGAs/CPLDs.

1. Verilog

// 2-to-1 Multiplexer in Verilog
module mux2to1 (
    input a, b, sel,
    output y
);
    assign y = sel ? b : a;
endmodule

2. VHDL

-- 2-to-1 Multiplexer in VHDL
entity mux2to1 is
    port (a, b, sel : in std_logic;
          y : out std_logic);
end mux2to1;

architecture behav of mux2to1 is
begin
    y <= b when sel = '1' else a;
end behav;

ASIC (Application-Specific Integrated Circuit)

Custom-designed ICs for specific applications. Not programmable like FPGAs.

ASIC vs FPGA:

FeatureASICFPGA
FlexibilityFixed (cannot change)Reconfigurable
Development CostVery high (millions)Low
Unit CostLow (in volume)High
PerformanceHighestLower
PowerLowestHigher
Time-to-MarketLong (months)Short (days)
Use CaseHigh volume productsLow volume, prototyping

Modern Digital Design Flow

1. Specification
   Define requirements, features, constraints
       ↓
2. Architecture Design
   Block diagrams, high-level design
       ↓
3. RTL Design (HDL Coding)
   Write Verilog/VHDL code
       ↓
4. Simulation & Verification
   Testbenches, functional verification
       ↓
5. Synthesis
   Convert HDL to gate-level netlist
       ↓
6. Place & Route
   Map logic to physical layout
       ↓
7. Timing Analysis
   Check timing constraints, optimize
       ↓
8. Bitstream Generation
   Create configuration file for FPGA
       ↓
9. Programming & Testing
   Load onto hardware, test in real environment

Timing Concepts

Setup Time (tsu): Minimum time data must be stable BEFORE clock edge

Hold Time (th): Minimum time data must be stable AFTER clock edge

Clock-to-Q Delay (tCQ): Time from clock edge to output change

Propagation Delay (tp): Time for signal to pass through gate

Timing Diagram:

CLK   ──┐   β”Œβ”€β”€β”€β”€β”€β”   β”Œβ”€
        β””β”€β”€β”€β”˜     β””β”€β”€β”€β”˜

DATA  ──────┐         β”Œβ”€β”€
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

        ←tsuβ†’ ←thβ†’
            ↑ CLK edge

Violation:
- Setup Violation: Data changes too close to clock edge
- Hold Violation: Data changes too soon after clock edge

Clock Frequency & Period

Maximum Clock Frequency:

fmax = 1 / (tCQ + tlogic + tsu)

Where:
tCQ = Clock-to-Q delay of source FF
tlogic = Combinational logic delay
tsu = Setup time of destination FF

Example:
tCQ = 2 ns, tlogic = 8 ns, tsu = 1 ns
fmax = 1 / (2+8+1) ns = 1/11 ns = 90.9 MHz

Metastability

When a flip-flop violates setup/hold time, output may become unstable (neither 0 nor 1).

  • Cause: Asynchronous inputs violating timing
  • Solution: Use synchronizers (2-FF chain)
  • Impact: Unpredictable behavior, system failure

Power Consumption in Digital Circuits

Types:

  • Dynamic Power: Power when switching (CVΒ²f)
  • Static Power: Leakage power when idle
  • Short-Circuit Power: During transition
Dynamic Power:
P = C Γ— VΒ² Γ— f Γ— Ξ±

C = Load capacitance
V = Supply voltage
f = Clock frequency
Ξ± = Switching activity factor (0 to 1)

Reducing Power:
- Lower voltage
- Reduce clock frequency
- Clock gating (disable unused blocks)
- Power gating (turn off unused blocks)

Future of Digital Logic Design

  • 3D ICs: Stacking multiple die layers
  • Quantum Computing: Qubits instead of bits
  • Neuromorphic Computing: Brain-inspired architectures
  • Optical Computing: Light-based logic
  • DNA Computing: Biological computation
  • Spintronics: Using electron spin
✏️ Practice: 1) Simplify F(A,B,C,D) = Σm(0,1,2,5,8,9,10) using K-map 2) Compare PAL, PLA, and PROM 3) List advantages of FPGAs over ASICs 4) Calculate maximum clock frequency if tCQ=3ns, tlogic=10ns, tsu=2ns 5) Draw a 3-variable K-map and group minterms

πŸŽ‰ Congratulations!

You've completed Digital Logic Design course! You now have solid foundation in DLD - from number systems to advanced FPGAs and modern digital design. Keep practicing and building circuits! βš‘πŸš€

Β© 2024 Pak Notes Hub β€” www.paknoteshub.online

Complete University-Level Digital Logic Design Notes in Easy English