在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2051|回复: 0

[求助] 关于fpga测占空比的问题

[复制链接]
发表于 2014-5-7 00:23:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本人用FPGA和51单片机分别对同一脉冲信号测量占空比,结果单片机测的正确,fpga测量一直不对,求大神们指点一下,fpga程序如下:library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity zhankong is
port( clk10m,datain: in std_logic;
            dataout: out integer   
     );
end entity zhankong;

architecture run of zhankong is
signal x1,y1:integer range 0 to 50000000;
begin

q:process(clk10m)            
variable y: integer range 0 to 50000000;
begin
  if(clk10m'event and clk10m='1')  then   
     if(datain='0') then     
        y:=y+1;
     elsif (y>0) then
        y1<=y;
         y:=0;
     end if;   
   end if;
end process;

q1:process(clk10m)            
variable x: integer range 0 to 50000000;
begin
  if(clk10m'event and clk10m='1')  then  
     if(datain='1') then  
        x:=x+1;
     elsif (x>0) then
        x1<=x;
        x:=0;
     end if;
   end if;
end process;

q2:process(x1,y1)
  begin
     if(clk10m'event and clk10m='1')  then
         dataout<=x1/(x1+y1);     --dataout记为占空比
     end if;
end process;   
end architecture run;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-29 01:40 , Processed in 0.024781 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表