M1 Computers and Data

Similar documents
COMP2611: Computer Organization. Data Representation

Inf2C - Computer Systems Lecture 2 Data Representation

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Digital Fundamentals

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Numeric Encodings Prof. James L. Frankel Harvard University

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Chapter 4: Data Representations

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Data Representation 1

Integers and Floating Point

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

MACHINE LEVEL REPRESENTATION OF DATA

CHW 261: Logic Design

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Introduction to Computers and Programming. Numeric Values

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Topic Notes: Bits and Bytes and Numbers

IEEE-754 floating-point

CS 61C: Great Ideas in Computer Architecture Performance and Floating Point Arithmetic

COMP2121: Microprocessors and Interfacing. Number Systems

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

World Inside a Computer is Binary

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Microcomputers. Outline. Number Systems and Digital Logic Review

CO212 Lecture 10: Arithmetic & Logical Unit

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Number System. Introduction. Decimal Numbers

CS 101: Computer Programming and Utilization

Outline. What is Performance? Restating Performance Equation Time = Seconds. CPU Performance Factors

CS 61C: Great Ideas in Computer Architecture Performance and Floating-Point Arithmetic

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

UNIT 7A Data Representation: Numbers and Text. Digital Data

Under the Hood: Data Representation. Computer Science 104 Lecture 2

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Topic Notes: Bits and Bytes and Numbers

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

17. Instruction Sets: Characteristics and Functions

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)

Survey. Motivation 29.5 / 40 class is required

Floating Point Arithmetic

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

CPE300: Digital System Architecture and Design

Chapter 2 Bits, Data Types, and Operations

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

Digital Fundamentals

Integer Representation Floating point Representation Other data types

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

BINARY SYSTEM. Binary system is used in digital systems because it is:

Final Labs and Tutors

Floating Point Numbers

Floating Point Numbers

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

IEEE Standard for Floating-Point Arithmetic: 754

Chapter 2 Bits, Data Types, and Operations

Team 1. Common Questions to all Teams. Team 2. Team 3. CO200-Computer Organization and Architecture - Assignment One

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Chapter 2 Data Representations

Floating Point Numbers

Number Systems CHAPTER Positional Number Systems

CO Computer Architecture and Programming Languages CAPL. Lecture 15

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

CPE300: Digital System Architecture and Design

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

Module 2: Computer Arithmetic

Number Representations

Representing numbers on the computer. Computer memory/processors consist of items that exist in one of two possible states (binary states).

Data Representations & Arithmetic Operations

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Chapter 3: Arithmetic for Computers

Floating Point January 24, 2008

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

Content. Information Coding. Where are we? Where are we? Bit vectors (aka Words )

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

3.5 Floating Point: Overview

Computer Organization: A Programmer's Perspective

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

CS 33. Data Representation (Part 3) CS33 Intro to Computer Systems VIII 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Computer Organization

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

FLOATING POINT NUMBERS

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Chapter 2. Data Representation in Computer Systems

Transcription:

M1 Computers and Data

Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed and unsigned integers. IEEE 754 floating point standard.

Basic Computer Organization Processor Executes programs Main Memory Holds program and data I/O For communication and data Processor (CPU) ALU CONTROL REGISTERS MEMORY Interconnection Network I/O I/O I/O I/O

Inside the Processor Control Hardware: Hardware to manage instruction execution ALU: Arithmetic and Logical Unit (hardware to do arithmetic and logic operations) Registers: Small units of memory to hold data/instructions temporarily during execution Memory: Stores information being processed by the CPU Input: Allows the user to supply information to the computer Output: Allows the user to receive information from the computer

Concept of Time and Speed Frequency: Number of occurrences of a repeating event per unit time. SI unit: Hertz (Hz) The period is the duration of one cycle in a repeating event Period = Cycle time Cycle Time = 1 Frequency

Clock Cycle Clock is a special signal to hardware A well defined indication for event start and complete. Time (ns) 1.0 1.5 2.0 2.5 Clock Rising Edge Falling edge Levels

Clock Cycle Clock is a special signal to hardware A well defined indication for event start and complete. Time (ns) 1.0 1.5 2.0 2.5 Clock Addition ADDITION COMPLETES IN THIS DURATION ANOTHER BLOCK Both operands are ready. The result is ready. The result is consumed by another block.

