The term random access simply means that we can access any location in memory equally quickly. We supply the memory address of the data we want to access, and the data is read or written almost immediately.
Random Access Memory (RAM) is read-write memory. We can write a value into a memory location, and then read it out again later.
RAM is also volatile, which means if you switch the computer off, the data is lost.
How is RAM used?
The main memory of your computer is RAM. So if you say a PC having 8 Gigabytes of memory, you are talking about the amount of RAM. The main RAM is directly accessed by the processor bus (see the Von Neumann architecture), so it is very fast.
Most processors also contain cache memory, which is a type of very fast RAM that is located very close to the CPU (usually on the CPU chip itself). This RAM is faster than the main RAM, but it is also more expensive to produce, so a computer will normally have a small amount of cache memory and a much larger amount of main memory. Cache memory is used to store the data which is accessed most often. For example if the program is executing a loop, the data and instructions for the loop will be held in the cache memory.
The CPU registers are also a type of RAM which is actually built in to the CPU. This is the fastest RAM, and the CPU will only have a very limited number of registers. They are typically used to store values while the CPU is performing a calculation.
What does RAM look like?
RAM is manufactured as a computer chip, similar to a CPU. However, RAM runs at a slower speed than the CPU, and consumes much less power, so RAM chips don't usually have a heat-sink.
In a PC or laptop, the RAM chips are mounted on their own small circuit board like this:
Image by kitschweb
There are 8 chips on this board (the black rectangles). The RAM board plugs into a slot on the main computer motherboard. The idea of this is to make it possible to to upgrade the amount of RAM is the PC, by taking out the RAM boards and replacing them with new boards of higher capacity. This is quite a common way to boost the performance of a slightly older PC, and a lot cheaper than replacing the entire machine.
For smaller devices such as phones or tablets, or single board computers like a Raspberry Pi or Arduino, the RAM chip is usually soldered onto the main circuit board and cannot be upgraded.
How RAM works
RAM is connected to the buses of the CPU, which means that the CPU can access data in RAM very quickly, normally within a few clock cycles.
Here is a simple illustration showing 16 bytes of RAM (16 locations, each holding a single byte). Of course, a real computer has far, far more memory:
To read data from memory - the CPU will set the 4 bits of the address bus to the number of the location it wants to read, then it will set the control bus to say that it intends to read from memory. The RAM will put the byte value from the memory location on to the data bus for the CPU to read.
To write data to memory - the CPU will set the 4 bits of the address bus to the number of the location it wants to write to, and sets the 8 bits of the data bus to the byte value to be written. Then it will set the control bus to say that it intends to write to memory. The RAM will store the data byte value in the correct memory location.
The address bus is used to select a specific memory location. With an address bus of 4 bits, we can select addresses from 0000 to 1111 binary (0 to 15 denary), so there are only 16 possible memory locations.
If the address bus was 20 bits wide, it would allow for 1,048,576 different memory locations (1MB). If it were 30 bits wide there would be 1,073,741,824 different locations (1GB). The RAM chip doesn't just include millions of bytes of storage, it also includes all the logic to decode the address bits so that each individual location can be selected.