Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity test8 is
  5. Port ( CLK : in STD_LOGIC;
  6. TRIGGER : in STD_LOGIC;
  7. LED14 : out STD_LOGIC;
  8. LED23 : out STD_LOGIC;
  9. G14 : out STD_LOGIC;
  10. G23 : out STD_LOGIC);
  11. end test8;
  12.  
  13. architecture Behavioral of test8 is
  14.  
  15. signal count14 : integer range 0 to 49999999 := 0;
  16. signal pulse14 : std_logic := '0';
  17. signal count23 : integer range 0 to 49999999 := 0;
  18. signal pulse23 : std_logic := '0';
  19. signal enable : std_logic := '0';
  20.  
  21. constant onticks : integer := 13234; --square wave on time
  22. constant deadticks : integer := 1470;--0; -- square wave off time
  23. constant stopticks : integer := 500000; --corresponds to length of RMP signal
  24. signal x : integer range 0 to 100000000 := 0;
  25. signal y : integer range 0 to 50000000 := 0;
  26.  
  27. begin
  28.  
  29. pulsetimer : process(TRIGGER, CLK) --counts wave on-time from start of trigger
  30. begin
  31. if rising_edge(CLK) then
  32. if TRIGGER = '1' then --trigger must be high at least length of pulse
  33. if x = stopticks then
  34. enable <= '0';
  35. else
  36. enable <= '1';
  37. x <= x + 1;
  38. end if;
  39. else
  40. enable <= '0';
  41. x <= 0;
  42. end if;
  43. end if;
  44. end process;
  45.  
  46.  
  47. waveform : process(CLK)
  48. begin
  49. if rising_edge(CLK) then
  50. if enable = '1' then
  51. if pulse14 ='1' then
  52. if count14 = onticks then
  53. count14 <= 0;
  54. pulse14 <= '0';
  55. else
  56. count14 <= count14+1;
  57. end if;
  58. end if;
  59. if pulse14 ='0' then
  60. if count14 = (deadticks*2 + onticks) then
  61. count14 <= 0;
  62. pulse14 <= '1';
  63. else
  64. count14 <= count14+1;
  65. end if;
  66. end if;
  67.  
  68. if y = (deadticks + onticks) then
  69. if pulse23 ='1' then
  70. if count23 = onticks then
  71. count23 <= 0;
  72. pulse23 <= '0';
  73. else
  74. count23 <= count23+1;
  75. end if;
  76. end if;
  77. if pulse23 ='0' then
  78. if count23 = (deadticks*2 + onticks) then
  79. count23 <= 0;
  80. pulse23 <= '1';
  81. else
  82. count23 <= count23+1;
  83. end if;
  84. end if;
  85. else
  86. y <= y + 1;
  87. end if;
  88. else
  89. pulse14 <= '0';
  90. pulse23 <= '0';
  91. y <= 0;
  92. end if;
  93. end if;
  94. end process;
  95.  
  96. G14 <= pulse14;
  97. G23 <= pulse23;
  98.  
  99. LED14 <= pulse14;
  100. LED23 <= pulse23;
  101. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement