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

ICS 2205 Lecture 2 - Gray Code, Boolean Algebra and Logic Gates

The document discusses digital logic and Boolean algebra. It begins with an overview of Gray code, including how to convert between binary and Gray code. It then covers Boolean algebra, describing the basic logic operations of OR, AND, and NOT. It defines various logic gates including NOR, NAND, XOR, and XNOR. Laws of Boolean algebra are also discussed.

Uploaded by

christine wambui
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

ICS 2205 Lecture 2 - Gray Code, Boolean Algebra and Logic Gates

The document discusses digital logic and Boolean algebra. It begins with an overview of Gray code, including how to convert between binary and Gray code. It then covers Boolean algebra, describing the basic logic operations of OR, AND, and NOT. It defines various logic gates including NOR, NAND, XOR, and XNOR. Laws of Boolean algebra are also discussed.

Uploaded by

christine wambui
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

DIGITAL LOGIC

 CHAPTER TWO: *Gray Code


*Boolean Algebra & Logic Gates (Part I)

By J. Mathenge

1 ICS 2205_DIGITAL LOGIC


Previously on NUMBER SYSTEMS AND CODES
1.8.3 Gray Code
*Read on Gray Code and its advantages.
In gray code, only one bit changes in going from one
number to the next.
It is a non-weighted code.
Converting from Binary to Gray Code
Example: Convert 101110110 to Gray Code.
i. Record the MSB of the binary number:
1
ii. Add the binary MSB to the next bit position, record
the sum and neglect any carries.
1 0 1 1 1 0 1 1 0

2 ICS 2205_DIGITAL LOGIC


NUMBER SYSTEMS AND CODES

. 1 0 1 1 1 0 1 1 0

1 1

iii. Record successive sums until completed.


1 1 1 0 0 1 1 0 1

Converting from Gray to Binary


Example: Convert 111001101 to Binary
i. Record the MSB of the given number:
1

3 ICS 2205_DIGITAL LOGIC


NUMBER SYSTEMS AND CODES

ii. Add the binary MSB to the next significant bit


position of the Gray Code number you are converting;
again recording the sum and ignoring any carries.
1 1 1 0 0 1 1 0 1

iii. Continue the process until completed.


1 0 1 1 1 0 1 1 0

4 ICS 2205_DIGITAL LOGIC


NUMBER SYSTEMS AND CODES

The table below shows the Gray codes for the first 16
decimal digits:

5 ICS 2205_DIGITAL LOGIC


Previously on NUMBER SYSTEMS AND CODES

Advantage of Gray Code


Only one (1) bit change in the gray code in moving
from one number to the next. Gray code is often used
in situations where other codes might produce
erroneous or ambiguous results during those
transitions in which more than 1 bit of the code is
changing e.g. in the transition from 7 to 8 in binary, all
bits change.

6 ICS 2205_DIGITAL LOGIC


Some Examples on Binary Arithmetic.

Perform: 39-25 in binary.


i. Rewrite the problem as: 39+(-25)
ii. Get the unsigned binary equivalents of 39 and 25.
32 16 8 4 2 1
39 1 0 0 1 1 1
25 0 1 1 0 0 1

Sign 32 16 8 4 2 1
Bit
+39 0 1 0 0 1 1 1
+25 0 0 1 1 0 0 1

7 ICS 2205_DIGITAL LOGIC


Some Examples on Binary Arithmetic.

Sign Bit (-64) 32 16 8 4 2 1


+25 0 0 1 1 0 0 1
OCN 1 1 0 0 1 1 0
Add one 1
-25 1 1 0 0 1 1 1
(TCN)

Sign Bit (-64) 32 16 8 4 2 1


+39 0 1 0 0 1 1 1
+(-25) 1 1 0 0 1 1 1
Solution 1 0 0 0 1 1 1 0

Carry Over/Over 8+4+2 = 14


8 ICS 2205_DIGITAL LOGIC
flow. Ignore it
Some Examples on Binary Arithmetic.

Perform: 659+825.
1024 512 256 128 64 32 16 8 4 2 1
659 1 0 1 0 0 1 0 0 1 1
825 1 1 0 0 1 1 1 0 0 1

1024 512 256 128 64 32 16 8 4 2 1


659 0 1 0 1 0 0 1 0 0 1 1
825 0 1 1 0 0 1 1 1 0 0 1

1024 512 256 128 64 32 16 8 4 2 1


659 0 1 0 1 0 0 1 0 0 1 1
825 0 1 1 0 0 1 1 1 0 0 1
Solution 1 0 1 1 1 0 0 1 1 0 0

9 ICS 2205_DIGITAL LOGIC  


Some Examples on Binary Arithmetic.
Perform: 659-825.
Rewrite the problem as: 659+(-825)
Sign Bit (-1024) 512 256 128 64 32 16 8 4 2 1

659 1 0 1 0 0 1 0 0 1 1
825 1 1 0 0 1 1 1 0 0 1

Sign Bit (-1024) 512 256 128 64 32 16 8 4 2 1


+659 0 1 0 1 0 0 1 0 0 1 1
+825 0 1 1 0 0 1 1 1 0 0 1

Sign Bit (-1024) 512 256 128 64 32 16 8 4 2 1


+825 0 1 1 0 0 1 1 1 0 0 1
OCN 1 0 0 1 1 0 0 0 1 1 0
Add 1
1
10 -825 1
ICS 2205_DIGITAL LOGIC 0 0 1 1 0 0 0 1 1 1
Some Examples on Binary Arithmetic.

 Perform: 659-825.
Sign Bit (-1024) 512 256 128 64 32 16 8 4 2 1
+659 0 1 0 1 0 0 1 0 0 1 1
+(-825) 1 0 0 1 1 0 0 0 1 1 1
1 1 1 0 1 0 1 1 0 1 0

11 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.1  Introduction

In Boolean algebra, the variables (known as Boolean
variables) are allowed to have only two possible values (0
or 1).
The expression x =f(A;B) means x is a function of
variables A and B where and B are Boolean variables and
can only take on two possible values 0 or 1.
2.2 Basic Operations of Boolean Algebra
Boolean algebra has only 3 basic operations:
i. Logical addition (the OR operation), Symbol “+”
ii. Logical multiplication (the AND operation), Symbol “.”
iii. Logical complementation (the NOT operation), Symbols
12 ICS 2205_DIGITAL LOGIC
2. BOOLEAN ALGEBRA AND LOGIC GATES
2.2.1 The OR operation
Operates on two or more variables. It is expressed as:
Example: x = A + B

Example: x = A + B + C

13 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.2.2 The AND operation
Example: x = A . B

2.2.3 NOT operation

Is read as .x = NOT A.

14 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.3 Other Logic Gates
2.3.1 The NOR gate
For two variables A and B, the NOR operation is
defined as:

15 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.3.2 The NAND gate

Read as .x equals NOT (A AND B AND C).

16 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.3.3 The Exclusive-OR gate
Defined as:

The Exclusive-OR operation is sometimes abbreviated


as XOR or EXOR.
Note that the XOR gate has only two inputs.

17 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.3.4 The Exclusive-NOR gate
This is usually abbreviated as XNOR or EXNOR gate.
It is the complement of the XOR operation.

18 ICS 2205_DIGITAL LOGIC


2. BOOLEAN ALGEBRA AND LOGIC GATES
2.4 Laws of Boolean Algebra

Looking at the above table, we can see that the


corresponding laws on either side are related by:
i. Interchanging + and . Symbols
ii. Interchanging 0 and 1
Theorems which are related to another by this double
19 ICSinterchange are known as duals.
2205_DIGITAL LOGIC
*End of session*

20 ICS 2205_DIGITAL LOGIC


Questions….?

21 ICS 2205_DIGITAL LOGIC

You might also like