EDA课程设计数字频率计_第1页
EDA课程设计数字频率计_第2页
EDA课程设计数字频率计_第3页
EDA课程设计数字频率计_第4页
EDA课程设计数字频率计_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

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

文档简介

1、eda课程设计报告题 目: 数字频率计 姓 名: 院 系: 电气学院 专业: 电子信息工程 指导教师: 完成时间: 2012年 6 月5 日目 录1 课程设计题目、内容与要求 1.1 设计内容1.2 具体要求2 系统设计 2.1 设计思路2.2 系统原理与设计说明3 系统实现 4 系统仿真 5硬件验证(操作)说明6总结 7 参考书目 1 课程设计题目、内容与要求1.1课程设计的题目:数字频率计设计1.2课程设计内容:(1)设计一个能测量方波信号的频率计;(2)测量范围是0-999999hz;(3)结果用十进制数显示。2 系统设计2.1设计思路:2.1.1 数字频率计是一种用十进制数字显示被测信

2、号频率的数字测量仪器.它的基本功能是测量方波信号及其他各种单位时间内变化的物理量。本数字频率计采用自顶向下的设计思想,通过闸门提供的1s闸门时间对被测信号进行计数及测出的被测信号的频率,测出的频率再通过译码器译码后输出给显示器显示。根据系统设计的要求,数字频率计的电路原理框图如下:4位十进制计数器锁存电路译码电路计数器闸门控制电路片选电路数据选择电路led数码显示待测输入信号4mhz时钟4mhz时钟图1 数字频率计电路原理框图2.2 系统原理与设计说明系统各个模块的功能如下:221标准时钟发生电路模块借用实验板上标准时钟发生电路,为计数闸门控制电路提供一个标准8hz信号。222 计数器闸门控制

3、电路模块计数器闸门控制电路就是产生三个控制信号,即计数器复位信号、4位十进制计数器允许计数信号、锁存信号。2.2.3锁存电路模块锁存电路就是为了让led数码管在信号来临之前保持计数值不变。2.2.4计数器复位电路模块计数器复位电路是让频率计恢复到计数初始态。2.2.5 led数码管驱动电路模块led数码管驱动电路就是为led数码管提供驱动电压。 3系统实现此部分先讲各个模块再讲模块联调的实现。3.1各部分模块的源程序 模块 fen 见图 1.1 ,通过对 4mhz 时钟进行分频以获得 0.5 hz 时钟,为核心模块 corna 提供 1 的闸门时间。library ieee; use ieee

4、.std_logic_1164.all; entity fen is port(clk:in std_logic; q:out std_logic); end fen;   architecture fen_arc of fen is begin process(clk) variable cnt: integer range 0 to 3999999; variable x:std_logic; begin if clk'event and clk='1'then if cnt<3999999 then cnt:=cnt+1; else cnt:=0;

5、 x:=not x; end if; end if; q<=x; end process; end fen_arc; 模块 sel见图1.2,该模块产生数码管的片选信号。library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity selx is port(clk:in std_logic; sel:inout std_logic_vector(2 downto 0); end selx;   architecture sel_arc of sexl is begin pro

6、cess(clk) variable cnt:std_logic_vector(2 downto 0); begin if clk'event and clk='1'then cnt:=cnt+1; end if; sel<=cnt; end process; end sel_arc; 核心模块 corna见图1.3,该模块是整个程序的核心,它能在 1 的闸门时间里完成对被测信号频率计数的功能,并通过选择输出数据实现自动换档的功能。library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsig

7、ned.all; entity corna is port(clr,sig,door:in std_logic; alm:out std_logic; q3,q2,q1,q0,dang:out std_logic_vector(3 downto 0); end corna;   architecture corn_arc of corna is begin process(door,sig) variable c0,c1,c2,c3,c4,c5,c6:std_logic_vector(3 downto 0); variable x:std_logic; begin if sig

8、9;event and sig='1'then if door='1'then if c0<"1001"then c0:=c0+1; else c0:="0000" if c1<"1001"then c1:=c1+1; else c1:="0000" if c2<"1001"then c2:=c2+1; else c2:="0000" if c3<"1001"then c3:=c3+1; else c

9、3:="0000" if c4<"1001"then c4:=c4+1; else c4:="0000" if c5<"1001"then c5:=c5+1; else c5:="0000" if c6<"1001"then c6:=c6+1; else c6:="0000" alm<='1' end if; end if; end if; end if; end if; end if; end if; else i

10、f clr='0'then alm<='0' end if; c6:="0000" c5:="0000" c4:="0000" c3:="0000" c2:="0000" c1:="0000" c0:="0000" end if; if c6/="0000"then q3<=c6; q2<=c5; q1<=c4; q0<=c3; dang<="0100&quo

11、t; elsif c5/="0000"then q3<=c5; q2<=c4; q1<=c3; q0<=c2; dang<="0011" elsif c4/="0000"then q3<=c4; q2<=c3; q1<=c2; q0<=c1; dang<="0010" elsif c3/="0000"then q3<=c3; q2<=c2; q1<=c1; q0<=c0; dang<="0001&

12、quot; end if; end if; end process; end corn_arc; 模块 lock见图1.4,该模块实现锁存器的功能,在信号l的下降沿到来时将信号a4、a3、a2、a1锁存。library ieee; use ieee.std_logic_1164.all; entity lock is port(l:in std_logic; a4,a3,a2,a1,a0:in std_logic_vector(3 downto 0); q4,q3,q2,q1,q0:out std_logic_vector(3 downto 0); end lock; architecture

13、 lock_arc of lock is begin process(l) variable t4,t3,t2,t1,t0:std_logic_vector(3 downto 0); begin if l'event and l='0'then t4:=a4; t3:=a3; t2:=a2; t1:=a1; t0:=a0; end if; q4<=t4; q3<=t3; q2<=t2; q1<=t1; q0<=t0; end process; end lock_arc; 模块 ch见图1.5,该模块对应于数码管片选信号,将相应通道的数据输出

14、,其中档位也通过显示。 library ieee; use ieee.std_logic_1164.all;   entity ch is port(sel:in std_logic_vector(2 downto 0); a3,a2,a1,a0,dang:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0); end ch;   architecture ch_arc of ch is begin process(sel) begin case sel is when"000&qu

15、ot;=>q<=a0; when"001"=>q<=a1; when"010"=>q<=a2; when"011"=>q<=a3; when"111"=>q<=dang; when others=>q<="1111" end case; end process; end ch_arc; 6模块 disp见图1.6,该模块为4线七段译码器。 library ieee; use ieee.std_logic_1164.all;

16、  entity disp is port(d:in std_logic_vector(3 downto 0); q:out std_logic_vector(6 downto 0); end disp;   architecture disp_arc of disp is begin process(d) begin case d is when "0000"=>q<="0111111" when "0001"=>q<="0000110" when "0010

17、"=>q<="1011011" when "0011"=>q<="1001111" when "0100"=>q<="1100110" when "0101"=>q<="1101101" when "0110"=>q<="1111101" when "0111"=>q<="0100111" whe

18、n "1000"=>q<="1111111" when "1001"=>q<="1101111" when others=>q<="0000000" end case; end process; end disp_arc;3.17 整个系统的顶层设计模块该部分讲述用元件例化的方法来实现模块联调library ieee;use ieee.std_logic_1164.all;entity hql is port(clr,sig,clk:in std_logic;

19、 alm:out std_logic;q:out std_logic_vector(6 downto 0);sel:inout std_logic_vector(2 downto 0);end hql;architecture sd of hql iscomponent fenport(clk:in std_logic;q:out std_logic);end component;component selxport(clk:in std_logic;sel:inout std_logic_vector(2 downto 0);end component;component cornaport

20、(clr,sig,door:in std_logic;alm:out std_logic;q3,q2,q1,q0,dang:out std_logic_vector(3 downto 0);end component;component lockport(l:in std_logic;a4,a3,a2,a1,a0:in std_logic_vector(3 downto 0); q4,q3,q2,q1,q0:out std_logic_vector(3 downto 0); end component;component chport(sel:in std_logic_vector(2 dow

21、nto 0); a3,a2,a1,a0,dang:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0);end component;component dispport(d:in std_logic_vector(3 downto 0); q:out std_logic_vector(6 downto 0); end component;signal qq:std_logic;signal qq3,qq2,qq1,qq0,qqdang:std_logic_vector(3 downto 0);signal tt4

22、,tt3,tt2,tt1,tt0:std_logic_vector(3 downto 0);signal ww:std_logic_vector(3 downto 0);beginu1:fen port map(clk=>clk,q=>qq);u2:selx port map(clk=>clk,sel=>sel);u3:corna port map(clr=>clr,sig=>sig,door=>qq,alm=>alm,q3=>qq3,q2=>qq2,q1=>qq1,q0=>qq0,dang=>qqdang);u4:

23、lock port map(l=>qq,a4=>qq3,a3=>qq3,a2=>qq2,a1=>qq1,a0=>qqdang,q4=>tt4,q3=>tt3,q2=>tt2,q1=>tt1,q0=>tt0); u5:ch port map(sel=>sel,a3=>tt4,a2=>tt3,a1=>tt2,a0=>tt1,dang=>tt0,q=>ww);u6:disp port map(d=>ww,q=>q);end sd;本部分讲述的是用图形的方法来实现模块联调,在mux plusii中现将编译好的各模块生成为图形(filecreat d

温馨提示

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

评论

0/150

提交评论