欢迎来到天天文库
浏览记录
ID:56800393
大小:110.00 KB
页数:13页
时间:2020-06-28
《基于fpga的数字秒表.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
数字秒表设计 数字秒表clkkclrrendataout(23..0)数字秒表的设计包括十进制计数器和六进制计数器,然后通过例化组合来得到数字秒表系统,这里首先要得到100Hz的时钟信号秒表计时的最大范围为1小时,精度为0.01秒,秒表可得到计时时间的分、秒、0.1秒、0.01秒等度量,并且各度量可正确进位 十进制计数器clkclrendout(3..0)六进制计数器dout(3..0)clkclren 计数单位及对应输出信号 libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycntshiisport(clk,clr,ena:instd_logic;dout:outstd_logic_vector(3downto0);co:outstd_logic);endcntshi;architectureartofcntshiissignaltmp:std_logic_vector(3downto0);beginprocess(clk,clr,tmp)beginifclr='1'thentmp<="0000";co<='0';elsifclk'eventandclk='1'thenifena='1'then十进制计数器源程序--时钟、复位、计数使能信号--计数输出信号--进位输出信号--定义计数器--复位信号有效--时钟上升沿--计数使能信号 iftmp="1001"thentmp<="0000";co<='1';elsetmp<=tmp+'1';endif;endif;endif;dout<=tmp;endprocess;endart;六进制计数器libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycntliuis--计数器加1--输出计数器的值--计数器满 port(clk,clr,ena:instd_logic;dout:outstd_logic_vector(3downto0);co:outstd_logic);endcntliu;architectureartofcntliuissignalcnt:std_logic_vector(3downto0);beginprocess(clk,clr,cnt)beginifclr='1'thencnt<="0000";co<='0';elsifrising_edge(clk)thenifena='1'thenifcnt="0101"thencnt<="0000";co<='1';elsecnt<=cnt+'1';--复位信号有效--时钟上升沿--允许计数--计数器满--计数器加1--时钟、复位、计数使能信号--定义计数器 endif;endif;endif;dout<=cnt;endprocess;endart;数字秒表顶层模块libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitymiaobiaoisport(clkk:instd_logic;clrr,en:instd_logic;dataout:outstd_logic_vector(23downto0));endmiaobiao;architecturewofmiaobiaois--定义时钟信号,周期为0.01秒--定义复位、计数使能信号--输出计时结果 componentcntliuisport(clk,clr,ena:instd_logic;q:outstd_logic_vector(3downto0);co:outstd_logic);endcomponentcntliu;componentcntshiisport(endart;clk,clr,ena:instd_logic;q:outstd_logic_vector(3downto0);co:outstd_logic);endcomponentcntshi;signalco1,co2,co3,co4,co5:std_logic;begin--定义六进制计数器元件--定义十进制计数器元件--定义计数器元件进位输出信号 u1:cntshiportmap(clkk,clrr,en,dataout(3downto0),co1);u2:cntshiportmap(co1,clrr,en,dataout(7downto4),co2);u3:cntshiportmap(co2,clrr,en,dataout(11downto8),co3);u4:cntliuportmap(co3,clrr,en,dataout(15downto12),co4);u5:cntshiportmap(co4,clrr,en,dataout(19downto16),co5);u6:cntliuportmap(co5,clrr,en,dataout(23downto20));endw;--元件例化语句,通过计数器级联实现数字秒表波形仿真十进制计数器仿真波形 六进制计数器仿真波形秒表仿真波形
此文档下载收益归作者所有
举报原因
联系方式
详细说明
内容无法转码请点击此处