0% found this document useful (0 votes)
14 views10 pages

Logic Design 3

Uploaded by

myschoolonthego
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views10 pages

Logic Design 3

Uploaded by

myschoolonthego
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Logic Design Dr.

YOUSRA AHMED
Lec_3

Binary Arithmetic
Binary arithmetic includes the basic arithmetic operations of addition, subtraction,
multiplication and division. The following sections present the rules that apply to these
operations when they are performed on binary numbers.

Binary Addition
Binary addition is performed in the same way as addition in the decimal-system and is, in
fact, much easier to master. Binary addition obeys the following four basic rules
0+ 0+ 1+ 1+
0 1 0 1
0 1 1 10

The results of the last rule may seem somewhat strange, remember that these are binary
numbers. Put into words, the last rule states that.

Example
01 + 10 +
10 00
11 10

Example
111 + 1010
101 1001
1100 1101
100000

C++ 1
Logic Design Dr. YOUSRA AHMED
Lec_3

Binary Subtraction:
Binary subtraction is just as simple as addition subtraction of one bit from another according
the following four basic rules.
0–0=0
1 – 1 =0
1–0=1
0 – 1 = 1 with a transfer (borrow) of 1.

Example:
1001 -
101
100

10 0 0 0 -
0 0 101
100 11
Binary Multiplication
0*0=0
1 * 0=0
0 * 1= 1
1*1=1

C++ 2
Logic Design Dr. YOUSRA AHMED
Lec_3

Example
101 *
10
000
101
1 0 1 0

Example:
1100 *
1010
0000
1100
0000
1100
111 1 0 0 0

C++ 3
Logic Design Dr. YOUSRA AHMED
Lec_3

Binary Division
0/ 1= 0
1 / 1= 1

Example:

Example:

C++ 4
Logic Design Dr. YOUSRA AHMED
Lec_3

Coding System
 Binary Coded Desimal (BCD)
 ASCII CODE

 Binary Coded Desimal (BCD)


Is an encoding for decimal numbers in which each digit is represented by its own binary
sequence. In computing and electronic systems, binary-coded decimal (BCD) is an
encoding for decimal numbers in which each digit is represented by its own binary
sequence. Its drawbacks are the increased complexity of circuits needed to implement
mathematical operations and a relatively inefficient encoding – it occupies more space
than a pure binary representation. Even though the importance of BCD has diminished, it
is still widely used in financial, commercial, and industrial applications. In BCD, a digit
is usually represented by four bits which, in general, represent the
values/digits/characters 0-9. Other bit combinations are sometimes used for sign or other
indications. To BCD-encode a decimal number using the common encoding, each
decimal digit is stored in a four-bit nibble. Decimal: 0 1 2 3 4 5 6 7 8 9

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

Thus, the BCD encoding for the number 1 2 7


would be: 0001 0010 0111

C++ 5
Logic Design Dr. YOUSRA AHMED
Lec_3

 American Standard Code for Information Interchange (ASCII CODE)

C++ 6
Logic Design Dr. YOUSRA AHMED
Lec_3

The binary-coded decimal scheme described in this article is the most common encoding, but
there are many others. The method here can be referred to as Simple Binary-Coded Decimal
(SBCD) or BCD 8421. In the headers to the table, the '8 4 2 1' indicates the four bit weights;
note that in the 5th column two of the weights are negative. The following table represents
decimal digits from 0 to 9 in various BCD systems:

C++ 7
Logic Design Dr. YOUSRA AHMED
Lec_3

Gray Code
A Gray Code represents numbers using a binary encoding scheme that groups a sequence of
bits so that only one bit in the group changes from the number before and after. It is named for
Bell Labs researcher Frank Gray, who described it in his 1947 patent submittal on Pulse Code
Communication. A Gray Code is not weighted, the columns of bits do not reflect an implicit
base weight as the Binary number system does.

A comparison of the first ten numbers in Decimal, Binary and Gray Code is shown in Table 1.
Table 1. Decimal, Binary, Gray Code Numbers

Decimal (base 10) Binary (base 2) Binary-Reflected (no base)


0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111

C++ 8
Logic Design Dr. YOUSRA AHMED
Lec_3

To convert from gray to binary

From the above operation, finally we can get the binary values like
b3 = g3,
b2 = b3 XOR g2,
b1= b2 XOR g1,
b0 = b1 XOR g0.

C++ 9
Logic Design Dr. YOUSRA AHMED
Lec_3

To Convert from binary to Gray

From the above operation, finally we can get the binary values like
g3=b3
g2 = b3 XOR b2,
g1= b2 XOR b1,
g0 = b1 XOR b0.

C++ 11

You might also like