1 Binary Coded Decimal Presented By Chung Wai Chow.

Slides:



Advertisements
Similar presentations
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Advertisements

Chapter 2 : Number System
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of numbers:
UNIVERSITY OF MASSACHUSETTS Dept
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Number System and Codes
ECE 645 – Computer Arithmetic Lecture 9: Basic Dividers ECE 645—Computer Arithmetic 4/1/08.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Arithmetic for Computers
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Conversion Between Lengths Positive number pack with leading zeros +18 = = Negative numbers pack with leading ones -18 =
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Chapter 8 Problems Prof. Sin-Min Lee Department of Mathematics and Computer Science.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Number Systems. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
Topic 1 – Number Systems. What is a Number System? A number system consists of an ordered set of symbols (digits) with relations defined for addition,
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Combinational Circuits
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
Integer Operations Computer Organization and Assembly Language: Module 5.
Chapter 8 Computer Arithmetic. 8.1 Unsigned Notation Non-negative notation  It treats every number as either zero or a positive value  Range: 0 to 2.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
COMPUTER ARITHMETIC Binary Coded Decimal Presented By Chung Wai Chow.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Multiplication and Division basics
Addition and Subtraction
Array multiplier TU/e Processor Design 5Z032.
Digital Logic and Computer Organization
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
William Stallings Computer Organization and Architecture 7th Edition
Chapter 1 Number Systems, Number Representations, and Codes
University of Maryland
Computer Organization and Design
Arithmetic Logical Unit
ECEG-3202 Computer Architecture and Organization
ECE 331 – Digital System Design
Presentation transcript:

1 Binary Coded Decimal Presented By Chung Wai Chow

2 Binary Coded Decimal Introduction: Although binary data is the most efficient storage scheme; every bit pattern represents a unique, valid value. However, some applications may not be desirable to work with binary data. For instance, the internal components of digital clocks keep track of the time in binary. The binary value must be converted to decimal before it can be displayed.

3 Binary Coded Decimal Because a digital clock is preferable to store the value as a series of decimal digits, where each digit is separately represented as its binary equivalent, the most common format used to represent decimal data is called binary coded decimal, or BCD.

4 1.The BCD format 2.Algorithms for addition 3.Algorithms for subtraction 4.Algorithms for multiplication 5.Algorithms for division Explanation of Binary Coded Decimal (BCD):

5 1) BCD Numeric Format Every four bits represent one decimal digit.  Use decimal values from 0 to 9

6  4-bit values above 9 are not used in BCD. 1) BCD Numeric Format The unused 4-bit values are: BCDDecimal

7 1) BCD Numeric Format Multi-digit decimal numbers are stored as multiple groups of 4 bits per digit.

8 1) BCD Numeric Format BCD is a signed notation  positive or negative. For example, +27 as 0(sign) as 1(sign)  BCD does not store negative numbers in two’s complement.

9 1) BCD Numeric Format Values represented b3b2b1b0b3b2b1b0 Sign and magnitude1’s complement2’s complement

10 2) Algorithms for Addition  1100 is not used in BCD.

11 2) Algorithms for Addition Two errors will occurs in a standard binary adder. 1) The result is not a valid BCD digit. 2) A valid BCD digit, but not the correct result. Solution: You need to add 6 to the result generated by a binary adder.

12 2) Algorithms for Addition A simple example of addition in BCD Incorrect BCD digit Add 6 Correct answer 1 4

13 2) Algorithms for Addition A BCD adder = = 4 If the result, S 3 S 2 S 1 S 0, is not a valid BCD digit, the multiplexer causes 6 to be added to the result.

14 A simple example of subtraction 3) Algorithms for Subtraction (+7) (- 3) (+4) 0011 is 3, the one’s complement is Each of the computations adds 1 to the one’s complement to produce the two’s complement of the number = 1101 The two’s complement of 3 is 1101

15 3) Algorithms for Subtraction The second change has to do with complements.  The nine’s complement in BCD, generated by subtracting the value to be complemented from another value that has all 9 S as its digits. Adding one to this value produces the ten’s complement, the negative of the original value. e.g, the nine’s complement of 631 is 999 – 631 = = 369 is the ten’s complement

16  The ten’s complement plays the subtraction and negation for BCD numbers. 3) Algorithms for Subtraction Hareware generates the nine’s complement of a single BCD digit.

17 Conclusion for addition and subtraction Using a BCD adder and Nine’s complement generation hardware to compute the addition and the subtraction for signed-magnitude binary numbers The algorithm for adding and subtracting as below: PM’1: U S X S, CU X + Y PM1: CU X + Y’ + 1, OVERFLOW 0 PM’2: OVERFLOW C

18 The algorithm for adding and subtracting CZ’PM2: U S X S CZPM2: U S 0 C’PM2: U S X’ S, U U’ + 1 2: FINISH 1

19 Example of addition of BCD numbers U S U = X S X + Y S Y X S X = +33 = Y S Y = +25 = PM’1: U S 0, CU PM’2: OVERFLOW 0 Result: U S U = = +58

20 Example of subtraction of BCD numbers U S U = X S X + Y S Y X S X = +27 = Y S Y = -13 = PM1: CU , OVERFLOW 0 CZ’PM2: U S 0 Result: U S U = = +14

21 4) Algorithms for Multiplication 1101 Multiplicand M X 1011 Multiplier Q ____ Product P

22 4) Algorithms for Multiplication Multiplicand Multiplier Product

23 4) Algorithms for Multiplication Required to use the BCD adder and nine’s complement circuitry. In BCD, each digit of the multiplicand may have any value from 0 to 9; each iteration of the loop may have to perform up to nine additions. We must incorporate an inner loop in the algorithm for these multiple additions. In addition, use decimal shifts right operation (dshr), which shift one BCD digit, or four bits at a time.

24 The BCD multiplication algorithm 1: U S X S +Y S, V S X S +Y S, U 0, i n, C d 0 Z Y0 ’2: C S U C d U + X, Y d0 Y d0 – 1, GOTO 2 Z Y0 2: i i - 1 3: dshr (C d UV), dshr (Y) Z’3: GOTO 2 ZT3: U S 0, V S 0 Z3: FINISH 1 4) Algorithms for Multiplication

25 4) Algorithms for Multiplication

26 Division can be implemented using either a restoring or a non-restoring algorithm. An inner loop to perform multiple subtractions must be incorporated into the algorithm. 5) Algorithms for Division ) _ 10

27 5) Algorithms for Division A logic circuit arrangement implements the restoring-division technique

28 A restoring-division example Initially Shift Subtract Set q Restore Shift Subtract Set q Restore Shift Subtract Set q Shift Subtract Set q Restore remainder Quotient First cycle Second cycle Third cycle Fourth cycle

29 5) Algorithms for Division The restoring-division algorithm: S1: DO n times Shift A and Q left one binary position. Subtract M from A, placing the answer back in A. If the sign of A is 1, set q 0 to 0 and add M back to A (restore A); otherwise, set q 0 to 1.

30 5) Algorithms for Division The non-restoring division algorithm: S1: Do n times If the sign of A is 0, shift A and Q left one binary position and subtract M from A; otherwise, shift A and Q left and add M to A. S2: If the sign of A is 1, add M to A.

31 References: Computer Systems Organization & Architecture, Addison Wesley Longman, Inc., 2001 Introduction to Computer Organization 4 th Edition. V.Carl hamacher Thank you