Untitled Document

# Module 3: A micro-network of communicating hardware
Topic 2: Memory organization

Primary or main memory is the purely electronic and volatile memory that a computer uses to store current data and code whilst executing a program or application.

Memory is a computer system's primary workspace. It works in tandem with the CPU, or microprocessor, to store data, programs, and processed information that can be made immediately and directly accessible to the CPU or to other system devices. Memory is central to a computer's operation because it forms the critical link between software and the CPU. Computer memory also determines the size and number of programs that can be run simultaneously, and helps to optimize the capabilities of increasingly powerful microprocessors.

Oh yeah! And it's fast too.

- Today's SDRAM technology can access (read or write) a memory address every 10ns (10 x 10^-9 seconds) or less depending upon the speed of the bus (10ns for a 100MHz bus).
- By way of comparison, the fastest hard drive technology today, used by the Quantum "Fireball" takes about 9.5ms (9.5 x 10^-3 seconds) to access a piece of data.

That makes your RAM about 1,000,000 times faster than a hard drive!

RAM is rather expensive though.

At todays prices: (3rd July 1998)

- 64M bytes of SDRAM costs around $300.
  - That is about $4.68 per megabyte.
- 8.4G bytes of Quantum IDE hard drive space costs about $520.
  - That is about $0.06 per megabyte!

That makes your best SDRAM about 100 times more expensive per megabyte that the best hard drive.

A hard drive does have one rather important advantage over RAM however. Data stored on a hard drive is not lost once the power is removed. For this reason:

- RAM is often referred to as 'working' or 'temporary' memory and
- a hard drive as 'long-term' or 'permanent' memory.

## Memory hierarchy

If you have read about computers at all or follow the classified advertisements in the local papers and computing magazines, you will have noticed that there are several different types of memory to choose from.

The IBM web site gives a good summary of memory types. So too does the Kingston Technology web site.

There is a hierarchy of memory types and uses. In general terms, the closer the memory is to the CPU then the faster it is and the more expensive it is:

## Register memory

Registers are the fastest memory elements and usually reside on the CPU chip itself. They are used to store temporary and partial results of calculations and sometimes system state information.

Because registers reside with the CPU they are extremely fast for the CPU to access. They may be as small as one bit or as large as several words depending upon the processor.

Because registers reside on the CPU chip itself there is not room for too many of them. Most modern processors have between 32 and 64 registers onboard.

Because registers are a fast but limited memory resource, much research goes into improving and creating more efficient register management (allocation) algorithms.

As suggested in module 2, topic 2, registers are made up from a series of simple flip-flops.

The state of each flip-flop may be read from the Q outputs. A high voltage value represents a '1' and a low voltage represents a '0' data value.

The speed of register memory lies in the fact that there are minimum of control signals needed to transfer data. There is also no need to place register data onto the system bus to transfer it to the CPU.

In the above diagram there is:

- a 'CLR' signal line to clear each flip-flop to a zero state and
- a 'CLK' signal line to that sends a clock pulse to cause the flip-flop to process the current D input to create the next Q state at the output.
- data in (D0-D7) and
- data out (Q0-Q7)

## Cache memory

Cache memory stores copies of chunks of frequently accessed RAM which is slower memory running at system board speed.

When the processor needs data, it will check in high-speed cache first to see if the data is there (fastest option). If not, then the processor will retrieve the data from slower main memory (RAM, slowest option). Cache works much like a home refrigerator. A refrigerator can be considered a �cache� for groceries. Instead of going to the grocery store (main memory) every time you're hungry, you can go to the refrigerator (cache) first to see if the food you want is there. If it is, then you've saved a lot of time. If not, then you have to spend the extra time to get it from the store.

As memory usage changes so different chunks of RAM are copied to the cache. As cache copies are modified then the changes are written back to RAM as necessary.

Cache memory can be divided into two parts and two speeds.

Level 1 (L1) cache is the fastest as it resides on the CPU chip itself and hence runs at CPU speed.

Level 2 (L2) cache memory is the next fastest. It resides off-chip but close by for easy access. L2 cache is a small block of high-speed memory (usually SRAM) located between the CPU and main memory.

## Random Access Memory

Internally, computer memory is arranged as a matrix of �memory cells� laid out in rows and columns, like squares on a checkerboard. Each memory cell is used to store a bit of data, which can be instantaneously retrieved by indicating the row and column location (or address) of the data. Because these bits of data can be individually accessed, retrieved, and modified at random, the type of main memory used in computers is called random access memory (RAM). RAM is a volatile form of memory, which means that it must have power in order to retain data. When the power is turned off, data in RAM is lost. Contrast this to other storage media such as disks, tapes, and CDs that retain data even without power.

Your computer should have as much RAM as you can afford if it's going to work efficiently. All computers use RAM in the same way (because they're all based on the von Neumann architecture). Both programs and data are called up from permanent storage (usually a hard drive or floppy disk) and operate in RAM. In general, this means that the more RAM you have, the more able you are to handle large amounts of data and big programs--though in practice, a lot of data in RAM is passed off into slower virtual memory to free up working space.

RAM memory resides on a totally different chip to the CPU so transfer of data to the CPU requires more time and many more control signals. Data logistics include:

- selecting a particular memory chip,
- selecting a particular word on the chip
- selecting the operation (read/write)
- organizing the data on to and off of the bus

## What kinds of RAM are there?

There are many different kinds of memory, each with its own features and benefits. Unfortunately, with so many different types of memory, it can be easy to get them confused. Use this glossary to help sort out the confusion, or as a quick reference to refresh your own memory from time to time.

The two main forms of RAM are DRAM and SRAM.

DRAM

(Dynamic RAM)

DRAM is the most common type of computer memory.

A bank of memory modules using DRAM chips usually forms the core of a computer's main memory. The system uses this memory to temporarily store programs, data, and processed information that moves to and from the processor, video card, and other peripherals.

It is called �dynamic� RAM because it must be refreshed, or re-energized, hundreds of times each second in order to retain data in its memory cells. It has to be refreshed because its memory cells are designed around tiny capacitors that store electrical charges. These capacitors work like very tiny batteries and will gradually lose their stored charges if they are not re-energized.

SRAM (Static RAM) | Static RAM also uses memory cells laid out in rows and columns to store data, but SRAM is about five times faster, twice as expensive, and twice as big as DRAM. SRAM is also volatile (must have power to retain data) but SRAM does not need to be constantly refreshed like DRAM. SRAM designs use preztle-like flip-flop circuits that allow electricity to flow through one side or the other depending on which one of two transistors is activated. This �flow through� design is faster than the �stored charge� design of DRAM, but it consumes more power. Because of its lower cost and smaller size, DRAM is preferred for use in computer main memory, while SRAM, because of its speed, is used primarily for cache memory.

FPM DRAM

(Fast Page Mode DRAM)

Most computers in use today use FPM DRAM.

This kind of memory is an improvement over older forms of DRAM, making it faster to access data in the same row, or �page.� If the data needed is in the same row as the previous data, the memory controller does not have to repeat the row location; it only needs to indicate the next column location. This makes the memory process a little faster.

Using FPM memory is like reading a dictionary. As long as the word you want is on the same �page,� it will be easy to scroll down the list and find the definition; but when you have to flip pages, it takes a little longer to find what you want.

EDO DRAM

(Extended Data Out DRAM)

EDO DRAM is almost the same as FPM, with a slight modification that allows back-to- back memory accesses to occur much faster. Because EDO is easy to implement, it has gained wide acceptance in a very short span of time.

A computer system must be designed to support EDO in order to make use of the extra efficiency it offers. EDO memory in a system that doesn't support it will work, but there will be no performance increase. At present, FPM and EDO DRAM make up the majority of main memory for computers.

EDO is sometimes called Hyper Page Mode DRAM.

BEDO DRAM

(Burst EDO DRAM)

Burst EDO is an innovation on standard EDO that allows a �burst,� or series, of data to be transmitted from memory with a single request. The assumption behind this feature is that the next data-address requested by the CPU will be sequential to the last one, which is usually true.

In BEDO DRAM all memory accesses occur in bursts.

SDRAM

(Synchronous DRAM)

SDRAM is another form of memory developed shortly after EDO. This technology is a more radical innovation that can synchronize itself with the system clock that controls the CPU. Being �in sync� with the processor eliminates timing delays and makes the memory retrieval process much more efficient.

In order to use SDRAM, a computer system must be designed to support that kind of memory. Most computers shipping today support EDO, but a few are beginning to support SDRAM. Over the next few years, FPM will phase out, and SDRAM will most likely overtake EDO as the standard memory for high-performance systems.

SGRAM (Synchronous Graphics RAM) | SGRAM is an extension of SDRAM that includes graphics-specific read/write features. SGRAM allows data to be retrieved and modified in blocks, instead of individually. This reduces the number of reads and writes that the memory must perform, and increases the performace of the graphics controller by making the process more efficient.
RDRAM (Rambus� DRAM) | RDRAM is a completely unique design developed by Rambus, Inc. RDRAM is extremely fast, but requires significant changes in the memory controller and memory/system interface to use. RDRAM uses a narrow, high-bandwidth �channel� to transmit data at speeds about ten times faster than standard DRAM. At present, RDRAM is being used in some game machines and PC graphics applications.

VRAM

(Video RAM)

