4-EED220 Lecture 4
4-EED220 Lecture 4
4-EED220 Lecture 4
Lecture 4
Binary Codes & Boolean Algebra
Mostafa Salah, Ph.D.
[email protected]
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
3
Binary Codes
Carry
BCD Addition
• When the binary sum is Greater than 9,
◼ 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
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
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
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, …).
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.
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.
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.