Built In Gate Primitives
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 39번째.
Verilog에는 실제 gate 기호를 사용하여 논리 회로를 설명할 수 있게 해 주는 기본 제공 gate primitive가 있습니다. 이를 structural 모델링이라고 합니다. 회로도를 그리는 것처럼 gate를 연결하여 회로를 구성합니다.
Gate primitive은 기본 논리 gates를 모델링하는 미리 정의된 키워드입니다. assign out = a & b와 같은 표현식을 작성하는 대신, gate를 인스턴스화합니다:
and(out, a, b); // 출력이 out이고 입력이 a와 b인 AND 게이트일반 구문
gate_type (output, input1, input2, ...);- 첫 번째 인수는 항상 output입니다
- 이후 인수는 inputs입니다 (gate에 따라 1개 이상)
사용 가능한 게이트 primitive
| 게이트 유형 | 키워드 | 입력 수 |
|---|---|---|
| AND | and | 2개 이상 |
| OR | or | 2개 이상 |
| NOT | not | 1개 |
| NAND | nand | 2개 이상 |
| NOR | nor | 2개 이상 |
| XOR | xor | 2개 이상 |
| XNOR | xnor | 2개 이상 |
Gate 프리미티브의 작동 방식
and(out, a, b)를 작성하면 Verilog는 a & b의 result로 out을 continuous하게 구동하는 AND gate를 생성합니다. a 또는 b가 변경될 때마다 실제 gate와 마찬가지로 out이 즉시 업데이트됩니다.
게이트 프리미티브와 연속 할당 비교
두 방법 모두 동일한 하드웨어를 생성합니다:
// 게이트 프리미티브
and(out, a, b);
// 연속 할당 (동일한 결과)
assign out = a & b;Gate primitive은 회로를 gates의 모음(structural 스타일)으로 설명하고 싶을 때 유용합니다. Continuous assignment은 behavioral 스타일(표현식)에 더 적합합니다.
챌린지
해야 할 일:
- 이 회로가 작동하도록 올바른 gate primitive를 Add하세요. module은 inputs
a와b의 AND를 output해야 합니다. output port의 이름은 이미c입니다.
직접 해보기
module gate_challenge (
input a,
input b,
output c
);
// TODO: 올바른 게이트 프리미티브를 추가하세요
// 출력 c는 a AND b여야 합니다
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 컴파일러