You are on page 1of 7

What is computer 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)

Memory is primarily of three types −


• Cache Memory
• Primary Memory/Main Memory
• Secondary Memory

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 (Main Memory)

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.

Characteristics of Main Memory


 These are semiconductor memories.
 It is known as the main memory.
 Usually volatile memory.
 Data is lost in case power is switched off.
 It is the working memory of the computer.
 Faster than secondary memories.
 A computer cannot run without the primary
memory.

Main Memory may be visualised as a set of labeled slots


called memory locations or memory cells. Each memory
location holds one data word and is designated as a unique address. Addresses are binary words which are generally
interpreted as numbers starting at number 0 and go up one for each successive memory location. Memory locations
can be used to store both data, such as characters and numbers, and program instructions.

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)

Example: to store the value 6 in a 32 bit integer, the binary value is


00000000 00000000 00000000 000001102

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

1. Random Access Memory

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:

 Static RAM or SRAM


 Static RAM (SRAM) based on flip flops
 Contents of each location persist as long as power is applied.
 Fast but relatively large
 Consume a lot of power
 Used for memory applications that are small but fast
 Dynamic Ram or DRAM
 Dynamic RAM (DRAM) employ capacitors
 Capacitor stores electric charge whose level represents a 1 or 0
 Capacitors dissipate with time and hence the charge must be restored frequently
 DRAMs
 smaller, slower than SRAMs
 support low cost, low power and high density and hence used in main memory

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:

 Programmable ROM or PROM


 Electrically Erasable Programmable ROM or EEPROM
 Erasable Programmable ROM or EPROM
 Flash Memory

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.

Auxiliary memory or secondary memory

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.

Characteristics of Secondary Memory

• These are magnetic and optical memories.


• It is known as the backup memory.
• It is a non-volatile memory.
• Data is permanently stored even if power is switched off.
• It is used for storage of data in a computer.
• Computer may run without the secondary memory.
• Slower than primary memories.

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.)

In terms of performance and cost, the memory hierarchy is presented in Fig. 3.

Registers

 top in the hierarchy


 matched in speed to the CPU
 but are large and consume significant power
 number of registers in a processor is small

Secondary and off-line storage devices

 at the bottom of the hierarchy


 cost per stored bit small in terms of money and power
 but access time is very long compared to registers

Fig. 3 Memory Hierarchy (Thakur, 2017)

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

Block Diagram of a Cache System

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)

Cache Memory Mapping

Associative Map Cache


• Any main memory blocks (MB) can be mapped into each cache block (CB).
• To keep track of which on of the 212 possible MBs is in each CB, a 12-bit tag field is added to each slot.
• Valid bit is needed to indicate whether or not the
CB holds a line that belongs to the program being
executed.
• Dirty bit keeps track of whether or not a line has
been modified while it is in the cache.
• The mapping from MBs to CBs is performed by
partitioning an address into fields.
• For each CB, if the valid bit is 1, then the tag field
of the referenced address is compared with the tag
field of the CB.

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.

Direct Map Cache


• Each CB corresponds to an explicit set of MBs.
• In our example we have 212 MBs and 24 CBs.
• A total of 212 / 24 = 28 MBs can be mapped onto each
CB.

• The 16-bit main memory address is partitioned into


an 8- bit tag field, followed by a 4-bit CB field,
followed by a 4-bit offset field.

Tag (8) CB field (4) Offset (4)


• When a reference is made to the main memory address, the CB field identifies in which of the 2 4 CBs the
block will be found.
• If the valid bit is 1, then the tag field of the referenced address is compared with the tag field of the slot.
Advantages
• The tag memory is much smaller than in associative mapped cache.
• No need for an associative search, since the CB field is used to direct the comparison to a single field.
Disadvantages
• Higher miss rate.

Set-Associative Mapped Cache


• Combines the simplicity of direct mapping with the
flexibility of associative mapping
• For this example, two CBs make up a set. Since there
are 24 CBs in the cache, there are 24/2 =23 sets.
• When an address is mapped to a set, the direct mapping
scheme is used, and then associative mapping is used
within a set.

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)

Cache Read and Write Policies:

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.

Advantages of Virtual Memory


 Simplified addressing scheme: the programmer does not need to bother about the exact locations of
variables/instructions in the physical memory. It is taken care of by the operating system.
 For a programmer, a large virtual memory will be available, even for a limited physical memory.
 Simplified access control.

Virtual memory can be organized in different ways.


Segmentation:

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.

2 methods in memory interleaving:


a. two-way interleaving – 2 memory blocks are accessed at the same time for reading and writing
b. four-way interleaving – 4 memory blocks are accessed at the same time

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.

You might also like