memorijski sistem

107
Memorijski sistem

Upload: daisy

Post on 16-Mar-2016

44 views

Category:

Documents


4 download

DESCRIPTION

Memorijski sistem. Processor. Input. Control. Memory. Datapath. Output. The Big Picture. Since 1946 all computers have had 5 components. Tipovi memorija. Hijerarhijska organi z acija memorije. Levels in Memory Hierarchy. Processor-DRAM Gap. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Memorijski sistem

Memorijski sistem

Page 2: Memorijski sistem

Control

Datapath

Memory

Processor

Input

Output

Since 1946 all computers have had 5 components

The Big Picture

Page 3: Memorijski sistem

Tipovi memorija

Page 4: Memorijski sistem

Hijerarhijska organizacija memorije

Page 5: Memorijski sistem

Levels in Memory Hierarchy

Page 6: Memorijski sistem

Microprocessor performance improved 55% per year since 1987, and 35% per year until 1986

Memory technology improvements aim primarily at increasing DRAM capacity not DRAM speed

Processor-DRAM Gap

Page 7: Memorijski sistem

Relative processor/memory speed

Page 8: Memorijski sistem

Relative processor/memory speed

Page 9: Memorijski sistem

MOS memories

RAM's ROM's

DRAMSRAM ROM

FLASHEEPROMEPROM

VOLATILE

Power off: contents lost

NON VOLATILE

Power off : contents kept

Volatile vs non Volatile Types of Memories

Page 10: Memorijski sistem

Percentage of Usage

Page 11: Memorijski sistem

Typical Applications of DRAM

Page 12: Memorijski sistem

Trends in DRAM main memory.

1990 1980 2000 2010

Num

ber o

f mem

ory

chip

s

Calendar year

1

10

100

1000

Large PCs

Work- stations

Servers

Super- computers

1 MB

4 MB

16 MB

64 MB

256 MB

1 GB

4 GB

16 GB

64 GB

256 GB

1 TB

Computer class

Memory size

Small PCs

DRAM Evolution

Page 13: Memorijski sistem

MRAM can replace many ofthers types of memory including SRAM, DRAM, ROM, EEPROM, Flash EEPROM, and feroelectric RAM (FRAM) . Prediction are crystalline structures that users grow on silicon.

Magnetic RAM as Universal Memory

Page 14: Memorijski sistem

Veliki kraj u odnosu na mali kraj

Page 15: Memorijski sistem

Konverzija BE u LE

Page 16: Memorijski sistem

Prezentacija u BE i LE

Page 17: Memorijski sistem

Tipovi poluprovodničkih memorija

Page 18: Memorijski sistem

Struktura memorijskog čipa

Page 19: Memorijski sistem

Address translation

Row decoding & read out

Column decoding

& selection

Tag comparison & validation

Pipelined and Interleaved Memory

Page 20: Memorijski sistem

Interleaved memory is more flexible than wide-access memory in that it can handle multiple independent accesses at once.

Add- ress

Addresses that are 0 mod 4

Addresses that are 2 mod 4

Addresses that are 1 mod 4

Addresses that are 3 mod 4

Return data

Data in

Data out Dispatch

(based on 2 LSBs of address)

Bus cycle

Memory cycle

0

1

2

3

0

1

2

3

Module accessed

Time

Memory Interleaving

Page 21: Memorijski sistem

Tri načina organizacije 96-bitne memorije

Page 22: Memorijski sistem

Povezivanje memorije kod 32-bitnih procesora

Page 23: Memorijski sistem

Memorijska adresa i memorijska mapa

Page 24: Memorijski sistem

Primer 1: Povezivanja memorije kod 32-bitnog procesora

Page 25: Memorijski sistem

Primer 1: Memorijska mapa

Page 26: Memorijski sistem

Primer 1: Realizacija dekodera adresa

Page 27: Memorijski sistem

Primer 2: Memorijska mapa i dekoder kada su M1 i M2 veličine 1 MB

Page 28: Memorijski sistem

Primer 3: Selekcija na osnovu MS bita

