fundamentals of computer science, 2nd part

24
Lecture 01 1 Fundamentals of Computer Science, 2 nd part Lecture 10 review

Upload: others

Post on 12-Sep-2021

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fundamentals of Computer Science, 2nd part

Lecture 01 1

Fundamentals of Computer Science, 2nd part

Lecture 10review

Page 2: Fundamentals of Computer Science, 2nd part

Lecture 01 2

Module Aim (SYLLABUS PAGE):

• …

• Introduce the main hardware components of a computer and their function.

• Explain the role of an operating system and system software.

• …

Page 3: Fundamentals of Computer Science, 2nd part

Lecture 01 3

A high level view of topics(not in order):

• Computer Architecture• I/O devices and network• Digital Logic• Microarchitecture• Machine Code• Operating Systems• Compilers and interpreters • ….

Page 4: Fundamentals of Computer Science, 2nd part

Lecture 01 4

Multilevel machines

Digital logic

Assembly

Operating System

ISA

Microarchitecture

problem oriented lang.

Hardware

Interpretation

Interpretation

translation(assembler)

translation(compiler)

Human friendly

Page 5: Fundamentals of Computer Science, 2nd part

Lecture 01 5

A Simple 1 CPU computer

control unit

ALU

Registers

main memory I/O device: printer, Disk

Bus

Bus: parallel wires for transmitting data, address and control signals

CPU

Page 6: Fundamentals of Computer Science, 2nd part

Lecture 01 6

Main Memory (continue)

• All cells in the memory the same numbers of bits

• addresses also are in binary

3 ways of organising a 96-bits memory

Page 7: Fundamentals of Computer Science, 2nd part

Lecture 01 7

Idea behind caching

• heavily used memory should be kept in the cache

• When CPU needs a word, it first looks at the cache. ONLY if the word is not there goes to the main memory

Page 8: Fundamentals of Computer Science, 2nd part

Lecture 01 8

Logical Architecture, a 2nd look

and various other devices mouse, printer, camera,….

Page 9: Fundamentals of Computer Science, 2nd part

Lecture 01 9

Gates

• Digital Logic layer is made of GatesCreating 0,1

� 0 denotes voltage between 0 ,1

� 1 denotes voltage between 2 and 5

� voltage outside not permitted

Gates are electronic devices that compute various functions of two-valued signals

Function?

� mapping INPUT to OUTPUT

Page 10: Fundamentals of Computer Science, 2nd part

Lecture 01 10

examples of gates

input output

What do tables resemble? NOT for negation (inverter), AND for conjunction, OR for disjunction, NAND output 0 iff both input 1, NOR …

Page 11: Fundamentals of Computer Science, 2nd part

Lecture 01 11

Example of Arithmetic circuit

011

101

110

000

XORBA

Page 12: Fundamentals of Computer Science, 2nd part

Lecture 01 12

Memory circuitidea: remember previous value

Solution: the output independent of the input

Example: SR latches

Page 13: Fundamentals of Computer Science, 2nd part

Lecture 01 13

Adder

INPUT via bus 1, 2 OUTPUT via bus 3

Page 14: Fundamentals of Computer Science, 2nd part

Lecture 01 14

Instruction Set Architecture (ISA)• Historically, the first (only) layer

• ISA is the interface between the software and hardware (language that both of have to understand)

Page 15: Fundamentals of Computer Science, 2nd part

Lecture 01 15

ISA level contains the following views of the hardwre:

• Memory model: 8bits cells (bytes)

• Registers:visible at the ISA level, control execution of program, hold temporary results, …

• Instructions: to control what machine does.LOAD, STORE for moving data between register and

memory,…MOVE copy data among the registersArithmetic and Boolean structures

Page 16: Fundamentals of Computer Science, 2nd part

Lecture 01 16

Language translators

Low-level languagesAssembly: each instruction directly translates into

machine code instruction Example: ADD 234 (notice it is not storing anything)High-levelFortran, C, C++, JAVA,…:One instruction corresponds to several machine code

instructions Translate from a high-level language into the machine

language (low-level)� Interpreter� Compiler

Page 17: Fundamentals of Computer Science, 2nd part

Lecture 01 17

Interpretation & Compilation

Interpretation:

translate and execute a high level program statement-by-statement, execution of each statement preceding the translation of the next.

Compilation:

separate translation and execution. First translate all the program then execute.

Notice: if a program statements executes 10 times, it must be translated 10 times by the interpreter.

Page 18: Fundamentals of Computer Science, 2nd part

Lecture 01 18

How to express syntax?

The basic idea is to explain how syntactic categories are formed. This is done by specifying production rules, each of which defines how a particular syntactic category be made from

• terminal symbols

• members of other nonterminal symbols

Page 19: Fundamentals of Computer Science, 2nd part

Lecture 01 19

Example of BNF:

��������������� � ����������������� ������

��� � ������� � � � � ��� � ������������������� ���������

��������� ���� ���� ���� �� ��� � ����������� ����������

��� ��������������������� ������������� ������� ��

������� �����������������������

����������������

��� � ��������������� ����������

����� ���������≠≠≠≠

Page 20: Fundamentals of Computer Science, 2nd part

Lecture 01 20

Compiler

Lexical Analysis

Syntax Analysis

Code Generation

Compiler

source program

object program

Optimization

Page 21: Fundamentals of Computer Science, 2nd part

Lecture 01 21

translation to tokens

�� X ≠ 1 �������X ��X –Y

the lexical analyser translate to tokens:

�� name(X) ≠ num(1) ���� ���

name(X) �� name(X) – name(Y)

TokenType Value

Page 22: Fundamentals of Computer Science, 2nd part

Lecture 01 22

parse tree �� name(X)≠ num(1) �������name(X) �� name(X) – num(1)

conditional

�� condition ���� statement

assignmentrelationname(X)

num(1)≠

���

��

name(X)

expression

operator

name(X) name(Y)–

Page 23: Fundamentals of Computer Science, 2nd part

Lecture 01 23

compiling Java to IJVM

i = j +k;

if (i ==3 )

k = 0;

else

j--;

….

Hex assembly …

j

j

k

j+k

Page 24: Fundamentals of Computer Science, 2nd part

Lecture 01 24

Central issues of OS design

Three main subject

� virtual memory

� File I/O

� parallel processing

Happy Christmas