发布时间 : 星期五 文章FPGA课程设计 二进制相位键控(PSK)调制器与解调器设计(DOC)更新完毕开始阅读
武汉理工大学《FPGA原理及应用》课程设计报告
附录
附录1 2CPSK调制器的程序代码
library ieee;
use ieee.std_logic_arith.all; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity PL_CPSK is
port(clk :in std_logic; --系统时钟
start :in std_logic; --开始调制信号 x :in std_logic; --基带信号
y :out std_logic); --已调制输出信号 end PL_CPSK;
architecture behav of PL_CPSK is
signal q:std_logic_vector(1 downto 0); --2位计数器 signal f1,f2:std_logic; --载波信号 begin
process(clk) --此进程主要是产生两重载波信号f1,f2 begin
if clk'event and clk='1' then if start='0' then q<=\
elsif q<=\ elsif q=\ else f1<='0';f2<='1';q<=q+1; end if; end if;
end process;
process(clk,x) --此进程完成对基带信号x的调制 begin
if clk'event and clk='1' then --上升沿触发 if q(0)='1' then
if x='1' then y<=f1; --基带信号x为‘1’时,输出信号y为f1 else y<=f2; --基带信号x为‘0’时,输出信号y为f2 end if; end if; end if;
end process; end behav;
20
武汉理工大学《FPGA原理及应用》课程设计报告
附录2 2CPSK解调器的程序代码
library ieee;
use ieee.std_logic_arith.all; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity PL_CPSK2 is
port(clk :in std_logic; --系统时钟 start :in std_logic; --同步信号 x :in std_logic; y :out std_logic); end PL_CPSK2;
architecture behav of PL_CPSK2 is signal q:integer range 0 to 3; begin
process(clk) begin
if clk'event and clk='1' then if start='0' then q<=0;
elsif q=0 then q<=q+1; if x='1' then y<='1'; else y<='0'; end if;
elsif q=3 then q<=0; else q<=q+1; end if; end if;
end process; end behav;
--调制信号 --基带信号 --此进程完成对CPSK调制信号的解调 --在q=0时,根据输入信号x的电平来进行判决 21
武汉理工大学《FPGA原理及应用》课程设计报告
附录3 2DPSK调制器绝对码转换为相对码的程序代码
library ieee;
use ieee.std_logic_arith.all; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity PL_DPSK is
port(clk :in std_logic; --系统时钟
start :in std_logic; --开始转换信号 x :in std_logic; --绝对码输入信号 y :out std_logic); --相对码输出信号 end PL_DPSK;
architecture behav of PL_DPSK is
signal q:integer range 0 to 3; --分频器
signal xx:std_logic; --中间寄存信号 begin
process(clk,x) --此进程完成绝对码到相对码的转换 begin
if clk'event and clk='1' then
if start='0' then q<=0; xx<='0';
elsif q=0 then q<=1; xx<=xx xor x;y<=xx xor x; --输入信号与前一个输出信号进行异或 elsif q=3 then q<=0; else q<=q+1; end if; end if;
end process; end behav;
22
武汉理工大学《FPGA原理及应用》课程设计报告
附录4 2DPSK解调器相对码转换为绝对码的程序代码
library ieee;
use ieee.std_logic_arith.all; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity PL_DPSK2 is
port(clk :in std_logic; --系统时钟
start :in std_logic; --开始转换信号 x :in std_logic; --相对码输入信号 y :out std_logic); --绝对码输出信号 end PL_DPSK2;
architecture behav of PL_DPSK2 is
signal q:integer range 0 to 3; --分频
signal xx:std_logic; --寄存相对码 begin
process(clk,x) --此进程完成相对码到绝对码的转换 begin
if clk'event and clk='1' then if start='0' then q<=0; elsif q=0 then q<=1;
elsif q=3 then q<=0; y<=xx xor x; xx<=x; --输入信号x与前一输入信号xx进行异或 else q<=q+1; end if; end if;
end process; end behav;
23