In the diagram above the peak of the pyramid represents the processor. The Register lie with in the processor it self hence are the closest to the processor and work the fastest. But the number of registers that can be included in a processor are limited, as it would lead to increase in processor size, increase in manufacturing cost etc. Thus the register memory is restricted to minimal.
A level below the register is the L1 cache or the first level cache. In the processors of today, L1 cache also lies on the processor chip itself, though it might lie outside too.
The cache memory works at a very fast speed but is also extremely expensive as compared to the other memories available. This high cost is one of the major restriction why we can not use lots of cache in a computer even thought it is faster.
The general thumb rule is, higher the cache memory faster would be the working of the processor.
After the L1 or first level of cache, modern systems have an L2 or the second level of cache.This is introduced mainly because we can not include a high amount of L1 cache when we are making L1 a part of the chip as it would occupy precious space on the chip.
L2 cache is mostly off the chip. But it is of the same kind as the L1 cache and hence is extremely fast in its operation. Together L1 and L2 help in making the system run fast. Some of the modern computers also have a third level or L3 cache.
Cost factor again restricts the amount of second level cache can be included.
All the cache though does make the system work faster but is of very limited in size, which is not really enough for the computer to function.
The next level of memory is the RAM. RAM basically stores all the data that the computer needs while it is running. RAM is also fast in its operation but slower than the cache, and less expensive. Thus we can afford to have a relatively large amount of RAM. The higher the RAM, faster is the system, but again price is a main limiting factor with regards to how much RAM can be included in the computer.
All the memories until the level of RAM are volatile, i.e. they loose the data stored in them as soon as power is switched off. This obviously is not a very desirable property as you would loose all your work.
Thus to store data even when power is not there secondary memory is made use of. The secondary memory is the slowest but the size is a lot bigger than the RAM or the cache because price of the secondary memory is a lot lesser than compared to RAM and cache.
Let us take a real life example to understand the above hierarchy .
Consider the laptop SL400c by lenovo.
The configuration is :
Intel T5870 Processor.
L1 cache: 32KB
L2 Cache : 2048KB
Secondary Memory: 160GB
The above data depicts the memory hierarchy clearly, L1 cache being the least and the secondary memory being the largest.