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

Faculty of Engineering and Technology

Electrical Engineering Department

EED220: Logic Design

Lecture 4
Binary Codes & Boolean Algebra
Mostafa Salah, Ph.D.
mostafa.abdulkhalek@fue.edu.eg
Contents
• Binary Codes
• Binary Logic
• Logic Gates
• Timing Diagram
• Introduction to Boolean Algebra

2
Binary Codes
Binary-Coded Decimal Code
• Each group of 4 bits representing one decimal digit.
(185)10 = (0001 1000 0101)BCD = (10111001)2

• A binary code that distinguishes among 10 elements


must contain at least FOUR bits, but 6 out of the 16
possible combinations remain unassigned.
• The binary combinations 1010 through 1111 are not used and
have no meaning in BCD.

➢It is important to realize that BCD numbers are


decimal numbers and not binary numbers, although
they use bits in their representation.

3
Binary Codes
Carry

BCD Addition
• When the binary sum is Greater than 9,

greater than or equal to 1010,


the result is an invalid BCD
digit. then add 6
• The addition of 6 = (0110)2 to the
binary sum converts it to the
correct digit and produces a
carry as required.
• This is because a carry in the
most significant bit position of
the binary sum and a decimal
carry differ by 16 – 10 = 6.
4
Binary Codes
Other Decimal Codes
• BCD, 2421, 8 4 -2 -1 are
weighted codes
• Excess‐3 is an unweighted code in
which each coded combination is
obtained from the corresponding
binary value plus 3

◼ Self-complementing:
◼ The sum of the weights = 9
◼ Can directly get 9’s complement
5
Binary Codes
ASCII Code
• Many applications of digital computers
require the handling not only of numbers, but
also of other characters or symbols, such as
the letters of the alphabet.
• In 1963, the American Standards Association
published the American Standard Code for
Information Interchange (ASCII), which
assigns each text character a unique byte
value.
• which uses seven bits to code 128 characters, as shown in
Table. The seven bits of the code are designated by b1 through
b7, with b7 the most significant bit. The letter A, is represented in
• ASCII is a seven‐bit code, but most computers manipulate an ASCII as 1000001 (column 100,
eight‐bit quantity. The extra bit is sometimes used for other row 0001)
purposes, depending on the application.

6
Unicode
Unicode, formally the Unicode Standard, is an information technology standard for
the consistent encoding, representation, and handling of text expressed in most of
the world's writing systems.
• First published 1991, Version 13.0, published March 2020, has 143,924
characters.
• Incorporates ASCII as code points 0–127, no change.
• Sufficient for the alphabet of almost any language (Chinese or Japanese)..
• Code points: represented as U+ followed by at four (more only if needed)
upper-case hexadecimal digits
• U+0041 A LATIN CAPITAL LETTER A
• U+2FC2 ⿂ KANGXI RADICAL FISH
• U+1F355 🍕 SLICE OF PIZZA (Meaning, not pictures)

7
Binary Codes
0 1

Gray Code 000 001


7 2
Non-weighted code. The advantage of the Gray code 111 010

over the straight binary number sequence is that only 110 011
3
6
one bit in the code group changes in going from one 101 100

number to the next Low power design. 5 4

Binary Code
000 001

0 1
011 000 001
010 7 2
100 101 100 011

101 010
3
6 111 110
110 111
Gray Code
5 4

8
Binary Codes
Binary to Gray Code Gray to Binary Code
• The generation of 4-bit Gray code: • The generation of 4-bit Binary code:
• G3 =   •   = G
• G2 =      •  = G  G
• G1 =      •  = G  B
• G0 =      •  = G  B

Gray Bits Binary Bits


B3 G3 G3 B3

B2 G2 B2
G2

B1 G1
B1
G1

G0
B0 B0
G0

9
Binary Codes
Binary to Gray Code Using Reflect
Method
▪ The generation of n-bit Gray code is done recursively
using reflect and prefix method:
• Generate code for n=1: 0 and 1 code.
• Take previous code in sequence: 0 and 1.
• Add reversed codes in the following list: 0, 1, 1 and 0.
• Now add prefix 0 for original previous code and prefix 1 for
new generated code: 00, 01, 11, and 10.

10
Binary logic
• Binary logic deals with variables that take on two discrete values and
with operations that assume logical meaning.

