打印

程序中多个实钟带来的问题分享给大家,警醒后来者

[复制链接]
1209|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
huofeijingfe|  楼主 | 2012-10-24 17:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
FPGA程序设计者,最后是全同步设计,这样所有程序都在主时钟同一个节拍下工作,系统时序分析和统计都有参照,程序稳定不容易出问题。

但是很多初学者由于对这个问题不了解或研究不深入经常写下面的程序:

LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
ENTITY tongbu  IS
        PORT(         
        CLK                        : IN   std_logic;        --晶振时钟
                clks                : IN   std_logic;        --秒脉冲输入
                reset                : IN   std_logic;        
                clk_tb                : OUT STD_LOGIC ;--同步信号输出
                right                : OUT STD_LOGIC ;
                fault                : OUT STD_LOGIC );

END tongbu ;
ARCHITECTURE a OF tongbu IS
SIGNAL s0        : STD_LOGIC ;
SIGNAL s1        : STD_LOGIC ;
SIGNAL s2        : STD_LOGIC ;
signal count :integer range 0 to 255;
signal pps_count :integer range 0 to 8;
signal low_count :integer range 0 to 8;

BEGIN
process(clks,s0)
begin
if(clks'event and clks='1')then
s1<='1';
end if;
if(s0='1')then
s1<='0';
end if;
end process;

process(CLK,clks,s1,count,reset)
begin
if(s1='1')then
if(CLK'event and CLK='1')then
  if(count=255 or (clks='1' and count>25)or reset='0')then
   count<=0;
  else count<=count+1;
end if;
end if;
end if;
end process;

process(clks,count)
begin
if(clks'event and clks='0')then
if(count<25 and s2='0')then
low_count<=low_count+1;
end if;
end if;
end process;

process(low_count)
begin
if(low_count>1)then
s0<='1';
else s2<='1';
end if;
end process;

process(clks,count,pps_count)
begin
if(count>248 and count<252 and pps_count<4)then
if(clks'event and clks='1')then
pps_count<=pps_count+1;
end if;
end if;
end process;

process(pps_count)
begin
if(pps_count>2)then
right<='1';
fault<='0';
elsif(pps_count<3)then
fault<='1';
right<='0';
end if;
end process;

END a;




上面程序写法对器件中D触发器结构和硬件实现非常不了解,产生了门控时钟(GATED CLOCK)。所谓门控时钟就是时钟信号通过逻辑门后去驱动D触发器,这样电路,软件经常不能准确评估延时和建立时间等路径参数。

如果对上面的电路仿真,就会出现下面告警:

  Warning: No clock transition on "count[0]" register due to stuck clock or clock enable

相关帖子

沙发
zrsing| | 2012-10-24 17:30 | 只看该作者
多谢分享

使用特权

评论回复
板凳
GoldSunMonkey| | 2012-10-24 23:46 | 只看该作者
多谢啦。

使用特权

评论回复
地板
jakfens| | 2012-10-25 10:49 | 只看该作者
:D

使用特权

评论回复
5
GoldSunMonkey| | 2012-10-25 17:08 | 只看该作者
:D
jakfens 发表于 2012-10-25 10:49
小狼,你忙啥呢?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

128

帖子

0

粉丝