생성일: 2021년 12월 4일 오후 5:04
What is a Computer?
![](https://media.vlpt.us/images/lsj8706/post/8a976887-c2ed-4b87-a225-2849d2f81deb/Untitled.png)
Abstraction: Virtual vs. Physical Memory
- Programmer sees virtual memory
- The system (system software + hardware, cooperatively) maps virtual memory addresses to physical memory
이상적인 구조
![](https://media.vlpt.us/images/lsj8706/post/ed0b94bf-df89-4dce-a1d4-5322f043bc52/Untitled%201.png)
Memory in a Modern System
![](https://media.vlpt.us/images/lsj8706/post/ac33c403-e46b-43d0-b8b4-d9cda13a1d10/Untitled%202.png)
이상적인 구조의 문제점
- 요구 사항이 서로 상반 된다
- Bigger is slower (용량이 클수록 위치를 결정하는데 오래 걸림)
- 빠를수록 비싸다
- 대역폭이 높을수록 비싸다
Memory는 성능에 매우 중요
![](https://media.vlpt.us/images/lsj8706/post/e016eb51-fbed-4f02-909a-d655bf83639a/Untitled%203.png)
- 메모리로 인해 계산에 병목(Bottlenecked) 현상이 생김
DRAM
- Dynamic random access memory
- Capacitor charge state indicates stored value
- Capacitor leaks through the RC path
![](https://media.vlpt.us/images/lsj8706/post/d213395d-4bb2-408a-a2da-8f0da29b76ea/Untitled%204.png)
SRAM
- Static random access memory
- Two cross coupled inverters store a single bit
![](https://media.vlpt.us/images/lsj8706/post/876c5dd8-92cb-4c83-b526-1ef4f5260825/Untitled%205.png)
Memory Bank Organization and Operation
![](https://media.vlpt.us/images/lsj8706/post/3ecd669e-0d9e-4c3c-8c6c-1137958203a0/Untitled%206.png)
DRAM vs. SRAM
- DRAM
- Slower access (capacitor)
- Higher density (1T 1C cell)
- Lower cost
- Requires refresh (power, performance, circuitry)
- Manufacturing requires putting capacitor and logic together
- SRAM
- Faster access (no capacitor)
- Lower density (6T cell)
- Higher cost
- No need for refresh
- Manufacturing compatible with logic process (no capacitor)
How Can We Store Data?
- Flip-Flops (or Latches)
- Static RAM
- Dynamic RAM
- Other storage technology (flash memory, hard disk, tape)
Why Memory Hierarchy?
- We want both fast and large
- But we cannot achieve both with a single level of memory
- Idea : Have multiple levels of storage
Memory Hierarchy
![](https://media.vlpt.us/images/lsj8706/post/284fe496-25f3-4651-8b09-27bfe1df72b8/Untitled%207.png)
Locality
- One’s recent past is a very good predictor of his/her near future.
- Temporal Locality (시간적 지역성) : If you just did something, it is very likely that you will do the same thing again soon
- Spatial Locality (공간적 지역성) : If you did something, it is very likely you will do something similar/related (in space)
Memory Locality
- Temporal : A program tends to reference the same memory location many times and all within a small window of time
- Spatial: A program tends to reference a cluster of memory locations at a time
Caching Basics : Exploit Temporal Locality
- Idea : Store recently accessed data in automatically managed fast memory (called cache)
- 데이터가 곧 다시 accessed 될 것이라고 예측
Caching Basics : Exploit Spatial Locality
- Idea: Store addresses adjacent to the recently accessed one in automatically managed fast memory
- Logically divide memory into equal size blocks
- Fetch to cache the accessed block in its entirety
- 가까운 데이터에 곧 access 할 것이라고 예측
Caching in a Pipelined Design
- The cache needs to be tightly integrated into the pipeline
- High frequency pipeline → Cannot make the cache large
- Idea : Cache hierarchy
![](https://media.vlpt.us/images/lsj8706/post/fb72b018-421b-4fbe-8acc-0d3ee49ec5e1/Untitled%208.png)
A Modern Memory Hierarchy
![](https://media.vlpt.us/images/lsj8706/post/a9c0bf87-8235-4c0f-a3b4-12c29e512263/Untitled%209.png)
Memory Hierarchy
![](https://media.vlpt.us/images/lsj8706/post/829bba92-140e-4afd-953b-a14c32acc403/Untitled%2010.png)
- Processors have cycle times of ~1 ns
- Fast DRAM has a cycle time of ~100 ns
- We have to bridge this gap for pipelining to be effective!
Basic terminologies
![](https://media.vlpt.us/images/lsj8706/post/5bad35cf-ade5-4037-b0f7-1ad8d6910233/Untitled%2011.png)
Multilevel Memory Hierarchy
- Modern processors use multiple levels of caches
- As we move away from processor, caches get larger and slower
- 𝐸𝑀𝐴𝑇𝑖 = 𝑇𝑖 + 𝑚 ∗ 𝐸𝑀𝐴𝑇𝑖+1
where 𝑇𝑖 is access time for level 𝑖 and 𝑚𝑖 is miss rate for level
![](https://media.vlpt.us/images/lsj8706/post/bc640cfb-5a57-4e19-9944-aaea73408fe3/Untitled%2012.png)
Cache organization (캐시 구성)
- Placement: Where do we place in the cache the data read from the memory?
- Algorithm for lookup: How do we find something that we have placed in the cache?
- Validity: How do we know if the data in the cache is valid?
Direct-mapped cache organization
![](https://media.vlpt.us/images/lsj8706/post/183cd77e-db17-4201-87fb-2db2af539e95/Untitled%2013.png)
10진수
![](https://media.vlpt.us/images/lsj8706/post/09d742df-ad9b-4578-844a-2b473d3403f7/Untitled%2014.png)
2진수
- Cache_Index = Memory_Address mod Cache_Size (mod는 나머지 연산)
![](https://media.vlpt.us/images/lsj8706/post/8e495563-8e8b-49c2-a411-d979f76b2b63/Untitled%2015.png)
- Cache_Tag = Memory_Address/Cache_Size
Sequence of Operation
![](https://media.vlpt.us/images/lsj8706/post/2296851d-f63d-4e50-bbd9-6d5983c9434c/Untitled%2016.png)
Thought Question (위의 그림에서)
Assume computer is turned on and every location in cache is zero. What can go wrong?
⇒ ADD a Bit!
- Each cache entry contains a bit indicating if the line is valid or not. Initialized to invalid
![](https://media.vlpt.us/images/lsj8706/post/addbf4be-6979-4268-8380-4b9e26e2fc65/Untitled%2017.png)
Hardware for direct mapped cache
![](https://media.vlpt.us/images/lsj8706/post/49c66c78-bc28-4273-bfd9-eb18a29ed832/Untitled%2018.png)