Hey guys, I am learning the VHDL right now, I have stock on my lab project hopw u guys can help me. I am writting code for trafficlights. I got warning say that triggerten, triggerfive triggerone triggerthree are not always assigned.Storageed may needed... This is my frist programing class, Please help me, thanks.
library ieee;
use ieee.std_logic_1164.all;
entity AutoTrafficLight is
port(CLK0:in bit; Xut bit_vector (0 to 7));
attribute LOC: string;
attribute LOC of CLK0: signal is "P11";
attribute LOC of X: signal is "P2 P3 P4 P5 P6 P7 P8 P9";
signal Qs: bit_vector(0 to 3);
signal tensec: std_logic;
signal threesec: std_logic;
signal onesec: std_logic;
signal fivesec: std_logic;
signal triggerten: std_logic;
signal triggerthree: std_logic;
signal triggerone: std_logic;
signal triggerfive: std_logic;
signal tencount: integer;
signal threecount: integer;
signal fivecount: integer;
signal onecount: integer;
end entity AutoTrafficLight;
-- where x(0)=>Main Street Red, x(4)=>Side Street Red
-- x(1)=>Main Street Yellow, x(5)=>Side Street Yellow
-- x(2)=>Main Street Greed, x(6)=>Side Street Green
-- x(3)=>Main Street Turn, x(7)=>Side Street Turn
-- and A(2),A(1),A(0) are the state bits Q2,@1,Q0
-- attribute LOC is a method of setting the pins on the chip
-- remember active low outputs will turn on the LED
architecture AutoTrafficLightBehavior of AutoTrafficLight is
begin
--==========================
--10sec timer
Process(CLK0, triggerten)
variable tencount: integer range 0 to 80;
begin
if CLK0='0' and CLK0' event then
if (triggerten = '0') then
tencount := 0;
tensec <= '1';
elsif tencount = 80 then
tensec <= '0';
else
tencount := tencount + 1;
end if;
end if;
end process;
--===========================
--3sec timer
Process(CLK0, triggerthree)
variable threecount: integer range 0 to 24;
begin
if CLK0='0' and CLK0' event then
if triggerthree = '0' then
threecount := 0;
threesec <= '1';
elsif threecount = 24 then
threesec <= '0';
else
threecount := threecount + 1;
end if;
end if;
end process;
--==========================
--5sec timer
Process(CLK0, triggerfive)
variable fivecount: integer range 0 to 40;
begin
if CLK0='0' and CLK0' event then
if triggerfive = '0' then
fivecount := 0;
fivesec <= '1';
elsif fivecount = 40 then
fivesec <= '0';
else
fivecount := fivecount + 1;
end if;
end if;
end process;
--===========================
--1sec timer
Process(CLK0, triggerone)
variable onecount: integer range 0 to 8;
begin
if CLK0='0' and CLK0' event then
if triggerone = '0' then
onecount := 0;
onesec <= '1';
elsif onecount = 8 then
onesec <= '0';
else
onecount := onecount + 1;
end if;
end if;
end process;
--==========================
Process (CLK0,Qs)
begin
if CLK0='0' and CLK0' event then
case Qs is
when "0000"=>Qs<="0001"; -- MG,SR
when "0001"=>Qs<="0010"; -- MY,SR
when "0010"=>Qs<="0011"; -- MR,SR
when "0011"=>Qs<="0100"; -- MR,STG
when "0100"=>Qs<="0101"; -- MR,SG
when "0101"=>Qs<="0110"; -- MR,SY
when "0110"=>Qs<="0111"; -- MR,SR
when "0111"=>Qs<="1000"; -- MTG,SR
when others=>Qs<="0000";
end case;
end if;
end process;
process (Qs)
begin
if Qs="0000" then X <="11010111"; --MG,SR,10s
triggerten<='1';
triggerthree<='0';
triggerfive<='0';
triggerone<='0';
elsif Qs="0001" then X <="10110111"; --MY,SR,3s
triggerten<='0';
triggerthree<='1';
triggerfive<='0';
triggerone<='0';
elsif Qs="0010" then X <="01110111"; --MR,SR,1s
triggerten<='0';
triggerthree<='0';
triggerfive<='0';
triggerone<='1';
elsif Qs="0011" then X <="01111110"; --MR,STG,5s
triggerten<='0';
triggerthree<='0';
triggerfive<='1';
triggerone <='0';
elsif Qs="0100" then X <="01111101"; --MR,SG,10s
triggerten<='1';
triggerthree<='0';
triggerfive<='0';
triggerone <='0';
elsif Qs="0101" then X <="01111011"; --MR,SY,3s
triggerten<='0';
triggerthree<='1';
triggerfive<='0';
triggerone <='0';
elsif Qs="0110" then X <="01110111"; -- MR,SR,1s
triggerten<='0';
triggerthree<='0';
triggerfive<='0';
triggerone <='1';
elsif Qs="0111" then X <="11100111"; -- MTG,SR,5s
triggerten<='1';
triggerthree<='0';
triggerfive<='1';
triggerone <='0';
else x<="11010111";
end if;
end process;
end architecture AutoTrafficLightBehavior;
library ieee;
use ieee.std_logic_1164.all;
entity AutoTrafficLight is
port(CLK0:in bit; Xut bit_vector (0 to 7));
attribute LOC: string;
attribute LOC of CLK0: signal is "P11";
attribute LOC of X: signal is "P2 P3 P4 P5 P6 P7 P8 P9";
signal Qs: bit_vector(0 to 3);
signal tensec: std_logic;
signal threesec: std_logic;
signal onesec: std_logic;
signal fivesec: std_logic;
signal triggerten: std_logic;
signal triggerthree: std_logic;
signal triggerone: std_logic;
signal triggerfive: std_logic;
signal tencount: integer;
signal threecount: integer;
signal fivecount: integer;
signal onecount: integer;
end entity AutoTrafficLight;
-- where x(0)=>Main Street Red, x(4)=>Side Street Red
-- x(1)=>Main Street Yellow, x(5)=>Side Street Yellow
-- x(2)=>Main Street Greed, x(6)=>Side Street Green
-- x(3)=>Main Street Turn, x(7)=>Side Street Turn
-- and A(2),A(1),A(0) are the state bits Q2,@1,Q0
-- attribute LOC is a method of setting the pins on the chip
-- remember active low outputs will turn on the LED
architecture AutoTrafficLightBehavior of AutoTrafficLight is
begin
--==========================
--10sec timer
Process(CLK0, triggerten)
variable tencount: integer range 0 to 80;
begin
if CLK0='0' and CLK0' event then
if (triggerten = '0') then
tencount := 0;
tensec <= '1';
elsif tencount = 80 then
tensec <= '0';
else
tencount := tencount + 1;
end if;
end if;
end process;
--===========================
--3sec timer
Process(CLK0, triggerthree)
variable threecount: integer range 0 to 24;
begin
if CLK0='0' and CLK0' event then
if triggerthree = '0' then
threecount := 0;
threesec <= '1';
elsif threecount = 24 then
threesec <= '0';
else
threecount := threecount + 1;
end if;
end if;
end process;
--==========================
--5sec timer
Process(CLK0, triggerfive)
variable fivecount: integer range 0 to 40;
begin
if CLK0='0' and CLK0' event then
if triggerfive = '0' then
fivecount := 0;
fivesec <= '1';
elsif fivecount = 40 then
fivesec <= '0';
else
fivecount := fivecount + 1;
end if;
end if;
end process;
--===========================
--1sec timer
Process(CLK0, triggerone)
variable onecount: integer range 0 to 8;
begin
if CLK0='0' and CLK0' event then
if triggerone = '0' then
onecount := 0;
onesec <= '1';
elsif onecount = 8 then
onesec <= '0';
else
onecount := onecount + 1;
end if;
end if;
end process;
--==========================
Process (CLK0,Qs)
begin
if CLK0='0' and CLK0' event then
case Qs is
when "0000"=>Qs<="0001"; -- MG,SR
when "0001"=>Qs<="0010"; -- MY,SR
when "0010"=>Qs<="0011"; -- MR,SR
when "0011"=>Qs<="0100"; -- MR,STG
when "0100"=>Qs<="0101"; -- MR,SG
when "0101"=>Qs<="0110"; -- MR,SY
when "0110"=>Qs<="0111"; -- MR,SR
when "0111"=>Qs<="1000"; -- MTG,SR
when others=>Qs<="0000";
end case;
end if;
end process;
process (Qs)
begin
if Qs="0000" then X <="11010111"; --MG,SR,10s
triggerten<='1';
triggerthree<='0';
triggerfive<='0';
triggerone<='0';
elsif Qs="0001" then X <="10110111"; --MY,SR,3s
triggerten<='0';
triggerthree<='1';
triggerfive<='0';
triggerone<='0';
elsif Qs="0010" then X <="01110111"; --MR,SR,1s
triggerten<='0';
triggerthree<='0';
triggerfive<='0';
triggerone<='1';
elsif Qs="0011" then X <="01111110"; --MR,STG,5s
triggerten<='0';
triggerthree<='0';
triggerfive<='1';
triggerone <='0';
elsif Qs="0100" then X <="01111101"; --MR,SG,10s
triggerten<='1';
triggerthree<='0';
triggerfive<='0';
triggerone <='0';
elsif Qs="0101" then X <="01111011"; --MR,SY,3s
triggerten<='0';
triggerthree<='1';
triggerfive<='0';
triggerone <='0';
elsif Qs="0110" then X <="01110111"; -- MR,SR,1s
triggerten<='0';
triggerthree<='0';
triggerfive<='0';
triggerone <='1';
elsif Qs="0111" then X <="11100111"; -- MTG,SR,5s
triggerten<='1';
triggerthree<='0';
triggerfive<='1';
triggerone <='0';
else x<="11010111";
end if;
end process;
end architecture AutoTrafficLightBehavior;