コメント
CoddyのVerilogジャーニー「基礎」セクションの一部。レッスン 4/90。
Comments は、computer が無視するコード内のメモです。コードが何をするのかを説明するのに役立ちます。
Comments の 2 種類:
1. 1行の comment
// これは単一行のコメントです
assign c = a & b; // コメントはコードの後にも置けます// の後にあるすべては、computer によって ignored されます。
2. 複数行コメント
/* これは複数行のコメントです
複数の行にまたがることができます
長い説明に役立ちます */
assign c = a & b;/* と */ の間にあるすべてが ignored になります。
コメントを使う理由
- Module の動作を説明する
- 各 input と output の用途を説明する
- コードを理解しやすくする
- 自分や他の人のためにメモを残す
チャレンジ
このチャレンジでは、既存のmoduleにcommentsを追加する必要があります。
実行すること:
moduleの動作を説明するsingle-line commentを先頭に追加します
// This is a module called 'test'counterの動作を説明するmulti-line commentをコードの末尾に追加します
/** It has a clock input, a reset input,* and a 4-bit output called count.* The initial block prints a message* to show that comments are ignored.*/
自分で試してみよう
module test(
input clk,
input reset,
output reg [3:0] count
);
initial $display("Comments are ignored by the computer");
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オンラインコンパイラ