这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » FPGA » FPGA项目源代码公布榜

共64条 1/7 1 2 3 4 5 6 ›| 跳转至

FPGA项目源代码公布榜

工程师
2007-11-10 21:49:37     打赏
作为FPGA的爱好者,我们希望能够更好的交流,更多的了解使用FPGA我们还能作哪些事情,能做到什么程度,能做到什么效果,这样大家多这个行业会有更多的了解。

大家可以把一些不涉及秘密的源代码公开于大家讨论。这样不仅能为初学者提供学习的最佳资料(看一些枯燥的书是没多大用的,个人感觉),也可以让自己的项目能够得到更多人的欣赏!



关键词: 项目     源代码     公布    

工程师
2007-11-10 21:57:03     打赏
2楼

为了抛砖引玉,我先送上几个源代码
多进制数字频率调制(MFSK)系统VHDL程序
--文件名:MFSK
--功能:基于VHDL硬件描述语言,完成对基带信号的MFSK调制
--说明:这里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; --系统时钟
start :in std_logic; --开始调制信号
x :in std_logic; --基带信号
y :out std_logic); --调制信号
end MFSK;
architecture behav of MFSK is
process(clk) process(clk,yy) --此进程完成对输入基带信号x的MFSK调制
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;

--对输入的基带信号x进行串/并转换,得到2位并行信号的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;


工程师
2007-11-10 22:02:42     打赏
3楼

FPGA驱动LCD显示中文字符“年”程序
--文件名:lcd_driver.vhd。
--功能:FGAD驱动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; --状态机时钟信号,同时也是液晶时钟信号,其周期应该满足液晶数据的建立时间
reset:in std_logic;
lcdda : out std_logic; --寄存器选择信号
lcdrw : out std_logic; --液晶读写信号
lcden : out std_logic; --液晶时钟信号
data : out std_logic_vector(7 downto 0)); --液晶数据信号
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"));--年字符数据存储器
signal clkk : std_logic;
begin

lcden <= clk ; --液晶时钟信号
lcdrw <= '0' ; --写数据

control:process(clk,reset,current_state) --液晶驱动控制器
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;


工程师
2007-11-10 22:03:46     打赏
4楼
FPGA驱动LED静态显示
--文件名: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 ); --四位二进制码输入
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驱动LED动态显示(4位)
--文件名:dynamic.vhd。
--功能:动态扫描模块,位选信号高电平有效。
--最后修改日期: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); --译码后的数据信号1(4位2进制数据
通过例1中的decoder模块译码得到din1,din2,din3,din4)
din2 : in std_logic_vector(6 downto 0); --译码后的数据信号2
din3 : in std_logic_vector(6 downto 0); --译码后的数据信号3
din4 : in std_logic_vector(6 downto 0); --译码后的数据信号4
shift: out std_logic_vector(3 downto 0); --位选信号
bus4 : out std_logic_vector(6 downto 0)); --数据信号
end dynamic;

architecture Behavioral of dynamic is
signal scan_clk:std_logic_vector(1 downto 0);
begin
process(clk,scan_clk,reset) --分频进程
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) --扫描进程
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;

工程师
2007-11-10 22:04:22     打赏
5楼
ADC0809 VHDL控制程序
--文件名:ADC0809.vhd
--功能:基于VHDL语言,实现对ADC0809简单控制
--说明:ADC0809没有内部时钟,需外接10KHz~1290Hz的时钟信号,这里由FPGA的系
--统时钟(50MHz)经256分频得到clk1(195KHz)作为ADC0809转换工作时钟。
--最后修改日期: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输出的采样数据
clk,eoc : in std_logic; --clk为系统时钟,eoc为ADC0809转换结束信号
clk1,start, ale,en: out std_logic; --ADC0809控制信号
abc_in :in std_logic_vector(2 downto 0); --模拟选通信号
abc_out :out std_logic_vector(2 downto 0); --ADC0809模拟信号选通信号
q : out std_logic_vector(7 downto 0)); --送至8个并排数码管信号
end ADC0809;
architecture behav of ADC0809 is
type states is ( st0,st1, st2, st3, st4,st5,st6); --定义各状态的子类型
signal current_state, next_state:states:=st0;
signal regl :std_logic_vector(7 downto 0); --中间数据寄存信号
signal qq:std_logic_vector(7 downto 0);
begin
com:process(current_state,eoc) --规定各种状态的转换方式
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; --检测EOC的下降沿
else next_state<=st4;
end if;
when st4=> ale<='0';start<='0';en<='0';
if eoc='0' then next_state<=st4; --检测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) --对系统时钟进行分频,得到ADC0809转换工作时钟
begin
if clk'event and clk='1' then qq<=qq+1; --在clk1的上升沿,转换至下一状态
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;

工程师
2007-11-10 22:06:03     打赏
6楼
TLC5510 VHDL控制程序
--文件名:TLC5510.vhd
--功能:基于VHDL语言,实现对高速A/D器件TLC5510控制
--最后修改日期:2004.3.20
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;

工程师
2007-11-10 22:06:42     打赏
7楼
DAC0832 接口电路程序
--文件名:DAC0832.VHD
--功能:产生频率为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; --系统时钟
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;


工程师
2007-11-10 22:07:23     打赏
8楼
TLC7524接口电路程序
--文件名:TLC7524.VHD
--功能:产生156.25KHz的正弦波。
--最后修改日期:2004.3.18。
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;

工程师
2007-11-10 22:08:44     打赏
9楼
URAT VHDL程序
--文件名:top.vhd。
--功能:顶层映射。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity top is
Port (clk32mhz,reset,rxd,xmit_cmd_p_in:in std_logic; --总的输入输出信号的定义
rec_ready,txd_out,txd_done_out:out std_logic;
txdbuf_in:in std_logic_vector(7 downto 0); --待发送数据输入
rec_buf:out std_logic_vector(7 downto 0)); --接收数据缓冲
end top;
architecture Behavioral of top is

component reciever
Port (bclkr,resetr,rxdr:in std_logic;
r_ready:out std_logic;
rbuf:out std_logic_vector(7 downto 0));
end component;

component transfer
Port (bclkt,resett,xmit_cmd_p:in std_logic;
txdbuf:in std_logic_vector(7 downto 0);
txd:out std_logic;
txd_done:out std_logic);
end component;

component baud
Port (clk,resetb:in std_logic;
bclk:out std_logic);
end component;

signal b:std_logic;
begin
u1:baud port map(clk=>clk32mhz,resetb=>reset,bclk=>b); --顶层映射
u2:reciever port map(bclkr=>b,resetr=>reset,rxdr=>rxd,r_ready=>rec_ready,
rbuf=>rec_buf);
u3:transfer port map(bclkt=>b,resett=>reset,xmit_cmd_p=>xmit_cmd_p_in,
txdbuf=>txdbuf_in,txd=>txd_out,txd_done=>txd_done_out);
end Behavioral;

2. 波特率发生器程序与仿真
(1)波特率发生器VHDL程序
--文件名:baud.vhd.
--功能:将外部输入的32MHz的信号分成频率为153600Hz的信号。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity baud is
Port (clk,resetb:in std_logic;
bclk:out std_logic);
end baud;
architecture Behavioral of baud is
begin
process(clk,resetb)
variable cnt:integer;
begin
if resetb='1' then cnt:=0; bclk<='0'; --复位
elsif rising_edge(clk) then
if cnt>=208 then cnt:=0; bclk<='1'; --设置分频系数
else cnt:=cnt+1; bclk<='0';
end if;
end if;
end process;
end Behavioral;

3. UART发送器程序与仿真
(1)UART发送器VHDL程序
--文件名:transfer.vhd。
--功能:UART发送器。
--说明:系统由五个状态(x_idle,x_start,x_wait,x_shift,x_stop)和一个进程构成。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity transfer is
generic(framlent:integer:=8);
Port (bclkt,resett,xmit_cmd_p:in std_logic; --定义输入输出信号
txdbuf:in std_logic_vector(7 downto 0):="11001010";
txd:out std_logic;
txd_done:out std_logic);
end transfer;
architecture Behavioral of transfer is
type states is (x_idle,x_start,x_wait,x_shift,x_stop); --定义个子状态
signal state:states:=x_idle;
signal tcnt:integer:=0;
begin
process(bclkt,resett,xmit_cmd_p,txdbuf) --主控时序、组合进程
variable xcnt16:std_logic_vector(4 downto 0):="00000"; --定义中间变量
variable xbitcnt:integer:=0;
variable txds:std_logic;
begin
if resett='1' then state<=x_idle; txd_done<='0'; txds:='1'; --复位
elsif rising_edge(bclkt) then
case state is
when x_idle=> --状态1,等待数据帧发送命令
if xmit_cmd_p='1' then state<=x_start; txd_done<='0';
else state<=x_idle;
end if;
when x_start=> --状态2,发送信号至起始位
if xcnt16>="01111" then state<=x_wait; xcnt16:="00000";
else xcnt16:=xcnt16+1; txds:='0'; state<=x_start;
end if;
when x_wait=> --状态3,等待状态
if xcnt16>="01110" then
if xbitcnt=framlent then state<=x_stop; xbitcnt:=0;
else state<=x_shift;
end if;
xcnt16:="00000";
else xcnt16:=xcnt16+1; state<=x_wait;
end if;
when x_shift=>txds:=txdbuf(xbitcnt); xbitcnt:=xbitcnt+1; state<=x_wait; --状态4,将待发数据进行并串转换
when x_stop=> --状态5,停止位发送状态
if xcnt16>="01111" then
if xmit_cmd_p='0' then state<=x_idle; xcnt16:="00000";
else xcnt16:=xcnt16; state<=x_stop;
end if; txd_done<='1';
else xcnt16:=xcnt16+1; txds:='1'; state<=x_stop;
end if;
when others=>state<=x_idle;
end case;
end if;
txd<=txds;
end process;
end Behavioral;
UART发送器的仿真波形如图8.8.7所示。

