Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

16-bit bitwise and in VHDL?

If I needed to perform a bitwise AND operation of two 16bit inputs and obtain a 16bit output in VHDL, would I be able to just AND the two inputs and store the result as the output vector? Or would I need to loop through each bit of the inputs, AND them, then store the result in the output vector? Would this work similarly for operations like or and xor?

like image 873
programmr Avatar asked Mar 12 '23 23:03

programmr


1 Answers

The "and" operator is overloaded in the std_logic_1164 package for std_logic, std_ulogic, std_logic_vector, and std_ulogic_vector (the types typically used). It is also defined for bit and bit_vector (as well as signed and unsigned).

So it is as straightforward as just applying the "and"operator. For example:

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;
like image 61
PlayDough Avatar answered Mar 24 '23 22:03

PlayDough