The terms used in memory systems can be very complex to understand, with so many different kinds of memory; this gets even more confusing when one name can be used to refer to many things, and one thing can be called by many names. In this post, I shall attempt to explain the myriad of names and things in the memory hierarchy. The things that I write below are from my understanding in this area, if there are any inaccuracies in what I write, please do drop a comment, I will be happy to correct it.
ROM - Read-Only Memory
The read-only memory, as its name suggests, contains data which are read-only. But it is not that simple.
To understand the ROM, I should talk about Application Specific Integrated Circuit (ASIC). ASICs commonly refer to customized integrated circuits which are designed in hardware to do a specified task. However, in a broader view, ASICs have 3 main categories: full-custom, semi-custom, and programmable. Technically, ROM is a type of full-custom ASIC, which logic/program is implemented by mask, and cannot be altered after the IC is fabricated, hence the name “Read-Only”. Advances in the IC fabrication processes gave rise to semi-custom and programmable ASICs. In these kinds of IC, the logic/program stored in the IC can be altered using a programmer device. One example of such IC is the Erasable and Programmable Read-Only Memory (EPROM); its name is oxymoronic: since it’s both ‘erasable’ and ‘programmable’, but yet “read-only”.
This gets even more confusing when it comes to larger embedded systems and devices such as the mobile phone. The memory used in these systems is mostly flash memory, a more advanced memory storage compared to the EPROMs. Flash memory is technically classified as Read-Write Memory (RWM), which is capable of both read and write access.
The memory of interest when talking about ‘ROM’ actually refers to the non-volatile memory of a system where the program of the system resides in (non-volatile means the data does not disappear after power supply is cut off) .Technically, a more suitable term to use is “program memory”. The type of memory used as program memory may not be just read-only; they can be programmable, or read/write capable memories.
The term ‘ROM’ has been casually used to refer to the program memory, as well as the program stored in the memory. This is because, although the type of memory used as program memory may technically be programmable or read-write capable, the data stored in the program memory is mostly read-only; it generally doesn't alter itself during runtime.
It is now clear why it gets confusing as ‘ROM’ is used to interchangeably refer to multiple things. For example, when I say that I am “flashing the rom to my phone”; it means that I am rewriting the program memory of my phone with another program.
RAM - Random Access Memory
By definition, Random Access Memory (RAM) is any integrated circuit that allows stored data to be accessed in any order with a worst case performance of constant time. By this definition, it basically covers all the memory storage devices today, even the hard disk drives. Yes, the HDDs are considered as RAM as well. Although there are significant timing differences when accessing different locations on the HDD, it is still considered as a RAM as it is random access capable. This is because in older times, magnetic tapes were a popular form of memory storage, to access a certain data on a tape, it need to scroll to that particular location (sequential access), in comparison with the tape, HDD is a random access capable memory.
But the above is just the technical definition, the term ‘RAM’ now refers to the main memory of a system.
We’ve talked about the program memory of a system above: the program memory holds the program of the system. The program is basically a set of instructions which the system will perform; it defines what the system will do. But just having the instruction is not sufficient for the system to work: the system will need to handle and work on data. To do that, it needs memory. That is why this memory is known as the main memory, or simply memory.
The main memory and program memory are different in many ways, access timings and technical details aside; the main reason why it is different is due to the difference in functionality: the program memory and main memory have different purpose, and the system should, generally, not alter its own program during runtime.
The program memory stores the instructions for the systems, the tasks
performed by the systems is defined by these instructions. The main
memory holds the intermediate data of the system, when the system
performs some tasks, it will usually require an input and generate an
output according to the instructions. In most cases, the input/output
can be stored in the main memory and will be accessed when the system
needs to use them to perform task.
As one of the key feature of the main memory is its fast random access speed during operation, the term ‘RAM’ is commonly used to refer to the main memory, and lesser used for the original technical definition it stood for. This, however, creates confusion when the same memory is refer to as 'RAM', "main memory" and "memory".
Program, firmware, operating system
Let us being this section by looking at the definition of each item found in Wikipedia:
- Program - a sequence of instructions written to perform a specified task with a computer.
- Firmware - the combination of read-only memory and program code and data stored in it
- Operating System - a set of software that manages computer hardware resources and provides common services for computer programs.
With the above definitions, it is easily seen that a program is part of a firmware, and an operating system is technically a super larger program which is capable of managing hardware resources and running other programs within it.
The confusion arises when different names are used to refer to the same item again.
Let’s look at an example of android: android is an operating system for devices such as mobile phones, tablets, media players; no confusion with that right? The problem: these devices are traditionally devices using small program memory (ROM); the architecture for such devices is called ‘firmware’ by definition. Operating systems are originally terms for computers, where the OS is stored in larger HDD auxiliary memory. However, small operating systems such as Android, while being less powerful than computer OS such as Windows/Mac/Linux, also qualify for the name “operating system” by definition.
This is why the program on a mobile phone can be referred to as both ‘firmware’ and “operating system”. And as mentioned above, it is also casually referred to as ‘ROM’ since it resides in the program memory, which is casually referred to as ‘ROM’ as the memory used as program memory is traditionally read-only memory.
Endnote
I hope my explanation helped clearing up some of the fog. I am still very green in this area, and my knowledge may be superficial. As mentioned above, if there are any inaccuracies in what I wrote, please do drop and comment and point it out, I'd be more than happy to change.