Page 29: Memorijski sistem

Preslikavanje memorijskih prostora

Page 30: Memorijski sistem

Tipičan adresni dekoder

Page 31: Memorijski sistem

Realizacija jedne adresne šeme

Page 32: Memorijski sistem

Realizacija dekodiranja adresa korišćenjem komparatora

Page 33: Memorijski sistem

Realizacija dekodera adresa korišćenjem PROM-a

Page 34: Memorijski sistem

Struktura PLD-a

Page 35: Memorijski sistem

ROM model sa programibilnim OR poljem

Page 36: Memorijski sistem

PAL model sa fiksnim OR poljem

Page 37: Memorijski sistem

PAL model sa programibilnim AND i OR poljima

Page 38: Memorijski sistem

Izgled makroćelije

Page 39: Memorijski sistem

Izgled FPGA kola

Page 40: Memorijski sistem

Izgled CPLD ćelije

Page 41: Memorijski sistem

Tipičan način povezivanja memorije

Page 42: Memorijski sistem

Tajming memorije

Page 43: Memorijski sistem

Tajming ciklusa upisa u memoriju

Page 44: Memorijski sistem

Tajming ciklusa čitanja iz memorije

Page 45: Memorijski sistem

Struktura dinamičke memorije

Page 46: Memorijski sistem

Dinamička memorija – logička šema

Page 47: Memorijski sistem

Povezivanje DRAM-ova

Page 48: Memorijski sistem

Povezivanje dinamičkih memorija

Page 49: Memorijski sistem

Tajming kod dinamičkih memorija

Page 50: Memorijski sistem

Povezivanje dinamičkih memorija

Page 51: Memorijski sistem

Virtuelna – fizička adresa

Page 52: Memorijski sistem

Položaj keša u memorijskoj hijerarhiji

Page 53: Memorijski sistem

Memorijski moduli

Page 54: Memorijski sistem

Memorijski moduli

Page 55: Memorijski sistem

Dual-port memorija

Page 56: Memorijski sistem

Struktura kružnog bafera

Page 57: Memorijski sistem

Princip rada kružnog bafera

Page 58: Memorijski sistem

Asocijativna memorija

Page 59: Memorijski sistem

Asocijativna memorija

Page 60: Memorijski sistem

Memorija u sistemu

Page 61: Memorijski sistem

Memorija u sistemu sa većim brojem procesora

Page 62: Memorijski sistem

Princip rada keša se zasniva na lokalnosti- koja može biti:

CPUadrese

podacikeš

kontroler

kešglavna

memorija

podaci

adresepodaci

Keš kontroler posreduje izmedju CPU-a i memorijskog sistema koga čine keš i glavna memorija.

vremenska lokalnost

prostorna lokalnost

Keš memorija

Page 63: Memorijski sistem

Cache memories act as intermediaries between the superfast processor and the much slower main memory.

Level-2 cache

Main memory

CPU CPU registers

Level-1 cache

Level-2 cache

Main memory

CPU CPU registers

Level-1 cache

(a) Level 2 between level 1 and main (b) Level 2 connected to “backside” bus

One level of cache with hit rate hCeff = hCfast + (1 – h)(Cslow + Cfast) = Cfast + (1 – h)Cslow

The Need for a Cache

Page 64: Memorijski sistem

Example

A system with L1 and L2 caches has a CPI of 1.2 with no cache miss. There are 1.1 memory accesses on average per instruction. What is the effective CPI with cache misses factored in? What are the effective hit rate and miss penalty overall if L1 and L2 caches are modeled as a single cache?Level Local hit rate Miss penalty L1 95 % 8 cycles L2 80 % 60 cycles

8 cycles

60 cycles

95% 4%1%

Solution

Ceff = Cfast + (1 – h1)[Cmedium + (1 – h2)Cslow]Because Cfast is included in the CPI of 1.2, we must account for the restCPI = 1.2 + 1.1(1 – 0.95)[8 + (1 – 0.8)60] = 1.2 + 1.1 0.05 20 = 2.3Overall: hit rate 99% (95% + 80% of 5%), miss penalty 60 cycles

Performance of a Two-Level Cache System

Page 65: Memorijski sistem

Cache size (in bytes or words). A larger cache can hold more of the program’s useful data but is more costly and likely to be slower.

Block or cache-line size (unit of data transfer between cache and main). With a larger cache line, more data is brought in cache with each miss. This can improve the hit rate but also may bring low-utility data in.

Placement policy. Determining where an incoming cache line is stored. More flexible policies imply higher hardware cost and may or may not have performance benefits (due to more complex data location).

Replacement policy. Determining which of several existing cache blocks (into which a new cache line can be mapped) should be overwritten. Typical policies: choosing a random or the least recently used block.

Write policy. Determining if updates to cache words are immediately forwarded to main (write-through) or modified blocks are copied back to main if and when they must be replaced (write-back or copy-back).

Cache Memory Design Parameters

Page 66: Memorijski sistem

Temporal- and spatial-locality of reference

When exhibiting spatial locality, a program accesses neighboring memory locations. When displaying temporal locality of reference a program repeatedly accesses the same memory location during a short time period. Both forms of locality occur in the following Pascal code segment:

Temporal locality - the CPU accesses i at three points in a short time period. Spatial locality - assuming that Pascal stores the elements of A into consecutive memory locations6, each loop iteration accesses adjacent memory locations.

Page 67: Memorijski sistem

Assuming no conflict in address mapping, the cache will hold a

small program loop in its entirety, leading to fast execution.

9-instruction program loop

Address mapping (many-to-one)

Cache memory

Main memory

Cache l ine/block (unit of t ransfer between main and cache memories)

Temporal localitySpatial locality

What Makes a Cache Work?

Page 68: Memorijski sistem

Addresses

Time

From Peter Denning’s CACM paper, July 2005 (Vol. 48, No. 7, pp. 19-24)

Temporal:Accesses to the same address are typically clustered in time

Spatial:When a location is accessed, nearby locations tend to be accessed also

Working set

Temporal and Spatial Localities

Page 69: Memorijski sistem

procesor

keš za instrukcije

keš za podatke

glavna memorija

pribavljanje podataka

pribavljanje instrukcija

Harvard arhitektura

Page 70: Memorijski sistem

L1-keš

mikroprocesor

L2-keš

glavnamemorija

1

2L1-keš

mikroprocesor

glavnamemorija

L2-keš

12

backside magistralafrontside magistralafrontside magistrala

L1 i L2 keš

Page 71: Memorijski sistem

mikroprocesor keš

most(bridge)

glavna memorija

procesorska / memorijska magistrala

sistemska / Ulazno-Izlazna magistrala

mikroprocesor

keš glavna memorija

most

magistrala procesora

memorijska magistrala

sistemska / Ulazno-Izlazna magistrala

Položaj keša u sistemu

Page 72: Memorijski sistem

grafički kontroler

Host / PCI most

glavna memorija (DRAM)

CD-ROM kontroler

PCI / ISA most

proširenja

tastatura , miš

AGPSCSI-Host

adapter

LAN- kontroler

mikroprocesor(host) saL1-kešom

L2-keš(SRAM)

IDE

IDE

USB

USB

….

PCIkartica:

ISAkartica: audio

flopi-diskkontroler ….

ISA-Bus

PCI-Bus

magistrala procesora (host magistrala)

Položaj keša u sistemu PC-a

Page 73: Memorijski sistem

Razlika u vremenima pristupa

Page 74: Memorijski sistem

Gradivni delovi keš memorije

Page 75: Memorijski sistem

Princip rada keš memorije

Page 76: Memorijski sistem

Keš memorija – primer organizacije

Page 77: Memorijski sistem

Keš memorija – primer realizacije u dva nivoa

Page 78: Memorijski sistem

031Tag

Tag 0

Tag 1

Tag 2

Tag 2047

28

k0

k1

k2

k2047

...

linija 0

linija 2

linija 1

linija 2047

V D

V D

V D

V D

MUX / DEMUX

22

32

32 323232

selekcija bajta

selekcija reči

selekt

selekcija bajta u okviru reči

ka / sa magistrale podataka

keš pogodak

tag pogodatak

adresa

valid pogodak

Asocijativna keš memorija

Page 79: Memorijski sistem

Asocijativna keš memorija sa FIFO politikom zamene

Page 80: Memorijski sistem

Direktno preslikana keš memorija

031Tag

Tag 0

Tag 1

Tag 2

Tag 2047

linija 0

linija 2

linija 1

linija 2047

V D

V D

V D

V D

MUX / DEMUX

22

32

32 323232

selekcija bajta

selekcija reči

selekt

selekcija bajta uokviru reči

ka / sa magistralepodataka

kešpogodak

tagpogodatak

adresa

validpogodak

Indeks

=

linija 0

linija 2

linija 1

linija 2047

11

17

17 1

1 1

dekoder adresa

Page 81: Memorijski sistem

Primer direktno preslikane keš memorije

Page 82: Memorijski sistem

Preslikavanje adresa kod direktno preslikane keš memorije

Page 83: Memorijski sistem

Direct-mapped cache holding 32 words within eight 4-word lines. Each line is associated with a tag and a valid bit.

3-bit line index in cache 2-bit word offset in line Main

memory locations

0-3 4-7

8-11

36-39 32-35 40-43

68-71 64-67 72-75

100-103 96-99 104-107

Tag Word

address

Valid bits

Tags

Read tag and specified word

Com-pare

1,Tag

Data out

Cache miss

1 if equal

Direct-Mapped Cache

Page 84: Memorijski sistem

Skupno-asocijativna keš memorija031

Tag

Tag 0

Tag 1

Tag 2

Tag 1023

linija 0

linija 2

linija 1

linija1023

V D

V D

V D

V D

22

32

32

selekcija bajta

selekcija reči

selekcija bajta u okviru reči

ka / sa magistrale podataka

keš pogodak

tag pogodatak

adresa

valid pogodak

Indeks

=

linija 0

linija 2

linija 1

linija 1023

1018

1

1

1

linija 0V D

Tag 0linija 0

= 11818

MUX / DEMUX

32 32 32

MUX / DEMUXen

en

32keš

pogodak

1

Page 85: Memorijski sistem

Primer dvostruko skupno-asocijativne keš memorije

Page 86: Memorijski sistem

Two-way set-associative cache holding 32 words of data within 4-word lines and 2-line sets.

Main memory locations

0-3

16-19

32-35

48-51

64-67

80-83

96-99

112-115

Valid bits Tags

1

0

2-bit set index in cache

2-bit word offset in line

Tag

Word address

Option 0

Option 1

Read tag and specified word from each option

Com-pare

1,Tag

Com-pare

Data out

Cache

miss

1 if equal

Set-Associative Cache

Page 87: Memorijski sistem

Položaj keša u sistemu

Page 88: Memorijski sistem

Položaj keša u sistemu – prod.

Page 89: Memorijski sistem

Virtuelni i realni keš

Page 90: Memorijski sistem

Interni i eksterni keš

Page 91: Memorijski sistem

Keš u odnosu na U/I podsistem

Page 92: Memorijski sistem

Procenat promašaja u funkciji od obima keša

Page 93: Memorijski sistem

Procenat promašaja u funkciji od obima keša

Page 94: Memorijski sistem

Politike zamene kod keša

Page 95: Memorijski sistem

Virtual verus Physical memory

Page 96: Memorijski sistem

Program segments in main memory and on disk.

Program and data on several disk tracks

System

Stack

Active pieces of program and data in memory

Unused space

The Need for Virtual Memory

Page 97: Memorijski sistem

Data movement in a memory hierarchy.

Pages Lines

Words

Registers

Main memory

Cache

Virtual memory

(transferred explicitly

via load/store) (transferred automatically

upon cache miss) (transferred automatically

upon page fault)

Memory Hierarchy: The Big Picture

Page 98: Memorijski sistem

Virtual-to-physical address translation parameters.

Virtual address

Physical address

Physical page number

Virtual page number Offset in page

Offset in page

Address translation

P bits

P bits

V P bits

M P bits

Example Determine the parameters for 32-bit virtual addresses, 4 KB pages, and 128 MB byte-addressable main memory.

Solution: Physical addresses are 27 b, byte offset in page is 12 b; thus, virtual (physical) page numbers are 32 – 12 = 20 b (15 b)

Address Translation in Virtual Memory

Page 99: Memorijski sistem

 

The role of page table in the virtual-to-physical address translation process.

Page table

Main memory

Valid bits

Page table register

Virtual page

number

Other f lags

Page Tables and Address Translation

Page 100: Memorijski sistem

 

Virtual memory as a facilitator of sharing and memory protection.

Page table for process 1

Main memory Permission bits

Pointer Flags

Page table for process 2

To disk memory

Only read accesses allow ed

Read & w rite accesses allowed

Protection and Sharing in Virtual Memory

Page 101: Memorijski sistem

 

Page table

Main memory

Valid bits

Page table register

Virtual page

number

Other flags

Virtual address

Memory access 1

Physical address

Memory access 2

The Latency Penalty of Virtual Memory

Page 102: Memorijski sistem

Virtual-to-physical address translation by a TLB and how the resulting physical address is used to access the cache memory.

Virtual page number

Byte offset

Byte offset in word

Physical address tag

Cache index

Valid bits

TLB tags

Tags match and entry is valid

Physical page number Physical

address

Virtual address

Tran

slat

ion

Other flags

Translation Lookaside Buffer

Page 103: Memorijski sistem

Example

 

An address translation process converts a 32-bit virtual address to a 32-bit physical address. Memory is byte-addressable with 4 KB pages. A 16-entry, direct-mapped TLB is used. Specify the components of the virtual and physical addresses and the width of the various TLB fields.

Solution Virtual page number

Byte offset

Byte offset in word

Physical address tag

Cache index

Valid bits

TLB tags

Tags match and entry is valid

Physical page number Physical

address

Virtual address

Tran

slat

ion

Other flags

12

12

20

20

VirtualPage number

416TLB

index

Tag

TLB word width =16-bit tag +20-bit phys page # +1 valid bit +Other flags 37 bits

16-entryTLB

Address Translation via TLB

Page 104: Memorijski sistem

 

Options for where virtual-to-physical address translation occurs.

TLB Main memory Virtual-address

cache

TLB Main memory Physical-address

cache

TLB

Main memory Hybrid-address cache

Virtual- or Physical-Address Cache?

Page 105: Memorijski sistem

A scheme for the approximate implementation of LRU .

0

1

0

0

1

1

0

1

0

1

0

1

0

0

0

1

(a) Before replacement (b) After replacement

Least-recently used policy: effective, but hard to implement

Approximate versions of LRU are more easily implemented Clock policy: diagram below shows the reason for name Use bit is set to 1 whenever a page is accessed

Page Replacement Policies

Page 106: Memorijski sistem

Memory hierarchy parameters and their effects on performance

Parameter variation Potential advantages Possible disadvantages

Larger main or cache size

Fewer capacity misses Longer access time

Longer pages or lines Fewer compulsory misses (prefetching effect)

Greater miss penalty

Greater associativity (for cache only)

Fewer conflict misses Longer access time

More sophisticated replacement policy

Fewer conflict misses Longer decision time, more hardware

Write-through policy (for cache only)

No write-back time penalty, easier write-miss handling

Wasted memory bandwidth, longer access time

Improving Virtual Memory Performance

Page 107: Memorijski sistem

Data movement in a memory hierarchy.

Pages Lines

Words

Registers

Main memory

Cache

Virtual memory

(transferred explicitly

via load/store) (transferred automatically

upon cache miss) (transferred automatically

upon page fault)

Cache memory: provides illusion of very high speed

Virtual memory: provides illusion of very large size

Main memory: reasonable cost, but slow & small

Locality makes the illusions work

Summary of Memory Hierarchy