- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys.
I want to do multiplication operation. My data a is 8 bits and data B also 8 bits. Then, the width will be 16 bits when I used lpm_mult. Is there any method to reduce the output to 8 bits? Thanks in advance.Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In any case by reducing the output to 8 bit you lose some information.
You can take the higher 8bits of the result and discard the low significant digits (bits) Or you can take the lower 8bits if you need to keep the same units as inputs, but in most cases your result would overflow. In general you xtract any 8bit part at a convenient offset. The choice depends on what's the multiplication and result purpose.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Cris72.
Thanks for your respond. Is it ok if I just xtract any 8bits same as you said eventhough the result of multiplication will be different. For example, dataa=128 (decimal) and datab=5(decimal). It should be 640. I have try just xtract any 8bits, the result is 50 (decimal). I need 8 bit because I want to display the data on VGA monitor.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that 640 won't fit in 8 bits. You need to implement this as a 16bit number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it is unclear what you want. How does data you want to send to VGA related to multiplication.
out_data(7 downto 0) <= mult_result(i+7 downto i); -- adjust your i
it seems strange. If you must show the result of multiplication your need other approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
wonder for 16 bit down to 8 bit data type, sound like in certain value it may get truncated, possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can just take the 8 MSBs (with rounding if you want). As long as you understand that this number is really X*256 then there is no problem. Ie. You can fit 640 into 8 bits if thats how you understand it. you can even use appropriate range definitions:
signal x : unsigned(15 downto 8); NOTE: the numeric_std library does NOT respect bit position when doing arithmatic. You need to do this yourself by extending the arrays yourself before the functions. The fixed point libraries do keep bit positions however.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tricky is right for this part.

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