views:

4555

answers:

3

Hi,

How do you concatenate bits in VHDL? I'm trying to use the following code:

Case b0 & b1 & b2 & b3 is ...

and it throws an error

Thanks

+5  A: 

The concatenation operator '&' is allowed on the right side of the signal assignment operator '<=', only

It works for variable assignments `:=` as well.. see other answers
Martin Thompson
+4  A: 

Here is an example

architecture EXAMPLE of CONCATENATION is
   signal Z_BUS : bit_vector (3 downto 0);
   signal A_BIT, B_BIT, C_BIT, D_BIT : bit;

begin

   Z_BUS <= A_BIT & B_BIT & C_BIT & D_BIT;

end EXAMPLE;
+1  A: 

You are not allowed to use the concatenation operator with the case statement. One possible solution is to use a variable within the process:

process(b0,b1,b2,b3)
   variable bcat : std_logic_vector(0 to 3);
begin
   bcat := b0 & b1 & b2 & b3;
   case bcat is
      when "0000" => x <= 1;
      when others => x <= 2;
   end case;
end process;
Justin