Forum Discussion
Altera_Forum
Honored Contributor
13 years ago --- Quote Start --- Neither is correct. If a, b, and bp are all std_logic_vector, then you cannot add without converting to signed or unsigned. std_logic_vector is just an array of bits, the compiler does not know how you want to interpret those bits, so you have to tell it using explicit casts/type-conversions.
bp <= std_logic_vector(unsigned(a) + unsigned(b));
where a and b are converted to unsigned, the sum a+b is also unsigned (1-bit wider), and it is converted to std_logic_vector before being assigned to bp (which is also std_logic_vector). Cheers, Dave --- Quote End --- Hai Dave, Then, what the different between bp<=SXT(a,9)+b with bp<=a+b? Or is it there are same actually? Can you give simple example for both line codes? Need helps,thanks in advance