Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constant COUNT_MAX : integer := 3;
- --set it '1' if the button creates a high pulse when its pressed, otherwise '0'.
- constant BTN_ACTIVE : std_logic := '1';
- signal count : integer := 0;
- signal count2 : integer := 0;
- type state_type is (idle,wait_time); --state machine
- signal state : state_type := idle;
- begin
- process(Reset,Clk)
- begin
- if(Reset = '1') then
- state <= idle;
- pulse_out <= '0';
- elsif(rising_edge(Clk)) then
- case (state) is
- when idle =>
- if(but_in = BTN_ACTIVE) then
- state <= wait_time;
- else
- state <= idle;
- if(count2 = COUNT_MAX) then
- count2 <= 0;
- pulse_out<='0';
- else
- count2<=count2+1;
- end if;
- end if;
- when wait_time =>
- if(count = COUNT_MAX) then
- count <= 0;
- if(but_in = BTN_ACTIVE) then
- pulse_out <= '1';
- else
- pulse_out <= '0';
- end if;
- count2<=0;
- state <= idle;
- else
- count <= count + 1;
- end if;
- end case;
- end if;
- end process;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement