电子科技大学-电子技术实验-FPGA-频率计-实验报告_第1页
电子科技大学-电子技术实验-FPGA-频率计-实验报告_第2页
电子科技大学-电子技术实验-FPGA-频率计-实验报告_第3页
电子科技大学-电子技术实验-FPGA-频率计-实验报告_第4页
电子科技大学-电子技术实验-FPGA-频率计-实验报告_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选优质文档-倾情为你奉上精选优质文档-倾情为你奉上专心-专注-专业专心-专注-专业精选优质文档-倾情为你奉上专心-专注-专业现代电子技术综合实验论文报告XX XXX中文摘要摘 要:随着电子信息产业的不断发展,信号频率的测量在科技研究和实际应用中的作用日益重要。传统的频率计通常是用很多的逻辑电路和时序电路来实现的,这种电路一般运行缓慢,而且测量频率的范围比较小。考虑到上述问题,本文设计一个基于FPGA技术的数字频率计。首先,我们把方波信号送入计数器里进行计数,获得频率值;最后把测得的频率数值送入显示电路里进行显示。本文从频率计的具体设计触发,详细阐述了基于FPGA的数字频率计的设计方案,设计了

2、各模块的代码,并对硬件电路进行了仿真。关键词:FPGA,VHDL,频率计,测量引言随着电子信息产业的发展,信号作为其最基础的元素,其频率的测量在科技研究和实际应用中的作用日益重要,而且需要测频的范围也越来越宽。传统的频率计通常采用组合电路和时序电路等大量的硬件电路构成,产品不但体积较大,运行速度慢,而且测量范围低,精度低。因此,随着对频率测量的要求的提高,传统的测频的方法在实际应用中已不能满足要求。因此我们需要寻找一种新的测频的方法。随着FPGA技术的发展和成熟,用FPGA来做为一个电路系统的控制电路逐渐显示出其无与伦比的优越性。因此本采用FPGA来做为电路的控制系统,设计一个能测量10Hz到

3、100MHz的数字频率计。用FPGA来做控制电路的数字频率计测量频率精度高,测量频率的范围得到很大的提高。项目任务与设计思路实验项目数字频率计的设计实验指标被测输入信号:方波测试频率范围为:10Hz100MHz 量程分为三档:第一档:闸门时间为1S时,最大读数为999.999KHz 第二档:闸门时间为0.1S时,最大读数为9999.99KHz 第三档:闸门时间为0.01S时,最大读数为99999.9KHz显示工作方式:a、用六位BCD七段数码管显示读数。 b、采用记忆显示方法 c、实现对高位无意义零的消隐。 实验思路根据实验指标,将电路设计分成6个模块:分频器,闸门选择,门控电路,计数器,锁存

4、器,显示控制。基于VHDL方法的设计方案设计方框图具体说明石英振荡器: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有效而其他两个

5、无效时,选择频率输出100Hz信号,dp1,dp2,dp3分别输出1,1,0。门控电路:根据选择频率信号产生闸门信号(计数器使能信号),清零信号,锁存使能信号,各信号的时序关系如图所示:计数器:考虑采用6个10进制计数器同步级联的方法。锁存器:门控电路产生的锁存使能信号的上升沿触发。扫描显示控制子系统:考虑该系统由三部分组成:预显示部分,消隐部分,显示部分。预显示部分:设计一个选择信号switch负责选择对应的LED灯(根据1kHz),并根据传来的数据,产生对应的数码管使能信号序列led(6:0)。消隐部分:设计一个信号hide(5:0),该信号的每一位分别代表一个LED灯,若该信号某一位为1

6、,则对应的LED灯消隐。hide信号的赋值根据dp1,dp2,dp3的值以及高位的数据是否为零决定。显示部分,设置一个使能输出信号G,并令它为低电平,根据hide信号和led信号以及dp1,dp2,dp3信号决定最终的输出。系统电路设计系统单元模块设计分频器entity freq_divider isport(clkin: in std_logic; clkout1: out std_logic; clkout10: out std_logic; clkout100: out std_logic; clkout1k: out std_logic);end freq_divider;archit

7、ecture Behavioral of freq_divider issignal clkcnt1: integer range 0 to :=0;signal clkcnt10: integer range 0 to :=0;signal clkcnt100: integer range 0 to :=0;signal clkcnt1k: integer range 0 to 48000:=0;signal clk1,clk10,clk100,clk1k: std_logic:=1; beginfc1: process(clkin) begin if rising_edge(clkin)

8、then if clkcnt1= then clkcnt1=1; clk1= not clk1; else clkcnt1=clkcnt1+1; end if; end if; end process; fc10: process(clkin) begin if rising_edge(clkin) then if clkcnt10= thenclkcnt10=1;clk10= not clk10; else clkcnt10=clkcnt10+1;end if; end if; end process; fc100: process(clkin) begin if rising_edge(c

9、lkin) then if clkcnt100= then clkcnt100=1; clk100= not clk100; else clkcnt100=clkcnt100+1; end if; end if; end process; fc1k: process(clkin) begin if rising_edge(clkin) then if clkcnt1k=24000 thenclkcnt1k=1;clk1k= not clk1k; else clkcnt1k=clkcnt1k+1;end if; end if; end process;- assignmentclkout1=cl

10、k1;clkout10=clk10;clkout100=clk100;clkout1k=clk1k;end Behavioral;闸门选择entity gate_sel isport(se1: in std_logic; se10: in std_logic; se100: in std_logic; f1: in std_logic; f10: in std_logic; f100: in std_logic; fref: out std_logic; dp1: out std_logic; dp2: out std_logic; dp3: out std_logic);end gate_s

11、el;architecture Behavioral of gate_sel issignal sel: std_logic_vector(2 downto 0):=000;beginselfref=f1;dp1=0;dp2=1;dp3 fref=f10;dp1=1;dp2=0;dp3fref=f100;dp1=1;dp2=1;dp3fref=0;dp1=1;dp2=1;dp3=1;end case;end process;end Behavioral;门控电路entity gate_con isport(Bsignal: in std_logic; gate,reset,latch: out

12、 std_logic);end gate_con;architecture Behavioral of gate_con issignal gate_tmp: std_logic:=0;signal latch_tmp: std_logic:=0;beginprocess(Bsignal) begin if rising_edge(Bsignal) then gate_tmp= not gate_tmp;end if; if falling_edge(Bsignal) then latch_tmp= not gate_tmp;end if;end process;gate=gate_tmp;l

13、atch=latch_tmp;reset=(not Bsignal)and(not gate_tmp)and(latch_tmp);end Behavioral;计数器entity conunter isport(count_en: in std_logic; Csignal: in std_logic; clear: in std_logic; carry_out:out std_logic; result: out std_logic_vector(3 downto 0);end conunter;architecture Behavioral of conunter is signal

14、count: std_logic_vector(3 downto 0):=0000; signal co_tmp: std_logic:=0;beginprocess(count_en,Csignal,clear)beginif clear=1 thencount=0000;elseif rising_edge(Csignal) thenif count_en=1 thenif count=1001 thencount=0000;else count=count+1;end if;end if;end if;end if;end process;process(count,clear)begi

15、nif clear=1 thenco_tmp=0;elseif count=1001 and count_en=1 thenco_tmp=1;elseco_tmp=0;end if;end if;end process;carry_out=co_tmp;result=count;end Behavioral;锁存器entity latch isport(latchin: in std_logic; overin: in std_logic; numin1: in std_logic_vector(3 downto 0); numin2: in std_logic_vector(3 downto

16、 0); numin3: in std_logic_vector(3 downto 0); numin4: in std_logic_vector(3 downto 0); numin5: in std_logic_vector(3 downto 0); numin6: in std_logic_vector(3 downto 0); overout: out std_logic; numout1: out std_logic_vector(3 downto 0); numout2: out std_logic_vector(3 downto 0); numout3: out std_logi

17、c_vector(3 downto 0); numout4: out std_logic_vector(3 downto 0); numout5: out std_logic_vector(3 downto 0); numout6: out std_logic_vector(3 downto 0);end latch;architecture Behavioral of latch isbeginprocess(latchin,overin,numin1,numin2,numin3,numin4,numin5,numin6)begin if rising_edge(latchin) thenn

18、umout1=numin1;numout2=numin2;numout3=numin3;numout4=numin4;numout5=numin5;numout6=numin6;overout=overin;end if;end process;end Behavioral;显示控制entity present_con isport(f1khz: in std_logic; q_over: in std_logic; freq_value0: in std_logic_vector(3 downto 0); freq_value1: in std_logic_vector(3 downto 0

19、); freq_value2: in std_logic_vector(3 downto 0); freq_value3: in std_logic_vector(3 downto 0); freq_value4: in std_logic_vector(3 downto 0); freq_value5: in std_logic_vector(3 downto 0); dp1: in std_logic; dp2: in std_logic; dp3: in std_logic; G: out std_logic; ledout: out std_logic_vector(6 downto

20、0); sel: out std_logic_vector(2 downto 0); dp: out std_logic);end present_con;architecture Behavioral of present_con issignal switch: std_logic_vector(2 downto 0):=000;signal value_tmp: std_logic_vector(3 downto 0):=0000;signal led: std_logic_vector(6 downto 0):=;signal dp_tmp: std_logic_vector(2 do

21、wnto 0):=000;signal hide: std_logic_vector(5 downto 0):=;begin- clk -process(f1khz)beginif rising_edge(f1khz) thenif switch=101 thenswitch=000;elseswitch value_tmp value_tmp value_tmp value_tmp value_tmp value_tmp value_tmp led led led led led led led led led led led = ;end case;end process;dp_tmpif

22、 freq_value5=0000 thenif freq_value4=0000 thenhide=;elsehide=;end if;elsehideif freq_value5=0000 thenif freq_value4=0000 then if freq_value3=0000 then hide=;elsehide=;end if;elsehide=;end if;elsehideif freq_value5=0000 thenif freq_value4=0000 then if freq_value3=0000 then if freq_value2=0000 then hi

23、de=;else hide=;end if;else hide=;end if;elsehide=;end if;else hidehideledout=;dpledout=;dpledout=;dpledout=;dpledout=;dpledout=;dpledout=;dpif hide(0)=1 thenledout=;dp=1;elseledout=led;dpif hide(1)=1 thenledout=;dp=1;elseledout=led;if dp_tmp=110 thendp=0;elsedpif hide(2)=1 thenledout=;dp=1;elseledou

24、t=led;if dp_tmp=101 thendp=0;elsedpif hide(3)=1 thenledout=;dp=1;elseledout=led;if dp_tmp=011 thendp=0;elsedpif hide(4)=1 thenledout=;dp=1;elseledout=led;dpif hide(5)=1 thenledout=;dp=1;elseledout=led;dpledout=;dp=1;end case;end if;end process;sel=switch;G=0;end Behavioral;系统硬件实现与调试管脚分配:NET clk LOC

25、= T8;NET dp LOC = C11;NET en LOC = D7;NET led LOC = B14;NET led LOC = A13;NET led LOC = C13;NET led LOC = C12;NET led LOC = A12;NET led LOC = B12;NET led LOC = A11;NET sel LOC = F8;NET sel LOC = D8;NET sel LOC = E7;NET sig_in LOC = C16;NET sel1 LOC = L10;NET sel10 LOC = F10;NET sel100 LOC = F9;仿真:分频

26、器processbeginclkin=1;wait for 1 ps;clkin=0;wait for 1 ps;end process;闸门选择processbeginse1=1;se10=0;se100=0;wait;end process;processbeginf1=1;wait for 100 ps;f1=0;wait for 100 ps;end process;processbeginf10=1;wait for 50 ps;f10=0;wait for 50 ps;end process;processbeginf100=1;wait for 10 ps;f100=0;wait

27、 for 10 ps;end process;门控电路processbeginBsignal=0;wait for 100 ps;Bsignal=1;wait for 100 ps;end process;计数器processbegincount_en=1;wait;end process;processbeginCsignal=1;wait for 10 ps;Csignal=0;wait for 10 ps;end process;processbeginclear=0;wait for 10 us;clear=1;wait for 10 ps;end process;锁存器processbeginlatchin=0;wait for 400 ps;latchin=1;wait for 100 ps;end process;processbeginoverin=0;wait;end process;processbeginnumin1=0001;wait for 10 ps;numin1=0000;wait for 10 ps;end process;processbeginnumin2=0010;wait for 20 ps;numin2=0100;wait for 20 ps;end proc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论