0

I would like to add zero at the lsb (zero padding). my input is

 m  :   IN STD_LOGIC_VECTOR (31 DOWNTO 0);

and another vector (lets say a) that his length is changing all the time.
I didn't manage doing that by using bitwise "OR" because the length is always not the same.

Himanshu
  • 4,327
  • 16
  • 31
  • 39
  • What do you mean by the length of 'a' changing all the time? – scary_jeff Mar 16 '15 at 11:06
  • a is another vector. every time i use this part of the code his length is diffrenet. at the first time it will be 5 bits len and at the second time it will be 22 bits len, etc – johnny_got Mar 16 '15 at 11:20
  • The fastest solution is a barrel shifter in shift-left mode. See other posts for this topic: e.g. http://stackoverflow.com/questions/26551049/vhdl-n-bit-barrel-shifter – Paebbels Mar 16 '15 at 12:44

1 Answers1

0

Assuming you don't know the length of a, but want to zero pad the LSB of the resulting vector b it to length of b.

b(b'left downto b'left - a'left) <= a;
b(b'left - a'left - 1 downto 0) <= (others => '0');

I hope I didn't mix up the - 1.

dieli
  • 179
  • 6