Guest User

Untitled

a guest
Nov 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. `timescale 1ns / 1ps
  2.  
  3. module flash_suppressor(
  4. input youre_not_the_boss_of_me_in,
  5. input sw0_in,
  6. output[3:0] lights,
  7. output glitch_out
  8. );
  9.  
  10. reg [31:0] glitch_status = 32'b0;
  11. reg [31:0] ctr = 32'b0;
  12. reg glitch_r = 1'b0;
  13.  
  14. assign lights[2:0] = 3'b111;
  15. assign lights[3] = glitch_r;
  16. assign glitch_out = glitch_r;
  17.  
  18. always @(posedge youre_not_the_boss_of_me_in)
  19. begin
  20. if (sw0_in == 1)
  21. begin
  22. glitch_r <= 1'b0;
  23. ctr <= 0;
  24. end
  25. else
  26. begin
  27. ctr <= ctr + 1;
  28. if (ctr == 3'b100)
  29. begin
  30. ctr <= 0;
  31. glitch_status <= 2'b10;
  32. end
  33. if (glitch_status > 0) begin
  34. glitch_r <= 1'b1;
  35. glitch_status <= glitch_status - 1;
  36. end else begin
  37. glitch_r <= 1'b0;
  38. end
  39. end
  40. end
  41. endmodule
Add Comment
Please, Sign In to add comment