|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本人初学VHDL,写了一个红灯60S,绿灯55S,黄灯5S的十字路字交通灯。代码如下,却出了如下警告,不知如何解决,求解答
代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity traffic3 is
port (rst: in std_logic;
clk: in std_logic;
led: out std_logic_vector (11 downto 0));
end;
architecture bhv of traffic3 is
type states is (st0,st1,st2,st3,st4);
signal current_state,next_state :states :=st0;
begin
process(rst,clk)
variable count : integer range 0 to 65535;
begin
if rst = '1' then
count := 0 ;
current_state <= st0;
elsif rising_edge(clk) then
if count =119 then
count := 0;current_state <= st0;
else count:=count +1;
current_state <= next_state;
end if;
end if;
end process;
process(current_state)
variable count : integer:=0;
begin
--if rising_edge(clk) then
case current_state is
when st0 =>
if count >0 and count <56 then --road1 green,road2 red;
next_state <= st1;
end if;
when st1 =>
if count >55 and count <61 then --road1 yellow,road2 red;
next_state <= st2;
end if;
when st2 =>
if count >60 and count <116 then --road1 red,road2 green;
next_state <= st3;
end if;
when st3 =>
if count >115 and count <121 then --road1 red,road2 yellow
next_state <= st4;
end if;
when st4 =>
if count >120 then --others
next_state <= st0;
end if;
when others => next_state <= st0;
end case;
end process;
process (current_state,clk)
begin
case current_state is
when st0 => led(5 downto 0) <= "000000"; --reset state
led(11 downto 6) <= "000000";
when st1 => led(5 downto 0) <= "100010"; --red1,green1,yellow1,red2,green2,yellow2;
led(11 downto 6)<= "100010";
when st2 => if clk = '1' then
led(5 downto 0) <= "100001";
led(11 downto 6)<= "100001";
elsif clk = '0' then
led(5 downto 0) <="100000";
led(11 downto 6)<="100000";
end if;
when st3 => led(5 downto 0) <= "010100";
led(11 downto 6) <= "010100";
when st4 => if clk = '1' then
led(5 downto 0) <= "001100";
led(11 downto 6)<= "001100";
elsif clk = '0' then
led(5 downto 0) <="010000";
led(11 downto 6)<="010000";
end if;
when others => led(5 downto 0) <= "000000";
led(11 downto 6) <= "000000";
end case;
end process;
end bhv;
警告:
Warning (10542): VHDL Variable Declaration warning at traffic3.vhd(30): used initial value expression for variable "count" because variable was never assigned a value
Warning (10631): VHDL Process Statement warning at traffic3.vhd(58): inferring latch(es) for signal or variable "led", which holds its previous value in one or more paths through the process
Warning: Output pins are stuck at VCC or GND
Warning (13410): Pin "led[0]" is stuck at GND
Warning (13410): Pin "led[1]" is stuck at GND
Warning (13410): Pin "led[2]" is stuck at GND
Warning (13410): Pin "led[3]" is stuck at GND
Warning (13410): Pin "led[4]" is stuck at GND
Warning (13410): Pin "led[5]" is stuck at GND
Warning (13410): Pin "led[6]" is stuck at GND
Warning (13410): Pin "led[7]" is stuck at GND
Warning (13410): Pin "led[8]" is stuck at GND
Warning (13410): Pin "led[9]" is stuck at GND
Warning (13410): Pin "led[10]" is stuck at GND
Warning (13410): Pin "led[11]" is stuck at GND
Warning: Design contains 2 input pin(s) that do not drive logic
Warning (15610): No output dependent on input pin "clk"
Warning (15610): No output dependent on input pin "rst"
如何解决呀,头痛。 |
|