COSC 2021: Computer Organization Instructor: Dr. Amir Asif...

31
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Section E Handout # 1: Computer Abstractions and Technology Topics: 1. High level language versus Assembly language versus Machine Language 2. Categorization of Software: Applications, Systems, Hardware 3. Components of a Computer: Input, Output, Memory, Control, and Datapath 4. Integrated Circuits (IC’s) Patterson: Sections 1.1 – 1.4. Read 1.8 for history of computer development.

Transcript of COSC 2021: Computer Organization Instructor: Dr. Amir Asif...

Page 1: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

COSC 2021: Computer Organization

Instructor: Dr. Amir Asif

Department of Computer Science

York University

Section E

Handout # 1: Computer Abstractions and Technology

Topics:

1. High level language versus Assembly language versus Machine Language

2. Categorization of Software: Applications, Systems, Hardware

3. Components of a Computer: Input, Output, Memory, Control, and Datapath

4. Integrated Circuits (IC’s)

Patterson: Sections 1.1 – 1.4. Read 1.8 for history of computer development.

Page 2: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

COSC2021: Computer Organization

Section E

Course Instructor: Amir Asif

Contact Information: Instructor Teaching Assistants

Office: CSEB 3032 TBA

[email protected]

(416) 736-2100 X70128

URL’s for the course: https://wiki.cse.yorku.ca/course/2021/

https://wiki.cse.yorku.ca/course_archive/2010-11/F/2021/

Text: D. A. Patterson and J. L. Hennessey, Computer Organization and Design,

San Francisco, CA: Morgan Kaufmann Publishers, Inc., 4th edition, 2008

Class Schedule: MW 17:30 – 19:00, Room TEL0016

Office Hours: Instructor: CSEB 3032, MT 16:30 – 17:30

Teaching Assistants: TBA

Laboratory: MT, 1900 – 22:00, CSE 1006

Assessment: Quizzes/Assignments: 10%

Lab Exercises: 35%

Mid-term Exam: 20%

Final Exam: 35%

Page 3: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

3

Future Applications of Computer (1)

Page 4: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

4

Future Applications of Computer (2)

Page 5: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

5

Future Applications of Computer (3)

Page 6: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

6

Future Applications of Computer (4)

Page 7: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

7

Future Applications of Computer (5)

Page 8: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

8

Future Applications of Computer (6)

Page 9: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

9

Future Applications of Computer (7)

“Had the transportation industry kept pace with the computer industry, today we could travel New

York to London in a second for about 50 cents !” (Patterson, 1998)

What is CSE 2021 about?

The course explains what is inside a computer, describing its hardware (HW), and introducing the

assembly language representation of a program compiled from a high level language.

You will learn:

1. How computers work?

2. How to analyze their performance?

3. How to code directly in MIPS?

3. What are the issues affecting modern processors (e.g. caches, pipelines)?

Why do I learn this stuff?

1. To build better software people use (improved performance)

2. To offer expert advice in applications, purchasing, etc.

Page 10: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

10

Binary Digits (Bits)

— Communication between different components of a computer as well as storage takes place

in terms of on and off electrical signals

— Symbols used to represent these electrical states are the numbers 1 and 0; binary digit 1

corresponding to high voltage and binary digit 0 corresponding to low voltage

— All operations and data inside a computer are expressed in terms of the binary digits or bits

1 0 1 0 1 1 0 0 1

Communication

Signal

Page 11: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

11

Hardware and Software Interface

— Software can be categorized in different categories:

1. Systems SW: provides commonly useful services to the

hardware, e.g., operating systems, compilers, and assemblers.

Operating systems interface between a user’s program and

the hardware providing: (a) basic input/output capabilities;

(b) storage and memory allocation, and; (c) protecting

sharing among simultaneous applications.

Compilers transform high language programs into

instructions that machine can execute.

2. Applications SW: are programs / packages used by the

computer users, e.g., Excel sheet, Emacs / vi text editor.

— Such a simplified view of software has certain problems, e.g.,

how to categorize compilers that produce assembly language

programs for both applications and systems software.

Activity 1: Give some examples of common operating systems?

Hardware

Applications SW

Systems SW

Fig. 1.2

Page 12: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

12

Categorization of Software

— More realistic categories for software are shown below:

O p e r a t i n g s y s t e m s

A p p l i c a t i o n s s o f t w a r e

l a T E X

V i r t u a l m e m o r y

F i l e s y s t e m

I / O d e v i c e d r i v e r s

A s s e m b l e r s

a s

C o m p i l e r s

g c c

S y s t e m s s o f t w a r e

S o f t w a r e

