📄 clk_div.vhd
字号:
--DDS时钟为448KHZ,周期为 ,一系统时钟为基准,14个状态为一个循环产生各种时钟信号clk_DDS
library ieee;
use ieee.std_logic_1164.all;
entity clk_div is
port(
c1_1024:in std_logic;
c2_DDS:in std_logic;
clk500,clk1000:out std_logic;
clkx4:out std_logic;
clk,reset_DDS:out std_logic);
end;
architecture one of clk_div is
signal cnt1:integer range 0 to 13;
signal cnt2:integer range 0 to 255;
signal cnt3:integer range 0 to 1023;
begin
process(c2_DDS)--产生14个状态
begin
if c2_DDS'event and c2_DDS='1' then
if cnt1<13 then
cnt1<=cnt1+1;
else
cnt1<=0;
end if;
end if;
end process;
process(c2_DDS,cnt1)--产生clk500
begin
if c2_DDS'event and c2_DDS='1' then
if cnt1=0 or cnt1=7 then
clk500<='1';
else
clk500<='0';
end if;
end if;
end process;
process(c2_DDS,cnt1)--14个状态中的第0状态的一周期为产生跳频图案clk1000
begin
if c2_DDS'event and c2_DDS='1' then
if cnt1=0 then
clk1000<='1';
else
clk1000<='0';
end if;
end if;
end process;
process(c2_DDS,cnt1)--14个状态中的第0和第1状态的两周期为DDS复位信号,变为低电平之后,在c2_DDS的作用下,开始向DDS装入控制信号
begin
if c2_DDS'event and c2_DDS='1' then
if cnt1<1 then
reset_DDS<='1';
else
reset_DDS<='0';
end if;
end if;
end process;
process(c1_1024)--对clkx1024进行256分频可得到clkx4
begin
if c1_1024'event and c1_1024='1' then
if(cnt2<255)then
cnt2<=cnt2+1;
clkx4<='0';
else
cnt2<=0;
clkx4<='1';
end if;
end if;
end process;
process(c1_1024)--对clkx1024进行1024分频可得到clk
begin
if c1_1024'event and c1_1024='1' then
if(cnt3<1023)then
cnt3<=cnt3+1;
clk<='0';
else
cnt3<=0;
clk<='1';
end if;
end if;
end process;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -