AND OR NOT Gates
CoddyのVerilogジャーニー「基礎」セクションの一部。レッスン 40/90。
このレッスンでは、最も基本的な3つの論理ゲート、AND、OR、NOTについて説明します。これらのゲートは、デジタル論理設計の基礎を形成します。
ANDゲート
ANDゲートは、すべての入力が1の場合にのみ1を出力します。
真理値表(2入力):
| a | b | out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Verilog ゲートプリミティブ:
and(out, a, b);連続代入の同等表現:
assign out = a & b;ORゲート
ORゲートは、少なくとも1つの入力が1のとき、1を出力します。
真理値表(2入力):
| a | b | out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Verilog ゲートプリミティブ:
or(out, a, b);連続代入と同等の記述:
assign out = a | b;NOTゲート
NOTゲートは、単一の入力の反対を出力します。inverterとも呼ばれます。
真理値表:
| a | out |
|---|---|
| 0 | 1 |
| 1 | 0 |
Verilog ゲートプリミティブ:
not(out, a);連続代入に相当する記述:
assign out = ~a;複数の入力
AND ゲートと OR ゲートには、2つを超える入力を指定できます:
and(out, a, b, c); // 3入力AND (out = a & b & c)
or(out, x, y, z, w); // 4入力ORNOT ゲートの入力は常にちょうど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チャレンジ
タスクに基づいて、不足しているゲートプリミティブを追加してください。
実行内容:
- 出力が
and_resultで、入力がpとqの AND ゲートを作成する - 出力が
or_resultで、入力がpとqの OR ゲートを作成する - 出力が
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このレッスンには短いクイズがあります。レッスンを始めて解答し、進捗を記録しましょう。
基礎のすべてのレッスン
4Operators Part 1
Arithmetic OperatorsModulo OperatorComparison OperatorsRecap - Simple MathBitwise Operators7Assign And Gates
Continuous AssignmentAssign With OperatorsBuilt In Gate PrimitivesAND OR NOT GatesXOR XNOR GatesRecap - Logic Gate Circuit10Decision Making
If StatementIf - ElseRecap - Simple ComparatorCase StatementCasex And CasezRecap - ALU Design5Operators Part 2
Logical OperatorsReduction OperatorsShift OperatorsConcatenation OperatorConditional OperatorRecap - Operator Challenge3Number System
Binary RepresentationSized NumbersUnsized NumbersNegative NumbersSpecial Values X And ZRecap - Number Formats6Modules
Module StructureInput And Output PortsInout PortsModule InstantiationPort Mapping By NamePort Mapping By OrderRecap - Build A Module9Procedural Blocks
Always BlockInitial BlockSensitivity ListBlocking AssignmentNon Blocking AssignmentRecap - Always vs Initial15Traffic Light Controller
Defining The StatesState Machine Logic自分で練習してみよう: Verilogオンラインコンパイラ