EEL 3705 / 3705L Digital Logic Design

Slides:



Advertisements
Similar presentations
ECE 331 – Digital System Design
Advertisements

Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor.
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Level ISA3: Information Representation
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.
1 Number Systems. 2 Numbers Each number system is associated with a base or radix – The decimal number system is said to be of base or radix 10 A number.
Number Systems and Arithmetic
Number Systems Lecture 02.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
مدار منطقي مظفر بگ محمدي Course Structure & Grading Homework: 25% Midterm: 30% Final:50% There is 5% extra! ( =105!) Textbook:
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
Number systems, Operations, and Codes
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,
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
Computer Math CPS120 Introduction to Computer Science Lecture 4.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.
FAMU-FSU College of Engineering 1 Part III The Arithmetic/Logic Unit.
Chapter 1: Binary Systems
CPEN Digital Logic Design Binary Systems Spring 2004 C. Gerousis © Digital Design 3 rd Ed., Mano Prentice Hall.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
FAMU-FSU College of Engineering 1 Computer Architecture EEL 4713/5764, Spring 2006 Dr. Michael Frank Module #9 – Number Representations.
CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.
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.
Digital logic COMP214  Lecture 2 Dr. Sarah M.Eljack Chapter 1 1.
CPE 201 Digital Design Lecture 2: Digital Systems & Binary Numbers (2)
Unit 1 Introduction Number Systems and Conversion.
Chapter 2 Binary Number Systems.
Introduction To Number Systems
Number Systems & Binary Arithmetic
Addition and Subtraction
Digital Design Chapter One Digital Systems and Binary Numbers
Data Representation.
Digital Logic and Computer Organization
Lecture No. 4 Number Systems
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
CHAPTER 1 : INTRODUCTION
CSCE 211: Digital Logic Design
Chapter 3 Data Representation
Number System conversions
Number Systems.
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
University of Gujrat Department of Computer Science
EEL 3705 / 3705L Digital Logic Design
EEL 3705 / 3705L Digital Logic Design
EEL 3705 / 3705L Digital Logic Design
Dr. Clincy Professor of CS
CSCE 211: Digital Logic Design
CSCE 211: Digital Logic Design
Data Representation in Computer Systems
Numbering System TODAY AND TOMORROW 11th Edition
CSCE 211: Digital Logic Design
Digital Logic & Design Lecture 02.
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
CSCE 211: Digital Logic Design
EEL 3705 / 3705L Digital Logic Design
Digital Systems and Binary Numbers
Information Representation
COE 202: Digital Logic Design Number Systems Part 2
Dr. Clincy Professor of CS
Presentation transcript:

EEL 3705 / 3705L Digital Logic Design Fall 2006 Instructor: Dr. Michael Frank Lecture Module #8: Radix Conversion 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Topics for Today (Fri. 1/19) Administrative announcements: Example of a design document handed out Textbook due date pushed back to next Tue. Lab #2 pushed back a week – Next week’s labs are to catch up & get started Topic: Arbitrary-radix (base-b) number systems Base-b number representations Commonly used bases in digital logic: 2, 8, 16 Arithmetic in base-b number systems Conversion between different bases 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Base Conversion Methods 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Base Conversions Some procedures for converting a number N from an old base b to a new base B: Method 0: If one of the bases is a power of the other, can do direct substitution of (groups of) digits. E.g., octal ↔ binary ↔ hex conversions work like this Otherwise: Two methods for conversion using arithmetic in the new base B: Method 1: Directly evaluate the polynomial expression for Nb. Method 2: (Horner’s rule) Repeatedly multiply by b and add digits of N, reading from left to right. Two methods for conversion using arithmetic in the old base b: Method 3: Repeatedly divide N by B, the remainders are the new digits, reading from right to left. Method 4: Repeatedly divide N by the largest power of B less than N; the quotients are the new digits, reading from left to right. Natural if new base is 10 Natural if old base is 10 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Example of Method 0 Convert 3F616 to octal. We’ll first convert to binary, then binaryoctal. Hex to binary groups of 4 bits: 3  00112, F  11112, 6  01102. The complete binary representation is: 11111101102 Binary groups of 3 bits to octal: 1  1, 111  7, 110  6, 110  6 The complete octal representation is: 17668 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Examples of Method 1 Convert 1011010112 to base 10. 1011010112 = (taking the sum from right to left) = 1×20 + 1×21 + 0×22 + 1×23 + 0×24 + 1×25 + 1×26 + 0×27 + 1×28 = 1·1 + 1·2 + 0·4 + 1·8 + 0·16 + 1·32 + 1·64 + 0·128 + 1·256 = 1 + 2 + 8 + 32 + 64 + 256 = 36310. Convert 3D9616 to base 10. 3D9616 = 3×163 + 13×162 + 9×161 + 6×160 = 3×4,096 + 13×256 + 9×16 + 6×1 = 12,288 + 3,328 + 144 + 6 = 15,76610 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Examples of Method 2 Convert 1011010112 to base 10. 1×2 + 0 = 2, ×2 + 1 = 5, ×2 + 1 = 11, ×2 + 0 = 22, ×2 + 1 = 45, ×2 + 0 = 90, ×2 + 1 = 181, ×2 + 1 = 36310. Convert 3D9616 to base 10. 3×16 = 48; +13 = 61; ×16 = 976; +9 = 985; ×16 = 15,760; +6 = 15,76610. 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Example of Method 3 (Dec.  Binary) Convert 36310 to binary. 363 ÷ 2 = 181 r 1 181 ÷ 2 = 90 r 1 90 ÷ 2 = 45 r 0 45 ÷ 2 = 22 r 1 22 ÷ 2 = 11 r 0 11 ÷ 2 = 5 r 1 5 ÷ 2 = 2 r 1 2 ÷ 2 = 1 r 0 1 ÷ 2 = 0 r 1. 1011010112 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Method 3 Variation: Tower Drawing Style Same algorithm, but without rewriting of quotients: 1011010112 0 r 1 2 1 r 0 2 2 r 1 2 5 r 1 2 11 r 0 2 22 r 1 2 45 r 0 2 90 r 1 2 181 r 1 2 363 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Example of Method 3 (Dec.  Hex) Convert 15,76610 to hexadecimal. 15,766 ÷ 16 = 985 r 6; 985 ÷ 16 = 61 r 9; 61 ÷ 16 = 3 r 13; 3 ÷ 16 = 0 r 3. 3D9616 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Example of Method 4 (Dec.  Binary) Convert 36310 to binary. 363 ÷ 256 = 1 r 107 107 ÷ 128 = 0 r 107 107 ÷ 64 = 1 r 43 43 ÷ 32 = 1 r 11 11 ÷ 16 = 0 r 11 11 ÷ 8 = 1 r 3 3 ÷ 4 = 0 r 3 3 ÷ 2 = 1 r 1 1 ÷ 1 = 1 r 0 1011010112 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Method 4 Variation When converting to binary, the divides in method 4 can be replaced by simple subtraction of the powers of 2. Example: Convert 36310 to binary. 363  256 = 107 107  64 = 43 43  32 = 11 11  8 = 3 3  2 = 1 1  1 = 0 256 128 64 32 16 8 4 2 1 1 1 1 1 1 1 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Example Where Neither Base is 10 or a Power of the Other Convert 2103  ___5 using each of methods 1-4. Method 1: N = 2·32 + 1·31 + 0·30 = 2·145 + 1·3 + 0 2·145 = 2·105 + 2·4 = 205 + 135 = 335 N = 335 + 3 = 305 + 115 = 415. Method 2: 2 · 3 = 115, + 1 = 125, · 3 = 305 + 115 = 415. Method 3: 2103 / 123 = 113 r 1, 113 / 123 = 0 r 113  415 Method 4: 2103 / 123 = 113 r 1, 1 / 1 = 1 r 0  415 Doing addition and multiplication in base 5 11 12 210 120 20 12 1 Doing division in base 3 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Another Way (Method 5) When converting between two bases neither of which is base 10 or a power of the other, you might find the following strategy easier than using any of methods 1-4 directly: First, convert from the old base to base 10 using either method 1 or 2 Next, convert from base 10 to the new base using either method 3 or 4. 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Example of Method 5 Convert 2103  ___5 using method 5. First use method 1 to convert to base 10: 2103 = 2·32 + 1·31 + 0·30 = 2·9 + 3 + 0 =18+3= 2110 Next use method 4 to convert to base 5: 2110 ÷ 5 = 4 r 1  415 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

