关于硬件:VHDL:std_logic信号的”其他类”命令

VHDL: “others-like” command for std_logic signals

我想编写一个代码,其中我的W_EN(std_logic)信号根据需要设置为1(如果满足某些条件),否则设置为零(如果没有特别指定)。如果W_EN是std_logic_vector,则可以通过这种方式使用"其他"语句来执行此操作(在示例代码中," W_EN"称为" one_if_one"):

1
2
3
4
5
6
7
8
9
10
signal cnt : unsigned (1 downto 0); --incremented at every clk_cycle
signal one_if_one : std_logic;

process (cnt)
begin
one_if_one <= (others => '0');
if (cnt ="01") then
 one_if_one <= '1';
end if;
end process;

但是由于W_EN只是一个位,因此不能将" others"与它一起使用。
因此,我想问您是否有某种方法可以实现"如果在过程中没有指定不同的情况,则设置为零"命令。

PS:我知道我可以简单地编写if的else分支,但是我不想这样做,因为这对我的真实代码会造成更多问题。

PPS:我目前发现的唯一解决方案是替换以下行:

1
one_if_one <= (others => '0');

1
 one_if_one <= 'L';

但是这将具有不同的含义,因为"其他人"施加的零是一个很强的数字。

在此先感谢您的帮助。


您不需要在这里做任何特别的事情。如果在特定过程中多次分配了信号,则最后一次分配是实际分配的值。

1
2
3
4
5
6
7
process (cnt)
begin
  one_if_one <= '0';
  if (cnt ="01") then
    one_if_one <= '1';
  end if;
end process;

等同于

1
2
3
4
5
6
7
8
process (cnt)
begin
  if (cnt ="01") then
    one_if_one <= '1';
  else
    one_if_one <= '0';
  end if;
end process;

您尝试使用的others语法专门用于分配数组类型,因此与std_logic类型的对象无关。