在VHDL中按位16位?

pro*_*mmr 3 vhdl logical-operators

如果我需要对两个16位输入执行按位与运算并在VHDL中获得16位输出,我是否可以对两个输入进行与运算并将结果存储为输出向量?还是我需要遍历输入的每一位,然后将它们与输入,然后将结果存储在输出向量中?对于像or或xor这样的操作,是否会类似地工作?

Pla*_*ugh 6

该“和”操作员在重载std_logic_1164std_logicstd_ulogicstd_logic_vector,和std_ulogic_vector(通常使用的类型)。还为bitbit_vector(以及signedunsigned)定义了它。

因此,这与应用“ and”运算符一样简单。例如:

architecture rtl of test is
  signal a : std_logic_vector(15 downto 0);
  signal b : std_logic_vector(15 downto 0);
  signal y : std_logic_vector(15 downto 0);
begin
  y <= a and b; -- Or 'y <= a xor b;' or 'y <= a or b;', etc
end architecture rtl;
Run Code Online (Sandbox Code Playgroud)