MatchLib
Functions

Set random seed. More...

Functions

int nvhls::set_random_seed ()
 Set random seed. More...
 

Detailed Description

Set random seed.

Function Documentation

int nvhls::set_random_seed ( )
inline

Set random seed.

Overview
A function to set the random seed in the testbench. The seed is set based on the following prioritization:
  1. The setting of the RAND_SEED environment variable at runtime
  2. The setting of the RAND_SEED CFLAG at compile time (or via #define in a source file)
  3. A random seed based on the unix timestamp at runtime

WARNING: The RAND_SEED will 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;
};

Definition at line 61 of file nvhls_rand.h.