- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I looked through the help for lpm_add_sub megafunction <http://quartushelp.altera.com/9.1/mergedProjects/hdl/mega/mega_file_lpm_add_sub.htm>
and couldn't really figure out if the input/output bits are set to, for example, 16, would the output give out 16MSB or 16LSB? Appreciate your help here. ((fyi -- lpm_mult outputs msb if output bits are restricted, while altmult_complex truncates msb if output bits are restricted))Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The general rule is MSBs for any arithmetic function.
Why are you using lpm_add_sub anyway when c <= a + b; in VHDL (and similar is available in verilog) is much much simpler to write and understand.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure if I understood the question but are you saying if you configured the A and B inputs to be 16 bits wide each and the result 16 bits wide what result bits would you get?
A 16 bit value + 16 bit value results in a 17 bit result due to carry over, lets call these bits [16..0] The result port of the LPM will give you bits [15..0] of the answer and [16] will wire up to the "cout" signal (carry out) So if you want the full 17 bits of resolution just combine the cout to the result like this (verilog): assign full_result = {cout, result}; // one bit concatenated in front of 16 bits- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unlike lpm_mult, lpm_add_sub has no option to truncate bits.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page