機(jī)電之家資源網(wǎng)
單片機(jī)首頁|單片機(jī)基礎(chǔ)|單片機(jī)應(yīng)用|單片機(jī)開發(fā)|單片機(jī)文案|軟件資料下載|音響制作|電路圖下載 |嵌入式開發(fā)
培訓(xùn)信息
贊助商
多進(jìn)制數(shù)字頻率調(diào)制(MFSK)系統(tǒng)VHDL程序
多進(jìn)制數(shù)字頻率調(diào)制(MFSK)系統(tǒng)VHDL程序
 更新時(shí)間:2008-7-27 16:56:49  點(diǎn)擊數(shù):3
【字體: 字體顏色
作為FPGA的愛好者,我們希望能夠更好的交流,更多的了解使用FPGA我們還能作哪些事情,能做到什么程度,能做到什么效果,這樣大家多這個(gè)行業(yè)會(huì)有更多的了解。

大家可以把一些不涉及秘密的源代碼公開于大家討論。這樣不僅能為初學(xué)者提供學(xué)習(xí)的最佳資料(看一些枯燥的書是沒多大用的,個(gè)人感覺),也可以讓自己的項(xiàng)目能夠得到更多人的欣賞!

為了拋磚引玉,我先送上幾個(gè)源代碼
多進(jìn)制數(shù)字頻率調(diào)制(MFSK)系統(tǒng)VHDL程序
--文件名:MFSK
--功能:基于VHDL硬件描述語言,完成對(duì)基帶信號(hào)的MFSK調(diào)制
--說明:這里MFSK的M為4
--最后修改日期:2004.2.13
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity MFSK is
port(clk :in std_logic; --系統(tǒng)時(shí)鐘
start :in std_logic; --開始調(diào)制信號(hào)
x :in std_logic; --基帶信號(hào)
y :out std_logic); --調(diào)制信號(hào)
end MFSK;
architecture behav of MFSK is
process(clk) process(clk,yy) --此進(jìn)程完成對(duì)輸入基帶信號(hào)x的MFSK調(diào)制
begin
if clk'event and clk='1' then
if start='0' then y<='0'; -- if語句完成2位并行碼到4種載波的選通
elsif yy="00" then y<=not f(3);
elsif yy="01" then y<=not f(2);
elsif yy="10" then y<=not f(1);
else y<=not f(0);
end if;
end if;
end process;
end behav;

--對(duì)輸入的基帶信號(hào)x進(jìn)行串/并轉(zhuǎn)換,得到2位并行信號(hào)的yy
begin
if clk'event and clk='1' then
if start='0' then q<=0;
elsif q=0 then q<=1;xx(1)<=x;yy<=xx;
elsif q=8 then q<=9;xx(0)<=x;
else q<=q+1;
end if;
end if;
end process;

FPGA驅(qū)動(dòng)LCD顯示中文字符“年”程序
--文件名:lcd_driver.vhd。
--功能:FGAD驅(qū)動(dòng)LCD顯示中文字符“年”。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd_driver is
Port ( clk : in std_logic; --狀態(tài)機(jī)時(shí)鐘信號(hào),同時(shí)也是液晶時(shí)鐘信號(hào),其周期應(yīng)該滿足液晶數(shù)據(jù)的建立時(shí)間
reset:in std_logic;
lcdda : out std_logic; --寄存器選擇信號(hào)
lcdrw : out std_logic; --液晶讀寫信號(hào)
lcden : out std_logic; --液晶時(shí)鐘信號(hào)
data : out std_logic_vector(7 downto 0)); --液晶數(shù)據(jù)信號(hào)
end lcd_driver;

architecture Behavioral of lcd_driver is
type state is (set_dlnf,set_cursor,set_dcb,set _cgram,write _cgram,set_ddram,write_data);
signal current_state:state;
type ram2 is array(0 to 7) of std_logic_vector(7 downto 0);
constant cgram:ram2:=(("00001000"),("00001111"),("00010010"),
("00001111"),("00001010"),("00011111"),("00000010"),("00000010"));--年字符數(shù)據(jù)存儲(chǔ)器
signal clkk : std_logic;
begin

