Lecture 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

CS 221

Logic Design
DR . S OHA A HME D E HS SAN
AS S ISTANT P ROF ESSOR, COMP UT E R S CI E NCE DE PARTMENT.
FACULT Y OF COM P U T E RS A N D A RT I F ICIA L I N T EL LI GENCE . HE LWA N U N I V ERS ITY
The importance of logic design
➢Electronic system consists of hardware and software
➢To learn how to design the hardware, you need to study
Logic design
➢To learn how to study software, you need to study
Programming Languages
Course Objectives
Students, by the end of the course, should be able to:
Analyze,
Design,
and Implement,
Combinational and Synchronous digital circuits.
References
Text Book
 Mano, M. M. and Ciletti, M. D. (2007), Digital design, Upper Saddle River, NJ: Prentice-Hall, 5th ed.

References
 S. Brown , Z. Vranesic, “Fundamentals Of Digital Logic With VHDL Design”, ISBN 0-07-012591-0.
 G. Langholz, A. Kandel, & J. L Mott, “Foundations of digital logic design”, ISBN 981-02-3110-5.
 D. J. Comer, “Digital Logic and State Machine Design”, ISBN 978-0195107234.
 Thomas L. Floyd, “Digital Fundamentals”, ISBN 978-0131946095
Grading policy
◦Mid-term Exam 30 %
◦Semester Work 20 %
◦Final-Exam (Written) 50 %
Microsoft Teams Code
Course Contents
1.Basic Logic Concepts
2.Combinational Logic Design
3.Sequential Circuits
4.Registers and Counters
5.Memories
What is meant by digital?
Digital describes electronic technology that generates, stores,
and processes data in terms of two states: ON (1) , OFF (0)
Difference between Analogue and Digital
➢While analog systems represent data using a continuous signal,
digital systems represent data using discrete values ( 0s and 1s)
Digital Logic Basic Operations
The three basic logical operations are:
◦ AND
◦ Ex: z = x . y or z=xy “z is equal to x AND y”
◦ OR
◦ Ex: z = x + y “z is equal to x OR y”

◦ NOT
◦ Ex: z=x or z=x’ “z is equal to NOT x ”

10
Truth table
It is a table of all possible combinations of the variables
It shows the relation between
◦ The values that the variables may take and
◦ The result of the operation

11
Timing Diagram

12
Logic Gate Symbols

Gates with multiple inputs:

When F=1? and when G=1?

13
More Logic Gates

14
Example
Draw a logic gate circuit of A’ +B and get their truth table

A B A’ Z= A’ +B
0 0 1 1
0 1 1 1
1 0 0 0
1 1 0 1

15
Signed integer representation

Signed binary integers may be expressed in three ways:


1. Signed magnitude
2. One’s complement
3. Two’s complement
Reminder: Binary addition is as easy as it gets. You need to know only four
rules:
0+0= 0 0+1= 1
1+0= 1 1 + 1 = 10
Signed integer representation
Signed magnitude is the most intuitive method for
representing the unsigned numbers.

The MSB (Most Significant Bit) of a binary number is kept as


the “sign” of the number

MSB = 1: negative number

MSB = 0: positive number

The remaining bits represent the magnitude (or absolute


value) of the numeric value.
Signed integer representation
Example: In an 8-bit word signed magnitude system give the decimal
representation of the following numbers: 00000001, 10000001
Answer:
•00000001:
-The MSB is 0: The number is positive
-The remaining 7 bits are: 00000012 = 110
-The decimal number is +1
•10000001:
-The MSB is 1: The number is negative
-The remaining 7 bits are: 00000012 = 110
-The decimal number is -1
Signed integer representation
Example 1: Add 010011112 to 001000112 using signed-magnitude arithmetic.
Sign 1 1 1 1 ⇐ carries
0 1001111 (79)
0 + 0100011 (35)
_________________________

0 1110010 (114)
Example: Add 110011112 (-79) to 011000112 (99) using signed-magnitude arithmetic.

0112 ⇐ borrows
0 1100011 (99)
1 - 1001111 (-79)
_____________
0 0010100 (20)
One’s Complement
A positive number in one’s complement (C1), is directly converted to its binary
representation. The result of this positive number is the same as that of the
signed magnitude representation.

To convert a negative number to its one’s complement (C1), this number is


subtracted from all ones, or you can simply complement each digit, such that
the 1s become 0s and vice versa.

Example Express 2310 and -910 in 8-bit binary one’s complement form.
Answer:
2310 = + (000101112) = 00010111C1
-910 = - (000010012) = 11110110C1
One’s Complement
Example: What is the decimal equivalent of the C1 number 11110110 ?
Answer: Here, you can notice that the MSB is 1. Then, you must
complement all the bits of the C1 number first, and then find the
equivalent value in decimal. Finally, remember to add the negative
sign.
11110110C1
Complement: 000010012
Convert :9
Include (-) : -9
One’s Complement
Example 1: Add 2310 to -910 using 8-bit binary one’s complement
arithmetic .

Reminder: In C1, the last carry is added to the result.


One’s Complement

Summary:
Although the “end carry around” adds some
complexity, one’s complement is simpler to
implement than signed magnitude.
Nevertheless, it still has the disadvantage of having
two different representations for zero: positive zero
and negative zero (00000000 & 11111111).
Two’s complement solves this problem.
Two’s Complement
Example: Express 2310, -2310, and -910 in 8-bit binary two’s complement
form.

2310 = + (000101112) = 00010111c2 (no need to complement, as it is a positive


number)

-2310 = -(000101112) = 11101000c1 + 1 = 11101001c2


-910 = -(000010012) = 11110110c1 + 1 = 11110111c2
Signed integer representation
Example: What is the decimal equivalent of the C2 number 11110110?
Here, you can notice that the MSB is 1. Then, you have to complement all the bits of
the C2 number first, add one, and then find the equivalent value in decimal. Finally,
remember to add the negative sign.
11110110C2
Complement: 00001001
Add 1 : 00001010
Convert : 10
Include (-) : -10
Two’s Complement
Example 1: Add 910 to -2310 using two’s complement arithmetic.

11110010➔ -(00001101 + 1 )= -14

The result is 11110010C2 = -(000011102) = -1410


Two’s Complement
Example 2: Find the sum of 2310 and -910 in binary using two’s complement arithmetic.
2310 = +(00010111)2 = 00010111C2
-910 = -(00001001)2 = 11110111C2
2310 + (-910) = 00010111C2 + 11110111C2
1 1 1 1 0 1 1 1
0 0 0 1 0 1 1 1 2310
+ 1 1 1 1 0 1 1 1 + (-910)
0 0 0 0 1 1 1 0 +1410

Result: 00001110C2 = +(000011102) = 1410

You might also like