ECE 372 Microcontroller Design

Similar documents
ECE260: Fundamentals of Computer Engineering

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

Conversions between Decimal and Binary

ECE380 Digital Logic. Positional representation

ENGIN 112 Intro to Electrical and Computer Engineering

Week No. 06: Numbering Systems

How do computers represent numbers?

Chapter 1 CSCI

Menu. Review of Number Systems EEL3701 EEL3701. Math. Review of number systems >Binary math >Signed number systems

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

Ex code

Four Important Number Systems

CSE 241 Digital Systems Spring 2013

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

Combinational Logic. By : Ali Mustafa

NUMBER SYSTEMS. and DATA REPRESENTATION. for COMPUTERS (PROBLEM ANSWERS)

Computer Arithmetic. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Computer Arithmetic

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers

Number Representation and Waveform Quantization

Midterm Examination # 1 Wednesday, February 25, Duration of examination: 75 minutes

Total Time = 90 Minutes, Total Marks = 100. Total /10 /25 /20 /10 /15 /20

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1

convert a two s complement number back into a recognizable magnitude.

Digital Systems and Information Part II

E&CE 223 Digital Circuits & Systems. Winter Lecture Transparencies (Introduction) M. Sachdev

ENG2410 Digital Design Introduction to Digital Systems. Fall 2017 S. Areibi School of Engineering University of Guelph

hexadecimal-to-decimal conversion

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

Chapter 4 Number Representations

Introduction to Digital Logic Missouri S&T University CPE 2210 Number Systems

Binary Floating-Point Numbers

Introduction to Digital Logic Missouri S&T University CPE 2210 Number Systems

Unit 3. Digital encoding

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Computer Architecture, IFE CS and T&CS, 4 th sem. Representation of Integer Numbers in Computer Systems

Review for Test 1 : Ch1 5

CPE100: Digital Logic Design I

DSP Design Lecture 2. Fredrik Edman.

JNTU World. Digital Logic Design. Introduction

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

CHAPTER 2 NUMBER SYSTEMS

Binary addition example worked out

Cs302 Quiz for MID TERM Exam Solved

Fundamentals of Digital Design

Lecture 2 Review on Digital Logic (Part 1)

ENGIN 112 Intro to Electrical and Computer Engineering

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit

0,..., r 1 = digits in radix r number system, that is 0 d i r 1 where m i n 1

of Digital Electronics

12/31/2010. Digital Operations and Computations Course Notes. 01-Number Systems Text: Unit 1. Overview. What is a Digital System?

Chapter 1 Error Analysis

Number Representations

Introduction to Digital Logic Missouri S&T University CPE 2210 Subtractors

8/13/16. Data analysis and modeling: the tools of the trade. Ø Set of numbers. Ø Binary representation of numbers. Ø Floating points.

E40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

Numbers and Arithmetic

Design of Digital Circuits Reading: Binary Numbers. Required Reading for Week February 2017 Spring 2017

10/14/2009. Reading: Hambley Chapters

NUMBERS AND CODES CHAPTER Numbers

FYSE410 DIGITAL ELECTRONICS [1] [2] [3] [4] [5] A number system consists of an ordered set of symbols (digits).

UNIT II COMBINATIONAL CIRCUITS:

Design of Sequential Circuits

Why digital? Overview. Number Systems. Binary to Decimal conversion

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

Mark Redekopp, All rights reserved. Lecture 1 Slides. Intro Number Systems Logic Functions

Systems I: Computer Organization and Architecture

Complement Arithmetic

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

What does such a voltage signal look like? Signals are commonly observed and graphed as functions of time:

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q

CSE 20 DISCRETE MATH. Winter

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

Number Theory: Representations of Integers

Introduction to digital systems. Juan P Bello

COMBINATIONAL LOGIC FUNCTIONS

Next, we include the several conversion from type to type.

