打印

quartus VHDL语言仿真问题

[复制链接]
1453|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wdoos|  楼主 | 2012-11-3 17:02 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity vhdlfinal is
  port(clk,en:in std_logic;
       con:buffer std_logic);
end vhdlfinal;
architecture one of vhdlfinal is
signal q:std_logic_vector(5 downto 0);
begin
process(clk,en)
begin
if en='1' then
  if clk'event and clk='1' then q<=q+1;
  end if;
elsif en='0' then
  if (q<5 or q>7) then q<=(others=>'0');
  elsif q=6 then con<=not con;
                      q<=(others=>'0');
  elsif q=7 then con<=not con;
                      q<=(others=>'0');
  else q<=(others=>'0');
  end if;

end if;
end process;
end one;

仿真结果如图所示,我想实现的功能是,在en为1时对时钟进行计数,当en为0时结束并判断计数值决定con是否反转,图中第一段脉冲为6,第二段为7,第三段为9,con在第一段结束时发生反转,功能正常,但是在第二段为7时,con却反转多次,请问这是为什么?还有,我还尝试过(q<8 and q>5)这样的条件,结果相同

相关帖子

沙发
沙河小菜鸟| | 2012-12-22 20:49 | 只看该作者
你的这个程序我仿真过。。。但是基本上没有得到结果。这个因为if语句在这个里面是并行的。

使用特权

评论回复
板凳
resxpl| | 2013-1-16 01:04 | 只看该作者
楼主程序毛病很多. 我做了一个.

library        ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity vhdlfinal is
        port(clk, en: in std_logic;
                con: out std_logic);
end vhdlfinal;

architecture vhdlfinal of vhdlfinal is
begin
s1: process(en, clk)
        variable count: integer range 0 to 15 := 0;
        variable con1: std_logic := '0';
        variable con2: std_logic := '0';
begin
        if en = '0' then
                count := 0;       
                con1 := con2;
        elsif clk'event and clk = '1' then
                if count = 5 or count = 6 then
                        con2 := not con1;
                else
                        con2 := con1;
                end if;                  
               
                if count /= 15 then
                        count := count + 1;
                end if;
        end if;
       
        con <= con1;
end process;

end vhdlfinal;

res1.JPG (23.41 KB )

res1.JPG

使用特权

评论回复
地板
resxpl| | 2013-1-16 01:06 | 只看该作者
其实,我做的这个也是有点缺陷. 主要是为了让entity定义一致.
实际上,加一个复位是比较必要的. 用于为所有信号设定初始值.

使用特权

评论回复
5
GoldSunMonkey| | 2013-1-16 23:50 | 只看该作者
大家很热情嘛

使用特权

评论回复
6
星星之火红| | 2013-1-17 20:37 | 只看该作者
GoldSunMonkey 发表于 2013-1-16 23:50
大家很热情嘛

我也有热情啊

使用特权

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

本版积分规则

15

主题

46

帖子

1

粉丝