Reg Type
CoddyのVerilogジャーニー「基礎」セクションの一部。レッスン 7/90。
Reg は Verilog における 2 つ目の主要なデータ型です。wire とは異なり、reg は値を格納します値を保持する変数です。
regは値を格納できますregはalwaysブロックで使用されますregはハードウェアにおける「レジスタ」を意味しません。単に「記憶領域」を意味します
reg の宣言
reg x; // 単一ビットの reg
reg y, z; // 1行に複数の regreg の仕組み
module reg_example;
reg x;
initial begin
x = 0; // x が 0 になる
$display("x = %d", x); // 表示: x = 0
x = 1; // x が 1 になる
$display("x = %d", x); // 表示: x = 1
end
endmoduleチャレンジ
行うこと:
-
countという名前のregを追加する
自分で試してみよう
module counter(
input clk,
input reset,
output out // デフォルトで wire(reg を削除)
);
// ここに reg count を宣言
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オンラインコンパイラ