39
FS 1 Computer Architecture Med 1 Cristiano Capuzzo

FS 1 Computer Architecture Med 1 Cristiano Capuzzo

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

FS 1 Computer ArchitectureMed 1

Cristiano Capuzzo

Cristiano Capuzzo

• Born and raised in Venice Italy• Laurea (Master’s) in 1998, thesis on Cycle

Optimizations, specialized in computer architecture, distributed systems and network systems

• 1999-2000 London - Client Applications Developer in Real time systems

• 2000-2004 Silicon Valley, California – Design and development of large scale, network controlled, real time systems; development of media management systems

Material for this lecture

• Extract from : “Computer Architecture, a quantitative approach” Hennessy Patterson – Morgan Kaufmann

• Slides from web site or “some other way”

• Nothing too detailed just try to get the gist of it

Objectives of this lecture

• Providing a basic understanding of the computational machine

• Describing at a higher level the various components of a computer and the way they interact with each other

• Getting overall the audience to feel they have a good understanding of “the was computers work”

Hardware vs. Software

• What is hardware? Everything that can be touched in a computer system: the chassis, the power cord, the boards, the integrated circuits and so on. Often, though, we refer to the electronic components, when talking about hardware

Electronics

• A discipline that makes use of electrical phenomena as pieces of information, in a broader sense

• Music from an MP3 player, a street light, the computer are electronic devices

• Nowadays electronics relies mostly on semiconductors technology

• Semiconductors: elements with mixed characteristics as far as electrical conductivity

• Semiconductor elements: silicon, germanium

Semiconductor Technology

• Metals conduct electricity, insulants don’t, semiconductors conduct only above a certain temperature

• Drugged semiconductors have increased electrical potential, positive or negative

• By alternating three layers with opposite charges, you get a transistor

Transistor

• Basic functionality: if a current enters the middle part (base) a current goes through the whole transistor, otherwise it doesn’t.

• It is an electronic switch, the current in the base could come from another transistor

Analog vs. digital - bit

• Analog devices work thanks to an analogy between a physical phenomena and another, e.g. a thermometer, a radio transmitter, etc.

• Digital devices use transistors as switches, the information is an alternative between two logic states, which can be electrically modified. True – False, 0 – 1. This basic amount of information is called bit

Binary numeric system

• Only two digits are available to computers, hence they use a binary numeric system

• Any type of operation can be performed in any numeric system, octal, binary, decimal, hexadecimal

• The hexadecimal system is widely used as its numbers are powers of binary numbers, just like we use thousand or millions

Binary Numeric System

• Like the decimal numeric system it is positional, the actual number is the result of the multiplication of the digit in a certain position by the power of ten in that position:

• In decimal: • 154 is 1×10² + 5×10¹ + 4×10º = 154• In binary:• 1010 is 1×2³ + 0×2² + 1×2¹ + 0×2º = 10

Computers logic

• Before transistor there were valves but the logic was the same: two states, open and close, which were used to store information and the possibility to invert them.

• Yes and no, 0 and 1, true or false and their negation, are the fundamentals of logic, from them all mathematics, and by extension all concepts, can be derived.

Bytes, Words

• A byte is a sequence of 8 bits

• It can represent an integer number that goes from 0 to 255 or (2^8) – 1

• A word, two bytes, can represent an integer number up to (2^16) – 1

• The byte is the fundamental information unit in computer technology

0 1 1 0 1 1 1 0

A byte

Memory

• RAM (Random Access Memory): there can be random access to data and the information is lost after the power goes off. A byte is retrieved providing its address, which is a sequence of bits

• ROM (Read Only Memory), permanent memory, in which the information persists after the power goes off

Microprocessors

• Microprocessors (transistor dimensions in the order of a millionth of meter) are the real computing part of the machine. They are called also CPUs (Central Processing Unit)

• All the other elements are meant to convey information to the microprocessor (memory, hard disk) or to the user (I/O devices)

Microprocessor

I/OInput/Output

Every computationalstep happens here

Memory

Data to and fromthe CPU

Datapath

• Microprocessors have themselves some sort of tiny memory (registers) and an ALU (Arithmetic Logic Unit) that performs very simple operations on the data provided in the CPU registers

• Datapath: ALU + registers + communication lines between them Registers

ALU

Buses

Output

Datapath

Control

• The control part of the microprocessor is a “microcomputer” itself that determines every operation performed in the Datapath.

• The Control reads a set of micro-instructions and acts accordingly, determining which data are fetched to the ALU etc.

Microprocessor Scheme

Registers

ALU

Buses

OutputDatapath

Microprogrammed Control(coordinates every operation

In the datapath throughmicroinstructions)

Coordination

Program counter(determines nextInstruction to be

executed)

Multiprogramming intro

• Interesting aspect of CPUs: ALU + registers + program counter (which determines next instruction to be executed) are the state of the processor

• The state of the processor is what is saved when switching from one program to another in multiprogramming, like when we have 10 Internet Explorer browsers open, even though only one CPU is available

Essentials of CPUs

• CPUs, also known as microprocessors, are the core of our computer and perform operations, but they are themselves at the same time like microcomputers, with their own memory (registers), the control, that determines the flow of actions, and an ALU that performs arithmetic-logic operations

Instruction Set

• Instruction set architecture: defines the operations the programmer or compiler writer can perform on the computer

• The instructions can be quite different for different CPUs; have their operands (arguments) stored in different places (registers, stack, main memory), the number of operands can vary, so can their size and so can the number of operations available

• Most machines use registers, which are very high speed memory locations internal to the CPU

Registers• A register is a storage element

within the CPU• Suppose we need to execute

the code a = a + b;• The values of a and b will be

sent to the registers through two different buses and the ALU will perform the operation

• The previous operation, translated by the compiler will result in something like:

MOV(R1, a) MOV(R2, b) ADD(R1,R2) meaning R1 <- R1 + R2

CPU

a

b

R1

+R2

Instruction Set Fundamentals

• The instruction set of a machine can vary from 50 to 300 instructions

• They are very simple operations on binary numbers, which performed in great number and at huge speed can result in, nowadays very complex, high level operations

• Compilers translate from higher level languages to the one defined by the instruction set

Memory

• What is memory: a sequence of bits, organized in a series of bytes that we can access randomly or sequentially

• The memory can be permanent, i.e. it maintains the information even after the machine is disconnected from power (ROM - read only memory) or it can be temporary, and lose all info when the machine is switched off (RAM – random access memory)

Memory speed

• Memory speed is inversely proportional to the dimension of the circuitry. But the smaller the memory chips are, the more expensive they are because of the technological process involved with producing it. Hence, the faster the memory the more expensive it is.

• This is the reason why all memory in a computer can’t be in a technology similar to the one used to produce MP3 players

Criteria to make the most of the little memory available

• As only a small amount of memory can be very expensive and fast, while most of it has to be slower and cheaper, a criteria has been developed to make the most of the little quantity of fast memory available

• The analysis of programs use and the memory accesses related to them has allowed computer architecture designers to recognize two fundamental principles

Principles of locality

• Principle of temporal locality: if a memory location has been accessed at a certain point in time there is a high chance it will be accessed again in a close point in time

• Principle of space locality: if a memory location has been accessed at a certain point in time there is a high chance a memory location close to it will be accessed again in a close point in time

Principles of locality

2324

“New MyWord Document” command instruction address532

‘a’

3412

6924

“Save MyWord Document” command instruction address

The two save command is likely to be Used more than one time (temporal locality)The two commands are related and locatedin close memory locations (spatial locality)

Name of a file opened ends here

Temporal Locality example

• Accesses to memory locations are linked to the individual use of computer systems, but think of an e-mail application

• When you open it, most of the times the tasks that you perform are linked: you read one email, and then you are likely to read another one, and one more, and that results in repeated accesses to the same memory locations, containing the code allowing the “Read e-mail” task to be performed

Spatial Locality example

• Again in the case of e-mail, as programs are written by humans and follow a certain consistency, if you perform an operation related to a previous one this is likely to be located in an area of memory close to the area accessed in the previous operation

• After or in between reading emails, you are likely to write some

Principles of locality e.g.

92732

“Send e-mail” command instruction address23

2543

90 81

78

“Read e-mail” command instruction address

The three save commands are likely to be used more than one time (temporal locality)They are also likely to be related and locatedin close memory locations (spatial locality)

“Compose new e-mail” command instruction address

Memory Speed

• This principles are of great use because computers can only be equipped with very small quantities of very fast memory

• The speed of memory is very much related to the technology employed. Smaller hardware is faster because of signal propagation through semiconductors, plus the bigger the memory the more time consuming the addressing process is going to be

Data kept in higher level memory

• Computers boast, generally, a small amount of very fast memory, both to reduce cost and to have faster access to “some data”

• Which data? The most recent one, according to the temporal locality principle, and the data close to it, according to the spatial locality principle

Memory types• Many different levels of memory are available, with different speed

and costs. The most expensive and fastest having a smaller size. Hence the concept of hierarchy.

• NAME TYPICAL SIZE ACCESS TIME (ns) MANAGED BY

• REGISTERS < 1 KB 10

COMPILER• CACHE < 1 MB 20

HARDWARE• MAIN MEMORY < 2 GB 100

OPERATING SYSTEM• DISK STORAGE < 1 TB 20,000,000

OS/USER

Memory Hierarchy

Registers

Cache

Main Memory

Storage (Disk)

< 1 KB

< 1 MB

< 2 GB

< 1 TB

Memory blocks

• The need for keeping closer data together and to have a criteria to move memory between levels of the hierarchy has led to the concept of memory blocks

• The constant swapping of blocks up and down the hierarchy can cause major delay in the program execution. Rarely nowadays microprocessors are not fast enough. In most cases, delay in execution is due to lack of memory and thrashing.

• Lack of memory can ultimately cause a program to fail for impossibility of performing all the tasks required at the same time and makes it more likely that bad program design decisions have a major impact on the execution, with potential failures (access to wrong memory location; sometimes result is disastrous)

Main memory–Storage Relationship

Block A

Hard disk

Block B Block C

Block E Block F

Block G Block H Block I Block J

Block K

Main Memory

Block D

If a block, J is notin main memory,and has to be loadedfrom the storage,if there is no placefor it, anotherblock has to go down to storage

Block A Block B Block C

Block E Block FBlock D

Blocks – Main memory - Storage

• The minimum unit of information that can be present or not present in main memory is a block

• If a block is needed by the CPU it is searched for in the cache (upper level); if it is not there, it is searched for in main memory and if this is a miss, too, then it is the turn of the storage (hard disk)

Summary

• Hardware vs. Software• Electronics• Analog vs. Digital• Binary Numeric System• Bytes Words• Memory• Memory Speed• Principles of Locality• Memory Blocks