打印

modelsim仿真计数器的问题

[复制链接]
1856|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wangjun403|  楼主 | 2010-12-29 22:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
为什么在时钟的下降沿,计数值才变化呢?
时钟周期100us
下面是代码
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
--use ieee.std_logic_unsigned.all;

entity cnt6 is
port
(clr,en,clk :in std_logic;
q :out std_logic_vector(2 downto 0)
);
end entity;

architecture rtl of cnt6 is
signal tmp :std_logic_vector(2 downto 0);
begin
process(clk)
-- variable q6:integer;
begin
if(clk'event and clk='1') then
if(clr='0')then
tmp<="000";
elsif(en='1') then
if(tmp="101")then
tmp<="000";
else
tmp<=unsigned(tmp)+'1';
end if;
end if;
end if;
q<=tmp;
-- qa<=q(0);
-- qb<=q(1);
-- qc<=q(2);
end process;
end rtl;

处女贴,恳请大家帮忙下,肯定会及时结贴的

相关帖子

沙发
byeyear| | 2011-1-2 21:42 | 只看该作者
你可以单步跟踪一下看看

使用特权

评论回复
板凳
lelee007| | 2011-1-5 13:16 | 只看该作者
路过,VHDL不会

使用特权

评论回复
地板
sxhhhjicbb| | 2011-1-10 22:29 | 只看该作者
例如,tmp<=unsigned(tmp)+'1';
标准中,tmp时序上是要在下一个if(clk'event and clk='1') then才变成新值,modelsim仿真的时候,半个时钟就有效,以满足建立时间的要求,即下一个时钟来时,此值一定是稳定的,LZ的看到的是对的。。。。。

使用特权

评论回复
5
岚369| | 2011-5-14 19:43 | 只看该作者
刚在学

使用特权

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

本版积分规则

0

主题

629

帖子

1

粉丝