In the previous tutorials, it was learnt that sequential circuits require memory elements to retain previous states of a digital system. The flip-flops and registers were then introduced as building blocks of memory in a sequential circuit. The registers are enough to store runtime data in small microcontrollers and ASICs. The complex computing systems require digital memory to not only store runtime information (as stored by registers in a microcontroller) but to store programs and data permanently within the digital system. So, they require dedicated memory either internal or external.
A memory is defined as a device that can store binary information to be accessed when needed for processing. After processing, the end results may be stored back to the memory. The digital systems can be 8-bit, 16-bit, 32-bit, 64-bit and so on. The 8-bit, 16-bit, 32-bit, 64-bit systems store data as 8-bit, 16-bit, 32-bit, 64-bit words respectively. The size of memory is expressed in bytes, kilo bytes, mega bytes, giga bytes and so on. Any memory is divided into building blocks called cells. Each cell is identified by a unique address ranging from 0 to number of cells minus one. Depending upon the type of digital system, i.e. 8-bit, 16-bit, 32-bit or 64-bit, the cells in memory can be 8-bit, 16-bit, 32-bit, 64-bit long.
The memory in a digital system may be used either to store programs and data permanently or to store data and instructions of a program temporarily during runtime of a program or application. Most of the digital systems require memory facilities for temporary as well as permanent storage of data and programs to execute intended applications. In some digital systems, the memory may be just used to retain data while it is transferred from an input device to an output device.
The categorization of digital memory is usually done in context to desktop and server computing systems. Based on location and usage of memories (in desktop and server systems), there are three types of memories –
1) Cache Memory
2) Main Memory
3) Secondary Memory
Cache Memory –
Cache memory is a high speed semiconductor memory either integrated in processor chip or interconnected to the processor by a separate bus. The CPU or processor can access data from cache memory more quickly compared to the main memory. The cache is generally a group of semiconductor registers or static random access memory. In microcontrollers and small microprocessors, a group of few registers may serve similar to cache memory.
The cache is used to store data and instructions that are used repeatedly by the processor in execution of a program, or data and instructions that may be needed next by the processor. Since Cache memory is a high speed memory either integrated or closely interconnected to the processor i.e. it is closest to the processor, it helps in increasing the overall speed of program execution.
Cache memory is faster than main memory and can be accessed in less time compared to the main memory in any digital system. Since cache memory is very expensive and have limited size, it is only used for storage of temporary data and runtime instructions that have to be executed immediately within a short period of time.
Most of the desktop and server processors have multi-tier or multi-level cache memory. Depending upon the proximity and accessibility, these levels are categorized as follow –
1) L1 Cache – Level 1 or Primary Cache is fastest cache and closest to the processor always embedded within the processor chip.
2) L2 Cache – Level 2 or Secondary Cache is usually greater in size than L1 cache. It is either embedded on the processor chip or connected to the processor by a dedicated interconnecting bus. It is used when L1 cache is consumed by the runtime data.
3) L3 Cache – Level 3 is a cache memory faster than RAM (primary memory) but significantly slower than L2 Cache. It is designed to accompany L1 and L2 cache memories during the execution of large programs. In multi-core processors, each core usually have individual L1 and L2 cache and share a common L3 cache. Nowadays, most of the processor chips have L1, L2 and L3 cache integrated in processor chip itself.
4) Specialized caches – A digital computing system may have different specialized caches. Like there can be disk catches to store and quickly access frequently used data. There can be specialized catches for specific applications like browsers, network address binding, databases etc.
Fig. 1: External Cache Memory
Main Memory –
Main memory is external memory that is used to store data, programs or operating system, a computing system is currently executing. It is also of limited capacity but significantly large compared to cache memories. Like cache memories are generally few kilobytes or megabytes while main memory is usually in gigabytes. Main memory is again a semiconductor memory but is slower compared to registers. It is a volatile memory and data stored/loaded in it is lost when the power is off. Main memory, also called primary memory is classified as RAM (Random Access Memory) and ROM (Read Only Memory).
Fig. 2: Primary Memories – RAM and ROM
Secondary Memory –
The secondary memory is external memory that is used for permanent storage of data and programs. These are optical (CD, DVD or Blu-Ray Discs) or magnetic memories (Hard Disks) which are non-volatile memories and can retain data stored in them even when they are not powered. Any processor access these memories through input output routines. The data (operating system files, data and programs) stored in these memories is first read and loaded in primary memory (RAM) and then it is read by processor from the primary memory. The optical discs can store data up to few gigabytes while magnetic disks having capacity in terabytes are available.
Fig. 3: Secondary Memories Like Hard Drives
Semiconductor, Optical and Magnetic Memories –
On the basis of construction, memories can be classified as semiconductor, optical and magnetic memories. Semiconductor memories are built on silicon wafers using LSI, VLSI or ULSI technologies. These are similar to digital ICs having logic gates used in their construction except that these are constructed explicitly only to store data. Cache memory, Flash memories and primary memories (RAM and ROM ) are semiconductor memories.
Optical memories store data on optically readable medium. CD, DVD and Blu-Ray Discs are popular examples of optical memories. The data is written and read from optical memories with the help of Optical Disc Drives by focusing Laser light on a spinning optical disc. Compact Discs (CDs) can store data up to 700 MB. Single Layer DVDs can store 4.7 GB data while dual layer DVDs can store 8.5 GB data. HD DVDs can store 15 GB data on single layer and 30 GB on dual layer. Single layer blu-ray discs can hold 25 GB data while dual layer blu-ray discs can hold 50 GB data. The quad layer blu-rays can hold 128 GB data.
Magnetic memories store data on magnetized medium. The data is stored and read from magnetic memory using read/write head where data is permanently stored on disc as magnetic patterns. The most widely used magnetic memory are hard drives. Their capacity can be in gigabytes to terabytes. Other examples of magnetic memories are floppy disks, magnetic strips and magnetic recording tapes (audio tapes) that now not obsolete.
Volatile and Non-Volatile Memory –
Volatile memory is a type of memory that loses its stored data when power to the memory circuit is cut off. Cache memory and RAM are volatile memories. The non-volatile memory retains stored data permanently even after the power supply is turned OFF. The ROM, Flash memories and secondary memory devices weather optical or magnetic are all non-volatile memories.
Static and Dynamic (Volatile) Memories –
In volatile memories like RAM, the data is retained by the memory device until the power is available to the memory device. The volatile memory can be again static or dynamic type. In static volatile memory, the data remains stored in the memory until the power is available without any need to periodically refresh or rewrite data to it. Registers, Static RAM and punched cards are static volatile memories.
In dynamic volatile memory, data does not remain permanently stored, instead it needs to be periodically rewritten despite continuous power supply. Dynamic memory uses the capacitance of a transistor as the storage device. Only one transistor is needed to store one bit of information. The capacitor must be refreshed periodically without being discharged in order to prevent loss of information. Dynamic RAM and circulating registers using CCD (Charge Coupled Devices) are examples of dynamic volatile memories.
Sequential Access and Random Access Memories –
The memory devices can also be classified on the basis of the method of access. Based on the method of access, memory devices can be classified as sequential access and random access memories. In a sequential access memory, a particular memory location is accessed sequentially, i.e. any memory location is accessed only after sequencing through previous memory locations. Therefore, the access time of a sequential memory varies depending on the location to be accessed. The ROM and secondary storage devices like hard drives and optical discs are sequential access memories.
On the other hand, in random access memory, any memory location can be accessed in a random manner and therefore it always have equal access time for all memory locations. The Cache memories and RAM (Random Access Memory) are examples of random access memories.
Virtual Memory –
Virtual memory is a memory management technique that allows temporary transfer of runtime data from RAM to secondary storage (hard drive) to meet out shortage of primary memory (RAM) while execution of large programs. This way an extremely large virtual memory is available to the programmer despite smaller size of available physical memory. This technique is implemented by the operating system where operating system forms contiguous addresses between RAM and virtual memory allocated on hard drive to store active runtime data on RAM and inactive runtime data on hard drive. In the following situations, entire program is not required to be loaded fully in main memory (RAM) and so virtual memory can be used –
User written error handling routines are used only when an error occurred in the data or computation.
Certain options and features of a program may be used rarely.
Many tables are assigned a fixed amount of address space even though only a small amount of the table is actually used.
The ability to execute a program that is only partially in memory would counter many benefits.
Less number of I/O would be needed to load or swap each user program into memory.
A program would no longer be constrained by the amount of physical memory that is available.
Each user program could take less physical memory; more programs could be run the same time, with a corresponding increase in CPU utilization and throughput.
The computing systems (microcontrollers, daughter boards and mother boards) mainly rely on semiconductor memories (cache, RAM and ROM) for program executions. In the next tutorial, RAM and ROM will be discussed in detail.
Filed Under: Articles