Unit II Chapter 4:- Digital Logic Contents 4.1 Introduction... 4

Numbers and Arithmetic

Computer Organization I Test 1/Version 1 CMSC 2833 Autumn 2007

Chapter 4: Combinational Logic Solutions to Problems: [1, 5, 9, 12, 19, 23, 30, 33]

Chapter 1. Binary Systems 1-1. Outline. ! Introductions. ! Number Base Conversions. ! Binary Arithmetic. ! Binary Codes. ! Binary Elements 1-2

1 Computing System 2. 2 Data Representation Number Systems 22

Lecture 2: Number Representations (2)

Save from: cs. Logic design 1 st Class أستاذ المادة: د. عماد

SAMPLE ANSWERS MARKER COPY

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 2 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CS6201 DIGITAL PRINCIPLES AND SYSTEM DESIGN

CHW 261: Logic Design

LOGIC CIRCUITS. Basic Experiment and Design of Electronics

SAU1A FUNDAMENTALS OF DIGITAL COMPUTERS

Digital Logic (2) Boolean Algebra

Numerical Analysis and Computing

Representing Numbers on the Computer

A crash course in Digital Logic

LOGIC GATES. Basic Experiment and Design of Electronics. Ho Kyung Kim, Ph.D.

Solutions - Homework 1 (Due date: September 25 th ) Presentation and clarity are very important! Show your procedure!

Sample Marking Scheme

Transcription:

Data Formats Humor There are 10 types of people in the world: Those who get binary and those who don t. 1

Information vs. Data Information An abstract description of facts, processes or perceptions How can we represent information? How can we represent changing information? We need to associate different values with different events Data Individual fact value or set of facts or values Measurement or storage September 19 th October 28, 2010 $250 1.8 Trillion Information vs. Data Information vs. Data Information is data with context or meaning International Talk Like a Pirate Day: Date of your first ECE 372 midterm: How much Bill Gates earns per second: Number of pennies to fill Empire State Building September 19 th October 28, 2010 $250 1.8 Trillion 2

Data Representation Data Representation The same data can be represented with: Different symbols English, Cyrillic, Arabic Different numeric bases Binary, Octal, Hexadecimal, Decimal Different formats Little Endian, Big Endian, Binary Coded Decimal Data Structure (Encodings) Decimal Numbers Uses the ten numbers from 0 to 9 Each column represents a power of 10 3

Data Structure (Encodings) Binary Numbers Uses the two numbers from 0 to 1 Every column represents a power of 2 0 0 0 0 1 0 0 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 Data Structure (Encodings) Binary Numbers 0 0 1 0 1 0 0 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 = 0*2 7 + 0*2 6 + 1*2 5 + 0*2 4 + 1*2 3 + 0*2 2 + 0*2 1 + 1*2 0 0 0 1 0 1 0 0 1 128 64 32 16 8 4 2 1 = 0*128 + 0*64 + 1*32 + 0*16 + 1*8 + 0*4 + 0*2 + 1*1 = 41 4

Data Structure (Encodings) Hexadecimal Numbers Uses the ten numbers from 0 to 9 and six letter A to F Each column represents a power of 16 0 0 0 0 A 0 C 5 16 7 16 6 16 5 16 4 16 3 16 2 16 1 16 0 Binary Decimal Hexadecimal 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 0 1 2 3 4 5 6 7 8 9 A B C D E F?? Data Structure (Encodings) 0 0 0 0 A 0 C 5 = A*16 3 + 0*16 2 + C*16 1 + 5*16 0 16 7 16 6 16 5 16 4 16 3 16 2 16 1 16 0 = 10*4096 + 0*256 + 12*16 + 5*1 = 41,157 10 5

Big vs. Little Endian Big Endian MSB (Most Significant Byte/Word) is at lowest address MIPS, Sparc, HC12 Little Endian LSB (Least Significant Byte/Word) is at lowest address PIC24F, x86 15 0 15 0 0x0800 lower address LSW unsigned long int *a; 0xFE 0x0801 higher address MSW a = 0x0800; *a = 254; 0x00 32 Bit Positive vs. Negative Numbers Negative numbers are common How can we represent negative numbers in binary? Signed-magnitude Use leftmost bit for sign bit So -5 would be: 1101 One s Complement Invert all bits for negative numbers So -5 would be: 1010 6

Positive vs. Negative Numbers Two s Complement Allows us to perform subtraction using addition No need for dedicated subtractor within CPU s ALU Two s complement of a number added to the number itself will equal zero So -5 would be: 1011 1011 2 + 0101 2 = 0000 2 (with carry of 1, ignored) Invert all bits and add 1 to get complement of a number Fast conversion: find first 1 from right, invert after 1 0011 1000 (56) + 1111 0110 (-10) 0010 1110 (46) Positive vs. Negative Numbers Decimal Signed- Magnitude One s Two s Complement Complement +4 - - - +3 0 11 0 11 0 11 +2 0 10 0 10 0 10 +1 0 01 0 01 0 01 0 0 00 0 00 0 00-1 1 01 1 10 1 11-2 1 10 1 01 1 10-3 1 11 1 00 1 01-4 - - 1 00 Are we missing a value? 7

Positive vs. Negative Numbers Data Ranges Unsigned 0 to 2 n -1 Signed-Magnitude -2 n-1-1 to 2 n-1-1 One s Complement -2 n-1-1 to 2 n-1-1 Two s Complement -2 n-1 to 2 n-1-1 Positive vs. Negative Numbers Determine the two s complement representation for the following decimal numbers (assume we are using 8-bit binary numbers): -1-11 -15 22-101 8

Binary Coded Decimal Binary Coded Decimal Each digit of a decimal number is represented as a 4-bit binary number Often used for 7-segment displays Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 BCD 0 1 2 3 4 5 6 7 8 9 Undefined Undefined Undefined Undefined Undefined Undefined 10 11 12 13 14 15 ASCII Characters 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8 9 A B C D E F Control characters Printable characters (96) 9

Real Numbers Real Numbers How can we represent a real number (i.e. numbers that contain a fractional part)? Fixed Point Numbers Note: our C compiler already has built-in routines to deal with real numbers However the computational needs will be SIGNIFICANT Fixed Point Numbers Fixed Point Numbers Real number with fixed number of digits before and after radix point N-bits used to represent integer part M-bits used to represent fractional part Unsigned range: 0 to 2 M + 1 / 2 N 0 1 0 0 0 1 0 0. 2 3 2 2 2 1 2 0 2-1 2-2 2-3 2-4 10

Fixed Point Numbers 0 1 0 0 0 1 0 0. = 0*2 3 + 1*2 2 + 0*2 1 + 0*2 0 + 2 3 2 2 2 1 2 0 2-1 2-2 2-3 2-4 0*2-1 + 1*2-2 + 0*2-3 + 0*2-4 0 1 0 0 0 1 0 0. 8 4 2 1 1 / 1 1 = 0*8 + 1*4 + 0*2 + 0*1 + / 1 2 / 4 8 / 16 0*.5 + 1*.25 + 0*.125 + 0*.0625 = 4.25 Fixed Point Numbers 1 0 1 1 1 0 0 1. = 1*2 3 + 0*2 2 + 1*2 1 + 1*2 0 + 2 3 2 2 2 1 2 0 2-1 2-2 2-3 2-4 1*2-1 + 0*2-2 + 0*2-3 + 1*2-4 1 0 1 1 1 0 0 1. 8 4 2 1 1 / 1 1 = 1*8 + 0*4 + 1*2 + 1*1 + / 1 2 / 4 8 / 16 1*.5 + 0*.25 + 0*.125 + 1*.0625 = 11.5625 11

