![]() |
|
||||||||||||||
| . 网站首页 . 新闻 . 新品 . 方案 . 专访 . 活动 . DSP . EDA . 评测室 . 技术文库 . 会员区 . 商城 . 服务导航 . 邮购 . 资源 . | ||
|
||
|
|||||
| 采用等精度测频原理的频率计的程序 | |||||
作者:Free 文章来源:Free 点击数: 更新时间:2008-1-3 ![]() |
|||||
|
--功能:4位显示的等精度频率计。 --最后修改日期:2004.4.14。 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity PLJ is port(clk:in std_logic; --基准时钟(10KHz) tclk:in std_logic; --被测信号 start:in std_logic; --复位信号 alarm0,alarm1:out std_logic; --超量程,欠量程显示 dian:out std_logic_vector(3 downto 0); --小数点 data1:out integer range 0 to 9999); --频率数据 end PLJ; architecture behav of PLJ is signal q:integer range 0 to 9999; --预置闸门分频系数 signal q1:integer range 0 to 10000; --被测信号计数器 signal q2:integer range 0 to 20000; --基准信号计数器 signal en,en1:std_logic; --预置闸门,实际闸门 signal qq,qqq:integer range 0 to 200000000; --运算器 signal data0:integer range 0 to 9999; --频率数据中间信号 begin process(clk) --此进程得到一个预置闸门信号 begin if clk'event and clk='1' then if start='1' then q<=0;en<='0'; elsif q=9999 then q<=9999;en<='0'; else q<=q+1;en<='1'; end if; end if; end process; process(tclk) --此进程计被测信号脉冲数,和得到一个实际闸门信号 begin if tclk'event and tclk='1' then if start='1' then q1<=0;en1<='0'; elsif en='1' then q1<=q1+1;en1<='1'; else en1<='0'; end if; end if; end process; process(clk) --此进程完成在实际闸门时间内,计基准脉冲数 begin if clk'event and clk='1' then if start='1' then q2<=0; elsif en1='1' then if q2=20000 then q2<=20000; else q2<=q2+1; end if; end if; end if; end process; process(clk) --此进程完成等精度频率计的运算 begin if clk'event and clk='1' then if start='1' then data0<=0;dian<="0000";alarm0<='0';alarm1<='0';qqq<=0;qq<=00; elsif en1='0' then if q1>=1000 then qq<=q1*10000; --根据q1的大小来判断小数点的位置 if qqq<qq then qqq<=qqq+q2;data0<=data0+1;dian<="0000"; --完成数据运算 elsif data0>=10000 then alarm0<='1'; --超量程显示 else data1<=data0; end if; elsif q1>=100 then qq<=q1*100000; if qqq<qq then qqq<=qqq+q2;data0<=data0+1; elsif data0>=10000 then data1<=1000;dian<="0000"; else data1<=data0;dian<="0010"; end if; elsif q1>=10 then qq<=q1*1000000; if qqq<qq then qqq<=qqq+q2;data0<=data0+1; elsif data0>=10000 then data1<=1000;dian<="0010"; else data1<=data0;dian<="0100"; end if; elsif q1>=1 then qq<=q1*10000000; if qqq<qq then qqq<=qqq+q2;data0<=data0+1; elsif data0>=10000 then data1<=1000;dian<="0100"; else data1<=data0;dian<="1000"; end if; end if; elsif q2>19999 then alarm1<='1'; --欠量程显示 else alarm1<='0'; end if; end if; end process; end behav; |
|||||
| 欢迎点击进入:TI德州中文网 (国内唯一针对TI应用的中文技术网站) 文章录入:admin 责任编辑:admin | |||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | |||||
| 最新热点 | 最新推荐 | 相关文章 | ||
| 基于FPGA的同步测周期高精度… |
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 | | |||
|
|