0% found this document useful (0 votes)
21 views19 pages

2-Binary Codes and Binary Logic

Uploaded by

Hamayun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
21 views19 pages

2-Binary Codes and Binary Logic

Uploaded by

Hamayun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 19

ACS134

DIGITAL & EMBEDDED SYSTEMS

LECTURE 3
BINARY CODES AND BINARY
LOGIC
Outline

• Binary codes
• Logic operations
• Logic gates
• Boolean functions
Weighted & non-weighted codes

• Code: A set of n-bit strings in which different bit strings


represent different numbers or other things is called a
code.
• WEIGHTED CODE
• obeys the position weighting principle, which states
that the position of each digit represents a specific
weight.
• example applications: data manipulation during
arithmetic operation and for input/output operations in
digital circuits
• example codes: Binary coded decimal and 2421
codes
Weighted & non-weighted codes

• NON- WEIGHTED CODE


• are not positionally weighted. So codes are not
assigned with any weight to each digit position.
• example applications: shift position encodes and for
error detecting purpose
• example codes: Excess-3 and Gray codes
Binary coded decimal (BCD)

Digit BCD Digit BCD


Code Code
0 0000 5 0101
1 0001 6 0110
2 0010 7 0111
3 0011 8 1000
4 0100 9 1001

• The weighted code BCD represents each decimal digit with


four bits
• Ex. 0011 0010 1001 = 32910
3 2 9

• This is NOT the same as 0011001010012


• Why do this? Because people think in decimal.
Other decimal codes

See https://www.tutorialspoint.com/what-is-excess-3-code
for more info on excess-3 codes
Gray code
Digit Binary Gray Code
0 0000 0000
1 0001 0001 • Gray code is not a number
2 0010 0011 system.
3 0011 0010 • It is an alternate way to
4 0100 0110
represent four bit data
5 0101 0111
6 0110 0101 • Only one bit changes from
7 0111 0100 one decimal digit to the
8 1000 1100 next
9 1001 1101
10 1010 1111 • Useful for reducing errors
11 1011 1110 in communication.
12 1100 1010 • Can be scaled to larger
13 1101 1011
numbers.
14 1110 1001
15 1111 1000
ASCII Code

• American Standard Code for Information Interchange


• ASCII is a 7-bit code, frequently used with an 8th bit for
error detection.
Character ASCII (bin) ASCII (hex) Decimal Octal
A 1000001 41 65 101
B 1000010 42 66 102
C 1000011 43 67 103

Z
a

1

ASCII codes with error-
detection
Parity bit: Extra bit to make the total number of 1’s
either even or odd
with even parity with odd parity

ASCII A = 1000001 01000001 11000001


ASCII T = 1010100 11010100 01010100

This method detects one, three or any odd combination


of errors in each character transmitted
Boolean Algebra
Boolean algebra is the mathematical language of digital
electronic circuits. It describes the arithmetical operation of a
two-state system. Consider the circuit below:
D

Points in the circuit are represented by Boolean variables


using symbols like A, B, C, etc. (small letters are sometimes
used too)
Boolean variables take the value either 0 or 1 only (or ‘false’
or ‘true’) and are thus known also as binary variables.
Inside the red boxes are the logic gates which define the
binary/ Boolean/logical operators. Three basic logic gates
are the NOT, AND and OR gates.
NOT gate
Truth Table
A Y

0 1
A Y
1 0

Symbol
Input Output
• The functionality can be represented with truth tables.
• Truth table completely specifies outputs for all input
combinations.
• NOT gate (or inverter):
• An input of 0 is inverted to a 1.
• An input of 1 is inverted to a 0.
• Logic operation: A’=Y (or 𝐴ҧ = 𝑌), ‘not A is equal to Y’
AND gate

A
Y
B

• Logic operation: A●B=Y, ‘A AND B equals to Y’


• If the two inputs signals Truth Table
are 1 (high) the A B Y

output will also be 1. 0 0 0

Otherwise, the output will 0 1 0


be 0 (low). 1 0 0

1 1 1
OR gate

A
Y
B

• Logic operation: A+B=Y, ‘A OR B equals to Y’


• If either of the two Truth Table
input signals are A B Y

1, or both of 0 0 0
them are, the output 0 1 1
will be 1. 1 0 1

1 1 1
Gate with multiple
inputs

3 Input OR Gate
Example: Alarm system with use of OR
gate
Ordering Boolean Functions

• How to interpret AB+C?


 Is it AB ORed with C ?
 Is it A ANDed with B+C ?
• For above, order of precedence for Boolean algebra:
AND before OR.
• Note that parentheses are needed here:

• Generally, the order of precedence is (from high to low


priority): parentheses, NOT, AND, OR.
Ordering Boolean Functions

• Write an expression for the output of the circuit, x


Private Study

• Review the slides

• Mano, Ciletti, Digital Design:


• Read Chapter 1: Sections 1.7 and 1.9
Summary

• Binary codes
• Logic operations
• Logic gates
• Boolean functions

You might also like