bsp; signal tmp : integer range 0 to 9999;
signal coun : integer range 0 to 78125000;
signal coun0 : integer range 0 to 250000000;
signal b : integer range 0 to 78125000;
signal c : integer range 0 to 500000000;
signal z, con : integer range 0 to 63;
signal f : std_logic_vector( 7 downto 0 );
signal amp, amp0, d : std_logic_vector(7 downto 0);
signal bcd0,bcd1,bcd2,bcd3 : integer range 0 to 9;
signal bcd01,bcd11,bcd21,bcd31 : integer range 0 to 9;
signal bcd00,bcd10,bcd20,bcd30 : integer range 0 to 9;
signal y : integer range 0 to 9;
signal addr : integer range 0 to 63;
begin
qq<=781250 when ss="1000" else
7812500 when ss="0100" else
78125000 when ss="0010" else
78125;
--qq信号对应SW=0时的档位选择信号SS,实现方波A和其他三种波形的频率预置
qqq<= 500000 when ss="1000" else
5000000 when ss="0100" else
50000000 when ss="0010" else
50000;
--qqq信号对应SW=1时的档位选择信号SS,实现方波B的频率预置
process(clk)
--此进程分别描述了各种波形的频率、幅度(方波A的占空比)调节以及各种波形的任意线
--形叠加等。
variable count4 : integer range 0 to 6250000;
variable count : 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;
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=