else null;
end if;
end if;
else count1:=0; --正弦波、三角波、锯齿波
if count0=4999999 then counter:=conv_integer(amp)*1961;
count0:=0; bcd01<=0; bcd11<=0; bcd21<=0; bcd31<=0;
elsif count0=4999000 then bcd00<=bcd01; bcd10<=bcd11; bcd20<=bcd21;
bcd30<=bcd31; count0:=count0+1;
else count0:=count0+1;
if counter>99999 then counter:=counter-100000; bcd01<=bcd01+1;
elsif counter>9999 then counter:=counter-10000; bcd11<=bcd11+1;
elsif counter>999 then counter:=counter-1000; bcd21<=bcd21+1;
elsif counter>99 then counter:=counter-100; bcd31<=bcd31+1;
else null;
end if;
end if;
end if;
end if;
end process;
process(clk) --输出波形幅度(峰-峰值)数据译码动态显示
variable count : integer range 0 to 499999;
begin
if rising_edge(clk) then
if count<=124999 then y<=bcd00; count:=count+1; shift<="0111"; lcd(0)<='0';
elsif count<=249999 then y<=bcd10; count:=count+1; shift<="1011";lcd(0)<='1';
elsif count<=374999 then y<=bcd20; count:=count+1; shift<="1101";lcd(0)<='1';
elsif count<499999 then y<=bcd30; count:=count+1; shift<="1110";lcd(0)<='1';
elsif count=499999 then y<=bcd30; count:=0; shift<="1110";lcd(0)<='1';
end if;
end if;
case y is --7段码译码
when 0 => lcd(7 downto 1)<="0000001";
when 1 => lcd(7 downto 1)<="1001111";
when 2 => lcd(7 downto 1)<="0010010";
when 3 => lcd(7 downto 1)<="0000110";
when 4 => lcd(7 downto 1)<="1001100";
when 5 => lcd(7 downto 1)<="0100100";
when 6 => lcd(7 downto 1)<="0100000";
when 7 => lcd(7 downto 1)<="0001111";
when 8 => lcd(7 downto 1)<="0000000";
when 9 => lcd(7 downto 1)<="0000100";
when others => lcd(7 downto 1)<="0000001";
end case;
end process;
ym:process(clk) --正弦波在一个周期内时域上的64个采样点的波形数据
begin
if rising_edge(clk) then
case f is
when "00000000"=> d<="11111111" ; when "00000001"=> d<="11111110" ;
when "00000010"=> d<="11111100" ;when "00000011"=> d<="11111001" ;
when "00000100"=> d<="11110101" ; when "00000101"=> d<="11101111" ;
when "00000110"=> d<="11101001" ;when "00000111"=> d<="11100001" ;
when "00001000"=> d<="11011001" ; when "00001001"=> d<="11001111" ;
when "00001010"=> d<="11000101" ;when "00001011"=> d<="10111010" ;
when "00001100"=> d<="10101110" ; when "00001101"=> d<="10100010" ;
when "00001110"=> d<="10010110" ;when "00001111"=> d<="10001001" ;
when "00010000"=> d<="01111100" ; when "00010001"=> d<="01110000" ;
when "00010010"=> d<="01100011" ;when "00010011"=> d<="01010111" ;
when "00010100"=> d<="01001011" ; when "00010101"=> d<="01000000" ;
when "00010110"=> d<="00110101" ;when "00010111"=> d<="00101011" ;
when "00011000"=> d<="00100010" ; when "00011001"=> d<="00011010" ;
when "00011010"=> d<="00010011" ;when "00011011"=> d<="00001101" ;
,多功能波形发生器VHDL程序与仿真