What is a memory hierarchy and why is it important? Let’s answer the second part of that question by looking at the graph below:
Year after year, processor performance increases at a much higher rate than that of memory. This is the processor-memory performance gap and results in a computer that can process data much faster than it can retrieve data from memory.
In the gardening example from the previous exercise, you needed to get fertilizer from the store. The garden is equivalent to the processor and retrieving the fertilizer from the store is the same as retrieving data from the main memory.
The image above represents a simple memory hierarchy. At the top is the processor with the best performance. But it can only hold a small amount of data. At the bottom is memory with decreased performance but increased size for data. This memory is the DDR memory used widely in computers today and throughout this lesson, it will be called the main memory.
The middle section of the memory hierarchy is the cache and is equivalent to your storage shed in the gardening example. The shed is where the extra fertilizer is stored for later use. Cache memory is similar in that it stores data for faster access times to help bridge the processor-memory performance gap.
Throughout this lesson, you will work with a simulated memory hierarchy. A description of each file is in the Hint.
In app.py an instance of the
ISA() class is assigned to
cache_arch. This is the simulated architecture that will run instructions to access the memory hierarchy.
.read_instructions() method is called and passed ex2_instructions. This will run the code to retrieve data from memory.
Instead of using binary or hex data in the simulation, the data stored in memory will be alphanumeric characters, such as
Run the code. The output shows there is no memory found in the architecture.
Next, we’ll add main memory to the architecture.
cache_arch initialization, call the
.set_memory() method of
cache_arch with the argument
When you run app.py you should see the console output of each instruction that accesses the main memory. In the end, the simulation outputs a text string of all the data accessed from the main memory and the total execution time.