Input vhdl比较新输入和旧输入

Input vhdl比较新输入和旧输入,input,store,vhdl,Input,Store,Vhdl,你是怎么做到的 我对这个很陌生,我相信这很容易,但我似乎不知道怎么做 下面是一些伪代码 port(x,y: in std_logic_vector (2 downto 0) -- 3 bit input that is basically counted eg ("000", "001", "010"... "111", "000" ...) q_out : out integer); -- this is just an example signal temp_q_out: inte

你是怎么做到的

我对这个很陌生,我相信这很容易,但我似乎不知道怎么做

下面是一些伪代码

port(x,y: in std_logic_vector (2 downto 0) -- 3 bit input that is basically counted eg ("000", "001", "010"... "111", "000" ...)
    q_out : out integer); -- this is just an example

signal temp_q_out: integer;

when x (or y) increments -- THIS IS THE PART I CAN'T GET
    temp_q_out <= temp_ q_out + 1;


case temp_q_out is
    when 0 q_out <= 7
    when 1 q_out <= 12
    when 2 q_out <= 4
    when others q_out <= 100
端口(x,y:std_逻辑_向量(2到0)——基本计数的3位输入,例如(“000”、“001”、“010”…“111”、“000”…)
q_out:out整数);--这只是一个例子
信号温度输出:整数;
当x(或y)增加时——这是我无法得到的部分

temp_q_out使用流程。进程像原子语句一样执行。您可以在它们内部使用变量。以下过程监听x和y信号。当其中一个发生更改时,将按顺序执行该过程

process(x, y)
variable tmpX: integer := -1;
variable tmpY: integer := -1;
begin
    if (x = tmpX + 1) or (y = tmpY + 1) then
        temp_q_out <= temp_ q_out + 1;
    tmpX := x;
    tmpY := y;
end process;
过程(x,y)
变量tmpX:integer:=-1;
变量tmpY:integer:=-1;
开始
如果(x=tmpX+1)或(y=tmpY+1),则

temp_q_out我认为没有一种安全的方法可以用异步逻辑来做你想做的事情。假设你想合成这个,你需要一个时钟输入。然后,您可以添加一个进程来存储以前的
x
y
值,并检查新值是否等于旧值。下面是一个例子:

过程(clk)
变量prev_x,prev_y:std_logic_vector(2到0):=(其他=>'0');
开始
如果上升沿(clk),则
如果(x/=prev_x)或(y/=prev_y),则

如果不是合成的话,这是可以的,否则我绝对不会这么做。这将导致闩锁和容易出现故障,我怀疑它是否会像预期的那样工作。
process(clk)
  variable prev_x, prev_y : std_logic_vector(2 downto 0) := (others => '0');
begin
  if rising_edge(clk) then
    if (x /= prev_x) or (y /= prev_y) then
      temp_q_out <= temp_q_out + 1;
    end if;
    prev_x := x;
    prev_y := y;
  end if;
end process;