📄 phase.vhd
字号:
------------------------------------------------------------------
--Copyright (C), 2004- , Huangwei. --
--File name:phase(鉴相器) --
--Author:huangwei Version:1.0 Date:2004/11/24 --
--Description: --
--该程序主要完成的功能是用于同步锁相环中的鉴相功能;其输入端是 --
--来自线路传输来的数据信号和本地的时钟以及本地高频时钟;输出超--
--前/滞后信号。本模块的编程思想是边缘鉴相(异或方式)输出超前/--
--滞后信号,然后通过高频时钟对其提取脉冲,从而获得和高频时钟等--
--宽度的超前/滞后脉冲。方便之后用来插入或扣除高频脉冲。 --
----------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity phase is
port(
datain : in std_logic; --数据输入
clk_2M : in std_logic; --本地时钟输入
clk_h : in std_logic; --本地高频时钟输入
light : out std_logic; --边缘鉴相异或信号
insert : out std_logic; --超前脉冲
deduct : out std_logic —滞后脉冲
);
end phase;
architecture phase_arc of phase is
signal count : integer range 0 to 1024; --计数寄存器
signal ahead : std_logic; --超前信号寄存器
signal back : std_logic ; --滞后信号寄存器
signal databuff : std_logic; --输出数据寄存器
begin
process(clk_2M,datain,clk_h,databuff,count,ahead,back)
begin
databuff <= ( (clk_2M xor datain) and datain ); --边缘异或鉴相
if rising_edge(datain) then --超前/滞后判决
if (clk_2M = '1') then --数据上升沿时,本地时钟为‘1’,故超前
ahead <= '1';
back <= '0';
elsif ( clk_2M= '0') then --数据上升沿时,本地时钟为‘0’,故滞后
ahead <= '0';
back <= '1';
end if;
end if;
if rising_edge(clk_h) then
--根据边缘异或鉴相和超前/滞后信号确定超前/滞后脉冲
light <= databuff;
if (databuff = '1') then
if (ahead = '1') then
count <= count + 1;
elsif (back = '1') then
count <= count - 1;
elsif ( (ahead and back) = '0' ) then
count <= 15;
end if;
elsif (databuff = '0') then
count <= 15;
end if;
end if;
if (count = 16) then
insert <= '1';
deduct <= '0';
elsif (count = 14) then
insert <= '0';
deduct <= '1';
else
insert <= '0';
deduct <= '0';
end if;
end process;
end phase_arc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -