Module 6 Memory
Module 6 Memory
Computer memory is one of the most important parts of the computer. It stores and allows users to access the data
anytime, anywhere they want. There are two types of computer memories:
Volatile memory and
Non-volatile memory.
Volatile memory is termed as RAM which stands for Random access memory. While non-volatile stands for ROM
which is an acronym for Read-only memory. Computer memory is based on the two factors that include access time
and capacity. The faster the speed of the memor is the lesser will be the access time. A computer uses the memory
which is organized in such a way that it enables largest capacity of the memory and the faster speed. (toppr, n.d.)
At the core of the computer is the central processing unit or CPU, the source of control that runs all programs and
instructions. In order to function, computers use memory:
Fig. 1 Memory’s place (How Do Computers Store Data? - Memory & Function, 2020)
Cache Memory
Cache memory is a very high-speed semiconductor memory which can speed up the CPU. It acts as a buffer
between the CPU and the main memory. It is used to hold those parts of data and program which are most frequently
used by the CPU. The parts of data and programs are transferred from the disk to cache memory by the operating
system, from where the CPU can access them.
Advantages
• Cache memory is faster than the main memory.
• It consumes less access time as compared to the main memory.
• It stores the program that can be executed within a short period of time.
• It stores data for temporary use.
Disadvantages
• Cache memory has limited capacity.
• It is very expensive.
Primary memory holds only those data and instructions on which the computer is currently working. It has a limited
capacity and data is lost when power is switched off. It is generally made up of semiconductor device. These
memories are not as fast as registers. The data and instruction required to be processed resides in the main memory.
The usual convention when drawing block diagrams of memory is to have the lowest memory location at the bottom
and the highest memory address at the top, although not all manufacturers follow this convention.
The maximum size of the memory that can be used in any computer is determined by the addressing scheme. For
example, a computer that generates 16-bit addresses is capable of addressing up to 216= 64K memory locations.
Machines whose instructions generate 32-bit addresses can utilize a memory that contains up to 232= 4G (giga)
locations. The number of locations represents the size of the address space of the computer. (Hamacher, Vranesic, &
Zaky, 2002)
The CPU can directly access data stored in Main Memory. When a memory location is accessed (READ), the
contents of the memory location are unchanged (an exact copy of the contents of that location is made for processing
by the CPU). When new information is placed in a memory location (WRITE), the existing data is overwritten with
the new data. Data is stored in binary (1’s and 0’s).
A byte is 8-bits and bytes are grouped into words. A computer with a 32-bit word has 4 bytes per word, whereas a
computer with a 64-bit word has 8 bytes per word. Most instructions operate in entire words, for example, adding
two 32-bit integers. Thus a 32-bit machine will have 32-bit registers and instructions for manipulating 64-bit words,
whereas a 64-bit machine will have 64-bit registers and instructions for manipulating 64-bit words. (Computer
Systems, 2005)
The main memory unit that connects directly to the CPU is the primary memory. Further, there are two types of
primary memory i.e RAM and ROM
RAM is also known as the volatile memory. It is in the form of the chip that is implemented with the use os
semiconductors. Generally, RAM is used to store temporary storage of output data, input data, and intermediate
results. RAM can be divided into two categories:
2. Read-only memory
ROM is not as accessible as RAM and is, therefore, non-volatile memory. Once a ROM chip is programmed it
cannot be rewritten or programmed. The only changes you can make in ROM is at the time of manufacturing. ROM
has three categories which are:
PROM
The PROM stands for Programmable Read only Memory. It is also nonvolatile and may be written into only once.
For PROM, the writing process is performed electrically in the field. PROMs provide flexibility and convenience.
EPROM
Erasable Programmable Read-only Memory or EPROM chips have quartz windows and by applying ultraviolet light
erase the data can be erased from the EPROM. Data can be restored in an EPROM after erasure. EPROMs are more
expensive than PROMs and are generally used for prototyping or small-quantity, special purpose work.
EEPROM
EEPROM stands for Electrically Erasable Programmable Read-only Memory. This is a read mostly memory that
can be written into at any time without erasing prior contents; only the byte or bytes addressed are updated. The
write operation takes considerably longer than the read operation. It is more expensive than EPROM.
Flash Memory
An entire flash memory can be erased in one or a few seconds, which is much faster than EPROM. In addition, it is
possible to erase just blocks of memory rather than an entire chip.
This type of memory is also known as external memory or non-volatile. It is slower than the main memory. These
are used for storing data/information permanently. CPU directly does not access these memories, instead they are
accessed via input-output routines. The contents of secondary memories are first transferred to the main memory,
and then the CPU can access it. For example, disk, CD-ROM, DVD, etc.
Secondary memory is a permanent storage device. It is non-volatile in nature and is used to store programs and data
when they are not being processed. Because of this, the data remains in the same stage as long as they are not
deleted or rewritten from the user’s end. A secondary memory includes devices such as:
1. Optical disks like DVD, CD, and Blue-ray disks
2. Magnetic disks like memory stick, floppy disk, and hard disk drive.
3. Solid state disks like the thumb drive, pen, and flash.
Along with this one may also ask units and measurements as to how memory in computers is measured. We all use a
hard disk and a pen drive to transfer the data from one place to another. But what are its units? Computer measures
data in many forms such as Megabyte, Kilobyte, Byte, Bit, Nibble, Terabyte, Gigabyte, Exabyte, Petabyte, and
many more. Here are the conversions of these data into one form or another:
8 Bits 1 Byte
Bytes (1024) KiloByte (1KB)
KB (1024) MegaByte (1MB)
MB (1024) GigaByte (1GB)
GB (1024) TeraByte (1TB)
TB (1024) PetaByte (1PB)
PB (1024) ExaByte (1EB)
EB (1024) ZettaByte (1ZB)
ZB (1024) YottaByte (1YB)
1 YB BrontoByte
1024 BrontoByte 1 GeopByte
In computer memory, bits is the smallest memory. While Geopbyte is the highest memory. 1 bit is the binary unit.
(toppr, n.d.)
Registers
Memory Caching
One way to reduce the memory access time is to use a cache memory. An important design issue is to provide a
computer system with as large and fast a memory as possible, within a given cost target. Several techniques to
increase the effective size and speed of the memory. (Hamacher, Vranesic, & Zaky, 2002)
Cache memory -increases the effective speed
Virtual memory -increases the effective size
Cache
Cache by definition is a place for safe storage and provides the fastest possible storage after the registers. The cache
contains a copy of portions of the main memory. When the CPU attempts to read a word from memory, a check is
made to determine if the word is in the cache. If so, the word is delivered to the CPU. If not, a block of the main
memory, consisting of some fixed number of words, is read into the cache and then the word is delivered to the
CPU.
This is a small, fast memory that is inserted between the larger, slower main memory and the processor.
It holds the currently active segments of a program and
their data.
Reduces memory access time
In the figure, the block diagram of a system using cache is shown. It consists of two components.
Fast Memory
Control Logic Unit
Control logic is further divided into two parts.
Determine and Comparison Unit: For determining and comparisons of the different parts of the address and to
evaluate hit or miss.
Tag RAM: Second part consists of tag memory which stores the part of the memory address (called tag) of the
information (block) placed in the data cache. It also contains additional bits used by the cache management logic.
Locality of Reference
The working of the cache is based on the principle of locality which has two aspects.
Spatial Locality: refers to the fact when a given address has been referenced, the next address is highly probable to
be accessed within a short period of time.
Temporal Locality refers to the fact that once a particular data item is accessed, it is likely that it will be referenced
again within a short period of time.
To exploit these two concepts, the data is transferred in blocks between cache and the main memory. For a request
for data, if the data is available in the cache it results in a cache hit. And if the requested data is not present in the
cache, it is called a cache miss. (Jordan)
Advantages
• Any MB can be placed into any CB.
• Regardless of how irregular the data and program references are, if a CB is available for the MB, it can be
stored in the cache.
Disadvantages
• Considerable hardware overhead needed for cache bookkeeping.
• There must be a mechanism for searching the tag memory in parallel.
Advantages
• In our example the tag memory increases only slightly
from the direct mapping and only two tags need to be searched for each memory reference. The set-
associative cache is widely used in today’s microprocessors. (Mewada)
Virtual Memory
Virtual memory acts as a cache between main memory and secondary memory. Data is fetched in advance from the
secondary memory (hard disk) into the main memory so that data is already available in the main memory when
needed. The benefit is that the large access delays in reading data from hard disk are avoided.
Pages are formulated in the secondary memory and brought into the main memory. This process is managed both in
hardware (Memory Management Unit) and the software (The operating systems is responsible for managing the
memory resources).
The data interchange takes place between cache, main memory and the disk. The Memory Management unit (MMU)
is located between the CPU and the physical memory. Each memory reference issued by the CPU is translated from
the logical address space to the physical address space, guided by operating system controlled mapping tables. As
address translation is done for each memory reference, it must be performed by the hardware to speed up the
process. The operating system is invoked to update the associated mapping tables.
In segmentation, memory is divided into segments of variable sizes depending upon the requirements. Main memory
segments identified by segments numbers, start at virtual address 0, regardless of where they are located in physical
memory.
Paging:
In this scheme, we have pages of fixed size. In demand paging, pages are available in secondary memory and are
brought into the main memory when needed.
Fragmentation:
Paging scheme results in unavoidable internal fragmentations i.e. some pages (mostly last pages of each process)
may not be fully used. This results in wastage of memory. (Jordan)
Memory Interleaving
Interleaving is an advanced technique to improve memory performance. Memory interleaving increases bandwidth
by allowing simultaneous access to more than one chunk of memory. This improves performance because the
processor can transfer more information to/from memory in the same amount of time, and helps alleviate the
processor-memory bottleneck that is a major limiting factor in overall performance. Interleaving works by dividing
the system memory into multiple blocks.
Each block of memory is accessed using different sets of control lines, which are merged together on the memory
bus. When a read or write is begun to one block, a read or write to other blocks can be overlapped with the first one.
The more blocks, the more that overlapping can be done.
In order to get the best performance from this type of memory system, consecutive memory addresses are spread
over the different blocks of memory. In other words, if you have 4 blocks of interleaved memory, the system doesn't
fill the first block, and then the second and so on. It uses all 4 blocks, spreading the memory around so that the
interleaving can be exploited.