Page 13: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

13

Instructions

— Instructions: are commands given to a computer to perform a particular task.

Example: Addition of variables A and B

High Level Language: (A + B)

Binary notation for the add operation: 100011001010000

— Binary machine language program: is a one-to-one binary representation of a program

written in a high level language. Clearly, binary machine language programs are tedious to

write and debug.

— Instead a symbolic notation is used as an intermediate step between the high level language

and its binary representation. This symbolic notation is referred to as the assembly language.

Assembler is a program that translates assembly language instructions to their binary version.

Example: Addition of variables A and B

High Level Language: (A + B)

Assembly Language: add A,B

Binary notation for the add operation: 100011001010000

Page 14: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

14

Levels of

Programming

High level language: is a portable

language composed of words and

algebraic expressions that a non-

computer engineer can write.

Why use High-level Language?

1. Ease in writing & debugging

2. Improved productivity

3. HW independence

Compiler: converts a program

written in high-level language

into its equivalent symbolic

assembly language representation.

Assembler: translates

assembly language into the binary

machine language.

s w a p ( i n t v [ ] , i n t k ) { i n t t e m p ;

t e m p = v [ k ] ; v [ k ] = v [ k + 1 ] ; v [ k + 1 ] = t e m p ;

}

s w a p : m u l i $ 2 , $ 5 , 4 a d d $ 2 , $ 4 , $ 2 l w $ 1 5 , 0 ( $ 2 ) l w $ 1 6 , 4 ( $ 2 ) s w $ 1 6 , 0 ( $ 2 ) s w $ 1 5 , 4 ( $ 2 ) j r $ 3 1

0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

B i n a r y m a c h i n e l a n g u a g e p r o g r a m ( f o r M I P S )

C c o m p i l e r

A s s e m b l e r

A s s e m b l y l a n g u a g e p r o g r a m ( f o r M I P S )

H i g h - l e v e l l a n g u a g e p r o g r a m ( i n C )

Page 15: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

15

Instruction Set Architecture (1)

— Computer Architecture = Instruction Set Architecture (ISA) + Machine Organization

— Machine Orgnaization: Ways in which different computer components (Registers, ALU,

Shifters, Logic Units, ...) are interconnected.

— Recall instructions are commands given to a computer to perform a particular task.

— Instruction Set: is a collection / library of instructions that a computer can execute.

instruction set

software

hardware

Page 16: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

16

Instruction Set Architecture (2)

— Programs written for a computer can only use the instructions provided in its instruction set.

— Examples of modern instruction set architectures (ISA’s):

1. 80x86/Pentium/K6/MMX (Intel, 1978-96)

2. DEC Alpha (Digital,1992-97) v1, v3

3. MIPS (SGI, 1986-96) I, II, III, IV, V

4. SPARC (Sun, 1987-95) v8, v9

5. RISC (HP/IBM, 1986-96) v1.1, v2.0

— Instructions in the MIPS instruction set can be divided in five categories:

1. Arithmetic operations: add,sub(subtract),mult(multiply),div (division),etc.

2. Logical operations: and, or, sll (shift left logical), etc.

3. Data Transfer: lw (load), sw (save), etc.

4. Conditional branch: beq(branch if equal), slt set if less than), etc.

5. Unconditional branch: j (jump), etc.

Activity 1: Will the ISA developed on one machine be compatible to another machine of a different

manufacturer?

Page 17: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

17

Common Computer Architectures

Data alignment means putting the data at a memory offset equal to some multiple of the word size

Memory protection prevents a process from accessing memory that has not been allocated to it.

Addressing mode specifies how to calculate the effective memory address of an operand.

Memory mapped I/O: uses the same address bus to address both memory and I/O devices, and the

CPU instructions used to access the memory are also used for accessing devices. (Port-mapped)

Page 18: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

18

Computer Architecture: The Anatomy of Computers

Hardware Elements: Computer, Monitor, Keyboard, Mouse, Network, …

Output

device

Input

device

Input

device

Network

cable

Page 19: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

19

Computer Architecture

Page 20: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

20

Inside a PC: The Big Picture (4)

Processor

Control

Datapath

Memory

(RAM,

Hard Disk,

CD)

Input

(keyboard)

Output

(CRT)

Page 21: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

21

Input Devices: Mouse

Keyboard, Mouse, Joystick, Touch Screen, Stylus, Graphic Tablet, …

Fig. 1.5: Inside of a Mechanical Mouse

Operation of a Mouse:

1. Consists of a small ball

2. Ball has contacts with 2

wheels on the x and y axis

3. Each wheel increments or

decrements a counter

4. Counters records how far the

mouse has moved

5. Cursor on the screen is moved

accordingly

Page 22: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

22

Input Devices: Mouse (2)

Operation of an optical mouse:

1) LED illuminates desktop

2) Current position is the reference location

3) A small low-resolution camera determines

the location of the LED illuminated site

4) Some basic image processing algorithm is

used to compute the x and y movements.

Supersedes roller-ball mechanical mouse.

Page 23: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

23

Computer: Opening the box

Bottom of laptop with DRAM

mounted as DIMMs (Dual

inline memory modules)

Page 24: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

24

Inside a PC: Motherboard (2)

PC Motherboard consists of a central processing unit (CPU), ISA and PCI card slots, Dynamic

random access memory (DRAM), and connectors for I/O devices

ISA & PCI

card slots

CPU

Audio

connector

Parallel

connector

Page 25: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

Inside a Microprocessor

AM

D B

arcelona

Upto 4 core (processors) are allowed.

Cache (L1, L2, L3) is small, fast memory that acts as a buffer for DRAM (slow memory)

FPU stands for floating point unit, performing decimal operations.

DDR stands for Double data rate SDRAM.

Page 26: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

26

Inside a PC: CPU (3)

CPU comprises of two main

components:

1. Datapath: is a collection of

functional units that perform

data processing operations. It

consists of ALU, data and

instruction cache, bus, and

integer and floating point data

path. The later performs integer

and floating point arithmetic

operations

2. Control: tells the datapath

memory and I/O devices what

to do based on the program

B r a n c h

C o n t r o l

D a t a c a c h e

I n s t r u c t i o n c a c h e

B u s I n t e g e r d a t a - p a t h

F l o a t i n g - p o i n t

d a t a p a t h

Page 27: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

27

Output Device: Cathode Ray Tube

— Cathode ray tube (CRT) consists of an electronic gun that shoots electrons onto a

phosphorous-coated screen (display).

— The screen is divided into picture elements (or pixels) with a resolution varying from (512 x

340) to (1560 x 1280) pixels.

— The electronic gun illuminates each pixel depending upon the given intensity.

— Typically the number of intensity levels depend upon the number of bits allocated per pixel.

For 8 bits/pixel gray-scale displays, the number of intensity levels are 256.

— Color displays use 24 bits/pixel, 8 bits for each of the three primary colors (R,G,B).

— Screen is refreshed 30 to 75 times every second.

Electronic gun

Electron beam

Phosphorous-coated

screen

A CRT Display

Page 28: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

Innovation (1)

— Technology used in computers have advanced from vacuum tubes (1951), transistors (1965),

Integrated circuits (IC’s) (1975), to Very large scale integrated circuits (VLSI) (1995).

— Capacity of a DRAM has quadrupled almost every 3 years

Year Size (bit)

1980 64 Kb

1983 256 Kb

1986 1 Mb

1989 4 Mb

1992 16 Mb

1996 64 Mb

2000 256 Mb

2004 512 Mb

2007 1 Gb

Fig. 1.14: Capacity of DRAM over 1980 - 2002

Page 29: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

29

Innovation (2)

Moore's Law states that the transistor density on integrated circuits doubles every couple of

years. This exponential growth and ever-shrinking transistor size has resulted in increased

performance with decreased cost.

Page 30: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

30

Where are we headed?

— Performance issues (Section 1.4) vocabulary and motivation

— MIPS instruction set architecture (Chapter 2)

— Arithmetic and how to build an ALU (CD Appendix C)

— Constructing a processor to execute our instructions (CD Appendix D)

— Single Cycle versus Multicycle implementation (Chapter 4)

— Pipelining to improve performance (Chapter 4)

— Memory: caches and virtual memory (Chapter 5)

Page 31: COSC 2021: Computer Organization Instructor: Dr. Amir Asif ...asif/2021Fall10/handout1v2_full.pdf · COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer

31

Learning Objectives

By the end of the course, you will be able to:

1. Translate high-level programs (such as those in Java or C) to assembly language and, finally, in

machine language on an instruction-by-instruction basis.

2. Write and debug simple programs involving input/output routines, arithmetic operations,

decisions, repetitions, and procedures directly in an assembly language such as MIPS.

3. Design a prototype Arithmetic Logic Unit (ALU) from basic building blocks such as gates and flip

flops using elementary logic design concepts.

4. Construct the datapath and control unit of the processor using either of the: (i) single cycle

implementation; (ii) multiple cycle implementation, or (iii) pipelining; and explain how computer

execute programs in these implementations.

5. Abstract computer hardware by building modules in a hardware description language such as

Verilog.