SlideShare a Scribd company logo
1 of 101
Computer System Architecture
Chapter -1
Department of Computer Science and Engineering
Mr. Ashutosh Kumar
Research Scholar
Department of Computer Science and Engineering
National Institute of Technology Raipur
Outline
CPU Organization & Functionality
 CPU Organization
 Fundamental and features
 Data Representation
– Basic Formats
– Fixed and Floating Representation
– Instruction Set
– Instruction Format
– Type and Programming Consideration
– Addressing Mode
• Fixed –Point Arithmetic Multiplication Algorithm
• Hardware Algorithm
• Booth Multiplication Algorithm
Structure of the computer
Main
memory
I/O
CPU
COMPUTER
System
Bus
ALU
Registers
Control
Unit
CPU
Internal
Bus
Control Unit
Registers and
Decoders
CONTROL
UNIT
Sequencing
Logic
Contr ol
Memory
Structure of the computer
There are four main structural components of the computer:
 CPU – controls the operation of the computer and
performs its data processing functions
 Main Memory – stores data
 I/O – moves data between the computer and its
external environment
 System Interconnection – some mechanism that
provides for communication among CPU, main
memory, and I/O
CPU (Central Processing Unit)
 Control Unit
Controls the operation of the CPU and hence the
computer
 Arithmetic and Logic Unit (ALU)
Performs the computer’s data processing function
 Registers
Provide storage internal to the CPU
 CPU Interconnection
Some mechanism that provides for communication
among the control unit, ALU, and registers
4 channel
DDR-4
RAM
Memory
Interfaces
Expendable
upto
capacity
Processor
Placing or
Interface
(Intel/AMD)
Serial ATA/SATA
Interface
CMOS
Battery
Ethernet
Connector
VGA Port
USB 2.0
Port
I/O Headphone or Mic
Jack
Super I/O PCI
Express
PCI
Interface
AGP
Slot
Major Component of Multicore
computer
History of Computers
First Generation: Vacuum Tubes
• Vacuum tubes were used for digital logic elements and memory
• IAS computer
– Fundamental design approach was the stored program concept
• Attributed to the mathematician John von Neumann
• First publication of the idea was in 1945 for the EDVAC
– Design began at the Princeton Institute for Advanced Studies
– Completed in 1952
– Prototype of all subsequent general-purpose computers
Second Generation: Transistors
 Smaller
 Cheaper
 Dissipates less heat than a vacuum tube
 Is a solid state device made from silicon
 Was invented at Bell Labs in 1947
 It was not until the late 1950’s that fully transistorized
computers were commercially available
Computer Generations
Generation
Approximate
Dates Technology
Typical Speed
(operations per second)
1 1946–1957 Vacuum tube 40,000
2 1957–1964 Transistor 200,000
3 1965–1971 Small and medium scale
integration
1,000,000
4 1972–1977 Large scale integration 10,000,000
5 1978–1991 Very large scale integration 100,000,000
6 1991- Ultra large scale integration >1,000,000,000
Second Generation Computers
• Introduced:
More complex arithmetic and logic units and control
units
The use of high-level programming languages
Provision of system software which provided the
ability to:
• Load programs
• Move data to peripherals
• Libraries perform common computations
Third Generation: Integrated
Circuits
1958 – the invention of the integrated circuit
Discrete component
– Single, self-contained transistor
– Manufactured separately, packaged in their own
containers, and soldered or wired together onto
masonite-like circuit boards
– Manufacturing process was expensive and
cumbersome
– The two most important members of the third generation were the IBM
System/360 and the DEC PDP-8
Integrated Circuits
 Data storage – provided by
memory cells
 Data processing – provided by
gates
 Data movement – the paths
among components are used to
move data from memory to
memory and from memory
through gates to memory
 Control – the paths among
components can carry control
signals
 A computer consists of gates,
memory cells, and
interconnections among these
elements
 The gates and memory cells
are constructed of simple
digital electronic components
 Exploits the fact that such
components as transistors,
resistors, and conductors can
be fabricated from a
semiconductor such as silicon
 Many transistors can be
produced at the same time on
a single wafer of silicon
 Transistors can be connected
with a processor metallization
to form circuits
Later Generations
LSI
Large
Scale
Integration
VLSI
Very Large
Scale
Integration
ULSI
Ultra Large
Scale
Integration
Semiconductor Memory
Microprocessors
Evolution of Intel Microprocessors
4004 8008 8080 8086 8088
Introduced 1971 1972 1974 1978 1979
Clock speeds 108 kHz 108 kHz 2 MHz
5 MHz, 8 MHz, 10
MHz
5 MHz, 8 MHz
Bus width 4 bits 8 bits 8 bits 16 bits 8 bits
Number of
transistors
2,300 3,500 6,000 29,000 29,000
Feature size
(µm)
10 8 6 3 6
Addressable
memory
640 Bytes 16 KB 64 KB 1 MB 1 MB
(a) 1970s Processors
Evolution of Intel Microprocessors
(b) 1980s Processors
80286 386TM DX 386TM SX 486TM DX
CPU
Introduced 1982 1985 1988 1989
Clock speeds 6 MHz - 12.5
MHz
16 MHz - 33
MHz
16 MHz - 33
MHz
25 MHz - 50
MHz
Bus width 16 bits 32 bits 16 bits 32 bits
Number of transistors
134,000 275,000 275,000 1.2 million
Feature size (µm) 1.5 1 1 0.8 - 1
Addressable
memory
16 MB 4 GB 16 MB 4 GB
Virtual
memory
1 GB 64 TB 64 TB 64 TB
Cache — — — 8 kB
Evolution of Intel Microprocessors
(c) 1990s Processors
486TM SX Pentium Pentium Pro Pentium II
Introduced 1991 1993 1995 1997
Clock speeds 16 MHz - 33
MHz
60 MHz - 166
MHz,
150 MHz - 200
MHz
200 MHz - 300
MHz
Bus width 32 bits 32 bits 64 bits 64 bits
Number of
transistors
1.185 million 3.1 million 5.5 million 7.5 million
Feature size (µm) 1 0.8 0.6 0.35
Addressable
memory
4 GB 4 GB 64 GB 64 GB
Virtual memory 64 TB 64 TB 64 TB 64 TB
Cache 8 kB 8 kB
512 kB L1 and 1
MB L2
512 kB L2
Evolution of Intel Microprocessors
(d) Recent Processors
Pentium III Pentium 4
Core 2 Duo Core i7 EE
4960X
Introduced 1999 2000 2006 2013
Clock speeds 450 - 660 MHz 1.3 - 1.8 GHz 1.06 - 1.2 GHz 4 GHz
Bus
wid
th
64 bits 64 bits 64 bits 64 bits
Number of
transistors
9.5 million 42 million 167 million 1.86 billion
Feature size (nm) 250 180 65 22
Addressable
memory
64 GB 64 GB 64 GB 64 GB
Virtual memory 64 TB 64 TB 64 TB 64 TB
Cache 512 kB L2 256 kB L2 2 MB L2 1.5 MB L2/15
MB L3
Number of cores 1 1 2 6
Data Representation in Computers
 Data are stored in Registers
 Registers are limited in number & size
 With a n-bit register
 Min value 0
 Max value 2n-1
n-1 n-2 … ... ... 2 1 0
n-bits
Data Representation
Data
Representation
Qualitative
• Represents quality or
characteristics
• Not proportional to a
value
• Name, NIC no, index no,
Address
Quantitative
• Quantifiable
• Proportional to value α
• No of students, marks for
CS2052, GPA
Data Representation (Cont.)
Data
Signed
Integers
Unsigned
Quantitative
Non-
integers
Signed
Unsigned
Qualitative
Number Systems
 Decimal number system
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 Binary number system
0, 1
 Octal number system
0, 1, 2, 3, 4, 5, 6, 7
 Hexadecimal number system
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Quantitative Numbers
 Integers
 Unsigned
 Signed
 Non-integers
20
+20, -20
 Floating point numbers - 10.25, 3.33333…, 1/8 = 0.125
Signed Integers
 We need a way to represent negative values
 3 representations
 Sign & Magnitude representation (S&M)
 Complement method
 Bias notation or Excess notation
1. Sign & Magnitude Representation
sign n-1 n-2 ... ... 2 1 0
Magnitude (n-bits)
 n-bit unsigned magnitude & sign bit (S)
 If S
 0 – Integer is positive or zero
 1 – Integer is negative or zero
 Range –(2n-1) to +(2n-1)
