COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 3 - ARITMETHIC-LOGIC UNIT JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Similar documents
Carry Look Ahead Adders

Chapter 5 Arithmetic Circuits

Midterm Exam Two is scheduled on April 8 in class. On March 27 I will help you prepare Midterm Exam Two.

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design

Chapter 1: Solutions to Exercises

Adders, subtractors comparators, multipliers and other ALU elements

Combinational Logic Design Arithmetic Functions and Circuits

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

Binary Multipliers. Reading: Study Chapter 3. The key trick of multiplication is memorizing a digit-to-digit table Everything else was just adding

Adders, subtractors comparators, multipliers and other ALU elements

EECS150. Arithmetic Circuits

Combinational Logic. By : Ali Mustafa

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

UNIT III Design of Combinational Logic Circuits. Department of Computer Science SRM UNIVERSITY

CS 140 Lecture 14 Standard Combinational Modules

14:332:231 DIGITAL LOGIC DESIGN

DIVIDER IMPLEMENTATION

Hardware Design I Chap. 4 Representative combinational logic

CSE140: Components and Design Techniques for Digital Systems. Decoders, adders, comparators, multipliers and other ALU elements. Tajana Simunic Rosing

ALU (3) - Division Algorithms

Graduate Institute of Electronics Engineering, NTU Basic Division Scheme

Solutions for Appendix C Exercises

Linear Feedback Shift Registers (LFSRs) 4-bit LFSR

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

Adders - Subtractors

Number representation

Chapter 4. Combinational: Circuits with logic gates whose outputs depend on the present combination of the inputs. elements. Dr.

Review. EECS Components and Design Techniques for Digital Systems. Lec 18 Arithmetic II (Multiplication) Computer Number Systems

Ex code

Systems I: Computer Organization and Architecture

Divider Implementation

9. Datapath Design. Jacob Abraham. Department of Electrical and Computer Engineering The University of Texas at Austin VLSI Design Fall 2017

Chapter 2 Basic Arithmetic Circuits

Hakim Weatherspoon CS 3410 Computer Science Cornell University

ELEN Electronique numérique

CHAPTER 2 NUMBER SYSTEMS

COMBINATIONAL LOGIC FUNCTIONS

Lecture 8: Sequential Multipliers

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters

Arithmetic Circuits-2

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

ECE380 Digital Logic. Positional representation

CprE 281: Digital Logic

The goal differs from prime factorization. Prime factorization would initialize all divisors to be prime numbers instead of integers*

Logic. Combinational. inputs. outputs. the result. system can

EECS150 - Digital Design Lecture 10 - Combinational Logic Circuits Part 1

Design of Sequential Circuits

Multiplication of signed-operands

Cost/Performance Tradeoffs:

COE 202: Digital Logic Design Combinational Circuits Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Numbers and Arithmetic

Binary addition by hand. Adding two bits

Menu. Binary Adder EEL3701 EEL3701. Add, Subtract, Compare, ALU

Unit 16 Problem Solutions

Introduction to Digital Logic

CSE 140L Spring 2010 Lab 1 Assignment Due beginning of the class on 14 th April

Arithmetic in Integer Rings and Prime Fields

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops

CMSC 313 Lecture 18 Midterm Exam returned Assign Homework 3 Circuits for Addition Digital Logic Components Programmable Logic Arrays

Tree and Array Multipliers Ivor Page 1

ELCT201: DIGITAL LOGIC DESIGN

3.3 Dividing Polynomials. Copyright Cengage Learning. All rights reserved.

ALUs and Data Paths. Subtitle: How to design the data path of a processor. 1/8/ L3 Data Path Design Copyright Joanne DeGroat, ECE, OSU 1

Numbers and Arithmetic

1 Short adders. t total_ripple8 = t first + 6*t middle + t last = 4t p + 6*2t p + 2t p = 18t p

Looking at a two binary digit sum shows what we need to extend addition to multiple binary digits.

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q

Arithmetic Circuits-2

CMPUT 329. Circuits for binary addition

Addition and Subtraction

CMP 334: Seventh Class

Arithmetic Circuits How to add and subtract using combinational logic Setting flags Adding faster

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit

Answers (1) A) 36 = - - = Now, we can divide the numbers as shown below. For example : 4 = 2, 2 4 = -2, -2-4 = -2, 2-4 = 2.

Proposal to Improve Data Format Conversions for a Hybrid Number System Processor

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