• The two values the variables assume may be called by different names
(true and false, yes and no, 1 and 0, …).

• Binary logic consists of binary variables and a set of logical operations.


• The variables are designated by letters of the alphabet, such as A, B, C, x, y, z,
etc.,
• Each variable having two and only two distinct possible values: 1 and 0.
• There are three basic logical operations: AND, OR, and NOT. Each operation
produces a binary result.
11
Binary logic
1. AND: This operation is represented by a dot or by the absence of an operator.
• For example, x.y = z or xy = z is read “x AND y is equal to z.”
• The logical operation AND is interpreted to mean that z = 1 if and only if x = 1 and y = 1;
otherwise, z = 0.

2. OR: This operation is represented by a plus sign.


• For example, x + y = z is read “x OR y is equal to z,”
• meaning that z = 1 if x = 1 or if y = 1 or if both x = 1 and y = 1. If both x = 0 and y = 0, then
z = 0.

3. NOT: This operation is represented by a prime


• For example, x’ = z (or 𝑥ҧ = z ) is read “not x is equal to z,”
• meaning that z is what x is not.
• In other words, if x = 1, then z = 0, but if x = 0, then z = 1. The NOT operation is also
referred to as the complement operation, since it changes a 1 to 0 and a 0 to 1.
12
Switching Circuit

AND

OR

13
Logic Gates
• Logic gates are electronic circuits that operate on one or more input
signals to produce an output signal.

• The graphic symbols used to designate the three types of gates are
shown in Fig.

• The gates are blocks of hardware that produce the equivalent of


logic‐1 or logic‐0 output signals if input logic requirements are
satisfied.
14
Logic Gates: Complementary MOSFET Technology
• Logic gates are implemented by several technologies.
• CMOS: P-MOS and N-MOS connected between supply rails.

2-input AND gate 2-input OR gate NOT gate

15
Signal Levels for Binary Logic Values
• In a digital system voltages are interpreted to
be either of two recognizable values, 0 or 1.
• For example, a particular digital system may
define logic 0 as a signal equal to 0 V and logic 1
as a signal equal to 3 V.

• In practice, each voltage level has an


acceptable range.
• The input terminals of digital circuits accept
binary signals within the allowable range and
respond at the output terminals with binary
signals that fall within the specified range.

16
Timing Diagram
The timing diagrams illustrate the

voltage
response of each gate to the input
signal combinations; Most timing diagrams
use the following conventions:
• Higher value is a logic one
• Lower value is a logic zero
• A slot showing a high and low is an either or
(such as on a data line)
• A greyed-out slot is a don’t care or
indeterminate.

time

1
7
Boolean Algebra
Father of Boolean algebra
• He came up with a type of linguistic algebra, the three most basic
operations of which were (and still are) AND, OR and NOT. It was
these three functions that formed the basis of his premise and
were the only operations necessary to perform comparisons or
basic mathematical functions.
• Boole’s system (detailed in his 'An Investigation of the Laws of
Thought, on Which Are Founded the Mathematical Theories of
Logic and Probabilities', 1854) was based on a binary approach,
processing only two objects - the yes-no, true-false, on-off, zero-
one approach.
• Surprisingly, given his standing in the academic community, Boole's
idea was either criticized or completely ignored by the majority of
his peers. George Boole
November 1815 – December 1864
• Eventually, one bright student, Claude Shannon (1916-2001),
picked up the idea and ran with it

18
Two‐Valued Boolean Algebra
A two‐valued Boolean algebra is defined on a set of two
elements, B = {0, 1}, with rules for the two binary operators “
+“ and “ ∙ “ as shown in the following operator tables

Terminology:
Literal: A variable or its complement
Product term: literals connected by •
Sum term: literals connected by +

These rules are exactly the same as the AND, OR, and NOT
operations, respectively,

19
References
‒ M. Mano and M. Ciletti, Digital Design, with an introduction to the
Verilog HDL. 5th Ed. Pearson, 2013.
‒ John F. Wakerly, Digital Design: Principles and Practices. 4th Ed.
Pearson, 2005.
‒ R. Katz and G. Boriello, Contemporary Logic Design. 2nd Ed. Pearson,
2005.
‒ S. Brown and Z. Vranesic , Fundamentals of Digital Logic with Verilog
Design. 3rd Ed. SEM, 2013.

You might also like