761.60K
Категория: ЭлектроникаЭлектроника

QQQ 2224. Lecture 4

1.

Arithmetic Operations and Circuits
Lecture 4
Digital Electronics

2.

Binary Arithmetic
important function of digital systems and
computers
◻ basic set of logic-circuit building blocks
◻ arithmetic operations follow a step-by-step
procedure to arrive at the correct answer
◻ four basic arithmetic functions:
◻ addition
◻ subtraction
◻ multiplication
◻ division

3.

Addition
adding numbers in binary
is similar as in decimal
◻ When binary sum
exceeds 1, carry 1 to the
next-more-significant
column

4.

Subtraction
R0 - difference
(remainder from
subtraction)
◻ Bout = 1, if borrow
required
◻ A0 must borrow from A1
next-more-significant
column

5.

Multiplication & Division
1.
2.
division uses the same procedure as decimal division
3.
4.
Multiply the 20 bit of the
multiplier times the
multiplicand
Multiply the 21 bit of the
multiplier times the
multiplicand. Shift the
result one position to the
left before writing it down
Repeat step 2 for other
bits of the multiplier
Take the sum of the four
partial products to get the
final product

6.

Two’s-Complement
Representation
both positive and negative numbers can be
represented using the same format
◻ binary subtraction is greatly simplified
◻ Most computer systems are based on 8-bit
(byte) or 16-bit (integer) numbers
◻ MSB of number used to signify whether the
number is positive or negative

7.

Steps for Decimal-to-Two’sComplement Conversion

If the decimal number is positive:
◻ two’s-complement number - binary equivalent of
the decimal number

If the decimal number is negative
◻ Complement each bit of the true binary equivalent
of the decimal number (one’s complement)
■ e.q. 1’s complement of 6 (for 8 bit binary) = 1111 1001
◻ Add 1 to the one’s-complement number to get the
magnitude bits
■ Representation of -6 in 2’s complement for 8 bit binary

8.

Steps for Two’s-Complement-toDecimal Conversion

If 2’s-complement number is positive (sign bit
= 0)
◻ regular binary-to-decimal conversion

If 2’s-complement number is negative (sign bit
= 1)
◻ decimal sign will be –
◻ Complement the entire 2’s-complement number
■ do a 1’s complement
◻ Add 1 to arrive at the true binary equivalent
◻ do a regular binary-to-decimal conversion to get
the decimal numeric value.

9.

Review Questions
In binary subtraction, the borrow-out of the
least significant column becomes the borrowin of the next-more-significant column. True
or false?
Which bit in an 8-bit two’s-complement
number is used as the sign bit?
Are the following two’s-complement numbers
positive or negative?
1.
2.
3.
a)
b)
c)
1010 0011
0010 1101
1000 0000

10.

Two’s-Complement Arithmetic

Implement all basic arithmetic functions (+,,*,/)
◻ involving positive and negative numbers

Subtraction – adding two 2’s-complement
numbers
◻ same digital circuitry used for additions &
subtractions

be careful not to exceed the maximum range
◻ +127…-128 for 8-bit systems
◻ +32767…-32768 for 16-bit systems
Note: The carry-out of the MSB is ignored. (It will always
occur for positive sums.) The 8-bit answer is 0000 1011.

11.

Octal Arithmetic
Octal Addition
Octal Subtraction
Add 2 octal digits
(working with decimal
equivalents)
◻ If decimal sum <8, write
down the octal
equivalent
◻ If decimal sum is >=8,
subtract 8, write down
hex result in that
column, and carry 1 to
the next-more-significant


similar to decimal
subtraction
◻ except when you
borrow 1 from the left,
it increases in value
by 8
◻ octal notation
simplifies
documentation and
use of equipment

12.

Hexadecimal Arithmetic
Hexadecimal Addition
Hexadecimal Subtraction
Add 2 hex digits
(working with decimal
equivalents)
◻ If decimal sum <16,
write down the hex
equivalent
◻ If decimal sum is >=16,
subtract 16, write down
hex result in that
column, and carry 1 to


similar to decimal
subtraction
◻ except when you
borrow 1 from the left, it
increases in value by
16
◻ hexadecimal notation
simplifies
documentation and use
of equipment

13.

BCD Arithmetic
Repeat steps below for each group of BCD bits
◻ Add BCD numbers as regular true binary numbers
◻ if the sum is <= 9 (1001)



it is a valid BCD answer; leave it as is
If the sum is > 9 or there is a carry-out of the MSB
it is an invalid BCD number
◻ add 6 (0110) to the result to make it valid
◻ any carry-out of the MSB is added to the next-more-significant
BCD number.

14.

Review Questions
1.
2.
3.
4.
Which of the following decimal numbers
cannot be converted to 8-bit two’scomplement notation?
(a) 89 (b) 135
(c) -107
(d) -144
The procedure for subtracting numbers in
two’s-complement notation is exactly the
same as for adding numbers. True or false?
When subtracting hex digits, if the least
significant digit borrows from its left, its value
increases by ___________?
What procedure is used to correct the result

15.

16.

a) 21 - 13
b) 54 118
English     Русский Правила