图8.8.7 UART发送器的仿真波形
4. UART接收器程序与仿真
(1)UART接收器VHDL程序
--文件名:reciever.vhd。
--功能:UART接受器。
--说明:系统由五个状态(r_start,r_center,r_wait,r_sample,r_stop)和两个进程构成
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity reciever is
generic(framlenr:integer:=8);
Port (bclkr,resetr,rxdr:in std_logic; --定义输入输出信号
r_ready:out std_logic;
rbuf:out std_logic_vector(7 downto 0));
end reciever;
architecture Behavioral of reciever is
type states is (r_start,r_center,r_wait,r_sample,r_stop); --定义各子状态
signal state:states:=r_start;
signal rxd_sync:std_logic;
begin
pro1:process(rxdr)
begin
if rxdr='0' then rxd_sync<='0';
else rxd_sync<='1';
end if;
end process;

pro2:process(bclkr,resetr,rxd_sync) --主控时序、组合进程
variable count:std_logic_vector(3 downto 0); --定义中间变量
variable rcnt:integer:=0;
variable rbufs:std_logic_vector(7 downto 0);
begin
if resetr='1' then state<=r_start; count:="0000"; --复位
elsif rising_edge(bclkr) then
case state is
when r_start=> --状态1,等待起始位
if rxd_sync='0' then state<=r_center; r_ready<='0'; rcnt:=0;
else state<=r_start; r_ready<='0';
end if;
when r_center=> --状态2,求出每位的中点
if rxd_sync='0' then
if count="0100" then state<=r_wait; count:="0000";
else count:=count+1; state<=r_center;
end if;
else state<=r_start;
end if;
when r_wait=> --状态3,等待状态
if count>="1110" then
if rcnt=framlenr then state<=r_stop;
else state<=r_sample;
end if;
count:="0000";
else count:=count+1; state<=r_wait;
end if;
when r_sample=>rbufs(rcnt):=rxd_sync; rcnt:=rcnt+1;state<=r_wait;
--状态4,数据位采样检测
when r_stop=>r_ready<='1'; rbuf<=rbufs; state<=r_start; --状态4,输出帧接收完毕信号
when others=>state<=r_start;
end case;
end if;
end process;
end Behavioral;


工程师
2007-11-10 22:19:47     打赏
10楼
ASK调制VHDL程序
--文件名:PL_ASK
--功能:基于VHDL硬件描述语言,对基带信号进行ASK振幅调制
--最后修改日期:2004.3.16
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity PL_ASK is
port(clk :in std_logic; --系统时钟
start :in std_logic; --开始调制信号
x :in std_logic; --基带信号
y :out std_logic); --调制信号
end PL_ASK;
architecture behav of PL_ASK is
signal q:integer range 0 to 3; --分频计数器
signal f :std_logic; --载波信号
begin
process(clk)
begin
if clk'event and clk='1' then
if start='0' then q<=0;
elsif q<=1 then f<='1';q<=q+1; --改变q后面数字的大小,就可以改变载波信号的占空比
elsif q=3 then f<='0';q<=0; --改变q后面数字的大小,就可以改变载波信号的频率
else f<='0';q<=q+1;
end if;
end if;
end process;
y<=x and f; --对基带码进行调制
end behav;

 ASK解调VHDL程序及仿真
1.ASK解调VHDL程序
--文件名:PL_ASK2
--功能:基于VHDL硬件描述语言,对ASK调制信号进行解调
--最后修改日期:2004.2.12
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity PL_ASK2 is
port(clk :in std_logic; --系统时钟
start :in std_logic; --同步信号
x :in std_logic; --调制信号
y :out std_logic); --基带信号
end PL_ASK2;
architecture behav of PL_ASK2 is
signal q:integer range 0 to 11; --计数器
signal xx:std_logic; --寄存x信号
signal m:integer range 0 to 5; --计xx的脉冲数
begin
process(clk) --对系统时钟进行q分频,
begin
if clk'event and clk='1' then xx<=x; --clk上升沿时,把x信号赋给中间信号xx
if start='0' then q<=0; --if语句完成q的循环计数
elsif q=11 then q<=0;
else q<=q+1;
end if;
end if;
end process;
process(xx,q) --此进程完成ASK解调
begin
if q=11 then m<=0; --m计数器清零
elsif q=10 then
if m<=3 then y<='0'; --if语句通过对m大小,来判决y输出的电平
else y<='1';
end if;
elsif xx'event and xx='1'then m<=m+1; --计xx信号的脉冲个数
end if;
end process;
end behav;


共64条 1/7 1 2 3 4 5 6 ›| 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]