The journey to becoming a developer

My future is created by what I do today, not tomorrow.

Computer Science/Crash Course

Boolean Logic & Logic Gates: Crash Course Computer Science #3

Millie 2021. 10. 3. 12:15

Crash Course Computer Science 3번째 시간! NOT, OR, AND가 프로그래밍 언어에서 무슨 일을 하는지는 대략적으로나마 알고 있어서 수월하게 들을 수 있을 줄 알았지만, 이것을 전기적/하드웨어적으로 본다는 것은 또 다른 것이었다. 


Binary : of two states

2가지 전기적인 상태만으로도 중요한 정보를 표현할 수 있다. 

  • On : 전류 흐름(electricity is flowing), true
  • Off : 전류 흐르지 않음(no electricity is flowing), false

Why Computers use binary?

1. 2진법으로는 상태를 명확하게 나타낼 수 있다. 중간 상태가 없어서 애매함이 없다. 

예전에는 3진법이나 5진법도 초기 전자 컴퓨터에 사용했지만, 중간에 애매한 상태들이 많이 존재하기 때문에 전기적인 잡음이 생겨서 신호가 섞일 수 있었다. 트랜지스터가 1초에 수백만번의 상태를 바꾸는데, 이러면 상황은 더 악화된다.

 

2. Boolean Algebra(불리언 대수학)에서 참과 거짓을 조작하는 데 필요한 규칙과 연산 방법을 모두 알아낼 수 있었다.

이 접근은 논리 방정식을 통해 공식적이고 체계적으로 증명되었다. 

NOT

하나의 불리언 값을 취하며 그 값을 부정한다. 값이 참이면 거짓으로, 거짓이면 참으로 뒤집는다. 

그리고 앞으로 Gate라는 것을 알아볼 것인데, 이것은 전류의 길을 통제하기 때문에 Gate라고 한다. 

NOT Gate

If we turn the input on, the transistor allows current to pass through it to the "ground" and the output wire won't receive that current - so it will be off.

In our water metaphor, grounding(접지 상태) would be like if all the water in your house was flowing our of a huge hose, so there wasn't any water pressure left for your shower.

AND

  • The AND Boolean operation takes two inputs, but still has a single output.
  • The output is only true if both inputs are true

AND Gate

A는 켜졌지만 B가 켜지지 않아서 전류가 흐르지 않음. 두개가 다 on이어야 전류가 흐른다. 

To build an AND gate, we need two transistors connected together so we have our two inputs and one output.

If we turn on just transistor A, current won't flow because the current is stopped by transistor B.

Only if transistor A AND transistor B are on does the output wire have current.

OR

Only one input has to be true for the output to be true

Or statement is also true if both facts are true

The only time an Or statement is false is if both inputs are false

OR Gate

Building an OR gate from transistors needs a few extra wires.

Instead of having two transistors in series(on after the other, 직렬), we have them in parallel(병렬)

XOR (Exclusive OR)

XOR i like a regular OR, but with one difference : if both inputs are true, the XOR is false.

The only time an XOR is true is when one input is true and the output is false. 

Moving up another layer of abstraction!

AND, OR, NOT 등을 기호로 나타내는 것. 

Representing them and thinking about them this way allows us to build even bigger components while keeping the overall complexity relatively the same - just remember that all of the mess of transistors and wires is still there. (더 큰 구성 요소에 대한 생각을 길러 줌. 전체적인 복잡성은 비교적 똑같이 유지됨.)

Logic Gates Symbols 

When computer engineer are designing processors, they rarely work at the transistor level, and instead work with much larger blocks, like logic gates, and even larger components made up of logic gates.

And even if you are a professional computer programmer, it's not often that you think about how the logic that you are programming is actually implemented in the physical world by these teeny tiny components.


영상을 볼 때 한글 자막, 영어 자막의 도움을 받는데, 부정확한 부분이 자주는 아니지만 종종 있다. 그래서 영어 듣기 실력을 늘리는 게 중요하다고 생각되었다. 귀를 기울이면서 열심히 적어보았다. 

JavaScript에서 마주쳤던 AND, NOT, OR 연산자들의 역사를 알아보는 것이 흥미로웠다. gate로 알아보는 부분은 좀 어려웠지만 마지막에 캐리안 선생님이 말했듯 이것을 모르더라도 추상화를 통해서 프로그래밍을 할 수가 있다. 그래도 이런 동작 원리를 안다면 이해의 폭이 더 넓어질 것이다.