Computing Workshop: Hardware - 3
Memory
Recap and Agenda
Last week we looked at
Today, we’ll see:
Reminder: 2 classes left :(
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
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!
Details? Take it away, Carrie-Anne!
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
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!
Important reminder about ICs
We need to use a voltage regulator with our ICs to prevent them from blowing up
Let’s make this thing!
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
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?
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
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?
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!
But that’s just 256 bits, not 256 bytes!
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
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.
But not everything in life is a number!
So how do we store letters or text?
We’ll find out about that after our break!
Take 5 to stretch, chat, and/or hydrate!
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.
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!
Not all memory is equal
Memory balances some core attributes:
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!
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.
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
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!
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)
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!
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?
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?
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?
Recap
This week we saw:
Next week we will: