- Joined
- Jul 10, 2010
- Messages
- 4
- Reaction score
- 0
Dear friends,
i have to design a structure in which i have to implement some multiplications and additions/subtractions. for multiplications, i am simply using the shift-add tecchnique. e.g. if i have to multiply 51 (which is constant) with an incoming number e.g. 'a' then i am doing like, (a<<5)+(a<<4)+(a<<1)+a. it is OK for a positive number. but i want to know that if the incoming number is negative e.g. in my case it is -32 and i am using 10 bits to represent it, what should i do in order to maintain the rules of multiplications that a +*+=+, +*-=- etc. i myself tried to do a little technique but it is not efficient. e.g. i am saving the MSB of the incoming number in a temporary std_logic. then after shifts and adds, i am concatenating the inverted sign_bit with the result. but here i have a problem of the incoming number is zero. in this case the result must be 0 but after concatenating a '1' with it, makes it something else.
please guide me in this regard. i need a little detail because i have worked on it for the last 2 days but to now avail.
regards
i have to design a structure in which i have to implement some multiplications and additions/subtractions. for multiplications, i am simply using the shift-add tecchnique. e.g. if i have to multiply 51 (which is constant) with an incoming number e.g. 'a' then i am doing like, (a<<5)+(a<<4)+(a<<1)+a. it is OK for a positive number. but i want to know that if the incoming number is negative e.g. in my case it is -32 and i am using 10 bits to represent it, what should i do in order to maintain the rules of multiplications that a +*+=+, +*-=- etc. i myself tried to do a little technique but it is not efficient. e.g. i am saving the MSB of the incoming number in a temporary std_logic. then after shifts and adds, i am concatenating the inverted sign_bit with the result. but here i have a problem of the incoming number is zero. in this case the result must be 0 but after concatenating a '1' with it, makes it something else.
please guide me in this regard. i need a little detail because i have worked on it for the last 2 days but to now avail.
regards