Menu
Coddy logo textTech

AND OR NOT 게이트

Coddy Verilog 여정의 기초 섹션에 포함된 레슨 — 90개 중 40번째.

이 레슨에서는 가장 기본적인 세 가지 논리 게이트인 AND, OR, NOT을 다룹니다. 이 게이트들은 디지털 논리 설계의 기초를 이룹니다.

AND 게이트

AND 게이트는 모든 입력이 1일 때만 1을 출력합니다.

진리표 (2입력):

about
000
010
100
111

Verilog gate primitive:

and(out, a, b);

Continuous assignment equivalent:

assign out = a & b;

OR 게이트

OR 게이트는 입력 중 최소 하나1일 때 1을 출력합니다.

진리표 (2개 입력):

about
000
011
101
111

Verilog 게이트 프리미티브:

or(out, a, b);

연속 할당(Continuous assignment) 동등 표현:

assign out = a | b;

NOT 게이트

NOT 게이트는 단일 입력의 반대를 출력합니다. inverter라고도 부릅니다.

진리표:

aout
01
10

Verilog gate primitive:

not(out, a);

Continuous assignment equivalent:

assign out = ~a;

다중 입력 (Multiple Inputs)

AND 및 OR 게이트는 2개 이상의 입력을 가질 수 있습니다:

and(out, a, b, c);     // 3입력 AND (out = a & b & c)
or(out, x, y, z, w);   // 4입력 OR

NOT 게이트는 항상 정확히 1개의 입력만을 가집니다.

코드 예제

module and_or_not (
  input a, b,
  output and_out,
  output or_out,
  output not_out
);
  and(and_out, a, b);   // AND 게이트
  or(or_out, a, b);     // OR 게이트
  not(not_out, a);      // NOT 게이트 (인버터)
endmodule
challenge icon

챌린지

과제 설명에 따라 누락된 게이트 프리미티브를 추가하세요.

수행할 작업:

  1. 출력이 and_result이고 입력이 pq인 AND 게이트를 생성하세요.
  2. 출력이 or_result이고 입력이 pq인 OR 게이트를 생성하세요.
  3. 출력이 not_result이고 입력이 p인 NOT 게이트를 생성하세요.

직접 해보기

module gates_challenge (
  input p,
  input q,
  output and_result,
  output or_result,
  output not_result
);
  
  // TODO: AND 게이트 추가 (and_result = p & q)
  
  // TODO: OR 게이트 추가 (or_result = p | q)
  
  // TODO: NOT 게이트 추가 (not_result = ~p)

endmodule
quiz icon실력 점검

이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.

기초의 모든 레슨