this is my code for a fun Fire extinguishing system in a 50 unit apartment.this is fire_detection_system.v:
module fire_detection_system (
input wire clk, // Clock signal
input wire reset, // Reset signal
input wire [49:0] smoke_detectors, // Smoke sensor signal
input wire [4:0] floor_buttons, // Buttons on each floor
input wire janitor_button, // Janitor button
output wire [49:0] sprinkler_activate // Sprinkler activation signal
);
reg [5:0] timer; // 6-bit timer for 60-second delay
reg [1:0] state; // State machine: 00 (idle), 01 (waiting), 10 (active)
assign sprinkler_activate = (state == 2'b10) ? smoke_detectors : 50'b0; // Activate sprinklers in active state
always @(posedge clk or posedge reset) begin
if (reset) begin
timer <= 0;
state <= 2'b00; // Initialize to idle state
end else begin
case (state)
2'b00: // Idle state
if (smoke_detectors != 50'b0) begin
state <= 2'b01; // Transition to waiting state
timer <= 60; // Set timer to 60 seconds
end
2'b01: // Waiting state
if (timer > 0) begin // Decrement timer
timer <= timer - 1;
end else begin
state <= 2'b10; // Transition to active state
end
2'b10: // Active state
if (floor_buttons != 5'b0 || janitor_button) begin
state <= 2'b00; // Reset to idle state on button press
end
endcase
end
end
endmodule
and this is my fire_detection_system_tb.v:
module fire_detection_system_tb;
// Inputs
reg clk;
reg reset;
reg [49:0] smoke_detectors;
reg [4:0] floor_buttons;
reg janitor_button;
// Outputs
wire [49:0] sprinkler_activate;
// Instantiate the fire detection system
fire_detection_system dut (
.clk(clk),
.reset(reset),
.smoke_detectors(smoke_detectors),
.floor_buttons(floor_buttons),
.janitor_button(janitor_button),
.sprinkler_activate(sprinkler_activate)
);
// Clock generation
always begin
#5 clk = ~clk;
end
initial begin
// Initialize inputs
clk = 0;
reset = 1;
smoke_detectors = 50'b0;
floor_buttons = 5'b0;
janitor_button = 0;
#10; // Wait for reset to settle
// Test cases
smoke_detectors = 50'b0;
floor_buttons = 5'b0;
janitor_button = 0;
#60; // Wait for timer to expire
smoke_detectors = 50'b1;
floor_buttons = 5'b0;
janitor_button = 0;
#60; // Wait for timer to expire and sprinklers to activate
smoke_detectors = 50'b1;
floor_buttons = 5'b1;
janitor_button = 0;
#1; // Wait for button press to be detected
smoke_detectors = 50'b0;
floor_buttons = 0;
janitor_button = 1;
#60; // Wait for timer to expire and sprinklers to deactivate
$finish;
end
endmodule
i want to show the signal that i have been used inside initial box on modelsim scope, but modelsim doesn't recognize any wave signal in this file. and the files have been compilled correctly without errors.simulation layout
