end process;
y<=f(0) when yy=\ f(1) when yy=\ f(2) when yy=\
f(3); --根据yy寄存器数据,输出对应的载波 end behav;
解调程序: library ieee;
use ieee.std_logic_arith.all; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity MPSK2 is
port(clk :in std_logic; --系统时钟 start :in std_logic; --同步信号 x :in std_logic; --调制信号 y :out std_logic); --基带信号 end MPSK2;
architecture behav of MPSK2 is
signal q:integer range 0 to 7; --计数器 signal xx:std_logic_vector(2 downto 0); --加法器
signal yyy:std_logic_vector(1 downto 0);--2位并行基代信号寄存器 signal yy:std_logic_vector(2 downto 0); --寄存xx数据 begin process(clk) begin
if clk'event and clk='1' then
if start='0' then q<=0;
elsif q=0 then q<=1;yy<=xx; y<=yyy(0);
--把加法计数器的数据送入yy寄存器 if x='0' then xx<=\
--调制信号x为低电平时,送入加法器的数据“001” else xx<=\ end if;
elsif q=2 then q<=3; if x='0' then xx<=xx+\
--调制信号x为低电平时,送入加法器的数据“001” end if;
elsif q=4 then q<=5; y<=yyy(1); if x='0' then xx<=xx+\
--调制信号x为低电平时,送入加法器的数据“010” end if;
elsif q=6 then q<=7; if x='0' then xx<=xx+\
--调制信号x为低电平时,送入加法器的数据“011” end if; else q<=q+1; end if; end if; end process;
process(yy) --此进程根据yy寄存器里的数据进行译码 begin
if clk='1' and clk'event then
if yy=\寄存器“101”对应基带码“00” elsif yy=\寄存器“011”对应基带码“01”
elsif yy=\寄存器“010”对应基带码“10” elsif yy=\寄存器“100”对应基带码“11” else yyy<=\ end if; end if; end process; end behav;