标题: FSK调制与解调VHDL程序 [打印本页]

作者: wang1587170    时间: 2018-1-8 17:25
标题: FSK调制与解调VHDL程序
8.10  FSK调制与解调VHDL程序
1. FSK调制VHDL程序
--文件名:PL_FSK
--功能:基于VHDL硬件描述语言,对基带信号进行FSK调制
--最后修改日期:
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity PL_FSK is
port(clk     :in std_logic;         --系统时钟
     start   :in std_logic;         --开始调制信号
     x     :in std_logic;          --基带信号
     y     :out std_logic);        --调制信号
end PL_FSK;
architecture behav of PL_FSK is
signal q1:integer range 0 to 11;      --载波信号f1的分频计数器
signal q2:integer range 0 to 3;       --载波信号f2的分频计数器
signal f1,f2:std_logic;             --载波信号f1f2
begin
process(clk)                     --此进程通过对系统时钟clk的分频,得到载波f1
begin
if clk'event and clk='1' then
   if start='0' then q1<=0;
   elsif q1<=5 then f1<='1';q1<=q1+1; --改变q1后面的数字可以改变,载波f1的占空比
   elsif q1=11 then f1<='0';q1<=0;    --改变q1后面的数字可以改变,载波f1的频率
   else  f1<='0';q1<=q1+1;
   end if;
end if;
end process;
process(clk)                      --此进程通过对系统时钟clk的分频,得到载波f2
begin
if clk'event and clk='1' then
   if start='0' then q2<=0;
   elsif q2<=0 then f2<='1';q2<=q2+1; --改变q2后面的数字可以改变,载波f2的占空比
   elsif q2=1 then f2<='0';q2<=0;     --改变q2后面的数字可以改变,载波f2的频率
   else f2<='0';q2<=q2+1;
   end if;
end if;
end process;
process(clk,x)                    --此进程完成对基带信号的FSK调制
begin
if clk'event and clk='1' then
   if x='0' then y<=f1;            --当输入的基带信号x=0’时,输出的调制信号yf1
   else y<=f2;                  --当输入的基带信号x=1’时,输出的调制信号yf2
   end if;
end if;
end process;
end behav;
1. FSK解调VHDL程序
--文件名:PL_FSK2
--功能:基于VHDL硬件描述语言,对FSK调制信号进行解调
--最后修改日期:
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity PL_FSK2 is
port(clk      :in std_logic;             --系统时钟
     start    :in std_logic;             --同步信号
     x      :in std_logic;             --调制信号
     y      :out std_logic);           --基带信号
end PL_FSK2;
architecture behav of PL_FSK2 is
signal q:integer range 0 to 11;           --分频计数器
signal xx:std_logic;                   --寄存器
signal m:integer range 0 to 5;           --计数器
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)                         --此进程完成FSK解调
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


作者: FFEGFIUEGUEGT    时间: 2018-1-9 20:46
这个程序你运行成功过吗?为什么我运行起来显示有三个警告啊




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1