cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rdb98791
Adventurer
Adventurer
326 Views
Registered: ‎03-05-2020

constant random number generation (pre-synthesis)

I am trying to allow a random number generator to dictate which RTL entities gets instantiated in a long stream of logic blocks (maybe think of it as auto-generated code). I basically have a constant "seed" value that is fed into a function that calls "UNIFORM" of the ieee.math_real package, and the output of this is converted to an integer assigned to a constant. The RTL code will then use this integer as part of a "generate" statement to decide what entity to instantiate.

Nothing I am doing should require any "real" data types to be inferred: Everything is either a constant, a function that inputs/outputs constant, and "generate" statements that utilize the constant. This all works in simulation.

However, Vivado will not allow me to synthesis with any code containing the "UNIFORM" function, as this requires the use of a "real" variable, and apparently Vivado not smart enough to realize that the real variable is only an intermediate variable used to generate a constant.

I'm getting "non-constant real-valued expression is not supported."

Is there another way to achieve what I am trying to do? I just need to be able to generate random integer constants for use in generate statements.

 

 

0 Kudos
1 Reply
maps-mpls
Mentor
Mentor
286 Views
Registered: ‎06-20-2017

>Is there another way to achieve what I am trying to do? I just need to be able to generate random integer constants for use in generate statements.

Look into LFSRs with maximal length primitive polynomials.  Create some functions in a package that uses these to generate a PRN based on a seed.  Make your seed your top level generic.  Use tcl to override that top level generic based on, for example, the date/time you start your synthesis.

Some references:  https://www.xilinx.com/support/documentation/application_notes/xapp210.pdf (This is for synthesizable LFSRs but you don't need that, the text might be useful for backup.  Also these things are pretty trivial to code up)

Chapter 16 of Applied Cryptography (more theory, more tap tables than the above)

There are other probably less elaborate ways to accomplish what you want, but I've done similar to above in a slightly different application.

*** Destination: Rapid design and development cycles *** Unappreciated answers get deleted, unappreciative OPs get put on ignored list ***
0 Kudos