How a Library Explains Computer Memory
Understanding Memory Hierarchy through a library analogy

I turn computer science into stories, and narration, my goal and intention isn't to teach the how. It is to help people see why the Algorithms, Data Structures, and Flows exist through visualisation by connecting the systems.
In the last blog, we have discussed about how Arithmetic Logic Unit works, like executing a task by selecting the appropriate logic gates then forming an equation and get simplified by K-Maps and finally executed by half adders, adders etc.
Now, let’s discuss about how data is fetched from the Memory Unit(MU)!
Imagine you’re in a library, working on an assignment. when you need a book, what do you do?
you will ask the librarian right!
Where Can I find the book on Computer Architecture?
The Librarian checks their system and says,
Floor 1, Block 2, Rack 4
The same way, Librarian here ———→ Translation Lookaside Buffer(TLB).
when CU requests the data, it sends a Logical Address to Translation Lookaside Buffer(TLB), then TLB translates into the Physical Address(the actual location of the data).
It doesn’t fetch for you, it just gives you physical address of the data.
Organizing Your Desk = Memory Hierarchy
When you’re doing task at your desk, how do you organize your things?
The materials for your current task are on the desk surface.
The materials you’ll need later are inside the desk drawers or shelves.
The items you use frequently(pens, clips, stapler) are in the pen stand.
The same way, Memory Unit is also organized,
The Current Instructions which are to be executed now are placed in Registers.
The Instructions which are to be executed next will be in Random Access Memory(RAM).
The Frequently used data(pens, clips) are placed in cache.
The bulk storage(books) in SSD or HDD(Library racks).
How Each Level Fetches Data
Like how you walk to get the books, for each location in this Memory Hierarchy(Cache, RAM, SSD/HDD) there are different processes or methods to get that books.
Direct Mapping, Fully Associative Mapping, and Set Associative Mapping are used in Cache to get the data.
Addressing modes determine how the CPU calculates operand addresses before accessing memory
Disk Scheduling Algorithms are used in SSD or HDD.
There are no methods to access the data from Register, why??? because the current instructions(which are to be executed) are placed in registers itself
Access Time
In your real desk setup, the closer something is to you the faster you can grab it right!, If you observe how data is placed, you would easily know which memory access is faster
The Current Instructions(Registers) —> your desk surface —> Fastest
Cache(Frequently used) — > Pen stand —> Faster
RAM —> next-up materials —> Fast
SSD/HDD —> Library Archives(racks) —> SSD is faster than HDD but still thousands of times slower than RAM
So, the next time you sit in library organizing your desk for doing task or assignment, the same way Memory Hierarchy is there, It organizes and fetches data through different levels of memory.



