电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx

上传人:b****5 文档编号:30720899 上传时间:2023-08-19 格式:DOCX 页数:35 大小:610.48KB
下载 相关 举报
电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx_第1页
第1页 / 共35页
电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx_第2页
第2页 / 共35页
电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx_第3页
第3页 / 共35页
电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx_第4页
第4页 / 共35页
电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx

《电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx》由会员分享,可在线阅读,更多相关《电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx(35页珍藏版)》请在冰豆网上搜索。

电子科技大学 电子技术实验 FPGA 频率计 实验报告.docx

电子科技大学电子技术实验FPGA频率计实验报告

《现代电子技术综合实验》论文报告

29013050XXXXX

中文摘要

摘要:

随着电子信息产业的不断发展,信号频率的测量在科技研究和实际应用中的作用日益重要。

传统的频率计通常是用很多的逻辑电路和时序电路来实现的,这种电路一般运行缓慢,而且测量频率的范围比较小。

考虑到上述问题,本文设计一个基于FPGA技术的数字频率计。

首先,我们把方波信号送入计数器里进行计数,获得频率值;最后把测得的频率数值送入显示电路里进行显示。

本文从频率计的具体设计触发,详细阐述了基于FPGA的数字频率计的设计方案,设计了各模块的代码,并对硬件电路进行了仿真。

关键词:

FPGA,VHDL,频率计,测量

一、引言

随着电子信息产业的发展,信号作为其最基础的元素,其频率的测量在科技研究和实际应用中的作用日益重要,而且需要测频的范围也越来越宽。

传统的频率计通常采用组合电路和时序电路等大量的硬件电路构成,产品不但体积较大,运行速度慢,而且测量范围低,精度低。

因此,随着对频率测量的要求的提高,传统的测频的方法在实际应用中已不能满足要求。

因此我们需要寻找一种新的测频的方法。

随着FPGA技术的发展和成熟,用FPGA来做为一个电路系统的控制电路逐渐显示出其无与伦比的优越性。

因此本采用FPGA来做为电路的控制系统,设计一个能测量10Hz到100MHz的数字频率计。

用FPGA来做控制电路的数字频率计测量频率精度高,测量频率的范围得到很大的提高。

二、项目任务与设计思路

1、实验项目

数字频率计的设计

2、实验指标

被测输入信号:

方波

测试频率范围为:

10Hz~100MHz

量程分为三档:

第一档:

闸门时间为1S时,最大读数为999.999KHz

第二档:

闸门时间为0.1S时,最大读数为9999.99KHz

第三档:

闸门时间为0.01S时,最大读数为99999.9KHz

显示工作方式:

a、用六位BCD七段数码管显示读数。

b、采用记忆显示方法

c、实现对高位无意义零的消隐。

3、实验思路

根据实验指标,将电路设计分成6个模块:

分频器,闸门选择,门控电路,计数器,锁存器,显示控制。

 

三、基于VHDL方法的设计方案

1、设计方框图

2、具体说明

石英振荡器:

48MHz的晶振信号。

分频器:

将48MHz的信号分频成1Hz,10Hz,100Hz的基准频率;同时产生1kHz的信号作为扫描显示控制子系统的时钟。

闸门选择开关:

设置三个开关sel1,sel10,sel100。

闸门选择:

设置一个选择频率输出和三个小数点输出dp1,dp2,dp3。

根据闸门选择开关的信号,当se11有效而其他两个无效时,选择频率输出1Hz信号,dp1,dp2,dp3分别输出0,1,1;当sel10有效而其他两个无效时,选择频率输出10Hz信号,dp1,dp2,dp3分别输出1,0,1;当sel100有效而其他两个无效时,选择频率输出100Hz信号,dp1,dp2,dp3分别输出1,1,0。

门控电路:

根据选择频率信号产生闸门信号(计数器使能信号),清零信号,锁存使能信号,各信号的时序关系如图所示:

计数器:

考虑采用6个10进制计数器同步级联的方法。

锁存器:

门控电路产生的锁存使能信号的上升沿触发。

扫描显示控制子系统:

考虑该系统由三部分组成:

预显示部分,消隐部分,显示部分。

预显示部分:

设计一个选择信号switch负责选择对应的LED灯(根据1kHz),并根据传来的数据,产生对应的数码管使能信号序列led(6:

0)。

消隐部分:

设计一个信号hide(5:

0),该信号的每一位分别代表一个LED灯,若该信号某一位为1,则对应的LED灯消隐。

hide信号的赋值根据dp1,dp2,dp3的值以及高位的数据是否为零决定。

显示部分,设置一个使能输出信号G,并令它为低电平,根据hide信号和led信号以及dp1,dp2,dp3信号决定最终的输出。

四、系统电路设计

五、系统单元模块设计

1、分频器

entityfreq_divideris

port(clkin:

instd_logic;

clkout1:

outstd_logic;

clkout10:

outstd_logic;

clkout100:

outstd_logic;

clkout1k:

outstd_logic);

endfreq_divider;

architectureBehavioraloffreq_divideris

signalclkcnt1:

integerrange0to48000000:

=0;

signalclkcnt10:

integerrange0to4800000:

=0;

signalclkcnt100:

integerrange0to480000:

=0;

signalclkcnt1k:

integerrange0to48000:

=0;

signalclk1,clk10,clk100,clk1k:

std_logic:

='1';

begin

fc1:

process(clkin)

begin

ifrising_edge(clkin)then

ifclkcnt1=24000000then

clkcnt1<=1;

clk1<=notclk1;

else

clkcnt1<=clkcnt1+1;

endif;

endif;

endprocess;

fc10:

process(clkin)

begin

ifrising_edge(clkin)then

ifclkcnt10=2400000then

clkcnt10<=1;

clk10<=notclk10;

else

clkcnt10<=clkcnt10+1;

endif;

endif;

endprocess;

fc100:

process(clkin)

begin

ifrising_edge(clkin)then

ifclkcnt100=240000then

clkcnt100<=1;

clk100<=notclk100;

else

clkcnt100<=clkcnt100+1;

endif;

endif;

endprocess;

fc1k:

process(clkin)

begin

ifrising_edge(clkin)then

ifclkcnt1k=24000then

clkcnt1k<=1;

clk1k<=notclk1k;

else

clkcnt1k<=clkcnt1k+1;

endif;

endif;

endprocess;

--assignment

clkout1<=clk1;

clkout10<=clk10;

clkout100<=clk100;

clkout1k<=clk1k;

endBehavioral;

2、闸门选择

entitygate_selis

port(se1:

instd_logic;

se10:

instd_logic;

se100:

instd_logic;

f1:

instd_logic;

f10:

instd_logic;

f100:

instd_logic;

fref:

outstd_logic;

dp1:

outstd_logic;

dp2:

outstd_logic;

dp3:

outstd_logic);

endgate_sel;

architectureBehavioralofgate_selis

signalsel:

std_logic_vector(2downto0):

="000";

begin

sel<=se1&se10&se100;

process(sel,f1,f10,f100)

begin

caseselis

when"100"=>

fref<=f1;

dp1<='0';

dp2<='1';

dp3<='1';

when"010"=>

fref<=f10;

dp1<='1';

dp2<='0';

dp3<='1';

when"001"=>

fref<=f100;

dp1<='1';

dp2<='1';

dp3<='0';

whenothers=>

fref<='0';

dp1<='1';

dp2<='1';

dp3<='1';

endcase;

endprocess;

endBehavioral;

3、门控电路

entitygate_conis

port(Bsignal:

instd_logic;

gate,reset,latch:

outstd_logic);

endgate_con;

architectureBehavioralofgate_conis

signalgate_tmp:

std_logic:

='0';

signallatch_tmp:

std_logic:

='0';

begin

process(Bsignal)

begin

ifrising_edge(Bsignal)then

gate_tmp<=notgate_tmp;

endif;

iffalling_edge(Bsignal)then

latch_tmp<=notgate_tmp;

endif;

endprocess;

gate<=gate_tmp;

latch<=latch_tmp;

reset<=(notBsignal)and(notgate_tmp)and(latch_tmp);

endBehavioral;

4、计数器

entityconunteris

port(count_en:

instd_logic;

Csignal:

instd_logic;

clear:

instd_logic;

carry_out:

outstd_logic;

result:

outstd_logic_vector(3downto0));

endconunter;

architectureBehavioralofconunteris

signalcount:

std_logic_vector(3downto0):

="0000";

signalco_tmp:

std_logic:

='0';

begin

 

process(count_en,Csignal,clear)

begin

ifclear='1'then

count<="0000";

else

ifrising_edge(Csignal)then

ifcount_en='1'then

ifcount="1001"then

count<="0000";

else

count<=count+1;

endif;

endif;

endif;

endif;

endprocess;

process(count,clear)

begin

ifclear='1'then

co_tmp<='0';

else

ifcount="1001"andcount_en='1'then

co_tmp<='1';

else

co_tmp<='0';

endif;

endif;

endprocess;

 

carry_out<=co_tmp;

result<=count;

endBehavioral;

5、锁存器

entitylatchis

