1 of 32

Computing Workshop: Hardware - 3

Memory

2 of 32

Recap and Agenda

Last week we looked at

  • Integrated circuits on our breadboards.
  • Building an adder, transforming our breadboards into little binary calculators!

Today, we’ll see:

  • How computers store information, using latches.
  • DIfferent kinds of computer memory and how they look

Reminder: 2 classes left :(

3 of 32

ALU

Last week we looked at the arithmetic and logic unit (ALU)

As the name suggests, the ALU can do logical operations and math

You control what operation to do with the Opcode, and the inputs are at the top of the V with the output at the bottom

This is all done using logic gates

4 of 32

Our ALU is lonely

The ALU on its own it’s very interesting because the results of our calculations aren’t stored anywhere. But how can a computer store information at all?

The trick is to “trap” the flow of electricity by creating feedback loop within a circuit. The presence of this “trapped electricity” represents a binary digit 1, whereas its absence represents a 0.

We can do this rather easily with the logic gates we already know!

5 of 32

Details? Take it away, Carrie-Anne!

6 of 32

Constructing our very own AND-OR latch

Before we make this, let’s draw the truth table so we can check our circuit against it later.

This is just like a normal diagram with 2 inputs and one output, however the inputs are the set and reset inputs (respectively)

SET

RESET

7 of 32

Reminder about ICs

This is a “pinout diagram” for the chips we’ll be using.

The top of the IC has a little divot to help you orient them.

Make sure the VCC is connected to the positive and the GND is connected to the negative.

Test out the AND & OR ICs on your breadboard by observing their output using an LED!

8 of 32

Important reminder about ICs

We need to use a voltage regulator with our ICs to prevent them from blowing up

9 of 32

Let’s make this thing!

10 of 32

Scaling up

By putting together many 1-bit memory units like the one you just built, we can construct larger memory units.

By joining eight 1-bit units, we can store one byte.

Finally, by using many 1-byte units, we can construct our computer’s main memory, or RAM.

01001110

1-bit

8-bits or

1 byte

11 of 32

1 byte isn’t very much

Now we know how memory works but we have a new problem: to remember anything useful we’re going to need a lot of bits.

For example, the average smartphone photo is 5MBs.

5MB = 5,000KB = 5,000,000 bytes = 40,000,000 bits…

So how can we store all these bits?

12 of 32

Where are you??

One solution to this problem is addresses

The idea is to structure our data as a matrix or table, where we locate the information (binary number) stored at a particular x, y coordinate

Think of this like a map of Manhattan: I can ask you to meet me at 3rd and 48th street and you know where to go

13 of 32

It’s the same for memory!

1-bit memory units are arranged in a matrix.

To select a particular bit, specify the row and column number of the bit!

What to do with an address? Only 2 options: read or write!

In a 16x16 grid, we need 4 bits for the row, and 4 for the column

What’s the address of the selected 1-bit memory cell?

14 of 32

But that’s long-winded!

Groups of four bits occur very often, so being able to represent a group of four bits succinctly makes sense. With four bits, we can represent the numbers 0 to 15, so we need sixteen digits for this new base, called hexadecimal.

The commonly used digits are all the decimal digits 0-9 plus A, B, C, D, E, F. “A” stands for ten, “B” for eleven, …, and “F” stands for fifteen.

Binary, decimal, and hexadecimal are all just different ways of representing numbers. Like saying the same thing but in different languages!

15 of 32

But that’s just 256 bits, not 256 bytes!

  • So what? Just put eight 256-bit memory units side by side, and now we can store 256 bytes.

16 of 32

It’s just a big list of bytes

But remember we got to 256 bytes, but a instagram photo is about 5MBs or 5 million bytes!

So how do computers do it? They just add more and more memory

17 of 32

Walk like a computer

On you computer memory worksheets, compute the sum of the values in the cells referred to by the addresses 111000 and 111100. Overwrite the value in cell 001101 with the value you computed.

18 of 32

But not everything in life is a number!

So how do we store letters or text?

19 of 32

We’ll find out about that after our break!

Take 5 to stretch, chat, and/or hydrate!

20 of 32

So what about letters?

I lied! Everything is a number, even letters!

Just associate numbers with letters, e.g. “a” = 1, b = “2”, etc. But what about other symbols? Like “!”?

Incoming: ASCII, the American Standard Code for Information Interchange! It defines numbers for 128 symbols, which means we need seven bits to represent one ASCII character.

21 of 32

And now to do some decoding!

On the worksheets, you have an ASCII table and 512 bits of RAM, preloaded with some interesting data. Some of that data is ASCII-encoded!

  1. Using the ASCII table, decode eight bytes starting at address 110000 This spells a japanese word; look it up!
  2. Use the ASCII table to decode the sequence of bytes starting at address 001101 and continuing until you read a NUL character.�Don't worry if what you decode is just symbols! Hint: if you read the symbols aloud, it should form a kind of poem.

22 of 32

Not all memory is equal

Memory balances some core attributes:

  • Size
  • Capacity
  • Speed
  • Price
  • Persistent
  • Durable

23 of 32

Processor register, Cache, and RAM

These three forms of memory occupying the top of the hierarchy!

They are small and extremely fast, but have a small capacity, very expensive and will get flushed when we turn off our computer as they trap electricity like our SR latch!

24 of 32

Other ways to store bits

How else can we store electricity without losing it?

Recall that bits are just two states: on/off! There are a few ways we can think about storing data that is persistent.

25 of 32

What about magnetic polarity?

Magnets have two poles, north and south, and we can control which is which by applying a current.

For example, if the north pole of our magnet is pointing up, we can consider that 1 and if the south is up, we can think of that as zero

26 of 32

Or what if we used light?

Let’s say I use a shiny metal disc to store bits. A small laser will illuminate each address of the disc, and if it reflects the laser back to a camera (optical sensor), the computer will interpret this as a 1 or true. If there is no light, then 0 or false.

This is how CDs store values!

27 of 32

What about USB sticks and SSD?

Earlier we made an assumption that you can’t have trapped electricity without a constant power supply, but research has changed this!

In the 80s, flash memory was invented, which was small sized, medium capacity, fast (but not as fast as RAM) and expensive

Flash memory is the basis of SSD memory and USB keys (aka USB flash drive)

28 of 32

Time to consult!

You have recently been hired at MemCorp LLC. Your job is to provide your clients with what you believe is the best memory for their problems. First answer alone, then you will get a chance to discuss with your groupmates!

29 of 32

Client 1: Cherry Angelcake

Ms. Angelcake is the CEO and owner of Angelcake Co. She has completely automated the process of making cakes using robotic arms. The robotic arms need to quickly shuttle many recipe instructions! What kind of memory should Ms. Angelcake use?

What kind of memory do you recommend?

30 of 32

Client 2: Dr. Hart

Dr. Hart is currently responsible for managing her hospitals database of patients. This is a large hospital in the heart of New Comp city, meaning her database will store the info of a lot of patients. This data doesn’t need to fast, just reliable and cheap!

What kind of memory do you recommend?

31 of 32

Client 3: KirbyMastah

KirbyMastah is a speedrunner of video games like Kirby and Sonic. Along with needing to play his games on his computer at the highest possible graphics, he also livestreams his world record attempts to twitch. Furthermore he’s notorious for leaving dozens of tabs open in Google chrome while he plays.

What kind of memory would you recommend for him?

32 of 32

Recap

This week we saw:

  • How to build our own 1-bit memory unit using logic gates in a feedback loop
  • How we can scale up our tiny memory units into larger blocks to form a computer’s main memory, or RAM.
  • How computers use different types of memory for different purposes: hard disks for storage, RAM for storing programs and temporary data, and registers as go-betweens for communicating with the ALU.

Next week we will:

  • Learn about the mastermind processor!
  • Find out what happens when you turn a computer on