4 Bit Counter
CoddyのVerilogジャーニー「基礎」セクションの一部。レッスン 84/90。
チャレンジ
0から15までカウントし、0に戻る4ビットカウンターを作成してください。
モジュールインターフェース
| ポート | 方向 | 幅 | 説明 |
|---|---|---|---|
clk | input | 1 bit | クロック信号 |
reset | input | 1 bit | カウンターを0にリセット |
count | output | 4 bits | 現在のカウンター値 |
真理値表
| クロックサイクル | count |
|---|---|
| リセット後 | 0 |
| 1 | 1 |
| 2 | 2 |
| ... | ... |
| 15 | 15 |
| 16 | 0(循環して戻る) |
以下のモジュールを完成させてください。
実行すること:
reset時に、countを0に設定する- クロックの立ち上がりエッジごとに、
countを1増加させる countが15に達したら、次の増加で0に戻るようにする
自分で試してみよう
module counter (
input clk,
input reset,
output reg [3:0] count
);
// TODO: posedge clk と posedge reset を持つ always ブロックを追加
// リセット時: count <= 0
// それ以外: count <= count + 1
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オンラインコンパイラ