library ieee;
use ieee.std_logic_1164.all;
USE IEEE.STD_LOGIC_unsigned.ALL;
entity controler is
port
(clk,reset,jia,jian:in std_logic;
paralleloutut std_logic_vector(7 downto 0)
);
end;
architecture behavior of controler is
signal fre,foot:std_logic_vector(39 downto 0);
begin
process(clk,reset,jia,jian)
variable i:integer range 0 to 4;
begin
foot<="0000000000000000000000000000000001100100";
if(reset='1' or jian='1' or jia='1') then
i:=4;
if reset='1' then
fre<="0000000010000000000000000000000000000000";
elsif jian='1' then
fre<=fre-foot;
else if jia='1' then
fre<=fre+foot;
end if;
end if;
elsif rising_edge(clk) then
case i is
when 4=> parallelout <= fre(39 downto 32);i:=3;
when 3=> parallelout <= fre(31 downto 24);i:=2;
when 2=> parallelout <= fre(23 downto 16);i:=1;
when 1=> parallelout <= fre(15 downto 8);i:=0;
when 0=> parallelout <= fre(7 downto 0);i:=4;
end case;
end if;
end process;
end;
library ieee;
use ieee.std_logic_1164.all;
USE IEEE.STD_LOGIC_unsigned.ALL;
entity controler is
port
(clk,reset,jia,jian:in std_logic;
paralleloutut std_logic_vector(7 downto 0)
);
end;
architecture behavior of controler is
signal fre,foot:std_logic_vector(39 downto 0);
begin
process(clk,reset,jia,jian)
variable i:integer range 0 to 4;
begin
foot<="0000000000000000000000000000000001100100"; -- 任意信号有了变化
-- 此处都会执行
if(reset='1' or jian='1' or jia='1') then
i:=4;
if reset='1' then
fre<="0000000010000000000000000000000000000000"; -- 你的reset很可能
-- 没有期望的功能
elsif jian='1' then
fre<=fre-foot;
else if jia='1' then
fre<=fre+foot;
end if;
end if;
elsif rising_edge(clk) then
case i is
when 4=> parallelout <= fre(39 downto 32);i:=3;
when 3=> parallelout <= fre(31 downto 24);i:=2;
when 2=> parallelout <= fre(23 downto 16);i:=1;
when 1=> parallelout <= fre(15 downto 8);i:=0;
when 0=> parallelout <= fre(7 downto 0);i:=4;
end case;
end if;
end process;
end;