Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16597 Discussions

The lpm_add_sub and lpm_mult both have option to select input type as signed/unsigned

Altera_Forum
Honored Contributor II
1,161 Views

In case of 2's complement, addition and subtraction are the same. I am not sure about multiplication though. Therefore, what difference does it make if we select the input type as being signed or unsigned for the lpm_add_sub and lpm_mult? Does the way to carry out addition or subtraction actually change if we select the input type as being signed or unsigned?

0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
427 Views

 

--- Quote Start ---  

In case of 2's complement, addition and subtraction are the same. I am not sure about multiplication though. Therefore, what difference does it make if we select the input type as being signed or unsigned for the lpm_add_sub and lpm_mult? Does the way to carry out addition or subtraction actually change if we select the input type as being signed or unsigned? 

--- Quote End ---  

 

 

For +/- Yes it does with respect to carry bit for example [001] +[111] (+1-1) should be zero if signed but would be 8 [1000] if unsigned. Apart from that they are same. 

 

The main advantage of 2's complement system is just that +/- become same as unsigned apart from above. mult is different
0 Kudos
Altera_Forum
Honored Contributor II
427 Views

 

--- Quote Start ---  

Yes it does with respect to carry bit for example [001] +[111] (+1-1) should be zero if signed but would be 8 [1000] if unsigned. Apart from that they are same. 

--- Quote End ---  

 

That's not how lpm_add_sub works. Carry bit generation is the same for signed and unsigned, please try. The only difference is in the generation of optional overflow bit. 

 

Your example isn't quite right. In case of signed number you'll either add 3 bit number, then the there's no fourth result bit. Or you have four bit numbers, then you get [0001]+[1111] = [0000].
0 Kudos
Reply