Exclusive-OR and Exclusive

Download Report

Transcript Exclusive-OR and Exclusive

Arithmetic Operations
and Circuits
Lecture 5
Binary Arithmetic
let’s look at the procedures for performing the four basic arithmetic functions: addition,
subtraction, multiplication, and division
Addition
The procedure for adding numbers in binary is similar to adding in decimal, except that
the binary sum is made up of only 1’s and 0’s. When the binary sum exceeds 1, you
must carry a 1 to the next-more-significant column, as in regular decimal addition
Addition
Subtraction
Subtraction
Multiplication
The procedure for the multiplication is as
follows:
1. Multiply the 20 bit of the multiplier times
the multiplicand.
2. Multiply the 21 bit of the multiplier times
the multiplicand. Shift the result one
position to the left before writing it down.
3. Repeat step 2 for the 22 bit of the multiplier. Because the 22 bit is a 0, the result
is 0.
4. Repeat step 2 for the 23 bit of the multiplier.
5. Repeating step 2 for the four leading 0’s in the multiplier will have no effect
on the answer, so don’t bother.
6. Take the sum of the four partial products to get the final product of 143 decimal.
(Written as an 8-bit number, the product is 1000 11112.)
Multiplication
Division
Two’s-Complement Representation
To be able to represent both positive and negative numbers, the two’s-complement format
uses the most significant bit (MSB) of the 8- or 16-bit number to signify whether the
number is positive or negative
The MSB is therefore called the sign bit and is defined as 0 for positive numbers and 1 for
negative numbers
The range of positive numbers in an 8-bit system is 0000 0000 to 0111 1111 (0
to 127). The range of negative numbers is 1111 1111 to 1000 0000 ( -1 to -128)
Two’s-Complement Representation
Two’s-Complement Representation
Two’s-Complement Arithmetic
All four of the basic arithmetic functions involving positive and negative numbers can be
dealt with very simply using two’s-complement arithmetic
Subtraction is done by adding the two two’s-complement numbers
Two’s-Complement Arithmetic
Hexadecimal Arithmetic
A method of representing groups of 4 bits as a single digit. Hexadecimal notation has been
widely adopted by manufacturers of computers and microprocessors because it simplifies
the documentation and use of their equipment.
Hexadecimal Arithmetic
Subtraction of hexadecimal numbers is similar to decimal subtraction, except that
when you borrow 1 from the left, the borrower increases in value by 16
BCD Arithmetic
Digital electronics naturally works in binary, and we have to group four binary digits
together to get enough combinations to represent the 10 different decimal digits. This 4bit code is called binary-coded decimal (BCD).
Arithmetic Circuits
All the arithmetic operations and procedures can be implemented using adders formed from
the basic logic gates. For a large number of digits we can use medium-scale-integration (MSI)
circuits, which actually have several adders within a single integrated package
Basic Adder Circuit
(a) Addition of two 2-bit binary numbers;
(b) truth table for the LSB addition;
(c) truth table for the more significant
column
Half-Adder
Full-Adder
Block Diagrams
We can simplify HA and FA representation by just drawing a box with the input and output
lines
Block diagram of a 4-bit binary adder.
Four-Bit Full-Adder ICs
Two’s-Complement Adder/Subtractor Circuit
Arithmetic/Logic Units
Arithmetic/logic units (ALUs) are available in large-scale IC packages (LSI).
The LSI circuits are generally considered to be ICs containing from 100 to 10,000 gate
equivalents.
Typically, an ALU is a multipurpose device capable of providing several different
arithmetic and logic operations.
The specific operation to be performed is chosen by theuser by placing a specific binary code
on the mode select inputs.
Microprocessors mayalso have ALUs built in as one of their many operational units. In such
cases, the specific operation to be performed is chosen by software instructions.
Once the mode control (M) is set, you have 16 choices within either the logic or arithmetic
categories.
The specific function you want is selected by applying the appropriate
binary code to the function select inputs (S3 to S0)
Arithmetic/Logic Units