0% found this document useful (0 votes)
4 views3 pages

Vehicle Safety System Scenarios Module

The document describes a Verilog module for a vehicle-to-vehicle (V2V) system that detects various driving scenarios based on speed and distance inputs. It includes logic for activating scenarios such as speed difference, distance warning, emergency braking, and traffic jam detection, along with corresponding outputs like buzzer and brake. The module also features a timer for auto-clearing scenario 1 after a specified duration.

Uploaded by

ganesheart1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Vehicle Safety System Scenarios Module

The document describes a Verilog module for a vehicle-to-vehicle (V2V) system that detects various driving scenarios based on speed and distance inputs. It includes logic for activating scenarios such as speed difference, distance warning, emergency braking, and traffic jam detection, along with corresponding outputs like buzzer and brake. The module also features a timer for auto-clearing scenario 1 after a specified duration.

Uploaded by

ganesheart1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

module v2v_system (

input clk, rst,

input [7:0] my_speed,

input [7:0] front_speed,

input [7:0] distance,

input scenario2_enable,

input scenario3_enable,

input system_enable,

output reg scenario1_active,

output reg scenario2_active,

output reg scenario3_active,

output reg scenario4_active,

output reg buzzer,

output reg brake,

output reg [3:0] warning_display

);

// Timer for scenario 1 auto-clear

reg [27:0] timer;

reg timer_running;

// Scenario detection

always @(*) begin

// Scenario 1 - Speed Difference

if ((my_speed > front_speed) &&

((my_speed - front_speed) > 8'd10) &&

(distance > 8'd20) && system_enable)

scenario1_active = 1'b1;

else

scenario1_active = 1'b0;
// Scenario 2 - Distance Warning

if ((distance < 8'd20) && scenario2_enable && system_enable)

scenario2_active = 1'b1;

else

scenario2_active = 1'b0;

// Scenario 3 - Emergency Braking

if ((distance < 8'd10) && (my_speed > front_speed) && scenario3_enable && system_enable)

scenario3_active = 1'b1;

else

scenario3_active = 1'b0;

// Scenario 4 - Traffic Jam / Low Speed

if ((my_speed < 8'd10) && (front_speed < 8'd10) && (distance < 8'd5) && system_enable)

scenario4_active = 1'b1;

else

scenario4_active = 1'b0;

end

// Timer logic for scenario1 auto-clear

always @(posedge clk or posedge rst) begin

if (rst) begin

timer <= 0;

timer_running <= 0;

end else begin

if (scenario1_active) begin

timer_running <= 1;

timer <= 0;

end else if (timer_running) begin

if (timer < 28'd500000000)


timer <= timer + 1;

else

timer_running <= 0;

end

end

end

// Outputs

always @(*) begin

buzzer = 0;

brake = 0;

warning_display = 4'b0000;

if (scenario1_active || timer_running)

warning_display = 4'b0001; // Scenario1

if (scenario2_active) begin

buzzer = 1;

warning_display = 4'b0010; // Scenario2

end

if (scenario3_active) begin

buzzer = 1;

brake = 1;

warning_display = 4'b0011; // Scenario3

end

if (scenario4_active) begin

warning_display = 4'b0100; // Scenario4 (traffic jam)

end

end

endmodule

You might also like