Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer



Similar documents
Chapter 4 System Unit Components. Discovering Computers Your Interactive Guide to the Digital World

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

Discovering Computers Living in a Digital World

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance

Memory is implemented as an array of electronic switches

Chapter 8 Memory Units

CHAPTER 2: HARDWARE BASICS: INSIDE THE BOX

The Central Processing Unit:

Chapter 3: Computer Hardware Components: CPU, Memory, and I/O

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Main Memory & Backing Store. Main memory backing storage devices

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

CSCA0102 IT & Business Applications. Foundation in Business Information Technology School of Engineering & Computing Sciences FTMS College Global

The string of digits in the binary number system represents the quantity

lesson 1 An Overview of the Computer System

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

Hardware: Input, Processing, and Output Devices. A PC in Every Home. Assembling a Computer System

Obj: Sec 1.0, to describe the relationship between hardware and software HW: Read p.2 9. Do Now: Name 3 parts of the computer.

Primary Memory. Input Units CPU (Central Processing Unit)

Multiple Choice Questions(Computer)

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Number Representation

2011, The McGraw-Hill Companies, Inc. Chapter 3

To understand how data is processed, by a computer, we can draw a simple analogy between computers and humans.

Algorithms and Methods for Distributed Storage Networks 3. Solid State Disks Christian Schindelhauer

Introduction To Computers: Hardware and Software

CSCA0201 FUNDAMENTALS OF COMPUTING. Chapter 5 Storage Devices

With respect to the way of data access we can classify memories as:

RAM & ROM Based Digital Design. ECE 152A Winter 2012

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Memory Basics. SRAM/DRAM Basics

Memory. The memory types currently in common usage are:

Homework # 2. Solutions. 4.1 What are the differences among sequential access, direct access, and random access?

Parts of a Computer. Preparation. Objectives. Standards. Materials Micron Technology Foundation, Inc. All Rights Reserved

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Tech Application Chapter 3 STUDY GUIDE

CHAPTER 7: The CPU and Memory

Computer Logic (2.2.3)

Counting in base 10, 2 and 16

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Introduction to Information System Layers and Hardware. Introduction to Information System Components Chapter 1 Part 1 of 4 CA M S Mehta, FCA

Chapter 1. The largest computers, used mainly for research, are called a. microcomputers. b. maxicomputers. c. supercomputers. d. mainframe computers.

Module 2. Embedded Processors and Memory. Version 2 EE IIT, Kharagpur 1

Chapter 2: Basics on computers and digital information coding. A.A Information Technology and Arts Organizations

How To Store Data On A Computer (For A Computer)

Computer Basics: Chapters 1 & 2

Numbering Systems. InThisAppendix...

Week One Lecture Note 1.0 INTRODUCTION TO COMPUTER 1.1 WHAT IS COMPUTER?

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Chapter 2: Computer-System Structures. Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General System Architecture

Technical Product Specifications Dell Dimension 2400 Created by: Scott Puckett

Microprocessor or Microcontroller?

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

Chapter 8. Secondary Storage. McGraw-Hill/Irwin. Copyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.

Central Processing Unit

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

COMPUTER BASICS. Seema Sirpal Delhi University Computer Centre

Systems I: Computer Organization and Architecture

Computer Performance. Topic 3. Contents. Prerequisite knowledge Before studying this topic you should be able to:

Chapter 13. PIC Family Microcontroller

Chapter 1 Computer System Overview

1.1 Electronic Computers Then and Now

A N. O N Output/Input-output connection

2 COMPUTER ORGANISATION

Lecture N -1- PHYS Microcontrollers

Slide Set 8. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

Communicating with devices

Writing Assignment #2 due Today (5:00pm) - Post on your CSC101 webpage - Ask if you have questions! Lab #2 Today. Quiz #1 Tomorrow (Lectures 1-7)

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Data Storage. 1s and 0s

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

Base Conversion written by Cathy Saxton

SDRAM and DRAM Memory Systems Overview

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

Block diagram of typical laptop/desktop

361 Computer Architecture Lecture 14: Cache Memory

ELECTRONIC DOCUMENT IMAGING

MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS

Chap-02, Hardware and Software. Hardware Model

1 PERSONAL COMPUTERS

Computer Systems Structure Main Memory Organization

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Tested product: Auslogics BoostSpeed

Handout 17. by Dr Sheikh Sharif Iqbal. Memory Unit and Read Only Memories

Let s put together a Manual Processor

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

CHAPTER 4 MARIE: An Introduction to a Simple Computer

MULTIPLE CHOICE FREE RESPONSE QUESTIONS

CHAPTER 3 Boolean Algebra and Digital Logic

Embedded Software development Process and Tools: Lesson-3 Host and Target Machines

Lecture 2: Computer Hardware and Ports.

Discovering Computers Chapter 7 Storage

Candidates should be able to: (i) describe the purpose of RAM in a computer system

Fall Lecture 1. Operating Systems: Configuration & Use CIS345. Introduction to Operating Systems. Mostafa Z. Ali. mzali@just.edu.

Transcription:

Computers CMPT 125: Lecture 1: Understanding the Computer Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 A computer performs 2 basic functions: 1. executes a sequence of instructions (program) 2. stores and recalls information (data) We can characterize a computer by: its speed the type of instructions it can execute the capacity of its memory A computer system is made up of hardware and software. 1 CMPT 125: Understanding the Computer, Lecture 1 2 Hardware The Central Processing Unit (CPU) The hardware refers to the electronic equipment that forms a computer system. These include: Central processing unit (CPU): responsible for executing programs Input/output (I/O) devices: keyboard, mouse, monitor, controllers etc. Main memory holds the program and data being processed by the CPU Secondary memory or storage devices: hard disks, floppy disks, etc. The CPU reads and writes numerical values (instructions and/or data) to locations in the main memory. The CPU executes program instructions one at a time, and sequentially until directed otherwise. When we turn on our computer, the internal hardware gives the CPU the address of the first program instruction. INPUT/OUTPUT EXTENAL MEMORY USER CPU MAIN MEMORY Figure 1: A computer system. CMPT 125: Understanding the Computer, Lecture 1 3 CMPT 125: Understanding the Computer, Lecture 1 4

The CPU components Transmission of Data the control unit: coordinates the transfer of data and instructions between main memory and the registers in the CPU registers: provides small memory storage in the CPU, e.g.: 1. instruction register: holder for current instruction being executed 2. program counter: holder for address of next instruction 3. general register(s): temporary storage for values as needed arithmetic/logic unit: performs calculations Data must be moved to and from these various memory locations, to and from the CPU. The electrical pathways within the computer that allow components to communicate with each other are called buses. Computer components (such as the CPU and the various types of memory), are laid out on a board, called the motherboard, with the buses connecting them together. All data, instructions and any other signals, travel on the bus. CMPT 125: Understanding the Computer, Lecture 1 5 CMPT 125: Understanding the Computer, Lecture 1 6 System Clock The Main Memory A clock generates an electronic pulse at regular intervals which synchronizes the events of the CPU. The rate of the clock determines the clock-speed, and give an idea of how fast the CPU and process instructions (different processors may process a different number of instructions per clock cycle). The main memory holds both programs and data. Information is stored in distinct locations, specified by a unique numerical address. Addresses 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 Data Values Larger values may use several locations Figure 2: Memory Locations. In the earliest computers, programs and data did not share the same memory. In the late 1940s, John von Neumann first carried out the idea of using the same memory for both. CMPT 125: Understanding the Computer, Lecture 1 7 CMPT 125: Understanding the Computer, Lecture 1 8

An Example Program Instructions for interpreting the program How does the CPU interpret numeric values as instructions and data? Let s look at a program that adds two numbers. An example program might look like this in main memory: Address Contents 100 1104 101 3105 102 2106 103 0000 104 1230 105 3017 106 0000 Can you interpret this program? CMPT 125: Understanding the Computer, Lecture 1 9 The first four locations are interpreted as instructions, and the last three as data. Address Contents 100 1104 instruction 101 3105 instruction 102 2106 instruction 103 0000 instruction 104 1230 data 105 3017 data 106 0000 data Meaning of instructions (for this example only): The leftmost digit determines the instruction type: Digit Meaning 0 stop 1 load 2 store 3 add The right three digits of the code indicate the memory location to use in the operation. CMPT 125: Understanding the Computer, Lecture 1 10 The program interpreted Program Before and After Execution The program may be interpreted as follows: Address Contents Meaning 100 1104 LOAD 104 101 3105 ADD 105 102 2106 STORE 106 103 0000 STOP 104 1230 DATA 105 3017 DATA 106 0000 DATA The CPU does the following when executing the program: place the contents of location 104 in a specific place in the CPU called a register. bring the contents of location 105 into the CPU and add it to the data already stored in the register the register now holds only the result of the addition individual values are lost. move the result into location 106 for storage Before execution After execution Address Contents Meaning 100 1104 LOAD 104 101 3105 ADD 105 102 2106 STORE 106 103 0000 STOP 104 1230 DATA 105 3017 DATA 106 0000 DATA Address Contents Meaning 100 1104 LOAD 104 101 3105 ADD 105 102 2106 STORE 106 103 0000 STOP 104 1230 DATA 105 3017 DATA 106 4247 DATA CMPT 125: Understanding the Computer, Lecture 1 11 CMPT 125: Understanding the Computer, Lecture 1 12

A Higher Level Program Software The same program in a higher level programming language such as Java, is much more human friendly! int a = 1230; int b = a + 3017; //b now holds the value 4247 The software refers to the programs that are executed by a computer. An essential software of the computer system is the operating system (OS) which 1. provides a user interface, typically a graphical user interface (GUI), allowing interaction between the user and the computer. 2. manages computer resources such as the CPU and main memory, e.g.: defines how files are organized how memory is managed, how the CPU is used 3. provides system calls (eg. memory allocation, opening, reading, and saving files, etc.) for software applications. CMPT 125: Understanding the Computer, Lecture 1 13 CMPT 125: Understanding the Computer, Lecture 1 14 Analog Signals Digital Signals Analog signals are continuous in time. Figure 3: The electrical signal used to represent the pressure variations of a sound wave is an analog signal. The process of taking individual values on a continuous signal at regular time intervals is called sampling. Music on compact discs is stored digitally. The sampling rate is typically 44,100 samples per second (or 44.1 khz). The term analog refers to the fact that it is analogous of the signal it represents. A continuous signal cannot be stored, or processed, in a computer since it would require an infinite amount of data. Analog signals must therefore be discretized, or digitized, to produce a a finite set of numbers, for computer use. Figure 4: A digital, or sampled, signal. CMPT 125: Understanding the Computer, Lecture 1 15 CMPT 125: Understanding the Computer, Lecture 1 16

How is Data Stored? Decimal System There are several ways to represent numbers. Normally we, humans, use the decimal system (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,...). Computers on the other hand, represent numbers in binary form. Data in binary form and can represent any kind of information (sound, music, text, numbers, pictures, video, etc.) or operating instructions. To get an idea how the binary system works, lets first look at the more familiar decimal system. The decimal system is based on the number 10. The value of an individual digit, depends on its relative position in a group of other digits. Each position is worth 10 times as much as the position to the right. The number 126 is evaluated as: 1 10 2 + 2 10 1 + 6 10 0 = 126 CMPT 125: Understanding the Computer, Lecture 1 17 CMPT 125: Understanding the Computer, Lecture 1 18 Binary System Bits The binary system is based on the number 2. Each bit position in the group is worth twice as much as the position to the right. The binary number 1001 is evaluated as 1 2 3 + 0 2 2 + 0 2 1 + 1 2 0 = 9 Other systems include octal and hexadecimal. The smallest unit of memory is the bit, representing the position, either on or off, of an electronic switch inside the computer hardware. A bit can represent either 0 or 1 depending on the state of the switch. The term is a contraction of the term binary digit. Two (2) bits can assume 4 unique patterns and thus 4 unique values. Binary form Decimal form 00 0 01 1 10 2 11 3 In general, n bits can assume 2 n unique values. CMPT 125: Understanding the Computer, Lecture 1 19 CMPT 125: Understanding the Computer, Lecture 1 20

Bytes Numeric Representation The byte is used to measure memory capacity, and is nearly always defined as 8 bits. A byte can therefore assume 2 8 = 256 unique values. The number of bytes used to represent instructions and datum vary, e.g., one byte is used to store the letter G: 01000111. The most widely used coding system is ASCII (American Standard Code for Information Interchange). It consists of 128 numerical codes that represent alphanumeric characters, punctuation marks, and special control codes. Numerical values generally occupy from 1 to 8 bytes. Integers represented using 16 bits (called shorts) provide a range of -32,768 to +32,767. One bit is allocated for the sign, usually the most significant bit, so that a leading 0 indicates a positive number and 1 a negative number. For the sake of saving space, let s look at only 8 bits. For positive numbers, there are 7 bits to represent the magnitude, allowing for a highest value of: 01111111 = 2 6 + 2 5 + 2 4 + 2 3 + 2 2 + 2 1 + 2 0 = 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127 CMPT 125: Understanding the Computer, Lecture 1 21 CMPT 125: Understanding the Computer, Lecture 1 22 Two s Complement Floating Point Representation There are several ways of representing negative numbers, the most common being two s complement. take the binary representation of the magnitude take the complement of all the bits (change 0s to 1s and 1s to 0s) add 1 The number -128 would then be 10000000 (binary representation of the magnitude) 01111111 (taking the complement bits) 10000000 (adding 1) which is negative because of the leading 1. The lowest number that can be represented using 8 bits is therefore -128. Why is it not 11111111? The floating point representation was developed to represent numbers with fractional parts. To get an idea of how the floating point representation works, consider a number 824.68, which can be written using a fractional part and an exponent: 824.68 = 0.82468 10 3 The exponent, 3, is the number of places the decimal point had to be shifted to the left in order to be in front of the first digit. The fractional part, 0.82468, known as the mantissa. CMPT 125: Understanding the Computer, Lecture 1 23 CMPT 125: Understanding the Computer, Lecture 1 24

