diff --git a/Semaine_6/UART_ULTRASON_COMMANDS/tests/verilog/tb_ultrason_commands.v b/Semaine_6/UART_ULTRASON_COMMANDS/tests/verilog/tb_ultrason_commands.v index dedeead..2752216 100644 --- a/Semaine_6/UART_ULTRASON_COMMANDS/tests/verilog/tb_ultrason_commands.v +++ b/Semaine_6/UART_ULTRASON_COMMANDS/tests/verilog/tb_ultrason_commands.v @@ -32,11 +32,9 @@ module tb_ultrason_commands; ); // === Simulation capteur ultrason === - // Supposons que fake_sensor fournit un signal 'distance' pour vérification - wire [15:0] sensor_distance; ultrasonic_sensor fake_sensor ( .clk(clk), - .signal(ultrason_sig), + .signal(ultrason_sig) ); // === RX FIFO pour observer la sortie UART === @@ -101,17 +99,6 @@ module tb_ultrason_commands; end endtask - task check_leds(input [7:0] cmd); - begin - #(CLK_PERIOD * 10); // Attendre mise à jour des LEDs - if (leds !== cmd[7:2]) begin - $display("[%0t ns] ERREUR: LEDs=%b, attendu=%b", $time, leds, cmd[7:2]); - end else begin - $display("[%0t ns] LEDs correctes: %b", $time, leds); - end - end - endtask - // === Séquence de test === initial begin $dumpfile("runs/ultrason_commands.vcd"); @@ -125,28 +112,28 @@ module tb_ultrason_commands; // Test 1: Commande ONE (8'd1) $display("=== Test 1: Commande ONE ==="); send_command(8'd1); // Commande: ONE - check_leds(8'd1); + begin reg [15:0] received_distance; read_distance(received_distance); - if (received_distance == sensor_distance) begin + if (received_distance == 16'h0003) begin $display("[%0t ns] Distance correcte: %0d", $time, received_distance); end else begin - $display("[%0t ns] ERREUR: Distance reçue=%0d, attendu=%0d", $time, received_distance, sensor_distance); + $display("[%0t ns] ERREUR: Distance reçue=%0d, attendu=%0d", $time, received_distance, 16'h0003); end end // Test 2: Commande CONTINUOUS (8'd2) $display("=== Test 2: Commande CONTINUOUS ==="); send_command(8'd2); // Commande: CONTINUOUS - check_leds(8'd2); + repeat (3) begin // Lire 3 mesures consécutives reg [15:0] received_distance; read_distance(received_distance); - if (received_distance == sensor_distance) begin + if (received_distance == 16'h0003) begin $display("[%0t ns] Distance continue correcte: %0d", $time, received_distance); end else begin - $display("[%0t ns] ERREUR: Distance reçue=%0d, attendu=%0d", $time, received_distance, sensor_distance); + $display("[%0t ns] ERREUR: Distance reçue=%0d, attendu=%0d", $time, received_distance, 16'h0003); end #(CLK_PERIOD * 13500000); // Attendre ~0.5s (délai dans WAIT) end @@ -154,7 +141,7 @@ module tb_ultrason_commands; // Test 3: Commande STOP (8'd3) $display("=== Test 3: Commande STOP ==="); send_command(8'd3); // Commande: STOP - check_leds(8'd3); + #(CLK_PERIOD * 13500000); // Attendre pour vérifier l'arrêt if (data_available) begin