sulg 发表于 2012-11-30 16:37:03

菜鸟的vhdl问题

process(kz)
begin
for i in 20 downto 1 loop
   if ck='1' then   
      y<=‘1‘;
          wait until ck='0';   
   else null;   
   end if;      
      if ck='0' then   
    y<=‘0’;   
wait until ck='1';      
else null;   
end if;         
   end loop;   
       end process;

我想在在kz变化时让y接的灯闪灭十下然后熄灭,ck是一直都有的基准时钟信号,应该怎么写,我这样写会提示错误
好像是wait until那边的错误,刚学vhdl不太懂{:3_57:}

今世小浪子 发表于 2012-12-5 21:10:37

很少用 wait 和 for 循环

冰峰 发表于 2012-12-11 18:44:41

楼至,好像wait不能被综合,你的具体条件是什么?
在ck上升沿检测kz?发现kz变法就让灯闪烁十下?
下面是我写的,不知对不对,以前学过一段时间,现在忘了很多,可能语法不对。
我感觉我把问题复杂化了,写了这么多代码

process(CK,RST)
begin
if (RST =1) then
    kz_d0 <= '0';
elsif (CK'event and CK = '1') then
    kz_d0 <= kz;
end if;
end process;

process(CK,RST)
begin
if (RST =1) then
    s <= '0';
elsif (CK'event and CK = '1') then
    if (kz != kz_d0) then               --kz变化
      s <= '1';
    else
      s <= '0';
    end if;
end if;
end process;

process(CK,RST)
begin
if (RST =1) then
    count <= '0';                     --定义为0~8的整数信号
elsif (CK'event and CK = '1') then
    if (s = '1')
      if (count = 8) then
      count <= 0;
      else
      count <= count + '1';
      end if;
    else
      count <= '0';
    end if;
end if;
end process;

process(CK,RST)
begin
if (RST =1) then
    y <= '0';
elsif (CK'event and CK = '1') then
    if (count != 0) then
      y <= y + '1';                  --y,二进制,01交替变化
    else
      y <= '0';
    end if;
end if;
end process;
页: [1]
查看完整版本: 菜鸟的vhdl问题