Docsity

Primary memory and error correcting codes with examples, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
5 - Primary memory and error
correcting codes
#CA
Primary Memory
Main memory (RAM)
The main memory, or RAM stores the data in bits, so that it can be
interpreted by the computer.
When organising data into memory every address has to contain the
same amount of bits than the other ones, so, depending on the data we
need to represent, we have to decide a fixed size to store it.
If we organise the data using large cells we will have less addresses that
could be potentially too large for data and that will need wider data buses
in order to transmit the data outside ad inside of memory. At the same
time we will also need fewer memory access (because more data is
transmitted).
If we organise data using smaller cells we will have more addresses that
could be potentially too small for data and that will need much more
memory access because the data bus is now way smaller.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Primary memory and error correcting codes with examples and more Study notes Computer Architecture and Organization in PDF only on Docsity!

5 - Primary memory and error

correcting codes

#CA

Primary Memory

Main memory (RAM)

The main memory , or RAM stores the data in bits, so that it can be interpreted by the computer. When organising data into memory every address has to contain the same amount of bits than the other ones, so, depending on the data we need to represent, we have to decide a fixed size to store it. If we organise the data using large cells we will have less addresses that could be potentially too large for data and that will need wider data buses in order to transmit the data outside ad inside of memory. At the same time we will also need fewer memory access (because more data is transmitted). If we organise data using smaller cells we will have more addresses that could be potentially too small for data and that will need much more memory access because the data bus is now way smaller.

The basic group number of bits is 8 and forms a byte , which is the used group for standard cell organisation. Even though an address, or cell, has a specific number of bits in it, a real meaningful information in memory is not stored in a single cell. A word is the group of bytes and cells that is used to perform operations inside the computer. Since in a n bits architecture every operation is made with n bits, a word is the smallest unit of operation. For example, in a 32 bit architecture a word is 4 bytes and every operation is performed with blocks of 4 bytes (sum, logic operations, read and write etc).

Metrics

Since computers uses power of 2 to represent numbers, the term "Kilobyte" is not correct. In the scientific representation, a "Kilobyte" is the value of 1000 bytes, which is not the same as a "Kilobyte" in the computer representation. In order to represent a "Kilobyte" with power of two we need to use at minimum the 10th power of 2 ( 210 ), which is 1024 Bytes.

Addresses with groups of 3 bits If i wanted to organise my data in 3 bits i would have: 0 - 1 - 2 - 3- 010 ... Where the left number is the nth^ address.

Curiosity In the past the bigger memory was of 4GB because a 32bit machine could only deal with numbers below 232 = 4.294.967.

with the neighbour addresses , so that after this first memory operation the other load instructions will be executed faster because the cache already holds the needed data.

Cache access

Computing access time To give an example of how cache improved architectures we can look at this image:

To know what is the access time we now do: c + (1 − h ) m where:

c is cache access time;

Cache levels

Most CPUs have multiple levels of caches, where the first gets checked first and the second gets checked if the instruction was not in level 1, and so on. Eventually if its not even in the last level the cache will load from memory the addresses in all levels.

The cache levels gets bigger (and slower) the more they get close to memory, but the probability that the instruction needed are already in the cache gets every level down higher (because it gets bigger every time), minimising the times that the CPU actually loads from memory. Here's the typical today's levels:

While time of memory access before was just: m. Way faster than the main memory but very expensive.

m is memory access time; h is cache hit/ratio (how many times the CPU accesses the cache).

L1 (64Kb): the fastest level, with an unsuccess rate of 4% [2]; L2 (1.5 Mb): has an unsuccess rate of 20% of 4% (0.8%) L3 (32 Mb): it is usually off the chip and has an unsuccess rate of 40% of 20% of 4% (0.32%) We can see that at this point only the 0.32% of the register-memory instructions actually have to go in memory itself. The average success rate is computed with the sum of the success rates of each level.

Impact of caches Take a set of 100.000 instructions, where the 20% are instructions that need to load something from memory, then with a speed of 1 cycle for non-load instructions and 180 cycles for load instruction,

Example of the parity

If we have a code word of 4 bits, then we have 2 m + r^ = 23+1^ = 16 possible code words , 2 m^ = 2^3 = 8 valid code words and 2 m (2 r^ − 1) = 2^3 (2 − 1) = 8 invalid code words. Valid code words with a even parity are:

memory word (m) redundancy parity bit (r) 000 0 001 1 010 1 011 0 100 1 101 0 110 0 111 1

For each valid code word there are 4 invalid code words, for a total of 8 excluding duplicates and 16 possible code words in total:

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

This though means that we can detect a single bit flip but not fix it, because we don't know which bit flipped.

Richard Hamming

Is the founder of ACM, he devised a way to correct error-codes: the Hamming code, and a generic metric: the Hamming distance

Hamming distance

The Hamming distance is the metric used to measure how many bit flips there are between any valid code word to another. In the previous example the hamming distance was of 2, because from a valid code word we need two bit flips to get to another valid code word. With a Hamming distance of 2 it is impossible to correct an error, since the invalid code word could have different bit flips and still be a valid code word, but not the code word it came from. With a Hamming distance of 3 it is possible to correct 1 bit flip, since there is only one possible valid code word that the invalid code word came from.

The number of bits that i can detect and correct are computed by taking the hamming distance:

how many bit flips can I detect? Less or equal than the distance-

Scheme

Even if the computer places bits wherever it wants, as humans it is better to visualise how the Hamming code works we utilise this table, where each check bit (green positions) is positioned in every power of two's positions, starting from 20 up to the power of two that covers the entire memory word (blue positions).

We have these check bits, that checks parity:

First check bit : represented by the position number 20 ; Scheme: checks parity 1 bit yes and 1 bit no starting from its position; Second check bit : represented by the position number 21 ; Scheme: checks parity 2 bits yes and 2 bits no starting from its position; Third check bit : represented by the position number 22 ; Scheme: checks parity 4 bits yes and 4 bits no starting from its position; Fourth check bit : represented by the position number 23 ; Scheme: checks parity 8 bits yes and 8 bits no starting from its position.

Filling parity bits

To fill parity bits in a word we check for a parity in each check bit scheme, if there is not the check bit will be 1, otherwise 0. What we get is a different combination for each bit; the data bit number 3 for example is checked by the 1st and 2nd check bit, and so on according to the scheme.

Checking for errors

To know whether there has been a flip or not, and eventually correct it, we check for each check bit scheme if there is a parity or not and determine the flipped bit by looking at the schemas combination where the parity didn't occur:

Check in the first scheme for a parity (1 bit yes and 1 bit no): if yes, then the bits in the schema are correct; if not, then there is an error in one[3]^ of the bits covered by the first check bit; Check in the second scheme for a parity (2 bits yes and 2 bits no): if yes, then the bits are correct; If not, then there could be an error in one of the bits covered by the second check bit; Check in the third scheme for a parity (4 bits yes and 4 bits no): If yes, then the bits are correct; If not, then there could be an error in the bits covered by the third check bit.

  1. i.e. Cycles Per Instruction↩
  2. the unsuccess rate is the probability of an instruction to be on the successive levels, so the unsuccess ratio of the a lower level is always based on the unsuccess ratio of the level before it.↩
  3. this is by assumption that not more than 1 bit flipped, since we can not correct more than 1 bit.↩