Recap - Simple Comparator
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 54번째.
챌린지
2비트 비교기는 두 2비트 이진수를 비교하여 한 수가 다른 수보다 큰지, 작은지 또는 같은지를 판별하는 회로입니다.
할 일:
if-else 문을 사용하여 2비트 비교기를 만드세요.
작동 방식:
a > b일 때greater는 1이어야 하고,less와equal은 0이어야 합니다.a < b일 때less는 1이어야 하고,greater와equal은 0이어야 합니다.a == b일 때equal은 1이어야 하고,greater와less는 0이어야 합니다.
직접 해보기
module comparator (
input [1:0] a,
input [1:0] b,
output reg greater,
output reg less,
output reg equal
);
always @(*) begin
// TODO: a와 b를 비교하기 위한 if-else 문을 추가하세요
// a > b이면 greater = 1로 설정
// a < b이면 less = 1로 설정
// a == b이면 equal = 1로 설정
end
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 컴파일러