--文件名:mine4.vhd。
--功能:实现4种常见波形正弦、三角、锯齿、方波(A、B)的频率、幅度可控输出(方波
--A的占空比也是可控的),可以存储任意波形特征数据并能重现该波形,还可完成
--各种波形的线形叠加输出。
--说明: SSS(前三位)和SW信号控制4种常见波形种哪种波形输出。4种波形的频率、
--幅度(基准幅度A)的调节均是通过up、down、set按键和4个BCD码置入器以及一
--个置入档位控制信号(ss)完成的(AMP的调节范围是0"5V,调节量阶为1/51V)。
--其中方波的幅度还可通过u0、d0调节输出数据的归一化幅值(AMP0)进行进一步
--细调(调节量阶为1/(51*255)V)。方波A的占空比通过zu、zp按键调节(调节
--量阶1/64*T)。系统采用内部存储器——RAM实现任意输入波形的存储,程序只支
--持键盘式波形特征参数置入存储,posting 为进入任意波置入(set)、清除(clr)状态
--控制信号,SSS控制存储波形的输出。P180为预留端口,
--最后修改日期:2004.3.26。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity mine4 is
port(clk : in std_logic; --时钟信号输入
set, clr, up, down, zu, zd : in std_logic; --各个波形特征的调节触发信号
posting : in std_logic; --任意波键盘置入信号
u0,d0,sw : in std_logic; --方波A、B的切换sw,和方波B的幅度调节按键
ss : in std_logic_vector( 3 downto 0 ); --档位选择信号
sss : in std_logic_vector( 4 downto 0 ); --波形选择信号
Data3, Data2, Data1,Data0 : in std_logic_vector(3 downto 0); --BCD码输入
p180 : out std_logic; --预留接口
lcd : out std_logic_vector(7 downto 0); --显示输出
shift : out std_logic_vector(3 downto 0); --位码输出
dd, a : out std_logic_vector( 7 downto 0)); --波形、幅度数据输出
end mine4;
architecture behav of mine4 is
subtype word is std_logic_vector( 7 downto 0 );
type unit is array(63 downto 0) of word;
signal ram : unit;
signal qqq : integer range 0 to 250000000;
signal qq : integer range 0 to 78125000;
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'0');
end loop;
end if;
end if;
else count4:=count4+1;
end if;
else
if set='1' then coun0 then
if sw='0' then
if coun31 then dd31 then dd3:=conv_integer(("111111"-f(5 downto 0))&"00");
else dd3:=conv_integer(f(5 downto 0)&"00"); --三角波波形数据dd3
end if;
end if;
if sss(0)='1' then
if addr0 then z"00000000" then amp0"00000000" then amp9999999 then count:=count-10000000; bcd0999999 then count:=count-1000000; bcd199999 then count:=count-100000; bcd29999 then count:=count-10000; bcd399999 then counter:=counter-100000; bcd019999 then counter:=counter-10000; bcd11999 then counter:=counter-1000; bcd2199 then counter:=counter-100; bcd31 lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) lcd(7 downto 1) d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d null;
end case;
end if;
end process;
p180<='1';
end behav;