TLC5510接口電路VHDL程序
--功能:基於VHDL語言,實現對高速A/D器件TLC5510控制
library ieee;
use ieee.std_logic_1164.all;
entity tlc5510 is
port(clk :in std_logic; --系統時鐘
oe :out std_logic; --TLC5510的輸出使能/OE
clk1:out std_logic; --TLC5510的轉換時鐘
din:in std_logic_vector(7 downto 0); --來自TLC5510的採樣數據
dout:out std_logic_vector(7 downto 0)); --FPGA數據輸出
end tlc5510;
architecture behav of tlc5510 is
signal q:integer range 3 downto 0;
begin
process(clk) --此進程中,把CLK進行4分頻,得到TLC5510的轉換時鐘
begin
if clk'event and clk='1' then
if q=3 then q<=0;
else q<=q+1;
end if;
end if;
if q>=2 then clk1<='1'; --對系統CLK進行4分頻
else clk1<='0';
end if;
end process;
oe<='0'; --輸出使能賦低電平
dout<=din; --採樣數據輸出
end behav;
DAC0832接口電路VHDL程序
--功能:產生頻率爲762.9Hz的鋸齒波。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity DAC0832 is
port(clk:in std_logic; --系統時鐘
rst:in std_logic; --復位信號
ile:out std_logic; --數據鎖存允許信號
cont:out std_logic; --控制信號(WR1、WR2、CS、Xfer)
data_out:out std_logic_vector(7 downto 0));--波形數據輸出
end DAC0832;
architecture behav of DAC0832 is
signal q:integer range 0 to 63; --計數器
signal data:std_logic_vector(7 downto 0); --波形數據
begin
process(clk)
begin
if rst='1' then q<=0; --復位,對計數器q清零
elsif clk'event and clk='1' then
if q=63 then q<=0; --此IF語句對系統時鐘進行64分頻
if data="11111111" then data<="00000000";--此IF語句產生鋸齒波波形數據
else data<=data+1;
end if;
else q<=q+1;
end if;
end if;
end process;
ile<='1';cont<='0';data_out<=data; --ile、cont賦值;波形數據輸出;
end behav;
TLC7524接口電路程序
--功能:產生156.25KHz的正弦波。
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity TLC7524 is
port( clk :in std_logic; --系統時鐘
rst :in std_logic; --復位信號
data_out:out std_logic_vector(7 downto 0)); --波形數據
end TLC7524;
architecture behav of TLC7524 is
signal b:integer range 0 to 63; --地址計數器
signal q:integer range 0 to 4; --計數器
signal d:integer range 0 to 255; --波形數據寄存器
begin
process(clk) --此進程通過對系統時鐘的分頻,完成的地址計數器的循環計數
begin
if rst='1' then b<=0; --復位時,對地址寄存器清零
elsif clk'event and clk='1' then
if q=4 then q<=0; --此IF語句完成對系統時鐘的5分頻
if b=63 then b<=0; --此IF語句完成對地址的循環計數
else b<=b+1;
end if;
else q<=q+1;
end if;
end if;
end process;
process(b) --此進程存儲了正弦波64個採樣點的波形數據
begin
case b is
when 00=> d<=255 ; when 01=> d<=254 ;when 02=> d<=252 ;when 03=> d<=249 ;
when 04=> d<=245 ; when 05=> d<=239 ;when 06=> d<=233 ;when 07=> d<=225 ;
when 08=> d<=217 ; when 09=> d<=207 ;when 10=> d<=197 ;when 11=> d<=186 ;
when 12=> d<=174 ; when 13=> d<=162 ;when 14=> d<=150 ;when 15=> d<=137 ;
when 16=> d<=124 ; when 17=> d<=112 ;when 18=> d<= 99 ;when 19=> d<= 87 ;
when 20=> d<= 75 ; when 21=> d<= 64 ;when 22=> d<= 53 ;when 23=> d<= 43 ;
when 24=> d<= 34 ; when 25=> d<= 26 ;when 26=> d<= 19 ;when 27=> d<= 13 ;
when 28=> d<= 8 ; when 29=> d<= 4 ;when 30=> d<= 1 ;when 31=> d<= 0 ;
when 32=> d<= 0 ; when 33=> d<= 1 ;when 34=> d<= 4 ;when 35=> d<= 8 ;
when 36=> d<= 13 ; when 37=> d<= 19 ;when 38=> d<= 26 ;when 39=> d<= 34 ;
when 40=> d<= 43 ; when 41=> d<= 53 ;when 42=> d<= 64 ;when 43=> d<= 75 ;
when 44=> d<= 87 ; when 45=> d<= 99 ;when 46=> d<=112 ;when 47=> d<=124 ;
when 48=> d<=137 ; when 49=> d<=150 ;when 50=> d<=162 ;when 51=> d<=174 ;
when 52=> d<=186 ; when 53=> d<=197 ;when 54=> d<=207 ;when 55=> d<=217 ;
when 56=> d<=225 ; when 57=> d<=233 ;when 58=> d<=239 ;when 59=> d<=245 ;
when 60=> d<=249 ; when 61=> d<=252 ;when 62=> d<=254 ;when 63=> d<=255 ;
when others=> null;
end case;
end process;
data_out<=conv_std_logic_vector(d,8); --正弦波波形數據輸出
end behav;
NUM463
個人博客式公衆號
用心每一天