本来打算用FPGA写一个小功能,用DHT11检测温度并显示出来,写完后程序报错,死活找不出为什么错,就来求助一下大家,希望有大神帮我过过眼,这样写对不对。下面附上代码:
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity temperatrue is
Port ( temp : in std_logic;
vcc:out std_logic:='1';
clk : in STD_LOGIC;
light :out std_logic_vector(1 downto 0);
num1 : out std_logic_vector(7 downto 0));
end temperatrue;
architecture Behavioral of temperatrue is
signal i:integer:=1;
signal k:integer:=-2;
signal k1:integer:=0;
signal k2:integer:=0;
signal m:integer:=0;
signal n1:integer:=0;
signal n2:integer:=0;
signal t:integer:=1;
signal light_next:std_logic_vector(1 downto 0);
signal num_next1:std_logic_vector(7 downto 0);
signal num_next2:std_logic_vector(7 downto 0);
signal temperatrue_next :std_logic_vector(7 downto 0);
begin
process(clk) is
begin
if clk'event and clk='1' then
light<=light_next;
num1<=num_next1;
if n1=3 then
n1<=0;
else
n1<=n1+1;
end if;
end if;
end process;
process(clk) is
begin
if clk'event and clk='1' then
n2<=n2+1;
if n2<1500 then
vcc<='1';
elsif n2<1500+20 then
vcc<='0' ;
elsif n2<1520+2850 then
vcc<='1';
end if;
if n2=1520+2850 then
n2<=1;
end if;
end if;
end process;
process(n1) is
begin
case n1 is
when 0=> light_next<="10";
when 1=> light_next<="01";
when others=> light_next<="11";
end case;
end process;
process(light_next,t) is
begin
case light_next is
when"10"=> case t/10 is
when 0=> num_next1<="00000011";
when 1=> num_next1<="10011111";
when 2=> num_next1<="00100101";
when 3=> num_next1<="10011111";
when 4=> num_next1<="00001101";
when 5=> num_next1<="10011001";
when 6=> num_next1<="01001001";
when 7=> num_next1<="00011111";
when 8=> num_next1<="00000001";
when 9=> num_next1<="00001001";
when others=> num_next1<="11111111";
end case;
when "01"=> case t-(t/10)*10 is
when 0=> num_next1<="00000011";
when 1=> num_next1<="10011111";
when 2=> num_next1<="00100101";
when 3=> num_next1<="10011111";
when 4=> num_next1<="00001101";
when 5=> num_next1<="10011001";
when 6=> num_next1<="01001001";
when 7=> num_next1<="00011111";
when 8=> num_next1<="00000001";
when 9=> num_next1<="00001001";
when others=> num_next1<="11111111";
end case;
when others=> num_next1<="11111111";
end case;
end process;
process(temp) is
begin
if temp'event and temp='1' then
k<=k+1;
k1<=k2;
k2<=n2;
if k>15 and k<24 then
if k2-k1>100 then
if k=23 then
t<=t+1;
else
m<=1;
i<=1;
while i<=23-k loop
m<=m*2;
i<=i+1;
end loop;
t<=t+m;
end if;
end if;
end if;
end if;
if k=39 then
k<=-2;
k1<=0;
k2<=0;
t<=0;
end if;
end process;