Zain Rizvi
Zain Rizvi

Reputation: 24636

Concatenating bits in VHDL

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

Upvotes: 17

Views: 174915

Answers (3)

user21246
user21246

Reputation: 1814

Here is an example of concatenation operator:

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;

Upvotes: 12

Justin
Justin

Reputation: 306

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;

Upvotes: 12

user21246
user21246

Reputation: 1814

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

Upvotes: 27

Related Questions