Recap - Simple Comparator
CoddyのVerilogジャーニー「基礎」セクションの一部。レッスン 54/90。
チャレンジ
2ビット比較器は、2つの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オンラインコンパイラ