In the previous tutorial, it was mentioned that primary memory can be of two types – Random Access Memory and Read Only Memory. These memories are essential part of any processor or controller based system. In this tutorial, these memories will be discussed in detail.
Fig. 1: Primary Memories – RAM and ROM
Random Access Memory (RAM) –
Random Access Memory is used to store the binary information during the runtime of a program. The data and instructions are loaded in RAM from a secondary storage when a program is executed by the processor. The data and instructions and the results returned by the processor remains in RAM temporarily till the program is executed. Once the program is terminated, the data and instructions in the RAM are also cleared (or they may remain in RAM as garbage value until new data and instructions are written to RAM on execution of another program).
RAM is read/write memory. The process of storing data in the memory is called write operation. The process of transferring the data stored in memory to processor or secondary storage is called read operation. RAM is a random access memory, so data can be read or written directly from any location in the memory. It takes the same time to read or write data to any location in RAM. This is different from sequential access memories in which time required to read or write data depends upon the location in the memory. Since in a RAM, access time to read or write binary information from or to any location respectively remains same and is always extremely less compared any secondary storage, it is usually expensive.
RAM is a volatile memory i.e. data stored in it is lost when the power is witched off or whenever there is a power failure. Hence, Most of the desktop computing systems use a backup uninterruptible power system (UPS) to buy time to complete processing and shut down running programs properly. RAM is a semiconductor memory, so it is usually compact in size. Being expensive and semiconductor type, the commercially available RAM memories generally have limited capacity.
The data is stored in RAM in groups of bits called words. In any read or write operation, complete words are read or written from or to the memory respectively. The length of words is usually a multiple of 8 bits i.e. 8-bit, 16-bit, 32-bit, 64-bit and so on. The length of the words depend upon the type of computing system whether it is 8-bit, 16-bit, 32-bit, 64-bit and so on. The group of 8 bits is called byte. So, words can be 1-byte, 2-byte, 3-byte, 4-byte and so on in length. The data stored in the memory is read through parallel data output lines and is written to the memory through parallel data input lines. The number of data input and data output lines must be equal to the length of the words stored in the memory as complete word is read or written at any time.
Each word in the memory is identified by a unique address. There must be n number of address lines to read 2n words of a memory. Apart from data input, data output and address lines, there are two control inputs to specify the direction of transfer of data for the memory. These control inputs are read and write. The read causes data to be transferred from memory to the processor and write causes data to be transferred to the memory from processor or secondary storage.
The addresses of the words in memory are used access the memory location identified by the address. The addresses range from 0 to 2n – 1 where there are n number of address lines.
The capacity of any RAM memory is either expressed in bytes like Kilobytes, Megabytes and Gigabytes by the number of words and word length. For example, RAM memory storing 16-bit words with a capacity to store 1K words can be said to have a capacity of 1K X 16 words or 16 KB in capacity.
Read and Write Operation –
There are two operations that can be performed in any RAM memory – Read and Write. The write operation is performed by implementing the following steps –
1) Apply binary address of the word that has to be written in the memory on the address lines.
2) Apply data bits to written in the selected memory address on the data input lines.
3) Activate the write control input, so the data bits are written to the specified memory address.
The read operation is performed by implementing the following steps –
1) Apply binary address of the word that has to be read from the memory on the address lines.
2) Activate the read control input, so the data bits from the specified memory address are read through the data output lines.
In some RAM memories there is an additional control input called memory enable. This input must be active for applying any read or write operation. The read and write operation in memory are controlled by the processor (or central processing unit in desktop and server systems). The time taken to read data from the RAM memory is called access time. The time taken to write data to RAM is called cycle time. The CPU is synchronized by its own clock, the memory does not have any internal clock to activate read or write operation. So, the access time and cycle time must be always less than a time equal to a fixed number of CPU cycles. For example, if cycle time for RAM is 50 ns, so access time will be less than 50 ns and CPU cycle has a period of 20 ns, read and write operation can be performed in three CPU cycles.
When data has to be written to the RAM, memory enable and read/write signals must be activated after signals on address line and data input lines are stable, otherwise, the data will be lost. The control signals – memory enable and read/write must remain active for the time equal to the cycle time of the memory. The signals at address and data input lines must remain stable for a short period even after the control inputs are deactivated.
The access time is usually far less than the cycle time of RAM memory. While read operation, some period of time must be spared to handle another request of the read operation. The read and write operations on RAM are generally demonstrated by timing diagrams. The timing diagrams show the status of memory enable, read/write control signal, address line and data input or data output line in contrast to the CPU cycles.
Types of RAM –
RAM memories are categorized by their mode of operation. On the basis of mode of operation, RAM is classified as of two types –
1) Static RAM – Static RAM consist of internal latches that store the binary information. As latches can retain data till they have the power supply, the data stored in SRAM remains intact till the power is supplied to it. In case of a power failure or shut down the data stored in SRAM is lost. SRAM has short access and cycle times. It is easy to interface and use, since data remain on it till the power supply is not interrupted. SRAM chips use a matrix of 6 transistors without use of any capacitors. Transistors do not require power to prevent leakage, so SRAM need not have to be refreshed on a regular basis.
Because of the extra space in the matrix, SRAM uses more number of chips for the same storage. That is why SRAM is quite expensive. Some static RAM are also used as Cache Memories. Such SRAM have very limited capacity and have extremely small access and cycle times.
2) Dynamic RAM – Dynamic RAM stores binary information as charge stored in capacitors inside a chip of MOS transistors. As capacitors get discharged over a period of time, data on dynamic RAM needs to be refreshed periodically. The refreshing of data is done by cycling through the words periodically over few milliseconds restoring the charge in the capacitors. So, Dynamic RAM is refreshed hundreds of times every second. DRAM consists of memory cells where each memory cell is built from a transistor and a capacitor. Due to this construction Dynamic RAM is small in size and less expensive compared to static RAM.
Memory Decoding –
While read or write operation, memory addresses are selected by applying address number to the address lines. The signals on address lines are decoded by a decoder circuit to select a memory location. The memory enable input is usually connected to the decoder circuit to either enable or disable read/write operations.
Error Detection and Correction –
There are possibilities of error in storage and reading of data from the memory. Therefore, employment of error detection and correction techniques is a common practice while read and write operations. The most common error detection technique is parity bit. The parity bit is generated and stored along with the word in the memory. When the data is written to the memory, it is accepted when the parity of bits is correct while when data is read, parity is again checked to confirm the accuracy of the word. If the parity does not match, it implies that there has occur an error in read/write operation. In case, there is an error, check bits generate a pattern that is called syndrome. The pattern is used to identify the bit in the word that has error. The particular bit is inversed to correct the error. The error detection codes generate multiple parity check bits that are stored along with the words.
Read Only Memory (ROM) –
Read Only Memory (ROM) is a primary memory from which only data can be read but cannot be written by a user. This is non-volatile memory in which data once transferred remains on the memory even without any power supply to the memory unit. The binary information is permanently stored in such memories during their manufacture itself.
The ROM generally stores such instructions as are required by the computing system when is powered on. This operation is referred to as bootstrap. These memories are commonly used in desktop and server computers. Many embedded devices like washing machines, televisions and microwave ovens also use these memories to boot embedded programs.
The process of transferring binary data on ROM is called burning or programming. In burning, fixed interconnections between logic gates are formed on the ROM chip which represent the binary information. The data on ROM is read using a decoder circuit.
Types of ROM –
There are the following types of ROM memories −
1) Masked ROM (MROM) – The very first ROMs were hard-wired devices that contained a pre-programmed set of data or instructions. These kinds of ROMs are known as masked ROMs. These ROM memories are not much expensive.
2) Programmable Read Only Memory (PROM) – The PROM is a read-only memory that can be modified only once by a user. The user buys a blank PROM and enters the desired contents using a PROM programmer. Inside the PROM chip there are small fuses which are burnt open during programming. It can be programmed only once and is not erasable. Most of the one-time programmable microcontrollers have PROM to store the application logic.
3) Erasable and Programmable Read Only Memory (EPROM) – An EPROM can be erased by exposing it to ultra-violet light for some duration that can be up to 40 minutes. Usually, an EPROM eraser is used to erase data from EPROM. For programming EPROM, an electrical charge is trapped in an insulated gate region. The charge can retain for more than ten years because the charge has no leakage path. For erasing this charge, ultra-violet light is passed through a quartz crystal window (lid). This exposure to ultra-violet light dissipates the stored charge to erase the stored binary data. The quartz lid remains sealed with a sticker while normal use of the chip.
4) Electrically Erasable and Programmable Read Only Memory (EEPROM)- The EEPROM is programmed and erased electrically. It can be erased and reprogrammed as many as ten thousand times. Both erasing and programming take about 4 to 10 ms (millisecond). In EEPROM, any location can be selectively erased and programmed. EEPROM can be erased one byte at a time, rather than need to erase the entire chip. Hence, the process of re-programming is flexible though it is quite slow.
Filed Under: Articles