Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------
- -- Entity: stopLightLogic
- -- Date: Jan 26, 2012
- -- Author:
- --
- -- Description
- --------------------------------------------------------------------------------
- library ieee;
- use ieee.std_logic_1164.all;
- entity stopLightLogic is
- port(
- clock : in std_logic;
- reset : in std_logic;
- lights1 : out std_logic_vector(2 downto 0); -- red yellow green
- lights2 : out std_logic_vector(2 downto 0); -- red yellow grean
- walk1 : out std_logic; -- walk symbol
- walk2 : out std_logic; -- walk symbol
- hand1 : out std_logic; -- flashing stop hand
- hand2 : out std_logic; -- flashing stop hand
- segs1 : out std_logic_vector(15 downto 0); -- walk countdown
- segs2 : out std_logic_vector(15 downto 0) -- walk countdown
- );
- end entity stopLightLogic;
- architecture arch of stopLightLogic is
- signal count : integer range 0 to 92;
- begin
- counter : process(clock, reset)
- begin
- if reset = '0' or count = 92 then
- count <= 0;
- elsif rising_edge(clock) then
- count <= count + 1;
- end if;
- end process;
- -- anything that runs when count changes
- process(count)
- begin
- -- handle the lights for direction 1
- if count = 0 then
- lights1 <= "011"; -- red (reset)
- elsif count < 30 then
- lights1 <= "110"; -- green
- elsif count < 45 then
- lights1 <= "101"; -- yellow
- else
- lights1 <= "011"; -- red
- end if;
- -- handle the lights for cross direction
- if count < 46 or count = 91 then
- lights2 <= "011"; -- red
- elsif count < 76 then
- lights2 <= "110"; -- green
- else
- lights2 <= "101"; -- yellow
- end if;
- -- pedestrian signals
- if count = 19 then
- segs1 <= "1001111110011111"; -- 11
- elsif count = 20 then
- segs1 <= "1001111100000011"; -- 10
- elsif count = 21 then
- segs1 <= "1111111100001001"; -- 9
- elsif count = 22 then
- segs1 <= "1111111100000001"; -- 8
- elsif count = 23 then
- segs1 <= "1111111100011111"; -- 7
- elsif count = 24 then
- segs1 <= "1111111111000001"; -- 6
- elsif count = 25 then
- segs1 <= "1111111101001001"; -- 5
- elsif count = 26 then
- segs1 <= "1111111110011001"; -- 4
- elsif count = 27 then
- segs1 <= "1111111100001101"; -- 3
- elsif count = 28 then
- segs1 <= "1111111100100101"; -- 2
- elsif count = 29 then
- segs1 <= "1111111110011111"; -- 1
- else
- segs1 <= "1111111111111111"; -- off
- end if;
- if count < 19 then
- hand1 <= '1';
- elsif count = 19 then
- hand1 <= '0';
- elsif count = 20 then
- hand1 <= '1';
- elsif count = 21 then
- hand1 <= '0';
- elsif count = 22 then
- hand1 <= '1';
- elsif count = 23 then
- hand1 <= '0';
- elsif count = 24 then
- hand1 <= '1';
- elsif count = 25 then
- hand1 <= '0';
- elsif count = 26 then
- hand1 <= '1';
- elsif count = 27 then
- hand1 <= '0';
- elsif count = 28 then
- hand1 <= '1';
- else
- hand1 <= '0';
- end if;
- -- pedestrian signals 2
- if count = 65 then
- segs2 <= "1001111110011111"; -- 11
- elsif count = 66 then
- segs2 <= "1001111100000011"; -- 10
- elsif count = 67 then
- segs2 <= "1111111100001001"; -- 9
- elsif count = 68 then
- segs2 <= "1111111100000001"; -- 8
- elsif count = 69 then
- segs2 <= "1111111100011111"; -- 7
- elsif count = 70 then
- segs2 <= "1111111111000001"; -- 6
- elsif count = 71 then
- segs2 <= "1111111101001001"; -- 5
- elsif count = 72 then
- segs2 <= "1111111110011001"; -- 4
- elsif count = 73 then
- segs2 <= "1111111100001101"; -- 3
- elsif count = 74 then
- segs2 <= "1111111100100101"; -- 2
- elsif count = 75 then
- segs2 <= "1111111110011111"; -- 1
- else
- segs2 <= "1111111111111111"; -- off
- end if;
- if count < 65 then
- hand2 <= '1';
- elsif count = 65 then
- hand2 <= '0';
- elsif count = 66 then
- hand2 <= '1';
- elsif count = 67 then
- hand2 <= '0';
- elsif count = 68 then
- hand2 <= '1';
- elsif count = 69 then
- hand2 <= '0';
- elsif count = 70 then
- hand2 <= '1';
- elsif count = 71 then
- hand2 <= '0';
- elsif count = 72 then
- hand2 <= '1';
- elsif count = 73 then
- hand2 <= '0';
- elsif count = 74 then
- hand2 <= '1';
- else
- hand1 <= '0';
- end if;
- end process;
- end architecture arch;
- -------------------------------------------------- timeline ------------------------------------------------------
- -- 0sec -> 30sec -> 45sec -> 46sec -> 76sec -> 91sec -> 92sec
- -- lights1 green yellow red red red red reset timer
- -- lights2 red red red green yellow red reset timer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement