Files
SystemVerilog-Learning/seq_detector_1011/tb_seq_detector_1011.sv
T
2026-11-29 10:34:26 +01:00

57 lines
1.3 KiB
Systemverilog

`timescale 1ns / 1ps
module tb_seq_detector_1011;
logic clk;
logic rst;
logic in;
logic detected;
seq_detector_1011 dut(
.clk(clk),
.rst(rst),
.in(in),
.detected(detected)
);
initial begin
clk = 1'b0;
forever #5 clk = ~clk;
end
initial begin
$dumpfile("seq_detector_1011.vcd");
$dumpvars(0, tb_seq_detector_1011);
rst = 1'b1;
in = 1'b0;
// detected = 1'b0; inutile output
#20;
@(posedge clk);
rst <= 1'b0;
in <= 1'b1; @(posedge clk); // Bit 1
in <= 1'b0; @(posedge clk); // Bit 0
in <= 1'b1; @(posedge clk); // Bit 1
in <= 1'b1; @(posedge clk); // Bit 1 -> détection #1 attendue au cycle suivant
in <= 1'b0; @(posedge clk); // Bit 0
in <= 1'b1; @(posedge clk); // Bit 1
in <= 1'b1; @(posedge clk); // Bit 1 -> détection #2 (chevauchement)
in <= 1'b0; @(posedge clk); // Bit 0
in <= 1'b1; @(posedge clk); // Bit 1
in <= 1'b0; @(posedge clk); // Bit 0
in <= 1'b1; @(posedge clk); // Bit 1
in <= 1'b1; @(posedge clk); // Bit 1 -> détection #3 (chevauchement 101011)
in <= 1'b0;
repeat (2) @(posedge clk); // Laisse 2 cycles pour voir la dernière détection retomber
$display("Fin de la simulation.");
$finish;
end;
endmodule