View unanswered posts | View active topics It is currently Tue Apr 16, 2024 10:06 pm



Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3
 g-core 
Author Message

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
I'm just going gung-ho on the posit number operations.
I’ve been trying to implement a posit number square root function (for FPGA hardware) and it works for even exponent sizes but not for odd sizes. It has me stumped at the moment. It appears to be the size of the exponent, not the value that is causing issues.

For es = 6:
Code:
Input       Square#1     Square#2     Root
 xxxxxxxx   42000000   42000000   41000000
 4ed171e1   4ed171e1   4ed171e1   47678e2b
 4e9f7a6b   4e9f7a6b   4e9f7a6b   474a0e34
 4f6a1ca8   4f6a1ca8   4f6a1ca8   47ad1b9c
*b0ef1e32   80000000   80000000   80000000
 4f52510a   4f52510a   4f52510a   47a41322
*4f717615   4f717612   4f717612   47afcdd1
*b0b23190   80000000   80000000   80000000
*b08f434a   80000000   80000000   80000000
*b09f6fae   80000000   80000000   80000000
*4f40f04c   4f40f04a   4f40f04a   479d266b
*b0e14da7   80000000   80000000   80000000
*4eac47b2   4eac47b3   4eac47b3   47520241


For es = 5 (same numbers) exponent appears to be off by one, significand looks okay
Code:
  Input      Square#1     Square#2      Root
 xxxxxxxx   44ffffff      44ffffff      426a09e6
*5da2e3c0   5ca2e3be   5ca2e3be   4e4777fc
*5d3ef4d6   5c3ef4d6   5c3ef4d6   4e1dbfe6
*5ed4394f   5fd43950   5fd43950   4fe99f79
*a1de3c63   80000000   80000000   80000000
*5ea4a215   5fa4a214   5fa4a214   4fd012cd
*5ee2ec2b   5fe2ec2b   5fe2ec2b   4ff13faf
*a1646321   80000000   80000000   80000000
*a11e8693   80000000   80000000   80000000
*a13edf5e   80000000   80000000   80000000
*5e81e098   5f81e097   5f81e097   4fbc7cd0
*a1c29b4c   80000000   80000000   80000000
*5d588f65   5c588f65   5c588f65   4e28ff4f
*5ea1d9e9   5fa1d9e8   5fa1d9e8   4fce894a

I'm comparing the square of the calculated root to the input.

_________________
Robert Finch http://www.finitron.ca


Sun Apr 19, 2020 10:20 am
Profile WWW

Joined: Wed Apr 24, 2013 9:40 pm
Posts: 213
Location: Huntsville, AL
Rob:

I am interested in your successes with posits. When you're finished, will you be posting / releasing some information on their implementation.

Read your comment on issue you're having with odd-sized exponent fields and computing the square roots for such posits. In the short run, why not reformat the posit into one with an even length square root? I would think that one of the fundamental components of your posit library would be format conversions, especially to support addition / subtraction.

_________________
Michael A.


Mon Apr 20, 2020 1:04 am
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
Okay, I have put some code for posit arithmetic in Github under cores/thor/trunk/thor2020/v3/rtl//fpu. The same code is also available in opencores.org under the Float816 floating-point accelerator project.
Much of this work is based on the PACoGEN project in github. A good site for posits: posithub.org

Quote:
Read your comment on issue you're having with odd-sized exponent fields and computing the square roots for such posits. In the short run, why not reformat the posit into one with an even length square root? I would think that one of the fundamental components of your posit library would be format conversions, especially to support addition / subtraction.
I put code in to shift the number by a bit if es is odd and that seems to work, but it probably is just masking a greater issue.

Currently implemented:
intToPosit
fpToPosit
positTofp
positAddsub
positMul
positSqrt

no divide yet.

_________________
Robert Finch http://www.finitron.ca


Mon Apr 20, 2020 3:43 am
Profile WWW

Joined: Wed Apr 24, 2013 9:40 pm
Posts: 213
Location: Huntsville, AL
Thanks for the link. Haven't had time to fully delve into the paper or your code.

However, one thing that I found intriguing was that, within what appeared to be a somewhat reasonable approximation, inversion (1/x) was somewhat easy to achieve. If that's the case, what's to prevent you from implementing division as inversion followed by multiplication.

That is the approach that I used to implement fixed point division. I used the Goldschmidt square root algorithm which computes both the square root and the inverse of the square root. Since I needed the square root to solve the law of cosines, and I only needed to perform a division once per computational cycle, I used the square of the inverse of the square root followed by multiplication to implement that division operation that I needed. (The quantity for which I was computing the square root was always positive and non-zero.)

_________________
Michael A.


Tue Apr 21, 2020 4:05 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 34 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software