FPGA设计数字系统Word文档格式.docx

上传人:b****1 文档编号:5184991 上传时间:2023-05-04 格式:DOCX 页数:139 大小:48.76KB
下载 相关 举报
FPGA设计数字系统Word文档格式.docx_第1页
第1页 / 共139页
FPGA设计数字系统Word文档格式.docx_第2页
第2页 / 共139页
FPGA设计数字系统Word文档格式.docx_第3页
第3页 / 共139页
FPGA设计数字系统Word文档格式.docx_第4页
第4页 / 共139页
FPGA设计数字系统Word文档格式.docx_第5页
第5页 / 共139页
FPGA设计数字系统Word文档格式.docx_第6页
第6页 / 共139页
FPGA设计数字系统Word文档格式.docx_第7页
第7页 / 共139页
FPGA设计数字系统Word文档格式.docx_第8页
第8页 / 共139页
FPGA设计数字系统Word文档格式.docx_第9页
第9页 / 共139页
FPGA设计数字系统Word文档格式.docx_第10页
第10页 / 共139页
FPGA设计数字系统Word文档格式.docx_第11页
第11页 / 共139页
FPGA设计数字系统Word文档格式.docx_第12页
第12页 / 共139页
FPGA设计数字系统Word文档格式.docx_第13页
第13页 / 共139页
FPGA设计数字系统Word文档格式.docx_第14页
第14页 / 共139页
FPGA设计数字系统Word文档格式.docx_第15页
第15页 / 共139页
FPGA设计数字系统Word文档格式.docx_第16页
第16页 / 共139页
FPGA设计数字系统Word文档格式.docx_第17页
第17页 / 共139页
FPGA设计数字系统Word文档格式.docx_第18页
第18页 / 共139页
FPGA设计数字系统Word文档格式.docx_第19页
第19页 / 共139页
FPGA设计数字系统Word文档格式.docx_第20页
第20页 / 共139页
亲,该文档总共139页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

FPGA设计数字系统Word文档格式.docx

《FPGA设计数字系统Word文档格式.docx》由会员分享,可在线阅读,更多相关《FPGA设计数字系统Word文档格式.docx(139页珍藏版)》请在冰点文库上搜索。

FPGA设计数字系统Word文档格式.docx

4.源程序及注释

(1)上层模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_signed.all;

useieee.std_logic_unsigned.all;

entitycheifis

port(clk_1m:

instd_logic;

--时钟信号,1MHz。

k1:

--调节频率的开关信号。

k2:

--调节占空比的开关信号。

k3:

--换挡开关信号。

sel:

outstd_logic_vector(5downto0);

--数码管片选信号。

d:

outstd_logic_vector(6downto0);

--数码管的驱动信号。

f:

outstd_logic_vector(7downto0));

--输出给DAC0832的8位数字信号。

endcheif;

architectureaaofcheifis

signalmode_mid:

integerrange0to1;

signalclk_125_mid:

std_logic;

signals1:

signals2:

signals3:

signalfs_mid:

signalstatusf_mid:

integerrange0to9;

signalstatush_mid:

integerrange0to8;

componentkeyin--调用防抖动模块。

port(k:

kout:

bufferstd_logic;

clk_125:

instd_logic);

endcomponent;

componentfp--调用分频及控制模块。

port(clk_1m:

s1:

s3:

statusf:

outintegerrange0to9;

mode:

outintegerrange0to1;

fs:

outstd_logic);

componentoutput--调用信号输出模块。

port(fs:

s2:

statush:

outintegerrange0to8;

outstd_logic_vector(7downto0));

endcomponent;

componentdisplay--调用分频及显示模块。

port(statusf:

inintegerrange0to9;

statush:

inintegerrange0to8;

inintegerrange0to1;

clk_1m:

outstd_logic;

outstd_logic_vector(5downto0);

outstd_logic_vector(6downto0));

begin

u1:

keyinportmap(k1,s1,clk_125_mid);

u2:

keyinportmap(k2,s2,clk_125_mid);

u3:

keyinportmap(k3,s3,clk_125_mid);

u4:

fpportmap(clk_1m,s1,s3,statusf_mid,mode_mid,fs_mid);

u5:

outputportmap(fs_mid,s2,statush_mid,f);

u6:

displayportmap(statusf_mid,statush_mid,mode_mid,clk_1m,

clk_125_mid,sel,d);

endaa;

(2)下层模块

①防抖动模块

libraryieee;

useieee.std_logic_1164.all;

entitykeyinis

--有抖动的开关信号。

bufferstd_logic;

--消抖动后的开关信号。

--时钟信号,125Hz。

endkeyin;

architectureaaofkeyinis

signala,d1,d2,s,r,q1,q2,b:

p1:

process(clk_125)

begin

if(clk_125=′0′)then

d1<

=k;

d2<

=d1;

endif;

endprocess;

p2:

process

s<

=d1andd2;

r<

=(notd1)and(notd2);

a<

=sor((notr)anda);

p3:

if(clk_125′eventandclk_125=′1′)then

q2<

=q1;

q1<

=a;

b<

=q1andnotq2;

kout<

=b;

②分频及控制模块

entityfpis

--经过防抖后输入的调节频率的开关信号。

--经过防抖后输入的换挡开关信号。

--改变频率的控制计数器。

mode:

--换挡控制信号。

outstd_logic);

--取样信号。

endfp;

architectureaaoffpis

signaln:

integerrange0to166;

signalm:

integerrange0to1;

signalstatus:

signalfs2:

signalfs2_10:

signalfs1:

signalcount:

signalc:

integerrange0to10;

process(s1,s3)

if(s1′eventands1=′1′)then

if(status=9)then

status<

=0;

else

=status+1;

if(s3′eventands3=′1′)then

if(m=1)then

m<

elsif(m=0)then

=1;

casestatusis

when0=>

n<

=166;

--信号n用来控制对1MHz信号分频电路输出信号的频率。

when1=>

=83;

when2=>

=55;

when3=>

=41;

when4=>

=33;

when5=>

=27;

when6=>

=23;

when7=>

=20;

when8=>

=18;

when9=>

=16;

whenothers=>

=null;

endcase;

endprocess;

process(clk_1m)

if(clk_1m′eventandclk_1m=′1′)then

if(count=n)then--n的值不同,输出信号的频率也不同。

count<

fs2<

=′1′;

=count+1;

=′0′;

elsenull;

endprocess;

process(fs2)

begin

if(fs2′eventandfs2=′1′)then--实现换挡功能。

if(m=0)then

fs2_10<

=fs2;

if(c=9)then

c<

=c+1;

endprocess;

process(fs2_10)

if(fs2_10′eventandfs2_10=′1′)then

fs1<

=notfs1;

--2分频后得到不同频率的取样信号。

fs<

=fs1;

statusf<

=status;

mode<

=m;

endaa;

③信号输出模块

useieee.std_logic_signed.all;

entityoutputis

port(fs:

s2:

--经过防抖后输入的调节占空比的开关信号。

--改变占空比的控制计数器。

f:

outstd_logic_vector(7downto0));

endoutput;

architectureaaofoutputis

signalm:

integerrange0to29;

p1:

process(s2)

777776

(s2′eventands2=if′1′)then

if(status=8)then

endprocessp1;

process(fs)--本进程描述一个用于调节脉宽的控制计数器。

if(fs′eventandfs=′1′)then

if(m=29)then

=m+1;

null;

endprocessp3;

process(status)--本进程描述不同占空比的矩形波的显示控制。

casemis--当m<

3,占空比为10%。

f<

="

11111111"

;

00000000"

casemis。

casemis

when0=>

when3=>

casemis

when10=>

when11=>

when4=>

when12=>

when13=>

when14=>

whenothers=>

when5=>

when18=>

when19=>

when20=>

when21=>

when22=>

when23=>

when24=>

when25=>

when26=>

when27=>

when28=>

when29=>

when6=>

when7=>

when8=>

when28=>

endprocessp2;

statush<

④分频及显示模块

entitydisplayis

--改变显示频率的控制计数器。

--改变显示占空比的控制计数器。

--时钟信号,1MHz。

--防抖动模块的时钟信号。

enddisplay;

architectureaaofdisplayis

signalnto1999;

:

integerrange0

signalclk_500:

signalclk_250:

signalclk_125_mid

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

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2