Guest
I'm trying to achieve multiply using one or more shift operations. For
example,
A = 5*B can be written as
A = 4*B + B or
A = (B sll 2) + B
Now, B is a signed number, so when I do (B sll 2), the shift operation
doesn't discriminate the sign bit, and I end up losing it (falls off to
the left side).
One solution would be to save the MSb of B, perform 'sll' on the rest,
and concatenate them together. If B were signed(7 downto 0) :
A = ((B(7) & (B(6 downto 0) sll 2)) + B;
Is there a better way to do this, perhaps some built-in function I
couldn't find?
I'm thinking that there has to be an easier way. I'm not concerned
about the overflow (yet). Can anyone help? I'm not that fluent in
VHDL. Thank you.
example,
A = 5*B can be written as
A = 4*B + B or
A = (B sll 2) + B
Now, B is a signed number, so when I do (B sll 2), the shift operation
doesn't discriminate the sign bit, and I end up losing it (falls off to
the left side).
One solution would be to save the MSb of B, perform 'sll' on the rest,
and concatenate them together. If B were signed(7 downto 0) :
A = ((B(7) & (B(6 downto 0) sll 2)) + B;
Is there a better way to do this, perhaps some built-in function I
couldn't find?
I'm thinking that there has to be an easier way. I'm not concerned
about the overflow (yet). Can anyone help? I'm not that fluent in
VHDL. Thank you.