Last active
December 28, 2015 22:39
-
-
Save Atlantic777/7573307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------------------------- | |
-- Company: | |
-- Engineer: | |
-- | |
-- Create Date: 23:20:28 11/20/2013 | |
-- Design Name: | |
-- Module Name: stop_3 - Behavioral | |
-- Project Name: | |
-- Target Devices: | |
-- Tool versions: | |
-- Description: | |
-- | |
-- Dependencies: | |
-- | |
-- Revision: | |
-- Revision 0.01 - File Created | |
-- Additional Comments: | |
-- | |
---------------------------------------------------------------------------------- | |
library IEEE; | |
use IEEE.STD_LOGIC_1164.ALL; | |
-- Uncomment the following library declaration if using | |
-- arithmetic functions with Signed or Unsigned values | |
--use IEEE.NUMERIC_STD.ALL; | |
use IEEE.STD_LOGIC_UNSIGNED.ALL; | |
-- Uncomment the following library declaration if instantiating | |
-- any Xilinx primitives in this code. | |
--library UNISIM; | |
--use UNISIM.VComponents.all; | |
entity stop_3 is | |
Port ( iCLK : in STD_LOGIC; | |
iSTART : in STD_LOGIC; | |
iSTOP : in STD_LOGIC; | |
iCONTINUE : in STD_LOGIC; | |
iRESET : in STD_LOGIC; | |
oSECONDS : out STD_LOGIC_VECTOR (7 downto 0)); | |
end stop_3; | |
architecture Behavioral of stop_3 is | |
signal sSTATE : STD_LOGIC_VECTOR (1 downto 0); | |
signal sSECONDS : STD_LOGIC_VECTOR (7 downto 0); | |
signal sPRESCALER : STD_LOGIC_VECTOR (7 downto 0); | |
signal sPRESCALER_OUT : STD_LOGIC; | |
begin | |
process(iCLK) begin | |
if(iCLK'event and iCLK = '1') then | |
if (iRESET = '0' ) then sSTATE <= "00"; | |
elsif (iSTOP = '0' ) then sSTATE <= "01"; | |
elsif (iSTART = '0' ) then sSTATE <= "10"; | |
elsif (iCONTINUE = '0' ) then sSTATE <= "11"; | |
elsif (sSTATE = "10" ) then sSTATE <= "11"; | |
end if; | |
end if; | |
end process; | |
process(iCLK) begin | |
if(iCLK'event and iCLK = '1') then | |
if (sSTATE(0) = '0') then sPRESCALER <= (others => '0'); | |
elsif (sSTATE(1) = '1') then | |
if(sPRESCALER = "00010111") then | |
sPRESCALER <= (others => '0'); | |
sPRESCALER_OUT <= '1'; | |
else | |
sPRESCALER_OUT <= '0'; | |
sPRESCALER <= sPRESCALER + 1; | |
end if; | |
end if; | |
end if; | |
end process; | |
process(iCLK) begin | |
if(iCLK'event and iCLK = '1') then | |
if(sSTATE(0) = '0') then | |
sSECONDS <= (others => '0'); | |
elsif (sPRESCALER_OUT = '1') then | |
sSECONDS <= sSECONDS + 1; | |
end if; | |
end if; | |
end process; | |
oSECONDS <= sSECONDS; | |
end Behavioral; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment