You are on page 1of 52

Logic Circuits Design

Chapter 1
Digital Systems and Information

Mutah University
Faculty of IT, Department of Software Engineering
Dr. Ra’Fat A. AL-msie’deen
Course Info

 Course title: Logic Circuits Design.


 Credit hours (theory, practical): 3 hours.
 Instructor: Dr. Ra’Fat A. AL-msie’Deen.
Required Textbook
 Logic and Computer Design
Fundamentals.
– Fifth Edition.
– M. Morris Mano, Charles R.
Kime, Tom Martin.
– 2014.
Generic Computer
Information Representation
 Digital systems store, move, and process information.
 Information represents a broad range of phenomena from:
– The physical world:
• Characterized by parameters such as weight, temperature,
and frequency.
• Most physical parameters are continuous: capable of taking
on all possible values over a defined range.
– Man-made world:
• Such as business records using words, quantities, and
currencies.
• Parameters are discrete in nature.
 In general, information systems must be able to represent both
continuous and discrete information.
Information Representation (Cont.)

 The signals in most present-day electronic digital systems use


just two discrete values and are therefore said to be binary.
 The two discrete values used are often called 0 and 1, the
digits for the binary number system.

(Figure) Examples
of Voltage Ranges
and Waveforms for
Binary Signals.
Information is represented using signals.

 Electrical signals such as voltages and


currents are the most common.
 There are two types of signals:
– Analog signals represent
information that is continuous in
time and value.

– Digital signals represent


information that is discrete in time
and value.
What is a digital system?

 It is a system that manipulates (processes) discrete elements


of information.
 A digital system is a discrete information processing system.
 Examples of digital systems:
– the calculator,
– digital voltmeters,
– and general purpose computers.
 In such systems, all quantities are represented using two
values.
 Note: if the system in Not Digital, it is "Analog".
What is A/D conversion?
 To process analog data using a digital system, we need analog to
digital (A/D) conversion.
 There are two main steps in order to discretize a signal:
– Sampling: taking finite samples in time (discretize in time).
Samples are taken by measuring the value of the signal at
regular time intervals.
– Quantization: taking finite values (discretize in value).
 Sampling + quantization + encoding ≡ ADC ≡ A/D ≡ Analog
to digital conversion
What is A/D conversion? (Cont.)
What is A/D conversion? (Cont.)
 How many values to consider when quantizing data?
– Multi-valued quantization.
– Binary-valued quantization
 Example: Comparison between multi-valued and binary-
valued quantization assuming that the voltage range is 0-3.

Voltage Multi-valued Binary-valued


0-0.5 0 000
0.5-1 1 001 (encoding)
1-1.5 2 010
1.5-2 3 011
2-2.5 4 100
2.5-3 5 101
Sample value Digital Multi-valued logic Digital binary
What is A/D conversion? (Cont.)

 Note that in order to transfer data in case of multi-valued


quantization, we need fewer wires.
 In this example, the multi-valued quantized data requires
one wire whereas binary-valued quantized data requires
three wires.
 However, binary quantization is preferred over multi-
valued quantization since it provides higher immunity to
noise.
 In general, binary systems are preferred since they are
simpler, easy to design, and extremely reliable.
 Note: Always keep in mind that digital does not mean binary.
The Digital Computer

 General-Purpose Computers are an example of binary


systems.
 A block diagram of a digital computer is shown in Figure
below.
The Digital Computer

 The memory stores programs as well as input, output, ….


 The datapath (ALU) performs arithmetic and other data-
processing operations as specified by the program.
 The control unit supervises the flow of information between
the various units.
 A datapath, when combined with the control unit, forms a
component referred to as a central processing unit, or CPU.
 Input device: keyboard.
 Output device: LCD (liquid crystal display).
– These devices use digital logic circuits
Digital logic

 Digital logic: is a science that deals with circuits that operate


on a set of two-valued elements; binary values.
Digital logic (Cont.)

 Physical quantities: continuous.


 Signal: mathematical function that describes physical
quantities.
 Digital signal: discrete in time and finite.
 Analog signal: infinite values.
 Again: why digital?
– Analog has errors.
– Digital systems have excellent noise immunity.
 Most real life signals are analog signals (continuous)
Number Systems

 We will deal with different systems.


 The systems of numbering we consider are positional positive
radix (base) system.
 In general the structure of any number in base r:

Most Significant Digit (MSD) Least Significant Digit (LSD)

 Where A is any value in [0, r-1].


– Base 5 → [0 - 4]
The Binary Numbering System

 The binary number system is a base 2 system with two digits:


0 and 1.
 A binary digit is called a bit.
 bit - binary digit.
 The decimal equivalent of a binary number can be found by
expanding the number into a power series with a base of 2.
– For example,
– (11010)2 = 1 * 24 + 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20
= (26)10
The Binary Numbering System (Cont.)
 The digits in a binary number are called bits.
 When a bit is equal to 0, it does not contribute to the sum during
the conversion.
 Therefore, the conversion to decimal can be obtained by adding the
numbers with powers of two corresponding to the bits that are
equal to 1.
– For example,
• (110101.11)2 = ( ? )10
– Solution:
• (110101.11) 2 = 25 + 24 + 22 + 20 + 2-1 + 2-2
» = 32 + 16 + 4 + 1 + 0.5 + 0.25
» = (53.75)10
Negative Exponents
 The exponent of a number says how many
times to use the number in a multiplication.
– In this example: 82 = 8 × 8 = 64
 In words: 82 can be called "8 to the second
power", "8 to the power 2" or simply "8
squared“.
 But those are positive exponents, what
about something like: 8-2.
– That exponent is negative ... what does it
mean?
• Example: 8-1 = 1 ÷ 81 = 1/8 = 0.125.
• Example: 2-2 = 1 ÷ 22 = 1/4 = 0.25.
• Example: 2-1 = 1 ÷ 21 = 1/2 = 0. 5.
The Binary Numbering System (Cont.)

 The following table shows the first 7 numbers obtained from 2


to the power n.

(Table) Powers of Two. n 2n


0 1
1 2
2 4
3 8
4 16
5 32
6 64
The Octal Numbering System

 r = 8 (23), allowed digits: {0, 1, 2, 3, ….., 7}.


– Example:
• (127.4)8 = ( ? )10
– Solution:
• (127.4)8 = 1*82 + 2*81 + 7*80 + 4*8-1
» = (87.5) 10

(Table) Powers of eight. n 8n


0 1
1 8
2 64
3 512
The Hexadecimal Numbering System
 r = 16 (24), allowed digits: {0, 1, 2, 3, ……, 9, A, B, C, D, E, F}.
– 10 → A
– 11 → B
(Table) Powers of 16. n 16n
– 12 → C
0 1
– 13 → D
1 16
– 14 → E
2 256
– 15 → F
3 4096
• Example: (B65F)16 = ( ? )10
• Solution:
– (B65F)16 = 11 * 163 + 6 * 162 + 5 * 161 + 15 * 160
– = 11 * 4096 + 6 * 256 + 5 * 16 + 15 * 1
» = (46687)10
Number Systems

 The following table shows


the representations of
numbers from (0)10 to
(16)10 in binary, octal, and
hexadecimal:

 Note: when the base


value increases (r↑), the
number of digits required
to represent the value
will decrease.
Conversion between Numbering Systems

1. Conversion from base (r) into decimal:

𝑛−1 −1
– Value = 𝑖=0 𝐴𝑖 𝑟𝑖 + 𝑗=−𝑚 𝐴𝑗 𝑟𝑗

– Example: (312.4)5 = (?)10


• Solution:
» = 3 * 52 + 1 * 51 + 2 * 50 + 4 * 5-1
» = 75 + 5 + 2 + 0.8 = (82.8)10
Conversion between Numbering Systems (Cont.)

2. Conversion from base 10 to any base (r):


– For the integer part:
• Use repeated integer divisions on successive quotients with base
r and save the remainders until the quotient is 0. Then, read the
remainders from the bottom to the top.
– Example: (153)10 = (?)8 “Conversion of Decimal integers to Octal”
– Solution:

