• No results found

Computing and Programming Fundamentals

N/A
N/A
Protected

Academic year: 2021

Share "Computing and Programming Fundamentals"

Copied!
54
0
0

Loading.... (view fulltext now)

Full text

(1)

1

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

Chapter No 4 – Number Systems and Logic Gates

Compiled By:

Muzammil Ahmad Khan Muhammad Kashif Shaikh

Sir Syed University of Engineering & Technology Computer Engineering Department

University Road, Karachi-75300, PAKISTAN

Batch 2013

C E – 101 : C & P F

Computing and Programming Fundamentals

2

2 0 1 3

CE - 101 : Computing and Programming Fundamentals

ƒ Course Objectives:

ƒ Upon successful completion of this course, the student will be able to:

ƒFundamentals of Computer Engineering and Information Technology

ƒOverview of History, Classification and Components of Computers

ƒNumber Systems and Logic Gates

ƒOverview of Software, Operating Systems, Networks and Internet

ƒIntroduction about Programming

ƒBasic Building Blocks, Loop, Decision Making

(2)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 3

2 0 1 3

CPF Books

ƒ Text Book:

1. Introduction to Computers ( 7th Edition )

By Peter Norton

2. Turbo C Programming For The PC ( Revised Edition )

By Robert Lafore

ƒ Reference Books:

1. Computer, Communications and Information.

By Sarah Hutchinson and Stacey Sawyer 2. Let Us C

By Yashavant Kanetkar

2 0 1 3

Marks Distribution

ƒ Mid Term _______________ 20

ƒ Lab Work + Project _______________ 20

ƒ Quiz _______________ 5

ƒ Assignment + Class Performance _______________ 5

ƒ Semester Final Paper _______________ 50

ƒ Total Marks _______________ 100

(3)

3

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 5

2 0 1 3

CPF Course Website

ƒ http://www.ssuet.edu.pk/courses/ce101/cpf

ƒ https://sites.google.com/site/cedssuet/

6

2 0 1 3

Course Instructors

ƒ Muzammil Ahmad Khan [email protected] Assistant Professor, CED

Room No: BS-04 Section A

ƒ Muhammad Kashif Shaikh [email protected] Assistant Professor, CED

Room No: BS-04 Section B

ƒ Umme Laila [email protected]

Assistant Professor, CED Room No: BS-04

Section C

(4)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 7

2 0 1 3

Course Instructors

ƒ Zeeshan Karim [email protected]

Assistant Professor, CED Room No: ISP

Section D

ƒ Sarfaraz Natha [email protected] Lecturer, CED

Room No: BF-02 Section E

ƒ Samreena Bano [email protected]

Lecturer, CED Room No: AG-06 Section F

2 0 1 3

Course Outline 9 PART A

ƒ History of Computer

ƒ Classification of Computer

ƒ Basic Components

ƒ CPU, I/O, Peripheral Devices, Storage

ƒ Von Neumann Architecture

ƒ Number Systems

ƒ Binary Numbers

ƒ Boolean Logic

9 PART B

ƒ Types of Programming Languages

ƒ Algorithm

ƒ Flow Chart

ƒ Introduction to C Language Programming

ƒ Basic Building Blocks

ƒ Loops

ƒ Decision Making Statements

(5)

5

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

Number Systems and Logic Gates

Chapter

4

Compiled By: Muzammil Ahmad Khan & Muhammad Kashif Shaikh

Batch 2013

CE – 101: Computing and Programming Fundamentals

10

2 0 1 3

Chapter 4 - Contents

ƒ Know the different types of numbers

ƒ Describe positional notation

ƒ Convert numbers in other bases to base 10

ƒ Convert base 10 numbers into numbers of other bases

ƒ Describe the relationship between bases 2, 8, and 16

ƒ Explain computing and bases that are powers of 2

ƒ Logic Gates and Boolean Algebra

(6)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 11

2 0 1 3

Number System

ƒ A number system defines how a number can be represented using distinct symbols. A number can be represented differently in different systems.

ƒ For example, the two numbers (2A)

16

and (52)

8

both refer to the same quantity, (42)

10

, but their representations are different.

2 0 1 3

Number System

ƒ The system used to count discrete units is called number system.

ƒ There are four systems of arithmetic which are often used in digital electronics.

ƒ Decimal Number System

ƒ Binary Number System

(7)

7

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 13

2 0 1 3

Common Number Systems

No No

0, 1, … 9, A, B, … F 16

Hexa- Decimal

No No

0, 1, … 7 8

Octal

Yes No

0, 1 2

Binary

No Yes

0, 1, … 9 10

Decimal

Used in computers?

Used by humans Symbols ?

Base System

14

2 0 1 3

Conversion Among Bases

ƒ The possibilities:

Decimal Octal

Binary

Hexadecimal

(8)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 15

2 0 1 3

Quick Example

25 10 = 11001 2 = 31 8 = 19 16

Base

2 0 1 3

Decimal Numbering systems

ƒ Base: 10

ƒ Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

ƒ Representation 5234

Thousands Hundreds Tens Units 5 2 3 4

ƒ Example: 5234

10

10

3

= 1000 10

2

= 100 10

1

= 10 10

0

= 1

(9)

9

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 17

2 0 1 3

Positional Notation

Continuing with our example…

642 in base 10 positional notation is:

6 x 10² = 6 x 100 = 600 + 4 x 10¹ = 4 x 10 = 40

+ 2 x 10º = 2 x 1 = 2 = 642 in base 10

This number is in base 10

The power indicates the position of

the number

18

2 0 1 3

Positional Notation

d

n

* R

n-1

+ d

n-1

* R

n-2

+ ... + d

2

* R + d

1 As a formula:

642 is: 6

3

* 10

2

+ 4

2

* 10

+

2

1

R is the base of the number n is the number of

digits in the number

d is the digit in the ithposition in the number

(10)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 19

2 0 1 3

Positional Notation

What if 642 has the base of 13?

642 in base 13 is equivalent to 1068 in base 10 + 6 x 13² = 6 x 169 = 1014

+ 4 x 13¹ = 4 x 13 = 52 + 2 x 13º = 2 x 1 = 2

= 1068 in base 10

2 0 1 3

Binary Numbering System

ƒ Base: 2

ƒ Digits: 0, 1

ƒ binary number: 110101

2

positional powers of 2: 2

5

2

4

2

3

2

2

2

1

2

0

decimal positional value: 32 16 8 4 2 1

binary number: 1 1 0 1 0 1

(11)

11

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 21

2 0 1 3

Binary to Decimal

ƒ Technique

ƒ Multiply each bit by 2

n

, where n is the “weight” of the bit

ƒ The weight is the position of the bit, starting from 0 on the right

ƒ Add the results

22

2 0 1 3

Converting Binary to Decimal

ƒ What is the decimal equivalent of the binary number 1101110 ?

1 x 26 = 1 x 64 = 64 + 1 x 25 = 1 x 32 = 32 + 0 x 24 = 0 x 16 = 0 + 1 x 23 = 1 x 8 = 8 + 1 x 22 = 1 x 4 = 4 + 1 x 21 = 1 x 2 = 2 + 0 x 2º = 0 x 1 = 0

= 110 in base 10 (1101110)2 = (110)10

(12)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 23

2 0 1 3

Converting Binary to Decimal

101011

2

=> 1 x 2

0

= 1 1 x 2

1

= 2 0 x 2

2

= 0 1 x 2

3

= 8 0 x 2

4

= 0 1 x 2

5

= 32 (101011)

2 =

(43)

10 Bit “0”

2 0 1 3

Binary to Decimal Conversion

ƒ To convert to base 10, add all the values where a one digit occurs.

Ex: 110101

2

positional powers of 2: 2

5

2

4

2

3

2

2

2

1

2

0

decimal positional value: 32 16 8 4 2 1

binary number: 1 1 0 1 0 1

(13)

13

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 25

2 0 1 3

Decimal to Binary Conversion

ƒ

The Division Method. Divide by 2 until you reach

zero, and then collect the remainders in reverse.

Example 1: (56)

10

= (111000)

2

2 ) 56 Rem:

2 ) 28 0 2 ) 14 0 2 ) 7 0 2 ) 3 1 2 ) 1 1

26

2 0 1 3

Decimal to Binary Conversion

ƒ Technique

ƒ Divide by two, keep track of the remainder

ƒ First remainder is bit 0 (LSB, least-significant bit)

ƒ Second remainder is bit 1

ƒ Etc.

(14)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 27

2 0 1 3

125

10

= ?

2 2 125 62 1 2

31 0 2

15 1 2

7 1 2

3 1 2

1 1 2

0 1

125

10

= 1111101

2

2 0 1 3

Decimal to Binary Conversion

ƒ

The Subtraction Method:

Subtract out largest power of 2 possible (without going below zero) each time until you reach 0.

Place a one in each position where you were able to

subtract the value, and a 0 in each position that you

could not subtract out the value without going below

zero.

(15)

15

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 29

2 0 1 3

Decimal to Binary Conversion

ƒ

The Subtraction Method:

Example: 56

10

56 2

6

2

5

2

4

2

3

2

2

2

1

2

0

- 32 64 32 16 8 4 2 1

24 1 1 1 0 0 0 - 16

8 - 8

0 Answer: 56

10

= 111000

2

30

2 0 1 3

Octal Numbering System

ƒ Base: 8

ƒ Digits: 0, 1, 2, 3, 4, 5, 6, 7

ƒ Octal number: 1246

8

powers of : 8

4

8

3

8

2

8

1

8

0

decimal value: 4096 512 64 8 1

(16)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 31

2 0 1 3

Octal to Decimal Conversion

ƒ To convert to base 10, beginning with the rightmost digit multiply each nth digit by 8

(n-1)

, and add all of the results together.

Example: 1246

8

positional powers of 8: 8

3

8

2

8

1

8

0

decimal positional value: 512 64 8 1 Octal number: 1 2 4 6

1246

8

= 512 + 128 + 32 + 6 = 678

10

2 0 1 3

Decimal to Octal Conversion

ƒ The Division Method. Divide by 8 until you reach zero, and then collect the remainders in reverse.

Example: 4330

10

= 10352

8

8 ) 4330 Rem:

8 ) 541 2

8 ) 67 5

8 ) 8 3

(17)

17

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 33

2 0 1 3

Hexadecimal Numbering System

ƒ Base: 16

ƒ Digits: 0, 1, 2, 3, 4, 5, 6, 7,8,9,A,B,C,D,E,F

ƒ Hexadecimal number: 1F4

16

powers of : 16

4

16

3

16

2

16

1

16

0

decimal value: 65536 4096 256 16 1

34

2 0 1 3

Hexadecimal Numbering System

4- Bit Group Decimal Digit HexaDecimal Digit

0000 0 0

0001 1 1

0010 2 2

0011 3 3

0100 4 4

0101 5 5

0110 6 6

0111 7 7

1000 8 8

1001 9 9

1010 10 A

1011 11 B

1100 12 C

1101 13 D

1110 14 E

1111 15 F

(18)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 35

2 0 1 3

Hexa-Decimal to Decimal Conversion

ƒ To convert to base 10, beginning with the rightmost digit multiply each nth digit by 16

(n-1)

, and add all of the results together.

Example: 1F4

16

positional powers of 16: 16

3

16

2

16

1

16

0

decimal positional value: 4096 256 16 1 Hexadecimal number: 1 F 4

1F4

16

= 256 + 240 + 4 = 500

10

2 0 1 3

Hexa-Decimal to Decimal Conversion

ƒ What is the decimal equivalent of the hexadecimal number DEF?

D x 16² = 13 x 256 = 3328 + E x 16¹ = 14 x 16 = 224 + F x 16º = 15 x 1 = 15

= 3567 in base 10

(DEF) = (3567)

(19)

19

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 37

2 0 1 3

Decimal to Hexa Conversion

ƒ The Division Method. Divide by 16 until you reach zero, and then collect the remainders in reverse.

Example 1: 126

10

= 7E

16

16) 126 Rem:

16) 7 14 = E 0 7

38

2 0 1 3

Decimal to Hexa Conversion

Example: 810

10

16

3

| 16

2

16

1

16

0

4096 | 256 16 1

| 3 2 A

Answer: 810

10

= 32A

16

(20)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 39

2 0 1 3

Binary to Octal Conversion

ƒ Since the maximum value represented in 3 bit is equal to:

2

3

– 1 = 7

i.e. using 3 bits we can represent values from 0 –7 which are the digits of the Octal numbering system.

Thus, three binary digits can be converted to one octal digit.

2 0 1 3

Binary to Octal Conversion

Three-bit Group Decimal Digit Octal Digit

000 0 0

001 1 1

010 2 2

011 3 3

100 4 4

101 5 5

(21)

21

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 41

2 0 1 3

Octal to Binary Conversion

ƒ Example :Convert 742

8

=

2

7 = 111 4 = 100 2 = 010

7 4 2

8

= 1 1 1 1 0 0 0 1 0

2

42

2 0 1 3

Binary to Octal Conversion

Example : Convert 10100110

2

=

8

110 = 6 100 = 4

010 = 2 ( pad empty digits with 0)

1 0 1 0 0 1 1 0

2

= 2 4 6

8

(22)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 43

2 0 1 3

Binary to Hexa Conversion

ƒ Since the maximum value represented in 4 bit is equal to:

2

4

– 1 = 15

i.e. using 4 bits we can represent values from 0 –15 which are the digits of the Hexadecimal numbering system.

Thus, Four binary digits can be converted to one Hexadecimal digit.

2 0 1 3

Hexa to Binary Conversion

ƒ Example :Convert 3D9

8

=

2

3 = 0011

D = 1101

9 = 1001

(23)

23

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 45

2 0 1 3

Binary to Hexa Conversion

Example: Convert 10100110

2

=

8

0110 = 6 1010 = A

1010 0110

2

= A 6

16

46

2 0 1 3

Octal to Hexa Conversion

ƒ To convert between Octal to Hexadecimal numbering

systems and visa versa convert from one system to

binary first then convert from binary to the new

numbering system

(24)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 47

2 0 1 3

Hexa to Octal Conversion

Example : Convert E8A

16

=

8

1110 1000 1010

2

111 010 001 010 (group by 3 bits)

E 8 A

16

= 7 2 1 2

8

2 0 1 3

Octal to Hexa Conversion

Example : Convert 752

8

=

16

111 101 010

2

(group by 4 bits)

0001 1110 1010

1 E A

(25)

25

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 49

2 0 1 3

Exercise – Convert ...

1AF 703

1110101 33

Hexa- Decimal Octal

Binary Decimal

50

2 0 1 3

Exercise – Convert ...

1AF 657

110101111 431

1C3 703

111000011 451

75 165

1110101 117

21 41

100001 33

Hexa- Decimal Octal

Binary

Decimal

(26)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 51

2 0 1 3

Arithmetic in Binary

• Remember: there are only 2 digits in binary: 0 and 1

• Position is key, carry values are used:

Carry Values 1 1 1 1 1 1

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

1 0 1 0 0 0 1 0

2 0 1 3

Binary Subtraction

Remember borrowing?

Apply that concept here:

1 2

2 0 2

1 0 1 0 1 1 1

(27)

27

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 53

2 0 1 3

Number System ( Summary )

ƒ Binary 0,1

ƒ Octal 0,1,2,3,4,5,6,7

ƒ Decimal 0,1,2,3,4,5,6,7,8,9

ƒ Hexadecimal 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

54

2 0 1 3

Basic Logic Functions

1 1

0 1

1 0

0 0 0

1 0

1 0

1 1

0 1 0

0 0

1 0

1 1

0 0 1

0 1

0 0

0 1

1 1 1

not A A

xnor B A

xor B A

nor B A

nand B A

or B A

and

B

B

A

(28)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 55

2 0 1 3

Logic Gate Symbols

ƒ AND

ƒ OR

ƒ NAND

ƒ NOR

ƒ XOR

ƒ XNOR

ƒ NOT

2 0 1 3

Logic Gates

ƒ Logic Gates are the basic building blocks for building electronic (digital) circuits

ƒ They have output terminal, and ( n ) input terminal(s)

ƒ Output will be 1 or 0, depending on the digital levels of the input terminal(s)

ƒ These gates form the basic building blocks of digital systems; that evaluate digital input levels and

produce specific output response

Logic Gate

(29)

29

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 57

2 0 1 3

Logic Gate Notations

ƒ Not A is written Ā

ƒ A and B is written AB

ƒ A or B is written A + B

ƒ A xor B is written A ⊕ B

58

2 0 1 3

Related Terminologies

1. Boolean Expression

ƒ An expression which evaluates to either true or false is called a Boolean Expression.

ƒ An expression that results in a value of either TRUE or FALSE. For example, the expression 2 < 5 (2 is less than 5) is a Boolean expression because the result is TRUE.

ƒ All expressions that contain relational operators , such as the less than sign (<), are Boolean.

ƒ The operators - - AND, OR, XOR, NOR, and NOT - - are Boolean operators.

ƒ Boolean expressions are also called comparison expressions, conditional expressions, and relational expressions.

(30)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 59

2 0 1 3

Related Terminologies

2. Truth Table

ƒ A truth table shows how a logic circuit's output responds to various combinations of the inputs, using logic 1 for true and logic 0 for false.

ƒ A truth table is a breakdown of a logic function by listing all possible values the function can attain

ƒ All permutations of the inputs are listed on the left, and the output of the circuit is listed on the right. The desired output can be achieved by a combination of logic gates.

ƒ A truth table can be extended to any number of inputs. The input columns are usually constructed in the order of binary counting with a number of bits equal to the number of inputs.

2 0 1 3

Related Terminologies

3. Logic Circuit

ƒ Logic Circuit is a graphical representation of a program using formal logic

(31)

31

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 61

2 0 1 3

AND Gate

ƒ This is a 2-Input AND Gate…(label inputs & output)

ƒ By convention, letters A, B are used as inputs, and letter(s) X is used as output

ƒ AND Gate Operation is defined as:

ƒ The output, X, is HIGH if input A and input B are both HIGH.

ƒ Output is 1 only when all inputs are 1

ƒ Let’s complete a truth table for the AND gate

AND

62

2 0 1 3

AND Gate

ƒ AND Gate Truth Table

0 X = 0

0

0 X = 0

1

1 X = 0

0

1 X = 1

1

AND Truth Table

1 1

1

0 0

1

0 1

0

0 0

0

X B

A

AND

(32)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 63

2 0 1 3

AND Gate

ƒ Notation of AND Gate

ƒ A AND B

ƒ A . B

ƒ A B

ƒ AND gates may havemore than two inputs

ƒ How many combinations to be listed in a truth table?

AND

2 0 1 3

OR Gate

ƒ This is a two-input OR gate…(label inputs & output)

ƒ OR Gate Operation is defined as:

ƒ The output at X will be HIGH whenever input A or input B is HIGH or both are HIGH.

ƒ Output is 1 only when any of the inputs is 1

ƒ Let’s complete a truth table for the OR gate

OR

(33)

33

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 65

2 0 1 3

OR Gate

z

OR Gate Truth Table

0 X = 0

0

0 X = 1

1

1 X = 1

0

1 X = 1

1

OR Truth Table

1 1

1

1 0

1

1 1

0

0 0

0

X B

A

OR

66

2 0 1 3

ƒ Notation of OR Gate

ƒ A OR B

ƒ A + B

ƒ AND gates may have more than two inputs

ƒ How many combinations to be listed in a truth table?

OR

(34)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 67

2 0 1 3

NOT Gate

ƒ Not gate is also known as Inverter Gate

ƒ

A NOT gate is a one-input-one-output logic gate

ƒ Notation of NOT Gate: NOT A = A

NOT

2 0 1 3

NOT Gate

NOT

0 1

When A = 0, Output X is NOT 0, Hence = 1

1 0

0 1

1 0

X A

NOT Truth Table

(35)

35

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 69

2 0 1 3

XOR Gate

ƒ XOR is also called as Exclusive OR

ƒ Operation of XOR gate

ƒ True if either true but not both

ƒ Similar Input, Output will be 0

ƒ Dissimilar Input, Output will be 1

ƒ Notation of XOR gate: A B

+

70

2 0 1 3

XOR Gate

ƒ XOR Gate

XOR Truth Table

0 1

1

1 0

1

1 1

0

0 0

0

X B

A

ƒ True if either true but not both

ƒ Similar Input, Output will be 0

ƒ Dissimilar Input,

Output will be 1

(36)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 71

2 0 1 3

XOR Gate

2 0 1 3

NAND Gate

ƒ NAND gate

( NOT-AND = NAND, opposite of AND )

ƒ The simplest NAND gate is a two-input-one-output logic gate

ƒ Operation of NAND gate:

ƒ NAND = Output is 0 only when all inputs are 1

NAND

(37)

37

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 73

2 0 1 3

NAND Gate

0 X = 1

0

0 X = 1

1

1 X = 1

0

1 X = 0

1

NAND Truth Table

0 1

1

1 0

1

1 1

0

1 0

0

X B

A

NAND

74

2 0 1 3

NOR Gate

ƒ NOR gate ( NOT-OR = NOR, opposite of OR )

ƒ The simplest NOR gate is a two-input-one-output logic gate

ƒ Operation of NOR gate:

ƒ NOR gate = Output is 1 only when all inputs are 0

NOR

(38)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 75

2 0 1 3

NOR Gate

NOR

NOR Truth Table

0 1

1

0 0

1

0 1

0

1 0

0

X B

A

0 X = 1

0

0 X = 0

1

1 X = 0

0

1 X = 0

1

2 0 1 3

NXOR Gate

ƒ NXOR gate ( NOT-XOR = NOR, opposite of XOR )

ƒ The simplest NXOR gate is a two-input-one-output logic gate

ƒ Operation of XNOR gate

ƒ Similar Input, Output will be 1

ƒ Dissimilar Input, Output will be 0

NXOR Truth Table

0 1 0

1 0 0

X

B

A

(39)

39

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 77

2 0 1 3

Boolean Exp → Logic Circuit

ƒ To draw a circuit from a Boolean expression:

ƒ From the left, make an input line for each variable.

ƒ Next, put a NOT gate in for each variable that appears negated in the expression.

ƒ Still working from left to right, build up circuits for the sub-expressions, from simple to complex.

78

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ Logic Circuit:

A B + (A+B) B

ƒ Input Lines for Variables

A

B

(40)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 79

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ NOT Gate for B

A

B

B

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ Sub-expression A B

A

B

A B

(41)

41

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 81

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ Sub-expression A + B

A

B

B

A B

A + B

82

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ Sub-expression A + B

A

B

B

A B A+B

A + B

(42)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 83

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ Sub-expression ( A + B ) B

A

B

B

A B

A+B A + B

(A+B) B

2 0 1 3

Logic Circuit: A B + (A+B) B

ƒ Entire Expression

A

B

B

A B

A+B A + B

(43)

43

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 85

2 0 1 3

Logic Circuit → Boolean Exp

ƒ In the opposite direction, given a logic circuit, we can write a Boolean expression for the circuit.

ƒ First we label each input line as a variable.

ƒ Then we move from the inputs labeling the outputs from the gates.

ƒ As soon as the input lines to a gate are labeled, we can label the output line.

ƒ The label on the circuit output is the result.

86

2 0 1 3

Logic Circuit → Boolean Exp

A

B

_ A

_ B

A+B _ AB

_ AB

_ _ AB+AB

_ _ AB+AB

______

_ _

(AB+AB) (A+B) ______

Entire Expression

(44)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 87

2 0 1 3

Simplifying Boolean Expressions

ƒ As in ordinary algebra, some Boolean expressions can be simplified

ƒ The logic circuit that results from a simplified expression will have fewer gates and operations

ƒ XOR is not a Basic Function

B A B

A B

A ⊕ = +

2 0 1 3

Laws of Boolean Algebra

Identity Law Zero Law A + 0 = A A . 0 = 0 A . 1 = A A + 1 = 1

Idempotent Law Commutative Law A + A = A A + B = B +A

A . A = A AB = BA

Associative Law Distributive Law (A+B) + C = A + (B+C) A (B+C) = AB + AC (AB) C = A (BC) A + BC = (A+B) (A+C)

(45)

45

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 89

2 0 1 3

Laws of Boolean Algebra

Absorption Law DeMorgan’s Law A + AB = A A+B____

= A_ B_

A (A+B) = A ___AB

= A_ +B_

Complement Law Double Complement A + A_

= 1 A__

= A A A_

= 0

90

2 0 1 3

Identity and Null Law

ƒ Identity Law

ƒ A + 0 = A

ƒ A . 1 = A

ƒ A ⊕ 0 = A

ƒ Null Law

ƒ A + 1 = 1

ƒ A . 0 = 0

ƒ A ⊕ 1 = Ā

(46)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 91

2 0 1 3

Idempotence and Inverse Law

ƒ Idempotence Law

ƒ A + A = A

ƒ A . A = A

ƒ A ⊕ A = 0

ƒ Inverse Law

ƒ A + Ā = 1

ƒ A . Ā = 0

ƒ A ⊕ Ā = 1

A A =

2 0 1 3

Commutative and Associative Law

ƒ Commutative Law

ƒ

A + B = B + A

ƒ

AB = BA

ƒ

A ⊕ B = B ⊕ A

ƒ Associative Law

ƒ

A + B + C = (A+B)+C

= A+(B+C)

ƒ

A B C = (AB) C

= A (BC)

ƒ

A ⊕ B ⊕ C = (A ⊕ B) ⊕ C

= A ⊕(B ⊕ C)

(47)

47

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 93

2 0 1 3

Distributive and Absorption Law

ƒ Distributive Law

ƒ AB + AC = A (B + C)

ƒ AB ⊕ AC = A (B ⊕ C)

ƒ Absorption Law

ƒ A + AB = A

ƒ A (A+B) = A

94

2 0 1 3

DeMorgan’s Law

B A B

A + =

B A

AB = +

(48)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 95

2 0 1 3

DeMorgan’s Law

ƒ Implementation of DeMorgan's Theorem with basic gates.

2 0 1 3

Simplification Revisited

ƒ Once we have the BE for the circuit, perhaps we can simplify.

( ) ( ) ( )

( )( ) ( )

( )( )

( A B ) A

B B A B A

B A B A B A

B A B A B A B A B A B A

+

=

+ +

=

+ +

+

=

+

=

+

+

(49)

49

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 97

2 0 1 3

Logic Circuit → Boolean Exp

Reduces to :

98

2 0 1 3

Example 1

( )

AB AB

AB A A

B A A

Law Identity Apply

0

Law Inverse Apply

Law ve Distributi Apply

+ +

+

(50)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 99

2 0 1 3

Example 2

C) D)(A (B

C) D(A C)

B(A

CD) (AD

BC) (AB

CD AD

BC AB

+ +

+ +

+

+ +

+

+ +

+

again Law ve Distributi Apply

Law ve Distributi Apply

Law e Associativ Apply

2 0 1 3

Example 3

( )

( )

( )

B A

B A B A

B A B A B A

B A B A B A

B A B A

+

+ +

+ +

+

on Substituti Use

e Idempotenc Apply

Law e Associativ Apply

on Substituti Use

(51)

51

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 101

2 0 1 3

Example 4

( )

1

Law Inverse

Apply

Law s DeMorgan' Apply

Law e Associativ Apply

AB AB

B A AB

B A AB

+ + +

+ +

102

2 0 1 3

Example 5

( )( ) ( )( )

A B A B

B A B A

B A B A

B A

+ +

+

again Law s DeMorgan' Apply

Law s DeMorgan' Apply

Or

&

And using Rewrite

(52)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 103

2 0 1 3

Example 5 (continued)

( )( )

( )( )

Law Identity

Apply

0 0

Law Inverse

Apply

Law ve Distributi Apply

Law Inverse

Apply

AB B

A

AB B

A

B B AB B

A A A

B A B A

B A B A

+

+ +

+

+ +

+

+ +

+ +

2 0 1 3

Example 6

( )

( ) ( )

( ) ( )

Law Identity

Law Inverse

0 0

Law ve Distributi

Law s DeMorgan'

Law s DeMorgan'

Law Inverse Apply

B A B A

B A B A

B B B A B A A A

B A B A

B A AB

B A AB

B A AB

+

+ + +

+ + +

+ +

+ +

(53)

53

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 105

2 0 1 3

Algebraic Manipulation Examples

1. X + XY = X (1+Y) = X

2. XY + XY’ = X (Y + Y’) = X

3. X + X’Y = (X + X’) (X + Y) = X + Y

4. X (X + Y) = X + XY = X (1 + Y) = X

5. (X + Y)(X + Y’) = X + XY’ + XY + YY’

= X (1 + Y’) + XY

= X·1 + XY

= X + XY

= X (1 + Y)

= X

6. X(X’ + Y) = XX’ +XY = XY

106

2 0 1 3

The Boolean Triangle

Boolean Expression

Truth Table Logic

Circuit

(54)

Compiled By: Muzammil Ahmad Khan

&

Kashif Shaikh

CPF - Chapter No 4 : Number Systems and Logic Gates 107

2 0 1 3

Review Basic Logic Gates

2 0 1 3

Conclusion

ƒ Logic Gates and Boolean Algebra are the bridge

between symbolic logic and electronic digital

computing.

References

Related documents

Wavelet Based Data Mining Method for Risk Measures and Portfolio Management, presented at the 7th NCTU National Finance Conference, January, 2014.. Augmented Wavelet Analyzing

Pada proses pembuatan suatu proyek konstruksi, pemilik dapat memilih salah satu alternatif pembiayaan proyek dari Metode Simple Alternatives dan Metode Multiple Alternatives

The management of the benchmark watershed villages in China, Thailand and India, in line with watershed concepts, reduced land degradation and soil loss, improved water use

Good Morning. I am Charlene Red Thunder, Area Director of the Aberdeen Area Indian Health Service. I am an enrolled tribal member of the Cheyenne River Sioux Tribe of South Dakota.

number. 3) If the complement of the input’s (or output’s) internal logic state affects inputs or outputs, then a bar is placed over the identifying numbers of the affected inputs or

The county and/or vendors/sub-contractors receiving SAPTBG funds, for the provision of providing substance abuse prevention, intervention or treatment services shall report and

Wkh lqwxlwlrq lv vwudljkwiruzdug1 Wkh vwduw0xs wd{ j lv vxqn dw hruw vwdjh dqg grhv qrw gluhfwo| dhfw surw vkdulqj dqg dgylfh lq +;,/ vhh Sursrvlwlrq 4 dqg lwv looxvwudwlrq lq Iljxuh

The following are registered trademarks or trademarks of Autodesk, Inc., in the USA and other countries: 3DEC (design/logo), 3December, 3December.com, 3ds Max, ADI, Alias, Alias