UNIT - 1
Digital logic
● It is the "language" of computers.
● It allows electronic devices to understand, process, and store binary information (0s and 1s)
using simple rules of logic.
Ex. - If you press a button (input = 1), and a light turns ON (output = 1), that’s a simple digital logic
action using a logic gate.
Aspect Digital Logic
Works on Binary values (0 and 1)
Based on Logic gates and circuits
Used in All digital devices & computers
Advantage Reliable, fast, easy to scale
Output depends on Logical rules applied to inputs
Logic gate -
A logic gate is the basic building block of digital circuits.
● It performs a logical operation on one or more binary inputs and produces a single binary
output (either 0 or 1).
● In simple words: Logic gates control the flow of digital signals (0s and 1s) using rules of
Boolean algebra.
Basic Types of Logic Gates:
1. AND Gate
○ Output = 1 only if all inputs are 1.
○ Truth Table:
A B Output
0 0 0
0 1 0
1 0 0
1 1 1
2. OR Gate
○ Output = 1 if at least one input is 1.
○ Truth Table:
A B Output
0 0 0
0 1 1
1 0 1
1 1 1
3. NOT Gate (Inverter)
○ Output = opposite of input.
○ Truth Table:
A Output
0 1
1 0
Universal Gates (can build any circuit):
4. NAND Gate (NOT + AND)
○ Output = 0 only if all inputs are 1.
○ Otherwise, output = 1.
5. NOR Gate (NOT + OR)
○ Output = 1 only if all inputs are 0.
Special Gates:
6. XOR (Exclusive OR) Gate
○ Output = 1 if inputs are different.
○ Output = 0 if inputs are the same.
7. XNOR (Exclusive NOR) Gate
○ Output = 1 if inputs are the same.
○ Output = 0 if inputs are different.
Combinational circuit -
A combinational circuit is a digital circuit where the output depends only on the present input values.
There is no memory element, so past inputs have no effect.
Key Characteristics:
● Output = f(Inputs)
● No memory → doesn’t store past states.
● Faster, since it only computes based on inputs.
● Constructed using logic gates.
Examples:
● Adders (Half Adder, Full Adder) → perform binary addition.
● Subtractors → binary subtraction.
● Multiplexers (MUX) → select one input among many.
● Demultiplexers (DEMUX) → route input to one of many outputs.
● Encoders / Decoders → convert data from one form to another.
● Comparators → compare two binary numbers.
Sequential Circuits -
A sequential circuit is a digital circuit where the output depends on both the present inputs and the
past history (stored in memory elements).
Thus, sequential circuits = Combinational circuit + Memory.
Key Characteristics:
● Output = f(Inputs, Previous State)
● Contains memory elements (Flip-Flops, Registers).
● Requires a clock signal for synchronization.
● Slower than combinational (due to memory and clocking).
Examples:
● Flip-Flops (SR, JK, D, T) → store 1 bit of data.
● Registers → group of flip-flops to store multiple bits.
● Counters (Up/Down, Mod-n) → count pulses.
● Shift Registers → shift data left or right.
● Finite State Machines (FSMs) → widely used in control systems.
Comparison Table:
Feature Combinational Circuits Sequential Circuits
Output Depends On Present inputs only Present inputs + past states
Memory No Yes (flip-flops, registers)
Speed Faster Slower (due to memory, clock)
Basic Elements Logic gates Logic gates + memory elements
Clock Signal Not required Required (synchronous circuits)
Examples Adders, MUX, Encoders Flip-Flops, Counters, FSMs
Boolean Laws -
Boolean Laws are the fundamental rules of Boolean algebra, used in digital logic
design and computer science.
These laws are the backbone of logic circuit simplification in digital electronics,
computer architecture, and programming.
They help simplify logic expressions and circuits. Boolean algebra works with
binary values:
● 0 → False (LOW, OFF)
● 1 → True (HIGH, ON)
Laws for Boolean Algebra
These are the rules we use to simplify logical expressions and design efficient
circuits.
1. Identity Law
In the Boolean Algebra, we have identity elements for both AND(.) and OR(+)
operations. The identity law states that in Boolean algebra, we have such
variables that, on operating with the AND and OR operations, we get the same
result, i.e.
● A + 0 = A
● A.1 = A
2. Commutative Law
Binary variables in Boolean Algebra follow the commutative law. This law states
that operating boolean variables A and B is similar to operating boolean
variables B and A. That is,
● A. B = B. A
● A + B = B + A
3. Associative Law
Associative law states that the order of performing Boolean operators is illogical
as their result is always the same. This can be understood as,
● ( A . B ) . C = A . ( B . C )
● ( A + B ) + C = A + ( B + C)
4. Distributive Law
Boolean Variables also follow the distributive law, and the expression for the
Distributive law is given as:
● A . ( B + C) = (A . B) + (A . C)
5. Inversion Law
Inversion law is the unique law of Boolean algebra that states, the complement of
the complement of any number is the number itself.
● (A')' = A
Apart from these other laws are mentioned below:
6. AND Law
AND law of the Boolean algebra uses AND operator and the AND law is,
● A . 0 = 0
● A . 1 = A
● A . A = A
7. OR Law
OR law of the Boolean algebra uses OR operator and the OR law is,
● A + 0 = A
● A + 1 = 1
● A + A = A
8. Complement Law
The Complement Law states that a variable ORed with its complement is always
1, and a variable ANDed with its complement is always 0.
● A + A' = 1
● A . A’ = 0
9. Domination Law
The Domination Law states that any variable ORed with 1 will always be 1, and
any variable ANDed with 0 will always be 0.
● A + 1 = 1
● A . 0 = 0
10. Double Negation Law
The Double Negation Law states that the complement of the complement of a
variable is the variable itself.
● (A')' = A
Summary Table
The basic laws of Boolean Algebra are summarized in the table below:
Law OR Form AND Form
1. Identity Law P+0=P P⋅1=P
2. Idempotent Law P+P=P P⋅P=P
3. Commutative
P+Q=Q+P P⋅Q=Q⋅P
Law
P + (Q + R) = (P P ⋅ (Q ⋅ R) =
4. Associative Law
+ Q) + R (P ⋅ Q) ⋅ R
P ⋅ (Q + R) =
P + (Q ⋅ R) = (P
5. Distributive Law (P ⋅ Q) + (P ⋅
+ Q) ⋅ (P + R)
R)
6. Inversion Law (A′)′ = A (A′)′ = A
(P + Q)′ = P′ ⋅ (P ⋅ Q)′ = P′ +
7. De Morgan's Law
Q′ Q′
8. Complement Law P + P′ = 1 P ⋅ P′ = 0
9. Domination Law P+1=1 P⋅0=0
10. Double Negation
(P′)′ = P (P′)′ = P
Law
11. Absorption Law P + (P ⋅ Q) = P P ⋅ (P + Q) = P
De Morgan’s Theorems
There are two basic theorems of great importance in Boolean Algebra, which are
De Morgan’s First Law and De Morgan’s Second Law. These are also called De
Morgan’s Theorems.
De Morgan’s First Law -
De Morgan's Law states that the complement of the product (AND) of two
Boolean variables (or expressions) is equal to the sum (OR) of the complement of
each Boolean variable (or expression).
(P.Q)' = (P)' + (Q)'
The truth table for the same is given below:
P Q (P)' (Q)' (P.Q)' (P)' + (Q)'
T T F F F F
T F F T T T
F T T F T T
F F T T T T
We can see that truth values for (P.Q)' are equal to truth values for (P)' + (Q)',
corresponding to the same input. Thus, De Morgan's first law is true.
De Morgan’s Second Law
Statement: The Complement of the sum (OR) of two Boolean variables (or
expressions) is equal to the product(AND) of the complement of each Boolean
variable (or expression).
(P + Q)' = (P)'.(Q)'
The truth table for the same is given below:
(P + Q)' (P)'.(Q)'
P Q (P)' (Q)'
OR Op. AND Op.
T T F F F F
T F F T F F
F T T F F F
F F T T T T
We can see that truth values for (P + Q)' are equal to truth values for (P)'.(Q)',
corresponding to the same input. Thus, De Morgan's second law is true.
Circuit simplification for boolean
equation -
Ex- 1
Q = B (A+C)
Ex - 2
Q = AB + BC (B+C)
Q.3- Draw the logic circuit corresponding to the Boolean expression. Y=AB+B’C.
It is an expression showing the sum of two products.
Thus we require two AND gates and an OR gate. To generate b¯ we also require a NOT gate.
Their circuit can be drawn as follows.
Introduction to Number System
● Number System is a method of representing numbers with the help
of a set of symbols and rules; it is a mathematical notation used to
represent quantities or values in various forms.
● Humans understand decimals and computers understand binary, so we
have two different number systems.
.
Decimal Number System -
The Decimal Number System is the standard system for denoting numbers.
● It is also called the base-10 system.
● Digits used in it are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
● Each digit in the number is at a specific place value that is powers of 10.
● From right to left - units have the place value as 100, Tens has the place
value as 101, Hundreds as 102, Thousands as 103, and so on.
Example:
10285 can be written as
10285 = (1 × 104) + (0 × 103) + (2 × 102) + (8 × 101) + (5 × 100)
10285 = 1 × 10000 + 0 × 1000 + 2 × 100 + 8 × 10+ 5 × 1
10285 = 10000 + 0 + 200 + 80 + 5
10285 = 10285
Binary Number System
Binary Number System is the number system with base 2.
● The numbers are formed using two digits - 0 and 1.
● A binary number system is very useful in electronic devices and
computer systems because it can be easily performed using just two
states i.e. 0 and 1.
● Each digit in the number is at a specific place value that is powers of 2.
● From right to left - as powers of 2 i.e. 20, 21, 22, etc).
Binary Numbers can be converted to Decimal value by multiplying each digit
with the place value and then adding the result.
Example:
(1011)₂ can be written as
(1011)₂ = 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰
(1011)₂ = 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1
(1011)₂ = 11 (in decimal)
Octal Number System
Octal Number System is the number system with base 8.
● The numbers are formed using 8 digits i.e. 0, 1, 2, 3, 4, 5, 6, 7.
● Octal number system is useful for representing file permissions in
Unix/Linux operating systems.
● Each digit in the number is at a specific place value that is powers of 8.
● From right to left - as powers of 8 i.e. 80, 81, 82, etc.
Octal Numbers can be converted to Decimal value by multiplying each digit with
the place value and then adding the result.
Example:
(325)8 can be written as
(325)8 = 3 × 8² + 2 × 8¹ + 5 × 8⁰
(325)8 = 192 + 16 + 5
(325)8 = 213 (in decimal)
Hexadecimal Number System
Hexadecimal Number System is the number system with base 16.
● The numbers are formed using 16 digits i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,
B, C, D, E and F.
● Hexadecimal Numbers are useful for handling memory address
locations.
● The digits from 0 to 9 are used as in the decimal system, but the
numbers 10 to 15 are represented using the letters A to F as follows: 10
is represented as A, 11 as B, 12 as C, 13 as D, 14 as E, 15 as F.
ii. Place Value: the position of the digit. Each digit in the number is at a
specific place value that is powers of 16. (from right to left - as powers
of 16 i.e. 160, 161, 162, etc)
Hexadecimal Number System an be converted to Decimal value by multiplying
each digit with the place value and then adding the result.
Example:
(2F)16 can be written as
(2F)16 = 2 × 16¹ + F × 16⁰
(2F)16 = 2 × 16 + 15 × 1
(2F)16 = 32 + 15
(2F)16= 47 (in decimal)
Conversion from Decimal to Other Number Systems
To convert decimal to another base, divide by the target base, record remainders from
right to left until the quotient is 0, then specify the base for each section (binary:
base-2, octal: base-8, hexadecimal: base-16 with A–F for 10–15).
Decimal to Binary Conversion
Decimal to Octal Conversion
Decimal to Hexadecimal Conversion
Decimal to Binary - (97)10 - (1100001)2
Decimal to Octal - (97)10 - (141)8
Decimal to Hexadecimal - (97)10 - (61)16
Binary to Decimal - (110000)2 - ( )10
2p6 + 2p5 + 2p4 + 2p3 + 2p2 + 2p1 + 2p0
64+32+16+8+4+2+1
X x x x x x x
1+1+ 0+ 0+ 0+0+1
—----------------------------------
64+32+0+0+0+0+1 = (97)10
Octal to Decimal -
Hexa Decimal to Decimal -
Binary to Octal -
Ex - (1100001)2 —-> ( )8
Rule - 4 2 1
2p2+2p1+2p0
4+2+1
001+100+001
0*4+0*2+1*1 1*4+0*2+0*1 0*4+0*2+1*1
1 4 1
(141)8
Octal to Binary -
(141)8 —-> ( )2
421
141
001 100 001
(1100001)2
Hexadecimal to Binary -
(61)16 —--> (1100001)2
8421
6 1
0110 0001
(1100001)2
Binary to Hexadecimal -
(1100001)2 —--> (61)16
0110 0001
8 4 2 1 8421
6 1 = (61)16
Octal to Hexadecimal -
(141)8 —-> (61)16
4 2 1
1 4 1
001 100 001
(1100001)2
0110 0001
8421 8421
6 1
(61)16
Hexadecimal to Octal -
(61)16 —-> (141)8
6 1
8421 8421
0110 0001
(1100001)2
4 2 1 421 421
001 100 001
1 4 1
Binary Arithmetic, which is the basic method of performing calculations
(addition, subtraction, multiplication, division) in the binary number system
(using only 0 and 1).
1. Binary Addition
Similar to decimal addition, but only two digits (0 and 1).
Rules:
● 0 + 0 = 0
● 0 + 1 = 1
● 1 + 0 = 1
● 1 + 1 = 10 (which is 0, with carry 1)
Example:
1011 (11 in decimal)
+1101 (13 in decimal)
--------
11000 (24 in decimal)
2. Binary Subtraction
Rules are like decimal subtraction, but with borrowing.
Rules:
● 0 – 0 = 0
● 1 – 0 = 1
● 1 – 1 = 0
● 0 – 1 = 1 (borrow 1 from next higher bit)
Example:
1011 (11 in decimal)
- 0101 (5 in decimal)
--------
0110 (6 in decimal)
3. Binary Multiplication
Same as decimal multiplication but easier (since only 0 or 1).
Rules:
● 0 × 0 = 0
● 0 × 1 = 0
● 1 × 0 = 0
● 1 × 1 = 1
Example:
101 (5 in decimal)
× 11 (3 in decimal)
-----------
101 (5 × 1)
+ 1010 (5 × 1, shifted one place left)
-----------
1111 (15 in decimal)
101
+101x
1 1 1 1 (15)10
4. Binary Division
Same as decimal long division.
Rules:
● 0 / 0 = Undefined
● 0 / 1 = Undefined
● 1 / 0 = 0
● 1 / 1 = 1
Example:
1010 ÷ 10
= 101
_______
10) 1010 (101
- 10
—-------
010
- 10
—-----
0
(10 in decimal ÷ 2 in decimal = 5, which is 101 in binary)
Ex - 2
_______
101) 11010 (101
-101
—-------
00110
- 101
—---—-----
001
Ex -3
_______
1000) 11000 (11
Ex - 4
_______
100) 1111000 (11110
Operation Example (Binary) Result (Decimal
Equivalent)
Addition 1011 + 1101 = 11000 11 + 13 = 24
Subtraction 1011 – 0101 = 0110 11 – 5 = 6
Multiplication 101 × 11 = 1111 5 × 3 = 15
Division 1010 ÷ 10 = 101 10 ÷ 2 = 5
What is ASCII?
● ASCII stands for American Standard Code for Information
Interchange.
● It is a character encoding standard that assigns numeric values (0–127
in 7-bit, 0–255 in extended 8-bit) to characters like:
○ Letters (A–Z, a–z)
○ Digits (0–9)
○ Symbols (+, -, @, etc.)
○ Control characters (Enter, Tab, Backspace, etc.)
Common ASCII Values (7-bit standard)
Character ASCII Value Binary Hex
(Decimal) (7-bit)
A 65 1000001 41
B 66 1000010 42
Z 90 1011010 5A
a 97 1100001 61
b 98 1100010 62
z 122 1111010 7A
0 48 0110000 30
9 57 0111001 39
Space 32 0100000 20
Enter (LF) 10 0001010 0A
Key Ranges
● Control Characters: 0 – 31 (e.g., NULL=0, TAB=9, LF=10, ESC=27)
● Digits: 48 – 57 → '0'–'9'
● Uppercase Letters: 65 – 90 → 'A'–'Z'
● Lowercase Letters: 97 – 122 → 'a'–'z'
● Special Symbols: 32–47, 58–64, 91–96, 123–126
Example in Computer Architecture
● If you press the key A on the keyboard:
○ The system sends 65 (01000001 in binary) to the processor.
● The processor stores and processes it as binary, but you see ‘A’ on
screen.
● Keypoints —-->
● ASCII = American Standard Code for Information Interchange
● It is a character encoding standard developed in the 1960s.
● ASCII assigns a numeric value (code) to each character, digit,
punctuation mark, or control signal so that computers can process and
store text.
○ Example:
■ 'A' → 65 (in decimal) → 01000001 (in binary)
■ 'a' → 97
■ '0' → 48
Why is ASCII Important?
● It allows computers, networks, and devices to exchange text in a
standard way.
● Used in:
○ Programming languages (C, Python, Java store characters using
ASCII/Unicode)
○ File formats (text files, HTML, etc.)
○ Communication protocols (like email, HTTP headers)
Example
Suppose you type Hello:
● H → ASCII 72 → Binary 01001000
● e → ASCII 101 → Binary 01100101
● l → ASCII 108 → Binary 01101100
● o → ASCII 111 → Binary 01101111
So the word Hello is stored as:
01001000 01100101 01101100 01101100 01101111
What is Von Neumann Architecture?
● Proposed by John von Neumann in 1945.
● It is a computer architecture model where programs (instructions) and
data are stored in the same memory.
● Sometimes called the Princeton Architecture.
● Most modern computers (PCs, laptops, microcontrollers) are based on
this model.
Main Components of Von Neumann
Architecture
1. Input Unit
○ Devices like keyboard, mouse, scanner.
○ Feed data and instructions into the system.
2. Output Unit
○ Devices like monitor, printer.
○ Display results.
3. Memory (RAM)
○ Stores data and instructions together in binary form.
○ Divided into:
■ Primary memory (RAM, cache)
■ Secondary storage (HDD, SSD)
4. Control Unit (CU)
○ Fetches instructions from memory.
○ Decodes them.
○ Sends control signals to other units.
5. Arithmetic Logic Unit (ALU)
○ Performs arithmetic operations (+, −, ×, ÷).
○ Performs logic operations (AND, OR, NOT, comparisons).
6. Registers
○ Small, high-speed storage inside the CPU.
○ Examples: Instruction Register (IR), Program Counter (PC),
Accumulator.
7. System Bus
○ Communication lines connecting CPU, memory, and I/O.
○ Types:
■ Data Bus → transfers data.
■ Address Bus → transfers memory addresses.
■ Control Bus → transfers control signals.
Characteristics of Von Neumann Architecture
● Stored Program Concept → both instructions & data are kept in the
same memory.
● Sequential Execution → instructions executed one after another.
● Single Bus System → data & instructions share the same path.
● Binary Representation → all information in 0s and 1s.
Von Neumann Cycle (Instruction Cycle)
1. Fetch → CU gets instruction from memory (using Program Counter).
2. Decode → CU interprets the instruction.
3. Execute → ALU performs operation or CU signals I/O.
4. Store → Result is written back to memory/register.
This cycle repeats continuously.
Advantages
● Simple and easy design.
● Flexible: same memory for data and programs.
● Widely adopted in modern computers.
Disadvantages
● Von Neumann Bottleneck: Since data & instructions use the same bus,
speed is limited.
● Sequential execution → slower compared to parallel models (like
Harvard architecture).
BCD (Binary Coded Decimal)
BCD stands for Binary Coded Decimal.
It is a way of representing decimal numbers (0–9) in binary form.
● In BCD, each decimal digit is written as a 4-bit binary number.
● Example:
○ Decimal 0 → BCD = 0000
○ Decimal 5 → BCD = 0101
○ Decimal 9 → BCD = 1001
○ Decimal 12 → BCD = 0001 0010 (1 and 2 written separately)
Why use BCD?
● Computers work in binary, but humans understand decimal.
● BCD helps in applications like calculators, digital clocks,
digital counters, and financial systems where exact decimal
representation is needed.
Example
Decimal number 59 in BCD:
● 5 → 0101
● 9 → 1001
So, 59 in BCD = 0101 1001
BCD is a coding system where each decimal digit is stored in its
own 4-bit binary form.
Question: Add 67 + 85 using BCD
Step 1: Write numbers in BCD
● 67 = 0110 0111
● 85 = 1000 0101
0111
+0101
------
1100 (12 decimal → invalid BCD)
Since 1100 > 1001, add correction 0110:
1100
+0110
------
1 0010 → result = 2, carry = 1
Units digit = 2, carry = 1
Add the tens place (6 + 8 + carry 1)
0110
+1000
+0001
------
1111 (15 decimal → invalid BCD)
Since 1111 > 1001, add correction 0110:
1111
+0110
------
1 0101 → result = 5, carry = 1
Write the result
● Hundreds = 1 (carry)
● Tens = 5
● Units = 2
Final Answer = 152
What is Gray Code?
● Gray code (also called reflected binary code) is a binary
numbering system where two successive values differ by only
one bit.
● It is used in digital systems to prevent errors during transitions
(e.g., in rotary encoders, Karnaugh maps).
Conversion: Binary → Gray Code
The rules are simple:
1.The MSB (most significant bit) of the Gray code is the same
as the MSB of the binary number.
2.Each next Gray bit = Binary bit ⊕ (XOR) previous Binary
bit.
Example 1: Convert Binary 1011 → Gray
Binary: 1 0 1 1
● Step 1: Copy MSB → 1
● Step 2: XOR (1 ⊕ 0) = 1
● Step 3: XOR (0 ⊕ 1) = 1
● Step 4: XOR (1 ⊕ 1) = 0
👉 Gray Code = 1110
XOR Table -
0 0 0
0 1 1
1 0 1
1 1 0
(11001)B —-----> ( ) G
1->1->0->0->1
a4 a3 a2 a1 a0
a4 a4 xor a3 a3 xor a2 a2 xor a1 a1 xor a0
10101
Conversion: Gray Code → Binary
The rules are almost the reverse of Binary → Gray:
1.The MSB (most significant bit) of Binary is the same as the
MSB of the Gray code.
2.Each next Binary bit = Previous Binary bit ⊕ (XOR) Current
Gray bit.
Example 1: Convert Gray 1110 → Binary
Gray: 1 1 1 0
● Step 1: Copy MSB → Binary = 1
● Step 2: (1 ⊕ 1) = 0 → Binary = 10
● Step 3: (0 ⊕ 1) = 1 → Binary = 101
● Step 4: (1 ⊕ 0) = 1 → Binary = 1011
Binary = 1011
Q.2 - (10101)B —-- > ( )G
B4 b3 b2 b1 b0
B4 b4 xor g3b3 xor g2b2 xor g1b1 xor g0
A Karnaugh Map (K-Map) is a diagram used in digital logic
design to simplify Boolean algebra expressions.
● It’s a grid-like representation of truth tables.
● Each cell corresponds to a minterm (a unique combination of
input variables).
● It helps minimize the number of logic gates needed in a circuit.
● K Map is used to simplify the boolean expression in pictorial format
without using boolean laws.
● Developed by Karnaugh in 1953.
Types of K-Maps -
● 2-variable K-Map → 2² = 4 cells
● 3-variable K-Map → 2³ = 8 cells
● 4-variable K-Map → 2⁴ = 16 cells
● 5-variable or more → handled by computer tools (manual becomes
complex)
Keypoints -
2p2 = 4
B 0 1
A 0 1
0
1 3 2
2p3 = 8
B.C 00 01 11 10
A
0 1 3 2
4 5 7 6
0
1
2p4 = 16
CD 00 01 11 10
AB 0 1 3 2
00
01 4 5 7 6
11 12 13 15 14
10 8 9 11 10
Rules For K - Map -
1. No Zero allowed.
2. Groups can be vertical or horizontal but can’t be
diagonal.
3. Overlapping is allowed.
4. The group should be as large as possible.
Ex - 1
F(A.B) = (0,2,3)
B
A 1
1 1