Lecture 2 Number Representation, Overflow and Logic Topics Adders Math Behind Excess-3 Overflow Unsigned, signed-magnitude Two’s Complement Gray Code Boolean.

Slides:



Advertisements
Similar presentations
CHAPTER 2 Number Systems, Operations, and Codes
Advertisements

Digital Fundamentals Floyd Chapter 2 Tenth Edition
Chapter 1 Number Systems and Codes
Major Numeric Data Types Unsigned Integers Signed Integer Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
Assembly Language and Computer Architecture Using C++ and Java
Chapter 3 Data Representation.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
Storage of Bits Computers represent information as patterns of bits
Major Numeric Data Types Unsigned Integers Signed Integers Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
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.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Overflow Signed binary is in fixed range -2 n-1  2 n-1 If the answer for addition/subtraction more than the.
Number System and Codes
Information Representation and Number Systems BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
CS 105 Digital Logic Design
1.6 Signed Binary Numbers.
Chapter 5 Data representation.
© 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
Computers Organization & Assembly Language
Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
Digital Systems and Logic Design
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
Logic and Digital System Design - CS 303
IT253: Computer Organization
Computer Architecture
Topic 2 – Introduction to Computer Codes. Computer Codes A code is a systematic use of a given set of symbols for representing information. As an example,
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Data Representation.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Lecture 1 Binary Representation Topics Terminology Base 10, Hex, binary Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement.
Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7× × × ×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
Number Systems ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
ECE 2110: Introduction to Digital Systems BCD, Gray, Character, Action/Event, Serial Data.
ECE 3110: Introduction to Digital Systems unsigned Multiplication/Division codes.
1 Lecture 3 ENGRE 254 1/14/09. 2 Lecture 1 review Digital signals assume two values represented by “0” and “1”. Typically a “0” represents a voltage near.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Digital Circuits Text Book –M. M. Mano, "Digital Design," 3rd Ed., Prentice Hall Inc., Reference –class notes Grade –quizzes:15% –mid-term:27.5%
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
CEC 220 Digital Circuit Design Binary Codes
Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Lecture 3 Combinational Circuits
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
Chapter 1: Binary Systems
Number Representation and Arithmetic Circuits
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
Lecture 3 Boolean algebra Topics Error Correcting Codes Boolean algebra Combinational circuits Algebraic analysis, Truth tables, Logic Diagrams Sums-of-Products.
CS2100 Computer Organisation
Lecture No. 4 Number Systems
University of Gujrat Department of Computer Science
Lecture 3 Boolean algebra
Digital Logic & Design Lecture 03.
ECE 331 – Digital System Design
Presentation transcript:

Lecture 2 Number Representation, Overflow and Logic Topics Adders Math Behind Excess-3 Overflow Unsigned, signed-magnitude Two’s Complement Gray Code Boolean Logic August 26, 2015 CSCE 211 Digital Design

– 2 – CSCE 211H Fall 2015 Last Time:! Base R  Base 10 conversions Base R  Base 10 Base 10  Base R Base 10 fractions  Base R fractions Ripple carry adder Signed Magnitude Two’s complementNew: Things from last Lecture: Slides Two’s Complement arithmetic Basic Gates: AND, OR, NOT, XOR, NOR, NAND Adders Binary Coded Decimal Two’s Complement Overflow Gray Code Boolean LogicHomework 1) Two’s complement of 87, and 2) Two’s complement of -43, 3) 2.26 (sign extension), and 4) 2.29, sc.edu

– 3 – CSCE 211H Fall 2015

– 4 – CSCE 211H Fall 2015

– 5 – CSCE 211H Fall 2015

– 6 – CSCE 211H Fall 2015 Octal Arithmetic

– 7 – CSCE 211H Fall 2015 Ripple Carry Adder

– 8 – CSCE 211H Fall 2015 Excess n code Excess-3 code Excess-127 code for IEEE 754 floating point

– 9 – CSCE 211H Fall 2015 Excess-3 Code for Decimals Justification ex3[7] = 1010 // excess-3 representation ex3[7] = 1010 // excess-3 representation +ex3[4] = ex3[4] = // carry=1, sum=0001 not correct ex3 // it should be 0100 which is So if there is a carry then we should correct the sum by adding 3. The math behind this is If x + y >= 10 then ex3[x] +ex3[y] = bcd[x] bcd[y] + 3 But since x+y =bcd[x] + bcd[y] >= 10 we have ex3[x] +ex3[y] = bcd[x]+bcd[y] + 6 >= = 16 So the carry is correct but the sum digit = (ex3[x] +ex3[y]) mod 16 = (bcd[x]+bcd[y] +6) - 16 So the sum digit is the correct bcd of (x+y) but not excess-3 so we need to add 3.

– 10 – CSCE 211H Fall 2015 Excess-3 Code for Decimals Justification ex3[2] = 0101 // excess-3 representation ex3[2] = 0101 // excess-3 representation +ex3[6] = ex3[6] = So if there is no carry then we should correct the sum by... And the math in this case: If x + y < 10 then ex3[x] + ex3[y] =

– 11 – CSCE 211H Fall 2015 Why Excess-3 Code for Decimals ?

– 12 – CSCE 211H Fall 2015 IEEE 754 floating pt – Excess 127 IEEE 754 single-precision binary floating-point format: binary32 The IEEE 754 standard specifies a binary32 as having: Sign bitSign bit: 1 bit Sign bit ExponentExponent width: 8 bits Exponent SignificandSignificand precision: 24 bits (23 explicitly stored) precision Significandprecision

– 13 – CSCE 211H Fall 2015 One more example …000

– 14 – CSCE 211H Fall 2015 Special Exponents Expfield = e  expField = expField =

– 15 – CSCE 211H Fall 2015 Floating point demographics How many 32 bit IEEE754 floats are there? Easier question first how many positive floats with expField = ?

– 16 – CSCE 211H Fall 2015 Floating point operations AdditionMultiplication

– 17 – CSCE 211H Fall 2015 What is overflow? In general what does overflow mean? For unsigned integers? Examples For signed magnitude or two’s complement what does overflow mean? For floats? Underflow?

– 18 – CSCE 211H Fall 2015 Overflow in Two’s Complement x n x n-1 x n-2 …x 2 x 1 x 0 +y n y n-1 y n-2 …y 2 y 1 y 0 s n+1 s n s n-1 s n-2 …s 2 s 1 s 0 Overflow Case 1 positive + positive = negative !? Meaning of course that the sign bits of both addends is 0 and the sign bit of the sum is 1 Case 2 …

– 19 – CSCE 211H Fall 2015 Gray Code In some mechanical devices you want to encode positions as binary strings in such a way that positions close to each other are represented by strings that are close together. Gray code – adjacent positions differ in only one bit Figure 2-6 encoding disk

– 20 – CSCE 211H Fall 2015 Construction of Gray Codes Gray Codes are reflective Algorithm for construction of Gray Codes on n-bits  A 1-bit Gray code has two words 0 and 1.  The first 2n words of an (n+1)-bit gray code are the words of the n-bit gray code with a leading 0 added.  The next 2n words of an (n+1)-bit gray code are the words of the n-bit gray code but written in reverse order with a leading 1 added.

– 21 – CSCE 211H Fall 2015 Construction of Gray Codes 1-bit gray code bit gray code bit gray code bit gray code 0 000

– 22 – CSCE 211H Fall 2015 Representations of Characters How many characters do we need to represent? How many bits does this take ? ASCIIUNICODE

– 23 – CSCE 211H Fall 2015 Codes representing characters ASCII - American Standard Code for Information Interchange 8 bits = 7 + parity ASCII table in chapter 2, (Table 2-11) 32 Control characters + 96 printable characters Unicode 16 bits

– 24 – CSCE 211H Fall 2015 N-cubes 1-cube2-cube3-cube Traversing in gray-code order

– 25 – CSCE 211H Fall 2015 Parity Bits Even parity bit – parity bit is set so that the number of ones is even Odd parity bit

– 26 – CSCE 211H Fall 2015 Error Correcting codes For an n-bit code, consider the hypercube of dimension n Choose some subset of the nodes as code words. Suppose the distance between any two two code words is at least 3. Now consider transmission errors. Then if there is an error in transmitting just one bit then the distance from the received word to one code word is one, distances to other code words are at least two. Single error correcting, double error detecting. Such codes are called Hamming codes after their inventor Richard Hamming.

– 27 – CSCE 211H Fall 2015 Boolean Algebra George Boole (1854) invented a two valued algebra To “give expression … to the fundamental laws of reasoning in the symbolic language of a Calculus.” 1938 Claude Shannon at Bell Labs noted that this Boolean logic could be used to describe switching circuits. (Switching Algebra) In Shannon’s view a relay has two positions open and closed representing 1 and 0. Collections of relays satisfied the properties of Boolean algebra.

– 28 – CSCE 211H Fall 2015 Homework Set 2 1.What is the representation of the maximum unsigned integer using 12 bits? a) Representation (string of 12 bits) (b) value in decimal 2.What is the representation of the maximum two’s complement integer using 12 bits? a) Representation (string of 12 bits) (b) value in decimal b) What is the representation of -37 in two’s complement using 12 bits? c) Representation (string of 12 bits) (b) value in decimal 3.IEEE bit float a) What is the representation and value of the largest (non infinite) float? b) What is the representation of as a IEEE 754 float? c) How many floats are there >= 16 ? d) Are there more positive floats > 16 or < 16?