for loop with real

Guest #3611559
Hi everyone!

I would like to create a for loop for code like this:

if input >= 1.0 then output = 11111111111111
if input =0.999878 then output = 11111111111110
if input =0.999756 then output = 11111111111101
.
.
.
.
.
if input = -0.999878 then output = 10000000000001
if input <= -1.0 then output = 10000000000000


It seams to be simple but apparently the paramater of the for loop can't 
be of real type. Do you know an other way to do the same thing I want 
but real compatible please ??
Moderator (Company: Titel)
angelo wrote:
> Do you know an other way to do the same thing I want but real compatible
> please ??
Is this for simulation only or must it be implemented on real hardware?


BTW: when I look at your code then I am fairly sure that there is a kind 
of algorithm or a formula to calculate the result...
Guest
For-loops with real/float types are allowed, but not always useful.

In this case I would use a linear function with no loop at all.

Something like "output = (input+1)*8192". Try it for a few input values.
Guest
Lothar Miller wrote:
> Is this for simulation only or must it be implemented on real hardware?

Yes is this for simulation, I know real is not synthesizable.

Tom wrote:
> Something like "output = (input+1)*8192". Try it for a few input values.

Tom, few adaptations your code and that gives me exactly I want, thank 
you a lot!

Reply

A question of your own? This thread is over 12 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.