Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

not random at each execution

Hi all,

I have a problem with generating a random from the uniform function, it is always the same with each execution of the process.

I have attached a piece of code to the testbench.

If someone gets to see where it's wrong. Thank you

16 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    For testing, you NEED re-createable results, so having it fully random would be of a hinderance rather than a help.

    On hardware, you cannot even use the uniform function, so you will need some form of random number generator. You could use an LFSR, but it works similarly, in that once you give it a seed you'll get the same sequence.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    For testing, you NEED re-createable results, so having it fully random would be of a hinderance rather than a help.

    On hardware, you cannot even use the uniform function, so you will need some form of random number generator. You could use an LFSR, but it works similarly, in that once you give it a seed you'll get the same sequence.

    --- Quote End ---

    Okay. I'll try a pseudo RNG that i have .

    It is clear I will be able to change his seed. After I will try to see how to make it change with each simulation launch.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Okay. I'll try a pseudo RNG that i have .

    It is clear I will be able to change his seed. After I will try to see how to make it change with each simulation launch.

    --- Quote End ---

    The best way to do it is to have a generic that assigns the seed, then you can assign this when you launch the simulation.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    [h=3]Okay, Good idea.

    Another question that I am asking, if I can have the effect random but Synthesizable on FPGA ?

    thank you

    [/h]
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    [h=3]Okay, Good idea.

    Another question that I am asking, if I can have the effect random but Synthesizable on FPGA ?

    thank you

    [/h]

    --- Quote End ---

    uniform is not a synthesisable function, as real types are not synthesisable

    You will need to build a LFSR, which generates a pseudo random sequence, otherwise you'll have to investigate other methods of generating random numbers in FPGA.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Okay, i will try to integrate the LFSR into my system. thank for the proposition.

    see you soon