采用等精度测频原理的频率计的程序与仿真

 2 E币 
成为会员,免费下载资料
文件大小:120.44 KB 上传者:龙芯 时间:2008-10-02 20:46:03 下载量:14
4位显示的等精度频率计
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            elsif data0>=10000 then alarm0<='1';                          --超量程显示         
           else data1<=data0;
           end if;
        elsif q1>=100 then qq<=q1*100000;
           if qqq            elsif data0>=10000 then data1<=1000;dian<="0000";  
           else data1<=data0;dian<="0010";
           end if;
        elsif q1>=10 then qq<=q1*1000000;
           if qqq            elsif data0>=10000 then data1<=1000;dian<="0010";  
           else data1<=data0;dian<="0100";
           end if;
        elsif q1>=1 then qq<=q1*10000000;
           if qqq            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;

等精度频率计仿真图
说明:小数点dian在en1的下降沿就输出,在某些特殊情况(1000tclk=clk仿真图所示),只有当数据转换完成时,小数点dian的信号才能保证正确。用数据作为闸门来控制小数点dian信号输出,这部分可以在译码部分完成。

等精度频率计仿真图—欠量程

等精度频率计仿真图—超量程

等精度频率计仿真图—5tclk=clk

等精度频率计仿真图—9tclk=clk

等精度频率计仿真图—50tclk=clk

等精度频率计仿真图—80tclk=clk

等精度频率计仿真图—300tclk=clk

等精度频率计仿真图—1000tclk=clk

等精度频率计仿真图—5000tclk=clk

等精度频率计仿真图—6000tclk=clk

等精度频率计仿真图—10000tclk=clk
展开
折叠
559
评论
共 0 个
内容存在敏感词
    易百纳技术社区暂无数据
相关资料
关于作者
易百纳技术社区
龙芯
贡献资料 1
易百纳技术社区 我上传的资料
登录查看
我赚取的积分
登录查看
我赚取的收益
登录查看
上传资料 赚取积分兑换E币
易百纳技术社区
删除原因
广告/SPAM
恶意灌水
违规内容
文不对题
重复发帖
置顶时间设置
结束时间
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-资料模块

审核失败

失败原因
备注
易百纳技术社区