Recap - Build A Module
Part of the Fundamentals section of Coddy's Verilog journey — lesson 36 of 90.
Challenge
This challenge combines everything you learned in this chapter. You will create a module from scratch and instantiate it.
What to do:
Part 1: Create a module called <strong>flipflop</strong> with:
- 1-bit input called
clk - 1-bit input called
d - 1-bit input called
reset - 1-bit output called
q(use reg, assigned in always block)
The module should work as follows:
- When
resetis 1,qbecomes 0 - Otherwise, on each clock edge,
qbecomesd
Part 2: Instantiate the <strong>flipflop</strong> module in the <strong>top</strong> module using port mapping by name
Connect the ports to the following signals:
- Port
clk→ signalclock - Port
d→ signaldata - Port
reset→ signalreset_signal - Port
q→ signalout
Try it yourself
// Part 1: Create the flipflop module
// TODO: Add ports
// TODO: Add always block with posedge clk and posedge reset
// If reset is 1, q <= 0
// Else q <= d
// Part 2: Top module with instantiation
module top (
input clock,
input data,
input reset_signal,
output out
);
// TODO: Instantiate flipflop with instance name ff1
// Use port mapping by name: .clk(clock), .d(data), .reset(reset_signal), .q(out)
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 Logic