Docsity

Memory Organization - Computer Architecture - Lecture Slides, Slides of Computer Architecture and Organization

Partial preview of the text

Download Memory Organization - Computer Architecture - Lecture Slides and more Slides Computer Architecture and Organization in PDF only on Docsity!

• Memory Hierarchy

• Main Memory

• Auxiliary Memory

• Associative Memory

• Cache Memory

• Virtual Memory

• Memory Management Hardware

MEMORY ORGANIZATION

MEMORY HIERARCHY

Magnetic tapes

Magnetic disks

I/O

processor

CPU

Main memory

Cache memory

Auxiliary memory

Register

Cache

Main Memory

Magnetic Disk

Magnetic Tape

Memory Hierarchy is to obtain the highest possible

access speed while minimizing the total cost of the memory system

Memory Hierarchy

MEMORY ADDRESS MAP

RAM 1

RAM 2

RAM 3

RAM 4

ROM

0000 - 007F

0080 - 00FF

0100 - 017F

0180 - 01FF

0200 - 03FF

Component

Hexa address 0 0 0 x x x x x x x 0 0 1 x x x x x x x 0 1 0 x x x x x x x 0 1 1 x x x x x x x 1 x x x x x x x x x

Address bus

Memory Connection to CPU

- RAM and ROM chips are connected to a CPU

through the data and address buses

- The low-order lines in the address bus select

the byte within the chips and other lines in the

address bus select a particular chip through

its chip select inputs

Address space assignment to each memory chip

Example: 512 bytes RAM and 512 bytes ROM

Main Memory

CONNECTION OF MEMORY TO CPU

Main Memory

CS CS RD WR AD

128 x 8 RAM 1

CS CS RD WR AD

128 x 8 RAM 2

CS CS RD WR AD

128 x 8 RAM 3

CS CS RD WR AD

128 x 8 RAM 4

Decoder 3 2 1 0

16-11 10 9 8 7-1 RD WR

Address bus Data bus

CPU

CS CS 512 x 8 AD9^ ROM

1- 7

9

8

Data

Data

Data

Data

Data

ASSOCIATIVE MEMORY

- Accessed by the content of the data rather than by an address

- Also called Content Addressable Memory (CAM)

Hardware Organization

Argument register(A)

Key register (K)

Associative memory array and logic

m words n bits per word

Match register

Input

Read Write

M

- Compare each word in CAM in parallel with the

content of A(Argument Register)

- If CAM Word[i] = A, M(i) = 1

- Read sequentially accessing CAM for CAM Word(i) for M(i) = 1

- K(Key Register) provides a mask for choosing a

particular field or key in the argument in A

(only those bits in the argument that have 1’s in

their corresponding position of K are compared)

Associative Memory

ORGANIZATION OF CAM

Internal organization of a typical cell Cij

Word 1^ C 11

Word i

Word m

Bit 1 Bit j^ Bit n

M 1

M (^) i

M (^) m

Associative Memory

Aj

R S

Output

Match logic

Input

Write

Read

Kj

F (^) ij To M (^) i

A 1 Aj An

K 1 Kj Kn

C1j C1n

Ci1 Cij Cin

Cm1 Cmj Cmn

CACHE MEMORY

Locality of Reference

- The references to memory at any given time

interval tend to be confined within a localized areas

- This area contains a set of information and

the membership changes gradually as time goes by

- Temporal Locality

The information which will be used in near future

is likely to be in use already( e.g. Reuse of information in loops)

- Spatial Locality

If a word is accessed, adjacent(near) words are likely accessed soon

(e.g. Related data items (arrays) are usually stored together;

instructions are executed sequentially)

Cache

- The property of Locality of Reference makes the

Cache memory systems work

- Cache is a fast small capacity memory that should hold those information

which are most likely to be accessed

Cache Memory

Main memory

Cache memory

CPU

PERFORMANCE OF CACHE

All the memory accesses are directed first to Cache

If the word is in Cache; Access cache to provide it to CPU

If the word is not in Cache; Bring a block (or a line) including

that word to replace a block now in Cache

- How can we know if the word that is required

is there?

- If a new block is to replace one of the old blocks,

which one should we choose?

Memory Access

Performance of Cache Memory System

Hit Ratio - % of memory accesses satisfied by Cache memory system

Te: Effective memory access time in Cache memory system

Tc: Cache access time

Tm: Main memory access time

Te = Tc + (1 - h) Tm

Example: Tc = 0.4 μs, Tm = 1.2μs, h = 0.85%

Te = 0.4 + (1 - 0.85) * 1.2 = 0.58μs

Cache Memory

MEMORY AND CACHE MAPPING - DIRECT MAPPING -

Addressing Relationships

Direct Mapping Cache Organization

Memory address Memory data 00000 1 2 2 0

00777 01000

01777 02000

02777

2 3 4 0 3 4 5 0

4 5 6 0 5 6 7 0

6 7 1 0

Index address Tag^ Data 000 0 0^ 1 2 2 0

777 0 2^ 6 7 1 0

Cache memory

Tag(6) Index(9)

32K x 12

Main memory

Address = 15 bits Data = 12 bits

512 x 12

Cache memory

Address = 9 bits Data = 12 bits

00 000

77 777

000

777

  • Each memory block has only one place to load in Cache
  • Mapping Table is made of RAM instead of CAM
  • n-bit memory address consists of 2 parts; k bits of Index field and n-k bits of Tag field
  • n-bit addresses are used to access main memory and k-bit Index is used to access the Cache

Cache Memory

DIRECT MAPPING

Direct Mapping with block size of 8 words

Operation

- CPU generates a memory request with (TAG;INDEX)

- Access Cache using INDEX ; (tag; data)

Compare TAG and tag

- If matches -> Hit

Provide CacheINDEX to CPU

- If not match -> Miss

M[tag;INDEX] <- CacheINDEX

Cache[INDEX] <- (TAG;M[TAG; INDEX])

CPU <- CacheINDEX

Index (^) tag data 000 0 1 3 4 5 0 007 0 1^ 6 5 7 8 010 017

Block 0

Block 1

Block 63

Tag Block Word

INDEX

Cache Memory

BLOCK REPLACEMENT POLICY

Many different block replacement policies are available

LRU(Least Recently Used) is most easy to implement

Cache word = (tag 0, data 0, U0 );(tag 1, data 1, U1 ), Ui = 0 or 1(binary)

Implementation of LRU in the Set Associative Mapping with set size = 2

Modifications

Initially all U0 = U1 = 1

When Hit to (tag 0, data 0, U0), U1 <- 1(least recently used)

(When Hit to (tag 1, data 1, U1), U0 <- 1(least recently used))

When Miss, find the least recently used one(Ui=1)

If U0 = 1, and U1 = 0, then replace (tag 0, data 0)

M[tag 0, INDEX] <- Cache[INDEX](data 0)

Cache[INDEX](tag 0, data 0, U0) <- (TAG,M[TAG,INDEX], 0); U1 <- 1

If U0 = 0, and U1 = 1, then replace (tag 1, data 1)

Similar to above; U0 <- 1

If U0 = U1 = 0, this condition does not exist

If U0 = U1 = 1, Both of them are candidates,

Take arbitrary selection

Cache Memory

CACHE WRITE

Write Through

When writing into memory

If Hit, both Cache and memory is written in parallel

If Miss, Memory is written

For a read miss, missing block may be

overloaded onto a cache block

Memory is always updated

-> Important when CPU and DMA I/O are both executing

Slow, due to the memory access time

Write-Back (Copy-Back)

When writing into memory

If Hit, only Cache is written

If Miss, missing block is brought to Cache and write into Cache

For a read miss, candidate block must be

written back to the memory

Memory is not up-to-date, i.e., the same item in

Cache and memory may have different value

Cache Memory

ADDRESS MAPPING

Organization of memory Mapping Table in a paged system

Address Space and Memory Space are each divided

into fixed size group of words called blocks or pages

1K words group Page 0

Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7

Block 3

Block 2

Block 1

Address space^ Block 0 N = 8K = 2^13

Memory space M = 4K = 2^12

Block 0 Block 1 Block 2 Block 3

MBR

Table address

Presence bit

Page no. Line number Virtual address

Main memory address register Memory page table

Main memory 11 00

Virtual Memory

ASSOCIATIVE MEMORY PAGE TABLE

Assume that

Number of Blocks in memory = m

Number of Pages in Virtual Address Space = n

Page Table

- Straight forward design -> n entry table in memory

Inefficient storage space utilization

<- n-m entries of the table is empty

- More efficient method is m-entry Page Table

Page Table made of an Associative Memory

m words; (Page Number:Block Number)

1 0 1 Line number

Page no.

Argument register

Key register

Associative memory

Page no. Block no.

Virtual address

Page Fault

Page number cannot be found in the Page Table

Virtual Memory