Guest User

Untitled

a guest
Jul 18th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // 5555 NE Moore Court
  2. // Hillsboro, OR 97214
  3. // U.S.A
  4. //
  5. // TEL: 1-800-Lattice (USA and Canada)
  6. // 503-268-8001 (other locations)
  7. //
  8. // web: http://www.latticesemi.com/
  9. // --------------------------------------------------------------------
  10. //
  11. // Revision History :
  12.  
  13. module LED_Rotation(
  14. input clk,
  15. output LED1,
  16. output LED2,
  17. output LED3,
  18. output LED4,
  19. output LED5
  20. );
  21.  
  22. reg[15:0] div_cntr1;
  23. reg[6:0] div_cntr2;
  24. reg[1:0] dec_cntr;
  25. reg half_sec_pulse;
  26.  
  27. always@(posedge clk)
  28. begin
  29. div_cntr1 <= div_cntr1 + 1;
  30. if (div_cntr1 == 0)
  31. if (div_cntr2 == 91)
  32. begin
  33. div_cntr2 <= 0;
  34. half_sec_pulse <= 1;
  35. end
  36. else
  37. div_cntr2 <= div_cntr2 + 1;
  38. else
  39. half_sec_pulse <= 0;
  40.  
  41. if (half_sec_pulse == 1)
  42. dec_cntr <= dec_cntr + 1;
  43.  
  44. end
  45.  
  46.  
  47. assign LED1 = (dec_cntr == 0) ;
  48. assign LED2 = (dec_cntr == 1) ;
  49. assign LED3 = (dec_cntr == 2) ;
  50. assign LED4 = (dec_cntr == 3) ;
  51. assign LED5 = 1'b1;
  52.  
  53. endmodule
Advertisement
Add Comment
Please, Sign In to add comment