📄 ask_decoder.vhd
字号:
library ieee;
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ask_decoder is
port(clk: in std_logic; --系统时钟
start: in std_logic; --解调开始信号.
ask_input: in std_logic; --调制信号输入
base_output: out std_logic); --解调后基带信号输出
end ask_decoder;
architecture behav of ask_decoder is
signal cnt: integer range 0 to 35; --系统时钟计数器
signal data_reg: std_logic; --寄存器
signal rising_cnt: integer range 0 to 2; --aSK已调信号的上升沿计数器
begin
fenpin:process (clk) --对系统时钟进行cnt分频
begin
if clk'event and clk='1' then
data_reg <= ask_input; --在clk信上升沿时,对输入信号进行寄存
if start='0' then
cnt<=0; --if语句完成cnt的循环计数
elsif cnt=35 then
cnt<=0;
else
cnt<=cnt+1;
end if;
end if;
end process fenpin;
ask_demod1:process(cnt,rising_cnt,clk) --此进程完成aSK解调
begin
if clk'event and clk='1' then
if cnt=28 then
if rising_cnt>=1 then
base_output <= '1'; --if语句通过对rising_cnt大小,来判决base_output输出的电平
else
base_output <= '0';
end if;
end if;
end if;
end process ask_demod1;
ask_demod2:process(data_reg,cnt) --此进程完成aSK解调
begin
if cnt=35 then
rising_cnt <= 0; --rising_cnt计数器清零
elsif data_reg'event and data_reg = '1' then
rising_cnt <= rising_cnt+1; --计data_reg信号的脉冲个数
else
null;
end if;
end process ask_demod2;
end behav;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -