4 Bit Counter
Parte de la sección Fundamentos del Journey de Verilog de Coddy. Lección 84 de 90.
Desafío
Construye un contador de 4 bits que cuente de 0 a 15 y vuelva a 0.
Interfaz del módulo
| Puerto | Dirección | Ancho | Descripción |
|---|---|---|---|
clk | input | 1 bit | Señal de reloj |
reset | input | 1 bit | Restablecer el contador a 0 |
count | output | 4 bits | Valor actual del contador |
Tabla de verdad
| Ciclo de reloj | count |
|---|---|
| Después de reset | 0 |
| 1 | 1 |
| 2 | 2 |
| ... | ... |
| 15 | 15 |
| 16 | 0 (vuelve al inicio) |
Tu tarea es completar el módulo siguiente.
Qué hacer:
- En
reset, establececounten 0 - En cada flanco ascendente del reloj, incrementa
counten 1 - Cuando
countalcance 15, el siguiente incremento debe volver a 0
Pruébalo tú mismo
module counter (
input clk,
input reset,
output reg [3:0] count
);
// TODO: Añade un bloque always con posedge clk y posedge reset
// En reset: count <= 0
// De lo contrario: count <= count + 1
endmoduleTodas las lecciones de Fundamentos
1Introducción
Qué es VerilogHardware frente a softwareTu primer móduloComentariosNiveles de abstracción del diseño4Operators 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 LogicPractica por tu cuenta: Compilador de Verilog online