0

我是 VHDL 新手,对这个设计感到困惑

当 Acknwledgement= '1' 和 clk='1' 然后

计数应该是计数+1;

当确认='0'时,我的时钟总计数值应分配给'输出',然后重置计数='0'和输出='0'。

有人能帮忙吗。提前致谢。

编辑:粘贴在评论中的代码:

library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity acknw is
    port (acknw  : in  std_logic;
          clk    : in  std_logic;
          output : out integer range 0 to 15);
end acknw;
architecture Behavioral of acknw is
begin
    process(clk, acknw) variable c : integer range 0 to 15;
    begin
        if(clk'event and clk = '1') then
            if(acknw = '1') then 
                 c := c+1;
                 output <= c;
            else 
                 c := 0;
                 output <= c;
            end if;
        end if;
    end process;
end Behavioral;
4

1 回答 1

0

从您的评论听起来您想要一个异步确认,请尝试以下操作:

library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity acknw is
    port (acknw  : in  std_logic;
          clk    : in  std_logic;
          output : out integer range 0 to 15);
end acknw;
architecture Behavioral of acknw is
begin
    process(clk, acknw) 
    begin
        if (acknw = '0') then
          output <= 0;
        elsif rising_edge(clk) then
          -- rollover
          if (output /= 15) then
            output <= output + 1;
          else
            output <= 0;
          end if;
        end if;
    end process;
end Behavioral;
于 2012-05-14T22:19:17.620 回答