Recap - Full Testbench
Parte de la sección Fundamentos del Journey de Verilog de Coddy. Lección 78 de 90.
Desafío
Este desafío pone a prueba todo lo que has aprendido sobre testbench: stimulus, display, monitor, dumpfile, dumpvars y las tareas del sistema. Se te proporciona un módulo de compuerta XOR para probar.
Qué hacer:
Crea un testbench completo que:
- Declare señales (
regpara las entradas,wirepara la salida) - Instancie la compuerta XOR con el nombre
dut - Cree un archivo de formas de onda llamado
xor_waveform.vcd - Vuelque todas las señales del testbench
- Imprima un encabezado: "Testing XOR Gate"
- Use
$monitorpara realizar el seguimiento de time, x, y y z - Pruebe las cuatro combinaciones de entrada (00, 01, 10, 11) con un retardo
#10entre cada una - Imprima "Test complete" al final
- Finalice la simulación con
$finish
Pruébalo tú mismo
module xor_gate (
input x,
input y,
output z
);
assign z = x ^ y;
endmodule
module testbench;
// TODO: Declara reg para x e y
// TODO: Declara wire para z
// TODO: Instancia xor_gate con el nombre dut
// Conecta .x(x), .y(y), .z(z)
initial begin
// TODO: Añade $dumpfile "xor_waveform.vcd"
// TODO: Añade $dumpvars (0, testbench)
// TODO: Añade $display "Testing XOR Gate"
// TODO: Añade $monitor para time, x, y, z
// Formato: "Time %0t: x=%b, y=%b, z=%b"
// TODO: Añade estímulo para las cuatro combinaciones
// 00, 01, 10, 11 con retardo #10
// TODO: Añade $display "Test complete"
// TODO: Añade $finish
end
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 Challenge14Testbench Basics
What Is A TestbenchCreating StimulusDisplay And MonitorDumpfile And DumpvarsUsing System TasksRecap - Full Testbench3Number 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