Nazar R. wrote:> Can eny one help me?
1.) Read the manual of the edit box:

1

Reply

2

Rules — please read before posting

3

:

4

Formatting options

5

:

6

[vhdl]VHDL code[/vhdl]

2.) Use indention and advanced formatting to get a readable code.

1

ifsqrt(sqrt1)mod1.0/=0.0then

2

whilesqrt(sqrt1+k1*p1)mod1.0/=0.0loop

3

k1<=k1+1.0;

4

exitwhensqrt(sqrt1+k1*p1)mod1.0>0.0;

5

endloop;

6

g1<=sqrt(sqrt1+k1*p1)modp1;

7

else

8

g1<=sqrt(sqrt1)modp1;

9

endif;

3.) What data types have the used signals?
Integer? Real?
> p1=< 28623421
What is "p1"? Is it the input parameter for the incomplete function or
the unknown process?
> For example p1=< 28623421, sqrt1 >= p1.
What does that mean? What do you expect? What do you get instead? And
HOW do you get that?
Simply attach the complete *.vhd file...

Nazar R. wrote:> it dosen`t work corectly with big data(number). For example p1=<> 28623421, sqrt1 >= p1. Can eny one help me?
I suppose you simply have a problem with the number of significant
digits of a real number.
See that: http://codepad.org/s4xolHhg

Nazar R. wrote:> this part of code must work with real type
What figures/value/nubmers have those parameters?
Or the other way: show your complete code and the corresponding test
bench. Otherwise we will not get a point here... :-/

why? if you try to write this sentens into the paper and do some math
you have tru answer. in this line i do some chek, if sqrt1... after do
mod operation exit the 0 state

out of the mist wrote:> mod is defined for integers but not for real.
Only in C...
But look at this:
http://codepad.org/1q85mdCr
A float value nearly never is something like .0000000!
Its more something like .00001 or .999999
Nearly never the result of that operation will be 0.0

Hi Nazar,
sqrt(sqrt1) mod 1.0 is almost ALWAYS unequal 0.0 if sqrt1 is a
floating point number.
Think about it.
Try 1.0 mod 1.0 and 0.9999999999 mod 1.0
and let us know the result

in my work i use real type bacause i use sqrt operators a lot of time,
thets why i convert all of my variables to real from integer type. all
operations in the my model give me result in some sing like that 100.0,
152.0, 343558137.0

Martin wrote:> mod 1.0 is almost ALWAYS unequal 0.0
Or the other way: NEVER EVER compare a float value to equality
Even if two float numbers "look" the same, they may be different:
http://codepad.org/FO8DdkGkNazar R. wrote:> all operations in the my model give me result in some sing like that> 100.0, 152.0, 343558137.0
No, they don't. Think about that, its a "problem" of how a real value is
defined in IEEE 754.

Nazar R. wrote:> write in the calc
In which one?
> 123 mod 1
The mod function is NOT the problem here.
> i dont know how discribe you my problem
Looks alike...
Nazar R. wrote:> all operations in the my model give me result in some sing like that> 100.0, 152.0, 343558137.0
Where do you see this values?
For those .0 values have a look there:
http://codepad.org/SlmEEkho
You CANNOT compare a float number for equality...

Nazar R. wrote:> do you have active-hdl?
Yes. Active HDL also uses the IEE 754 format. And therefore it also has
the same restrictions...
> do you have active-hdl?
But as I already said several times: post your complete VHDL file (as
a *.vhd or *.vhdl file pls!) and the test bench so everybody else can
test your specific problem on his simulator. You can attach several
files to one post...

> use IEEE.std_logic_unsigned.all;> use IEEE.std_logic_signed.all;> use ieee.numeric_std.all;> use IEEE.std_logic_arith.all;
Ouch, ouch, ouch, ouch...
EITHER use the use numeric_std (best and preferred choice)
OR use those two: std_logic_signed and std_logic_arith
OR use those two: std_logic_unsigned and std_logic_arith
BUT do NOT use all of them together. Otherwise you have multiple type
definitions and therfore sometimes very weird behaviour...
Nazar R. wrote:> sorry i attach only bench file before
A test bench usually is a *.vhd module WITHOUT ports in the entity. I
will have a look at that tomorrow, now I'm away for the night... ;-)

The entity has only one input but no output.
You use conflicting IEEE packages.
But the main problem is comparing float as Lothar has told you.
Will the compare for equality ever return true? When? Only when it is
exactly equal which might be very rare. You could compare if the float
value is in a given range. E.g. if the value is greater 0.0 and smaller
0.1.

This will never happen:
> exit when sqrt(sqrt1+k1*p1) mod 1.0 > 1.0;
Something mod 1.0 is always less then 1.0
Therefore this "exit" is useless and obsolete.
I took your code and transferred it into a little bit more handy test
bench. My conclusion: I can se no sense in those calculations. With the
values in the code I have 1.5 million loop iterations...
So the big question is:
What should this code do? Whats the origin of this code? Whats its
purpose?

So, let's again. I am engaged in developing advanced algorithm Rabin
among Atstsdf. Part of my code should find the square root of a number.
Do I have to check this number due to the fact that this number must
then be multiplied by the transaction module and there should get an
integer. small numbers I come out all right, here's an example I attach
a file, it should just run. I ask if large numbers fixate the process of
calculating and never stops

Nazar R. wrote:> I am engaged in developing advanced algorithm Rabin among Atstsdf.
Must this code be implemented on a FPGA in future? Then forget about
real...
> here's an example I attach a file, it should just run.
And what should happen?
> here's an example I attach a file, it should just run.
Attach a second one that doesn't "run". And tell how you can see that...
> exit when sqrt(sqrt1+k1*p1) mod 1.0 < 1.0;
Something mod 1.0 is ALWAYS less then 1.0, so here the loop will ALWAYS
be terminated...
Did you read the post https://embdev.net/topic/384548#4390186
Did you understand it?
Let me say it this way: I've shown you some major design flaws and you
ignored all of that hints. I've also shown you a way to set up a
little bit more "talky" test bench and you dig further on with your
code. What do you expect as "help"?