lcden <= clk ; --液晶時(shí)鐘信號(hào)
lcdrw <= '0' ; --寫數(shù)據(jù)

control:process(clk,reset,current_state) --液晶驅(qū)動(dòng)控制器
variable cnt1: std_logic_vector(2 downto 0);
begin
if reset='0'then
current_state<=set_dlnf;
cnt1:=(others => '1');
lcdda<='0';
elsif rising_edge(clk)then
current_state <= current_state ;
lcdda <= '0';
case current_state is
when set_dlnf=>
data<="00111100";--3cH
current_state<=set_cursor;
when set_cursor=>
data<="00000110";--06H
current_state<=set_dcb;
when set_dcb=>
data<="00001111";--0fH
current_state<=set_ cgram;
when set_ cgram=>
data<="01000000";--40H
current_state<=write_ cgram;
when write_ cgram=> --向CGRAM中寫入“年”
lcdda<='1';
cnt1:=cnt1+1;
data<=cgram(conv_integer(cnt1));
if cnt1 = "111" then
current_state<=set_ddram;
end if;
when set_ddram=> --從第一行的起始地址開始顯示
data<="10000000";--80H
current_state<=write_data;
when write_data=>
lcdda<='1';
data<="00000000"; --寫入字符“年”
when others => null;
end case;
end if;
end process;
end Behavioral;

 
FPGA驅(qū)動(dòng)LED靜態(tài)顯示
--文件名:decoder.vhd
--功能:譯碼輸出模塊,LED為共陽接法
--最后修改日期:2004.3.24
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoder is
Port (seg:in std_logic_vector(3 downto 0 ); --四位二進(jìn)制碼輸入
q3:out std_logic_vector(6 downto 0) ); --輸出LED七段碼
end decoder;

architecture Behavioral of decoder is
begin
process(seg)
begin
case seg is
when "0000" => q3<="0000001";--0
when "0001" => q3<="1001111";--1
when "0010" => q3<="0010010";--2
when "0011" => q3<="0000110";--3
when "0100" => q3<="1001100" --4
when "0101" => q3<="0100100";--5
when "0110" => q3<="0100000";--6
when "0111" => q3<="0001111";--7
when "1000" => q3<="0000000";--8
when "1001" => q3<="0000100";--9
when others => q3<="1111111";
end case;
end process;
end Behavioral;
例2:FPGA驅(qū)動(dòng)LED動(dòng)態(tài)顯示(4位)
--文件名:dynamic.vhd。
--功能:動(dòng)態(tài)掃描模塊,位選信號(hào)高電平有效。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity dynamic is
Port ( clk : in std_logic;
reset: in std_logic;
din1 : in std_logic_vector(6 downto 0); --譯碼后的數(shù)據(jù)信號(hào)1(4位2進(jìn)制數(shù)據(jù)
通過例1中的decoder模塊譯碼得到din1,din2,din3,din4)
din2 : in std_logic_vector(6 downto 0); --譯碼后的數(shù)據(jù)信號(hào)2
din3 : in std_logic_vector(6 downto 0); --譯碼后的數(shù)據(jù)信號(hào)3
din4 : in std_logic_vector(6 downto 0); --譯碼后的數(shù)據(jù)信號(hào)4
shift: out std_logic_vector(3 downto 0); --位選信號(hào)
bus4 : out std_logic_vector(6 downto 0)); --數(shù)據(jù)信號(hào)
end dynamic;

architecture Behavioral of dynamic is
signal scan_clk:std_logic_vector(1 downto 0);
begin
process(clk,scan_clk,reset) --分頻進(jìn)程
variable scan:std_logic_vector(17 downto 0);
begin
if reset='1' then
scan:="000000000000000000";
scan_clk<="00";
elsif clk'event and clk='1'then
scan:=scan+1;
end if;
scan_clk<=scan(17 downto 16);
end process;

process(scan_clk,din1,din2,din3,din4) --掃描進(jìn)程
begin
case scan_clk is
when "00"=>
bus4<=din1;
shift<="0001";
when "01"=>
bus4<=din2;
shift<="0010";
when "10"=>
bus4<=din3;
shift<="0100";
when "11"=>
bus4<=din4;
shift<="1000";
when others=> bus4<="0000000";shift<="0000";
end case;
end process;

end Behavioral;
ADC0809 VHDL控制程序
--文件名:ADC0809.vhd
--功能:基于VHDL語言,實(shí)現(xiàn)對(duì)ADC0809簡單控制
--說明:ADC0809沒有內(nèi)部時(shí)鐘,需外接10KHz~1290Hz的時(shí)鐘信號(hào),這里由FPGA的系
--統(tǒng)時(shí)鐘(50MHz)經(jīng)256分頻得到clk1(195KHz)作為ADC0809轉(zhuǎn)換工作時(shí)鐘。
--最后修改日期:2004.3.20
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity ADC0809 is
port ( d : in std_logic_vector(7 downto 0); --ADC0809輸出的采樣數(shù)據(jù)
clk,eoc : in std_logic; --clk為系統(tǒng)時(shí)鐘,eoc為ADC0809轉(zhuǎn)換結(jié)束信號(hào)
clk1,start, ale,en: out std_logic; --ADC0809控制信號(hào)
abc_in :in std_logic_vector(2 downto 0); --模擬選通信號(hào)
abc_out :out std_logic_vector(2 downto 0); --ADC0809模擬信號(hào)選通信號(hào)
q : out std_logic_vector(7 downto 0)); --送至8個(gè)并排數(shù)碼管信號(hào)
end ADC0809;
architecture behav of ADC0809 is
type states is ( st0,st1, st2, st3, st4,st5,st6); --定義各狀態(tài)的子類型
signal current_state, next_state:states:=st0;
signal regl :std_logic_vector(7 downto 0); --中間數(shù)據(jù)寄存信號(hào)
signal qq:std_logic_vector(7 downto 0);
begin
com:process(current_state,eoc) --規(guī)定各種狀態(tài)的轉(zhuǎn)換方式
begin
case current_state is
when st0=>next_state<=st1;ale<='0';start<='0';en<='0';
when st1=>next_state<=st2;ale<='1';start<='0';en<='0';
when st2=>next_state<=st3;ale<='0';start<='1';en<='0';
when st3=> ale<='0';start<='0';en<='0';
if eoc='1' then next_state<=st3; --檢測(cè)EOC的下降沿
else next_state<=st4;
end if;
when st4=> ale<='0';start<='0';en<='0';
if eoc='0' then next_state<=st4; --檢測(cè)EOC的上升沿
else next_state<=st5;
end if;
when st5=>next_state<=st6;ale<='0';start<='0';en<='1';
when st6=>next_state<=st0;ale<='0';start<='0';en<='1';regl<=d;
when others=> next_state<=st0;ale<='0';start<='0';en<='0';
end case;
end process;
clock:process(clk) --對(duì)系統(tǒng)時(shí)鐘進(jìn)行分頻,得到ADC0809轉(zhuǎn)換工作時(shí)鐘
begin
if clk'event and clk='1' then qq<=qq+1; --在clk1的上升沿,轉(zhuǎn)換至下一狀態(tài)
if QQ="01111111" THEN clk1<='1'; current_state <=next_state;
elsif qq<="01111111" then clk1<='0';
end if;
end if;
end process;
q<=regl; abc_out<=abc_in;
end behav;
TLC5510 VHDL控制程序
--文件名:TLC5510.vhd
--功能:基于VHDL語言,實(shí)現(xiàn)對(duì)高速A/D器件TLC5510控制
--最后修改日期:2004.3.20
library ieee;
use ieee.std_logic_1164.all;
entity tlc5510 is
port(clk :in std_logic; --系統(tǒng)時(shí)鐘
oe :out std_logic; --TLC5510的輸出使能/OE
clk1:out std_logic; --TLC5510的轉(zhuǎn)換時(shí)鐘
din:in std_logic_vector(7 downto 0); --來自TLC5510的采樣數(shù)據(jù)
dout:out std_logic_vector(7 downto 0)); --FPGA數(shù)據(jù)輸出
end tlc5510;
architecture behav of tlc5510 is
signal q:integer range 3 downto 0;
begin
process(clk) --此進(jìn)程中,把CLK 進(jìn)行4分頻,得到TLC5510的轉(zhuǎn)換時(shí)鐘
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'; --對(duì)系統(tǒng)CLK進(jìn)行4分頻
else clk1<='0';
end if;
end process;
oe<='0'; --輸出使能賦低電平
dout<=din; --采樣數(shù)據(jù)輸出
end behav;
DAC0832 接口電路程序
--文件名:DAC0832.VHD
--功能:產(chǎn)生頻率為762.9Hz的鋸齒波。
--最后修改日期:2004.3.18。
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; --系統(tǒng)時(shí)鐘
rst:in std_logic; --復(fù)位信號(hào)
ile:out std_logic; --數(shù)據(jù)鎖存允許信號(hào)
cont:out std_logic; --控制信號(hào)(WR1、WR2、CS、Xfer)
data_out:out std_logic_vector(7 downto 0)); --波形數(shù)據(jù)輸出
end DAC0832;
architecture behav of DAC0832 is
signal q:integer range 0 to 63; --計(jì)數(shù)器
signal data:std_logic_vector(7 downto 0); --波形數(shù)據(jù)
begin
process(clk)
begin
if rst='1' then q<=0; --復(fù)位,對(duì)計(jì)數(shù)器q清零
elsif clk'event and clk='1' then
if q=63 then q<=0; --此IF語句對(duì)系統(tǒng)時(shí)鐘進(jìn)行64分頻
if data="11111111" then data<="00000000"; --此IF語句產(chǎn)生鋸齒波波形數(shù)據(jù)
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賦值;波形數(shù)據(jù)輸出;
end behav;

 
  • 上一篇: FPGA入門LED的FPGA控制
  • 下一篇: FPGA的簡易可存儲(chǔ)示波器設(shè)計(jì)
  • 發(fā)表評(píng)論   告訴好友   打印此文  收藏此頁  關(guān)閉窗口  返回頂部
    熱點(diǎn)文章
     
    推薦文章
     
    相關(guān)文章
    網(wǎng)友評(píng)論:(只顯示最新5條。)
    關(guān)于我們 | 聯(lián)系我們 | 廣告合作 | 付款方式 | 使用幫助 | 機(jī)電之家 | 會(huì)員助手 | 免費(fèi)鏈接

    點(diǎn)擊這里給我發(fā)消息66821730(技術(shù)支持)點(diǎn)擊這里給我發(fā)消息66821730(廣告投放) 點(diǎn)擊這里給我發(fā)消息41031197(編輯) 點(diǎn)擊這里給我發(fā)消息58733127(審核)
    本站提供的機(jī)電設(shè)備,機(jī)電供求等信息由機(jī)電企業(yè)自行提供,該企業(yè)負(fù)責(zé)信息內(nèi)容的真實(shí)性、準(zhǔn)確性和合法性。
    機(jī)電之家對(duì)此不承擔(dān)任何保證責(zé)任,有侵犯您利益的地方請(qǐng)聯(lián)系機(jī)電之家,機(jī)電之家將及時(shí)作出處理。
    Copyright 2007 機(jī)電之家 Inc All Rights Reserved.機(jī)電之家-由機(jī)電一體化網(wǎng)更名-聲明
    電話:0571-87774297 傳真:0571-87774298
    杭州濱興科技有限公司提供技術(shù)支持

    主辦:杭州市高新區(qū)(濱江)機(jī)電一體化學(xué)會(huì)
    中國行業(yè)電子商務(wù)100強(qiáng)網(wǎng)站

    網(wǎng)站經(jīng)營許可證:浙B2-20080178-1