Altera_Forum
Honored Contributor
15 years agostrange behaviour of square root VHDL code
I need a plain VHDL-square root code for a special purpose and used "google code search".
I thus found the following code in their files, obviously written by Altera. http://www.google.com/codesearch/p?hl=de#twz1piy0-yo/trunk/fpc/mathlib/fp_sqrroot.vhd&q=fp_sqrroot%20lang:vhdl&sa=n&cd=1&ct=rc (Also try "fp_sqrroot lang:vhdl" in google's search box.) I tried to simulate it and found weird results shown in the attached graphics. It seems to be a problem of the bit "N-1". I tried with 40bits and 52 bits as well. As soon as this bit is "1" the output behaves like a root function - optically prooved. But if the bit is 0 with lower radicants, the output appears inverted like "x - root()".:confused: Could someone pleae explain this behaviour?? I think there is a bug in the code or something is missing since e.g. the signal "onevec" is declared and also set but never used. Any ideas? Is that an Altera Code? I have also the files themselves attached, to make it easier ti simulate it.