A Modular Circuit to Convert from Base 2 to Base 10 (Binary to BCD) We do division in old base (base 2). This can be viewed as using method 3 or 4. (Pull up bin_to_bcd project in Quartus to see details better.) 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

A different circuit for converting base 2 to base 10, using method 1 We can do the arithmetic in “base 10” by using special BCD adders… Add up powers of 2 represented in binary-coded decimal… Constants encoding the various powers of two in BCD 64 32 16 08 04 02 01 n6..0 n6 n5 n4 n3 n2 n1 n0 BCD + BCD + BCD + BCD + Each of these buses holds two 4-bit BCD digits Each of these adders adds two 2-digit BCD numbers BCD + bcd13..0, bcd03..0 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Fixed-Width Binary Arithmetic and Overflow 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Fixed-Width Binary Arithmetic In digital systems, usually there is only a fixed number n of bits of storage immediately available to represent a given arithmetic result. What happens if the numeric value of the desired result doesn’t fit in the given number of bits? The usual behavior of hardware is just to truncate the result, in other words to discard some of the extra bits, usually on the left… This is equivalent to using “modulo 2n” arithmetic. We should be aware of when this procedure will lead to a different numeric result than regular arithmetic. In other words, we should know the overflow conditions. 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Modulo-m arithmetic In modulo-m arithmetic, all numeric results are projected onto a value in the range [0,m). Namely, the remainder when dividing by m. Example: 4+3 = 7 ≡ 2 (mod 5) Since 7/5 = 1 r 2. We can visualize the ordinary number line as laid out along a spiral straddling lines representing the different possible mod-m values. ≡ 0 (mod 5) 20 15 ≡ 1 (mod 5) 10 ≡ 4 (mod 5) 19 5 21 14 16 9 11 4 6 1 3 2 8 7 13 12 18 17 22 ≡ 2 (mod 5) ≡ 3 (mod 5) Visualization of number line in modulo-5 arithmetic 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Modulo 2n arithmetic Fixed-width binary arithmetic with n bits is equivalent to modulo 2n arithmetic. Discarding the leftmost bits projects us onto one of the arms of the spiral. An “overflow” happens when we wrap around and leave the innermost arm of the spiral. Crossing the dotted red line… It’s like how your car odometer rolls over after 100,000 miles. 00 100 00 11 111 11 01 101 01 10 110 10 2-bit truncation spiral 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

M. Frank, EEL3705 Digital Logic, Fall 2006 Number Wheel Diagrams We can represent modulo arithmetic using a “number wheel” picture Think of this as similar to a roulette wheel, or the face of a clock As you wrap around past the overflow marker, you start repeating the same numbers over again. overflow marker 1 7 000 111 001 6 2 110 010 101 011 5 3 100 4 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006

Unsigned Overflow Example Suppose we are doing fixed-width, unsigned binary arithmetic in three bits, and we add the numbers 5 and 3. What is the result, and is there an overflow? Expressed in 3 bits, 5 = 1012, 3 = 0112. Carry out the addition shown at right. The result is 10002 = 8, which does not fit in 3 bits. The leftmost 1 gets truncated away, leaving 000 as the result. So yes, there is an overflow! Addition causes an overflow whenever there is a carry out of the highest-order bit position. 1 1 1 101 + 011 1000 11/28/2018 M. Frank, EEL3705 Digital Logic, Fall 2006