# How A Computer Works

## 1 Learning Objectives

By the end of the lesson…

• All Should Know that computers can store data in memory.
• All Should Be able to explain the concept of primary storage (RAM).
• Most Should Should Be able to explain the concept of Secondary Storage in terms of Magnetic or Optical mediums.

## 2 Storing Bits

### Learn It

• You've seen how logic gates can be used to perform some simple calculations such as adding bits together and maybe even subtracting bits.
• In order to do anything useful, computers need to be able to store the bits though.
• You may have seen in an earlier assessment how NAND gates can be used to store bits using an arrangement known as a D-Latch.
• For longer term storage of data, computers use volatile and non-volatile storage.

## 3 A Nibble or a Byte of a Word

### Learn It

• Storage is measured in bits. This is the number of 1s and 0s that the storage can potentially hold.
• A single bit is not a very useful measure, as there's not much a computer can do with just a 1 or a 0
• Sometimes we talk in terms of a nibble of data. A nibble is 4 bits - `1001` for instance.
• More usefully we use the term byte, which is 8 bits - `10101010`.
• Sometimes we talk of a word which can be 8, 16, 32 or 64 bits. You'll see why later.
• Even then, a few bytes of data is far too small, when we are talking about the capacity of modern storage devices.
• The webpage for last lesson is stored on a server and takes up 25,000 bytes. We use the standard prefix kilo to represent 1000, so this becomes 25kB.
• We can keep going up, in thousands, to describe the quantities of data. Below is a table with some examples.
bytes value prefix symbol example
1000 thousand kilo kB Words in this document up to this point - 10kB
1000000 million mega MB A song in MP3 format - 8MB
1000000000 billion giga GB An HD movie on Blu-ray - 27GB
1000000000000 trillion tera TB The back up of Wikipedia is around 4TB of data
1000000000000000000 quintillion exa EB The annual global exchange of data on the internet is around 950EB

## 4 Non-volatile storage

### Learn It

• Non-volatile memory stores data without needing to be permenantly powered.
• Examples of non-volatile memory are
1. Solid State Hard drives and Flash memory
2. Magnetic Hard disks
3. Optical discs such as Blu-ray, DVDs and CDs
• Solid state hard drives use NAND gates with special transistors that hold their charge to store bits of information.
• Magnetic disks and Optical discs are different though.

## 5 Assessment

• Conduct some research and learn how Magnetic disks and Optical discs are able to store bits.
• Right click to save the template to your homedirve. You will need to use this template for the Silver, Gold and Platinum badges for this lesson.
• Make sure you include the capacity (maximum amount of data they can hold) of the disks or discs.
• Present your findings in a suitable format for assessment.

## 6 Volatile storage

### Learn It

• Volatile storage is only able to store bits while it is being powered.
• Volatile storage is often called Primary Storage or Random Access Memory (RAM).
• There are two main types of RAM. Static RAM (SRAM) and Dynamic RAM (DRAM
• SRAM is fast and expensive and is used to hold bits for short periods of time before operations are carried out on them like addition and subtraction. The D-Latch arrangement of NAND gates is a typical memory cell capable of holding a single bit of data inside SRAM. We normally call this type of memory Cache.
• DRAM is slower and cheaper. DRAM is often simply called RAM and is used to store instructions for the computer and for storing bits of data for slightly longer periods.
• If you were to run the following script…
```x = 4
y = 5
z = x + y
```
• the values of x and y would be stored in DRAM, as well as the instruction to add the numbers together, followed by instructions to store the value of z in DRAM as well.
• A single memory cell in RAM (that can hold 1 bit) is made up of some transistors and a capacitor. The capacitor can hold charge for a short amount of time, but quickly drains and needs to be constantly recharged.

## 7 RAM

### Learn It

• Inside DRAM there are rows and columns of memory cells, each capable of holding 1 bit of data.
• A memory cell consists of some transistors and a capacitor. Capacitors can hold charge, but drain quickly.
• Below you can see a simplification for how RAM works
• The diagram show RAM with a word size of 16. That means that each row contains 16 cells.
• If we want to add some data into the RAM, we need to choose where to put it.
• Computers use addresses to indicate where in the RAM the data will be stored. In this example each address consists of 8 memory cells, so it can hold 1 byte of data.
• Modern computers usually have 32 or 64 bit address spaces, but such an example wouldn't fit on the webpage.
• Memory addresses are numbered. The first memory address is 0, the second is 1, the third is 10 and the fourth is 11.

### Try It

• Have a go at typing an address in binary into the Address input box and hit submit.
• You should see the numbers in the top and left bar change colour, indicating where the address is.
• To write data to that address we need to open the correct row and then send current down the correct columns to charge the memory cells.
• Type in an 8-bit binary number into the data box and then hit submit.
• You should see the rows and columns turn red to indicate that current is flowing through them. The cells should also turn red to indicate that they are holding charge.
• Now select a new address and write some data to it.
• The memory cells from the previous write should still be red, as they'll hold the charge for a short peiod of time. However, they'll need to be frequently recharged to keep the data.
• RAM can be read by detecting whether the tiny capacitors are more than 50% charged. If they are then the cell is holding a 1, otherwise they're holding a 0.

## 8 Assessment

• Use screen shots of the the RAM simulation to describe the process by which data can be stored in RAM.
• Ensure that you use the following key words: memory cell, word, address, capacitor.