1
\$\begingroup\$

I am stuck with a very trivial coding issue. Please refer the link below: Cordic Algorithm using Verilog enter image description here

By what mathematical rule hex 26dd2b6a is equal to 0.607252935008814?

\$\endgroup\$
2
  • 3
    \$\begingroup\$ My best guess is Single precision IEEE 754. \$\endgroup\$
    – Janka
    Sep 17 at 0:00
  • \$\begingroup\$ Some kind of scaling for the units being used. Maybe it represents a fraction of 2*pi? \$\endgroup\$
    – SteveSh
    Sep 17 at 0:04
5
\$\begingroup\$

The number appears to be encoded as a fixed point similar to Q1.30 Q-format by Texas Instruments

If you take the 0x26dd3b6a and divide it by 0x40000000 you will get the expected value 0.6072529350

You may use Calculator in Windows, switch it to Programmer view, select HEX and paste your hex string. Then convert to decimal. You may need to copy to clipboard before switching to standard or scientific calculator mode where you can display real numbers (and divide by the decadic equivalent of 0x40000000).

Since all of your constants are positive it is hard to tell whether the intended format is signed or unsigned.

In other words (assuming unsigned) the two MSB bits are the integral part and the remaining 30 bits are the fractional part.

If the format is signed (as the Q1.30 would be) then the MSB is sign bit followed by the integral part and 30 bits of the fractional part. (Doesn't make any difference here for positive numbers < 2.0).

\$\endgroup\$
6
  • \$\begingroup\$ Thank you @Martin. How to do this division?. I am really stuck in a debugging kind of issue. \$\endgroup\$
    – Deepika
    Sep 17 at 2:13
  • \$\begingroup\$ Why you divide by 0x3fffffff, but not by 0x4fffffff. Please eloborate \$\endgroup\$
    – Deepika
    Sep 17 at 2:41
  • \$\begingroup\$ @Deepika To answer the two questions: - Why to divide by 0x3fffffff? This is a binary number that has all 30 least significant bits set. This is equivalent to the highest value that can be expressed by your fractional portion. The correct answer is actually not 0x3fffffff nor 0x4ffffff but 0x400000. (Tiniest difference but still ;-)) - How to do the division? Convert your hex numbers to decadic and use calculator, right? 0x26DD3B6A/0x40000000=652032874/1073741824 = 0.607252935 \$\endgroup\$ Sep 17 at 3:16
  • \$\begingroup\$ Hi @Martin Vana, suppose the number is 0x 5c33, then with what hex number should be divide. I really apolozise for asking so basic questions. \$\endgroup\$
    – Deepika
    Sep 17 at 4:30
  • \$\begingroup\$ I think 0x5c33 be divided by 0x7FFF? \$\endgroup\$
    – Deepika
    Sep 17 at 4:45
2
\$\begingroup\$

h26DD3B6A is a straight binary fraction of 2^30

Converting to decimal, h26DD3B6A is d652,032,874
Converting 2^30 to decimal: d1,073,741,824

\${{652032874}\over{1073741824}} = 0.607252934\$

I'd guess those two leading bits of the 32-bit number have something to do with signs.

\$\endgroup\$
0
1
\$\begingroup\$

Go ahead and try things like little or big endian 32-bit IEEE754 floats, or fractional signed numbers, seeing all these are < 1.

But honestly, in FPGAs your bitwidths are scaled by the operations that you apply, and these values might literally just have one proportionality factor specified elsewhere.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.