Fixed Point Numbers 0100.0100 (4.25) + 1011.1001 (11.5625) 1111.1101 1 1 1 1 1 1 0 1. = 1*2 3 + 1*2 2 + 1*2 1 + 1*2 0 + 2 3 2 2 2 1 2 0 2-1 2-2 2-3 2-4 1*2-1 + 1*2-2 + 0*2-3 + 1*2-4 1 1 1 1 1 1 0 1. 8 4 2 1 1 / 1 1 = 1*8 + 1*4 + 1*2 + 1*1 + / 1 2 / 4 8 / 16 1*.5 + 1*.25 + 0*.125 + 1*.0625 = 15.8125 Real number representation similar to scientific notation x = M * B E Base (B) Base of the numbering systems considered Binary (2) for computer based implementations We will assume base of 2 for remaining description Sign (S) Indicating positive of negative number 0 Positive, 1 Negative S E M 1 8 23 31 0 12

Real number representation similar to scientific notation x = M * 2 E Mantissa (M) Digits corresponding to the magnitude Stored in a normalized form, where the first bit is assumed to be 1 1 is the only possible non-zero number in binary Remaining bits correspond to fraction values (similar to fixed point) 1 2 0 2-1 2 2-2 -3 2-21 2-22 2-23 S E M 1 8 23 31 0 Real number representation similar to scientific notation x = M * 2 E Exponent (E) Needs to represent both positive and negative values Stored exponent is adjust using the exponent bias Exponent bias = 2 N-1-1, where N is the number of bits in the exponent E Actual = E Stored E Bias Example, 8-bit exponent: E Bias = 2 8-1 -1 = 127 E Stored = 1000 0000 2 = 128 E Actual = 128-127 = 1 S E M 1 8 23 31 0 13

Example: Convert the value 118.625 to floating point representation 1. Determine sign bit: -118.625 is negative, S = 1 2. Convert to binary: 118.625 = 1110110.101 118.625 3. Normalize number 1110110.101 = 1.110110101 * 2 6 Mantissa 4. Determine exponent E Stored = E Actual + E Bias E Stored = 6 + 127 = 133 10 = 10000101 2 S E M 1 10000101 11011010100000000000000 31 0 Real number representation similar to scientific notation x = M * 2 E Zero Due to assuming a leading 1 in the mantissa, we cannot directly represent the value 0 using floating point Defined special case for value of 0 Define special case: Exponent and mantissa of all 0 s corresponds to the value 0 Other special cases exist: +/- Infinity Denormalized value Not a Number S E M 1 8 23 31 0 14

IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754) Single Precision Floating Point S E M 1 8 23 31 0 Double Precision Floating Point S E M 1 11 52 63 0 Data vs. Information What does the bit pattern mean: 1011 1001 Unsigned: 185 decimal Sign-Magnitude: -57 decimal 1 s complement: -70 decimal 2 s complement: -71 decimal Fixed point 4bit.4bit: 11.5625 decimal BCD: 1011 2 =B (Undefined) 1001 2 = 9 10 ASCII: 9 HC12 Opcode: $39 = ADCA (Add with Carry to A, Ext. Addressing) 15

Information Representation Text Page 1 page letter 8.5x11 inches, 60x68 12 point characters ASCII 8bit: 60x68x8 = 32640 bits 4 Kbytes Fax Page Scan Fax low resolution 204x98 dots/inch 8.5x204x11x98 = 1869252 dots 235 Kbytes (B/W) DVD 8Mbit/sec 2 hours 2x60x60x8 = 57600 Mbit Approximately 7.2 Gbytes Information Representation Digital Audio 44.2kHz sampling rate 16bit/channel 1..65536=2^16 Stereo How many seconds of sound fit in 32kbyte EPROM mono? 1.4 Mbyte floppy mono? 660Mbyte CD Rom stereo? 16

Humor Time for Fun (or maybe not?) 10 Gallon 7 Gallon 3 Gallon 17