153 1 Least significant digit 153 /8 = 19, remainder=1


19 3
19/8 = 2, remainder=3
2 2 Most significant digit
2/8 = 0, remainder=2
0

– Solution: (153)10 = (231)8


Conversion between Numbering Systems (Cont.)

2. Conversion from base 10 to any base (r):


– For the integer part:
– Conversion of Decimal integers to binary
– Example: (73)10 = (?)2
73 1 Least significant digit (LSD)
36 0
18 0
9 1
4 0
2 0
1 1 Most significant digit (MSD)
0
– Solution: (73)10 = (1001001)2
Conversion between Numbering Systems (Cont.)

2. Conversion from base 10 to any base (r):


– For the integer part:
– Conversion of Decimal integers to Hexadecimal
– Example: (245)10 = (?)16

245 5 Least significant digit (LSD)


15 15 Most significant digit (MSD)
0

– Solution: (245)10 = (F5)16


Conversion between Numbering Systems (Cont.)

2. Conversion from base 10 to any base (r):


– For the integer part:
– For the fractional part:
• Use repeated multiplications with base r on the fractional
part and save the integer parts. Stop when the fraction is 0.
Then, read the integer parts from top to bottom.
• Example: (0.375)10 = (?)2
• Solution:
0.375 *2 = 0.75 Integer part = 0 Most significant digit
0.75 *2 = 1.5 Integer part = 1
0.5 *2 = 1.0 Integer part = 1 Least significant digit

• Solution: (0.375)10 = (0.011)2


Conversion between Numbering Systems (Cont.)
2. Conversion from base 10 to any base (r):
– For the integer part:
– For the fractional part:
• Example: Convert (0.513)10 to a three-digit octal fraction.
• Note: The process of multiplying the fractions by r does not necessarily
end with zero. In this case, the number of digits of the fraction to be
used from the conversion must be specified.
0.513 *8 = 4.104 Integer part = 4 Most significant digit
0.104 *8 = 0.832 Integer part = 0
0.832 *8 = 6.656 Integer part = 6
0.656 *8 = 5.248 Integer part = 5 Least significant digit

• Solution: (0.513)10 = (0.4065)8


– The fourth digit (5) is used for rounding in base 8 of the second-to-
the-last digit (6).
• Solution: (0.513)10 = (0.407)8
Conversion between Numbering Systems (Cont.)
2. Conversion from base 10 to any base (r):
– For the integer part:
– For the fractional part:
• Example: (41.6875)10 = (?)2
Integer Part Fractional Part

41 1 Least significant digit 0.6875 *2 = 1.375 Integer part = 1 MSD


20 0 0.375 *2 = 0.75 Integer part = 0
10 0 0.75 *2 = 1.5 Integer part = 1
5 1 0.5 *2 = 1.0 Integer part = 1 LSD
2 0
1 1 Most significant digit
0

• Solution: (41.6875)10 = (101001.1011)2


Conversion between Numbering Systems (Cont.)

3. Conversion between octal and binary:


57 1 Least significant digit
– First approach:
28 0
• Octal ↔ Decimal ↔ Binary.
14 0
– Example: (71)8 = (?)2
7 1
– (71)8 = (?)10;
3 1
– (71)8 = 7 * 81 + 1 * 80 = 56 + 1 = (57)10
1 1 Most significant digit
– (57)10 =(111001)2.
0
– Second approach:
• A simpler and easier way to convert between octal and binary.
• In octal r = 8 = 23 . Hence each octal digit = 3 bits.
– Previous example “(71)8 = (?)2” resolved using the second approach:
– All you have to do is to convert each octal digit in its equivalent 3
bits.
Conversion between Numbering Systems (Cont.)

3. Conversion between octal and binary:


– Example: (11000011.0011)2 = (?)8
– All you have to do is to group each 3 bits in their
equivalent octal digit.

– Solution: (11000011.0011)2 = ( 303.14 )8

