1
0
forked from tanchou/Verilog

Refactor ultrasonic_fpga module: update distance output and state handling; add top_ultrason_uart module for integration with UART and ultrasonic sensor

This commit is contained in:
Gamenight77
2025-04-17 13:02:47 +02:00
parent 8c1b452487
commit 897f829e40
3 changed files with 64 additions and 9 deletions

View File

@@ -4,10 +4,9 @@ module ultrasonic_fpga #(
input wire clk,
input wire start,
inout wire sig, // Broche bidirectionnelle vers le capteur
output reg [15:0] distance // Distance mesurée en cm
output reg [15:0] distance, // Distance mesurée en cm
output reg [2:0] state
);
reg [2:0] state;
reg [15:0] trig_counter;
reg [31:0] echo_counter;
reg sig_out;
@@ -27,7 +26,7 @@ module ultrasonic_fpga #(
localparam integer TRIG_PULSE_CYCLES = CLK_FREQ / 100_000; // 10us pulse
localparam integer DIST_DIVISOR = (58 * CLK_FREQ) / 1_000_000; // pour conversion us -> cm
localparam integer MAX_CM = 370;
localparam integer MAX_CM = 350;
localparam integer TIMEOUT_CYCLES = (MAX_CM * 58 * CLK_FREQ) / 1_000_000;
localparam WAIT_NEXT_CYCLES = (CLK_FREQ / 1000) * 100; // 60 ms