Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is $random considered a "forbidden system function or task"? #2221

Open
benjamin051000 opened this issue Aug 2, 2024 · 2 comments
Open

Comments

@benjamin051000
Copy link

invalid-system-task-function states:

Checks that no forbidden system tasks or functions are used. These consist of the following functions: $psprintf, $random, and $dist_*. As well as non-LRM function $srandom. See [Style: forbidden-system-functions].

When I use $random in a SystemVerilog file, Verible prints this warning:

1. $random is a forbidden system function or task, please use $urandom instead [Style: forbidden-system-functions][invalid-system-task-function]

I'm curious as to why it's discouraged to use $random and instead use $urandom. Forgive me, I'm pretty new to verilog & systemverilog. Thanks for the clarification!

@hzeller
Copy link
Collaborator

hzeller commented Aug 5, 2024

I think that was mostly a request by DV engineers that like to inject better ways to get test vector, though it would probably good to have that as an explicit style guide somewhere so that it is easy to refer to.

Maybe @fangism remembers the details ?

@snsokolov
Copy link
Contributor

$random breaks reproducibility:

Quote from the style guide:
"$random and $dist_*: these functions should not be used as they are not part of the SystemVerilog random stability model and may break simulation reproducibility. Use $urandom or randomize() instead."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants