Jump to content

How to separate decimals and integers on the FPGA side?


Recommended Posts

On 4/19/2024 at 5:09 AM, Neil Pate said:

This question can be interpreted a bunch of ways. Can you explain with a bit more detail? Maybe show us some pictures?

 

Firstly thank you very much for your reply! My idea is simple, input a fixed point number and how to output its integer part separately from its decimal part. For example, if the input is 1.5, the output will be 1 and 0.5.🤪

Link to comment
On 4/19/2024 at 5:09 AM, Neil Pate said:

This question can be interpreted a bunch of ways. Can you explain with a bit more detail? Maybe show us some pictures?

 

I seem to have implemented this feature. Using the module round toward-infinity. That should do it, right?🤨

DY1E7S@LT0E2C8_5`XP_OUJ.png

Link to comment

No, that probably doesn't work how you expect for negative numbers. Fortunately, for fixed point numbers, the decimals are just the least significant bits. The cool thing about that approach is that the code is just a wiring operation and thus uses ~0 resources and 0 time to calculate.

 

wiring to get least significant bits.png

Link to comment
7 hours ago, infinitenothing said:

No, that probably doesn't work how you expect for negative numbers. Fortunately, for fixed point numbers, the decimals are just the least significant bits. The cool thing about that approach is that the code is just a wiring operation and thus uses ~0 resources and 0 time to calculate.

 

wiring to get least significant bits.png

If my requirement does not include the case of negative numbers, can I use the procedure I wrote above.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.