Introduction to Computer Science. William Hsu Department of Computer Science and Engineering National Taiwan Ocean University

Similar documents
Introduction to Computer Science. William Hsu Department of Computer Science and Engineering National Taiwan Ocean University

Figure 2.1 CPU and main memory connected via a bus. Computer Architecture 2014/10/12. Chapter 2: Data Manipulation

Chapter 2: Data Manipulation

Chapter 2: Data Manipulation

Chapter 2: Data Manipulation

Chapter 2: Data Manipulation. Copyright 2015 Pearson Education, Inc.

Chapter 2 Data Manipulation

Computer Architecture and Data Manipulation. Von Neumann Architecture

Chapter 2: Data Manipulation

Data Manipulation. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Introduction to Computer Science Lecture 2: Data Manipulation

Latches. IT 3123 Hardware and Software Concepts. Registers. The Little Man has Registers. Data Registers. Program Counter

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

Computer Organization

Full file at

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMPUTER ARCHITECURE- III YEAR EEE-6 TH SEMESTER 16 MARKS QUESTION BANK UNIT-1

COMPUTER ORGANIZATION AND ARCHITECTURE

Understanding Computers. Hardware Terminology

5 Computer Organization

Computer Organization

Computer Architecture Dr. Charles Kim Howard University

2 MARKS Q&A 1 KNREDDY UNIT-I

Introduction to Computer Science Lesson 5

COS 140: Foundations of Computer Science

UNIT 2 (ECS-10CS72) VTU Question paper solutions

5 Computer Organization

Overview of Computer Organization. Chapter 1 S. Dandamudi

COSC 122 Computer Fluency. Computer Organization. Dr. Ramon Lawrence University of British Columbia Okanagan

RISC Processors and Parallel Processing. Section and 3.3.6

Overview of Computer Organization. Outline

Computer Architecture

Typical Processor Execution Cycle

Introduction to Computer Science. Homework 1

ECE 485/585 Microprocessor System Design

SAE5C Computer Organization and Architecture. Unit : I - V

CS 101, Mock Computer Architecture

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

Computer and Hardware Architecture I. Benny Thörnberg Associate Professor in Electronics

CN310 Microprocessor Systems Design

Real instruction set architectures. Part 2: a representative sample

EE 4980 Modern Electronic Systems. Processor Advanced

Computer Systems. Binary Representation. Binary Representation. Logical Computation: Boolean Algebra

Chapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017

Computer Architecture

Microprocessor Architecture Dr. Charles Kim Howard University

Data Manipulation. *2.4 Arithmetic/Logic. Instructions. Logic Operations Rotation and Shift Operations Arithmetic Operations. *2.5 Communicating with

Computers Are Your Future

Processor design - MIPS

Chapter 5:: Target Machine Architecture (cont.)

Chapter 2: Instructions How we talk to the computer

Universität Dortmund. ARM Architecture

Microprocessors and Microcontrollers. Assignment 1:

Computer Architecture, RISC vs. CISC, and MIPS Processor

Computer Architecture Dr. Charles Kim Howard University

Full file at

Machine Architecture. or what s in the box? Lectures 2 & 3. Prof Leslie Smith. ITNP23 - Autumn 2014 Lectures 2&3, Slide 1

3.1 Description of Microprocessor. 3.2 History of Microprocessor

Introduction to parallel computing

Chapter 5 12/2/2013. Objectives. Computer Systems Organization. Objectives. Objectives (continued) Introduction. INVITATION TO Computer Science 1

Dec Hex Bin ORG ; ZERO. Introduction To Computing

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

Chapter 5: Computer Systems Organization

Chapter 5: Computer Systems Organization. Invitation to Computer Science, C++ Version, Third Edition

PC I/O. May 7, Howard Huang 1

Course Description: This course includes concepts of instruction set architecture,

QUIZ Ch.6. The EAT for a two-level memory is given by:

Architectures & instruction sets R_B_T_C_. von Neumann architecture. Computer architecture taxonomy. Assembly language.

Lecture 4: ISA Tradeoffs (Continued) and Single-Cycle Microarchitectures

Basic Computer Architecture

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

Computer Architecture

Introduction to Computers & Programming

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

Computers Are Your Future

Segment 1A. Introduction to Microcomputer and Microprocessor

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

Introduction. Computer System Organization. Languages, Levels, Virtual Machines. A multilevel machine. Sarjana Magister Program

Computer Organization + DIGITAL DESIGN

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

UNIT 2 PROCESSORS ORGANIZATION CONT.

Lecture 8: RISC & Parallel Computers. Parallel computers

Week 1. Introduction to Microcomputers and Microprocessors, Computer Codes, Programming, and Operating Systems

ECE 486/586. Computer Architecture. Lecture # 7

3.3 Hardware Parallel processing

ADVANCED COMPUTER ARCHITECTURE TWO MARKS WITH ANSWERS

Chapter 2A Instructions: Language of the Computer

Where Does The Cpu Store The Address Of The

CIT 668: System Architecture. Computer Systems Architecture

Chapter 13 Reduced Instruction Set Computers

Lecture 23. Finish-up buses Storage

PART A (22 Marks) 2. a) Briefly write about r's complement and (r-1)'s complement. [8] b) Explain any two ways of adding decimal numbers.

AVR Microcontrollers Architecture

ARM Processor. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

omputer Design Concept adao Nakamura

SYLLABUS. osmania university CHAPTER - 1 : REGISTER TRANSFER LANGUAGE AND MICRO OPERATION CHAPTER - 2 : BASIC COMPUTER

A Review of Chapter 5 and. CSc 2010 Spring 2012 Instructor: Qian Hu

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1

ECE 341. Lecture # 15

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Transcription:

Introduction to Computer Science William Hsu Department of Computer Science and Engineering National Taiwan Ocean University

Chapter 2: Data Manipulation The successor to Intel's Haswell CPU technology, "Broadwell", has been revealed and shown working here at the Intel Developer Forum in San Francisco. The chip is built using a whole new production process that shrinks Haswell's 22nm transistors down to 14nm. That is tiny.

2.1 Computer Architecture 2.2 Machine Language 2.3 Program Execution 2.4 Arithmetic/Logic Instructions 2.5 Communicating with Other Devices 2.6 Program Data Manipulation 2.7 Other Architectures

Computer Architecture Central Processing Unit (CPU) or processor Arithmetic/Logic unit versus Control unit. Registers General purpose. Special purpose. AMD s world #1 5GHz CPU. 2014/8/29 4

CPU and Main Memory Connected via a Bus 2014/8/29 5

Computer Architecture Bus. Motherboard. 2014/8/29 6

Intel 4004 Schematics 2014/8/29 7

Intel Core i7 3770k 2014/8/29 8

Processor Speed over Time 2014/8/29 9

IO Bridges Northbridge is connected directly to the CPU via the frontside bus (FSB) Responsible for tasks that require the highest performance. Southbridge, also known as I/O controller hub. 2014/8/29 10

Block diagrams 2014/8/29 11

Stored Program Concept A program can be encoded as bit patterns and stored in main memory. From there, the CPU can then extract the instructions and execute them. In turn, the program to be executed can be altered easily. 2014/8/29 12

Terminology Machine instruction: An instruction (or command) encoded as a bit pattern recognizable by the CPU. Machine language: The set of all instructions recognized by a machine. 2014/8/29 13

Machine Language Philosophies Reduced Instruction Set Computing (RISC) Few, simple, efficient, and fast instructions. Examples: PowerPC from Apple/IBM/Motorola and ARM. Complex Instruction Set Computing (CISC) Many, convenient, and powerful instructions. Example: Intel. 2014/8/29 14

CISC vs RISC CISC Has more complex hardware. More compact software code. Takes more cycles per instruction. Can use less RAM as no need to store intermediate results. RISC Has simpler hardware. More complicated software code. Takes one cycle per instruction. Can use more RAM to handle intermediate results. 2014/8/29 15

Machine Instruction Types Data Transfer: copy data from one location to another. Arithmetic/Logic: use existing bit patterns to compute a new bit patterns. Control: direct the execution of the program. 2014/8/29 16

Registers 8086 2014/8/29 17

Registers (core ix, 64bit) 2014/8/29 18

Adding Values Stored in Memory 2014/8/29 19

Dividing Values Stored in Memory 2014/8/29 20

The Architecture of the Machine Described in Appendix C 2014/8/29 21

Parts of a Machine Instruction Op-code: Specifies which operation to execute. Operand: Gives more detailed information about the operation. Interpretation of operand varies depending on op-code. 2014/8/29 22

The Composition of an Instruction for the Machine in Appendix C 2014/8/29 23

Decoding the Instruction 35A7 2014/8/29 24

An Encoded Version of the Instructions in Figure 2.2 2014/8/29 25

Program Execution Controlled by two special-purpose registers: Program counter: address of next instruction. Instruction register: current instruction. Machine Cycle Fetch Decode Execute (Store) 2014/8/29 26

Decoding the Instruction B258 2014/8/29 27

The Program from Figure 2.7 Stored in Main Memory Ready for Execution 2014/8/29 28

Performing the Fetch Step of the Machine Cycle 2014/8/29 29

Performing the Fetch Step of the Machine Cycle (continued) 2014/8/29 30

Endian Order Depending on which computing system you use, you will have to consider the byte order in which multi-byte numbers are stored, particularly when you are writing those numbers to a file. The two orders are called Little Endian and Big Endian. 31

Little Endian (1) Little Endian means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte long int Byte3 Byte2 Byte1 Byte0 will be arranged in memory as follows: Base Address+0 Base Address+1 Base Address+2 Base Address+3 Byte0 Byte1 Byte2 Byte3 Intel processors (those used in PC's) use "Little Endian" byte order. 32

Little Endian (2) 33

Big Endian Big Endian means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Base Address+0 Byte3 Base Address+1 Base Address+2 Byte2 Byte1 Base Address+3 Byte0 Motorola processors (those used in Mac's) use "Big Endian" byte order. 34

Arithmetic/Logic Operations Logic: AND, OR, XOR Masking Rotate and Shift: circular shift, logical shift, arithmetic shift Arithmetic: add, subtract, multiply, divide Precise action depends on how the values are encoded (two s complement versus floating-point). 2014/8/29 35

Rotating the Bit Pattern 65 h (hexadecimal) One Bit to the Right 2014/8/29 36

Communicating with Other Devices Controller: An intermediary apparatus that handles communication between the computer and a device. Specialized controllers for each type of device General purpose controllers (USB and FireWire) Port: The point at which a device connects to a computer Memory-mapped I/O: CPU communicates with peripheral devices as though they were memory cells 2014/8/29 37

Controllers Attached to a Machine s Bus 2014/8/29 38

A Conceptual Representation of Memory- Mapped I/O 2014/8/29 39

Communicating with Other Devices (continued) Direct memory access (DMA): Main memory access by a controller over the bus. Von Neumann Bottleneck: Insufficient bus speed impedes performance. Handshaking: The process of coordinating the transfer of data between components. 2014/8/29 40

Communicating with Other Devices (continued) Parallel Communication: Several communication paths transfer bits simultaneously. Serial Communication: Bits are transferred one after the other over a single communication path. 2014/8/29 41

Communicating with Other Devices (continued) Universal serial bus (USB) Thunderbolt 2014/8/29 42

Transfer speed: USB vs Thunderbolt 2014/8/29 43

Anything faster? InfiniBand (abbreviated IB) is a computer-networking communications standard used in high-performance computing that features very high throughput and very low latency. Data interconnection, switches, storage server connections. 2014/8/29 44

Infiniband speed 2014/8/29 45

Serial attached SCSI Serial Attached SCSI (SAS) is a point-to-point serial protocol that moves data to and from computer-storage devices such as hard drives and tape drives. Replaces the older Parallel SCSI (Parallel Small Computer System Interface ("scuzzy") bus technology in mid 1980s. SAS offers optional compatibility with Serial ATA (SATA), versions 2 and later. This allows the connection of SATA drives to most SAS backplanes or controllers. The reverse, connecting SAS drives to SATA backplanes, is not possible 2014/8/29 46

External SAS connectors 2014/8/29 47

Serial attached SCSI 2014/8/29 48

Data Communication Rates Measurement units: Bps: Bits per second Kbps: Kilo-bps (1,000 bps) Mbps: Mega-bps (1,000,000 bps) Gbps: Giga-bps (1,000,000,000 bps) Bandwidth: Maximum available rate. 2014/8/29 49

Communication Speed over the Years 2014/8/29 50

Programming Data Manipulation Programing languages shields users from details of the machine: A single Python statement might map to one, tens, or hundreds of machine instructions. Programmer does not need to know if the processor is RISC or CISC. Assigning variables surely involves LOAD, STORE, and MOVE op-codes. 2014/8/29 51

Bitwise Problems as Python Code print(bin(0b10011010 & 0b11001001)) # Prints '0b10001000' print(bin(0b10011010 0b11001001)) # Prints '0b11011011' print(bin(0b10011010 ^ 0b11001001)) # Prints '0b1010011' 2014/8/29 52

Control Structures If statement: if (water_temp > 140): print('bath water too hot!') While statement: while (n < 10): print(n) n = n + 1 2014/8/29 53

Functions Function: A name for a series of operations that should be performed on the given parameter or parameters Function call: Appearance of a function in an expression or statement x = 1034 y = 1056 z = 2078 biggest = max(x, y, z) print(biggest) # Prints '2078' 2014/8/29 54

Functions (continued) Argument Value: A value plugged into a parameter. Fruitful functions return a value. void functions, or procedures, do not return a value. sidea = 3.0 sideb = 4.0 # Calculate third side via Pythagorean Theorem hypotenuse = math.sqrt(sidea**2 + sideb**2) print(hypotenuse) 2014/8/29 55

Input / Output # Calculates the hypotenuse of a right triangle import math # Inputting the side lengths, first try sidea = int(input('length of side A? ')) sideb = int(input('length of side B? ')) # Calculate third side via Pythagorean Theorem hypotenuse = math.sqrt(sidea**2 + sideb**2) print(hypotenuse) 2014/8/29 56

Marathon Training Assistant # Marathon training assistant. import math # This function converts a number of minutes and # seconds into just seconds. def total_seconds(min, sec): return min * 60 + sec # This function calculates a speed in miles per hour given # a time (in seconds) to run a single mile. def speed(time): return 3600 / time 2014/8/29 57

Marathon Training Assistant (continued) # Prompt user for pace and mileage. pace_minutes = int(input('minutes per mile? ')) pace_seconds = int(input('seconds per mile? ')) miles = int(input('total miles? ')) # Calculate and print speed. mph = speed(total_seconds(pace_minutes, pace_seconds)) print('your speed is ' + str(mph) + ' mph') # Calculate elapsed time for planned workout. total = miles * total_seconds(pace_minutes, pace_seconds) elapsed_minutes = total // 60 elapsed_seconds = total % 60 print('your elapsed time is ' + str(elapsed_minutes) + ' mins ' + str(elapsed_seconds) + ' secs') 2014/8/29 58

Example Marathon Training Data Time Per Mile Total Elapsed Time Minutes Seconds Miles Speed (mph) Minutes Seconds 9 14 5 6.4981949458 4 46 10 8 0 3 7.5 24 0 7 45 6 7.7419354838 7 7 25 1 8.0898876404 4 46 30 7 25 2014/8/29 59

Other Architectures Technologies to increase throughput: Pipelining: Overlap steps of the machine cycle. Superscalar: Multiple instructions per cycle. Parallel Processing: Use multiple processors simultaneously SISD: No parallel processing MIMD: Different programs, different data SIMD: Same program, different data MISD? 2014/8/29 60

Parallel Processing 2014/8/29 61

Pipelining 2014/8/29 62

Data Hazards 2014/8/29 63

Superscalar 2014/8/29 64

Design and power consumption 2014/8/29 65