Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- entity test8 is
- Port ( CLK : in STD_LOGIC;
- TRIGGER : in STD_LOGIC;
- LED14 : out STD_LOGIC;
- LED23 : out STD_LOGIC;
- G14 : out STD_LOGIC;
- G23 : out STD_LOGIC);
- end test8;
- architecture Behavioral of test8 is
- signal count14 : integer range 0 to 49999999 := 0;
- signal pulse14 : std_logic := '0';
- signal count23 : integer range 0 to 49999999 := 0;
- signal pulse23 : std_logic := '0';
- signal enable : std_logic := '0';
- constant onticks : integer := 13234; --square wave on time
- constant deadticks : integer := 1470;--0; -- square wave off time
- constant stopticks : integer := 500000; --corresponds to length of RMP signal
- signal x : integer range 0 to 100000000 := 0;
- signal y : integer range 0 to 50000000 := 0;
- begin
- pulsetimer : process(TRIGGER, CLK) --counts wave on-time from start of trigger
- begin
- if rising_edge(CLK) then
- if TRIGGER = '1' then --trigger must be high at least length of pulse
- if x = stopticks then
- enable <= '0';
- else
- enable <= '1';
- x <= x + 1;
- end if;
- else
- enable <= '0';
- x <= 0;
- end if;
- end if;
- end process;
- waveform : process(CLK)
- begin
- if rising_edge(CLK) then
- if enable = '1' then
- if pulse14 ='1' then
- if count14 = onticks then
- count14 <= 0;
- pulse14 <= '0';
- else
- count14 <= count14+1;
- end if;
- end if;
- if pulse14 ='0' then
- if count14 = (deadticks*2 + onticks) then
- count14 <= 0;
- pulse14 <= '1';
- else
- count14 <= count14+1;
- end if;
- end if;
- if y = (deadticks + onticks) then
- if pulse23 ='1' then
- if count23 = onticks then
- count23 <= 0;
- pulse23 <= '0';
- else
- count23 <= count23+1;
- end if;
- end if;
- if pulse23 ='0' then
- if count23 = (deadticks*2 + onticks) then
- count23 <= 0;
- pulse23 <= '1';
- else
- count23 <= count23+1;
- end if;
- end if;
- else
- y <= y + 1;
- end if;
- else
- pulse14 <= '0';
- pulse23 <= '0';
- y <= 0;
- end if;
- end if;
- end process;
- G14 <= pulse14;
- G23 <= pulse23;
- LED14 <= pulse14;
- LED23 <= pulse23;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement