0% found this document useful (0 votes)
60 views

Lecture1, 2, 3-Digital Systems I - Topic 1, Number Systems

The document provides an introduction to digital system design and covers topics such as number systems including binary, decimal, hexadecimal and octal. It discusses coding systems such as signed numbers, binary coded decimal and seven segment display codes.

Uploaded by

attarshahriar
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)
60 views

Lecture1, 2, 3-Digital Systems I - Topic 1, Number Systems

The document provides an introduction to digital system design and covers topics such as number systems including binary, decimal, hexadecimal and octal. It discusses coding systems such as signed numbers, binary coded decimal and seven segment display codes.

Uploaded by

attarshahriar
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/ 24

Introduction to Digital System Design

Z. Navabi

Topic 1

Number Systems

Zain Navabi

Slides prepared by Katayoon Basharkhah


Outline

2-1 Why Binary?


2-2 Decimal and Binary
2-3 Hex and Octal
2-4 Coding System
2-5 Binary arithmetic

2
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Why Binary?
• Computers don’t understand words or numbers the way humans do.

• In the lowest level, computers work with 0 and 1.

• Binary number is base 2.

Introduction to Digital System Design - Copyright Zainalabedin Navabi 3


Decimal and Binary
Decimal Numbers

Decimal Point
Binary Point
3 2 1 -1 -2 -3 -4
−𝟒
4𝟒
𝟏𝟎
2 𝟏𝟎
2
𝟑 𝟏𝟎
2
𝟐 𝟏𝟎
2
𝟏 𝟏𝟎
2
𝟎
0
𝟏𝟎−𝟏
2 𝟏𝟎−𝟐
2 𝟏𝟎−𝟑
2 2𝟏𝟎

2 5 . 1 3
25.13= 2*101 +5*100 + 1*10-1+3*10-2

Integer Fraction

4
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Decimal and Binary
Binary Numbers

Binary Point
4 3 2 1 0 -1 -2 -3 -4

2 2 2 2 2 2 2 2 2

1 1 0 0 1 . 0 0 1 0
(11001.1010)2 = 1*24 + 1*23 +0*22 + 0*21 +1*20 + 0*2-1+0*2-2+ 1*2-3+0*2-4 = (25.125)10

Integer Fraction

Binary to decimal conversion

5
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Decimal and Binary
Decimal to Binary Conversion (Integer Part)
(29.61)10=(?)2

Multiple divisions and collecting the remainders, the first remainder is the nearest
digit to the binary point.

14 07 03 1
2 29 2 14 2 07 2 03
28 14 06 02
1 0 1 1

(29)D = (11101.)B
Binary point

6
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Decimal and Binary
Decimal to Binary Conversion (Fractional Part)
Use multiplication to find the fractional part.

0.61*2 = 1 . 22
0.22*2 = 0 . 44
0.44*2 = 0 . 88 (0.61)10=(.100111)2 (29.61)10=(11101.100111)2
0.88*2 = 1 . 96

0.96*2 = 1 . 92

0.92*2 = 1 . 84

7
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Octal and Hex 0000 0
0001 1
To do conversions from base 2 to base 8(16), each 3(4) bits in 0010 2
base 2 must be converted into it’s equivalent in base 8(16).
0011 3
0100 4
(35.37)10 = (00 100 011.010 111 00)2 0101 5
0110 6
(35.37)10 = (43.27)octal 0111 7
(35.37)10 = (0010 0011.0101 1100)2 1000 8
1001 9
(35.37)10 = (23.5C)Hex 1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
8
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System
1- Signed Numbers
• We define the left-most digit as the number’s sign digit.
• The definition constructs the Sign and Magnitude representation of numbers.
• In this representation all digits except the left-most construct the magnitude of
the number, while the left-most digit being 1 shows that the number is negative
or positive otherwise.

Sign Magnitude

0 1001001 +73

1 1001001 -73

9
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System
2- Binary Coded Decimal
• A system of writing numerals.
• Assigns a four-digit binary code to each digit 0 through 9 in a decimal (base-10) numeral.

0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
10
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System
3- Seven Segment Display Code
• A system for simple display of digits 0 to 9.
• Assigns a seven-digit binary code to each digit 0 through 9 (base-10) numeral.
a b c d e f g
0 0000 1 1 1 1 1 1 0
1 0001 0 1 1 0 0 0 0
2 0010 1 1 0 1 1 0 1
3 0011 1 1 1 1 0 0 1
4 0100 0 1 1 0 0 1 1
5 0101 1 0 1 1 0 1 1
6 0110 1 0 1 1 1 1 1
7 0111 1 1 1 0 0 0 0
8 1000 1 1 1 1 1 1 1
9 1001 1 1 1 1 0 1 1
11
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System
3- Seven Segment Display Code

12
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System Decimal Binary
0 0000
Gray
0000
4- Gray Code 1 0001 0001
• Physical switches are not ideal: it is very unlikely that physical switches 2 0010 0011
will change states exactly in synchrony. 3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
0111 1111 1101 1001 0100
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
• Solution: Two successive values differ in only one bit.
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
13
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System
5- ASCII
• In some application storing text is the
most important of all. The ASCII
code is used for this mean.

• Digits 0 through 9, lowercase and


uppercase letters all have specific codes
in this system.

• Today, an extended ASCII table is also


used alongside the basic one which
contains the codes of foreigner letters.

14
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Coding System
5- ASCII
• 8-bit codes are used to represent the ASCII codes, where the leftmost digit
specifies which table a specific code belongs to. Codes starting with 1 are
from the extended ASCII table and those starting with 0 belongs to the
basic one.

• Special characters are also included in the ASCII code range. It’s also true
about the control characters.

15
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Binary arithmetic
1- Addition
• Adding numbers in base 2 can be considered the same as decimal
Addition.

• The main problems can occur when doing subtractions. But even
in this case the borrowing is just as it is in decimal numbers.
+2 +2 +2 +2

+1 +1 +1 1 01101
101101 +1 +1 +1 +1
+ 011001 - 0 01110
1000110 0 11111
Addition Subtraction

Introduction to Digital System Design - Copyright Zainalabedin Navabi 16


Binary arithmetic
2- Subtraction
• With another look at the arithmetic in our decimal number
system:
The Largest number with the same number
of digits plus 1 as our operand is added
and subtracted
52 - 37 = 52 - 37 + 100 - 100 = 52 - (37 + 99) + 1 - 100 =
52 + (62 + 1) - 100 = 52 + 63 - 100 = 115 - 100 = 15
Negative of 37
• We have actually found a new way to negate 37 and that is the
result of subtracting it from 99 and adding 1 to it.

Introduction to Digital System Design - Copyright Zainalabedin Navabi 17


Binary arithmetic
2- Subtraction
• With another look at the arithmetic in our decimal number
system:
00110100 - 00100101 = 00110100 - 00100101 + 100000000 - 100000000 =
00110100 - 00100101 + 11111111 + 1 - 100000000 =
00110100 + 11011011 - 100000000 = 100001111 - 100000000 = 00001111

The negative of 00100101

• This representation for negative numbers is used in the 2’s


Complement System.

Introduction to Digital System Design - Copyright Zainalabedin Navabi 18


Binary arithmetic
3- Two’s complement
• 2’s complementing a number is consisted of complementing it and then
adding 1.

• The same rule as the sign and magnitude representation for distinguishing
positive numbers from negative ones applies in the 2’s complement
system.

• In the 2’s complement system, the positive numbers have the same form
as they have in the sign and magnitude system.

• 2’s complementing a negative number is performed as starting from the


right-most digit until the first ‘1’ is reached and then complementing the
rest of the digits.
Introduction to Digital System Design - Copyright Zainalabedin Navabi 19
Binary arithmetic
4- Two’s complement arithmetic
+1+1+1 +1 +1
00011011
+ 01001101
01101000
Addition

+1 +1 +1 +1
0 0 0 1 1 0 1 1 negating 0 0 0 1 1 0 1 1
- 01001101 + 10110011
11001110 -(00110010)
Binary
Subtraction
Introduction to Digital System Design - Copyright Zainalabedin Navabi 20
Binary arithmetic
5- Overflow
0 0 1 1 0 1 0 0
+
0 1 1 0 1 0 0 0

1 0 0 1 1 1 0 0

• A negative result has occurred from the addition of 2 positive numbers.

• The result could have been shown correctly in 9 bits, but our system has at most 8.

Introduction to Digital System Design - Copyright Zainalabedin Navabi 21


Binary arithmetic
5- Overflow

Introduction to Digital System Design - Copyright Zainalabedin Navabi 22


Binary arithmetic
5- Overflow
• A way for pointing out an overflow occurrence is when the sign bit of the result
differs from that of the operands (if the operand’s sign bits are the same).

• Solution: Sign-Extension Process

0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0
+
0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0

0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0

Sign-Extension

Introduction to Digital System Design - Copyright Zainalabedin Navabi 23


Conclusion
We have covered:

• Binary number representation.


• Binary to decimal conversion and vs.
• Coding systems like BCD, Gray code and ASCII.
• Binary arithmetic.
• Two’s complement system.

Introduction to Digital System Design - Copyright Zainalabedin Navabi 24

You might also like