Set random seed.
- Overview
- A function to set the random seed in the testbench. The seed is set based on the following prioritization:
- The setting of the NVHLS_RAND_SEED environment variable at runtime
- The setting of the NVHLS_RAND_SEED CFLAG at compile time (or via #define in a source file)
- A random seed of 0 (deterministic)
WARNING: The user-defined random seed may be overriden in cosimulation, causing SCVerify to always simulate with an effective seed of 0. To work around this, call set_random_seed() inside an SC_THREAD instead of in sc_main.
- A Simple Example
#include <nvhls_rand.h>
int sc_main(int argc, char *argv[]) {
testbench tb("tb");
sc_report_handler::set_actions(SC_ERROR, SC_DISPLAY);
sc_start();
bool rc = (sc_report_handler::get_count(SC_ERROR) > 0);
if (rc)
DCOUT(
"TESTBENCH FAIL" << endl);
else
DCOUT(
"TESTBENCH PASS" << endl);
return rc;
};
int set_random_seed()
Set random seed.
Definition at line 60 of file nvhls_rand.h.