Review for Final Exam

Cost/Performance Tradeoff of n-select Square Root Implementations

Overview. Arithmetic circuits. Binary half adder. Binary full adder. Last lecture PLDs ROMs Tristates Design examples

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

6.111 Lecture # 12. Binary arithmetic: most operations are familiar Each place in a binary number has value 2 n

Building a Computer Adder

Proposal to Improve Data Format Conversions for a Hybrid Number System Processor

This Unit: Arithmetic. CIS 371 Computer Organization and Design. Pre-Class Exercise. Readings

Lecture 11. Advanced Dividers

Binary addition example worked out

A Simple Architectural Enhancement for Fast and Flexible Elliptic Curve Cryptography over Binary Finite Fields GF(2 m )

Lecture 3 Review on Digital Logic (Part 2)

Chapter 5. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 5 <1>

Lecture 8. Sequential Multipliers

Resource Efficient Design of Quantum Circuits for Quantum Algorithms

Arithmetic Circuits-2

Arithmetic and Logic Unit First Part

convert a two s complement number back into a recognizable magnitude.

ECE/CS 552: Introduction To Computer Architecture 1. Instructor:Mikko H Lipasti. Fall 2010 University i of Wisconsin-Madison

Transcription:

OMUTERS ORGANIZATION 2ND YEAR OMUTE SIENE MANAGEMENT ENGINEERING UNIT 3 - ARITMETHI-LOGI UNIT JOSÉ GARÍA RODRÍGUEZ JOSÉ ANTONIO SERRA ÉREZ Tema 3. La Unidad entral de roceso. A.L.U.

Arithmetic Logic Unit ALU Introduction Logic Operations Addition and subtraction arry propagated adder (A) Adder-Subtractor circuit Overflow arry Look-ahead Adder (LA) Multiplication Binary multiplication without sign Binary multiplication with sign Booth Algorithm Division onclusions Tema 3. La Unidad entral de roceso. A.L.U. 2

Introduction Introduction B A TEM D E ALU Z O Arithmetic and logic operator (one or more) Accumulator One or more temporal registers Result flags arry () Negative (N) Overflow (O or V) Zero (Z) Tema 3. La Unidad entral de roceso. A.L.U. 3

Logic operations Logic Operations Easy to implement Direct correspondence with the Hardware. Logic gates AND, OR, XOR, INVERTER,... Operation A B 00 0 Result 0 Tema 3. La Unidad entral de roceso. A.L.U. 4

Addition and subtraction Half-adder Binary half-adder (H.A.) Inputs Outputs X Y S S = X Y + X Y = X Y 0 0 0 0 = X Y 0 0 0 0 0 H.A. A S A B H.A. B S Tema 3. La Unidad entral de roceso. A.L.U. 5

Full Adder (F.A.) Addition and Subtraction A B F.A. Inputs Outputs in A B in S out 0 0 0 0 0 S 0 0 0 0 0 0 out 0 0 0 0 0 0 0 0 0 S = A B in + A B in + A B in + A B in out = A B + A in + B in S = out = ( A B) in AB + in ( A B) Tema 3. La Unidad entral de roceso. A.L.U. 6

Full Adder (F.A.) Addition and Subtraction Usign half-adders (H.A.) H.A. A S F.A. H.A. S S B out in Tema 3. La Unidad entral de roceso. A.L.U. 7

Full Adder (F.A.) Addition and Subtraction Usign gates Tema 3. La Unidad entral de roceso. A.L.U. 8

arry ropagated Adder Addition and Subtraction To add two numbers of n bits, n full adder should be placed one after another. arry is propagated from one stage to the next one: arry ropagated Adder. B 3 A 3 B 2 A 2 B A B 0 A 0 4 2 2 0 S 3 S 2 S S 0 Tema 3. La Unidad entral de roceso. A.L.U. 9

arry ropagated Adder Addition and Subtraction Adders built with logic gates using the expression: S = A B in + A B in + A B in + A B in out = A B + A in + B in B 3 A 3 B 2 A 2 B A B 0 A 0 4 8T 9T 2 6T 7T 2 4T 5T 2T 3T 0 S 3 S 2 S S 0 Tema 3. La Unidad entral de roceso. A.L.U. 0

arry ropagated Adder Addition and Subtraction Full adders built with half-adders A B in S out B 3 A 3 B 2 A 2 B A B 0 A 0 4 9T 8T 2 7T 6T 2 5T 4T 3T 2T 0 S 3 S 2 S S 0 Total _ Time = ( 2 n + )T Tema 3. La Unidad entral de roceso. A.L.U.

Subtractor circuit Addition and Subtraction The circuit works with numbers in two s complement notation. A - B = A + ((B) + ) B 3 A 3 B 2 A 2 B A B 0 A 0 2 2 0 = 4 S 3 S 2 S S 0 Tema 3. La Unidad entral de roceso. A.L.U. 2

Adder-Subtractor ircuit Addition and Subtraction S/A B i input 0 0 0 0 0 0 Total _ Time = 2( n + )T B 3 A 3 B 2 A 2 B A B 0 A 0 R/S 4 2 2 0 S 3 S 2 S S 0 Tema 3. La Unidad entral de roceso. A.L.U. 3

Overflow detection Addition and Subtraction Two s complement Adder-Substractor with overflow detection B 3 A 3 B 2 A 2 B A B 0 A 0 R/S 4 3 2 0 S 3 S 2 S S 0 V Tema 3. La Unidad entral de roceso. A.L.U. 4

Overflow Detection Addition and Subtraction. ase Addition of two positive numbers S 4 3 2 0 0 0 0 OV 2. ase Addition of two negative numbers S 4 3 2 0 0 0 0 0 0 0 OV Tema 3. La Unidad entral de roceso. A.L.U. 5

arry Look-ahead Adder Assume A and B to be 4 bits numbers arry generating signal: arry propagating signal: Addition and Subtraction i i i b a G = = = + i i i b a Tema 3. La Unidad entral de roceso. A.L.U. 6 arry on stage i: haracterized for A and B: = + i i i b a i i i i G + = 2 3 3 3 2 2 2 0 0 0 0 G G G G + = + = + = + =

arry Look-ahead Adder Expanding the expressions depending on -: Addition and Subtraction 0 2 0 2 2 2 2 0 0 0 0 0 G G G G G G + + + = + + = + = Tema 3. La Unidad entral de roceso. A.L.U. 7 arries depend on ai and bi. These expressions are resolved as addition of products. Three leves of logic gates are needed to get each carry. 0 2 3 0 2 3 2 3 2 3 3 3 0 2 0 2 2 2 2 G G G G G G G + + + + = + + + =

arry Look-ahead Adder Addition and Subtraction a 3 b 3 a 2 b 2 a b a 0 b 0 g 3 p 3 S 3 c 2 g 2 p 2 S 2 c g p S c 0 g 0 p 0 S 0 c - c 3 Look-ahead arry Generator Tema 3. La Unidad entral de roceso. A.L.U. 8

arry Look-ahead Adder Addition and Subtraction a 3 b 3 3T c 2 a 2 b 2 3T c a b 3T c 0 a 0 b 0 c - p 3 4T g 2 p 2 4T g p 4T g 0 p 0 4T T T S 3 T T S T T 2 S T T S 0 g 3 c 3 Look-ahead arry Generator 3T F.A. a i b i i- H.A. 3T H.A. T 4T S i c i Adders built with half-adders Tema 3. La Unidad entral de roceso. A.L.U. 9

Example (8 bits LA) Addition and Subtraction a 7 b 7 a 6 b 6 a 5 b 5 a 4 b 4 a 3 b 3 a 2 b 2 a b a 0 b 0 c 6 c 5 c 4 c 3 c 2 c c 0 c - g 7 p 7S7 g 6 p g 6 5p 5S5 g 4 p 4S4 S 6 g 3 p 3S3 g 2 p g 2 p S g 0 p 0S0 S 2 c 7 Look-ahead carry generator Look-ahead carry generator alculate the delay in this LA supposing that the adders are built with half-adders. ompare the result against a 8 bits A. Tema 3. La Unidad entral de roceso. A.L.U. 20

Example ( 4 bits LA) Addition and Subtraction Tema 3. La Unidad entral de roceso. A.L.U. 2

Example (4 bits LA) Addition and Subtraction 3 2 0 3 2 0 0 0 0 0 0 0 0 0 Tema 3. La Unidad entral de roceso. A.L.U. 22

Multiplication Multiplication Sums and shifts algorithm If multiplicand has n bits and multiplier has m bits, them the product will have n+m bits. Binary multiplication: simple as you only multiply by or by 0. Multiplicand 5 3 2 Multiplier 4 3 5 3 2 5 9 6 2 2 8 roduct 2 2 9 2 9 2 Tema 3. La Unidad entral de roceso. A.L.U. 23

Binary multipication without sign Multiplication Repeat n times If bit 0 of multiplier= then End if End repeat Sum the multiplicand to the left half of the product and place the result int the left half of the product Shift the product register bit to the right Shift the multiplier register bit to the right reliminary Version ALU Multiplicand n bits Multiplier n bits Sum Right shift Right shift roduct 2n bits Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 24

Binary multiplication without sign Multiplication Multiplicand 0 Multiplier 0 0 0 0 0 0 0 0 roduct 0 0 0 reliminary Version ALU Multiplicand n bits Multiplier n bits Sum Right shift Right shift roduct 2n bits Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 25

Binary multiplication without sign Multiplication Repeat n times If bit 0 of product register= then End if End repeat Sum the multiplicand to the left half of the product and place the result in the left half of the product. Shift the product register bit to the right Final Version Multiplicand n bits ALU Sum Right shift roduct 2n bits Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 26

Binary multiplication without sign Multiplication 0 0 Multiplicand 0(d Iteration 0 Initial values ALU Sum Right shift 0 0 0 0 0 0 0 roduct Multiplier 5(d Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 27

Binary multiplication without sign Multiplication 0 0 Multiplicand Iteration roduct + Multiplicand ALU Sum Right shift 0 0 0 0 0 roduct Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 28

Binary multiplication without sign Multiplication 0 0 Multiplicand Iteration Right shift ALU Sum Right shift 0 0 0 0 0 0 roduct Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 29

Binary multiplication without sign Multiplication 0 0 Multiplicand Iteration 2 Right shift ALU Sum Right shift 0 0 0 0 0 0 roduct Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 30

Binary multiplication without sign Multiplication 0 0 Multiplicand Iteration 3 roduct + Multiplicand ALU Sum Right shift 0 0 0 0 0 roduct Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 3

Binary multiplication without sign Multiplication 0 0 Multiplicand Iteration 3 Right shift ALU Sum Right shift 0 0 0 0 0 0 roduct Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 32

Binary multiplication without sign Multiplication 0 0 Multiplicand Iteration 4 Right shift ALU Sum Right shift 0 0 0 0 0 0 roduct 50(d Multiplier Write ontrol Tema 3. La Unidad entral de roceso. A.L.U. 33

Binary multiplication without sign Multiplication Multiplicand = 00 Multiplier = 00 roduct Multiplicand Action Iteration 0000 00 00 Initial values 0 00 00 00 Sum prod. and multiplicand 00 000 00 Right shift prod. bit 000 00 00 Right shift prod. bit 2 00 00 00 Sum prod. and multiplicand 3 00 000 00 Right shift prod. bit 3 00 000 00 Right shift prod. bit 4 Tema 3. La Unidad entral de roceso. A.L.U. 34

Fast multiplication Multiplication Tema 3. La Unidad entral de roceso. A.L.U. 35

Binary multiplication with sign Multiplication Assume two s complement numbers A = 00 y B = 00 Apply sums and shifts algorithm 0 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Wrong version Right version Tema 3. La Unidad entral de roceso. A.L.U. 36

Booth Algorithm Multiplication Assume Multiplicand = 2 and Multiplier = 7 (binaries 000 x 0) Booth expressed 7 = 8 - and replaced the multiplier by this decomposition: 0 = 000-000 = +00-0 0 0 Multiplicand x + 0 0 - Multiplier according to A. Booth 0 Multiplicand subtraction 0 0 0 0 0 0 2 shifts (2 zeros in the multiplier) 0 0 0 0 Multiplicand addition 0 0 0 0 0 Tema 3. La Unidad entral de roceso. A.L.U. 37

Booth Algorithm Multiplication urrent Bit Bit on the left Replacement 0 0 0 (no transition) 0 - (transition to negative) 0 + (transition to positive) 0 (no transition) Example: Multiplicand = 00 y Multiplier = 000 Multiplier according to Booth = +000-+-0 0 0 x + 0 0 0 - + - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Tema 3. La Unidad entral de roceso. A.L.U. 38

Booth Algorithm Multiplication q - =0 Repeat n times If q 0 = and q - = 0 then roduct h = product h - Multiplicand If q 0 = 0 and q - = then roduct h = roduct h + Multiplicand Arithmetic shift to the right of roduct and q - End repeat. Multiplicand n bits ALU Sum/Subt. Right shift roduct Multiplier q 0 q - ontrol 2n bits Tema 3. La Unidad entral de roceso. A.L.U. 39

Booth Algorithm Multiplication Multiplicand = 00 Multiplier = 0 Multiplicand roduct q - Action Itertion 00 0000 0 0 Initial values 0 00 0000 0 0 00 No operation 00 0000 0 0 Right shift 00 00 0 0 0 Subtraction 2 00 00 00 Right shift 2 00 00 00 No operation 3 00 000 00 Right shift 3 00 000 00 No operation 4 00 0000 00 Right shift 4 Tema 3. La Unidad entral de roceso. A.L.U. 40

Division Division Division can be expressed as: Dividend = Quotient x Divisor + Remainder The remainder is smaller than the divisor. Double of space should be reserved for the dividend. Assume positive operands. Dividend 0000 0 Divisor 000 00 Quotient 0 000 0 00 0 000 Remainder Tema 3. La Unidad entral de roceso. A.L.U. 4

Algorithm with restoration Division Repeat n times Shift dividend to the left Dividend h = Dividend h - Divisor If Dividend h < 0 then (does not fit) else end if end repeat q 0 =0 Dividend h = Dividend h + Divisor (restore) q 0 = Divisor n bits ALU Sum/Subt. Left shift Dividend Quotient Remainder 2n bits q 0 ontrol Tema 3. La Unidad entral de roceso. A.L.U. 42

Algorithm with restoration Division Dividend Divisor Action Iteration 00 00 00 Initial values 0 00 0_ 00 Shift bit to the left 000 0_ 00 Restar 000 0 00 Dividend h > 0 q 0 = 000 _ 00 Shift bit to the left 2 000 _ 00 Dividend h - Divisor (Subtract) 2 000 00 Dividend h > 0 q 0 = 2 00 _ 00 Shift bit to the left 3 _ 00 Dividend h - Divisor (Subtract) 3 0 00 Dividend h <= 0 q 0 = 0 3 00 0 00 Dividend h + Divisor (Restore) 3 0 0_ 00 Shift bit to the left 4 00 0_ 00 Dividend h - Divisor (Subtract) 4 00 0 00 Dividend h > 0 q 0 = 4 Rem. Quot. Tema 3. La Unidad entral de roceso. A.L.U. 43

Algorithm without restoration Division Dividend h = Dividend h - Divisor Repeat n times If Dividend h < 0 then Shift the Dividend to the left Dividend h = Dividend h + Divisor Else End if Shift the Dividend to the left Dividend h = Dividend h - Divisor If Dividend h < 0 then Else End if End repeat q 0 =0 q 0 = Divisor n bits Sum/Subt. ALU Left shift Dividend Quotient Remainder 2n bits ontrol Tema 3. La Unidad entral de roceso. A.L.U. 44 q 0

Algorithm without restoration Division Dividend Divisor Action Iteration 0000 0 000 Initial values 0 0 0 000 Dividend h - Divisor 0 00 _ 000 Dividend h < 0 Shift left 0 _ 000 Dividend h + Divisor 0 0 000 Dividend h < 0 q 0 = 0 0 0_ 000 Dividend h < 0 Shift left 2 0_ 000 Dividend h + Divisor 2 00 000 Dividend h < 0 q 0 = 0 2 00_ 000 Dividend h < 0 Shift left 3 000 00_ 000 Dividend h + Divisor 3 000 00 000 Dividend h >= 0 q 0 = 3 00 00_ 000 Dividend h > 0 Shift left 4 000 00_ 000 Dividend h - Divisor 4 000 00 000 Dividend h > 0 q 0 = 4 Remain. Quotient Tema 3. La Unidad entral de roceso. A.L.U. 45

onclusions onclusions Adders Temporal problems with arry ropagated Adder, specially if n high. arry Look-ahead Adders improve response time of the adders. Multiplication roblems with the multiplication of signed numbers. Booth algorithm allows to multiply two s complement numbers and sometimes it reduces the number of operations if there is s or 0 s chains in the multiplier. Division Algorithm with restoration for positive numbers. For negative numbers, the sign must be preprocessed. The result s sign will depend on that. Tema 3. La Unidad entral de roceso. A.L.U. 46