Floating Point Numbers Units of binary storage A number less than 0.1, such as 0.068514, can be similarly represented as 0.068514 = 0.68614 10 1, where the negative exponent indicates that the decimal point must be moved to the right. A computer stores a floating-point number as a separate mantissa and exponent (though usually in binary form) using 4 bytes: 1 byte for the exponent 3 bytes for the mantissa gives a resolution of 7 decimal digits (including sign). Double precision uses a total of 8 bytes and give a little over 15 decimal digits of resolution. Operations on floating-point and double precision numbers are usually performed more slowly than with integers (unless the computer has special hardware). Because computer memory is based on the binary number system, all units of storage are powers of two. Unit Symbol Number of Bytes byte 2 0 = 1 kilobyte KB 2 10 = 1024 megabyte MB 2 20 = 1, 048, 576 gigabyte GB 2 30 = 1, 073, 741, 824 terabyte TB 2 40 = 1, 099, 511, 627, 776 CMPT 125: Understanding the Computer, Lecture 1 25 CMPT 125: Understanding the Computer, Lecture 1 26 Where is Data Stored RAM (Random Access Memory) So now that we now how data is stored in a computer, let s look a little closer at where it is stored. There are three primary types of memory: 1. RAM (Random Access Memory) 2. ROM (Read-Only Memory) 3. Storage memory RAM is the fast memory in which data and instructions are stored when being used by the CPU. Also referred to as main memory. It is volatile: when the power is shut off, the memory is wiped clean. CMPT 125: Understanding the Computer, Lecture 1 27 CMPT 125: Understanding the Computer, Lecture 1 28

Types of RAM ROM (Read-Only Memory) DRAM (Dynamic RAM): Data is erased once it is read, and must be constantly rewritten (once read) to keep it present. Relatively inexpensive. SRAM (Static RAM): Data does not need to be constantly rewritten in order to keep it secure, but more expensive than DRAM. VRAM (Video RAM): Special memory (typically a type of SRAM) used for holding video. Used on graphics, video and accelerator cards. Flash memory. A cross between RAM and forms of ROM. Constructed like EEPROM, is non-volatile, but is fast like RAM. Can only erase multiple memory locations at a time: changing a byte is only possible by rewriting a whole block. Memory in which instructions are permanently encoded: cannot be changed, and are not erased when the computer is shut down. Commonly used to start and set-up a computer: when the power is turned on, the instructions in ROM are loaded into the computer s RAM. CMPT 125: Understanding the Computer, Lecture 1 29 CMPT 125: Understanding the Computer, Lecture 1 30 Types of ROM Storage (secondary) memory PROM (Programmable ROM): Can be programmed after the chip is produced. Instructions are burned into the chip electrically (as coded pulses of electricity), after which they cannot be changed. EPROM (Erasable PROM): Instructions can be changed by exposing the chip to ultraviolet light. EEPROM (Electrically Erasable PROM): Instructions can be erased using an electrical current rather than normal ultraviolet light: faster and can be done in-circuit. Non-volatile (stable), and used to store large quantities of data. Includes hard drives, diskettes, CD-ROMS, etc. Since it is slower than RAM and ROM, data is copied to RAM before being used by the CPU. Virtual memory is storage memory can be used as a slower RAM, thus simulating a computer with more RAM. Particularly useful when working with large files. CMPT 125: Understanding the Computer, Lecture 1 31 CMPT 125: Understanding the Computer, Lecture 1 32

Cache Memory Used to allow more efficient operation of the CPU. The processor keeps the most recently used data and instructions in the cache, making it immediately available instead of having to make the slower request from storage memory or RAM. Usually a type of SRAM. Expensive, though usually smaller. CMPT 125: Understanding the Computer, Lecture 1 33