Monday, May 21, 2012

CACHE



There are two main classifications of RAM: static RAM (SRAM) and dynamic RAM (DRAM). SRAM is faster, but that speed comes at a price: it has a lower density and it is more expensive. Since main memory needs to be quite large and inexpensive, it is implemented with DRAM.

A small, fast SRAM is placed between the processor and main memory to hold the most recently used code and data under the assumption that they will most likely be used again soon. This small, fast SRAM is called a RAM cache.

The reason the SRAM of the cache needs to be small is that larger address decoder circuits are slower than small address decoder circuits.

It is possible to take this concept a step further by placing an even smaller SRAM between the cache and the processor thereby creating two levels of cache. This new cache is typically contained inside of the processor.
When two caches are present, the one inside the processor is referred to as a level 1 or L1 cache while the one between the L1 cache and memory is referred to as a level 2 or L2 cache. The split cache is another cache system that requires two caches. In this case, a processor will use one cache to store code and a second cache to store data.

Cache Organization
The success of caches is due primarily to the principle of locality. This suggests that when one data item is loaded into a cache, the items close to it in memory should be loaded too. For example, if a program enters a loop, most of the instructions that make up that loop will be executed multiple times.

Because of this, caches are typically organized so that when one piece of data or code is loaded, the block of neighboring items is loaded too. Each block loaded into the cache is identified with a number called a tag that can be used to determine the original addresses of the data in main memory. This way, when the processor is looking for a piece of data or code, it only needs to look at the tags to see if the word is contained in the cache. The each block of words and its corresponding tag are combined in the cache to form a line.

Cache Operation
When the processor needs a word from memory, it first checks the cache. The circuits used to access the same word from main memory may be activated simultaneously so no time is lost in case the data is not available in the cache, a condition known as a miss. If the search of the cache is successful, then the processor will use the cache's word and disregard the results from main memory. This is referred to as a hit. In the case of a miss, the entire block containing the requested word is loaded into a line of the cache, and the word is sent to the processor.

Cache Characteristics
  • The cache system used by a processor is defined by six traits:
  • •      The size of the cache.
  • •      The size of a block, which when combined with the size of the cache defines the number of lines.
  • •      The number of caches (i.e., multiple levels or a split cache).
  • •      The mapping function (the link between a block's address in memory and its location in the cache).
o   Direct Mapping.
o   Associative Mapping.
o   Set-Associative Mapping.
  • •      The replacement algorithm (the method used to figure out which block to remove from the cache in order to free up a line).
o   Least Recently Used (LRU) – This method replaces the block that
hasn't been read by the processor in the longest period of time.
o   First In First Out (FIFO) – This method replaces the block that
has been in cache the longest.
o   Least Frequently Used (LFU) – This method replaces the block
which has had fewest hits since being loaded into the cache.
o   Random – This method randomly selects a block to be replaced. It
has only slightly lower performance than LRU, FIFO, or LFU.
  • •      The write policy (how the processor writes data to the cache so that main memory eventually gets updated)
o   Write Through Policy : One method for resolving this is to have the cache update memory every time the processor writes to the cache.
o   Write Back Policy : A second method is to update main memory only when a line of the cache that has been modified to is about to be replaced with a new block from memory.

Sunday, May 20, 2012

RAM


The term Random Access Memory (RAM) is typically applied to memory that is easily read from and written to by the microprocessor.
In actuality, this is a misuse of this term. For a memory to be random
access means that any address can be accessed at any time. This is to
differentiate it from storage devices such as tapes or hard drives where
the data is accessed sequentially.

In general, RAM is the main memory of a computer. Its purpose is
to store data and applications that are currently in use. The operating
system controls the use of this memory dictating when items are to be
loaded into RAM, where they are to be located in RAM, and when they
need to be removed from RAM. RAM is meant to be very fast both for
reading and writing data. RAM also tends to be volatile in that as soon
as power is removed, all of the data is lost.

Static RAM (SRAM)
SRAM is made from an array of latches such as the D-latch. Each latch can maintain a single bit of data within a single memory address or location.
Latches are not small devices as logic circuits go, but they are very
fast. Therefore, in the pursuit of the performance goals of speed and
size.
SRAMs are better adapted to speed. In general, SRAMs:
• store data in transistor circuits similar to D-latches;
• are used for very fast applications such as RAM caches;
• tend to be used in smaller memories which allows for very fast
access due to the simpler decoding logic; and
• are volatile meaning that the data remains stored only as long as
power is available.
       Dynamic RAM (DRAM)
A bit is stored in a DRAM using a device called a capacitor. Presence of charge is considered a logic '1'. The absence of a charge is considered a logic '0'. Since a capacitor can be made very small, DRAM technology is better adapted to high density memories, i.e., cramming a great deal of bits into a small space.
Capacitors do have a problem though. Every once in a while, one of the electrons will escape from the negatively charged plate and land on the positively charged plate. If this happens enough, the stored '1' will disappear. This movement of electrons from one plate to the other is referred to as leakage current.

The electrons stored on the plates of the capacitors are also lost
when the processor reads the data. Therefore, each read removes some of the electrons. In order to avoid having leakage current or processor reads corrupt the data stored on the DRAMs, an additional logic called refresh circuitry is used that periodically reads the data in the DRAM then restores the ones with a full charge of electrons. The refresh process involves disabling memory circuitry, then reading each word of data and writing it back.
In general, DRAMs:
• have a much higher capacity due to the smaller size of the capacitor
(The RAM sticks of your computer's main memory are DRAMs.);
• will "leak" charge due to the nature of capacitors eventually causing
the data to disappear unless it is refreshed periodically;
• are much cheaper than SRAM; and
• are volatile meaning that the data is fixed and remains stored only
as long as power is available.
 
Synchronous Memory Interfacing
When the memory follows a precise timing requirement governed by a clock that is added to the bus to keep everything attached in lock-step, the interface is
referred to as synchronous and the memory that uses this type of
interface is referred to as synchronous DRAM or SDRAM.
One improvement to SDRAM allows two words of data to be
written or read during a single clock cycle. This means that every time
the processor accesses the memory it transfers two words, one on the
rising edge of the clock and one on the falling edge. This type of
memory is referred to as Double Data Rate SDRAM or DDR SDRAM. DDR2 and DDR3 double and quadruple the DDR rate by allowing four and eight data words respectively to be transferred during a single clock pulse.

ROM


In every computer system, there must be a portion of memory that is
stable and impervious to power loss. This kind of memory is called
Read Only Memory or ROM.

Once again, this term is a misnomer. If it was not possible to write to this type of memory, we could not store the code or data that is to be contained in it. It simply means that without special mechanisms in place, a processor cannot write to this type of memory. If through an error of some sort, the processor tries to write to
this memory, an error will be generated.

The most common application of ROM is to store the computer's
BIOS. Since the BIOS is the code that tells the processor how to access
its resources upon powering up, it must be present even when the
computer is powered down.

Another application is the code for embedded systems. For example, it is important for the code in your car's computer to remain even if the battery is disconnected.

There are some types of ROM that the microprocessor can write to,
but usually the time needed to write to them or the programming
requirements needed to do so make it unwise to write to them regularly.
Therefore, these memories are still considered read only.

In some cases, the processor cannot write to a ROM under any
circumstances. For example, the code in your car's computer should
never need to be modified. This ROM is programmed before it is
installed. To put a new program in the car's computer, the old ROM is
removed and discarded and a new ROM is installed in its place.

Saturday, May 19, 2012

WelcuUuM



Being TechnicaL is GOOD..,
ComputeRs are BETTER...,
ProgramminG is thE BEST...... :)