✔ Last Episode
- Using just logic gates, we built a simple ALU, which performs arithmetic and logic operations, hence the 'A'(Arithmetic) and the 'L'(Logic).
- It would be useful to store that value, and maybe even run several operations in a row. That's where computer memory comes in.
❔ Today's Episode
Today, we’re going to start small - literally by building a circuit that can store one single bit of information.
After that, we’ll scale up, and build our very own memory module, and we’ll combine it with our ALU next time, when we finally build our very own CPU!
🎲 Random Access Memory, RAM
- 게임을 하고 있는데 전원이 나가면 하던 것들이 모두 날아간다. 콘솔 게임기, 노트북, 컴퓨터가 RAM을 사용하기 때문이다. RAM은 전원이 켜져 있을 때만 게임 상태 같은 것을 저장할 수 있다.
- RAM stores things like gate state - as long as the power stays on.
Another type of memory - persistent memory
- survive without power, and it's used for different things.
🔄 Circuits that loop back on themselves
- All of the logic circuits we've discussed so far go in one direction - always flowing forward - like our 8-bit ripple adder from last episode.
- But we can also create circuits that loop back on themselves.
OR Gate
- input이 모두 0일 때 : 회로의 output은 항상 0이다.
- input A가 1일 때 : output 1
- input B가 1일 때 : output 1, 그런데 회로가 연결되어 있으므로 loop back, 즉 되돌아 오게 된다. A를 0으로 바꿔도 ouput은 여전히 1이다. 이렇게 1을 기록할 수 있는 회로가 완성되었다.
- 그런데 여기엔 문제가 있다. 이 변화는 영구적이라는 것이다. 한 번 B에 1을 입력하게 되면 바꿀 수가 없고, output 역시 1에서 0이 될 수가 없다.
AND Gate
- AND Gate는 OR Gate와 반대로 0을 기록할 수 있다.
- A가 아무리 1로 바뀌더라도 1 AND 0 은 0이다.
- B는 루프에 있기 때문에 1로 입력을 할 순 없는 상태라고 이해했다. (그래서 1 AND 1 이 일어날 수가 없다)
Now we’ve got circuits that can record both 0s and 1s.
AND-OR Latch
OR은 1을, AND은 0을 기록할 수 있었다. 이것을 유용하게 만들려면 이 두 회로를 하나의 회로로 합쳐 버리는 것이다. 이것을 AND-OR Latch라고 한다. latch란 걸쇠, 좌물쇠라는 뜻이다. 특정한 값을 "latch onto" 즉 걸어두고, 그대로 유지하기 때문에 latch 라고 이름붙인 것이다.
여기에는 input이 2개이다.
- set input : ouput을 1로 세팅한다.
- reset input : ouput을 0으로 리셋한다.
If set and reset are both 0, the circuit just outputs whatever was last put in it.
It remembers a single bit of information! Memory!
- writing - 메모리에서 값을 집어넣는 것
- reading - 메모리에서 값을 얻는 것
그런데 지금 input이 set, reset 이렇게 2개 있으니까 헷갈릴 수 있다. input을 하나의 선으로 만들어 보자.
Gated Latch
set, reset 대신에 "Data Input"이라는 wire 한 개로 대체했다. 0이나 1이라는 input이 여기로 들어오면 이제 그 값을 저장할 수 있다.
Write Enable이라는 wire가 하나 더 있는데, 이것은 메모리 쓰기를 가능하게 하거나, 잠글 수 있게 한다.
논리 회로를 더 추가해서 위와 같은 회로를 만들 수 있고, 이것을 Gated Latch라고 한다. 문을 열거나 닫을 수 있다는 의미이다.
회로가 좀 복잡해졌고, 각 logic gate를 일일이 다루는 것이 아니니, 여기서 추상화의 수준을 한 단계 높이고, Gated Latch를 상자 하나로 만들어 버리자. 바로 bit 1개를 저장하는 상자인 것이다.
Write enable wire가 off 상태라면, 메모리가 바뀌지 않는다.
Write enable wire를 1로 만들어 on으로 된다며 Gate를 열어주는 것과 같다. 그러면 이제 Gate Latch에 값 1을 저장할 수 있다.
출력이 1로 유지되게 하려면 Write enable wire를 꺼 준다. 그러면 Data in이 0이라고 해도, 값이 메모리에 저장되었기 때문에 Data out은 항상 1을 유지하게 된다.
Register
- 이러한 Gate Latch는 단지 1비트만 저장할 수 있지만, 8개를 나란히 두게 되면 8bit의 정보를 저장할 수 있다. 이런 식으로 작동하는 Latch의 그룹을 Register라고 한다. 이것은 1개의 숫자를 저장할 수 있다.
- 레지스터의 비트 수는 width라고 한다.
- Early computers had 8-bit registers, then 16, 32, and today, many computers have registers that are 64-bits wide.
- To write to register, we first have to enable all of the latches.
- We can do this with a single wire that connects to all of their enable inputs, which we set to 1.
- We then send our data in using the 8 data wires, and then set enable back to 0, and the 8 bit value is now saved in memory.
16 x 16 Latch Matrix
In this matrix, we don’t arrange our latches in a row, we put them in a grid.
This means in total, for 256 bits of memory, we only need 35 wires - 1 data wire, 1 write enable wire, 1 read enable wire, and 16 rows and columns for the selection. That’s significant wire savings!
Memory Adress
The way to uniquely specify each intersection
Multiplexer
To convert from an address into something that selects the right row or column, we need a special component called a multiplexer.
You feed it a 4 bit number, and it connects the input line to a corresponding output line.
So if we pass in 0000, it will select the very first column for us.
If we pass in 0001, the next column is selected, and so on.
We need one multiplexer to handle our rows and another multiplexer to handle the columns.
This component can store 256 bytes at 256 different addresses.
"Random Access" Memory
An important property of this memory is that we can access any memory location, at any time, and in a random order.
RAM is like a human’s short term or working memory, where you keep track of things going on right now.
Memory, RAM, Memory Adress, Register 등 컴퓨터에서 매우 중요한 핵심 기능이 어떤 식으로 작동하는지를 배웠다. 이 부분은 확실히 다른 자료와 함께 공부해야 될 것 같다. 방대한 내용을 10분짜리 영상으로 압축해서 보다 보니 아직 잘 와닿지 않는 부분도 있다.