Graphics memory must work very quickly to update, or refresh, the screen (60-70 times a second) in order to prevent screen �flicker.� At the same time, graphics memory must respond very quickly to the CPU or graphics controller in order to change the image on screen. With ordinary DRAM, the CRT and CPU must compete for a single data port, causing a bottleneck of data traffic.

VRAM is a �dual-ported� memory that solves this problem by using two separate data ports. One port is dedicated to the CRT, for refreshing and updating the image on the screen. The second port is dedicated for use by the CPU or graphics controller, for changing the image data stored in memory.

VRAM works much like a fast food drive-through that uses two windows. After you place an order, you pay at one window, then drive up and get your food at the next window. This makes the process faster and more efficient.

WRAM (Window RAM) | WRAM is another type of dual-ported memory also used in graphics-intensive systems. It is slightly different from VRAM in that its dedicated display port is smaller, and that it supports EDO features.

## What does RAM look like?

RAM usually consists of a number of memory chips that are mounted onto a small printed circuit board. The board is referred to as a memory module and comes in two main types for todays computers:

- SIMM (Single In-line Memory Module)
- DIMM (Dual In-line Memory Module)

### CPU and memory requirements

The most powerful Pentium and PowerPC microprocessors currently are 64-bit CPUs, which means they can simultaneously process 64 bits, or 8 bytes of data, at a time.

Each transaction between the CPU and memory is called a bus cycle. The number of data bits a CPU can transfer during a single bus cycle affects a computer's performance and dictates what type of memory the computer requires.

Most desktop computers use either 72- or 30-pin SIMMs. A 30-pin SIMM supports 8 data bits; a 72-pin SIMM supports 32 data bits.

### 30-pin SIMMs

Let's look at the example of a CPU that supports 32 data bits. If the computer's system (mother) board has 30-pin SIMM sockets, each of which supports 8 data bits, you'll need four 30-pin SIMMs to supply 32 bits. (This is a common configuration for systems that use 30-pin SIMMs.) The memory configuration on such a system is typically divided into two memory banks -- bank zero and bank one. Each memory bank consists of four 30-pin SIMM sockets. The CPU addresses memory one bank at a time.

> NOTE: With most computer models, mixing different-capacity SIMMs within the same bank prevents the computer from accurately detecting the amount of available memory. This causes one of two things to occur:

> 1. The computer will not boot up.
> 2. The computer will boot up but will not recognize or use some of the memory in the bank. For example, if a bank had three 1-megabyte SIMMs and one 4-megabyte SIMM, it would recognize them all as 1-megabyte SIMMs.

### 72-pin SIMMs

| The 72-pin SIMM was developed to satisfy the ever-expanding memory requirements of desktop computers. One 72-pin SIMM supports 32 data bits, which is four times the number of data bits supported by a single 30-pin SIMM.
| If you have a 32-bit CPU -- such as a 486 from Intel or Motorola's 68040 -- you need only one 72-pin SIMM per bank to provide the CPU with 32 data bits. As we saw in the previous section, that same CPU would require four 30-pin SIMMs per bank to get its 32 data bits.

### DIMM memory

Dual In-line Memory Modules, or DIMMs, closely resemble SIMM-type memory.

Like SIMMs, most DIMMs install vertically into expansion sockets. The principal difference between the two is that:

- on a SIMM, opposing pins on either side of the board are `tied together' to form one electrical contact;
- on a DIMM, opposing pins remain electrically isolated to form two separate contacts.

DIMMs are often used in computer configurations that support a 64-bit or wider memory bus. In many cases, these computer configurations are based on powerful 64-bit processors like Intel's Pentium or IBM's PowerPC processors.

For example, Kingston's KTM40P/8 DIMM module used in IBM's PowerPC 40P RISC 000 computer is a 168-pin DIMM.

### Small Outline DIMMs

Another type of memory commonly used in both notebook and laptop computers is called Small Outline DIMM, or SO DIMM.

A small outline DIMM is like a 72-pin SIMM in a reduced-size package, but with some important technical differences. The small outline DIMM and the SIMM shown opposite both have 72 pins. However, it's the way the pins are arranged that differentiates these two types of memory. The three examples illustrate the differences among SIMM, DIMM, and SODIMM products.

The full size, 168-pin DIMM supports 64-bits transfers without being twice the size of the 72-pin SIMM which support only 32-bit transfers. The SODIMM also supports 32-bit transfers and was designed for use in notebook computers.

## Memory operation

The memory requirements of the computer may dictate that there must be one or more memory modules installed. In turn, like the memory modules above, these may be composed of two or more memory chips.

How does the computer access the data held in a specific location on just one of those chips?

To start with, a memory chip contains an array of memory elements. Each memory element holds a single bit of information and each element has a unique address.

### Consider an 32 MB memory organized as 32 bit words.

Each memory chip has the same basic pin structure.

- A number of address lines
- A number of data-in lines
- A number of data-out lines
- Control connections for:
  - Chip selection (CS)
  - Output enabling (OE)
  - Write enabling (WE)
- Power connections (not shown)

The chip above holds 32K x 8 bit words of data. Otherwise described as 32Kbytes.

- The chip has 15 address lines, suggesting that each 8-bit chunk of memory can be accessed at one of 2^15 addresses on that chip.
  - 2^15 = 32768 (32K)
- Data is read from and writen to the chip in 8-bit chunks

To get the desired 32 MB of memory using the 32Kx8 chips above, we would have to create an array of chips (like on a memory module). Infact, the full 32M of memory we would need 1024 x 32Kx8 chips!

To address 32 MBytes requires 25 address lines, but that is a byte address.

For a word address, we only need a quarter of those address lines, making 23 bits of address. (there are 4 bytes per 32-bit word!)

- 2^25 = 33554432 (32M) x bytes
- 2^23 = 8388608 (8M) x 32-bit words

Our array of chips may look something like this:

### How is a particular chip accessed?

In the above diagram you will notice that the 23 address lines are split into the 15 address lines required to access a data element on a chip, and a further 8 lines to select a particular group of 4 chips that might share the 4 bytes of the word being addressed.

- 1024 / 4 = 256 = 2^8

With only 8 address lines, how do we pick one of 256 groups of 4 chips?

For that matter, with only 15 bits of address, how can we access one of 32K bytes on a particular chip?

A: By using a decoder.

### Decoder

How many different 4-bit binary words are there?

A: 2^4 = 16. i.e.

0000 | 0100 | 1000 | 1100
0001 | 0101 | 1001 | 1101
0010 | 0110 | 1010 | 1110
0011 | 0111 | 1011 | 1111

So with 4 bits we could encode 16 different values.

If each of the 4 bits above were an address line then we could 'decode' that word to access one of 16 different memory elements or chips or groups of chips.

The circuit that decodes 4 address lines into one of 16 possible values is called a '4 to 16 decoder'.

Here is an example of a '3 to 8 decoder':

Decoders convert a binary encoded signal into one signal per input combination.

The small circle or dot at the input to the 'AND gates' means 'NOT' or negate. (module 2, topic 2)

In this example, if each of the three address inputs was '0', i.e. A0=0, A1=0, A2=0, then the output line D0 would be the only output to have the value '1'. In other words D0 would be selected.

At this time D1-D7 would all be '0'.

Decoders have a variety of functions.

- Consider decoding the instruction code in the instruction register of a machine
- Consider displaying a binary code with one light for each pattern e.g. a floor indicator on a lift.

## What is inside a memory chip?

The 32K x 8 example used above would be a bit bulky to demonstrate with.

Here is a diagram of a 4x3 memory chip that has four 3-bit words. Looks a bit like the arrangement of chips making up the 32Mbyte memory above huh?

Don't let the funny shaped gate diagrams phase you. This is just a two dimensional array of D flip-flops. The important features of the diagram are:

- 12 D flip-flops to hold the 12 1-bit values
- 3 data-in lines (3-bit words) I0, I1, I2
- 3 data-out lines O1, O2, O3
- 2 address lines (giving 2^2 = 4 possible word addresses) A0, A1
- 2 to 4 decoder is implemented with 'AND' and 'NOT' gates.
- Control lines are CS (chip select), RD (read data, opposite of WE), OE (output enable)

These days there are chips that are capable of storing 4Mbytes or 4M x 8-bits. Could you imagine the complexity that chip?

## Reading and writing to memory

The CPU usually has two registers that are the interface between the CPU itself and the RAM:

- MDR (Memory Data Register) is used to hold the value (word) to be written to memory in the case of a write operation or the value (word) just read from memory, in the case of a read operation.
- MAR (Memory Address Register) is used to hold the address of the memory location being accessed (read from or written to). A 32-bit address can be used to access 1 of 2^32 (= 4G) memory locations

The diagram above demonstrates the relationship between the MAR, MDR and main memory.

This example shows how the 6 to 64 decoder selects the appropriate word in the memory chip. The sequence of events that must occur to write some data to a chip are as follows:

1. Place the address of the data in the MAR
2. Place the data to be written to memory in the MDR
3. Set the chip select line (CS) to '1'
4. Set the write enable line (WE) to '1'
5. Set the output enable line (OE) to '1'
6. Output occurs at the next clock pulse.

So, there is a little bit about memory!

Alot of this information was sourced from:

The Ultimate Memory Guide - Copyright Kingston Technology

and

Memory Bits - published by Kingston Technology

To view this information in its original form...And for a whole lot more interesting information relevant to this area, I recommend a tour of the whole Kingston Technology site highly.