FPGA数字锁相环程序.docx

上传人:b****5 文档编号:29496362 上传时间:2023-07-24 格式:DOCX 页数:7 大小:14.63KB
下载 相关 举报
FPGA数字锁相环程序.docx_第1页
第1页 / 共7页
FPGA数字锁相环程序.docx_第2页
第2页 / 共7页
FPGA数字锁相环程序.docx_第3页
第3页 / 共7页
FPGA数字锁相环程序.docx_第4页
第4页 / 共7页
FPGA数字锁相环程序.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

FPGA数字锁相环程序.docx

《FPGA数字锁相环程序.docx》由会员分享,可在线阅读,更多相关《FPGA数字锁相环程序.docx(7页珍藏版)》请在冰豆网上搜索。

FPGA数字锁相环程序.docx

FPGA数字锁相环程序

libraryieee;

useieee.std_logic_1164.all;

entityyxoris

port(x1,x2:

instd_logic;

y:

outstd_logic);

endentityyxor;

architectureart1ofyxoris

begin

y<=x1xorx2;

endarchitectureart1;

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityid_controlleris

port(inc,dec,clk:

instd_logic;

out1:

outstd_logic);

endentityid_controller;

architectureart4ofid_controlleris

signaltmp:

std_logic_vector(1downto0);signalcont:

std_logic_vector(1downto0);signaltmp1:

std_logic;

begin

process(clk,inc,dec)

begin

if(clk'eventandclk='1')then

ifinc='1'then

cont<="01";

elsifdec='1'then

cont<="11";

else

cont<="10";

endif;

endif;

endprocess;

process(clk,cont)

begin

ifclk'eventandclk='1'then

iftmp

tmp<=tmp+1;

else

tmp<="00";

tmp1<=nottmp1;

endif;

endif;

endprocess;

out1<=tmp1;

endarchitectureart4;

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitydivis

port(clk:

instd_logic;

n:

instd_logic_vector(7downto0);y:

outstd_logic);

endentitydiv;

architectureart3ofdivis

signalk:

std_logic_vector(7downto0);signaltmp:

std_logic;

begin

process(clk,n)is

begin

ifclk'eventandclk='1'then

ifk

k<=k+'1';

else

k<="00000000";

tmp<=nottmp;

endif;

endif;

endprocess;

y<=tmp;

endarchitectureart3;

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitycount_kis

port(clk,updn,en,d,c,b,a:

instd_logic;

inc,dec:

outstd_logic);

endentitycount_k;

architectureart2ofcount_kis

signalcq,k,mo:

std_logic_vector(16downto0);signaltemp1,temp2:

std_logic;

signalinstruction:

std_logic_vector(3downto0);begin

instruction<=d&c&b&a;

withinstructionselect

mo<="11"when"0001",

"11"when"0010",

"11"when"0011",

"11"when"0100",

"11"when"0101",

"11"when"0110",

"11"when"0111",

"11"when"1000",

"11"when"1001",

"11"when"1010",

"11"when"1011",

"11"when"1100",

"11"when"1101",

"11"when"1110",

"11"when"1111",

"11"whenothers;

process(clk,en,updn,k,cq)

begin

ifclk'eventandclk='1'then

k<=mo;

ifen='1'then

ifupdn='0'then

ifcq

cq<=cq+1;

elsecq<=(others=>'0');

endif;

else

ifcq>0then

cq<=cq-1;

elsecq<=k;

endif;

endif;

elsecq<=(others=>'0');

endif;

endif;

endprocess;

process(en,updn,cq,k)is

begin

ifen='1'then

ifupdn='0'then

ifcq=kthentemp1<='1';

elsetemp1<='0';

endif;

temp2<='0';

else

ifcq="00"thentemp2<='1';elsetemp2<='0';

endif;

temp1<='0';

endif;

elsetemp1<='0';temp2<='0';

endif;

endprocess;

inc<=temp1;dec<=temp2;

endarchitectureart2;

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitysystemis

port(clk1,clk2,fin,en,d,c,b,a:

instd_logic;

n:

instd_logic_vector(7downto0);

fout:

inoutstd_logic);

endentitysystem;

architectureart5ofsystemis

componentyxoris

port(x1,x2:

instd_logic;

y:

outstd_logic);

endcomponentyxor;

componentid_controlleris

port(inc,dec,clk:

instd_logic;

out1:

outstd_logic);

endcomponentid_controller;

componentcount_kis

port(clk,updn,en,d,c,b,a:

instd_logic;

inc,dec:

outstd_logic);

endcomponentcount_k;

componentdivis

port(clk:

instd_logic;

n:

instd_logic_vector(7downto0);

y:

outstd_logic);

endcomponentdiv;

signals1,s2,s3,s4,s5:

std_logic;

begin

u1:

yxorportmap(fin,fout,s2);

u2:

count_kportmap(clk1,s2,en,d,c,b,a,s3,s4);u3:

id_controllerportmap(s3,s4,clk2,s1);

u4:

divportmap(s1,n,fout);

endarchitectureart5;

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 其它课程

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1