Example – Sign & Magnitude
 If 8-bit register is used what are min & max numbers?
 What are 0000 0000 and 1000 0000 in decimal?
 Representation of zero is not unique
Sign & Magnitude (Cont.)
 Advantages
 Sign reversal
 Finding absolute value |a|
 Flip sign bit
 Disadvantage
 Adding a negative of a number is not the same as subtraction
 e.g., add 2 and -3
 Need different operations
 Zero is not unique
Complement Method
 Base = Radix
 Radix r system means r number of symbols
 e.g., binary numbers have symbols 0, 1
 2 types
 r’s complement
 (r – 1)’s complement
 Where r is radix (base) of number system
 Examples
 Decimal
 Binary
9’s & 10’s complement 1’s &
2’s complement
Complement Method – Definition
 Given a number m in base/radix r & having n digits
 (r – 1)’s complement of m is
(rn – 1) – m
 r ’s complement of n is
(rn – 1) – m + 1 = rn – m
Example – Complement Method
 If m = 5982 & n = 4 digits
 9’s complement is
9 9 9 9
5 9 8 2 –
4 0 1 7
- maximum representable no
 10’s complement 9 9
9 9
5 9 8 2 –
4 0 1 7
1 +
4 0 1 8
or
1 0 0 0 0
5 9 8 2 –
4 0 1 8
Example – Complement Method
 If m = 382 & n = 3
 -n = -382 = 9 9 9 9 9 9
3 8 2 – 3 8 2 -
6 1 7 6 1 7
1 +
6 1 8
 -382 = 617 or 618
 Depending on which complement we use
 These are called complementary pair
1’s complement
 Calculated by
 (2n – 1) – m
 If m = 0101
 1’s complement of m on a 4-bit system 1 1 1 1
0 1 0 1 –
1 0 1 0
 This represents -5 in 1’s complement
Finding 1’s Complement – Short Cut
 Invert each bit of m
 Example
 m = 0 0 1 0 1 0 1 1
 1’s complement of m = 1 1 0 1 0 1 0 0
 m = 0 0 0 0 0 0 0 0 = 0
 1’s complement of m = 1 1 1 1 1 1 1 1 = -0
 Values range from -127 to +127
Addition with 1’s Complement
 If results has a carry add it to LSB (Least Significant Bit)
 Example
 Add 6 and -3 on a 3-bit system
 6 = 1 1 0
 -3 = 1 0 0 +
= 1 0 1 0
1 +
0 1 1
2’s Complement
 Doesn’t require end-around carry operation as in 1’s complement
 2’s complement is formed by
 Finding 1’s complement
 Add 1 to LSB
 New range is from -128 to +127
 -128 because of +1 to negative value
Example – 2’s Complement
 Find 2’s complement of 0101011
 m = 0 1 0 1 0 1 1
= 1 0 1 0 1 0 0
1 +
= 1 0 1 0 1 0 1
 2’s
 Short-cut
1. Search for the 1st bit with value 1 starting fromLSB
2. Inver all bits after 1st one
Example – 2’s Complement (Cont.)
 Add 6 and -5 on a 4-bit system 5 =
0101
-5 = 1011
6 = 0 1 1 0
-5 = 1 0 1 1+
1 0 0 0 1  0 0 0 1
Discard
1’s vs. 2’s Complement
 1’s complement has 2 zeros (+0, -0)
 Value range is less than 2’s complement
 2’s complement only has a single zero
 Value range is unequal
 No need of a separate subtract circuit
Doing a NOT operation is much more cost effective interms of
circuit design
 However, multiplication & division is slow
Fixed-Point Representation
old position 7 6 5 4 3 2 1 0
New position 4 3 2 1 0 -1 -2 -3
Bit pattern 1 0 0 1 1 . 1 0 1
Contribution 24 21 20 2-1 2-3 =19.625
Radix-point
Limitation of Fixed-Point
Representation
 To represent large numbers or very small numbers we need a very long
sequences of bits.
 This is because we have to give bits to both the integer part and the fraction
part.
Floating Point Numbers
 We needed to represent fractional values & values beyond 2n – 1
 +3207.23
 -0.000321
= 3.20723x103
=-3.21x10-4
Sign
Mantissa
Radix
(base)
Exponent
Floating Point Numbers (Cont.)
Sign
Radix
Mantissa
Exponent
sign en-1 … ... e0 mn-1 mn-2 … … m1 m0
Mantissa
Exponent
N  (1)s
m.2e
IEEE Floating Point Standard
(Cont.)
s31 e30 … ... e23 m22 mn-2 … … m1 m0
Exponent Mantissa
N  (1)s
[1.m]2E 127
 E – 127 = e
 E = e + 127
 What is stored is E
IEEE Floating Point Standard
(FPS)
 2 standards
1. Single precision
 32-bits
 23-bit mantissa
 8-bit exponent
 1-bit sign
2. Double precision
 64-bits
 52-bit mantissa
 11-bit exponent
 1-bit sign
S Exponent Mantissa (bits 0-22)
31 30 23 22 0
S Exponent Mantissa (bits 0-51)
63 62 52 51 0
Instruction Set 8086
Microprocessor
Theinstructionsetare categorizedinto the following types:
 Data transferinstructions
 Arithmetic instructions
 Logicalinstructions
 Flag manipulation instructions
 shiftand rotate instructions
 Stringinstructions
 8086 assemblerdirectives
Data Transfer Instruction
 MOV-
Move byte orword to registerormemory
 IN, OUT-
Input byte orword from port, output word toport
 LEA-
Load effective address
 LDS,LES-
Load pointer usingdata segment,extra segment
 PUSH,POP-
Pushword onto stack, pop word off stack
 XCHG-
Exchangebyte orword
 XLAT-
Translate byte usinglook-up table
Arithmetic Instruction
ADD – ADD Destination, Source
ADC – ADC Destination, Source
These instructions add a number from some source to a number in
some destination and put the result in the specified destination.
SUB – SUB Destination, Source
SBB – SBB Destination, Source
These instructions subtract the number in some source from the
number in some destination and put the result in the destination.
The SBB instruction also subtracts the content of carry flag from the
destination.
INC – INC Destination
The INC instruction adds 1 to a specified register or to a memory
location. AF, OF, PF, SF, and ZF are updated, but CF is not affected.
Arithmetic Instruction
MUL – MUL Source
This instruction multiplies an unsigned byte in some source with an
unsigned byte in AL register or an unsigned word in some source with
an unsigned word in AX register.
IMUL – IMUL Source
This instruction multiplies a signed byte from source with a signed
byte in AL or a signed word from some source with a signed word in
AX .
DIV – DIV Source
This instruction is used to divide an unsigned word by a byte or to
divide an unsigned double word (32 bits) by a word.
IDIV – IDIV Source
This instruction is used to divide a signed word by a signed byte, or to
divide a signed double word by a signed word.
Arithmetic Instruction
 DEC – DEC Destination
This instruction subtracts 1 from the destination word or byte.
 DAA (DECIMALADJUST AFTER BCD ADDITION)
This instruction is used to make sure the result of adding two packed BCD
numbers is adjusted to be a legal BCD number .
 DAS (DECIMALADJUST AFTER BCD SUBTRACTION)
This instruction is used after subtracting one packed BCD number from
another packed BCD number, to make sure the result is correct packed
BCD.
 CBW (CONVERT SIGNED BYTE TO SIGNED WORD)
This instruction copies the sign bit of the byte in AL to all the bits in AH.
AH is then said to be the sign extension of AL. CBW does not affect any
flag.
 CWD (CONVERT SIGNED WORD TO SIGNED DOUBLE WORD)
This instruction copies the sign bit of a word in AX to all the bits of the DX
register. In other words, it extends the sign of AX into all of DX. CWD
affects no flags.
Arithmetic Instruction
AAA (ASCII ADJUST FOR ADDITION)
Numerical data coming into a computer from a terminal is usually in
ASCII code.
AAS (ASCII ADJUST FOR SUBTRACTION)
Numerical data coming into a computer from a terminal is usually in
an ASCII code.
AAM (BCD ADJUST AFTER MULTIPLY)
Before you can multiply two ASCII digits, you must first mask the
upper 4 bit of each. This leaves unpacked BCD (one BCD digit per
byte) in each byte.
AAD (BCD-TO-BINARY CONVERT BEFORE DIVISION)
AAD converts two unpacked BCD digits in AH and AL to the
equivalent binary number in AL.
Logical Instruction
 AND – AND Destination, Source
This instruction ANDs each bit in a source byte or word with the same
numbered bit in a destination byte or word.
 OR – OR Destination, Source
This instruction ORs each bit in a source byte or word with the same
numbered bit in a destination byte or word.
 XOR – XOR Destination, Source
This instruction Exclusive-ORs each bit in a source byte or word with the
same numbered bit in a destination byte or word.
 NOT – NOT Destination
The NOT instruction inverts each bit (forms the 1’s complement) of a
byte or word in the specified destination.
Logical Instruction
 NEG – NEG Destination
This instruction replaces the number in a destination with its 2’s
complement.
 CMP – CMP Destination, Source
This instruction compares a byte / word in the specified source with a byte /
word in the specified destination.
 TEST – TEST Destination, Source
This instruction ANDs the byte / word in the specified source with the byte /
word in the specified destination.
FLAG MANIPULATION
Instruction
 STC:
It sets the carry flag to 1.
 CLC:
It clears the carry flag to 0.
 CMC:
It complements the carry flag
 STD:
It sets the direction flag to 1. If it is set, string bytes are
accessed from higher memory address to lower memory
address.
 CLD:
It clears the direction flag to 0. If it is reset, the string bytes
are accessed from lower memory address to higher memory
address.
Instruction Format
 An instruction format or instruction code is a group of bits used to
perform a particular operation on the data stored in computer.
 Processor fetches an instruction from memory and decodes
the bits to execute the instruction.
 Different computer may have their own instruction set .
 The operation of the processor is determined by the instructions
it executes, referred to as machine instructions or computer
instructions
 The collection of different instructions that the processor can
execute is referred to as the processor’s instruction set
 Each instruction must contain the information required by the
processor for execution
Instruction Cycle State Diagram
Source and result operands can be in
one of four areas:
1) Main memory or virtual memory
 As with next instruction references, the main or virtualmemory
address must be supplied.
2) I/O devices
 The instruction must specify the I/O module and device for the operation. If
memory-mapped I/O is used, this is just another main or virtual memory address.
3) Processor register
 A processor contains one or more registers that may be referenced by machine
instructions.
 If more than one register exists each register is assigned a unique name or
number and the instruction must contain the number of the desired register
4) Immediate
 The value of the operand is contained in a field in the instruction being
executed
Types of Operand
 Addresses: immediate, direct, indirect, stack
Numbers: integer or fixed point (binary, twos complement),
floating point (sign, exponent), (packed) decimal
(246 = 0000 0010 0100 0110)
Characters: ASCII (128 printable and control characters + bit
for error detection)
 Logical Data: bits or flags, e.g., Boolean 0 and 1
Instruction Representation
Within the computer each instruction is represented by a sequence of bits
The instruction is divided into fields, corresponding to the constituent
elements of the instruction
Instruction Types
A computer should have a set of instructions that allows the userto formulate any
data processing task.. Any program written in a high- level language must be
translated into machine language to be executed, so we can categorize instruction
types as follows:
Data processing: Arithmetic instructions providecomputational capabilities
for processing numeric data
 Data storage: Movement of data into or out of register and or
memory locations
Data movement :I /O instructions are needed to transfer programs and data into
memory and the results of computations back outto the user
 Control: test instruction test the value of a data word or the statusof
a computation
Branch instruction used to branch to a different set of instructions depending on
the decision made
Instruction Formats
 Layout of bits in an instruction
 Includes opcode
 Includes (implicit or explicit) operand(s)
 Usually more than one instruction format in an instruction set
Instruction Length
Affected by and affects:
 Memory size
 Memory organization - addressing
 Bus structure, e.g., width
 CPU complexity
 CPU speed
Trade off between powerful instruction repertoire and saving space
Allocation of Bits
Number of addressing modes: implicit or additional bits specifying it
 Number of operands
 Register (faster, limited size and number, 32) versus memory
 Number of register sets, e.g., data and address (shorter addresses)
 Address range
 Address granularity (e.g., by byte)
 Number ofAddresses
 More addresses
1 More complex instructions
2More registers - inter-register operations are quicker 3-Less instructions per
program
 Fewer addresses
1 Less complex instructions
2More instructions per program, e.g. data movement 3-Faster fetch/execution
of instructions
Pentium Instruction Format
Pentium uses a variable length instruction format.
The Pentium instruction can be from 2 to 16 byteslong.
The Instruction is broken down into 6 sections
1-Instruction Prefixes
2-Opcode
3-Mod R/M
4 SIB
5Displacement 6-
Immediate
Instruction Prefixes
2 .Opcode
Instruction Prefix:used in multiprocessor
enviroments, specifically with strings
Segment Override: This specifies which
segment-register to use, if not the default.
Operand Size: The operand size can be either 16
or 32 bits, this specifies whichis being used.
Address Size: The Pentium can use a 16 or 32
bit address, this specifies which is being used.
The opcode can be either one or two bytes.
The opcode can also specify if the data is 16 or 32
bit.
The opcode specifies which way the data is going
(to or from memory).
The opcode specifies if an immediate value is
signed or not.
Addressing Modes
 Immediate
 Direct
 Indirect
 Register
 Register Indirect
 Displacement (Indexed)
 Stack
Immediate Addressing
 Operand is part of instruction
 Operand = address field
 e.g. ADD 5
—Add 5 to contents of accumulator
—5 is operand
 No memory reference to fetch data
 Fast
 Limited range
Immediate Addressing Diagram
Operand
Opcode
Instruction
Direct Addressing
 Address field contains address of operand
 Effective address (EA) = address field (A)
 e.g. ADD A
—Add contents of cell A to accumulator
—Look in memory at address A for operand
 Single memory reference to access data
 No additional calculations to work out effective address
 Limited address space
Direct Addressing Diagram
AddressA
Opcode
Instruction
Memory
Operand
Indirect Addressing (1)
 Memory cell pointed to by address field contains the address of
(pointer to) the operand
 EA = (A)
—Look in A, find address (A) and look there for operand
 e.g. ADD (A)
—Add contents of cell pointed to by contents of A to accumulator
Indirect Addressing (2)
 Large address space
 2n where n = wordlength
 May be nested, multilevel, cascaded
—e.g. EA = (((A)))
– Draw the diagramyourself
 Multiple memory accesses to find operand
 Hence slower
Indirect Addressing Diagram
AddressA
Opcode
Instruction
Memory
Pointer to operand
Operand
Register Addressing (1)
 Operand is held in register named in address filed
 EA = R
 Limited number of registers
 Very small address field needed
—Shorter instructions
—Faster instruction fetch
Register Addressing (2)
 No memory access
 Very fast execution
 Very limited address space
 Multiple registers helps performance
—Requires good assembly programming or compiler writing
—N.B. C programming
– register inta;
 c.f. Direct addressing
Register Addressing Diagram
Register Address R
Opcode
Instruction
Registers
Operand
Register Indirect Addressing
 C.f. indirect addressing
 EA = (R)
 Operand is in memory cell pointed to by contents of register R
 Large address space (2n)
 One fewer memory access than indirect addressing
Register Indirect Addressing Diagram
Opcode Register Address R
Memory
Operand
Pointer to Operand
Registers
Instruction
Displacement Addressing
 EA = A + (R)
 Address field hold two values
—A = base value
—R = register that holds displacement
—or vice versa
Displacement Addressing Diagram
Instruction
Memory
Operand
Pointer to Operand
Registers
Opcode Register R AddressA
+
Relative Addressing
 A version of displacement addressing
 R = Program counter, PC
 EA = A + (PC)
 i.e. get operand from A cells from current location pointed to by PC
 c.f locality of reference & cache usage
Base-Register Addressing
 A holds displacement
 R holds pointer to base address
 R may be explicit or implicit
 e.g. segment registers in 80x86
Indexed Addressing
 A = base
 R = displacement
 EA = A + R
 Good for accessing arrays
—EA = A + R
—R++
Combinations
 Postindex
 EA = (A) + (R)
 Preindex
 EA = (A+(R))
 (Draw the diagrams)
Stack Addressing
Operand is (implicitly) on top of stack
e.g.
—ADD
Pop top two items from stack
and add
Multiplication Algorithm Hardware
and Flowchart
Multiplication (often denoted by x) is the mathematical operation
of scaling one number by another. It is a basic arithmetic
operation.
Example: 3 x 4= 3+3+3+3=12
5 x 3 ½ =5+5+5+(half of 5)= 17.5
The basic idea of multiplication is repeated addition.
Multiplication
Paper and pencil example (unsigned):
Multiplicand
Multiplier
Product
1000
1001
1000
0000
0000
1000
01001000
m bits x n bits = m+n bit product
Binary makes it easy:
0 => place 0
1 => place a copy
( 0 x multiplicand)
( 1 x multiplicand)
Place a copy
Place 0
Multiply
64-bit Multiplicand reg, 64-bit ALU, 64-bit Productreg, 32-bit
multiplier reg
Multiplier
64-bitALU
Shift Left
Shift Right
Write
Control
32 bits
Multiplicand
64 bits
Product
64 bits
Unsigned Shift-add Multiplier
Yes: 32 repetitions
Done
No: < 32 repetitions
32nd
repetition?
Start
Multiplier0 = 1 1. Test Multiplier0 = 0
Multiplier0
1a. Add multiplicand to product &
place the result in Product register
Product Multiplier Multiplicand
0000 0000 0011 0000 0010 2. Shift the Multiplicand register left 1 bit.
0000 0010 0001 0000 0100
0000 0110 0000 0000 1000 3. Shift the Multiplier register right 1 bit.
0000 0110
Multiply Algorithm
Flowchart Version 1
Half of the shifted multiplicand register contains 0. Why not
shift the product right?
32-bit Multiplicand reg, 32 -bit ALU, 64-bit Product reg, 32-bit
Multiplier reg
Product
Multiplier
Multiplican
d
32-bitALU
Shift Right
Write
Control
32 bits
32 bits
64 bits
Shift Right
Multiply Hardware Version
Yes: 32 repetitions
Done
2. Shift the Product register right 1 bit.
3. Shift the Multiplier register right 1 bit.
No: < 32 repetitions
1. Test
Multiplier0
Multiplier0 = 0
Multiplier0 = 1
1a. Add multiplicand to the left half of product & place the result in
the left half of Product register
32nd
repetition?
Start
° Product Multiplier
0000 0000 0011
Multiplicand
0010
Multiply Algorithm
Flowchart Version 2
Product
0000 0000
Multiplier Multiplicand
0011 0010
00100000
00010000 0001 0010
00110000 0001 0010
00011000 0000 0010
00001100 0000 0010
00000110 0000 0010 Yes: 32 repetitions
Done
2. Shift the Product register right 1 bit.
3. Shift the Multiplier register right 1 bit.
No: < 32 repetitions
1. Test
Multiplier0
Multiplier0 = 0
Multiplier0 = 1
1a. Add multiplicand to the left half of product & place the result in
the left half of Product register
32nd
repetition?
Start
Multiply Algorithm
Flowchart Version 2
Combine Multiplier register and Product register
32-bit Multiplicand reg, 32 -bit ALU, 64-bit Product reg, (0-
bit Multiplier reg)
Multiplican
d
32-bitALU
Write
Control
32 bits
Product (Multiplier)
64 bits
Shift Right
Multiply Algorithm Version 3
Multiplicand
0010
Product
0000 0011
Yes: 32 repetitions
Done
2. Shift the Product register right 1 bit.
No: < 32 repetitions
1. Test
Product0
Product0 = 0
Product0 = 1
1a. Add multiplicand to the left half of product & place the result in
the left half of Product register
32nd
repetition?
Start
Missing Multiplier
Multiply Algorithm
Flowchart Version 3
Mcand:0010 P:00000011
1 P=P+Mcand Mcand:0010 P:00100011
ShrP Mcand:0010 P:00010001
2 P=P+Mcand Mcand:0010 P:00110001
ShrP Mcand:0010 P:00011000
3 0=>nop Mcand:0010 P:00011000
ShrP Mcand:0010 P:00001100
4 0=>nop Mcand:0010 P:00001100
ShrP Mcand:0010 P:00000110
Booth algorithm gives a procedure for multiplying binary integers in signed – 2’s complement
representation.
I will illustrate the booth algorithm with the following example: Example, 2 x (-4)
0010 * 1100
Step 1: Making the Booth table
1. From the two numbers, pick the number with the smallest difference between a series of
consecutive numbers, and make it a multiplier.
i.e., 0010 -- From 0 to 0 no change, 0 to 1 one change, 1 to 0 another
change ,so there are two changes on this one
1100 -- From 1 to 1 no change, 1 to 0 one change, 0 to 0 no change, so there is only one
change on this one.
Therefore, multiplication of 2 x (– 4), where 2 ten (0010 two) is the
multiplicand and (– 4) ten (1100two) is the multiplier.
Booth Multiplication Algorithm
2. Let X = 1100 (multiplier)
Let Y = 0010 (multiplicand)
Take the 2’s complement of Y and call it –Y
–Y = 1110
3. Load the X value in the table.
4. Load 0 for X-1 value it should be the previous first least significant bit of X
5.Load 0 in U and V rows which will have the product of X and Y at the end of
operation.
6.Make four rows for each cycle; this is because we are multiplying four bits
numbers.
Booth Multiplication Algorithm
Step 2: BoothAlgorithm
Look at the first least significant bits of the multiplier “X”, and the
previous least significant bits of the multiplier “X - 1”.
a.
1 0 Shift only
2 1 Shift only.
3 1 Add Y to U, and shift
4 0 Subtract Y from U, and shift or add (-Y) to U
and shift
b. Take U & V together and shift arithmetic right shift which preserves the
sign bit of 2’s complement number. Thus a positive number remains positive,
and a negative number remains negative.
c. Shift X circular right shift because this will prevent us from using two
registers for
the X value.
Booth Multiplication Algorithm
Booth Multiplication Algorithm
We have finished four cycles, so the answer is shown, in the last rows of U
and V which is: 11111000
Now to easily check our calculations, we take the original question, 2 x -4.
This becomes -8. -8 is the two's compliment of 8. 8 in eight bit binary is
00001000.
Taking the two's compliment by the method previously described, we get the
result 11111000, which is exactly the same as our Booths algorithm answer.
Booth Multiplication Algorithm
Thank you ... 

More Related Content

What's hot

Digital signal processing
Digital signal processingDigital signal processing
Digital signal processingPrabhu R
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085ShivamSood22
 
Addressing modes of 8051
Addressing modes  of 8051Addressing modes  of 8051
Addressing modes of 8051Bharath Reddy
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-busAnuj Modi
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer languageSanjeev Patel
 
Data manipulation instructions
Data manipulation instructionsData manipulation instructions
Data manipulation instructionsMahesh Kumar Attri
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer ArchitectureHaris456
 
8085 instructions and addressing modes
8085 instructions and addressing modes8085 instructions and addressing modes
8085 instructions and addressing modesSuchismita Paul
 
Addressing modes
Addressing modesAddressing modes
Addressing modesMukta Garg
 
Addressing modes of 8085
Addressing modes of 8085Addressing modes of 8085
Addressing modes of 8085Gaurav Solanki
 
Computer Organisation - Addressing Modes
Computer Organisation - Addressing ModesComputer Organisation - Addressing Modes
Computer Organisation - Addressing ModesArunaDevi63
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)Mahesh Kumar Attri
 

What's hot (18)

Digital signal processing
Digital signal processingDigital signal processing
Digital signal processing
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
Addressing modes of 8051
Addressing modes  of 8051Addressing modes  of 8051
Addressing modes of 8051
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-bus
 
Various type of register
Various type of registerVarious type of register
Various type of register
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
 
addressing modes
addressing modesaddressing modes
addressing modes
 
Data manipulation instructions
Data manipulation instructionsData manipulation instructions
Data manipulation instructions
 
Instruction.pdf
Instruction.pdfInstruction.pdf
Instruction.pdf
 
Instruction codes
Instruction codesInstruction codes
Instruction codes
 
Lecture 3 instruction set
Lecture 3  instruction setLecture 3  instruction set
Lecture 3 instruction set
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer Architecture
 
8085 instructions and addressing modes
8085 instructions and addressing modes8085 instructions and addressing modes
8085 instructions and addressing modes
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Addressing modes of 8085
Addressing modes of 8085Addressing modes of 8085
Addressing modes of 8085
 
Computer Organisation - Addressing Modes
Computer Organisation - Addressing ModesComputer Organisation - Addressing Modes
Computer Organisation - Addressing Modes
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)
 

Similar to CPU Architecture & Data Representation

Lec-1-2-27102021-122208am.pptx for embedded design
Lec-1-2-27102021-122208am.pptx for embedded designLec-1-2-27102021-122208am.pptx for embedded design
Lec-1-2-27102021-122208am.pptx for embedded designArsalanLatif5
 
Sqlmaterial 120414024230-phpapp01
Sqlmaterial 120414024230-phpapp01Sqlmaterial 120414024230-phpapp01
Sqlmaterial 120414024230-phpapp01Lalit009kumar
 
Kaizen cso002 l1
Kaizen cso002 l1Kaizen cso002 l1
Kaizen cso002 l1asslang
 
Instruction set.pptx
Instruction set.pptxInstruction set.pptx
Instruction set.pptxssuser000e54
 
Introduction to Computer Architecture and Organization
Introduction to Computer Architecture and OrganizationIntroduction to Computer Architecture and Organization
Introduction to Computer Architecture and OrganizationDr. Balaji Ganesh Rajagopal
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)Alveena Saleem
 
Module 1-ppt System programming
Module 1-ppt System programmingModule 1-ppt System programming
Module 1-ppt System programmingvishnu sankar
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
 
Ch12- instruction sets- char & funct.pdf
Ch12- instruction sets- char & funct.pdfCh12- instruction sets- char & funct.pdf
Ch12- instruction sets- char & funct.pdfsaimawarsi
 
COA Chapter 1.pdf
COA Chapter 1.pdfCOA Chapter 1.pdf
COA Chapter 1.pdfAbelAteme
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsSher Shah Merkhel
 
Lect05 Prog Model
Lect05 Prog ModelLect05 Prog Model
Lect05 Prog Modelanoosdomain
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorDarling Jemima
 
Session01_Intro.pdf
Session01_Intro.pdfSession01_Intro.pdf
Session01_Intro.pdfRahnerJames
 

Similar to CPU Architecture & Data Representation (20)

Lec-1-2-27102021-122208am.pptx for embedded design
Lec-1-2-27102021-122208am.pptx for embedded designLec-1-2-27102021-122208am.pptx for embedded design
Lec-1-2-27102021-122208am.pptx for embedded design
 
Sqlmaterial 120414024230-phpapp01
Sqlmaterial 120414024230-phpapp01Sqlmaterial 120414024230-phpapp01
Sqlmaterial 120414024230-phpapp01
 
06 mips-isa
06 mips-isa06 mips-isa
06 mips-isa
 
DLD_Lecture_notes2.ppt
DLD_Lecture_notes2.pptDLD_Lecture_notes2.ppt
DLD_Lecture_notes2.ppt
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
Kaizen cso002 l1
Kaizen cso002 l1Kaizen cso002 l1
Kaizen cso002 l1
 
Instruction set.pptx
Instruction set.pptxInstruction set.pptx
Instruction set.pptx
 
Introduction to Computer Architecture and Organization
Introduction to Computer Architecture and OrganizationIntroduction to Computer Architecture and Organization
Introduction to Computer Architecture and Organization
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)
 
Module 1-ppt System programming
Module 1-ppt System programmingModule 1-ppt System programming
Module 1-ppt System programming
 
CO_Chapter2.ppt
CO_Chapter2.pptCO_Chapter2.ppt
CO_Chapter2.ppt
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 
Ch12- instruction sets- char & funct.pdf
Ch12- instruction sets- char & funct.pdfCh12- instruction sets- char & funct.pdf
Ch12- instruction sets- char & funct.pdf
 
IDEA.ppt
IDEA.pptIDEA.ppt
IDEA.ppt
 
COA Chapter 1.pdf
COA Chapter 1.pdfCOA Chapter 1.pdf
COA Chapter 1.pdf
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Lect05 Prog Model
Lect05 Prog ModelLect05 Prog Model
Lect05 Prog Model
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
microprocessor
microprocessormicroprocessor
microprocessor
 
Session01_Intro.pdf
Session01_Intro.pdfSession01_Intro.pdf
Session01_Intro.pdf
 

Recently uploaded

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 

Recently uploaded (20)

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 

CPU Architecture & Data Representation

  • 1. Computer System Architecture Chapter -1 Department of Computer Science and Engineering Mr. Ashutosh Kumar Research Scholar Department of Computer Science and Engineering National Institute of Technology Raipur
  • 2. Outline CPU Organization & Functionality  CPU Organization  Fundamental and features  Data Representation – Basic Formats – Fixed and Floating Representation – Instruction Set – Instruction Format – Type and Programming Consideration – Addressing Mode • Fixed –Point Arithmetic Multiplication Algorithm • Hardware Algorithm • Booth Multiplication Algorithm
  • 3. Structure of the computer Main memory I/O CPU COMPUTER System Bus ALU Registers Control Unit CPU Internal Bus Control Unit Registers and Decoders CONTROL UNIT Sequencing Logic Contr ol Memory
  • 4. Structure of the computer There are four main structural components of the computer:  CPU – controls the operation of the computer and performs its data processing functions  Main Memory – stores data  I/O – moves data between the computer and its external environment  System Interconnection – some mechanism that provides for communication among CPU, main memory, and I/O
  • 5. CPU (Central Processing Unit)  Control Unit Controls the operation of the CPU and hence the computer  Arithmetic and Logic Unit (ALU) Performs the computer’s data processing function  Registers Provide storage internal to the CPU  CPU Interconnection Some mechanism that provides for communication among the control unit, ALU, and registers
  • 6.
  • 7. 4 channel DDR-4 RAM Memory Interfaces Expendable upto capacity Processor Placing or Interface (Intel/AMD) Serial ATA/SATA Interface CMOS Battery Ethernet Connector VGA Port USB 2.0 Port I/O Headphone or Mic Jack Super I/O PCI Express PCI Interface AGP Slot
  • 8. Major Component of Multicore computer
  • 9. History of Computers First Generation: Vacuum Tubes • Vacuum tubes were used for digital logic elements and memory • IAS computer – Fundamental design approach was the stored program concept • Attributed to the mathematician John von Neumann • First publication of the idea was in 1945 for the EDVAC – Design began at the Princeton Institute for Advanced Studies – Completed in 1952 – Prototype of all subsequent general-purpose computers
  • 10. Second Generation: Transistors  Smaller  Cheaper  Dissipates less heat than a vacuum tube  Is a solid state device made from silicon  Was invented at Bell Labs in 1947  It was not until the late 1950’s that fully transistorized computers were commercially available
  • 11. Computer Generations Generation Approximate Dates Technology Typical Speed (operations per second) 1 1946–1957 Vacuum tube 40,000 2 1957–1964 Transistor 200,000 3 1965–1971 Small and medium scale integration 1,000,000 4 1972–1977 Large scale integration 10,000,000 5 1978–1991 Very large scale integration 100,000,000 6 1991- Ultra large scale integration >1,000,000,000
  • 12. Second Generation Computers • Introduced: More complex arithmetic and logic units and control units The use of high-level programming languages Provision of system software which provided the ability to: • Load programs • Move data to peripherals • Libraries perform common computations
  • 13. Third Generation: Integrated Circuits 1958 – the invention of the integrated circuit Discrete component – Single, self-contained transistor – Manufactured separately, packaged in their own containers, and soldered or wired together onto masonite-like circuit boards – Manufacturing process was expensive and cumbersome – The two most important members of the third generation were the IBM System/360 and the DEC PDP-8
  • 14. Integrated Circuits  Data storage – provided by memory cells  Data processing – provided by gates  Data movement – the paths among components are used to move data from memory to memory and from memory through gates to memory  Control – the paths among components can carry control signals  A computer consists of gates, memory cells, and interconnections among these elements  The gates and memory cells are constructed of simple digital electronic components  Exploits the fact that such components as transistors, resistors, and conductors can be fabricated from a semiconductor such as silicon  Many transistors can be produced at the same time on a single wafer of silicon  Transistors can be connected with a processor metallization to form circuits
  • 15. Later Generations LSI Large Scale Integration VLSI Very Large Scale Integration ULSI Ultra Large Scale Integration Semiconductor Memory Microprocessors
  • 16. Evolution of Intel Microprocessors 4004 8008 8080 8086 8088 Introduced 1971 1972 1974 1978 1979 Clock speeds 108 kHz 108 kHz 2 MHz 5 MHz, 8 MHz, 10 MHz 5 MHz, 8 MHz Bus width 4 bits 8 bits 8 bits 16 bits 8 bits Number of transistors 2,300 3,500 6,000 29,000 29,000 Feature size (µm) 10 8 6 3 6 Addressable memory 640 Bytes 16 KB 64 KB 1 MB 1 MB (a) 1970s Processors
  • 17. Evolution of Intel Microprocessors (b) 1980s Processors 80286 386TM DX 386TM SX 486TM DX CPU Introduced 1982 1985 1988 1989 Clock speeds 6 MHz - 12.5 MHz 16 MHz - 33 MHz 16 MHz - 33 MHz 25 MHz - 50 MHz Bus width 16 bits 32 bits 16 bits 32 bits Number of transistors 134,000 275,000 275,000 1.2 million Feature size (µm) 1.5 1 1 0.8 - 1 Addressable memory 16 MB 4 GB 16 MB 4 GB Virtual memory 1 GB 64 TB 64 TB 64 TB Cache — — — 8 kB
  • 18. Evolution of Intel Microprocessors (c) 1990s Processors 486TM SX Pentium Pentium Pro Pentium II Introduced 1991 1993 1995 1997 Clock speeds 16 MHz - 33 MHz 60 MHz - 166 MHz, 150 MHz - 200 MHz 200 MHz - 300 MHz Bus width 32 bits 32 bits 64 bits 64 bits Number of transistors 1.185 million 3.1 million 5.5 million 7.5 million Feature size (µm) 1 0.8 0.6 0.35 Addressable memory 4 GB 4 GB 64 GB 64 GB Virtual memory 64 TB 64 TB 64 TB 64 TB Cache 8 kB 8 kB 512 kB L1 and 1 MB L2 512 kB L2
  • 19. Evolution of Intel Microprocessors (d) Recent Processors Pentium III Pentium 4 Core 2 Duo Core i7 EE 4960X Introduced 1999 2000 2006 2013 Clock speeds 450 - 660 MHz 1.3 - 1.8 GHz 1.06 - 1.2 GHz 4 GHz Bus wid th 64 bits 64 bits 64 bits 64 bits Number of transistors 9.5 million 42 million 167 million 1.86 billion Feature size (nm) 250 180 65 22 Addressable memory 64 GB 64 GB 64 GB 64 GB Virtual memory 64 TB 64 TB 64 TB 64 TB Cache 512 kB L2 256 kB L2 2 MB L2 1.5 MB L2/15 MB L3 Number of cores 1 1 2 6
  • 20. Data Representation in Computers  Data are stored in Registers  Registers are limited in number & size  With a n-bit register  Min value 0  Max value 2n-1 n-1 n-2 … ... ... 2 1 0 n-bits
  • 21. Data Representation Data Representation Qualitative • Represents quality or characteristics • Not proportional to a value • Name, NIC no, index no, Address Quantitative • Quantifiable • Proportional to value α • No of students, marks for CS2052, GPA
  • 23. Number Systems  Decimal number system 0, 1, 2, 3, 4, 5, 6, 7, 8, 9  Binary number system 0, 1  Octal number system 0, 1, 2, 3, 4, 5, 6, 7  Hexadecimal number system 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
  • 24. Quantitative Numbers  Integers  Unsigned  Signed  Non-integers 20 +20, -20  Floating point numbers - 10.25, 3.33333…, 1/8 = 0.125
  • 25. Signed Integers  We need a way to represent negative values  3 representations  Sign & Magnitude representation (S&M)  Complement method  Bias notation or Excess notation
  • 26. 1. Sign & Magnitude Representation sign n-1 n-2 ... ... 2 1 0 Magnitude (n-bits)  n-bit unsigned magnitude & sign bit (S)  If S  0 – Integer is positive or zero  1 – Integer is negative or zero  Range –(2n-1) to +(2n-1)
  • 27. Example – Sign & Magnitude  If 8-bit register is used what are min & max numbers?  What are 0000 0000 and 1000 0000 in decimal?  Representation of zero is not unique
  • 28. Sign & Magnitude (Cont.)  Advantages  Sign reversal  Finding absolute value |a|  Flip sign bit  Disadvantage  Adding a negative of a number is not the same as subtraction  e.g., add 2 and -3  Need different operations  Zero is not unique
  • 29. Complement Method  Base = Radix  Radix r system means r number of symbols  e.g., binary numbers have symbols 0, 1  2 types  r’s complement  (r – 1)’s complement  Where r is radix (base) of number system  Examples  Decimal  Binary 9’s & 10’s complement 1’s & 2’s complement
  • 30. Complement Method – Definition  Given a number m in base/radix r & having n digits  (r – 1)’s complement of m is (rn – 1) – m  r ’s complement of n is (rn – 1) – m + 1 = rn – m
  • 31. Example – Complement Method  If m = 5982 & n = 4 digits  9’s complement is 9 9 9 9 5 9 8 2 – 4 0 1 7 - maximum representable no  10’s complement 9 9 9 9 5 9 8 2 – 4 0 1 7 1 + 4 0 1 8 or 1 0 0 0 0 5 9 8 2 – 4 0 1 8
  • 32. Example – Complement Method  If m = 382 & n = 3  -n = -382 = 9 9 9 9 9 9 3 8 2 – 3 8 2 - 6 1 7 6 1 7 1 + 6 1 8  -382 = 617 or 618  Depending on which complement we use  These are called complementary pair
  • 33. 1’s complement  Calculated by  (2n – 1) – m  If m = 0101  1’s complement of m on a 4-bit system 1 1 1 1 0 1 0 1 – 1 0 1 0  This represents -5 in 1’s complement
  • 34. Finding 1’s Complement – Short Cut  Invert each bit of m  Example  m = 0 0 1 0 1 0 1 1  1’s complement of m = 1 1 0 1 0 1 0 0  m = 0 0 0 0 0 0 0 0 = 0  1’s complement of m = 1 1 1 1 1 1 1 1 = -0  Values range from -127 to +127
  • 35. Addition with 1’s Complement  If results has a carry add it to LSB (Least Significant Bit)  Example  Add 6 and -3 on a 3-bit system  6 = 1 1 0  -3 = 1 0 0 + = 1 0 1 0 1 + 0 1 1
  • 36. 2’s Complement  Doesn’t require end-around carry operation as in 1’s complement  2’s complement is formed by  Finding 1’s complement  Add 1 to LSB  New range is from -128 to +127  -128 because of +1 to negative value
  • 37. Example – 2’s Complement  Find 2’s complement of 0101011  m = 0 1 0 1 0 1 1 = 1 0 1 0 1 0 0 1 + = 1 0 1 0 1 0 1  2’s  Short-cut 1. Search for the 1st bit with value 1 starting fromLSB 2. Inver all bits after 1st one
  • 38. Example – 2’s Complement (Cont.)  Add 6 and -5 on a 4-bit system 5 = 0101 -5 = 1011 6 = 0 1 1 0 -5 = 1 0 1 1+ 1 0 0 0 1  0 0 0 1 Discard
  • 39. 1’s vs. 2’s Complement  1’s complement has 2 zeros (+0, -0)  Value range is less than 2’s complement  2’s complement only has a single zero  Value range is unequal  No need of a separate subtract circuit Doing a NOT operation is much more cost effective interms of circuit design  However, multiplication & division is slow
  • 40. Fixed-Point Representation old position 7 6 5 4 3 2 1 0 New position 4 3 2 1 0 -1 -2 -3 Bit pattern 1 0 0 1 1 . 1 0 1 Contribution 24 21 20 2-1 2-3 =19.625 Radix-point
  • 41. Limitation of Fixed-Point Representation  To represent large numbers or very small numbers we need a very long sequences of bits.  This is because we have to give bits to both the integer part and the fraction part.
  • 42. Floating Point Numbers  We needed to represent fractional values & values beyond 2n – 1  +3207.23  -0.000321 = 3.20723x103 =-3.21x10-4 Sign Mantissa Radix (base) Exponent
  • 43. Floating Point Numbers (Cont.) Sign Radix Mantissa Exponent sign en-1 … ... e0 mn-1 mn-2 … … m1 m0 Mantissa Exponent N  (1)s m.2e
  • 44. IEEE Floating Point Standard (Cont.) s31 e30 … ... e23 m22 mn-2 … … m1 m0 Exponent Mantissa N  (1)s [1.m]2E 127  E – 127 = e  E = e + 127  What is stored is E
  • 45. IEEE Floating Point Standard (FPS)  2 standards 1. Single precision  32-bits  23-bit mantissa  8-bit exponent  1-bit sign 2. Double precision  64-bits  52-bit mantissa  11-bit exponent  1-bit sign S Exponent Mantissa (bits 0-22) 31 30 23 22 0 S Exponent Mantissa (bits 0-51) 63 62 52 51 0
  • 46. Instruction Set 8086 Microprocessor Theinstructionsetare categorizedinto the following types:  Data transferinstructions  Arithmetic instructions  Logicalinstructions  Flag manipulation instructions  shiftand rotate instructions  Stringinstructions  8086 assemblerdirectives
  • 47. Data Transfer Instruction  MOV- Move byte orword to registerormemory  IN, OUT- Input byte orword from port, output word toport  LEA- Load effective address  LDS,LES- Load pointer usingdata segment,extra segment  PUSH,POP- Pushword onto stack, pop word off stack  XCHG- Exchangebyte orword  XLAT- Translate byte usinglook-up table
  • 48. Arithmetic Instruction ADD – ADD Destination, Source ADC – ADC Destination, Source These instructions add a number from some source to a number in some destination and put the result in the specified destination. SUB – SUB Destination, Source SBB – SBB Destination, Source These instructions subtract the number in some source from the number in some destination and put the result in the destination. The SBB instruction also subtracts the content of carry flag from the destination. INC – INC Destination The INC instruction adds 1 to a specified register or to a memory location. AF, OF, PF, SF, and ZF are updated, but CF is not affected.
  • 49. Arithmetic Instruction MUL – MUL Source This instruction multiplies an unsigned byte in some source with an unsigned byte in AL register or an unsigned word in some source with an unsigned word in AX register. IMUL – IMUL Source This instruction multiplies a signed byte from source with a signed byte in AL or a signed word from some source with a signed word in AX . DIV – DIV Source This instruction is used to divide an unsigned word by a byte or to divide an unsigned double word (32 bits) by a word. IDIV – IDIV Source This instruction is used to divide a signed word by a signed byte, or to divide a signed double word by a signed word.
  • 50. Arithmetic Instruction  DEC – DEC Destination This instruction subtracts 1 from the destination word or byte.  DAA (DECIMALADJUST AFTER BCD ADDITION) This instruction is used to make sure the result of adding two packed BCD numbers is adjusted to be a legal BCD number .  DAS (DECIMALADJUST AFTER BCD SUBTRACTION) This instruction is used after subtracting one packed BCD number from another packed BCD number, to make sure the result is correct packed BCD.  CBW (CONVERT SIGNED BYTE TO SIGNED WORD) This instruction copies the sign bit of the byte in AL to all the bits in AH. AH is then said to be the sign extension of AL. CBW does not affect any flag.  CWD (CONVERT SIGNED WORD TO SIGNED DOUBLE WORD) This instruction copies the sign bit of a word in AX to all the bits of the DX register. In other words, it extends the sign of AX into all of DX. CWD affects no flags.
  • 51. Arithmetic Instruction AAA (ASCII ADJUST FOR ADDITION) Numerical data coming into a computer from a terminal is usually in ASCII code. AAS (ASCII ADJUST FOR SUBTRACTION) Numerical data coming into a computer from a terminal is usually in an ASCII code. AAM (BCD ADJUST AFTER MULTIPLY) Before you can multiply two ASCII digits, you must first mask the upper 4 bit of each. This leaves unpacked BCD (one BCD digit per byte) in each byte. AAD (BCD-TO-BINARY CONVERT BEFORE DIVISION) AAD converts two unpacked BCD digits in AH and AL to the equivalent binary number in AL.
  • 52. Logical Instruction  AND – AND Destination, Source This instruction ANDs each bit in a source byte or word with the same numbered bit in a destination byte or word.  OR – OR Destination, Source This instruction ORs each bit in a source byte or word with the same numbered bit in a destination byte or word.  XOR – XOR Destination, Source This instruction Exclusive-ORs each bit in a source byte or word with the same numbered bit in a destination byte or word.  NOT – NOT Destination The NOT instruction inverts each bit (forms the 1’s complement) of a byte or word in the specified destination.
  • 53. Logical Instruction  NEG – NEG Destination This instruction replaces the number in a destination with its 2’s complement.  CMP – CMP Destination, Source This instruction compares a byte / word in the specified source with a byte / word in the specified destination.  TEST – TEST Destination, Source This instruction ANDs the byte / word in the specified source with the byte / word in the specified destination.
  • 54. FLAG MANIPULATION Instruction  STC: It sets the carry flag to 1.  CLC: It clears the carry flag to 0.  CMC: It complements the carry flag  STD: It sets the direction flag to 1. If it is set, string bytes are accessed from higher memory address to lower memory address.  CLD: It clears the direction flag to 0. If it is reset, the string bytes are accessed from lower memory address to higher memory address.
  • 55. Instruction Format  An instruction format or instruction code is a group of bits used to perform a particular operation on the data stored in computer.  Processor fetches an instruction from memory and decodes the bits to execute the instruction.  Different computer may have their own instruction set .  The operation of the processor is determined by the instructions it executes, referred to as machine instructions or computer instructions  The collection of different instructions that the processor can execute is referred to as the processor’s instruction set  Each instruction must contain the information required by the processor for execution
  • 57. Source and result operands can be in one of four areas: 1) Main memory or virtual memory  As with next instruction references, the main or virtualmemory address must be supplied. 2) I/O devices  The instruction must specify the I/O module and device for the operation. If memory-mapped I/O is used, this is just another main or virtual memory address. 3) Processor register  A processor contains one or more registers that may be referenced by machine instructions.  If more than one register exists each register is assigned a unique name or number and the instruction must contain the number of the desired register 4) Immediate  The value of the operand is contained in a field in the instruction being executed
  • 58. Types of Operand  Addresses: immediate, direct, indirect, stack Numbers: integer or fixed point (binary, twos complement), floating point (sign, exponent), (packed) decimal (246 = 0000 0010 0100 0110) Characters: ASCII (128 printable and control characters + bit for error detection)  Logical Data: bits or flags, e.g., Boolean 0 and 1
  • 59. Instruction Representation Within the computer each instruction is represented by a sequence of bits The instruction is divided into fields, corresponding to the constituent elements of the instruction
  • 60. Instruction Types A computer should have a set of instructions that allows the userto formulate any data processing task.. Any program written in a high- level language must be translated into machine language to be executed, so we can categorize instruction types as follows: Data processing: Arithmetic instructions providecomputational capabilities for processing numeric data  Data storage: Movement of data into or out of register and or memory locations Data movement :I /O instructions are needed to transfer programs and data into memory and the results of computations back outto the user  Control: test instruction test the value of a data word or the statusof a computation Branch instruction used to branch to a different set of instructions depending on the decision made
  • 61. Instruction Formats  Layout of bits in an instruction  Includes opcode  Includes (implicit or explicit) operand(s)  Usually more than one instruction format in an instruction set Instruction Length Affected by and affects:  Memory size  Memory organization - addressing  Bus structure, e.g., width  CPU complexity  CPU speed Trade off between powerful instruction repertoire and saving space
  • 62. Allocation of Bits Number of addressing modes: implicit or additional bits specifying it  Number of operands  Register (faster, limited size and number, 32) versus memory  Number of register sets, e.g., data and address (shorter addresses)  Address range  Address granularity (e.g., by byte)  Number ofAddresses  More addresses 1 More complex instructions 2More registers - inter-register operations are quicker 3-Less instructions per program  Fewer addresses 1 Less complex instructions 2More instructions per program, e.g. data movement 3-Faster fetch/execution of instructions
  • 63. Pentium Instruction Format Pentium uses a variable length instruction format. The Pentium instruction can be from 2 to 16 byteslong. The Instruction is broken down into 6 sections 1-Instruction Prefixes 2-Opcode 3-Mod R/M 4 SIB 5Displacement 6- Immediate
  • 64. Instruction Prefixes 2 .Opcode Instruction Prefix:used in multiprocessor enviroments, specifically with strings Segment Override: This specifies which segment-register to use, if not the default. Operand Size: The operand size can be either 16 or 32 bits, this specifies whichis being used. Address Size: The Pentium can use a 16 or 32 bit address, this specifies which is being used. The opcode can be either one or two bytes. The opcode can also specify if the data is 16 or 32 bit. The opcode specifies which way the data is going (to or from memory). The opcode specifies if an immediate value is signed or not.
  • 65. Addressing Modes  Immediate  Direct  Indirect  Register  Register Indirect  Displacement (Indexed)  Stack
  • 66. Immediate Addressing  Operand is part of instruction  Operand = address field  e.g. ADD 5 —Add 5 to contents of accumulator —5 is operand  No memory reference to fetch data  Fast  Limited range
  • 68. Direct Addressing  Address field contains address of operand  Effective address (EA) = address field (A)  e.g. ADD A —Add contents of cell A to accumulator —Look in memory at address A for operand  Single memory reference to access data  No additional calculations to work out effective address  Limited address space
  • 70. Indirect Addressing (1)  Memory cell pointed to by address field contains the address of (pointer to) the operand  EA = (A) —Look in A, find address (A) and look there for operand  e.g. ADD (A) —Add contents of cell pointed to by contents of A to accumulator
  • 71. Indirect Addressing (2)  Large address space  2n where n = wordlength  May be nested, multilevel, cascaded —e.g. EA = (((A))) – Draw the diagramyourself  Multiple memory accesses to find operand  Hence slower
  • 73. Register Addressing (1)  Operand is held in register named in address filed  EA = R  Limited number of registers  Very small address field needed —Shorter instructions —Faster instruction fetch
  • 74. Register Addressing (2)  No memory access  Very fast execution  Very limited address space  Multiple registers helps performance —Requires good assembly programming or compiler writing —N.B. C programming – register inta;  c.f. Direct addressing
  • 75. Register Addressing Diagram Register Address R Opcode Instruction Registers Operand
  • 76. Register Indirect Addressing  C.f. indirect addressing  EA = (R)  Operand is in memory cell pointed to by contents of register R  Large address space (2n)  One fewer memory access than indirect addressing
  • 77. Register Indirect Addressing Diagram Opcode Register Address R Memory Operand Pointer to Operand Registers Instruction
  • 78. Displacement Addressing  EA = A + (R)  Address field hold two values —A = base value —R = register that holds displacement —or vice versa
  • 79. Displacement Addressing Diagram Instruction Memory Operand Pointer to Operand Registers Opcode Register R AddressA +
  • 80. Relative Addressing  A version of displacement addressing  R = Program counter, PC  EA = A + (PC)  i.e. get operand from A cells from current location pointed to by PC  c.f locality of reference & cache usage
  • 81. Base-Register Addressing  A holds displacement  R holds pointer to base address  R may be explicit or implicit  e.g. segment registers in 80x86
  • 82. Indexed Addressing  A = base  R = displacement  EA = A + R  Good for accessing arrays —EA = A + R —R++
  • 83. Combinations  Postindex  EA = (A) + (R)  Preindex  EA = (A+(R))  (Draw the diagrams)
  • 84. Stack Addressing Operand is (implicitly) on top of stack e.g. —ADD Pop top two items from stack and add
  • 86. Multiplication (often denoted by x) is the mathematical operation of scaling one number by another. It is a basic arithmetic operation. Example: 3 x 4= 3+3+3+3=12 5 x 3 ½ =5+5+5+(half of 5)= 17.5 The basic idea of multiplication is repeated addition. Multiplication
  • 87. Paper and pencil example (unsigned): Multiplicand Multiplier Product 1000 1001 1000 0000 0000 1000 01001000 m bits x n bits = m+n bit product Binary makes it easy: 0 => place 0 1 => place a copy ( 0 x multiplicand) ( 1 x multiplicand) Place a copy Place 0 Multiply
  • 88. 64-bit Multiplicand reg, 64-bit ALU, 64-bit Productreg, 32-bit multiplier reg Multiplier 64-bitALU Shift Left Shift Right Write Control 32 bits Multiplicand 64 bits Product 64 bits Unsigned Shift-add Multiplier
  • 89. Yes: 32 repetitions Done No: < 32 repetitions 32nd repetition? Start Multiplier0 = 1 1. Test Multiplier0 = 0 Multiplier0 1a. Add multiplicand to product & place the result in Product register Product Multiplier Multiplicand 0000 0000 0011 0000 0010 2. Shift the Multiplicand register left 1 bit. 0000 0010 0001 0000 0100 0000 0110 0000 0000 1000 3. Shift the Multiplier register right 1 bit. 0000 0110 Multiply Algorithm Flowchart Version 1
  • 90. Half of the shifted multiplicand register contains 0. Why not shift the product right? 32-bit Multiplicand reg, 32 -bit ALU, 64-bit Product reg, 32-bit Multiplier reg Product Multiplier Multiplican d 32-bitALU Shift Right Write Control 32 bits 32 bits 64 bits Shift Right Multiply Hardware Version
  • 91. Yes: 32 repetitions Done 2. Shift the Product register right 1 bit. 3. Shift the Multiplier register right 1 bit. No: < 32 repetitions 1. Test Multiplier0 Multiplier0 = 0 Multiplier0 = 1 1a. Add multiplicand to the left half of product & place the result in the left half of Product register 32nd repetition? Start ° Product Multiplier 0000 0000 0011 Multiplicand 0010 Multiply Algorithm Flowchart Version 2
  • 92. Product 0000 0000 Multiplier Multiplicand 0011 0010 00100000 00010000 0001 0010 00110000 0001 0010 00011000 0000 0010 00001100 0000 0010 00000110 0000 0010 Yes: 32 repetitions Done 2. Shift the Product register right 1 bit. 3. Shift the Multiplier register right 1 bit. No: < 32 repetitions 1. Test Multiplier0 Multiplier0 = 0 Multiplier0 = 1 1a. Add multiplicand to the left half of product & place the result in the left half of Product register 32nd repetition? Start Multiply Algorithm Flowchart Version 2
  • 93. Combine Multiplier register and Product register 32-bit Multiplicand reg, 32 -bit ALU, 64-bit Product reg, (0- bit Multiplier reg) Multiplican d 32-bitALU Write Control 32 bits Product (Multiplier) 64 bits Shift Right Multiply Algorithm Version 3
  • 94. Multiplicand 0010 Product 0000 0011 Yes: 32 repetitions Done 2. Shift the Product register right 1 bit. No: < 32 repetitions 1. Test Product0 Product0 = 0 Product0 = 1 1a. Add multiplicand to the left half of product & place the result in the left half of Product register 32nd repetition? Start Missing Multiplier Multiply Algorithm Flowchart Version 3
  • 95. Mcand:0010 P:00000011 1 P=P+Mcand Mcand:0010 P:00100011 ShrP Mcand:0010 P:00010001 2 P=P+Mcand Mcand:0010 P:00110001 ShrP Mcand:0010 P:00011000 3 0=>nop Mcand:0010 P:00011000 ShrP Mcand:0010 P:00001100 4 0=>nop Mcand:0010 P:00001100 ShrP Mcand:0010 P:00000110
  • 96. Booth algorithm gives a procedure for multiplying binary integers in signed – 2’s complement representation. I will illustrate the booth algorithm with the following example: Example, 2 x (-4) 0010 * 1100 Step 1: Making the Booth table 1. From the two numbers, pick the number with the smallest difference between a series of consecutive numbers, and make it a multiplier. i.e., 0010 -- From 0 to 0 no change, 0 to 1 one change, 1 to 0 another change ,so there are two changes on this one 1100 -- From 1 to 1 no change, 1 to 0 one change, 0 to 0 no change, so there is only one change on this one. Therefore, multiplication of 2 x (– 4), where 2 ten (0010 two) is the multiplicand and (– 4) ten (1100two) is the multiplier. Booth Multiplication Algorithm
  • 97. 2. Let X = 1100 (multiplier) Let Y = 0010 (multiplicand) Take the 2’s complement of Y and call it –Y –Y = 1110 3. Load the X value in the table. 4. Load 0 for X-1 value it should be the previous first least significant bit of X 5.Load 0 in U and V rows which will have the product of X and Y at the end of operation. 6.Make four rows for each cycle; this is because we are multiplying four bits numbers. Booth Multiplication Algorithm
  • 98. Step 2: BoothAlgorithm Look at the first least significant bits of the multiplier “X”, and the previous least significant bits of the multiplier “X - 1”. a. 1 0 Shift only 2 1 Shift only. 3 1 Add Y to U, and shift 4 0 Subtract Y from U, and shift or add (-Y) to U and shift b. Take U & V together and shift arithmetic right shift which preserves the sign bit of 2’s complement number. Thus a positive number remains positive, and a negative number remains negative. c. Shift X circular right shift because this will prevent us from using two registers for the X value. Booth Multiplication Algorithm
  • 100. We have finished four cycles, so the answer is shown, in the last rows of U and V which is: 11111000 Now to easily check our calculations, we take the original question, 2 x -4. This becomes -8. -8 is the two's compliment of 8. 8 in eight bit binary is 00001000. Taking the two's compliment by the method previously described, we get the result 11111000, which is exactly the same as our Booths algorithm answer. Booth Multiplication Algorithm