Professional Documents
Culture Documents
Organization
Chapter 2
Lecture 1
The CPU
Chapter 2 – The CPU
✓In this chapter:
✓Review of computer arithmetic
✓Instruction sets
✓Processor structure and function
✓The control unit
✓RISC?
Computer Arithmetic
✓ Concerns:
✓ The way in which numbers are represented (binary format)
✓ Algorithms used for basic operations (add, subtract, multiply,
divide)
✓ Commonly performed on two different types of
numbers:
✓ Integer
✓ Floating point
The ALU
✓ALU:
✓Part of computer that performs arithmetic and logical
operations on data
✓All other components are there to serve ALU
✓Core of the computer
✓Based on simple digital logic devices that can store
binary digits and perform simple Boolean logic
operations
The ALU
✓How the ALU is interconnected:
✓Inputs and outputs
Control Flags
unit
ALU
Registers Registers
✓ Control unit:
✓ provides signals that control operation of ALU & movement
of data into and out of ALU
✓ Registers:
✓ present data to ALU and store results of operation
✓ Flags:
✓ set as a result of an operation E.g. if overflow happen
Integer Representation
✓ Binary number system: arbitrary number can be
represented by digits 0 & 1, sign, and point
E.g -1101.01012 = -13.312510
✓ For storage and processing,
✓Only 0 & 1 used to represent numbers
✓ E.g. 8 bit word for non-negative integers:
✓00000000 = 0
✓00000001 = 1
✓00101001 = 41
✓11111111 = 255
Integer Representation
✓ In general, if n bit sequence of binary digits
an-1an-2 … a1a0 is interpreted as unsigned integer A, its
value is:
n −1
A = 2 ai i
i =0
✓Drawbacks:
✓Signs and magnitudes should be considered in
addition and subtraction
✓Two representations of 0:
✓+010 = 00000000
✓-010 = 10000000
✓Which is difficult to test for 0
✓Because of these drawbacks, it is rarely used
Integer Representation
✓Subtraction rule:
✓To subtract one number (subtrahend) from another
(minuend), take the twos complement (negation)
of the subtrahend and add it to the minuend.
Addition and Subtraction
0010 = 2 0101 = 5
✓Examples: +1001 = -7
1011 = -5
+1110 = -2
0011 = 3
B Register A Register
Complementer
SW
OF Adder
Multiplication
✓ Complex operation (both in HW and SW)
✓ Wide variety of algorithms have been used
✓ Unsigned integers:
✓Successive shift and add :– generate partial
products one for each digit in multiplier
✓E.g. Multiplication of unsigned binary integers
1011 multiplicand (11)
x 1101 multiplier (12)
1011
0000
1011 partial products
1011
10001111 product (143)
Multiplication
✓Partial products: when multiplier bit = 0,
pp=0; when 1, pp = multiplicand
✓Total product is produced by summing pps
✓Multiplication of two n-bit binary integers
results in a product up to 2n bits in length
Multiplication
✓Hardware implementation
Flowchart
Example
Generally
✓ The operation of the multiplier is as follows.
✓ Control logic reads the bits of the multiplier one at a time.
If is 1, then the multiplicand is added to the A register
and the result is stored in the A register, with the C bit used
for overflow.
✓ Then all of the bits of the C, A, and Q registers are shifted
to the right one bit, so that the C bit goes into goes into and
is lost. If is 0, then no addition is performed, just the shift.
✓ This process is repeated for each bit of the original
multiplier.
✓ The resulting -bit product is contained in the A and Q
registers.
Reading Assignment
✓Multiplication: two’s compliment
multiplication
✓Text:- page 319
✓Division:
✓Floating point