Question: FSM Debouncer implementation on verilog. I get errors at 3 5 ns and 1 0 5 ns . Testbench is correct. Code I have tried:

FSM Debouncer implementation on verilog. I get errors at 35ns and 105ns. Testbench is correct. Code I have tried:
module Debounce (
input clk, b,// b is the bouncy pushbutton or switch
output reg s // debounced version of pushbutton, synchronized to clock
);
// State encoding
localparam [1:0]
WaitRise =2'b00,
SkipRise =2'b01,
WaitFall =2'b10,
SkipFall =2'b11;
reg [1:0] current_state, next_state;
// Synchronous state transition
always @(posedge clk) begin
current_state = next_state;
end
// Next-state logic and output logic
always @(*) begin
// Default values
next_state = current_state;
s =0; // Default output is 0
case (current_state)
WaitRise: begin
s =0; // Output is 0 in WaitRise
if (b) next_state = SkipRise; // Transition to SkipRise on b =1
end
SkipRise: begin
s =1; // Output is 1 in SkipRise
next_state = WaitFall; // Transition to WaitFall after one clock
end
WaitFall: begin
s =1; // Output remains 1 in WaitFall
if (!b) next_state = SkipFall; // Transition to SkipFall on b =0
end
SkipFall: begin
s =0; // Output is 0 in SkipFall
next_state = WaitRise; // Transition to WaitRise after one clock
end
default: begin
next_state = WaitRise; // Default state (fallback)
end
endcase
end
endmodule
FSM Debouncer implementation on verilog. I get

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!