ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Similar documents
Chapter 4 Arithmetic Functions

Chapter 3: part 3 Binary Subtraction

Chapter 3 Part 2 Combinational Logic Design

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Chapter 3 Part 2 Combinational Logic Design

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

World Inside a Computer is Binary

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Chapter 10 Binary Arithmetics

Digital Systems and Binary Numbers

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Chapter 1. Digital Systems and Binary Numbers

Lecture (02) Operations on numbering systems

EE 109 Unit 6 Binary Arithmetic

MC1601 Computer Organization

Number System. Introduction. Decimal Numbers

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Korea University of Technology and Education

Chapter 4 Arithmetic

Computer Organization

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Chapter 2: Number Systems

Chapter 1 Review of Number Systems

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

CS 261 Fall Mike Lam, Professor Integer Encodings

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Number Systems Base r

Chapter 5: Computer Arithmetic

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

Part 2,Number Systems Questions

COMPUTER ARITHMETIC (Part 1)

CO Computer Architecture and Programming Languages CAPL. Lecture 9

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

Principles of Computer Architecture. Chapter 3: Arithmetic

*Instruction Matters: Purdue Academic Course Transformation. Introduction to Digital System Design. Module 4 Arithmetic and Computer Logic Circuits

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

BINARY SYSTEM. Binary system is used in digital systems because it is:

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

Introduction to Computer Science. Homework 1

Numbering systems. Dr Abu Arqoub

Final Exam Solution Sunday, December 15, 10:05-12:05 PM

Number Systems CHAPTER Positional Number Systems

Arithmetic Operations

Arithmetic Operations on Binary Numbers

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Chap.3 3. Chap reduces the complexity required to represent the schematic diagram of a circuit Library

Fundamentals of Programming Session 2

Digital Systems and Binary Numbers

CHW 261: Logic Design

CO212 Lecture 10: Arithmetic & Logical Unit

DIGITAL SYSTEM DESIGN

SE311: Design of Digital Systems

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

COMP2611: Computer Organization. Data Representation

COMPUTER ORGANIZATION AND ARCHITECTURE

Electronics Engineering ECE / E & T

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

carry in carry 1101 carry carry

Number Systems. Both numbers are positive

Binary Systems and Codes

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

Chapter 10 - Computer Arithmetic

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

Arithmetic Processing

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

Chapter 5 Design and Implementation of a Unified BCD/Binary Adder/Subtractor

Advanced Computer Architecture-CS501

CS 64 Week 1 Lecture 1. Kyle Dewey

COMP 122/L Lecture 2. Kyle Dewey

Positional Number System

Lecture 2: Number Systems

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Representation of Non Negative Integers

Digital Fundamentals

D I G I T A L C I R C U I T S E E

Numeric Encodings Prof. James L. Frankel Harvard University

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

Binary Adders: Half Adders and Full Adders

Binary Arithmetic. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T.

in this web service Cambridge University Press

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Chapter 2 Bits, Data Types, and Operations

Signed umbers. Sign/Magnitude otation

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Chapter 2. Data Representation in Computer Systems

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

ECE 30 Introduction to Computer Engineering

CS101 Lecture 04: Binary Arithmetic

Chapter 5 : Computer Arithmetic

Microcomputers. Outline. Number Systems and Digital Logic Review

Chapter 2 Bits, Data Types, and Operations

Transcription:

University of Wisconsin - Madison ECE/Comp Sci 352 Digital Systems Fundamentals Charles R. Kime Section 2 Fall 2001 Chapter 3 Combinational Logic Design Part 4 Charles Kime & Thomas Kaminski Complements ƒ Subtraction of numbers requires a different algorithm from that for addition ƒ Adding the complement of a number is equivalent to subtraction ƒ We will discuss two complements: Diminished Radix Complement Radix Complement ƒ Subtraction will be done by adding the complement of the subtrahend Chapter 3-Part 4 2 1

Diminished Radix Complement ƒ Given a number N in Base r having n digits, the (r 1) s-complement (called the Diminished Radix Complement) is defined as: (r n 1) N ƒ Example: For r = 10, N = 123410, n = 4 (4 digits),we have: (r n 1) = 10,000 1 = 999910 The 9's complement of 123410 is then: 999910-123410 = 876510 Chapter 3-Part 4 3 Binary 1's Complement ƒ For r = 2, N = 01110011 2, n = 8 (8 digits): (r n 1) = 256-1 = 255 10 or 11111111 2 ƒ The 1's complement of 01110011 2 is then: 11111111 01110011 10001100 ƒ Since the 2 n 1 factor consists of all 1's and since 1 0 = 1 and 1 1 = 0, the one's complement is obtained by complementing each individual bit (bitwise NOT). Chapter 3-Part 4 4 2

Radix Complement ƒ ƒ ƒ Given a number N in Base r having n digits, the r's complement (called the radix complement) is defined as: r n N for N 0 and 0 for N = 0 The radix complement is obtained by adding 1 to the diminished radix complement Example: For r = 10, N = 1234 10, n = 4 (4 digits), we have: r n = 10,000 10 The 10's complement of 1234 is then 10,000-1234 = 8766 10 or 8765 + 1 (9's complement plus 1) Chapter 3-Part 4 5 Binary 2's Complement ƒ For r = 2, N = 01110011 2, n = 8 (8 digits), we have: (r n ) = 25610 or 1000000002 ƒ The 2's complement of 01110011 is then: 100000000 01110011 10001101 ƒ Note the result is the 1's complement plus 1 Chapter 3-Part 4 6 3

Alternate 2 s Complement ƒ Given: an n-bit binary number, beginning at the right and proceeding left: Copy all least significant 0 s Copy the first 1 Complement all bits thereafter. ƒ 2 s Complement Example: 10010100 Copy underlined bits: 100 and complement bits to the left: 01101100 Chapter 3-Part 4 7 Subtraction with Radix Complements ƒ For n-digit, unsigned numbers M and N, find M N in base r: Add the r's complement of the subtrahend N to the minuend M: M + (r n N) = M N + r n If M > N, the sum produces end carry r n which is discarded; from above, M N remains. If M < N, the sum does not produce an end carry and, from above, is equal to r n ( N M ), the r's complement of ( N M ). To obtain the result (N M), take the r's complement of the sum and place a in front. Chapter 3-Part 4 8 4

Unsigned 10 s Complement Subtraction Example 1 ƒ Find 543 10 123 10 543 1 543 123 10 s comp + 877 420 ƒ The carry of 1 indicates that no correction of the result is required. Chapter 3-Part 4 9 Unsigned 10 s Complement Subtraction Example 2 ƒ Find 123 10 543 10 0 123 123 10 s comp 543 + 457 10 s comp 580 520 ƒ The carry of 0 indicates that a correction of the result is required. ƒ Result = (520) Chapter 3-Part 4 10 5

Unsigned 2 s Complement Subtraction Example 1 ƒ Find 01010100 2 01000011 2 01010100 1 01010100 2 s comp 01000011 + 10111101 00010001 ƒ The carry of 1 indicates that no correction of the result is required. Chapter 3-Part 4 11 Unsigned 2 s Complement Subtraction Example 2 ƒ Find 01000011 2 01010100 2 01000011 001000011 01010100 2 s comp + 10101100 11101111 00010001 ƒ The carry of 0 indicates that a correction of the result is required. ƒ Result = (00010001) 2 s comp Chapter 3-Part 4 12 6

Subtraction with Diminished Radix Complement ƒ For n-digit, unsigned numbers M and N, find M N in base r: Add the (r 1)'s complement of the subtrahend N to the minuend M: M + (r n 1 N) = M N + r n 1 If M > N, the result is excess by r n 1. The end carry r n when discarded removes r n, leaving a result short by 1. To fix this shortage, whenever and end carry occurs we all 1 in the LSB position. This is called end-around carry. If M < N, the sum does not produce an end carry and, from above, is equal to r n 1 ( N M ), the r 1 's complement of ( N M ). To obtain the result (N M), take the r 1 's complement of the sum and place a in front. Chapter 3-Part 4 13 Unsigned 1 s Complement Subtraction Example 1 ƒ Find 01010100 2 01000011 2 01010100 1 01010100 1 s comp 01000011 + 10111100 00010000 +1 00010001 ƒ The end-around carry occurs. Chapter 3-Part 4 14 7

Unsigned 1 s Complement Subtraction Example 2 ƒ Find 01000011 2 01010100 2 01000011 0 01000011 01010100 1 s comp + 10101011 11101110 00010001 ƒ The carry of 0 indicates that a correction of the result is required. ƒ Result = (00010001) 1 s comp Chapter 3-Part 4 15 Signed Integers ƒpositive numbers and zero can be represented by unsigned n-digit, radix r numbers. We need a representation for negative numbers. ƒto represent a sign (+ or ) we need exactly one more bit of information (1 binary digit gives 2 1 = 2 elements which is exactly what is needed). ƒsince computers use binary numbers, by convention, (and, for convenience), the most significant bit is interpreted as a sign bit: s a n 2 a 2 a 1 a 0 where: s = 0 for Positive numbers s = 1 for Negative numbers and a i = 0 or 1 represent in some form the magnitude. Chapter 3-Part 4 16 8

Signed Integer Representations ƒsigned-magnitude here the n 1 digits are interpreted as a positive magnitude. ƒsigned-complement here the digits are interpreted as the rest of the complement of the number. There are two possibilities here: ƒsigned One's Complement Uses 1's Complement Arithmetic ƒsigned Two's Complement Use 2's Complement Arithmetic Chapter 3-Part 4 17 Signed Integer Representation Example ƒ r =2, n=3 Number Sign -Mag. 1's Comp. 2's Comp. +3 011 011 011 +2 010 010 010 +1 001 001 001 +0 000 000 000 0 100 111 1 101 110 111 2 110 101 110 3 111 100 101 4 100 Chapter 3-Part 4 18 9

Signed-Magnitude Arithmetic ƒ Addition: If signs are the same: 1. Add the magnitudes. 2. Check for overflow (a carry into the sign bit). 3. The sign of the result is the same. If the signs differ: 1. Subtract the subtrahend from the minuend 2. If a borrow occurs, take the two s complement of result and make the sign the complement of the sign of the minuend. 3. Overflow will never occur. ƒ Subtraction: Complement the sign bit of the number you are subtracting and follow the rules for addition. Chapter 3-Part 4 19 Sign-Magnitude Examples Chapter 3-Part 4 20 10

Signed-Complement Arithmetic ƒ Addition: 1. Add the numbers including the sign bits, discarding a carry out of the sign bits (2's Complement), or using an end-around carry (1's Complement). 2. If the sign bits were the same for both numbers and the sign of the result is different, an overflow has occurred. 3. The sign of the result is computed in step 1. ƒ Subtraction: Form the complement of the number you are subtracting and follow the rules for addition. Chapter 3-Part 4 21 Signed 2 s Complement Examples Chapter 3-Part 4 22 11

Signed 1 s Complement Examples Chapter 3-Part 4 23 2 s Complement Adder/Subtractor ƒ Subtraction can be accomplished by addition of the Two's Complement. 1. Complement each bit (One's Comp.) 2. Add one to the result. ƒ The following circuit computes A - B: ƒ When the Carry-In is 1, the 2 s comp of B is formed using XORs to form the 1 s comp and adding the 1 on A(3) B(3) x y C(0). Co Ci A(2) A(1) A(0) B(2) B(1) B(0) C(0) C(4) C(3) x y C(2) x y C(1) x FA Co FA Ci Co FA Ci Co S S S FA S y Ci S(3) S(2) S(1) S(0) Chapter 3-Part 4 24 12