RISC-V存储设计
To Do Lists
虚拟内存
为什么需要虚拟内存
- 对于 RAM
来说,应用太大(放不下):根据局部性原理,我们只把程序部分内容放入到 RAM
中就可以满足程序运行,具体实现有分段、分页两种手段
- 分段:在 RAM 中为不同应用程序分配不同的连续内存空间,各个应用程序之间彼此互不干扰;缺点是会产生外部碎片
- 分页:物理内存空间和虚拟内存空间都被分成很多页(比如 4kb)
TLB
Without TLB, we have to access the main memory twice to get the target content: the first access to get the target address, the second access to get the target content.
TLB Addressing
- Virtual Addressing: the CPU use the virtual address to access the data cache. Only when cache miss, the CPU access the TLB to try to get to missing data.
- Physical Addressing: each time, the CPU access the TLB first to get the data address, then use the data address to access the cache.