– Example : (7563.1102)8 = ( ? )2
– Solution: (111 101 110 011 . 001 001 000 010)2
Conversion between Numbering Systems (Cont.)

4. Conversion between hexadecimal and binary:


– In hexadecimal r = 16 = 24 .
– Hence each hexadecimal digit = 4 bits.
• Example: (F13.67)16 = ( ? )2
• Solution: (1111 0001 0011 . 0110 0111)2

• Example: (1101110001.110111)2 = ( ? )16


• Solution: (371.DC)16
Conversion between Numbering Systems (Cont.)
4. Conversion between hexadecimal and binary:
– Example: (D041.32)16 = ( ? )8
– Solution:
• (D041.32)16 = (1101 0000 0100 0001 . 0011 0010)2

• (D041.32)16 = ( 150101.144 )8

– Example: (365)r = (194)10; find r?


– Solution:
• 3r2 + 6r + 5 = 194
• 3r2 + 6r -189 = 0
• r2 + 2r – 63 = 0
• (r+9) (r-7) = 0
• So r = 7.
Arithmetic Operations
 The sum of two binary numbers is calculated following the
same rules as for decimal numbers,
– Except that the sum digit in any position can be only 1 or 0.
– Also, a carry in binary occurs if the sum in any bit position
is greater than 1.
• A carry in decimal occurs if the sum in any digit position
is greater than 9.
Inputs Outputs • Examples of the addition of two binary
A B Carry Sum numbers are as follows (note the
names of the operands for addition):
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
Arithmetic Operations (Cont.)

 Example: Hexadecimal addition


 Perform the addition (59F)16 + (E46)16
Arithmetic Operations (Cont.)

 The rules for subtraction are the same as in decimal, except


that a borrow into a given column adds 2 to the minuend bit.

Inputs Outputs
A B Borrow Difference
0 0 0 0
0 1 1 1
1 0 0 1
1 1 0 0

 A borrow in the decimal system adds 10 to the minuend digit.


Arithmetic Operations (Cont.)
 The following are examples of the subtraction of two binary
numbers; as with addition, note the names of the operands:

 In the first example shown, no borrows occur, so the difference bits


are simply the minuend bits minus the subtrahend bits.
 In the second example, in the right position, the subtrahend bit
is 1 with the minuend bit 0, so it is necessary to borrow from
the second position as shown. This gives a difference bit in the first
position of 1 (2 + 0 - 1 = 1).
 In the second position, the borrow is subtracted, so a borrow is
again necessary.
Arithmetic Operations (Cont.)

 Recall that, in the event that the subtrahend is larger than the
minuend, we subtract the minuend from the subtrahend and
give the result a minus sign.
 This is the case in the third example, in which this interchange
of the two operands is shown.
1 1 1 1 1
Arithmetic Operations (Cont.) X 1 0 1 0 1 0 0
Y 0 1 1 1 1 0 1
 Subtraction with Complements
1 0 0 1 0 0 0 1
– The complement operation dictates that if
Discard end carry 27
x= 1, then 𝑥 = 0.
Answer: X - Y =
– Example: Given the two binary numbers X
= 1010100 and Y = 1000011, perform 0 0 1 0 0 0 1
the subtraction x 1 0 1 0 1 0 0
 (a) X - Y 𝑥 0 1 0 1 0 1 1
 (b) Y - X by using 2’s complements. + 1
• 1’s complement of Y “1000011” is 2’s complement =
“0111100”.
0 1 0 1 1 0 0
• 2’s complement of Y “0111100” is
0111100 + 1 = 0111101.
Y 1 0 0 0 0 1 1
27 26 25 24 23 22 21 20 X 0 1 0 1 1 0 0
128 64 32 16 8 4 2 1 1 1 0 1 1 1 1
x 1 0 1 0 1 0 0 84 There is no end carry.
y 1 0 0 0 0 1 1 67 - 0 0 1 0 0 0 1
Arithmetic Operations (Cont.)

 The final operation to be illustrated is binary multiplication,


which is quite simple.
 The multiplier digits are always 1 or 0.
 Therefore, the partial products are equal either to the
multiplicand or to 0.
 Multiplication is illustrated by the following example:
Binary Codes
 An n-bit binary code is a group of n bits that assume up to 2n
distinct combinations of 0’s and 1’s, with each combination
representing one element of the set being coded.
 For example the following codes can be used to encode the colors:
red, yellow, blue, green.
– Red: 00
– Yellow: 01
– Blue: 10
– Green: 11
 If we have n bits, then the maximum number of items that can be
encoded is m ≤ 2n.
 In general, in order to encode M elements we need: n (bits)=
[log 2 𝑚] (items).
 For example, in order to encode 67 (4) elements we need 7 (2) bits.
 Binary codes can be classified into numeric codes and non-numeric
codes.
Binary Codes (Cont.)
 Binary is used to represent all types of data inside the digital system.
– Numeric or non-numeric.
 In general, in order to represent M items in binary, we need: n (bits)=
[log 2 𝑚] (items).
 In other words, the number of items that can be encoded using n bits is
M=2n.
 Examples on binary codes:
» Binary Coded Decimal (BCD).
» American Standard Code for Information Interchange (ASCII).
» Uni-Code.
» Gray Code.
» Parity Code.
Binary Coded Decimal (BCD)
 A numeric code.
 Encodes the ten decimal digits in 4 bits. In other words,
each group of four bits represents one decimal digit.
 A number with n decimal digits will require 4*n bits in BCD.
 Binary combinations 1010 → 1111 are not used and have no
meaning in BCD. Thus, BCD is very similar to hexadecimal, but
BCD stops at 9.
 Example: convert the number (23)10 to binary and BCD.
– (23)10 = (10111)2 → requires 5 bits
– (23)10 = (0010 0011)BCD → requires 8 bits
 Example: convert the number (185)10 to binary and BCD.
– (185)10 = (10111001)2 → requires 8 bits
– (185)10 = (0001 1000 0101)BCD → requires 12 bits
Binary Coded Decimal (BCD) … (Cont.)

 (Table)
Binary-
Coded
Decimal
(BCD):
American Standard Code for Information
Interchange (ASCII)
 Non-numeric code.
 Uses 7 bits for encoding → 27 = 128 characters (items)
classified into:
– Printable characters:
• which includes the 10 decimal digits, the 26 uppercase
letters, the 26 lowercase letters, and 32 special
characters such as (, # @ ; .)
– Non-printable control characters: such as NULL, space,
carriage return, delete.
– Note: (2)ASCII + (3)ASCII ≠ (5)ASCII
Unicode

 Non-numeric code.
 Uses 16 bits for encoding → 216 = 64 K characters (64*1024).
Gray Code
 Non-numeric code.
 There is only one bit change between
adjacent codes.
 For example, in order to encode the
colors (red, yellow, blue, green) using
gray codes, the codes will be assigned
to the colors as follows:
– Red: 00
– Yellow: 01
– Blue: 11
– Green: 10
 The following table shows the binary
code and gray code as we count from
000 to 111 and the number of bits
changing between adjacent codes for
each code.
Parity Code

 Non-numeric code.
 Extra bit(s) added to the original data to aid error detection.
 In case of a single parity bit, an additional bit is added make
the total number of 1s in the resulting code either even or
odd.
 The following table shows an example of forming even and
odd parity. In each case, the extra parity bit is added in the
most significant position of the code.
Parity Code (Cont.)

 The parity bit is helpful in detecting errors during transmission


of information from one location to another.
 For example, assume even parity is used, the following steps
are performed between two end points that uses parity to
perform error detection:
– Even parity is generated at the sending end.
– Data is transmitted.
– Parity is checked at the destination. If it is odd, then the
system detects that at least one bit has changed.
 Such a system detects one, three, ….. odd number of errors.
 In order to detect errors more efficiently, more parity bits are
needed.
Logic Circuits Design

Chapter 1
Digital Systems and Information

Mutah University
Faculty of IT, Department of Software Engineering
Dr. Ra’Fat A. AL-msie’deen

You might also like