Lecture 2. How does the computer work? Prof. Sin-Min Lee Department of Computer Science.

Slides:



Advertisements
Similar presentations
1 Chapter 2 The Digital World. 2 Digital Data Representation.
Advertisements

Representing Numbers: Integers
Level ISA3: Information Representation
Comp 1001 Introduction to Information Technology & Computer Architecture Wednesday 12-1Dr. Joe Carthy
CHAPTER 2: Number Systems
Binary Expression Numbers & Text CS 105 Binary Representation At the fundamental hardware level, a modern computer can only distinguish between two values,
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
Lecture 2. How does the computer work? Prof. Sin-Min Lee Department of Computer Science.
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.
Binary and Decimal Numbers
Introduction to Information Technology
The Binary Number System
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
Codes and number systems Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken ( ) and Harris & Harris (DDCA)
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
CS231 Fundamentals1 Fundamentals What kind of data do computers work with? – Deep down inside, it’s all 1s and 0s What can you do with 1s and 0s? – Boolean.
Numbering systems.
Understanding Computer Basics. Computer Case- The part of a computer system that houses the microprocessor, the RAM (Random Access Memory), and the Motherboard.
Numbering Systems CS208.
How Computers Work Dr. John P. Abraham Professor UTPA.
Computer Systems Chapter 1 Pages Hardware-physical pieces Key hardware components in a computer system: The physical parts. – Central processing.
Lecture 2. How does the computer work? Prof. Sin-Min Lee Department of Computer Science.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Chapter 1 Introduction to Computers Maran Illustrated Computers CIS
IKI Data Types & Representations Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
Integer Representation for People Computer Organization and Assembly Language: Module 3.
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
Digital Logic Lecture 2 Number Systems
CHAPTER 3: Number Systems
1 3 Computing System Fundamentals 3.2 Computer Architecture.
CHAPTER 3: Number Systems The Architecture of Computer Hardware and Systems Software & Networking: An Information Technology Approach 4th Edition, Irv.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Data Representation, Number Systems and Base Conversions
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Data Representation Bits, Bytes, Binary, Hexadecimal.
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
CHAPTER 3: Number Systems
CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Lecture 4 Number Systems Lecturer: Sumaira Hussain.
CS231: Computer Architecture I Laxmikant Kale Fall 2002.
Binary & Hex Review.
Assembly Language (CSW 353)
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Lecture 3: Binary values and number systems
Information Support and Services
Number Systems.
COMP211 Computer Logic Design Lecture 1. Number Systems
COMPUTING FUNDAMENTALS
Writer:-Rashedul Hasan. Editor:- Jasim Uddin
Chapter 3 Data Representation
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Data Structures Mohammed Thajeel To the second year students
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Number Systems and Codes
Binary and Hexadecimal Numbers
Information Representation
Digital Electronics and Microprocessors
Chapter Four Data Representation in Computers By Bezawit E.
Number Systems Rayat Shikshan Sanstha’s
Lecture 4 Number Systems. von Neumann Model Every computer today is based on the von Neumann Model. It is based on 3 ideas: 1.Four subsystems 2.Stored.
Number Systems Rayat Shikshan Sanstha’s
Binary & Hex Review.
UNIT – 3 & 4. Data Representation and Internal
Computer Organization
Presentation transcript:

Lecture 2. How does the computer work? Prof. Sin-Min Lee Department of Computer Science

‘Computer” of the day Jacquard loom late 1700’s for weaving silk “Program” on punch cards “Microcode”: each hole lifts a set of threads “Or gate”: thread lifted if any controlling hole punched

Card Punch Early “programmers” were well-paid (compared to loom operators)

Computer Architecture = Instruction Set Architecture + Machine Organization + …

Intel, the world's biggest semiconductor maker, said Monday it built a test chip with a new process that creates faster circuits by packing 10 million transistors into an area the size of the tip of a ballpoint pen. Intel, based in Santa Clara, Calif., has made the first working memory chip that uses so-called 65-nanometer technology to shrink the circuits inside chips, Intel researcher Mark Bohr said during a conference call. Aug. 31, 2004, 12:05AM Big gain in small package Intel test chip boasts technology to add to speed

Bit

so a k is... k in computing is short for kb or kilobyte where kilo means the same as anywhere else in our measurement system: 1000 so a k is 1000 bytes how about Mb? b for byte again, and M for mega: megabyte big M for mega, small m means milli, or one thousandth, 1/ 1000 as in mm, thousandths of a metre mega in our measurement system means one million, or a thousand thousand, so a megabyte is a thousand kilobytes or one million bytes how about GB? you can now buy hard disk drives in Gb, gigabytes, thousands of Mb or thousands of millions of bytes, so a 5Gb HDD holds 5000 Mb of data with some large computers storing up to Tb, terabytes... yup, thousands of Gb... so one terabyte (Tb) = 1000 gigabytes (Gb) = megabytes (Mb) = kilobytes (kb) = bytes or one thousand billion bytes of information

What is a Computer? Data Primitive Operations Sequence Control Data Access Storage Management Operating Environment May be actual hardware computer or software- simulated computer. Most computers a combination of the two.

In mathematics you don't understand things. You just get used to them. John von Neumann

Typical Machine Layout Two cycles: Fetch cycle - get instruction Execute cycle - do operation

Typical Machine Translation For example: As we see later, memory for data in blocks of storage pointed to by a register: X = Y + Z could be translated as: load R1, R2, 28[Location of Y] add R1, R2, 40 [Location of Z] store R1, R2, 24[Location of X] Instruction format: Opcoderegister, index, offset load R1, R2, 24

Ways to Construct a Computer Hardware Realization –Any precisely defined algorithm or data structure may be realized in hardware. Firmware Realization –Microprogramming or emulation Virtual Machine –Provided by a language environment Combination

Von Neumann Model of Execution Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction Obtain instruction from program storage Determine required actions and instruction size Locate and obtain operand data Compute result value or status Deposit results in storage for later use Determine successor instruction Almost all Modern Computers are Von Neumann machines

Data Representation Data comes in different forms such as numbers, text, images, audio, video, … How does the computer handle all the different data types? The most efficient solution is to use a uniform representation of data. All data from outside a computer are transformed into this uniform representation. The universal format is called a bit pattern (a sequence of bits).

Computer Memory Memory is comprised of a large collection of bi-state (off/on) electrical devices called bits (binary digits) A single bit can assume the value 0 or 1. A single bit is not sufficient to represent all data ; therefore, it is necessary to use a sequence of bits.

Basic Addressable Unit of Memory A byte is the basic addressable unit of memory. In virtually all modern computers, a byte consists of 8 bits. As indicated on the previous slide, an 8-bit byte can encode 256 distinct values.

Binary integer arithmetic Integers are stored in a computer using a fixed number of binary digits to encode each value.

Decimal system

Binary system The binary system is based on 2. There are only two digits: 0 and 1 We convert a number from binary to decimal by multiplying each binary digit by its corresponding power of 2. i.e. Multiply the bit at position n (n = 0, 1, 2, …) by

Binary system Binary to Decimal Conversion Binary number

1.Convert the binary number to decimal. 2.Convert the binary number to decimal. Exercises

Decimal review Numbers consist of a bunch of digits, each with a weight: The weights are all powers of the base, which is 10. We can rewrite the weights like this: To find the decimal value of a number, multiply each digit by its weight and sum the products. (1 x 10 2 ) + (6 x 10 1 ) + (2 x 10 0 ) + (3 x ) + (7 x ) + (5 x ) =

Decimal to Binary Conversion To convert a decimal to a binary number, use repetitive division. Divide the number by 2. Write the remainder as the least significant digit (rightmost digit). The quotient becomes the dividend in the next stage. Continue to divide by 2 until the quotient is zero, writing each remainder from right to left.

Decimal to binary conversion

Decimal to Binary Conversion Example: Write 18 in base / 2 = 9 r 0 9 / 2 = 4 r 1 4 / 2 = 2 r 0 2 / 2 = 1 r 0 1 / 2 = 0 r 1 18 base 10 = base 2

Converting binary to decimal We can use the same trick to convert binary, or base 2, numbers to decimal. The only difference is that the weights are powers of 2. For example, here is in binary: The decimal value is: (1 x 2 3 ) + (1 x 2 2 ) + (0 x 2 1 ) + (1 x 2 0 ) + (0 x 2 -1 ) + (1 x 2 -2 ) = = 13.25

Converting decimal to binary To convert a decimal integer into binary, keep dividing by 2 until the quotient is 0. Collect the remainders in reverse order. To convert a fraction, keep multiplying the fractional part by 2 until it becomes 0. Collect the integer parts in forward order. Example: : So, = / 2= 81rem 0 81 / 2= 40rem 1 40 / 2= 20rem 0 20 / 2= 10rem 0 10 / 2= 5rem 0 5 / 2= 2rem 1 2 / 2= 1rem 0 1 / 2= 0rem x 2 = x 2 = x 2 = 1.000

Why does this work? This works for converting from decimal to any base Why? Think about converting from decimal to decimal. Each division strips off the rightmost digit (the remainder). The quotient represents the remaining digits in the number. Similarly, to convert fractions, each multiplication strips off the leftmost digit (the integer part). The fraction represents the remaining digits. 162 / 10= 16rem 2 16 / 10= 1rem 6 1 / 10= 0rem x 10 = x 10 = x 10 = 5.000

Exercises 1.Convert the decimal number 35 to binary. 2.Convert the decimal number 327 to binary.

Bases other than 2 and 10 Any positive integer can be used as a base. For base 5 –The digits are {0, 1, 2, 3, 4} –In a number, such as 1203, each digit is implicitly multiplied by a positional power of 3. –1203 base 5 is

Bases that are Powers of 2 Bit patterns are designed to represent data when stored inside a computer. People find it difficult to manipulate bit patterns. Writing a long stream of 0s and 1s is tedious and error- prone. Bases which are powers of 2 are useful in simplifying notation.

Bases that are Powers of 2 A single digit of a base system represents exactly n bits of a base 2 system. Base Number of bits

Converting from base 2 to base 4 Valid digits in base 4 are 0, 1, 2, 3 To convert from base 2 to base 4 1. Organize the stream of binary digits into groups of two. 2. Find the base 4 value for each group of 2 bits

Converting from base 4 to base 2 To convert from base 4 to base 2 Convert each digit to its 2-bit equivalent base 4 is base 2

Base 8 (Octal ) Bit Pattern Bit Pattern Octal Digit Octal Digit Valid digits: 0, 1, 2, 3, 4, 5, 6, 7

Converting from base 2 to base 8 To convert from base 2 to base 8 1. Organize the stream of binary digits into groups of three. 2. Find the octal value for each group of 3 bits base 2 is 745 base 8

Converting from octal to binary To convert from octal to binary Convert each digit to its 3-bit equivalent base 8 is base 2

Binary to octal and octal to binary transformation

Exercises 1.Show the octal equivalent of the bit pattern Show the octal equivalent of the bit pattern What is the bit pattern for 24 base 8?

Base 16 is useful too The hexadecimal system uses 16 digits: A B C D E F You can convert between base 10 and base 16 using techniques like the ones we just showed for converting between decimal and binary. For our purposes, base 16 is most useful as a “shorthand” notation for binary numbers. –Since 16 = 2 4, one hexadecimal digit is equivalent to 4 binary digits. –It’s often easier to work with a number like B4 instead of Hex is frequently used to specify things like 32-bit IP addresses and 24-bit colors.

Converting from base 2 to hexadecimal To convert from base 2 to hexadecimal 1. Organize the stream of binary digits into groups of four. 2. Find the hexadecimal value for each group of 4 bits E 1 A

Converting from hexadecimal to base 2 To convert from hexadecimal (base 16) to base 2 Convert each digit to its 4-bit equivalent. 9 2 E 1 A

Binary to hexadecimal and hexadecimal to binary transformation

1.Show the hexadecimal equivalent of the bit pattern Show the hexadecimal equivalent of the bit pattern What is the bit pattern for 2675 base 16? 4.What is the bit pattern for B51E base 16? Exercises

Binary and hexadecimal conversions Converting from hexadecimal to binary is easy: just replace each hex digit with its equivalent 4-bit binary sequence. To convert from binary to hex, make groups of 4 bits, starting from the binary point. Add 0s to the ends of the number if needed. Then, just convert each bit group to its corresponding hex digit = = = = B 4. 2 C 16

Class Exercise 1.Bin to dec: Dec to bin: Bin to hex: Hex to bin: 0xFEDC 5.Hex to dec: 0x10A 6.Dec to hex: 165

Other Bases Base 8 (octal number system) –123 = 1 * * * 16 0 = 1 * * * 1 = = 83 Base 13 –123 = 1 * * * 13 0 = 1 * * * 1 = = 198