VHDL Plus operator `+` and Downto syntax

fpgavhdl

Considering variable a and b as STD_LOGIC_VECTOR (31 DOWNTO 0) we have a + b as 33 bit result;

How can we get 32 bits out of this?

Does VHDL have something like (a+b)(31 downto 0) or we should store c:= a+b and then get c(31 downto 0)?

Best Answer

If a, b, c are of type std_logic_vector(31 downto 0),

then, c := a + b;
will give the 32 bit answer in c (without carry) as you required.

If you want 33 bit answer in c (where c is std_logic_vector(32 downto 0))

Then c := ('0' & a) + ('0' & b) will give the 33 bit answer.

But you will need ieee.std_logic_unsigned package for adding std_logic_vector using + operator.