数字跑表(电子科大).doc_第1页
数字跑表(电子科大).doc_第2页
数字跑表(电子科大).doc_第3页
数字跑表(电子科大).doc_第4页
数字跑表(电子科大).doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

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

文档简介

数字跑表设计报告 学院:电子工程学院 学号:2011029180015 姓名:洪娜建 班级:电磁场5班一 系统总体设计设计要求设计一个数字秒表,有6个输出显示,分别为百分之一秒、十分之一秒、秒、十秒、分、十分,系统主要由显示译码器、分频器、十进制计数器和六进制计数器组成。整个秒表还需有一个启动/停止信号和一个复位信号,以便秒表能随意停止及启动。要求:1、跑表精度为0.01秒2、跑表计时范围为:1小时3、设置开始计时/停止计时、复位两个按钮4、显示工作方式:用六位BCD七段数码管显示读数5、扩展功能:锁存控制功能。系统工作原理数字跑表通过系统将48MHz时钟进行分频得到100Hz的秒表时钟,之后通过对时钟信号进行计数得到具体的跑表显示数值,跑表数值作为显示单元电路的输入,显示单元控制数码管动态扫描显示计数因此,系统主要划分为:分频器,计数器,显示控制,开始停在使能控制,清零控制,锁存控制。原理图如下:二 单元电路设计1. 分频器设计思路:输入信号48MHz,将其48000分频可得1KHz信号,再将1KHz信号10分频可得100Hz信号。1KHz用于显示LED扫描,100Hz用于计数器时钟。源程序如下:entity fenpin is Port ( clk : in STD_LOGIC; clk_1k : out STD_LOGIC; clk_100 : out STD_LOGIC);end fenpin;architecture Behavioral of fenpin is signal cnt1:INTEGER RANGE 1 TO 24000;signal cnt2:INTEGER RANGE 1 TO 5;signal clk_1k_temp:STD_LOGIC:=0;signal clk_100_temp:STD_LOGIC:=0;begin process(clk)begin if clkevent and clk=1 then if cnt1=24000 then cnt1=1; clk_1k_temp=not clk_1k_temp;else cnt1=cnt1+1;end if;end if;end process;clk_1k=clk_1k_temp;process(clk_1k_temp)begin if clk_1k_tempevent and clk_1k_temp=1 then if cnt2=5 then cnt2=1; clk_100_temp=not clk_100_temp;else cnt2=cnt2+1;end if;end if;end process;clk_100=clk_100_temp;end Behavioral;2. 计数器实验需要用到2个六进制计数器和4个十进制计数器,本人使用的级联方式为同步级联。十进制计数器的源程序:entity counter10 is Port ( reset : in STD_LOGIC; clk : in STD_LOGIC; carry_in : in STD_LOGIC; carry_out : out STD_LOGIC; cnt_out : out STD_LOGIC_VECTOR (3 downto 0);end counter10;architecture Behavioral of counter10 is signal cnt_temp :STD_LOGIC_VECTOR (3 downto 0):=0000;begin process(reset,clk)begin if reset=0 then cnt_temp=0000; elsif clkevent and clk=1 then if carry_in=1 then if cnt_temp1001 then cnt_temp=cnt_temp+1; else cnt_temp=0000; end if;end if; end if;if carry_in=1 and cnt_temp=1001 then carry_out=1;else carry_out=0;end if;end process;cnt_out=cnt_temp;end Behavioral;仿真结果:六进制计数器的源程序为:entity counter6 is Port ( reset : in STD_LOGIC; clk : in STD_LOGIC; carry_in : in STD_LOGIC; carry_out : out STD_LOGIC; cnt_out : out STD_LOGIC_VECTOR(3 downto 0);end counter6;architecture Behavioral of counter6 is signal cnt_temp:STD_LOGIC_VECTOR(3 downto 0):=0000;begin process(reset,clk)begin if reset=0 then cnt_temp=0000; elsif clkevent and clk=1 then if carry_in=1 then if cnt_temp0101 then cnt_temp=cnt_temp+1; else cnt_temp=0000; end if;end if; end if; if carry_in=1 and cnt_temp=0101 then carry_out=1;else carry_out=0;end if;end process;cnt_out=cnt_temp;end Behavioral;仿真结果:3. 使能控制按一下使能控制键,跑表开始计时,再次按下,跑表暂停计时,且计数器使能端高电平有效。因此程序设计思路为:最初提供一个低电平信号0,按一下使能控制键时,信号翻转位1,开始计时;当再次按下使能控制键时,信号再次翻转,变为0,计时暂停。源程序为:entity enable is Port ( ss : in STD_LOGIC; en : out STD_LOGIC);end enable;architecture Behavioral of enable is signal en_temp:STD_LOGIC:=0;begin process(ss)begin if ssevent and ss=0 then en_temp=not en_temp;end if;end process; en=en_temp;end Behavioral;4. 显示控制显示控制电路根据输入的时钟信号对输入的数据信号进行选择输出,同时输出位选信号控制数码管的动态信号。显示控制模块应包含一个六进制计数器、六选一数据选择器和七段译码器,六进制计数器的时钟信号频率为1KHZ,计数输出作为位选控制信号sel(2:0),数据选择器的地址控制信号为计数输出,数据选择器的数据端为要显示的六位数据mh(3:0),ml(3:0),sh(3:0),sl(3:0),ds(3:0),cs(3:0),根据地址控制信号选择其中一路输出至译码器,译码器的输出作为段选控制信号led(6:0)。源程序为:entity xianshi is Port ( clk : in STD_LOGIC; mh : in STD_LOGIC_VECTOR (3 downto 0); ml : in STD_LOGIC_VECTOR (3 downto 0); sh : in STD_LOGIC_VECTOR (3 downto 0); sl : in STD_LOGIC_VECTOR (3 downto 0); ds : in STD_LOGIC_VECTOR (3 downto 0); cs : in STD_LOGIC_VECTOR (3 downto 0); sel : out STD_LOGIC_VECTOR (2 downto 0); led : out STD_LOGIC_VECTOR (7 downto 0); G : out STD_LOGIC);end xianshi;architecture Behavioral of xianshi is signal sel_temp :STD_LOGIC_VECTOR (2 downto 0);signal led_temp :STD_LOGIC_VECTOR (3 downto 0);begin process(clk)-用时钟信号控制位选begin if clkevent and clk=1 then if sel_temp=101 then sel_temp=000; else sel_temp=sel_temp+1; end if;end if;end process;process(sel_temp,cs,ds,sl,sh,ml,mh)-用位选信号控制段选的输出beginif sel_temp=000 then led_temp=cs;elsif sel_temp=001 then led_temp=ds;elsif sel_temp=010 then led_temp=sl;elsif sel_temp=011 then led_temp=sh;elsif sel_temp=100 then led_temp=ml;else led_temp=mh; end if;end process;process(led_temp)-将段选信号译码begin led=11111111;if led_temp=0000 then led=00000011;elsif led_temp=0001 then led=10011111;elsif led_temp=0010 then led=00100101;elsif led_temp=0011 then led=00001101;elsif led_temp=0100 then led=10011001;elsif led_temp=0101 then led=01001001;elsif led_temp=0110 then led=01000001;elsif led_temp=0111 then led=00011111;elsif led_temp=1000 then led=00000001;elsif led_temp=1001 then led=00001001;end if;end process;G=0;sel=sel_temp;end Behavioral;5. 锁存控制设计思路:在计数器输出和显示器输入之间添加一个缓存装置,按下锁存键时,计数器的输出赋给一个临时变量,这时锁存控制装置的输出等于计数器的输出。而当按下读取键时,之前赋值的缓存就输入给显示装置,显示器显示的是之前锁存的数据。源程序如下:entity latch is Port ( latch : in STD_LOGIC; readlatch : in STD_LOGIC; input1 : in STD_LOGIC_VECTOR (3 downto 0); input2 : in STD_LOGIC_VECTOR (3 downto 0); input3 : in STD_LOGIC_VECTOR (3 downto 0); input4 : in STD_LOGIC_VECTOR (3 downto 0); input5 : in STD_LOGIC_VECTOR (3 downto 0); input6 : in STD_LOGIC_VECTOR (3 downto 0); output1 : out STD_LOGIC_VECTOR (3 downto 0); output2 : out STD_LOGIC_VECTOR (3 downto 0); output3 : out STD_LOGIC_VECTOR (3 downto 0); output4 : out STD_LOGIC_VECTOR (3 downto 0); output5 : out STD_LOGIC_VECTOR (3 downto 0); output6 : out STD_LOGIC_VECTOR (3 downto 0);end latch;architecture Behavioral of latch issignal latch1,latch2,latch3,latch4,latch5,latch6: STD_LOGIC_VECTOR(3 DOWNTO 0):=0000;begin process(latch)beginif latch=0 then latch1=input1;latch2=input2;latch3=input3;latch4=input4;latch5=input5;latch6=input6;end if;end process;process(readlatch)begin if readlatch=0 then output1=latch1; output2=latch2; output3=latch3; output4=latch4; output5=latch5; output6=latch6;else output1=input1;output2=input2;output3=input3;output4=input4;output5=input5;output6=input6;end if;end process;end Behavio

温馨提示

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

评论

0/150

提交评论