Clock Cycle Clock is a special signal to hardware A well defined indication for event start and complete. Time (ns) 1.0 1.5 2.0 2.5 Clock Memory Access Memory access happens here. ANOTHER BLOCK Address is ready Data is ready. The data is consumed

On Processor Performance How is frequency related to performance? Program ExecutionTime = Execution Time per Instruction Total Program Instructions CPU Time =Execution Time per Instruction Instruction Count Execution Time per Instruction= Cycles spent per Instruction Cycle Time CPU Time = IC Cycles per Instruction Cycle Time Example What is is the execution time of of a program containing a million instructions each occupying 4 cycles in in a 2 GHz processor?

Iron Law of Processor Performance CPU Time = IC Cycles per Instruction CycleTime Cycle Time= 1 Frequency CPU Time= IC CPI Frequency CPU time= Instructions Program cycles Clock Instruction Seconds Clock cycle

Iron Law of Processor Performance CPU time= Instructions cycles Clock Program Instruction Seconds Clock cycle COMPILER ARCHITECTURE AND ORGANIZATION

Data Representation

Objective How are program data (integers, strings, floats, addresses) represented (encoded) in an object file and during program execution?

ASCII 7-bit format Character Data American Standard Code for Information Interchange Numbers 0-9, letters a-z and A-Z, basic punctuation symbols, control codes, blank space. Range 0x0 0x1F 0x20 0x2F 0x3A 0x40 0x5B 0x60 0x7B - 0x7F Encoded Character Special Characters Non alphabet characters 0x30 0x39 0, 1,..., 8, 9 0x41 0x5A 0x61 0x7A A, B,..., Y, Z a, b,..., y, z

Character Data Unicode 8/16/32-bit formats (UTF-8, UTF-16, UTF-32) For most of the world's writing systems Contains a repertoire of more than 110,000 characters covering 100 scripts and various symbols All ASCII characters included in UTF-8.

Signed and Unsigned int x; unsigned int y; Integer Data Overflow: The number to be represented is larger than the range possible.

Signed Integer Data Sign Magnitude Representation Sign bit Magnitude bits x n 1 x n 2... x 2 x 1 x 0 MSB LSB ( 1) x n 1 [ xn 2 2 n 2 +...+ x 1 2 1 + x 0 2 0 ] Binary to/from Decimal conversion: (a) 0x4C (b) 27

Signed Integer Data Problems Sign bit uses up one bit space. Arithmetic circuits need extra steps to identify sign of the result. +0 and -0 exist.

Two's Complement Representation Leading zeros mean positive and leading ones mean negative 0000 0000 0000 0001 0000 0010... 0111 1110 0111 1111 1000 0000 1000 0001 1000 0010... 1111 1110 1111 1111 0 1 2 126 127-128 -127-126 -2-1

Two's Complement Representation x =x x... x x x ten n 1 n 2 2 1 0 x = x 2 n 1 +x 2 n 2 n +...+x 2 1 + x 2 0 ten ten n 1 n 2 1 0 Example Convert 17, -21, 32 into their 2's complement notation. Observe: Pick an 8-bit, 2's complement binary number. Invert its bits: 0 1 and 1 0. Add both these numbers in binary. What is the result?

Two's Complement Representation x x 1111 1111 1111 1111 1111 1111 1111 1100 0000 0000 0000 0000 0000 0000 0000 0011 x + x = -1 (x + 1) = -x x +1 0000 0000 0000 0000 0000 0000 0000 0100 x = -4 Binary to/from Decimal conversion: 0xFFFFFBD5

Sign Extension and Zero Extension Binary to to Decimal conversion: (a) 1 1011 (b) 11 111011 (c) 111 1011 (d) 1111 1011 Replicate the Most Significant Bit to the left. Sign extension 1001, 11001, 111001... = -7 11...1001 = - 7 Zero extension 0111 = 7, 00111 = 7, 000111 = 7,...

Unsigned Integer Data Interpret the 8-bit quantity 0x81 as (a) a signed integer, and (b) an unsigned integer. 1 0 0 0 0 0 0 1 (a) - 127 (b) 129 What are the max and min unsigned values of 16bit unsigned data?

One's Complement Similar to two's complement. The negative is found by inverting bits. Two zeros: 0000 and 1111. In the 8-bit one's complement representation, which are the most negative and most positive numbers? 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7-0 - 1-2 - 3-4 - 5-6 - 7 1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0

Byte Ordering... 99 0 0 0 0 4 7 A 0 100 101 102 103 104... How does one read the 4 bytes at address 100? 0 0 0 0 4 7 A 0 vs. A 0 4 7 0 0 0 0 100 is the MSB (at the big end). 100 is the LSB (at the little end). 27566 vs. 1605959680 Big Endian notation vs. Little Endian notation IBM, Network data Intel processors

Biased Representation The most negative value is represented by 0. Two's Complement Biased Notation (Biased by 128) 0000 0000 0000 0001 0000 0010... 0111 1110 0111 1111 1000 0000 1000 0001 1000 0010... 1111 1110 1111 1111 0 1 2 126 127-128 -127-126 -2-1 0000 0000 0000 0001 0000 0010... 0111 1110 0111 1111-128 -127-126 -2-1 1000 0000 1000 0001 1000 0010... 1111 1110 1111 1111 0 1 2 126 127 (Excess 128)

Real Data 3.14159265... (pi), 2.71828... (e) 0.00001 = 1.0 x 10-5 3,155,760,000 = 3.15576 x 10-9 Scientific form of a real number Single digit before the decimal point 1.0 x 10-5, 0.1 x 10-4, 0.01 x 10-3,... Normalized representation No leading zeros 1.0 x 10-5 Not 0.1 x 10-4, 0.01 x 10-3,...

Real Data Binary Notation 7.510 = ( ) 2 7.2510 = ( ) 2 7.12510 = ( ) 2 7.7510 = ( ) 2 7.37510 = ( ) 2 7.62510 = ( ) 2 7.87510 = ( ) 2

Real Data Binary Notation 7.62510 = 111.101 2 111.101 x 2 0, 1111.01 x 2-1, 11.1101 x 2 1,... Scientific form 1.11101 x 2 2, 0.111101 x 2 3, 0.0111101 x 2 4,... Normalized representation 1.11101 x 2 2. Computers use Normalized representation to store floats. 1.f x 2 e f: fraction, e: exponent.

Floating Point Representation 31 30............ 23 22 21........................ 1 0 s exponent fraction ( 1) s 1. f 2 e 127 IEEE 754 single precision format Exponent is biased by 127

IEEE 754 FP Representation Convert 0.5 into binary. Represent in IEEE 754 single precision floating point representation. Binary = 0.1 = 1.0 x 2-1. s=?, f =?, e =? s=0, f=0, e = (-1) + 127 = 126 0 0 1 1 1 1 1 1 0 0 0... 0 0 0x3F000000

IEEE 754 FP Representation Convert 0.75 into IEEE 754 SP FP. Convert 0xBDCCCCCC into decimal. Four special values Exponent Fraction Value 0 0 Zero (± 0) 255 0 Infinity (± ) 0 0 Denormal numbers (± 0.M x 2-126 ) 255 0 NaN (0/0 or -1)

IEEE 754 Double Precision 63 62............ 52 51 50........................ 1 0 s exponent fraction ( 1) s 1. f 2 e 1023

Real Data Representation Recap What are the place values of 7 positions after the decimal point in a binary real number?....... 2 n 2 n-1 2 n-2 2 0 2-1 2-2 2-3 decimal point Binary to to Decimal conversion: (a) 1.10 (b) 11.11 (c) 111.1011 (d) 111.100110011001 (e) 111.1101110111011101......

Real Data Representation Recap Convert into IEEE 754 SP FP: 13.1, 12.2, 11.3, 10.4, 9.5, 8.6, 7.7, 6.8, 5.9

Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed and unsigned integers. IEEE 754 floating point standard.

Word size = 32 bits Word Alignment Words can be stored linearly in addresses 0x00, 0x04, 0x08, 0x0C, 0x10,... These addresses are 'word boundaries' 100 101 102 103 104 105 106 107 0 0 C 0 4 7 A 0 3 0 0 2 4 7 1 8 200 201 202 203 204 205 206 207 0 A B 0 4 7 A 0 D 0 0 E 4 7 A 0......... 3 0 0 2 4 7 1 8 4 7 A 0 D 0 0 E Word Aligned Word Not Aligned