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;
begin
if rising_edge(clk) then
if posting='1' then
if count4=6249999 then count4:=0;
adr:=conv_integer(Data3)*10+conv_integer(Data2);--存储单位地址
if adr<64 then
if set='1' then ram(adr)<=conv_std_logic_vector((conv_integer(Data1)*10
+conv_integer(Data0))*2,8); --对置入的任意波形数据进行储存
elsif clr='1' then adr:=0; --存储器所有单元清零
for i in 0 to 63 loop
ram(i)<=(others=>'0');
end loop;
end if;
end if;
else count4:=count4+1;
end if;
else
if set='1' then coun<=0; b<=0; coun0<=0;c<=0;z<=31;amp0<="01111111"; addr<=0;
tmp<=conv_integer(Data3)*1000+conv_integer(Data2)*100
+conv_integer(Data1)*10+conv_integer(Data0); --频率数据
amp<="01111111"; --幅值
else
if tmp>0 then
if sw='0' then
if coun<qq then coun<=coun+tmp; b<=b+1; --频率到采样点间隔脉冲数转换
else
if count=b then count:=1;
if f=63 then f<="00000000";
else f<=f+1;
end if;
if sss="00010" then --方波A
if con<=z then dd<=amp0; con<=con+1;
elsif con=63 then con<=0; dd<="00000000";
else con<=con+1; dd<="00000000";
end if;
elsif sss="10000" then dd<=d; --正弦波
elsif sss="00100" then dd<=f(5 downto 0)&"00"; --锯齿波
elsif sss="01000" then --三角波
if f>31 then dd<=("111111"-f(5 downto 0))&"00";
else dd<=f(5 downto 0)&"00";
end if;
elsif sss="00001" then --任意波
,多功能波形发生器VHDL程序与仿真