Created
November 17, 2017 10:23
-
-
Save CreateRemoteThread/628533b95e90b612bd42a738253d834e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`timescale 1ns / 1ps | |
module flash_suppressor( | |
input youre_not_the_boss_of_me_in, | |
input sw0_in, | |
output[3:0] lights, | |
output glitch_out | |
); | |
reg [31:0] glitch_status = 32'b0; | |
reg [31:0] ctr = 32'b0; | |
reg glitch_r = 1'b0; | |
assign lights[2:0] = 3'b111; | |
assign lights[3] = glitch_r; | |
assign glitch_out = glitch_r; | |
always @(posedge youre_not_the_boss_of_me_in) | |
begin | |
if (sw0_in == 1) | |
begin | |
glitch_r <= 1'b0; | |
ctr <= 0; | |
end | |
else | |
begin | |
ctr <= ctr + 1; | |
if (ctr == 3'b100) | |
begin | |
ctr <= 0; | |
glitch_status <= 2'b10; | |
end | |
if (glitch_status > 0) begin | |
glitch_r <= 1'b1; | |
glitch_status <= glitch_status - 1; | |
end else begin | |
glitch_r <= 1'b0; | |
end | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment