📄 fupin_control.vhd
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity fupin_control is
Port ( clk2,sw1_2,sw2_2 ,set_2,butt0_2,butt1_2,butt2_2: in std_logic;
d_2 :in std_logic_vector(7 downto 0);
data0_2,data1_2,data2_2,data3_2:in
std_logic_vector(3 downto 0);
--tmpp_2 : in std_logic_vector(8 downto 0);
dd0_2, dd1_2 : out std_logic_vector(7 downto 0);
a0_2, a1_2 : out std_logic_vector(9 downto 0);
f_2:out std_logic_vector(8 downto 0));
end fupin_control;
architecture Behavioral of fupin_control is
signal sign, sign1 : std_logic;
signal f0, f1 : std_logic_vector( 8 downto 0 );
signal qq : integer range 0 to 78125000;
signal b : integer range 0 to 78125000;
signal tmpp:std_logic_vector(8 downto 0);
signal tmp:integer range 0 to 9999;
--signal d : std_logic_vector(7 downto 0);
signal amp0, amp1 : std_logic_vector(9 downto 0);
signal coun : integer range 0 to 78125000;
begin
qq<=138889 when sign1='0' else
13889 ;
process(clk2)
variable ds : std_logic;
begin
if rising_edge(clk2) then
if ds='1' then f_2<=f0; ds:=not ds; dd1_2<=d_2;
else f_2<=f1; ds:=not ds; dd0_2<=d_2;
end if;
end if;
end process;
---qqq<= 500000 when ss="1000" else
--- 5000000 when ss="0100" else
--- 50000000 when ss="0010" else
--- 50000;
process(clk2)
variable count4 : integer range 0 to 6250000;
variable count, cc : integer range 0 to 78125000;
variable count3 : integer range 0 to 250000000;
variable count1 : integer range 0 to 12500000;
variable count0 : integer range 0 to 3249999;
variable ddd : std_logic_vector(9 downto 0);
variable dd0,dd1,dd2,dd3,dd4 : integer range 0 to 255;
variable adr : integer range 0 to 63;
variable vc : integer range 0 to 12499999;
begin
if rising_edge(clk2) then
if sw1_2='0' then --当sw1='0',sw2='1' 则幅度调节;
if sw2_2='1' then
if set_2='1' then f1<=(others=>'0'); f0<=(others=>'0'); sign<='1';
vc:=0;
tmpp<=conv_std_logic_vector((conv_integer(data2_2)*100+conv_integer(data1_2)*10+conv_integer(data0_2)),9);
else
if vc=12499999 then vc:=0;
if butt1_2='1' then
if tmpp<"101100111" then tmpp<=tmpp+1;
elsif tmpp="101100111" then tmpp<="101100111";
end if;
elsif butt2_2='1' then
if tmpp>"000000000" then tmpp<=tmpp-1;
elsif tmpp="000000000" then tmpp<="000000000";
end if;
end if;
else vc:=vc+1;
end if;
if tmp>0 then
if coun<qq then coun<=coun+tmp; b<=b+1;
else
if count=b then count:=0;
if tmpp>"000000000" then
if sign='1' then f0<=tmpp; sign<='0';
else
if f0="101100111" then f0<="000000000";
else f0<=f0+1;
end if;
end if;
else
if f0="101100111" then f0<="000000000";
else f0<=f0+1;
end if;
end if;
if f1="101100111" then f1<="000000000";
else f1<=f1+1;
end if;
else count:=count+1;
end if;
end if;
end if;
end if;
else
if butt0_2='1' then
if set_2='1' then
sign1<='1';tmp<=conv_integer(data3_2)*1000+conv_integer(data2_2)*100+conv_integer(data1_2)*10+conv_integer(data0_2);
coun<=0; b<=0; amp0<="0111111111";
amp1<="0111111111"; f0<="000000000"; f1<="000000000";
end if;
else
if set_2='1' then
tmp<=conv_integer(data3_2)*1000+conv_integer(data2_2)*100+conv_integer(data1_2)*10+conv_integer(data0_2);
coun<=0; b<=0; amp0<="0111111111";
amp1<="0111111111"; f0<="000000000"; f1<="000000000";
sign1<='0';
else
if tmp>0 then
if coun<qq then coun<=coun+tmp; b<=b+1;
else
if count=b then count:=0;
if tmpp>"000000000" then
if sign='1' then f0<=tmpp; sign<='0';
else
if f0="101100111" then f0<="000000000";
else f0<=f0+1;
end if;
end if;
else
if f0="101100111" then f0<="000000000";
else f0<=f0+1;
end if;
end if;
if f1="101100111" then f1<="000000000";
else f1<=f1+1;
end if;
else count:=count+1;
end if;
end if;
end if;
end if;
end if;
end if;
else
if cc=b then cc:=0;
if tmpp>"000000000" then
if sign='1' then f0<=tmpp; sign<='0';
else
if f0="101100111" then f0<="000000000";
else f0<=f0+1;
end if;
end if;
else
if f0="101100111" then f0<="000000000";
else f0<=f0+1;
end if;
end if;
if f1="101100111" then f1<="000000000";
else f1<=f1+1;
end if;
else cc:=cc+1;
end if;
if count0=3249999 then count0:=0;
if butt1_2='1' then
if sw1_2='1' then
if sw2_2='0' then
if amp0<"1111111111" then amp0<=amp0+1;
else amp0<="1111111111";
end if;
else
if amp1<"1111111111" then amp1<=amp1+1;
else amp1<="1111111111";
end if;
end if;
end if;
elsif butt2_2='1' then
if sw1_2='1' then
if sw2_2='0' then
if amp0>"0000000000" then amp0<=amp0-1;
else amp0<="0000000000";
end if;
else
if amp1>"0000000000" then amp1<=amp1-1;
else amp1<="0000000000";
end if;
end if;
end if;
end if;
else count0:=count0+1;
end if;
end if;
end if;
end process;
a0_2<=amp0; a1_2<=amp1;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -