Machineboy空

[From Nand to Tetris] 모듈 3. Memory 본문

Computer/CS

[From Nand to Tetris] 모듈 3. Memory

안녕도라 2025. 2. 3. 17:10

main memory unit = RAM(Random Access Memory)을 만들어 볼 것

 

  • computer's processing chips: based on combinational logic
  • computer's memory logic : clock-based sequential logic

Key Concept

  • Combinational vs sequential logic
  • clocks and cycles
  • flip-flops
  • registers
  • RAM units
  • counters

3.1 Sequential Logic : 시간 단위가 있는 순차 논리 회로라는 개념

how to computers do one thing after another

지금까지는 input 넣으면 바로 output이 출력되고, 실행시간에 관한 생각을 안해봤는데 이제는 고려해 보자!

 

많은 연산을 같은 하드웨어를 사용해 수행해야 하는 경우나,

1부터 100까지 수를 더한다 했을 때, 중간 합을 기억하면서 total sum을 구할 것

 

Not Gate에 1타임에 1을 넣으면 2타임에 0으로 출력되는 모습

 

ContinuousTime(Physical Time)을 Discrete Time(Digital integer Unit)으로 Convert

Physical time: 실제 시간, 연속적인 arrow 이것을 convert할 것이다.

  • clock, kind of oscillator going up and down at a certail fixed rate
  • cycle of the clock = one digital integer time unit
  • break up our physical continuous time into a sequence of time. one, two, three...

예) NOT GATE 의 input 과 output은 다른 time unit

every time unit the input could change, and then the output would follow

 

Delay 문제를 해결하는 방법

실제로는 time 내에서 논리 연산이 수행될 때 딜레이가 존재. 하지만 끝값만 고려함으로써 이를 해결

end of the gray area,

all the signals reach their true and final and consistent state

all the hardware stabilizes

logical operation by end of the gray area

 

우리는 ignore these inconsistencies because gray가 끝난 뒷시점만 고려해주면 되니까

즉, 단절된 시간 단위를 쓰는 이유는 시스템을 좀 더 안정적으로 사용하기 위해서

 

 


 

3.2 Flip Flops  : 새로운 값을 저장하라고 하기 전까지 이전 값을 저장하고 있는 chip 토대

DEF와 1Bit Register

우리가 한 가지 놓친 것:  t-1 의 값도 기억하고 있어야 한다는 것.

moving information from t-1 to t

remember what happened previously and carry it on to the next stage

 

flip to 0 and then can flop back to 1

 

이전 상태 기억하는 법

The combinatorial logic which happens instantaneously

and the sequential logic which we don't want to thinking about how it is constructed from lower levels combinatorial stuff.

 

https://terms.naver.com/entry.naver?docId=1014634&cid=50324&categoryId=50324

 

조합 논리회로

조합 논리 회로전자용어사전 논리 회로에서 그 출력이 생각하고 있는 시점에서의 회로 입력 값만으로 정해지는 것. 출력이 위와 같이 입력 값만이 아니고 그 시점에서의 회로 상태에 따라서도

terms.naver.com

https://terms.naver.com/entry.naver?docId=1613053&cid=50324&categoryId=50324

 

순차 논리 회로

순차 논리 회로IT용어사전 입력의 조합만으로는 출력이 정해지지 않는 논리 회로로, 현재의 내부 상태와 입력에 의해 출력의 상태가 정해지는 것. 즉, 기억 작용이 있는 논리 회로이다. 예를 들

terms.naver.com

 

단순한 flipflop에서 확장해서 메모리는 어떻게 정보들을 기억하지? 느낌

 

 

intended functionality of the 1-Bit Register

How can we pipe and pipe the value that wer remember so it will keep on being remembered until we ask to change it

이건 real chip이 아니다

 

 

 

 

At each point in time we know the previous values.

We know what load is, we know what in is, we can compute what the next situation is, and at every given point in time, we can write down the values and all the different wires just like we did in combinatorial logic.

 


3.3 Memory Units

major player of 폰 노이만 구조 : memory

컴퓨터 구조에서의 memory in mother board는 many different meaning

 

휘발/ 비휘발 메모리

  • RAM: effectively erased when you pull out the plug of the computer
  • Disk, flash memory : persists even when the computer is not connected to power supply

RAM의 Duality

  • store programs data as well as instructions
  • 즉, RAM은 프로그램이 실행되는 동안 데이터를 저장하는 공간이자, 프로그램 자체(코드)도 저장하는 공간이다.

 

RAM의 기본 블럭, element가 되는 register

memory의 block: register

이전에 살펴본 1bit register을 stretch 해서 상상하면 됌

  • state: the value which is currently being expressed by the internal circuits of register

User's Perspective: How to read /write register?

 

contents of the register changed to 17. But the output of the register is still 0. And that's because, it takes a complete cycle for the register to actually stabilize and begin to emit the new state.

once I move to the next cycle, the output of the register is also 17

 

RAM Unit을 이제 만들어보자!

삼각형 의미: sequential chip, depends on a clock input

RAM Read/Write


3.4 Counters

예시. 브라우니 굽는 기계

 

domestic robot : bake some brownies for me

50가지의 지시를 포함하는 구체적인 프로그램을 작성할 것이다.

그리고 counter를 놓을 것이다. 다음에 실행해야할 지시의 번호를 emit하는

  • counter increments by one.
  • robot takes a look at the counter
  • robot execute instruction

다음 세트의 브라우니를 굽기 위해서는 0으로 돌리는 과정이 필요함

basic increment 뿐 아니라, change counter to a specific number할 수 있어야 함.

  • already warm 하다면, 11번으로 skip해라 라는 지시도 필요

카운터란 reset, next, goto 이 세 가지 기본 연산을 수행할 수 있는 hardware device를 말한다.


3.5 Project3 Overview


3.6 Perspective

RAM vs ROM vs Flash Memory vs Cache