CSE20 Lecture 2: Number Systems: Binary Numbers and Gray Code CK Cheng 1.

Slides:



Advertisements
Similar presentations
ECE 331 – Digital System Design
Advertisements

CSE-221 Digital Logic Design (DLD)
1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.
Kavita Hatwal Fall The decimal system, also called the base 10 number system is based on ten numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. All the numbers.
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.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Number System and Codes
1 CSE 20: Lecture 7 Boolean Algebra CK Cheng 4/21/2011.
COE 202: Digital Logic Design Number Systems Part 1
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
1.6 Signed Binary Numbers.
CSE 20 Discrete Mathematics Instructor CK Cheng, CSE2130 tel: Teaching Assistants Jingwei Lu
Lecture 12: Computer Arithmetic Today’s topic –Numerical representations –Addition / Subtraction –Multiplication / Division 1.
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Basic Arithmetic (adding and subtracting)
Computer Architecture
Chapter 2 Number Systems + Codes. Overview Objective: To use positional number systems To convert decimals to binary integers To convert binary integers.
1 Problem Solving using computers Data.. Representation & storage Representation of Numeric data The Binary System.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
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.
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.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
1 CSE 20 Lecture 13: Analysis of Recursive Functions CK Cheng.
CSE 20: Lecture 7 Boolean Algebra CK Cheng
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
CEC 220 Digital Circuit Design Binary Codes
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
1 CS151 Introduction to Digital Design Chapter 1 Lecture 3.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
Addition, Subtraction, Logic Operations and ALU Design
IT1004: Data Representation and Organization Negative number representation.
Negative binary numbers 1 Computer Architectures M.
Introduction to Digital Electronics Lecture 2: Number Systems.
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
ECE 3110: Introduction to Digital Systems Number Systems: signed numbers.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
CSE20 Lecture 2: Number Systems: Binary Numbers, Gray Code, and Negative Numbers CK Cheng 1.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Introduction To Number Systems
Addition and Subtraction
Digital Logic and Computer Organization
Lecture 6: Universal Gates
COMPUTING FUNDAMENTALS
ECE 2110: Introduction to Digital Systems
CSE 140 Lecture 11 Standard Combinational Modules
The University of Adelaide, School of Computer Science
Lecture 6: Universal Gates
Binary Math Basic operations.
Data Representation – Chapter 3
EEL 3705 / 3705L Digital Logic Design
Digital Systems and Binary Numbers
CSE20 Lecture 3 Number Systems
CSE 20: Lecture 8 Boolean Postulates and Theorems CK Cheng
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic
CSE 140 Lecture 11 Standard Combinational Modules
Presentation transcript:

CSE20 Lecture 2: Number Systems: Binary Numbers and Gray Code CK Cheng 1

Number Systems 1.Introduction 2.Binary Numbers 3.Gray code 4.Negative Numbers 5.Residual Numbers 2

2. Binary Numbers: iClicker What is the extent of a binary number system A. Coverage of integer and floating point numbers B. Mechanism of addition and subtraction operations C. Operations of logic functions D. All of the above E. None of the above. 3

2. Binary Numbers 1.Definition (radix 2) 2.Enumerations (value -> index) 3.Addition (logic -> hardware) 4

2.1 Definition of Binary Numbers Format: An n digit binary number (b n-1, …, b 1, b 0 ) 2 where b i in {0,1} for 0<= i < n Value: b n-1 2 n-1 + …+b b Non-redundancy: The system is non- redundant, i.e. different binary numbers represent different values. 5

2.2 Enumeration of Binary Numbers idb2b1b0b2b1b idb1b0b1b idb0b digit2 digits3 digits4 digits? idb3b2b1b0b3b2b1b An n digit binary code covers numbers from 0 to 2 n -1.

2.2 Enumeration of binary numbers iCliker When we enumerate binary numbers (b 3 b 2 b 1 b 0 ) 2 from 0 to 15, the sequence of b 3 should be A B C D

2.3 Addition of Binary Numbers Given two binary numbers A & B, we derive binary number S so that the value of S is equal to the sum of the values of A & B, i.e. (a n-1 …,a 1 a 0 ) 2 +(b n-1 …b 1 b 0 ) 2 =(s n-1 …s 1 s 0 ) 2 Caution: Overflow, i.e. the sum is beyond the range of the representation. 8

2.3 Addition: iClicker Given two binary numbers A=(a n-1 …,a 1 a 0 ) 2 and B=(b n-1 …b 1 b 0 ) 2 what is the largest possible value of A+B? A.2 n+1 B.2 n+1 -1 C.2 n+1 -2 D.None of the above 9

2.3 Addition of Binary Numbers Equality of addition (a n-1 …,a 1 a 0 ) 2 +(b n-1 …b 1 b 0 ) 2 =(s n-1 …s 1 s 0 ) 2 That is to say a n-1 2 n-1 +…+a a b n-1 2 n-1 +…+b b =(a n-1 +b n-1 )2 n-1 +…+(a 1 +b 1 )2 1 +(a 0 +b 0 )2 0 =s n-1 2 n-1 +…+s s

2.3 Addition of Binary Numbers b2b2 b1b1 b0b0 Value Examples: 11

2.3 Addition of Binary Numbers Bit i+1 Bit i Bit i-1 Carry i+1 Carry i aiai a i-1 bibi b i-1 Sum i Sum i-1 12 Formula for Bit i: Carry i +a i +b i = 2xCarry i+1 +Sum i

2.3 Adding 2 bits in a digit ab CarrySum Formula: a+b= 2xCarry + Sum 13

2.3 Adding 3 bits in a digit idabc CarrySum Formula: a+b+c= 2xCarry + Sum 14

3. Gray Code 1.Introduction 2.Example 3.Construction 4.Comments 15

3.1 Gray Code: Introduction Gray: Frank Gray patented the code in 1947 A variation of binary code The code will be used for logic operation (CSE20, CSE140) Feature: only one bit changes for two consecutive numbers 16

3.2 Gray Code: Example 17 idb2b1b0b2b1b0 g2g1g0g2g1g idb1b0b1b0 g1g0g1g digits3 digits Note the difference of the first and last rows.

3.2 Gray Code 18 idb2b1b0b2b1b0 g2g1g0g2g1g digits idb3b2b1b0b3b2b1b0 g3g2g1g0g3g2g1g ?

3.2 Gray Code: iClicker 19 A 4-digit Gray code (g 3 g 2 g 1 g 0 ) at id=8 is written as (ref: previous page) A.(0101) B.(0110) C.(1100) D.None of the above

3.3 Gray Code: Construction Construction of n-digit Gray code from n-1 digit Gray code Copy the n-1 digit Gray code for the top 2 n-1 rows. Fill 0 at digit g n-1 in the top rows. Reflect and append the n-1 digit code for the bottom 2 n-1 rows. Fill 1 at digit g n-1 in the bottom rows. 20

3.4 Gray Code: Comments There are various codes that satisfy the Gray code feature. Gray code saves communication power when the signals are continuous in nature, e.g. addresses, analog signals Gray code facilitates code checking when the signals are supposed to be continuous in value. For arithmetic operations, we need to convert the values. 21