traffic light vhdl

4
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; -- U!"##e$ $%e &"ll"'i( library )e!lara$i" i& usi( -- ari$%#e$i! &u!$i"s 'i$% Si(e) "r Usi(e) *alues --use IEEE.NU+ERIC_STD.ALL; -- U!"##e$ $%e &"ll"'i( library )e!lara$i" i& is$a$ia$i( -- ay ,ili ri#i$i*es i $%is !")e. --library UNISI+; --use UNISI+./C"# "e$s.all; e$i$y li(%$s is 0"r$ !l2 3 i STD_LOGIC; r 3 "u$ STD_LOGIC_/ECTOR )"'$" 5 ; ( 3 "u$ STD_LOGIC_/ECTOR )"'$" 5 ; y 3 "u$ STD_LOGIC_/ECTOR )"'$" 5 ; e) li(%$s; ar!%i$e!$ure 7e%a*i"ral "& li(%$s is s%are) *ariable !"u$13 i$e(er 38 5; si(al $es$!l23 s$)_l"(i! 38 959; s%are) *ariable !"u$3s$)_l"(i!_*e!$"r 4 )"'$" 5 38:55555:; be(i

Upload: michelle-brown

Post on 04-Oct-2015

3 views

Category:

Documents


0 download

DESCRIPTION

Traffic Light Control in VHDL

TRANSCRIPT

library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;-- Uncomment the following library declaration if using-- arithmetic functions with Signed or Unsigned values--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating-- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;

entity lights is Port ( clk : in STD_LOGIC; r : out STD_LOGIC_VECTOR (3 downto 0); g : out STD_LOGIC_VECTOR (3 downto 0); y : out STD_LOGIC_VECTOR (3 downto 0));end lights;

architecture Behavioral of lights isshared variable count1: integer := 0;signal testclk: std_logic := '0';shared variable count:std_logic_vector(4 downto 0):="00000";begin

clock: process(clk)beginif(rising_edge(clk)) thencount1 := count1 + 1; if(count1 = 500000) thentestclk r