You are on page 1of 39

COE 221

Digital Systems
Number Systems
Class Notes – 01*

* Reading Assignment: Chapter 1.1-1.8 of Textbook.

Dr. Ghassan Z. Qadah 1


Digital Systems
• What is a Digital System?
– A digital system is a collection of electronic circuits that store and process
data in digital form as opposed to analog form.

– The most primitive digital systems (circuits) are the AND, OR and NOT
gates which perform the logical AND, OR and NOT operations.

2
Dr. Ghassan Z. Qadah
Digital Systems

• Other type of digital systems are

– Computer is another example of a digital system.



– cell phone is a third example of a digital system.

– DVD player is another example of a digital system and many many


others

– Digital systems became so important these days to a point where our


current century is referred to it as the digital age

3
Dr. Ghassan Z. Qadah
Number Systems
• Definition: Number system
A collection of rules that are used to represent and
compute numbers in that system.

• Example: decimal system (293), binary system


(101), octal system (073) and hexadecimal system
(9A3). These systems are referred to as positional
systems.

• In general, a positional system represents the


number as a sequence of digits, where the value of
each digit is dependent on its magnitude and
position within the number.

Example: digit 2 in position 0 in the decimal number


232 has the value of 2 (2x100) whereas the same digit
at position 2 has the value of 200 (2x 102) as shown in
the figure.

Dr. Ghassan Z. Qadah 4


Representation of Numbers in
Positional Number Systems
• In general, a real number in a positional system is
represented as follows:

Where r is the base/radix of the number system


= 2 (for binary), 8 (for octal), 10 (for Decimal) and 16
(for hexadecimal)

and the digit

For the hex system ( with r = 16) and to avoid confusion, the hex digits 10, 11,
12, 13, 14, and 15 are represented with the letters A, B, C, D, E and F,
respectively.
Ex. The binary number (101.101)2  (positional real binary number)

Dr. Ghassan Z. Qadah 5


Value of Positional Numbers
• The decimal value of a positional number with a base r is:

Xr = an-1 * rn-1 + an-2 * rn-2 + …+ a0 * r0 . a-1 * r-1 + a-2 * r -2 …. a-m * r-m

Example: (101.101)2 ------- a binary example

• Interesting? : lend itself well to store and process numbers by computers.

Examples: compute the decimal value of the following numbers:

– (binary) (101.101)2

= 1* 22 + 0 * 21 + 1 * 20 + 1 * 2-1 + 0 * 2-2 + 1 * 2-3


= 4 + 1 + .5 + .125 = 5.625

6
Dr. Ghassan Z. Qadah
Value of Positional Numbers
• The decimal value of a positional number with a base r is:

Xr = an-1 * rn-1 + an-2 * rn-2 + …+ a0 * r0 . a-1 * r-1 + a-2 * r -2 …. a-m * r-m

• Other Examples: compute the decimal value of the following numbers:

– (Octal) (76.7)8 =
= 7 * 81 + 6 * 80 * 7 x 8-1
= 56 + 6 + .875
= 62.875
- (Hex) (B.C3)16 =

= 11 * 160 + 12 * 16-1 + 3 * 16-2


= 11.76171875

7
Dr. Ghassan Z. Qadah
Binary to Decimal Numbers Conversion: Example

8
Dr. Ghassan Z. Qadah
Decimal to Binary Conversion

– Two steps:
– Convert the integer part: Repeated Division-by-2 method
– Convert the fractional part: Repeated Multplication-by-2 method

(19.6875)10  (???)2

9
Dr. Ghassan Z. Qadah
Decimal to Binary Conversion

(19.6875)10  (???)2

10
Dr. Ghassan Z. Qadah
Decimal Numbers-to-binary Conversion:
Another Example
Convert the following decimal number to binary one:

11
Dr. Ghassan Z. Qadah
Decimal Numbers-to-binary Conversion: in class
Example
Convert the following decimal number to binary one:

12
Dr. Ghassan Z. Qadah
Binary Numbers: Simple Arithmetic operations(3)
• Binary Arithmetic:
– Addition

– Subtraction

Dr. Ghassan Z. Qadah 13


Binary Numbers (4)
– Multiplication

– Division: Use the


same procedure as
decimal division.

Dr. Ghassan Z. Qadah 14


Counting Binary Numbers
Question: Given n binary digits, how many unsigned binary numbers
can you make out of these digits?
• Solution:

– When n = 1, then the count is 2 binary numbers

– When n = 2, then the count is 4 binary numbers

Dr. Ghassan Z. Qadah 15


Counting Binary Numbers (1)
– When n = 4, then the count is 16 binary numbers

– When n , then the count of binary numbers is

Dr. Ghassan Z. Qadah 16


Signed and Unsigned Binary Numbers
• Digital systems handle two type of binary numbers:
Unsigned and signed.

• Unsigned number uses all of its bits to represent the


number value (ex. 1101).

• The signed number must handle the positive and negative


sign as follows:
• For binary numbers, three suitable methods exist to
represent signs:
– Sign-magnitude system
– 1’s complement
– 2’s complement

Dr. Ghassan Z. Qadah 17


Sign-Magnitude System
• Reserve 1 bit, the most significant bit (MSB), of the
number to represent the sign and the rest of the bits for
the magnitude. The MSB is set as follows:

– 0 if the number is positive


– 1 if the number is negative
Ex. express +7 and -7 as 4-bit sign-magnitude numbers

+7  0 111
-7  1 111

Ex. express +49 and -49 as an 8-bit sign-magnitude


numbers.
+49: 00110001
-49: 10110001
Drawback:
– Multiple representation for 0 (+0 and -0)
– Not preferred
Dr. Ghassan Z. Qadah 18
1’s Complement System
• Positive numbers stay the same.
• Negative numbers: flip each bit in the binary number including the
sign bit
– 0 1
– 1 0
Ex.: + 7  0111 (express as 4 bits)
- 7  1’s complement (0111)  1000

Ex.: express +7 and -7 as an 8-bit 1’s complement numbers


+ 7  00000111
- 7  11111000  (1’s complement (00000111))

Ex. Find the value of the 1’s complement number (11111000)

method:
– 1’s complement of number (11111000)  (0000111)  7, that is
the number is -7

Dr. Ghassan Z. Qadah 19


2’s Complement System
• Positive numbers stay the same.
• Negative numbers: two steps
– flip each bit in the binary number (find the 1’s complement).
– Add 1 to the number (ignore overflow)

Dr. Ghassan Z. Qadah 20


Why 2’s Complement System is Preferred?
• Preferred for two reasons:
– 2’th complement system generates one representation for the zero.
+ 0  0000
- 0  1111 (1’s complement for 0000)
1+
-----------
0000 (ignore the carry, same representation )

– 2’th complement system allows the user to perform subtraction by actually


performing addition  use same hardware for addition and subtraction

– Ex.

Dr. Ghassan Z. Qadah 21


Faster Way to Find 2’s Complement

Dr. Ghassan Z. Qadah 22


Addition in the 2’s Complement System

Dr. Ghassan Z. Qadah 23


Addition in the 2’s Complement System (1)

Dr. Ghassan Z. Qadah 24


Addition Overflow in 2’s Complement system (1)
• Overflow condition:
Overflow occurs when two numbers are added and the sum can’t fit in
the number of bits allocated for either of the two numbers.

• Overflow Occurs when both numbers are positive or both numbers are
negative.
• Overflow is detected when:
– Both numbers are positive and the sum is negative or
– Both numbers are negative and the sum is positive.

Dr. Ghassan Z. Qadah 25


Binary Number Representation: A Summery
• Represent the numbers +25 and -25 using 6 binary bits/digits in the
following number systems:
Sign-Magnitude, 1’s complement and 2’s complement

Decimal Sign- 1’s complement 2’s complement


Number magnitude
+25 011001
-25

• Convert the binary numbers ( 011001) and (111001) into decimal


assuming the number is stored in unsigned, sign-magnitude , 1’s
complement and 2’s complement formats.

Binary unsigned sign- 1’s 2’s


Number magnitude complement complement
011001
111001

Dr. Ghassan Z. Qadah 26


Binary Number Representation: A Summery
• Represent the numbers +25 and -25 using 6 binary bits/digits in the
following number systems:
Sign-Magnitude, 1’s complement and 2’s complement

Decimal Sign- 1’s complement 2’s complement


Number magnitude
+25 011001 011001 011001
-25 111001 100110 100111

• Covert the binary numbers ( 011001) and (111001) into decimal


assuming the number is stored in unsigned, sign-magnitude , 1’s
complement and 2’s complement formats.

Binary unsigned sign- 1’s 2’s


Number magnitude complement complement
011001 25 +25 +25 +25
111001 57 -25 -6 -7

Dr. Ghassan Z. Qadah 27


Octal System

• Decimal to Octal conversion

28
Dr. Ghassan Z. Qadah
Conversion between Binary and Octal
• Convert from Octal to binary: replace each octal digit with its
equivalent 3-bit binary number, as shown in the example below.

• Convert from binary to Octal: two steps,


– Start with LSB, partition the binary number into groups of 3 consecutive
bits.
– replace each group with the equivalent Octal digit, as shown in the example
below.

Dr. Ghassan Z. Qadah 29


Hexadecimal System

• Decimal to Hex conversion

Dr. Ghassan Z. Qadah 30


Conversion between Binary and Hex
• Convert from hex to binary: replace each hex digit with its equivalent 4-
bit binary number, as shown in the example below.

• Convert from binary to hex: two steps,


– Start with LSB, partition the binary number into groups of 4 consecutive
bits.
– replace each group with the equivalent hex digit, as shown in the example
below.

Dr. Ghassan Z. Qadah 31


Conversion between Hex and Octal
• Convert from Hex to Octal: two steps,
– Convert Hex to Binary using the method presented earlier.
– Convert Binary to Octal

• Convert from Octal to Hex: two steps,


– Convert Octal to Binary using the method presented earlier.
– Convert Binary to Hex.

Dr. Ghassan Z. Qadah 32


Conversion between Arbitrary Bases

Dr. Ghassan Z. Qadah 33


Binary Coded Decimal (BCD) Code

Dr. Ghassan Z. Qadah 34


BCD Arithmetic

Dr. Ghassan Z. Qadah 35


ASCII Code

Dr. Ghassan Z. Qadah 36


ASCII Codes

Dr. Ghassan Z. Qadah 37


Course Outcomes
Upon completion of the course, students will be able to:

1. Convert decimal numbers to/from binary, octal, hexadecimal and carry out
simple and signed arithmetic operations in these base systems.

2. Manipulate logic expressions using the theorems of Boolean Algebra and


synthesize simple logic circuits using basic logic gates like AND, OR, NAND and
NOR.

3. Minimize Boolean functions with 3, 4 variables using Karnaugh maps.

4.Use basic MSI components such as encoders, multiplexers and decoders in


designing reasonably sized digital circuits.

5. Understand functional and timing properties of different kinds of latches and flip
flops.
38
Dr. Ghassan Z. Qadah
Course Outcomes (continues)
6. Translate verbal description of a given sequential system to a circuit design
following procedures for designing synchronous sequential circuits.

7. Design a sequential circuit starting from a state diagram, using flip-flops and
basic MSI sequential components such as shift registers, counters, one shot and
register banks.

8. Build and test simple digital circuits using SSI/MSI/LSI components on logic
breadboards, and to use schematic captures to create and simulate simple circuits
using the Multisim software tool.

39
Dr. Ghassan Z. Qadah

You might also like