Recap - Always vs Initial
Part of the Fundamentals section of Coddy's Verilog journey. Lesson 51 of 90.
Challenge
Always vs Initial
Complete both blocks to make this counter work correctly.
What to do:
- The
initialblock should initializecountto 0 at time 0 - The
alwaysblock should incrementcountby 1 on each rising clock edge
Try it yourself
module counter;
reg clk;
reg [3:0] count;
// Clock generator (already given)
always #5 clk = ~clk;
// TODO: Add initial block to set count = 0
// TODO: Add always block to increment count on posedge clk
endmoduleAll lessons in Fundamentals
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 LogicPractice on your own: Online Verilog compiler