0% found this document useful (0 votes)
67 views65 pages

DLD Week 1 - Intro To Number Systems and BCD

This document contains a lecture on digital logic design. It begins with an introduction to the course and lecturer. It then discusses why digital logic design deals with discrete binary values and the design of digital circuits. The lecture outline covers a brief history of number systems in different civilizations like the Mayans, Babylonians and Arabs. It also discusses how to convert between different numbering systems like binary, octal, hexadecimal and decimal. The goal is to understand numbers from other civilizations and how our decimal system may appear to them.

Uploaded by

noreplypet202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views65 pages

DLD Week 1 - Intro To Number Systems and BCD

This document contains a lecture on digital logic design. It begins with an introduction to the course and lecturer. It then discusses why digital logic design deals with discrete binary values and the design of digital circuits. The lecture outline covers a brief history of number systems in different civilizations like the Mayans, Babylonians and Arabs. It also discusses how to convert between different numbering systems like binary, octal, hexadecimal and decimal. The goal is to understand numbers from other civilizations and how our decimal system may appear to them.

Uploaded by

noreplypet202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Introduction!

CSE 1125: Digital Logic Design – Week 1


Lec Raiyan Rahman
Dept of CSE, UIU
[email protected]

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 1


Hello and Good Morning!

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 2


Hello and Good Morning!
7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 3
A Little Introduction ☺

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 4


Lec Raiyan Rahman
Dept of CSE, UIU & Guest Faculty, BUP

• Lecturer (Feb 2019 – Jul 2023)


Department of Computer Science and Engineering
Military Institute of Science and Technology (MIST), Dhaka

• M.Sc. (ongoing) and B.Sc. in Computer Science and Engineering


Military Institute of Science and Technology (MIST)

Profile: https://cse.uiu.ac.bd/profiles/rahman-raiyan/

For any queries, send an email to: [email protected] or visit my


office (Room 719D) during counseling hours.

Weekly Schedule (counseling hour): Click Here

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 5


A Little Introduction, your turn ☺

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 6


Introduce yourself with:
1. Your name
2. CGPA (no, kidding)
3. What you are liking the most about CS.
4. And, what you dislike the most.

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 7


Welcome to DLD!

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 8


Before we start, here’s a (hopeful) promise:

If you follow my class closely, you will NOT need


anything else for this course*.

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 9


*But

1. Pay attention and actually 2. Don’t talk during the


take notes, not pics. lectures.

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 10


*But

3. Bring a bed if you want to sleep. Promise, I’ll let you.

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 11


*But

4. Be present in class. For absence due to valid reasons, send an


email within the class day to [email protected].

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 12


*But

5. One more thing, counselling hour is for counseling, not tuition!


So, always, try to take the most out of the class!

7/26/2023 LEC RAIYAN RAHMAN, DEPT OF CSE, UIU 13


Now, on with the classes!

7/26/2023 14
CSE 1125 : Digital Logic Design
Introduction
Week 1 Class 1

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 15


Why is it call digital logic design?

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 16


Why is it call digital logic design?

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 17


Why is it call digital logic design?
Digital logic design is called so because it primarily deals with the
design and manipulation of digital signals, which represent
information using discrete values, typically represented as binary
digits (0 and 1).

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 18


What is digital logic design?
• Digital logic design in computer science (CS) refers to the process
of designing and implementing digital circuits and systems using
principles of logic and Boolean algebra.

• These digital circuits are fundamental components of computer


hardware and various electronic devices, allowing them to perform
tasks such as computation, data processing, and control

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 19


What is digital logic design?

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 20


But first, we’ll have to start with where it all begins!

Numbers!

21
Lecture Outline
A Brief History of Numbers and Civilizations Binary Codes
How can we understand the numbers of other Binary Coded Decimal (BCD)
civilizations ?
Binary arithmetic
• Binary to decimal
• Single Bit Addition with Carry
• Octal to decimal
• Multiple Bit Addition
• Hexadecimal to decimal
• BCD Addition
What our numbers can mean to other civilizations
• Decimal to binary
• Decimal to octal
• Decimal to hexadecimal
Conversion of number systems with 2n digits
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 22
Lecture Outline
A Brief History of Numbers and Civilizations Binary Codes
How can we understand the numbers of other Binary Coded Decimal (BCD)
civilizations ?
Binary arithmetic
• Binary to decimal
• Single Bit Addition with Carry
• Octal to decimal
• Multiple Bit Addition
• Hexadecimal to decimal
• BCD Addition
What our numbers can mean to other civilizations
• Decimal to binary
• Decimal to octal
• Decimal to hexadecimal
Conversion of number systems with 2n digits
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 23
A Brief History of Numbers and Civilizations
The origin of our number system
• Why do you think our natural number system contains only 10 digits?
• 0 123456789
• It is related to our anatomy!

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 24


A Brief History of Numbers and Civilizations
(Cont.)
Counting Sheep
• Scenario: You are a person from the pre-historic era, without any
number system!

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 25


A Brief History of Numbers and Civilizations
(Cont.)
Counting Sheep
• What about now?

26
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU
A Brief History of Numbers and Civilizations
(Cont.)
• But this is a tedious and limited approach!
• Hence, different civilizations began to develop different number
systems.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 27


A Brief History of Numbers and Civilizations
(Cont.)
• But this is a tedious and limited approach!
• Hence, different civilizations began to develop different number
systems.

14
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 28
A Brief History of Numbers and Civilizations
(Cont.)
Different Civilizations Different Number Systems
• Arabs
• 10 digits – base 10 number system
• We just saw
• Mayans
• 20 digits – base 20 number system
• They did not wear sandals as they lived in a hot climate
• Babylonians
• 60 digits – base 60 number system
• The number 60 was important to them because they were engaged deeply in astronomical studies, also
because we have 12 joint in our 4 fingers (excluding the thumb) and 60 is a multiple of 12. More.
• The Babylonians also came up with the concept of
• a degree being divided into 60 minutes
• with each minute being divided into 60 seconds.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 29


A Brief History of Numbers and Civilizations
(Cont.)
Different Civilizations Different Number Systems

The The The


Mayans Arabs Babylonians
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 30
A Brief History of Numbers and Civilizations
(Cont.)
Different Civilizations Different Number Systems

The English Numbers

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 31


Lecture Outline
A Brief History of Numbers and Civilizations Binary Codes
How can we understand the numbers of other Binary Coded Decimal (BCD)
civilizations ?
Binary arithmetic
• Binary to decimal
• Single Bit Addition with Carry
• Octal to decimal
• Multiple Bit Addition
• Hexadecimal to decimal
• BCD Addition
What our numbers can mean to other civilizations
• Decimal to binary
• Decimal to octal
• Decimal to hexadecimal
Inter civilization number conversions
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 32
How can we understand the numbers of
other civilizations ?
Observe that we can represent our numbers (base-10) are like this:

•1234 = 1X103+2X102+3X101+4X100
•231.45 = ?

Note:
• A total of 10 digits are available in our system (0,1,2,3,4,5,6,7,8,9)
• For our number system 10 is called the base or the radix
• We can also write the above two numbers like this :
• (1234) 10
• (231.45)10

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 33


How can we understand the numbers of other
civilizations ?(Cont.)
• If a civilization uses 16 digits:
• 16-base system
• 16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
• Example : (1F0.1D)16
• If a civilization uses 8 digits:
• 8-base system
• 8 symbols (0,1,2,3,4,5,6,7)
• Example : (127.21)8
• If a civilization uses 2 digits:
• 2-base system
• 2 symbols (0,1)
• Example : (1011.01)2
• If a civilization uses n digits:
• n-base system
• n symbols (0,1,2,…,n-1)

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 34


How can we understand the numbers of
other civilizations ? (Cont.)
How do we understand the numbers of other civilizations?
• Let us try out with this one (base 2):
• (101.011)2

• Now try this one:


• (00111.10100)2

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 35


How can we understand the numbers of
other civilizations ? (Cont.)
How do we understand the numbers of other civilizations?

•Let us try out with this one (base 8):


• (01725.430)8 = (?)10
• Ans: (981.546875)10

•Let us try out with this one (base 16):


• (54.D2)16 = (?)10
• Ans: (84.8203125)10

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 36


Lecture Outline
A Brief History of Numbers and Civilizations Binary Codes
How can we understand the numbers of other Binary Coded Decimal (BCD)
civilizations ?
Binary arithmetic
• Binary to decimal
• Single Bit Addition with Carry
• Octal to decimal
• Multiple Bit Addition
• Hexadecimal to decimal
• BCD Addition
What our numbers can mean to other civilizations
• Decimal to binary
• Decimal to octal
• Decimal to hexadecimal
Conversion of number systems with 2n digits
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 37
What our numbers can mean to other
civilizations (Cont.)
• Converting our numbers (base 10) to base 2 numbers (Decimal to
binary)

• Converting our numbers (base 10) to base 8 numbers (Decimal to


octal)

• Converting our numbers (base 10) to base 16 numbers (Decimal to


hexadecimal)

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 38


Decimal to Binary Conversion - Steps
Let's take an example for n = (4.47)10 , k = 3

Step 1: Conversion of 4 to binary


1. 4/2 : Remainder = 0 : Quotient = 2
2. 2/2 : Remainder = 0 : Quotient = 1
3. 1/2 : Remainder = 1 : Quotient = 0

So equivalent binary of integral part of decimal is 100.

Step 2: Conversion of .47 to binary


1. 0.47 * 2 = 0.94, Integral part: 0
2. 0.94 * 2 = 1.88, Integral part: 1
3. 0.88 * 2 = 1.76, Integral part: 1

So equivalent binary of fractional part of decimal is .011

Step 3: Combined the result of step 1 and 2.

Final answer can be written as:


100 + .011 = 100.011

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 39


What our numbers can mean to other
civilizations (Cont.)
Converting our numbers (base 10) to base 2 numbers (Decimal to Binary)
• Try out with this one: (112)10
• Now let’s try with a fractional number (0.8125)10
• Finally let’s try to convert this number : (46.6875) 10
Caution!:
• Convert 0.6510 to N2
• 0.65 = 0.1010011001001 …
• Observe
• The fractional part begins repeating every 4 steps yielding repeating 1001 forever!
• In the earlier conversions, the fractional part became 0 as a result of the repeated
multiplications.
• In general, it may take many bits to get this to happen or it may never happen.
• Solution: Specify number of bits to right of radix point and round or truncate to
this number.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 40


Decimal to Binary Conversion - Steps
Convert the integral part of decimal to binary equivalent:
1. Divide the decimal number by 2 and store remainders.
2. Divide the quotient by 2.
3. Repeat step 2 until we get the quotient equal to zero.
4. Equivalent binary number would be reverse of all remainders of step 1.

Convert the fractional part of decimal to binary equivalent


1. Multiply the fractional decimal number by 2.
2. Integral part of resultant decimal number will be first digit of fraction binary
number.
3. Repeat step 1 using only fractional part of decimal number and then step 2.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 41


What our numbers can mean to other
civilizations (Cont.)
Converting our numbers (base 10) to base 8 numbers (Decimal to
octal)
(239.563)10=(?)8

Converting our numbers (base 10) to base 16 numbers (Decimal to


hexadecimal)
(725.25)10=(?)16

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 42


What our numbers can mean to other
civilizations (Cont.) - Generalized
• To Convert the Integer Part:
Repeatedly divide the number by the new radix and save the remainders. The
digits for the new radix are the remainders in reverse order of their
computation. If the new radix is > 10, then convert all remainders > 10 to digits
A, B, …
• To Convert the Fractional Part:
Repeatedly multiply the fraction by the new radix and save the integer digits
that result. The digits for the new radix are the integer digits in order of their
computation. If the new radix is > 10, then convert all integers > 10 to digits A,
B, …

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 43


Lecture Outline
A Brief History of Numbers and Civilizations Binary Codes
How can we understand the numbers of other Binary Coded Decimal (BCD)
civilizations ?
Binary arithmetic
• Binary to decimal
• Single Bit Addition with Carry
• Octal to decimal
• Multiple Bit Addition
• Hexadecimal to decimal
• BCD Addition
What our numbers can mean to other civilizations
• Decimal to binary
• Decimal to octal
• Decimal to hexadecimal
Conversion of number systems with 2n digits
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 44
Conversion of number systems with 2n digits

Binary Octal

Decimal

Hexa N-base
Decimal number
system

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 45


Conversion of number systems with 2n digits
• But for number systems that have 2n digits, we can devise an easier
way.
• This will ensure direct conversion.
• The examples we will see:
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 46


Conversion of number systems with 2n digits
• Before proceeding let us see a shortcut method for converting
decimals to binary.
• Example − Convert decimal number 205 into binary number.

Decimal 27 = 128 26 = 64 25 = 32 24 = 16 23 = 8 22 = 4 21 = 2 20=1


Binary 1 1 0 0 1 1 0 1

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 47


Conversion of number systems with 2n digits
• Before proceeding let us see a shortcut method for converting
decimals to binary.
• Example − Convert decimal number 205 into binary number.

Decimal 27 = 128 26 = 64 25 = 32 24 = 16 23 = 8 22 = 4 21 = 2 20=1


Binary 1 1 0 0 1 1 0 1

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 48


Conversion of number systems with 2n digits
Numbers in Different Bases

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 49


Conversion of number systems with 2n digits
Octal ↔ Binary
Octal to Binary:
• Restate the octal as three binary digits starting at the radix point and going
both ways.
Binary to Octal:
• Group the binary digits into three bit groups starting at the radix point and
going both ways, padding with zeros as needed in the fractional part.
• Convert each group of three bits to an octal digit.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 50


Conversion of number systems with 2n digits
Octal ↔ Binary

• Convert binary number (0110 011.1011)2 into octal number.

• Convert the number (63.54)8 into binary number.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 51


Conversion of number systems with 2n digits
Hexadecimal ↔ Binary

• Convert binary number (001100101.110111)2 into hexadecimal


number

• Convert the number (65.DC)16 into binary number.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 52


Conversion of number systems with 2n digits
Octal ↔ Hexadecimal

Octal ↔ Binary↔ Hexadecimal

• Convert octal number (635.177)8 into hexadecimal number

• Convert the number (19D.3F8)16 into binary number.

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 53


Lecture Outline
A Brief History of Numbers and Civilizations Binary Codes
How can we understand the numbers of other Binary Coded Decimal (BCD)
civilizations ?
Binary arithmetic
• Binary to decimal
• Single Bit Addition with Carry
• Octal to decimal
• Multiple Bit Addition
• Hexadecimal to decimal
• BCD Addition
What our numbers can mean to other civilizations
• Decimal to binary
• Decimal to octal
• Decimal to hexadecimal
Conversion of number systems with 2n digits
• Octal ↔ Binary
• Hexadecimal ↔ Binary
• Octal ↔ Hexadecimal
1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 54
Binary Numbers and Binary Coding
Information Types
• Non-numeric
• Greater flexibility since arithmetic operations not applied.
• Not tied to binary numbers

• Numeric
• Must represent range of data needed
• Very desirable to represent data such that simple, straightforward computation for
common arithmetic operations permitted
• Tight relation to binary numbers

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 55


Binary Numbers and Binary Coding
• Given n binary digits (called bits), a binary code is a mapping from a
set of represented elements to a subset of the 2n binary numbers.
• Example: A
binary code
for the seven
colors of the
rainbow
• Code 100 is
not used

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 56


Binary Numbers and Binary Coding
• Given M elements to be represented by a binary code, the minimum
number of bits, n, needed, satisfies the following relationships:

n = log2 M

Here M= 7
n = log2 M = log2 7 = 2.80

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 57


Binary Numbers and Binary Coding
• Suppose you are using n number of digits, in radix r, there are
maximum of rn distinct elements that can be represented.
• Examples:
• You can represent 4 elements in radix r = 2 with n = 2 digits: (00, 01, 10, 11).
• You can also represent 4 elements in radix r = 2 with n = 4 digits: (0001, 0010,
0100, 1000).

1/27/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 58


Binary arithmetic
Unsigned representation
• +6 = 110

• -6 = No representation

Range: 0 to 2n

Signed representation
• +6=0 110

• -6= 1 110

Range: -(2n-1-1) to +(2n-1-1)


10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 59
Representation using binary numbers
• Binary coding refers to the representation of information using
binary codes.
• Mapping definite binary numbers to definite information
Binary Code Information
Binary Code Information
00 Dhaka
0 False
01 Chittagong
1 True
10 Khulna

10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 60


Representation using binary numbers
• The seven colors of the rainbow

10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 61


Representation using binary numbers
Information Types
• Non-numeric
• Greater flexibility since arithmetic operations not applied.
• Not tied to binary numbers

• Numeric
• Must represent range of data needed
• Very desirable to represent data such that simple, straightforward
computation for common arithmetic operations permitted
• Tight relation to binary numbers

10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 62


Representation using binary numbers
• Do it yourself.

• You want to represent all the countries in the world, using binary
numbers. How many bits are required to do so?

• Total number of countries = 195


• Ans : 8 bits

10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 63


Representation using binary numbers
• Suppose you have a register that can contain 4 bits, how many
elements/ pieces of information can you represent?

• Ans : 2n

10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 64


Thank You

10/1/2023 Lec Raiyan Rahman, Dept. of CSE, UIU 65

You might also like