port(latchin:

instd_logic;

overin:

instd_logic;

numin1:

instd_logic_vector(3downto0);

numin2:

instd_logic_vector(3downto0);

numin3:

instd_logic_vector(3downto0);

numin4:

instd_logic_vector(3downto0);

numin5:

instd_logic_vector(3downto0);

numin6:

instd_logic_vector(3downto0);

overout:

outstd_logic;

numout1:

outstd_logic_vector(3downto0);

numout2:

outstd_logic_vector(3downto0);

numout3:

outstd_logic_vector(3downto0);

numout4:

outstd_logic_vector(3downto0);

numout5:

outstd_logic_vector(3downto0);

numout6:

outstd_logic_vector(3downto0));

endlatch;

architectureBehavioraloflatchis

begin

process(latchin,overin,numin1,numin2,numin3,numin4,numin5,numin6)

begin

ifrising_edge(latchin)then

numout1<=numin1;

numout2<=numin2;

numout3<=numin3;

numout4<=numin4;

numout5<=numin5;

numout6<=numin6;

overout<=overin;

endif;

endprocess;

endBehavioral;

6、显示控制

entitypresent_conis

port(f1khz:

instd_logic;

q_over:

instd_logic;

freq_value0:

instd_logic_vector(3downto0);

freq_value1:

instd_logic_vector(3downto0);

freq_value2:

instd_logic_vector(3downto0);

freq_value3:

instd_logic_vector(3downto0);

freq_value4:

instd_logic_vector(3downto0);

freq_value5:

instd_logic_vector(3downto0);

dp1:

instd_logic;

dp2:

instd_logic;

dp3:

instd_logic;

G:

outstd_logic;

ledout:

outstd_logic_vector(6downto0);

sel:

outstd_logic_vector(2downto0);

dp:

outstd_logic);

endpresent_con;

architectureBehavioralofpresent_conis

signalswitch:

std_logic_vector(2downto0):

="000";

signalvalue_tmp:

std_logic_vector(3downto0):

="0000";

signalled:

std_logic_vector(6downto0):

="0000000";

signaldp_tmp:

std_logic_vector(2downto0):

="000";

signalhide:

std_logic_vector(5downto0):

="000000";

begin

--clk--

process(f1khz)

begin

ifrising_edge(f1khz)then

ifswitch="101"then

switch<="000";

else

switch<=switch+1;

endif;

endif;

endprocess;

 

--showpreparation--

process(switch,freq_value0,freq_value1,freq_value2,freq_value3,freq_value4,freq_value5)

begin

caseswitchis

when"000"=>value_tmp<=freq_value0;

when"001"=>value_tmp<=freq_value1;

when"010"=>value_tmp<=freq_value2;

when"011"=>value_tmp<=freq_value3;

when"100"=>value_tmp<=freq_value4;

when"101"=>value_tmp<=freq_value5;

whenothers=>value_tmp<="1111";

endcase;

endprocess;

process(value_tmp)

begin

casevalue_tmpis

when"0000"=>led<="1000000";

when"0001"=>led<="1111001";

when"0010"=>led<="0100100";

when"0011"=>led<="0110000";

when"0100"=>led<="0011001";

when"0101"=>led<="0010010";

when"0110"=>led<="0000010";

when"0111"=>led<="1111000";

when"1000"=>led<="0000000";

when"1001"=>led<="0010000";

whenothers=>led<="1111111";

endcase;

endprocess;

dp_tmp<=dp1&dp2&dp3;

--hidevector--

process(dp_tmp,freq_value5,freq_value4,freq_value3,freq_value2)

begin

casedp_tmpis

when"011"=>

iffreq_value5="0000"then

iffreq_value4="0000"then

hide<="110000";

else

hide<="100000";

endif;

else

hide<="000000";

endif;

when"101"=>

iffreq_value5="0000"then

iffreq_value4="0000"then

iffreq_value3="0000"then

hide<="111000";

else

hide<="110000";

endif;

else

hide<="100000";

endif;

else

hide<="000000";

endif;

when"110"=>

iffreq_value5="0000"then

iffreq_value4="0000"then

iffreq_value3="0000"then

iffreq_value2="0000"then

hide<="111100";

else

hide<="111000";

endif;

else

hide<="110000";

endif;

else

hide<="100000";

endif;

else

hide<="000000";

endif;

whenothers=>

hide<="111111";

endcase;

endprocess;

--show--

process(switch,dp_tmp,led,hide,q_over)

begin

ifq_over='1'then

caseswitchis

when"000"=>

ledout<="1000111";

dp<='1';

when"001"=>

ledout<="1000111";

dp<='1';

when"010"=>

ledout<="1000001";

dp<='1';

when"011"=>

ledout<="1001000";

dp<='1';

when"100"=>

ledout<="1111111";

dp<='1';

when"101"=>

ledout<="1111111";

dp<='1';

whenothers=>

ledout<="1111111";

dp<='1';

endcase;

else

caseswit

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

当前位置:首页 > 幼儿教育 > 唐诗宋词

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

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