4 Bit Counter
جزء من قسم الأساسيات في رحلة Verilog على Coddy. الدرس 84 من 90.
التحدي
أنشئ عدّادًا من 4 بتات يعدّ من 0 إلى 15 ثم يعود إلى 0.
واجهة الوحدة
| المنفذ | الاتجاه | العرض | الوصف |
|---|---|---|---|
clk | input | 1 بت | إشارة الساعة |
reset | input | 1 بت | إعادة counter إلى 0 |
count | output | 4 بتات | قيمة counter الحالية |
جدول الحقيقة
| دورة الساعة | count |
|---|---|
| بعد reset | 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: أضف كتلة always مع posedge clk و posedge reset
// عند reset: 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 عبر الإنترنت