01-25-2021 08:45 AM
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.
01-25-2021 03:24 PM
>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.