본문 바로가기
Computer Architecture/컴퓨터구조[01]

[컴퓨터구조] 1113 (2) Ch5. Cache & Memory Systems

by leziwn.cs 2023. 11. 13.
Memory Technology
  • SRAM (Static RAM): CPU 내의 캐시 메모리에서 사용된다.
  • DRAM (Dynamic RAM)
  • Magnetic disk: 하드디스크 --> store everything in non-volatile way.

 

Principle of Locality
  • Temporal locality: Items accessed recently are likely to be accessed again soon.
  • Sptial locality: Items near those accessed recently are likely to be accessed soon.
Taking Advantage of Locality

▶ Memory hierarchy

  1. 모든 것을 disk에 저장한다.
  2. Disk에서 가장 최근에 사용된 것(temporal locality), 가장 가까운 것(spatial locality)을 DRAM으로 복사한다.
  3. DRAM에서 가장 최근에 사용된 것, 가장 가까운 것을 SRAM (cache memory)으로 복사한다.

 

Memory Hierarchy Levels
  • Block: "unit" of copying
  • 상위 레벨에 데이터가 존재한다면: Hit
    - Hit ratio: hits/accesses
  • 상위 레벨에 데이터가 존재하지 않는다면: Miss
    - Miss ratio

 

Cache Memory

: The level of the memory hierarchy closest to the CPU.

  • 하위 레벨 메모리에서 cache memory로 옮길 때는 addressing을 해야 한다.

 

Direct Mapped Cache

Direct Mapped Cache

: Memory 하위 3-bit와 같은 주소를 가지는 cache memory로 addressing된다.

 

Valid Bits & Tags
  • Valid bit: 캐시 메모리에 data가 들어 있는지 여부를 나타낸다. (N, Y)
  • Tag: 캐시 주소(memory 하위 3-bit) 이외의 나머지 주소를 저장한다.

 


Cache Example

▷ 조건:

  • Cache: 8 blocks (--> 8개의 block을 구분하기 위해서는 3 bits가 필요함)
  • Memory: 4 bytes/block: Block 1개 당 4 bytes
  • Direct mapped

Initial state

 

Memory block address: 10110 --> Cache block address: 110

  • 해당 cache block은 비어 있으므로, 채워 넣는다.
  • 이때, Data에는 전체 Memory block address를 저장한다.

 

Memory block address: 11010 --> Cache block address 010

  • 해당 cache block은 비어 있으므로, 채워 넣는다.

 

접근하고 싶은 memory address가 있다. --> Hit!

 

Hit event!

 

Miss event --> 수정한다!

  • 접근하고자 하는 memory address가 있었는데 cache에 저장되어 있는 정보가 달랐다. --> 수정한다!

 


Cache Example: Larger Block Size

▷ 조건:

  • Cache: 64 blocks (--> 64개의 block을 구분하기 위해서는 6 bits가 필요함)
  • Memory: 16 bytes/block: Block 1개 당 16 bytes

Cache Example: Larger Block Size

▶ Index: 000000, 000001, 000010, ... 111110, 111111 (6 bits: 64개의 cache block을 구분하기 위함)

▶ V (valid bit)

▶ Tag (22 bits)

▶ Offset (4 bits): memory의 16-byte를 구분한다. (2^4 = 16)

▶ Data

 

 

 

 

 

출처: 이화여자대학교 이형준교수님 컴퓨터구조

'Computer Architecture > 컴퓨터구조[01]' 카테고리의 다른 글

[컴퓨터구조] 1120  (0) 2023.11.21
[컴퓨터구조] 1115  (0) 2023.11.15
[컴퓨터구조] 1113 (1)  (0) 2023.11.13
[컴퓨터구조] 1108  (0) 2023.11.09
[컴퓨터구조] 1106  (0) 2023.11.09