频率计VHDL程序和仿真

上传人:龙*** 文档编号:90651523 上传时间:2019-06-14 格式:DOC 页数:7 大小:133KB
返回 下载 相关 举报
频率计VHDL程序和仿真_第1页
第1页 / 共7页
频率计VHDL程序和仿真_第2页
第2页 / 共7页
频率计VHDL程序和仿真_第3页
第3页 / 共7页
频率计VHDL程序和仿真_第4页
第4页 / 共7页
频率计VHDL程序和仿真_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《频率计VHDL程序和仿真》由会员分享,可在线阅读,更多相关《频率计VHDL程序和仿真(7页珍藏版)》请在金锄头文库上搜索。

1、频率计VHDL程序和仿真数字频率计VHDL程序与仿真一、功能:频率计。具有4位显示,能自动根据7位十进制计数的结果,自动选择有效数据的高4位进行动态显示。小数点表示是千位,即KHz。二、源程序及各模块和主要语句的功能library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity plj is port ( start:in std_logic; -复位信号 clk :in std_logic; -系统时钟 clk1:in std_logic; -被测信号 yy1:out std_logic_vect

2、or(7 downto 0); -八段码 w1 :out std_logic_vector(3 downto 0); -数码管位选信号end plj;architecture behav of PLj issignal b1,b2,b3,b4,b5,b6,b7:std_logic_vector(3 downto 0); -十进制计数器signal bcd:std_logic_vector(3 downto 0); -BCD码寄存器signal q :integer range 0 to 49999999; -秒分频系数 signal qq : integer range 0 to 499999

3、; -动态扫描分频系数signal en,bclk:std_logic; -使能信号,有效被测信号signal sss : std_logic_vector(3 downto 0); -小数点signal bcd0,bcd1,bcd2,bcd3 : std_logic_vector(3 downto 0); -寄存7位十位计数器中有效的高4位数据beginsecond:process(clk) -此进程产生一个持续时间为一秒的的闸门信号 begin if start=1 then q=0; elsif clkevent and clk=1 then if q49999999 then q=q+

4、1; else q=49999999; end if; end if; if q49999999 and start=0 then en=1; else en=0; end if;end process;and2:process(en,clk1) -此进程得到7位十进制计数器的计数脉冲begin bclk=clk1 and en;end process; com:process(start,bclk) -此进程完成对被测信号计脉冲数begin if start=1 then -复位b1=0000;b2=0000;b3=0000;b4=0000;b5=0000;b6=0000;b7=0000;

5、elsif bclkevent and bclk=1 then if b1=1001 then b1=0000; -此IF语句完成个位十进制计数 if b2=1001 then b2=0000; -此IF语句完成百位十进制计数 if b3=1001 then b3=0000; -此IF语句完成千位十进制计数 if b4=1001 then b4=0000; -此IF语句完成万位十进制计数 if b5=1001 THEN b5=0000; -此IF语句完成十万位十进制计数 if b6=1001 then b6=0000; -此IF语句完成百万位十进制计数 if b7=1001 then b7=0

6、000; -此IF语句完成千万位十进制计数 else b7=b7+1; end if; else b6=b6+1; end if; else b5=b5+1; end if; else b4=b4+1; end if; else b3=b3+1; end if; else b2=b2+1; end if; else b10000 then bcd3=b7; bcd2=b6; bcd1=b5; bcd0=b4; sss0000 then bcd3=b6; bcd2=b5; bcd1=b4; bcd0=b3; sss0000 then bcd3=b5; bcd2=b4; bcd1=b3; bcd0

7、=b2; sss=1011; else bcd3=b4; bcd2=b3; bcd1=b2; bcd0=b1; sss=1111; end if; end if; end if;end process;weixuan:process(clk) -此进程完成数据的动态显示begin if clkevent and clk=1 then if qq 99999 then qq=qq+1;bcd=bcd3; w1=0111; if sss=0111 then yy1(0)=0; else yy1(0)=1; end if; elsif qq199999 then qq=qq+1;bcd=bcd2;

8、w1=1011; if sss=1011 then yy1(0)=0; else yy1(0)=1; end if; elsif qq299999 then qq=qq+1;bcd=bcd1; w1=1101; if sss=1101 then yy1(0)=0; else yy1(0)=1; end if; elsif qq399999 then qq=qq+1;bcd=bcd0; w1=1110; if sss=1110 then yy1(0)=0; else yy1(0)=1; end if; else qqyy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)yy1(7 downto 1)=1111111; end case;end process;end behav;三、程序仿真图注:仿真中秒分频为50000,动态显示的分频系数也相应调小。频率计仿真全图频率计仿真-开始计数部分频率计仿真-结束结束、动态显示部分频率计仿真-复位、重新测频部分7 / 7

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号